wfs-data.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. // Api for QGIS moved to wfs-qgis.php
  3. require_once dirname(__FILE__) . '/se-lib/bootstrap.php';
  4. if (!Request::isHttps()) {
  5. header("Location: https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
  6. exit();
  7. }
  8. date_default_timezone_set('Europe/Warsaw');// PHP 5 >= 5.1.0 required by date functions
  9. $errorReportingLevel = E_ALL & ~E_NOTICE;
  10. error_reporting($errorReportingLevel);
  11. ini_set('error_reporting', $errorReportingLevel);
  12. if (file_exists(APP_PATH_ROOT . "/config/.config_{$_SERVER['SERVER_NAME']}.php")) {
  13. require APP_PATH_ROOT . "/config/.config_{$_SERVER['SERVER_NAME']}.php";
  14. }
  15. if (file_exists(APP_PATH_ROOT . "/.config.php")) include APP_PATH_ROOT . "/.config.php";
  16. require_once APP_PATH_ROOT . "/superedit-SEF.php";
  17. SEF('DEBUG_S');
  18. Lib::loadClass('ApiUser');
  19. Lib::loadClass('Api');
  20. if (!empty($_GET['sid'])) {
  21. session_id($_GET['sid']); // TODO: security BUG
  22. error_log('wfs-data.php _GET[sid] was read' .$_GET['sid'].' ; ');
  23. }
  24. session_start();
  25. session_write_close();
  26. $apiUser = new ApiUser();
  27. // ?LOGIN=LOGOUT
  28. if ('LOGOUT' == V::get('LOGIN', '', $_GET)) {
  29. $apiUser->logout();
  30. } else {
  31. $apiUser->auth();
  32. }
  33. set_time_limit(5 * 60);
  34. $taskPath = Request::getRewriteTaskPath();
  35. $taskPath = "/xml/wfsData{$taskPath}";
  36. 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>';}
  37. $api = new Api();
  38. $api->setUser($apiUser);
  39. $apiBaseUri = Request::getScriptUri();
  40. $api->setBaseUri($apiBaseUri);// TODO: RMME - replaced with Api_WfsNs::getBaseWfsUri();
  41. try {
  42. $api->execute($taskPath);
  43. }
  44. catch (HttpException $e) {
  45. Http::sendHeaderByCode($e->getCode());
  46. echo $e->getMessage();
  47. }
  48. catch (Exception $e) {
  49. Http::sendHeaderByCode(500);
  50. echo $e->getMessage();
  51. }
  52. ?>