[1698] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 5 | // | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org | |
---|
[2297] | 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 | // +-----------------------------------------------------------------------+ |
---|
[1698] | 23 | |
---|
| 24 | define ('PHPWG_ROOT_PATH', './'); |
---|
| 25 | |
---|
| 26 | include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); |
---|
[2325] | 27 | check_status(ACCESS_FREE); |
---|
[1698] | 28 | include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php'); |
---|
| 29 | |
---|
[1781] | 30 | if ( !$conf['allow_web_services'] ) |
---|
| 31 | { |
---|
| 32 | page_forbidden('Web services are disabled'); |
---|
| 33 | } |
---|
| 34 | |
---|
[1768] | 35 | /** |
---|
| 36 | * event handler that registers standard methods with the web service |
---|
| 37 | */ |
---|
[1698] | 38 | function ws_addDefaultMethods( $arr ) |
---|
| 39 | { |
---|
| 40 | include_once(PHPWG_ROOT_PATH.'include/ws_functions.inc.php'); |
---|
[1849] | 41 | global $conf, $user; |
---|
[1698] | 42 | $service = &$arr[0]; |
---|
| 43 | $service->addMethod('pwg.getVersion', 'ws_getVersion', null, |
---|
| 44 | 'retrieves the PWG version'); |
---|
[10017] | 45 | |
---|
| 46 | $service->addMethod('pwg.getInfos', 'ws_getInfos', null, |
---|
| 47 | 'retrieves general informations'); |
---|
[1698] | 48 | |
---|
[2435] | 49 | $service->addMethod('pwg.caddie.add', 'ws_caddie_add', |
---|
[2429] | 50 | array( |
---|
| 51 | 'image_id'=> array( 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
| 52 | ), |
---|
| 53 | 'adds the elements to the caddie'); |
---|
| 54 | |
---|
[1698] | 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), |
---|
[1781] | 59 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
[1698] | 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_with_thumbnail' => array( 'default'=> false ), |
---|
| 73 | ), |
---|
| 74 | 'Returns elements for the corresponding categories. |
---|
[3185] | 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, average_rate,...)' |
---|
[1698] | 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), |
---|
[11155] | 84 | 'tree_output' => array('default'=>false), |
---|
[1698] | 85 | ), |
---|
[11155] | 86 | 'retrieves a list of categories (tree_output option only compatible with json/php output format' ); |
---|
[1698] | 87 | |
---|
[1849] | 88 | $service->addMethod('pwg.images.addComment', 'ws_images_addComment', |
---|
| 89 | array( |
---|
| 90 | 'image_id' => array(), |
---|
[2029] | 91 | 'author' => array( 'default' => is_a_guest()? 'guest':$user['username']), |
---|
[1849] | 92 | 'content' => array(), |
---|
| 93 | 'key' => array(), |
---|
| 94 | ), |
---|
| 95 | 'add a comment to an image' ); |
---|
| 96 | |
---|
[1698] | 97 | $service->addMethod('pwg.images.getInfo', 'ws_images_getInfo', |
---|
[1849] | 98 | array( |
---|
| 99 | 'image_id' => array(), |
---|
| 100 | 'comments_page' => array('default'=>0 ), |
---|
[2435] | 101 | 'comments_per_page' => array( |
---|
| 102 | 'default' => $conf['nb_comment_page'], |
---|
[1849] | 103 | 'maxValue' => 2*$conf['nb_comment_page'], |
---|
| 104 | ), |
---|
| 105 | ), |
---|
[1698] | 106 | 'retrieves information about the given photo' ); |
---|
| 107 | |
---|
[2435] | 108 | $service->addMethod('pwg.images.rate', 'ws_images_rate', |
---|
| 109 | array( |
---|
| 110 | 'image_id' => array(), |
---|
| 111 | 'rate' => array(), |
---|
| 112 | ), |
---|
| 113 | 'rate the image' ); |
---|
| 114 | |
---|
[1837] | 115 | $service->addMethod('pwg.images.search', 'ws_images_search', |
---|
| 116 | array( |
---|
| 117 | 'query'=>array(), |
---|
| 118 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
| 119 | 'page' => array('default'=>0), |
---|
| 120 | 'order' => array('default'=>null), |
---|
| 121 | 'f_min_rate' => array( 'default'=> null ), |
---|
| 122 | 'f_max_rate' => array( 'default'=> null ), |
---|
| 123 | 'f_min_hit' => array( 'default'=> null ), |
---|
| 124 | 'f_max_hit' => array( 'default'=> null ), |
---|
| 125 | 'f_min_date_available' => array( 'default'=> null ), |
---|
| 126 | 'f_max_date_available' => array( 'default'=> null ), |
---|
| 127 | 'f_min_date_created' => array( 'default'=> null ), |
---|
| 128 | 'f_max_date_created' => array( 'default'=> null ), |
---|
| 129 | 'f_min_ratio' => array( 'default'=> null ), |
---|
| 130 | 'f_max_ratio' => array( 'default'=> null ), |
---|
| 131 | 'f_with_thumbnail' => array( 'default'=> false ), |
---|
| 132 | ), |
---|
| 133 | 'Returns elements for the corresponding query search.' |
---|
| 134 | ); |
---|
[2516] | 135 | |
---|
[2463] | 136 | $service->addMethod( |
---|
| 137 | 'pwg.images.setPrivacyLevel', |
---|
| 138 | 'ws_images_setPrivacyLevel', |
---|
| 139 | array( |
---|
| 140 | 'image_id' => array('flags'=>WS_PARAM_FORCE_ARRAY), |
---|
| 141 | 'level' => array('maxValue'=>$conf['available_permission_levels']), |
---|
[2413] | 142 | ), |
---|
[4513] | 143 | 'sets the privacy levels for the images (POST method only)' |
---|
[2463] | 144 | ); |
---|
[1837] | 145 | |
---|
[1698] | 146 | $service->addMethod('pwg.session.getStatus', 'ws_session_getStatus', null, '' ); |
---|
| 147 | $service->addMethod('pwg.session.login', 'ws_session_login', |
---|
| 148 | array('username', 'password'), |
---|
| 149 | 'POST method only' ); |
---|
| 150 | $service->addMethod('pwg.session.logout', 'ws_session_logout', null, ''); |
---|
| 151 | |
---|
| 152 | $service->addMethod('pwg.tags.getList', 'ws_tags_getList', |
---|
| 153 | array('sort_by_counter' => array('default' =>false) ), |
---|
| 154 | 'retrieves a list of available tags'); |
---|
| 155 | $service->addMethod('pwg.tags.getImages', 'ws_tags_getImages', |
---|
| 156 | array( |
---|
| 157 | 'tag_id'=>array('default'=>null, 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
| 158 | 'tag_url_name'=>array('default'=>null, 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
| 159 | 'tag_name'=>array('default'=>null, 'flags'=>WS_PARAM_FORCE_ARRAY ), |
---|
| 160 | 'tag_mode_and'=>array('default'=>false), |
---|
[1781] | 161 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
[1698] | 162 | 'page' => array('default'=>0), |
---|
| 163 | 'order' => array('default'=>null), |
---|
| 164 | 'f_min_rate' => array( 'default'=> null ), |
---|
| 165 | 'f_max_rate' => array( 'default'=> null ), |
---|
| 166 | 'f_min_hit' => array( 'default'=> null ), |
---|
| 167 | 'f_max_hit' => array( 'default'=> null ), |
---|
| 168 | 'f_min_date_available' => array( 'default'=> null ), |
---|
| 169 | 'f_max_date_available' => array( 'default'=> null ), |
---|
| 170 | 'f_min_date_created' => array( 'default'=> null ), |
---|
| 171 | 'f_max_date_created' => array( 'default'=> null ), |
---|
| 172 | 'f_min_ratio' => array( 'default'=> null ), |
---|
| 173 | 'f_max_ratio' => array( 'default'=> null ), |
---|
| 174 | 'f_with_thumbnail' => array( 'default'=> false ), |
---|
| 175 | ), |
---|
| 176 | 'Returns elements for the corresponding tags. Note that tag_id, tag_url_name, tag_name an be arrays. Fill at least one of them. ' |
---|
| 177 | ); |
---|
[2463] | 178 | |
---|
| 179 | $service->addMethod( |
---|
[3193] | 180 | 'pwg.images.addChunk', |
---|
| 181 | 'ws_images_add_chunk', |
---|
| 182 | array( |
---|
| 183 | 'data' => array(), |
---|
| 184 | 'original_sum' => array(), |
---|
| 185 | 'type' => array(), |
---|
| 186 | 'position' => array(), |
---|
| 187 | ), |
---|
| 188 | 'POST method only. For admin only.' |
---|
| 189 | ); |
---|
| 190 | |
---|
| 191 | $service->addMethod( |
---|
[4348] | 192 | 'pwg.images.addFile', |
---|
| 193 | 'ws_images_addFile', |
---|
| 194 | array( |
---|
| 195 | 'image_id' => array(), |
---|
| 196 | 'type' => array(), |
---|
| 197 | 'sum' => array(), |
---|
| 198 | ), |
---|
| 199 | 'Add or update a file for an existing photo. pwg.images.addChunk must have been called before (maybe several times)' |
---|
| 200 | ); |
---|
| 201 | |
---|
| 202 | |
---|
| 203 | $service->addMethod( |
---|
[2463] | 204 | 'pwg.images.add', |
---|
| 205 | 'ws_images_add', |
---|
| 206 | array( |
---|
[2569] | 207 | 'file_sum' => array(), |
---|
| 208 | 'thumbnail_sum' => array(), |
---|
[2670] | 209 | 'high_sum' => array('default' => null), |
---|
[3065] | 210 | 'original_sum' => array(), |
---|
[4911] | 211 | 'original_filename' => array('default' => null), |
---|
[2569] | 212 | 'name' => array('default' => null), |
---|
| 213 | 'author' => array('default' => null), |
---|
| 214 | 'date_creation' => array('default' => null), |
---|
| 215 | 'comment' => array('default' => null), |
---|
| 216 | 'categories' => array('default' => null), |
---|
| 217 | 'tag_ids' => array('default' => null), |
---|
| 218 | 'level' => array( |
---|
| 219 | 'default' => 0, |
---|
| 220 | 'maxValue' => $conf['available_permission_levels'] |
---|
| 221 | ), |
---|
[2463] | 222 | ), |
---|
[2569] | 223 | 'POST method only. |
---|
[3185] | 224 | <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.' |
---|
[2463] | 225 | ); |
---|
[2563] | 226 | |
---|
| 227 | $service->addMethod( |
---|
[8249] | 228 | 'pwg.images.addSimple', |
---|
| 229 | 'ws_images_addSimple', |
---|
| 230 | array( |
---|
| 231 | 'category' => array('default' => null), |
---|
| 232 | 'name' => array('default' => null), |
---|
| 233 | 'author' => array('default' => null), |
---|
| 234 | 'comment' => array('default' => null), |
---|
| 235 | 'level' => array( |
---|
| 236 | 'default' => 0, |
---|
| 237 | 'maxValue' => $conf['available_permission_levels'] |
---|
| 238 | ), |
---|
| 239 | 'tags' => array('default' => null), |
---|
[9191] | 240 | 'image_id' => array('default' => null), |
---|
[8249] | 241 | ), |
---|
[9191] | 242 | '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.' |
---|
[8249] | 243 | ); |
---|
[8266] | 244 | |
---|
[8249] | 245 | $service->addMethod( |
---|
[8266] | 246 | 'pwg.images.delete', |
---|
| 247 | 'ws_images_delete', |
---|
| 248 | array( |
---|
| 249 | 'image_id'=>array('default'=>0), |
---|
[10502] | 250 | 'pwg_token' => array(), |
---|
[8266] | 251 | ), |
---|
| 252 | 'Delete photos. You can give several image_ids, comma separated' |
---|
| 253 | ); |
---|
| 254 | |
---|
| 255 | $service->addMethod( |
---|
[2563] | 256 | 'pwg.categories.getAdminList', |
---|
| 257 | 'ws_categories_getAdminList', |
---|
| 258 | array(), |
---|
| 259 | 'administration method only' |
---|
| 260 | ); |
---|
[2583] | 261 | |
---|
| 262 | $service->addMethod( |
---|
| 263 | 'pwg.categories.add', |
---|
| 264 | 'ws_categories_add', |
---|
| 265 | array( |
---|
| 266 | 'name' => array(), |
---|
| 267 | 'parent' => array('default' => null), |
---|
| 268 | ), |
---|
| 269 | 'administration method only' |
---|
| 270 | ); |
---|
[2584] | 271 | |
---|
| 272 | $service->addMethod( |
---|
[8266] | 273 | 'pwg.categories.delete', |
---|
| 274 | 'ws_categories_delete', |
---|
| 275 | array( |
---|
| 276 | 'category_id'=>array('default'=>0), |
---|
[10502] | 277 | 'pwg_token' => array(), |
---|
[8266] | 278 | 'photo_deletion_mode' => array('default' => 'delete_orphans'), |
---|
| 279 | ), |
---|
| 280 | 'Delete categories. You can give several category_ids, comma separated. |
---|
| 281 | <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)' |
---|
| 282 | ); |
---|
| 283 | |
---|
| 284 | $service->addMethod( |
---|
[8272] | 285 | 'pwg.categories.move', |
---|
| 286 | 'ws_categories_move', |
---|
| 287 | array( |
---|
| 288 | 'category_id'=>array('default'=>0), |
---|
| 289 | 'parent'=>array('default'=>0), |
---|
[10502] | 290 | 'pwg_token' => array(), |
---|
[8272] | 291 | ), |
---|
| 292 | '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.' |
---|
| 293 | ); |
---|
| 294 | |
---|
| 295 | $service->addMethod( |
---|
[2584] | 296 | 'pwg.tags.getAdminList', |
---|
| 297 | 'ws_tags_getAdminList', |
---|
| 298 | array(), |
---|
| 299 | 'administration method only' |
---|
| 300 | ); |
---|
[2634] | 301 | |
---|
| 302 | $service->addMethod( |
---|
| 303 | 'pwg.tags.add', |
---|
| 304 | 'ws_tags_add', |
---|
| 305 | array( |
---|
| 306 | 'name' => array(), |
---|
| 307 | ), |
---|
| 308 | 'administration method only' |
---|
| 309 | ); |
---|
[2683] | 310 | |
---|
| 311 | $service->addMethod( |
---|
| 312 | 'pwg.images.exist', |
---|
| 313 | 'ws_images_exist', |
---|
| 314 | array( |
---|
[4954] | 315 | 'md5sum_list'=> array('default' => null), |
---|
| 316 | 'filename_list' => array('default' => null), |
---|
[2683] | 317 | ), |
---|
| 318 | 'check existence of a photo list' |
---|
| 319 | ); |
---|
[2919] | 320 | |
---|
| 321 | $service->addMethod( |
---|
[4347] | 322 | 'pwg.images.checkFiles', |
---|
| 323 | 'ws_images_checkFiles', |
---|
| 324 | array( |
---|
| 325 | 'image_id' => array(), |
---|
| 326 | 'thumbnail_sum' => array('default' => null), |
---|
| 327 | 'file_sum' => array('default' => null), |
---|
| 328 | 'high_sum' => array('default' => null), |
---|
| 329 | ), |
---|
| 330 | '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"' |
---|
| 331 | ); |
---|
| 332 | |
---|
| 333 | $service->addMethod( |
---|
[6049] | 334 | 'pwg.images.checkUpload', |
---|
| 335 | 'ws_images_checkUpload', |
---|
| 336 | null, |
---|
| 337 | 'check if Piwigo is ready for upload' |
---|
| 338 | ); |
---|
| 339 | |
---|
| 340 | $service->addMethod( |
---|
[2919] | 341 | 'pwg.images.setInfo', |
---|
| 342 | 'ws_images_setInfo', |
---|
| 343 | array( |
---|
| 344 | 'image_id' => array(), |
---|
[4513] | 345 | |
---|
[2919] | 346 | 'name' => array('default' => null), |
---|
| 347 | 'author' => array('default' => null), |
---|
| 348 | 'date_creation' => array('default' => null), |
---|
| 349 | 'comment' => array('default' => null), |
---|
| 350 | 'categories' => array('default' => null), |
---|
| 351 | 'tag_ids' => array('default' => null), |
---|
| 352 | 'level' => array( |
---|
| 353 | 'default' => 0, |
---|
| 354 | 'maxValue' => $conf['available_permission_levels'] |
---|
| 355 | ), |
---|
[4460] | 356 | 'single_value_mode' => array('default' => 'fill_if_empty'), |
---|
| 357 | 'multiple_value_mode' => array('default' => 'append'), |
---|
[2919] | 358 | ), |
---|
| 359 | 'POST method only. Admin only |
---|
[4460] | 360 | <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. |
---|
| 361 | <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 |
---|
| 362 | <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' |
---|
[2919] | 363 | ); |
---|
[4513] | 364 | |
---|
[3454] | 365 | $service->addMethod( |
---|
| 366 | 'pwg.categories.setInfo', |
---|
| 367 | 'ws_categories_setInfo', |
---|
| 368 | array( |
---|
| 369 | 'category_id' => array(), |
---|
[4513] | 370 | |
---|
[3454] | 371 | 'name' => array('default' => null), |
---|
| 372 | 'comment' => array('default' => null), |
---|
| 373 | ), |
---|
| 374 | 'POST method only.' |
---|
| 375 | ); |
---|
[8273] | 376 | |
---|
| 377 | $service->addMethod( |
---|
| 378 | 'pwg.plugins.getList', |
---|
| 379 | 'ws_plugins_getList', |
---|
| 380 | array(), |
---|
| 381 | 'get the list of plugin with id, name, version, state and description |
---|
| 382 | <br>administration status required' |
---|
| 383 | ); |
---|
| 384 | |
---|
| 385 | $service->addMethod( |
---|
| 386 | 'pwg.plugins.performAction', |
---|
| 387 | 'ws_plugins_performAction', |
---|
| 388 | array( |
---|
[10502] | 389 | 'action' => array(), |
---|
| 390 | 'plugin' => array(), |
---|
| 391 | 'pwg_token' => array(), |
---|
[8273] | 392 | ), |
---|
| 393 | 'install/activate/deactivate/uninstall/delete a plugin |
---|
| 394 | <br>administration status required' |
---|
| 395 | ); |
---|
[8309] | 396 | |
---|
| 397 | $service->addMethod( |
---|
| 398 | 'pwg.themes.performAction', |
---|
| 399 | 'ws_themes_performAction', |
---|
| 400 | array( |
---|
[10502] | 401 | 'action' => array(), |
---|
| 402 | 'theme' => array(), |
---|
| 403 | 'pwg_token' => array(), |
---|
[8309] | 404 | ), |
---|
| 405 | 'activate/deactivate/delete/set_default a theme<br>administration status required' |
---|
| 406 | ); |
---|
[10235] | 407 | |
---|
| 408 | $service->addMethod( |
---|
[10686] | 409 | 'pwg.images.resizeThumbnail', |
---|
| 410 | 'ws_images_resizethumbnail', |
---|
[10235] | 411 | array( |
---|
[10563] | 412 | 'image_id' => array('default' => null), |
---|
| 413 | 'image_path' => array('default' => null), |
---|
[10686] | 414 | 'maxwidth' => array('default' => $conf['upload_form_thumb_maxwidth']), |
---|
| 415 | 'maxheight' => array('default' => $conf['upload_form_thumb_maxheight']), |
---|
| 416 | 'quality' => array('default' => $conf['upload_form_thumb_quality']), |
---|
| 417 | 'crop' => array('default' => $conf['upload_form_thumb_crop']), |
---|
| 418 | 'follow_orientation' => array('default' => $conf['upload_form_thumb_follow_orientation']), |
---|
| 419 | 'library' => array('default' => $conf['graphics_library']), |
---|
| 420 | ), |
---|
| 421 | 'Create/Regenerate thumbnails photo with given arguments. |
---|
| 422 | <br>One of arguments "image_id" or "image_path" must be sent.' |
---|
| 423 | ); |
---|
| 424 | |
---|
| 425 | $service->addMethod( |
---|
| 426 | 'pwg.images.resizeWebsize', |
---|
| 427 | 'ws_images_resizewebsize', |
---|
| 428 | array( |
---|
| 429 | 'image_id' => array(), |
---|
| 430 | 'maxwidth' => array('default' => $conf['upload_form_websize_maxwidth']), |
---|
| 431 | 'maxheight' => array('default' => $conf['upload_form_websize_maxheight']), |
---|
| 432 | 'quality' => array('default' => $conf['upload_form_websize_quality']), |
---|
[10641] | 433 | 'automatic_rotation' => array('default' => $conf['upload_form_automatic_rotation']), |
---|
[10684] | 434 | 'library' => array('default' => $conf['graphics_library']), |
---|
[10235] | 435 | ), |
---|
[10686] | 436 | 'Regenerate websize photo with given arguments.' |
---|
| 437 | ); |
---|
[10511] | 438 | |
---|
| 439 | $service->addMethod( |
---|
| 440 | 'pwg.extensions.update', |
---|
| 441 | 'ws_extensions_update', |
---|
| 442 | array( |
---|
| 443 | 'type' => array(), |
---|
| 444 | 'id' => array(), |
---|
| 445 | 'revision'=> array(), |
---|
| 446 | 'pwg_token' => array(), |
---|
| 447 | ), |
---|
| 448 | 'Update an extension. Webmaster only. |
---|
| 449 | <br>Parameter type must be "plugins", "languages" or "themes".' |
---|
| 450 | ); |
---|
| 451 | |
---|
| 452 | $service->addMethod( |
---|
| 453 | 'pwg.extensions.ignoreUpdate', |
---|
| 454 | 'ws_extensions_ignoreupdate', |
---|
| 455 | array( |
---|
| 456 | 'type' => array('default'=>null), |
---|
| 457 | 'id' => array('default'=>null), |
---|
| 458 | 'reset' => array('default'=>null), |
---|
| 459 | 'pwg_token' => array(), |
---|
| 460 | ), |
---|
| 461 | 'Ignore an extension if it need update. |
---|
| 462 | <br>Parameter type must be "plugins", "languages" or "themes". |
---|
| 463 | <br>If reset parameter is true, all ignored extensions will be reinitilized.' |
---|
| 464 | ); |
---|
[10538] | 465 | |
---|
| 466 | $service->addMethod( |
---|
| 467 | 'pwg.extensions.checkUpdates', |
---|
| 468 | 'ws_extensions_checkupdates', |
---|
| 469 | array(), |
---|
| 470 | 'Check if piwigo or extensions are up to date.' |
---|
| 471 | ); |
---|
[1698] | 472 | } |
---|
| 473 | |
---|
[1768] | 474 | add_event_handler('ws_add_methods', 'ws_addDefaultMethods'); |
---|
[1698] | 475 | |
---|
[1768] | 476 | |
---|
| 477 | add_event_handler('ws_invoke_allowed', 'ws_isInvokeAllowed', EVENT_HANDLER_PRIORITY_NEUTRAL, 3); |
---|
| 478 | |
---|
[1698] | 479 | $requestFormat = null; |
---|
| 480 | $responseFormat = null; |
---|
| 481 | |
---|
| 482 | if ( isset($_GET['format']) ) |
---|
| 483 | { |
---|
| 484 | $responseFormat = $_GET['format']; |
---|
| 485 | } |
---|
| 486 | |
---|
| 487 | if ( isset($HTTP_RAW_POST_DATA) ) |
---|
| 488 | { |
---|
| 489 | $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); |
---|
| 490 | if ( strncmp($HTTP_RAW_POST_DATA, '<?xml', 5) == 0 ) |
---|
| 491 | { |
---|
| 492 | } |
---|
| 493 | else |
---|
| 494 | { |
---|
| 495 | $requestFormat = "json"; |
---|
| 496 | } |
---|
| 497 | } |
---|
| 498 | else |
---|
| 499 | { |
---|
| 500 | $requestFormat = "rest"; |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | if ( !isset($responseFormat) and isset($requestFormat) ) |
---|
| 504 | { |
---|
| 505 | $responseFormat = $requestFormat; |
---|
| 506 | } |
---|
| 507 | |
---|
| 508 | $service = new PwgServer(); |
---|
| 509 | |
---|
| 510 | if (!is_null($requestFormat)) |
---|
| 511 | { |
---|
| 512 | $handler = null; |
---|
| 513 | switch ($requestFormat) |
---|
| 514 | { |
---|
| 515 | case 'rest': |
---|
| 516 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_handler.php'); |
---|
| 517 | $handler = new PwgRestRequestHandler(); |
---|
| 518 | break; |
---|
| 519 | } |
---|
| 520 | $service->setHandler($requestFormat, $handler); |
---|
| 521 | } |
---|
| 522 | |
---|
| 523 | if (!is_null($responseFormat)) |
---|
| 524 | { |
---|
| 525 | $encoder = null; |
---|
| 526 | switch ($responseFormat) |
---|
| 527 | { |
---|
| 528 | case 'rest': |
---|
| 529 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_encoder.php'); |
---|
| 530 | $encoder = new PwgRestEncoder(); |
---|
| 531 | break; |
---|
| 532 | case 'php': |
---|
| 533 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/php_encoder.php'); |
---|
| 534 | $encoder = new PwgSerialPhpEncoder(); |
---|
| 535 | break; |
---|
| 536 | case 'json': |
---|
| 537 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/json_encoder.php'); |
---|
| 538 | $encoder = new PwgJsonEncoder(); |
---|
| 539 | break; |
---|
| 540 | case 'xmlrpc': |
---|
| 541 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/xmlrpc_encoder.php'); |
---|
| 542 | $encoder = new PwgXmlRpcEncoder(); |
---|
| 543 | break; |
---|
| 544 | } |
---|
| 545 | $service->setEncoder($responseFormat, $encoder); |
---|
| 546 | } |
---|
| 547 | |
---|
[1750] | 548 | set_make_full_url(); |
---|
[1698] | 549 | $service->run(); |
---|
| 550 | |
---|
| 551 | ?> |
---|