1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | define ('PHPWG_ROOT_PATH', './'); |
---|
25 | |
---|
26 | include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); |
---|
27 | check_status(ACCESS_FREE); |
---|
28 | include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php'); |
---|
29 | |
---|
30 | if ( !$conf['allow_web_services'] ) |
---|
31 | { |
---|
32 | page_forbidden('Web services are disabled'); |
---|
33 | } |
---|
34 | |
---|
35 | /** |
---|
36 | * event handler that registers standard methods with the web service |
---|
37 | */ |
---|
38 | function ws_addDefaultMethods( $arr ) |
---|
39 | { |
---|
40 | include_once(PHPWG_ROOT_PATH.'include/ws_functions.inc.php'); |
---|
41 | global $conf, $user; |
---|
42 | $service = &$arr[0]; |
---|
43 | $service->addMethod('pwg.getVersion', 'ws_getVersion', null, |
---|
44 | 'retrieves the PWG version'); |
---|
45 | |
---|
46 | $service->addMethod('pwg.getInfos', 'ws_getInfos', null, |
---|
47 | 'retrieves general informations'); |
---|
48 | |
---|
49 | $service->addMethod('pwg.caddie.add', 'ws_caddie_add', |
---|
50 | array( |
---|
51 | 'image_id'=> array( 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
52 | ), |
---|
53 | 'adds the elements to the caddie'); |
---|
54 | |
---|
55 | $service->addMethod('pwg.categories.getImages', 'ws_categories_getImages', |
---|
56 | array( |
---|
57 | 'cat_id'=>array('default'=>0, 'flags'=>WS_PARAM_FORCE_ARRAY), |
---|
58 | 'recursive'=>array('default'=>false), |
---|
59 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
60 | 'page' => array('default'=>0), |
---|
61 | 'order' => array('default'=>null), |
---|
62 | 'f_min_rate' => array( 'default'=> null ), |
---|
63 | 'f_max_rate' => array( 'default'=> null ), |
---|
64 | 'f_min_hit' => array( 'default'=> null ), |
---|
65 | 'f_max_hit' => array( 'default'=> null ), |
---|
66 | 'f_min_date_available' => array( 'default'=> null ), |
---|
67 | 'f_max_date_available' => array( 'default'=> null ), |
---|
68 | 'f_min_date_created' => array( 'default'=> null ), |
---|
69 | 'f_max_date_created' => array( 'default'=> null ), |
---|
70 | 'f_min_ratio' => array( 'default'=> null ), |
---|
71 | 'f_max_ratio' => array( 'default'=> null ), |
---|
72 | 'f_max_level' => array( 'default'=> null ), |
---|
73 | ), |
---|
74 | 'Returns elements for the corresponding categories. |
---|
75 | <br><b>cat_id</b> can be empty if <b>recursive</b> is true. Can be sent as an array. |
---|
76 | <br><b>order</b> comma separated fields for sorting (file,id, rating_score,...)' |
---|
77 | ); |
---|
78 | |
---|
79 | $service->addMethod('pwg.categories.getList', 'ws_categories_getList', |
---|
80 | array( |
---|
81 | 'cat_id' => array('default'=>0), |
---|
82 | 'recursive' => array('default'=>false), |
---|
83 | 'public' => array('default'=>false), |
---|
84 | 'tree_output' => array('default'=>false), |
---|
85 | 'fullname' => array('default'=>false), |
---|
86 | ), |
---|
87 | 'retrieves a list of categories (tree_output option only compatible with json/php output format' ); |
---|
88 | |
---|
89 | $service->addMethod('pwg.getMissingDerivatives', 'ws_getMissingDerivatives', |
---|
90 | array( |
---|
91 | 'types' => array( 'default'=>array(), 'flags'=>WS_PARAM_FORCE_ARRAY), |
---|
92 | 'ids' => array( 'default'=>array(), 'flags'=>WS_PARAM_FORCE_ARRAY), |
---|
93 | 'max_urls' => array( 'default' => 200 ), |
---|
94 | 'prev_page' => array( 'default'=> null), |
---|
95 | 'f_min_rate' => array( 'default'=> null ), |
---|
96 | 'f_max_rate' => array( 'default'=> null ), |
---|
97 | 'f_min_hit' => array( 'default'=> null ), |
---|
98 | 'f_max_hit' => array( 'default'=> null ), |
---|
99 | 'f_min_date_available' => array( 'default'=> null ), |
---|
100 | 'f_max_date_available' => array( 'default'=> null ), |
---|
101 | 'f_min_date_created' => array( 'default'=> null ), |
---|
102 | 'f_max_date_created' => array( 'default'=> null ), |
---|
103 | 'f_min_ratio' => array( 'default'=> null ), |
---|
104 | 'f_max_ratio' => array( 'default'=> null ), |
---|
105 | 'f_max_level' => array( 'default'=> null ), |
---|
106 | ), |
---|
107 | 'retrieves a list of derivatives to build' ); |
---|
108 | |
---|
109 | $service->addMethod('pwg.images.addComment', 'ws_images_addComment', |
---|
110 | array( |
---|
111 | 'image_id' => array(), |
---|
112 | 'author' => array( 'default' => is_a_guest()? 'guest':$user['username']), |
---|
113 | 'content' => array(), |
---|
114 | 'key' => array(), |
---|
115 | ), |
---|
116 | 'add a comment to an image' ); |
---|
117 | |
---|
118 | $service->addMethod('pwg.images.getInfo', 'ws_images_getInfo', |
---|
119 | array( |
---|
120 | 'image_id' => array(), |
---|
121 | 'comments_page' => array('default'=>0 ), |
---|
122 | 'comments_per_page' => array( |
---|
123 | 'default' => $conf['nb_comment_page'], |
---|
124 | 'maxValue' => 2*$conf['nb_comment_page'], |
---|
125 | ), |
---|
126 | ), |
---|
127 | 'retrieves information about the given photo' ); |
---|
128 | |
---|
129 | $service->addMethod('pwg.images.rate', 'ws_images_rate', |
---|
130 | array( |
---|
131 | 'image_id' => array(), |
---|
132 | 'rate' => array(), |
---|
133 | ), |
---|
134 | 'rate the image' ); |
---|
135 | |
---|
136 | $service->addMethod('pwg.images.search', 'ws_images_search', |
---|
137 | array( |
---|
138 | 'query'=>array(), |
---|
139 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
140 | 'page' => array('default'=>0), |
---|
141 | 'order' => array('default'=>null), |
---|
142 | 'f_min_rate' => array( 'default'=> null ), |
---|
143 | 'f_max_rate' => array( 'default'=> null ), |
---|
144 | 'f_min_hit' => array( 'default'=> null ), |
---|
145 | 'f_max_hit' => array( 'default'=> null ), |
---|
146 | 'f_min_date_available' => array( 'default'=> null ), |
---|
147 | 'f_max_date_available' => array( 'default'=> null ), |
---|
148 | 'f_min_date_created' => array( 'default'=> null ), |
---|
149 | 'f_max_date_created' => array( 'default'=> null ), |
---|
150 | 'f_min_ratio' => array( 'default'=> null ), |
---|
151 | 'f_max_ratio' => array( 'default'=> null ), |
---|
152 | 'f_max_level' => array( 'default'=> null ), |
---|
153 | ), |
---|
154 | 'Returns elements for the corresponding query search.' |
---|
155 | ); |
---|
156 | |
---|
157 | $service->addMethod( |
---|
158 | 'pwg.images.setPrivacyLevel', |
---|
159 | 'ws_images_setPrivacyLevel', |
---|
160 | array( |
---|
161 | 'image_id' => array('flags'=>WS_PARAM_FORCE_ARRAY), |
---|
162 | 'level' => array('maxValue'=>$conf['available_permission_levels']), |
---|
163 | ), |
---|
164 | 'sets the privacy levels for the images (POST method only)' |
---|
165 | ); |
---|
166 | |
---|
167 | $service->addMethod( |
---|
168 | 'pwg.images.setRank', |
---|
169 | 'ws_images_setRank', |
---|
170 | array( |
---|
171 | 'image_id' => array(), |
---|
172 | 'category_id' => array(), |
---|
173 | 'rank' => array(), |
---|
174 | ), |
---|
175 | 'sets the rank of a photo for a given album (POST method only, for admins)' |
---|
176 | ); |
---|
177 | |
---|
178 | |
---|
179 | $service->addMethod('pwg.rates.delete', 'ws_rates_delete', |
---|
180 | array( |
---|
181 | 'user_id' => array(), |
---|
182 | 'anonymous_id' => array( 'default'=>'' ), |
---|
183 | ), |
---|
184 | 'deletes all rates for a user (POST method only, admins only)' |
---|
185 | ); |
---|
186 | |
---|
187 | $service->addMethod('pwg.session.getStatus', 'ws_session_getStatus', null, '' ); |
---|
188 | $service->addMethod('pwg.session.login', 'ws_session_login', |
---|
189 | array('username', 'password'), |
---|
190 | 'POST method only' ); |
---|
191 | $service->addMethod('pwg.session.logout', 'ws_session_logout', null, ''); |
---|
192 | |
---|
193 | $service->addMethod('pwg.tags.getList', 'ws_tags_getList', |
---|
194 | array('sort_by_counter' => array('default' =>false) ), |
---|
195 | 'retrieves a list of available tags'); |
---|
196 | $service->addMethod('pwg.tags.getImages', 'ws_tags_getImages', |
---|
197 | array( |
---|
198 | 'tag_id'=>array('default'=>null, 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
199 | 'tag_url_name'=>array('default'=>null, 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
200 | 'tag_name'=>array('default'=>null, 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
201 | 'tag_mode_and'=>array('default'=>false), |
---|
202 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
203 | 'page' => array('default'=>0), |
---|
204 | 'order' => array('default'=>null), |
---|
205 | 'f_min_rate' => array( 'default'=> null ), |
---|
206 | 'f_max_rate' => array( 'default'=> null ), |
---|
207 | 'f_min_hit' => array( 'default'=> null ), |
---|
208 | 'f_max_hit' => array( 'default'=> null ), |
---|
209 | 'f_min_date_available' => array( 'default'=> null ), |
---|
210 | 'f_max_date_available' => array( 'default'=> null ), |
---|
211 | 'f_min_date_created' => array( 'default'=> null ), |
---|
212 | 'f_max_date_created' => array( 'default'=> null ), |
---|
213 | 'f_min_ratio' => array( 'default'=> null ), |
---|
214 | 'f_max_ratio' => array( 'default'=> null ), |
---|
215 | 'f_max_level' => array( 'default'=> null ), |
---|
216 | ), |
---|
217 | 'Returns elements for the corresponding tags. Note that tag_id, tag_url_name, tag_name an be arrays. Fill at least one of them. ' |
---|
218 | ); |
---|
219 | |
---|
220 | $service->addMethod( |
---|
221 | 'pwg.images.addChunk', |
---|
222 | 'ws_images_add_chunk', |
---|
223 | array( |
---|
224 | 'data' => array(), |
---|
225 | 'original_sum' => array(), |
---|
226 | 'type' => array(), |
---|
227 | 'position' => array(), |
---|
228 | ), |
---|
229 | 'POST method only. For admin only.' |
---|
230 | ); |
---|
231 | |
---|
232 | $service->addMethod( |
---|
233 | 'pwg.images.addFile', |
---|
234 | 'ws_images_addFile', |
---|
235 | array( |
---|
236 | 'image_id' => array(), |
---|
237 | 'type' => array(), |
---|
238 | 'sum' => array(), |
---|
239 | ), |
---|
240 | 'Add or update a file for an existing photo. pwg.images.addChunk must have been called before (maybe several times)' |
---|
241 | ); |
---|
242 | |
---|
243 | |
---|
244 | $service->addMethod( |
---|
245 | 'pwg.images.add', |
---|
246 | 'ws_images_add', |
---|
247 | array( |
---|
248 | 'file_sum' => array(), |
---|
249 | 'thumbnail_sum' => array('default' => null), |
---|
250 | 'high_sum' => array('default' => null), |
---|
251 | 'original_sum' => array(), |
---|
252 | 'original_filename' => array('default' => null), |
---|
253 | 'name' => array('default' => null), |
---|
254 | 'author' => array('default' => null), |
---|
255 | 'date_creation' => array('default' => null), |
---|
256 | 'comment' => array('default' => null), |
---|
257 | 'categories' => array('default' => null), |
---|
258 | 'tag_ids' => array('default' => null), |
---|
259 | 'level' => array( |
---|
260 | 'default' => 0, |
---|
261 | 'maxValue' => $conf['available_permission_levels'] |
---|
262 | ), |
---|
263 | 'check_uniqueness' => array('default' => true), |
---|
264 | 'image_id' => array('default' => null), |
---|
265 | ), |
---|
266 | 'POST method only. |
---|
267 | <br><b>categories</b> is a string list "category_id[,rank];category_id[,rank]" The rank is optional and is equivalent to "auto" if not given.' |
---|
268 | ); |
---|
269 | |
---|
270 | $service->addMethod( |
---|
271 | 'pwg.images.addSimple', |
---|
272 | 'ws_images_addSimple', |
---|
273 | array( |
---|
274 | 'category' => array('default' => null), |
---|
275 | 'name' => array('default' => null), |
---|
276 | 'author' => array('default' => null), |
---|
277 | 'comment' => array('default' => null), |
---|
278 | 'level' => array( |
---|
279 | 'default' => 0, |
---|
280 | 'maxValue' => $conf['available_permission_levels'] |
---|
281 | ), |
---|
282 | 'tags' => array('default' => null), |
---|
283 | 'image_id' => array('default' => null), |
---|
284 | ), |
---|
285 | 'POST method only.<br>Use the <b>image</b> field for uploading file.<br>Set the form encoding to "form-data"<br><b>category</b> is the numeric identifier of the destination category.<br>You can update an existing photo if you define an existing image_id.' |
---|
286 | ); |
---|
287 | |
---|
288 | $service->addMethod( |
---|
289 | 'pwg.images.delete', |
---|
290 | 'ws_images_delete', |
---|
291 | array( |
---|
292 | 'image_id'=>array('default'=>0), |
---|
293 | 'pwg_token' => array(), |
---|
294 | ), |
---|
295 | 'Delete photos. You can give several image_ids, comma separated' |
---|
296 | ); |
---|
297 | |
---|
298 | $service->addMethod( |
---|
299 | 'pwg.categories.getAdminList', |
---|
300 | 'ws_categories_getAdminList', |
---|
301 | array(), |
---|
302 | 'administration method only' |
---|
303 | ); |
---|
304 | |
---|
305 | $service->addMethod( |
---|
306 | 'pwg.categories.add', |
---|
307 | 'ws_categories_add', |
---|
308 | array( |
---|
309 | 'name' => array(), |
---|
310 | 'parent' => array('default' => null), |
---|
311 | ), |
---|
312 | 'administration method only' |
---|
313 | ); |
---|
314 | |
---|
315 | $service->addMethod( |
---|
316 | 'pwg.categories.delete', |
---|
317 | 'ws_categories_delete', |
---|
318 | array( |
---|
319 | 'category_id'=>array('default'=>0), |
---|
320 | 'pwg_token' => array(), |
---|
321 | 'photo_deletion_mode' => array('default' => 'delete_orphans'), |
---|
322 | ), |
---|
323 | 'Delete categories. You can give several category_ids, comma separated. |
---|
324 | <br><b>photo_deletion_mode</b> can be "no_delete" (may create orphan photos), "delete_orphans" (default mode, only deletes photos linked to no other album) or "force_delete" (delete all photos, even those linked to other albums)' |
---|
325 | ); |
---|
326 | |
---|
327 | $service->addMethod( |
---|
328 | 'pwg.categories.move', |
---|
329 | 'ws_categories_move', |
---|
330 | array( |
---|
331 | 'category_id'=>array('default'=>0), |
---|
332 | 'parent'=>array('default'=>0), |
---|
333 | 'pwg_token' => array(), |
---|
334 | ), |
---|
335 | 'Move categories. You can give several category_ids, comma separated. Set parent as 0 to move to gallery root. Only virtual categories can be moved.' |
---|
336 | ); |
---|
337 | |
---|
338 | $service->addMethod( |
---|
339 | 'pwg.categories.setRepresentative', |
---|
340 | 'ws_categories_setRepresentative', |
---|
341 | array( |
---|
342 | 'category_id'=>array('default'=>0), |
---|
343 | 'image_id'=>array('default'=>0), |
---|
344 | ), |
---|
345 | 'Set the representative photo for an album. The photo doesn\'t have to belong to the album. POST method only. Administration method only.' |
---|
346 | ); |
---|
347 | |
---|
348 | $service->addMethod( |
---|
349 | 'pwg.tags.getAdminList', |
---|
350 | 'ws_tags_getAdminList', |
---|
351 | array(), |
---|
352 | 'administration method only' |
---|
353 | ); |
---|
354 | |
---|
355 | $service->addMethod( |
---|
356 | 'pwg.tags.add', |
---|
357 | 'ws_tags_add', |
---|
358 | array( |
---|
359 | 'name' => array(), |
---|
360 | ), |
---|
361 | 'administration method only' |
---|
362 | ); |
---|
363 | |
---|
364 | $service->addMethod( |
---|
365 | 'pwg.images.exist', |
---|
366 | 'ws_images_exist', |
---|
367 | array( |
---|
368 | 'md5sum_list'=> array('default' => null), |
---|
369 | 'filename_list' => array('default' => null), |
---|
370 | ), |
---|
371 | 'check existence of a photo list' |
---|
372 | ); |
---|
373 | |
---|
374 | $service->addMethod( |
---|
375 | 'pwg.images.checkFiles', |
---|
376 | 'ws_images_checkFiles', |
---|
377 | array( |
---|
378 | 'image_id' => array(), |
---|
379 | 'thumbnail_sum' => array('default' => null), |
---|
380 | 'file_sum' => array('default' => null), |
---|
381 | 'high_sum' => array('default' => null), |
---|
382 | ), |
---|
383 | 'check if you have updated version of your files for a given photo, for each requested file type, the answer can be "missing", "equals" or "differs"' |
---|
384 | ); |
---|
385 | |
---|
386 | $service->addMethod( |
---|
387 | 'pwg.images.checkUpload', |
---|
388 | 'ws_images_checkUpload', |
---|
389 | null, |
---|
390 | 'check if Piwigo is ready for upload' |
---|
391 | ); |
---|
392 | |
---|
393 | $service->addMethod( |
---|
394 | 'pwg.images.setInfo', |
---|
395 | 'ws_images_setInfo', |
---|
396 | array( |
---|
397 | 'image_id' => array(), |
---|
398 | |
---|
399 | 'file' => array('default' => null), |
---|
400 | 'name' => array('default' => null), |
---|
401 | 'author' => array('default' => null), |
---|
402 | 'date_creation' => array('default' => null), |
---|
403 | 'comment' => array('default' => null), |
---|
404 | 'categories' => array('default' => null), |
---|
405 | 'tag_ids' => array('default' => null), |
---|
406 | 'level' => array( |
---|
407 | 'default' => null, |
---|
408 | 'maxValue' => $conf['available_permission_levels'] |
---|
409 | ), |
---|
410 | 'single_value_mode' => array('default' => 'fill_if_empty'), |
---|
411 | 'multiple_value_mode' => array('default' => 'append'), |
---|
412 | ), |
---|
413 | 'POST method only. Admin only |
---|
414 | <br><b>categories</b> is a string list "category_id[,rank];category_id[,rank]" The rank is optional and is equivalent to "auto" if not given. |
---|
415 | <br><b>single_value_mode</b> can be "fill_if_empty" (only use the input value if the corresponding values is currently empty) or "replace" (overwrite any existing value) and applies to single values properties like name/author/date_creation/comment |
---|
416 | <br><b>multiple_value_mode</b> can be "append" (no change on existing values, add the new values) or "replace" and applies to multiple values properties like tag_ids/categories' |
---|
417 | ); |
---|
418 | |
---|
419 | $service->addMethod( |
---|
420 | 'pwg.categories.setInfo', |
---|
421 | 'ws_categories_setInfo', |
---|
422 | array( |
---|
423 | 'category_id' => array(), |
---|
424 | |
---|
425 | 'name' => array('default' => null), |
---|
426 | 'comment' => array('default' => null), |
---|
427 | ), |
---|
428 | 'POST method only.' |
---|
429 | ); |
---|
430 | |
---|
431 | $service->addMethod( |
---|
432 | 'pwg.plugins.getList', |
---|
433 | 'ws_plugins_getList', |
---|
434 | array(), |
---|
435 | 'get the list of plugin with id, name, version, state and description |
---|
436 | <br>administration status required' |
---|
437 | ); |
---|
438 | |
---|
439 | $service->addMethod( |
---|
440 | 'pwg.plugins.performAction', |
---|
441 | 'ws_plugins_performAction', |
---|
442 | array( |
---|
443 | 'action' => array(), |
---|
444 | 'plugin' => array(), |
---|
445 | 'pwg_token' => array(), |
---|
446 | ), |
---|
447 | 'install/activate/deactivate/uninstall/delete a plugin |
---|
448 | <br>administration status required' |
---|
449 | ); |
---|
450 | |
---|
451 | $service->addMethod( |
---|
452 | 'pwg.themes.performAction', |
---|
453 | 'ws_themes_performAction', |
---|
454 | array( |
---|
455 | 'action' => array(), |
---|
456 | 'theme' => array(), |
---|
457 | 'pwg_token' => array(), |
---|
458 | ), |
---|
459 | 'activate/deactivate/delete/set_default a theme<br>administration status required' |
---|
460 | ); |
---|
461 | |
---|
462 | $service->addMethod( |
---|
463 | 'pwg.extensions.update', |
---|
464 | 'ws_extensions_update', |
---|
465 | array( |
---|
466 | 'type' => array(), |
---|
467 | 'id' => array(), |
---|
468 | 'revision'=> array(), |
---|
469 | 'pwg_token' => array(), |
---|
470 | ), |
---|
471 | 'Update an extension. Webmaster only. |
---|
472 | <br>Parameter type must be "plugins", "languages" or "themes".' |
---|
473 | ); |
---|
474 | |
---|
475 | $service->addMethod( |
---|
476 | 'pwg.extensions.ignoreUpdate', |
---|
477 | 'ws_extensions_ignoreupdate', |
---|
478 | array( |
---|
479 | 'type' => array('default'=>null), |
---|
480 | 'id' => array('default'=>null), |
---|
481 | 'reset' => array('default'=>null), |
---|
482 | 'pwg_token' => array(), |
---|
483 | ), |
---|
484 | 'Ignore an extension if it need update. |
---|
485 | <br>Parameter type must be "plugins", "languages" or "themes". |
---|
486 | <br>If reset parameter is true, all ignored extensions will be reinitilized.' |
---|
487 | ); |
---|
488 | |
---|
489 | $service->addMethod( |
---|
490 | 'pwg.extensions.checkUpdates', |
---|
491 | 'ws_extensions_checkupdates', |
---|
492 | array(), |
---|
493 | 'Check if piwigo or extensions are up to date.' |
---|
494 | ); |
---|
495 | } |
---|
496 | |
---|
497 | add_event_handler('ws_add_methods', 'ws_addDefaultMethods'); |
---|
498 | |
---|
499 | |
---|
500 | add_event_handler('ws_invoke_allowed', 'ws_isInvokeAllowed', EVENT_HANDLER_PRIORITY_NEUTRAL, 3); |
---|
501 | |
---|
502 | $requestFormat = 'rest'; |
---|
503 | $responseFormat = null; |
---|
504 | |
---|
505 | if ( isset($_GET['format']) ) |
---|
506 | { |
---|
507 | $responseFormat = $_GET['format']; |
---|
508 | } |
---|
509 | |
---|
510 | if ( !isset($responseFormat) and isset($requestFormat) ) |
---|
511 | { |
---|
512 | $responseFormat = $requestFormat; |
---|
513 | } |
---|
514 | |
---|
515 | $service = new PwgServer(); |
---|
516 | |
---|
517 | if (!is_null($requestFormat)) |
---|
518 | { |
---|
519 | $handler = null; |
---|
520 | switch ($requestFormat) |
---|
521 | { |
---|
522 | case 'rest': |
---|
523 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_handler.php'); |
---|
524 | $handler = new PwgRestRequestHandler(); |
---|
525 | break; |
---|
526 | } |
---|
527 | $service->setHandler($requestFormat, $handler); |
---|
528 | } |
---|
529 | |
---|
530 | if (!is_null($responseFormat)) |
---|
531 | { |
---|
532 | $encoder = null; |
---|
533 | switch ($responseFormat) |
---|
534 | { |
---|
535 | case 'rest': |
---|
536 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_encoder.php'); |
---|
537 | $encoder = new PwgRestEncoder(); |
---|
538 | break; |
---|
539 | case 'php': |
---|
540 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/php_encoder.php'); |
---|
541 | $encoder = new PwgSerialPhpEncoder(); |
---|
542 | break; |
---|
543 | case 'json': |
---|
544 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/json_encoder.php'); |
---|
545 | $encoder = new PwgJsonEncoder(); |
---|
546 | break; |
---|
547 | case 'xmlrpc': |
---|
548 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/xmlrpc_encoder.php'); |
---|
549 | $encoder = new PwgXmlRpcEncoder(); |
---|
550 | break; |
---|
551 | } |
---|
552 | $service->setEncoder($responseFormat, $encoder); |
---|
553 | } |
---|
554 | |
---|
555 | set_make_full_url(); |
---|
556 | $service->run(); |
---|
557 | |
---|
558 | ?> |
---|