wfs-data.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. // Api for QGIS moved to wfs-qgis.php
  3. if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') {
  4. header("Location: https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
  5. exit();
  6. }
  7. require_once dirname(__FILE__) . '/se-lib/bootstrap.php';
  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. session_start();
  21. session_write_close();
  22. $apiUser = new ApiUser();
  23. // ?LOGIN=LOGOUT
  24. if ('LOGOUT' == V::get('LOGIN', '', $_GET)) {
  25. $apiUser->logout();
  26. } else {
  27. $apiUser->auth();
  28. }
  29. set_time_limit(5 * 60);
  30. $reqUri = V::get('REQUEST_URI', '', $_SERVER);
  31. $reqScript = V::get('SCRIPT_NAME', '', $_SERVER);
  32. $taskPath = str_replace($reqScript, '', $reqUri);
  33. $taskPath = "/xml/wfsData{$taskPath}";
  34. 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>';}
  35. $api = new Api();
  36. $api->setUser($apiUser);
  37. $apiBaseUri = V::get('SCRIPT_URI', '', $_SERVER);
  38. $api->setBaseUri($apiBaseUri);
  39. try {
  40. $api->execute($taskPath);
  41. }
  42. catch (HttpException $e) {
  43. Http::sendHeaderByCode($e->getCode());
  44. echo $e->getMessage();
  45. }
  46. catch (Exception $e) {
  47. Http::sendHeaderByCode(500);
  48. echo $e->getMessage();
  49. }
  50. ?>