[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'); |
---|
[10022] | 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), |
---|
| 84 | ), |
---|
| 85 | 'retrieves a list of categories' ); |
---|
| 86 | |
---|
[1849] | 87 | $service->addMethod('pwg.images.addComment', 'ws_images_addComment', |
---|
| 88 | array( |
---|
| 89 | 'image_id' => array(), |
---|
[2029] | 90 | 'author' => array( 'default' => is_a_guest()? 'guest':$user['username']), |
---|
[1849] | 91 | 'content' => array(), |
---|
| 92 | 'key' => array(), |
---|
| 93 | ), |
---|
| 94 | 'add a comment to an image' ); |
---|
| 95 | |
---|
[1698] | 96 | $service->addMethod('pwg.images.getInfo', 'ws_images_getInfo', |
---|
[1849] | 97 | array( |
---|
| 98 | 'image_id' => array(), |
---|
| 99 | 'comments_page' => array('default'=>0 ), |
---|
[2435] | 100 | 'comments_per_page' => array( |
---|
| 101 | 'default' => $conf['nb_comment_page'], |
---|
[1849] | 102 | 'maxValue' => 2*$conf['nb_comment_page'], |
---|
| 103 | ), |
---|
| 104 | ), |
---|
[1698] | 105 | 'retrieves information about the given photo' ); |
---|
| 106 | |
---|
[2435] | 107 | $service->addMethod('pwg.images.rate', 'ws_images_rate', |
---|
| 108 | array( |
---|
| 109 | 'image_id' => array(), |
---|
| 110 | 'rate' => array(), |
---|
| 111 | ), |
---|
| 112 | 'rate the image' ); |
---|
| 113 | |
---|
[1837] | 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 | ); |
---|
[2516] | 134 | |
---|
[2463] | 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']), |
---|
[2413] | 141 | ), |
---|
[4513] | 142 | 'sets the privacy levels for the images (POST method only)' |
---|
[2463] | 143 | ); |
---|
[1837] | 144 | |
---|
[1698] | 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), |
---|
[1781] | 160 | 'per_page' => array('default'=>100, 'maxValue'=>$conf['ws_max_images_per_page']), |
---|
[1698] | 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 | ); |
---|
[2463] | 177 | |
---|
| 178 | $service->addMethod( |
---|
[3193] | 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( |
---|
[4348] | 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( |
---|
[2463] | 203 | 'pwg.images.add', |
---|
| 204 | 'ws_images_add', |
---|
| 205 | array( |
---|
[2569] | 206 | 'file_sum' => array(), |
---|
| 207 | 'thumbnail_sum' => array(), |
---|
[2670] | 208 | 'high_sum' => array('default' => null), |
---|
[3065] | 209 | 'original_sum' => array(), |
---|
[4911] | 210 | 'original_filename' => array('default' => null), |
---|
[2569] | 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 | ), |
---|
[2463] | 221 | ), |
---|
[2569] | 222 | 'POST method only. |
---|
[3185] | 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.' |
---|
[2463] | 224 | ); |
---|
[2563] | 225 | |
---|
| 226 | $service->addMethod( |
---|
[8249] | 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), |
---|
[9191] | 239 | 'image_id' => array('default' => null), |
---|
[8249] | 240 | ), |
---|
[9191] | 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.' |
---|
[8249] | 242 | ); |
---|
[8266] | 243 | |
---|
[8249] | 244 | $service->addMethod( |
---|
[8266] | 245 | 'pwg.images.delete', |
---|
| 246 | 'ws_images_delete', |
---|
| 247 | array( |
---|
| 248 | 'image_id'=>array('default'=>0), |
---|
| 249 | 'pwg_token' => array('default' => null), |
---|
| 250 | ), |
---|
| 251 | 'Delete photos. You can give several image_ids, comma separated' |
---|
| 252 | ); |
---|
| 253 | |
---|
| 254 | $service->addMethod( |
---|
[2563] | 255 | 'pwg.categories.getAdminList', |
---|
| 256 | 'ws_categories_getAdminList', |
---|
| 257 | array(), |
---|
| 258 | 'administration method only' |
---|
| 259 | ); |
---|
[2583] | 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 | ); |
---|
[2584] | 270 | |
---|
| 271 | $service->addMethod( |
---|
[8266] | 272 | 'pwg.categories.delete', |
---|
| 273 | 'ws_categories_delete', |
---|
| 274 | array( |
---|
| 275 | 'category_id'=>array('default'=>0), |
---|
| 276 | 'pwg_token' => array('default' => null), |
---|
| 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( |
---|
[8272] | 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('default' => null), |
---|
| 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( |
---|
[2584] | 295 | 'pwg.tags.getAdminList', |
---|
| 296 | 'ws_tags_getAdminList', |
---|
| 297 | array(), |
---|
| 298 | 'administration method only' |
---|
| 299 | ); |
---|
[2634] | 300 | |
---|
| 301 | $service->addMethod( |
---|
| 302 | 'pwg.tags.add', |
---|
| 303 | 'ws_tags_add', |
---|
| 304 | array( |
---|
| 305 | 'name' => array(), |
---|
| 306 | ), |
---|
| 307 | 'administration method only' |
---|
| 308 | ); |
---|
[2683] | 309 | |
---|
| 310 | $service->addMethod( |
---|
| 311 | 'pwg.images.exist', |
---|
| 312 | 'ws_images_exist', |
---|
| 313 | array( |
---|
[4954] | 314 | 'md5sum_list'=> array('default' => null), |
---|
| 315 | 'filename_list' => array('default' => null), |
---|
[2683] | 316 | ), |
---|
| 317 | 'check existence of a photo list' |
---|
| 318 | ); |
---|
[2919] | 319 | |
---|
| 320 | $service->addMethod( |
---|
[4347] | 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( |
---|
[6049] | 333 | 'pwg.images.checkUpload', |
---|
| 334 | 'ws_images_checkUpload', |
---|
| 335 | null, |
---|
| 336 | 'check if Piwigo is ready for upload' |
---|
| 337 | ); |
---|
| 338 | |
---|
| 339 | $service->addMethod( |
---|
[2919] | 340 | 'pwg.images.setInfo', |
---|
| 341 | 'ws_images_setInfo', |
---|
| 342 | array( |
---|
| 343 | 'image_id' => array(), |
---|
[4513] | 344 | |
---|
[2919] | 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 | ), |
---|
[4460] | 355 | 'single_value_mode' => array('default' => 'fill_if_empty'), |
---|
| 356 | 'multiple_value_mode' => array('default' => 'append'), |
---|
[2919] | 357 | ), |
---|
| 358 | 'POST method only. Admin only |
---|
[4460] | 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' |
---|
[2919] | 362 | ); |
---|
[4513] | 363 | |
---|
[3454] | 364 | $service->addMethod( |
---|
| 365 | 'pwg.categories.setInfo', |
---|
| 366 | 'ws_categories_setInfo', |
---|
| 367 | array( |
---|
| 368 | 'category_id' => array(), |
---|
[4513] | 369 | |
---|
[3454] | 370 | 'name' => array('default' => null), |
---|
| 371 | 'comment' => array('default' => null), |
---|
| 372 | ), |
---|
| 373 | 'POST method only.' |
---|
| 374 | ); |
---|
[8273] | 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('default' => null), |
---|
| 389 | 'plugin' => array('default' => null), |
---|
| 390 | 'pwg_token' => array('default' => null), |
---|
| 391 | ), |
---|
| 392 | 'install/activate/deactivate/uninstall/delete a plugin |
---|
| 393 | <br>administration status required' |
---|
| 394 | ); |
---|
[8309] | 395 | |
---|
| 396 | $service->addMethod( |
---|
| 397 | 'pwg.themes.performAction', |
---|
| 398 | 'ws_themes_performAction', |
---|
| 399 | array( |
---|
| 400 | 'action' => array('default' => null), |
---|
| 401 | 'themes' => array('default' => null), |
---|
| 402 | 'pwg_token' => array('default' => null), |
---|
| 403 | ), |
---|
| 404 | 'activate/deactivate/delete/set_default a theme<br>administration status required' |
---|
| 405 | ); |
---|
[1698] | 406 | } |
---|
| 407 | |
---|
[1768] | 408 | add_event_handler('ws_add_methods', 'ws_addDefaultMethods'); |
---|
[1698] | 409 | |
---|
[1768] | 410 | |
---|
| 411 | add_event_handler('ws_invoke_allowed', 'ws_isInvokeAllowed', EVENT_HANDLER_PRIORITY_NEUTRAL, 3); |
---|
| 412 | |
---|
[1698] | 413 | $requestFormat = null; |
---|
| 414 | $responseFormat = null; |
---|
| 415 | |
---|
| 416 | if ( isset($_GET['format']) ) |
---|
| 417 | { |
---|
| 418 | $responseFormat = $_GET['format']; |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | if ( isset($HTTP_RAW_POST_DATA) ) |
---|
| 422 | { |
---|
| 423 | $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); |
---|
| 424 | if ( strncmp($HTTP_RAW_POST_DATA, '<?xml', 5) == 0 ) |
---|
| 425 | { |
---|
| 426 | } |
---|
| 427 | else |
---|
| 428 | { |
---|
| 429 | $requestFormat = "json"; |
---|
| 430 | } |
---|
| 431 | } |
---|
| 432 | else |
---|
| 433 | { |
---|
| 434 | $requestFormat = "rest"; |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | if ( !isset($responseFormat) and isset($requestFormat) ) |
---|
| 438 | { |
---|
| 439 | $responseFormat = $requestFormat; |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | $service = new PwgServer(); |
---|
| 443 | |
---|
| 444 | if (!is_null($requestFormat)) |
---|
| 445 | { |
---|
| 446 | $handler = null; |
---|
| 447 | switch ($requestFormat) |
---|
| 448 | { |
---|
| 449 | case 'rest': |
---|
| 450 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_handler.php'); |
---|
| 451 | $handler = new PwgRestRequestHandler(); |
---|
| 452 | break; |
---|
| 453 | } |
---|
| 454 | $service->setHandler($requestFormat, $handler); |
---|
| 455 | } |
---|
| 456 | |
---|
| 457 | if (!is_null($responseFormat)) |
---|
| 458 | { |
---|
| 459 | $encoder = null; |
---|
| 460 | switch ($responseFormat) |
---|
| 461 | { |
---|
| 462 | case 'rest': |
---|
| 463 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/rest_encoder.php'); |
---|
| 464 | $encoder = new PwgRestEncoder(); |
---|
| 465 | break; |
---|
| 466 | case 'php': |
---|
| 467 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/php_encoder.php'); |
---|
| 468 | $encoder = new PwgSerialPhpEncoder(); |
---|
| 469 | break; |
---|
| 470 | case 'json': |
---|
| 471 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/json_encoder.php'); |
---|
| 472 | $encoder = new PwgJsonEncoder(); |
---|
| 473 | break; |
---|
| 474 | case 'xmlrpc': |
---|
| 475 | include_once(PHPWG_ROOT_PATH.'include/ws_protocols/xmlrpc_encoder.php'); |
---|
| 476 | $encoder = new PwgXmlRpcEncoder(); |
---|
| 477 | break; |
---|
| 478 | } |
---|
| 479 | $service->setEncoder($responseFormat, $encoder); |
---|
| 480 | } |
---|
| 481 | |
---|
[1750] | 482 | set_make_full_url(); |
---|
[1698] | 483 | $service->run(); |
---|
| 484 | |
---|
| 485 | ?> |
---|