wps.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /* QGIS- reverse inginiering:
  3. ?SERVICE=WFS&REQUEST=GetCapabilities&VERSION=1.0.0
  4. */
  5. require_once dirname(__FILE__) . '/se-lib/bootstrap.php';
  6. if (!Request::isHttps()) {
  7. header("Location: https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
  8. exit();
  9. }
  10. date_default_timezone_set('Europe/Warsaw');// PHP 5 >= 5.1.0 required by date functions
  11. $errorReportingLevel = E_ALL & ~E_NOTICE;
  12. error_reporting($errorReportingLevel);
  13. ini_set('error_reporting', $errorReportingLevel);
  14. trigger_error("WPS: {$_SERVER['REQUEST_METHOD']} https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}", E_USER_NOTICE); // TODO: RMMR DBG
  15. if ('POST' === $_SERVER['REQUEST_METHOD']) {
  16. trigger_error("WPS POST BODY: " . Request::getRequestBody(), E_USER_NOTICE); // TODO: RMMR DBG
  17. }
  18. if (file_exists(APP_PATH_ROOT . "/config/.config_{$_SERVER['SERVER_NAME']}.php")) {
  19. require APP_PATH_ROOT . "/config/.config_{$_SERVER['SERVER_NAME']}.php";
  20. }
  21. if (file_exists(APP_PATH_ROOT . "/.config.php")) include APP_PATH_ROOT . "/.config.php";
  22. require_once APP_PATH_ROOT . "/superedit-SEF.php";
  23. SEF('DEBUG_S');
  24. Lib::loadClass('ApiUser');
  25. Lib::loadClass('Api');
  26. session_start();
  27. session_write_close();
  28. $apiUser = new ApiUser();
  29. // ?LOGIN=LOGOUT
  30. if ('LOGOUT' == V::get('LOGIN', '', $_GET)) {
  31. $apiUser->logout();
  32. } else {
  33. $apiUser->auth();
  34. }
  35. set_time_limit(5 * 60);
  36. $taskPath = Request::getRewriteTaskPath();
  37. $taskPath = "/xml/wps{$taskPath}";
  38. IF(V::get('DBG','',$_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">taskPath (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($taskPath);echo'</pre>';}
  39. if ('/xml/wfs' == substr($taskPath, 0, 8)) {
  40. $taskPath = "/xml/wfsQgis/" . substr($taskPath, 9);
  41. }
  42. try {
  43. $api = new Api();
  44. $api->setUser($apiUser);
  45. $apiBaseUri = Request::getScriptUri();
  46. $api->setBaseUri($apiBaseUri);// TODO: RMME - replaced with Api_WfsNs::getBaseWfsUri();
  47. $api->execute($taskPath);
  48. }
  49. catch (HttpException $e) {
  50. DBG::log($e);
  51. Http::sendHeaderByCode($e->getCode());
  52. echo $e->getMessage();
  53. }
  54. catch (Exception $e) {
  55. Http::sendHeaderByCode(500);
  56. echo $e->getMessage();
  57. }
  58. ?>