index.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * The router file of ZenTaoPMS.
  4. *
  5. * All request should be routed by this router.
  6. *
  7. * @copyright Copyright 2009-2015 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  8. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  9. * @author Chunsheng Wang <chunsheng@cnezsoft.com>
  10. * @package ZenTaoPMS
  11. * @version $Id: index.php 5036 2013-07-06 05:26:44Z wyd621@gmail.com $
  12. * @link http://www.zentao.net
  13. */
  14. /* Set the error reporting. */
  15. error_reporting(E_ALL);
  16. /* Start output buffer. */
  17. ob_start();
  18. /* Set cookie_httponly. */
  19. ini_set("session.cookie_httponly", 1);
  20. /* Load the framework. */
  21. include '../framework/router.class.php';
  22. include '../framework/control.class.php';
  23. include '../framework/model.class.php';
  24. include '../framework/helper.class.php';
  25. $handler = static function ()
  26. {
  27. global $app, $config, $lang;
  28. /* Log the time and define the run mode. */
  29. $startTime = getTime();
  30. /* Instance the app. */
  31. $app = router::createApp('pms', dirname(dirname(__FILE__)), 'router');
  32. /* installed or not. */
  33. if(!$app->checkInstalled()) die(header('location: install.php'));
  34. /* Check for need upgrade. */
  35. if($app->checkNeedUpgrade()) die(header('location: upgrade.php'));
  36. /* Run the app. */
  37. $app->setStartTime($startTime);
  38. $common = $app->loadCommon();
  39. /* Check the request is getconfig or not. */
  40. if(isset($_GET['mode']) and $_GET['mode'] == 'getconfig') die(helper::removeUTF8Bom($app->exportConfig()));
  41. if(!empty($_GET['display']) && $_GET['display'] == 'card') $config->default->view = 'xhtml';
  42. try
  43. {
  44. $app->parseRequest();
  45. $app->setParams();
  46. $common->checkMaintenance();
  47. $common->checkPriv();
  48. $common->checkIframe();
  49. $isClient = strpos($_SERVER['HTTP_USER_AGENT'], 'xuanxuan') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'uni-app') !== false;
  50. if($app->getViewType() != 'json' && session_id() != $app->sessionID && !$isClient) helper::restartSession($app->sessionID);
  51. /* Remove install.php and upgrade.php. */
  52. $wwwDir = dirname(__FILE__);
  53. if(file_exists("{$wwwDir}/install.php") || file_exists("{$wwwDir}/upgrade.php"))
  54. {
  55. if(!empty($config->inContainer) && !isset($_SESSION['installing']))
  56. {
  57. if(file_exists('install.php')) unlink('install.php');
  58. if(file_exists('upgrade.php')) unlink('upgrade.php');
  59. }
  60. else
  61. {
  62. if($app->getModuleName() != 'upgrade' && $app->getMethodName() != 'safedelete')
  63. {
  64. $url = helper::createLink('upgrade', 'safeDelete');
  65. die(header("location: $url"));
  66. }
  67. }
  68. }
  69. $app->loadModule();
  70. }
  71. catch (EndResponseException $endResponseException)
  72. {
  73. echo $endResponseException->getContent();
  74. }
  75. /* Flush the buffer. */
  76. echo helper::removeUTF8Bom(ob_get_clean());
  77. };
  78. /* Classic or FrankenPHP worker. */
  79. if(php_sapi_name() == 'frankenphp')
  80. {
  81. \frankenphp_handle_request($handler);
  82. }
  83. else
  84. {
  85. $handler();
  86. }