airtime-boot.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. // Only enable cookie secure if we are supporting https.
  3. // Ideally, this would always be on and we would force https,
  4. // but the default installation configs are likely to be installed by
  5. // amature users on the setup that does not have https. Forcing
  6. // cookie_secure on non https would result in confusing login problems.
  7. if(!empty($_SERVER['HTTPS'])) {
  8. ini_set('session.cookie_secure', '1');
  9. }
  10. ini_set('session.cookie_httponly', '1');
  11. error_reporting(E_ALL|E_STRICT);
  12. function exception_error_handler($errno, $errstr, $errfile, $errline) {
  13. //Check if the statement that threw this error wanted its errors to be
  14. //suppressed. If so then return without with throwing exception.
  15. if (0 === error_reporting()) return;
  16. throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
  17. return false;
  18. }
  19. set_error_handler("exception_error_handler");
  20. // Define application environment
  21. defined('APPLICATION_ENV')
  22. || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
  23. defined('VERBOSE_STACK_TRACE')
  24. || define('VERBOSE_STACK_TRACE', (getenv('VERBOSE_STACK_TRACE') ? getenv('VERBOSE_STACK_TRACE') : true));
  25. // Ensure library/ is on include_path
  26. set_include_path(implode(PATH_SEPARATOR, array(
  27. get_include_path(),
  28. realpath(LIB_PATH)
  29. )));
  30. set_include_path(APPLICATION_PATH . 'common' . PATH_SEPARATOR . get_include_path());
  31. //Propel classes.
  32. set_include_path(APPLICATION_PATH . 'models' . PATH_SEPARATOR . get_include_path());
  33. //Controller plugins.
  34. set_include_path(APPLICATION_PATH . 'controllers/plugins' . PATH_SEPARATOR . get_include_path());
  35. //Zend framework
  36. if (file_exists('/usr/share/php/libzend-framework-php')) {
  37. set_include_path('/usr/share/php/libzend-framework-php' . PATH_SEPARATOR . get_include_path());
  38. }
  39. /** Zend_Application */
  40. require_once 'Zend/Application.php';
  41. $application = new Zend_Application(
  42. APPLICATION_ENV,
  43. CONFIG_PATH . 'application.ini'
  44. );
  45. require_once(APPLICATION_PATH . "logging/Logging.php");
  46. Logging::setLogPath('/var/log/airtime/zendphp.log');
  47. // Create application, bootstrap, and run
  48. try {
  49. $sapi_type = php_sapi_name();
  50. if (substr($sapi_type, 0, 3) == 'cli') {
  51. set_include_path(APPLICATION_PATH . PATH_SEPARATOR . get_include_path());
  52. require_once("Bootstrap.php");
  53. } else {
  54. $application->bootstrap()->run();
  55. }
  56. } catch (Exception $e) {
  57. echo $e->getMessage();
  58. echo "<pre>";
  59. echo $e->getTraceAsString();
  60. echo "</pre>";
  61. Logging::info($e->getMessage());
  62. if (VERBOSE_STACK_TRACE) {
  63. Logging::info($e->getTraceAsString());
  64. } else {
  65. Logging::info($e->getTrace());
  66. }
  67. }