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