api.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * The api router file of ZenTaoPMS.
  4. *
  5. * All request of entries should be routed by this router.
  6. *
  7. * @copyright Copyright 2009-2017 禅道软件(青岛)有限公司(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 Gang Liu <liugang@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(0);
  16. ini_set('zlib.output_compression', 'Off');
  17. /* Start output buffer. */
  18. ob_start();
  19. /* Load the framework. */
  20. include '../framework/api/router.class.php';
  21. include '../framework/api/entry.class.php';
  22. include '../framework/api/helper.class.php';
  23. include '../framework/api/control.class.php';
  24. include '../framework/model.class.php';
  25. /* Log the time and define the run mode. */
  26. $startTime = getTime();
  27. /* Instance the app. */
  28. $app = router::createApp('pms', dirname(dirname(__FILE__)), 'api');
  29. /* Run the app. */
  30. $common = $app->loadCommon();
  31. /* Set default params. */
  32. $config->requestType = 'GET';
  33. $config->default->view = 'json';
  34. /* Only has the api version then use apisession. Fix for passwordless login. */
  35. if($app->apiVersion) define('RUN_MODE', 'api');
  36. try
  37. {
  38. $app->parseRequest();
  39. /* APIv1 load entries, not control directly. */
  40. if(!$app->apiVersion)
  41. {
  42. $common->checkEntry();
  43. }
  44. elseif($app->apiVersion == 'v2')
  45. {
  46. $common->checkPriv();
  47. }
  48. $app->loadModule();
  49. }
  50. catch (EndResponseException $endResponseException)
  51. {
  52. die($endResponseException->getContent());
  53. }
  54. /* Flush the buffer. */
  55. echo $app->formatData(helper::removeUTF8Bom(ob_get_clean()));