PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/bootstrap.php

https://github.com/laposa/onxshop
PHP | 124 lines | 51 code | 36 blank | 37 comment | 9 complexity | 8d585a0c0f8bf6ebbf5540c3e47bcc62 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. *
  4. * Copyright (c) 2005-2013 Laposa Ltd (http://laposa.co.uk)
  5. * Licensed under the New BSD License. See the file LICENSE.txt for details.
  6. */
  7. /**
  8. * Set include paths
  9. */
  10. set_include_path(ONXSHOP_PROJECT_DIR . PATH_SEPARATOR . ONXSHOP_DIR . PATH_SEPARATOR . ONXSHOP_DIR . 'lib/' . PATH_SEPARATOR . get_include_path());
  11. require_once('lib/onxshop.functions.php');
  12. /**
  13. * Debug benchmarking
  14. */
  15. if (ONXSHOP_BENCHMARK && ONXSHOP_IS_DEBUG_HOST) {
  16. $time_start = microtime(true);
  17. define("TIME_START", $time_start);
  18. }
  19. /**
  20. * Include Bootstrap
  21. */
  22. require_once('lib/onxshop.bootstrap.php');
  23. /**
  24. * log to firebug
  25. */
  26. if (ONXSHOP_IS_DEBUG_HOST && ONXSHOP_DEBUG_FIREBUG) {
  27. require_once('Zend/Log/Writer/Firebug.php');
  28. require_once('Zend/Log.php');
  29. // Place this in your bootstrap file before dispatching your front controller
  30. $writer = new Zend_Log_Writer_Firebug();
  31. $GLOBALS['fb_logger'] = new Zend_Log($writer);
  32. require_once('Zend/Controller/Request/Http.php');
  33. $request = new Zend_Controller_Request_Http();
  34. require_once('Zend/Controller/Response/Http.php');
  35. $response = new Zend_Controller_Response_Http();
  36. $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
  37. $channel->setRequest($request);
  38. $channel->setResponse($response);
  39. }
  40. /**
  41. * Init Bootstrap
  42. */
  43. $Bootstrap = new Onxshop_Bootstrap();
  44. /**
  45. * Init pre-action (standard pre-actions defined as global variable in conf/global.php)
  46. */
  47. $Bootstrap->initPreAction($onxshop_pre_actions);
  48. /**
  49. * Init action
  50. */
  51. $Bootstrap->initAction($_GET['request']);
  52. /**
  53. * test log to firebug
  54. */
  55. if (ONXSHOP_IS_DEBUG_HOST && ONXSHOP_DEBUG_FIREBUG) {
  56. // Flush log data to browser
  57. $channel->flush();
  58. $response->sendHeaders();
  59. }
  60. /**
  61. * Output content
  62. */
  63. echo $Bootstrap->finalOutput();
  64. /**
  65. * Debug benchmarking
  66. */
  67. if (ONXSHOP_BENCHMARK && ONXSHOP_IS_DEBUG_HOST) {
  68. $time_end = microtime(true);
  69. $time = $time_end - $time_start;
  70. $time = round($time, 4);
  71. echo "<div class='onxshop_messages'><p class='onxshop_ok_msg'>Script total running time = $time sec.</p>";
  72. echo "<p class='onxshop_ok_msg'>Total Memory Usage = " . round((memory_get_usage()/1024)/1024, 2) . "MB</p>";
  73. echo '</div>';
  74. }
  75. if (ONXSHOP_DB_PROFILER) {
  76. $db = Zend_Registry::get('onxshop_db');
  77. $profiler = $db->getProfiler();
  78. $db_profile = array();
  79. $db_profile['total_num_queries'] = $profiler->getTotalNumQueries();
  80. $db_profile['total_elapsed_secs'] = $profiler->getTotalElapsedSecs();
  81. $db_profile['query_list'] = array();
  82. foreach ($profiler->getQueryProfiles() as $k=>$item) {
  83. $db_profile['query_list'][$k]['query'] = $item->getQuery();
  84. $db_profile['query_list'][$k]['query_params'] = $item->getQueryParams();
  85. $db_profile['query_list'][$k]['elapsed_secs'] = $item->getElapsedSecs();
  86. }
  87. echo "<pre>" . htmlspecialchars(print_r($db_profile, true)) . "</pre>";
  88. }