PageRenderTime 57ms CodeModel.GetById 49ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/bootstrap.php

https://github.com/laposa/onxshop
PHP | 124 lines | 51 code | 36 blank | 37 comment | 9 complexity | 8d585a0c0f8bf6ebbf5540c3e47bcc62 MD5 | raw file
  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
  9/**
 10 * Set include paths
 11 */
 12
 13set_include_path(ONXSHOP_PROJECT_DIR . PATH_SEPARATOR . ONXSHOP_DIR . PATH_SEPARATOR . ONXSHOP_DIR . 'lib/' . PATH_SEPARATOR . get_include_path());
 14require_once('lib/onxshop.functions.php');
 15
 16/**
 17 * Debug benchmarking
 18 */
 19 
 20if (ONXSHOP_BENCHMARK && ONXSHOP_IS_DEBUG_HOST) {
 21	$time_start = microtime(true);
 22	define("TIME_START", $time_start);
 23}
 24
 25
 26/**
 27 * Include Bootstrap
 28 */
 29
 30require_once('lib/onxshop.bootstrap.php');
 31
 32/**
 33 * log to firebug
 34 */
 35 
 36if (ONXSHOP_IS_DEBUG_HOST && ONXSHOP_DEBUG_FIREBUG) {
 37
 38	require_once('Zend/Log/Writer/Firebug.php');
 39	require_once('Zend/Log.php');
 40	
 41	// Place this in your bootstrap file before dispatching your front controller
 42	$writer = new Zend_Log_Writer_Firebug();
 43	$GLOBALS['fb_logger'] = new Zend_Log($writer);
 44	
 45	require_once('Zend/Controller/Request/Http.php');
 46	$request = new Zend_Controller_Request_Http();
 47	require_once('Zend/Controller/Response/Http.php');
 48	$response = new Zend_Controller_Response_Http();
 49
 50	$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
 51	$channel->setRequest($request);
 52	$channel->setResponse($response);
 53}
 54
 55
 56/**
 57 * Init Bootstrap
 58 */
 59
 60$Bootstrap = new Onxshop_Bootstrap();
 61
 62/**
 63 * Init pre-action (standard pre-actions defined as global variable in conf/global.php)
 64 */
 65
 66$Bootstrap->initPreAction($onxshop_pre_actions);
 67
 68/**
 69 * Init action
 70 */
 71	
 72$Bootstrap->initAction($_GET['request']);
 73
 74/**
 75 * test log to firebug
 76 */
 77 
 78if (ONXSHOP_IS_DEBUG_HOST && ONXSHOP_DEBUG_FIREBUG) {
 79
 80	// Flush log data to browser
 81	$channel->flush();
 82	$response->sendHeaders();  
 83}
 84
 85
 86/**
 87 * Output content
 88 */
 89
 90echo $Bootstrap->finalOutput();
 91
 92
 93/**
 94 * Debug benchmarking
 95 */
 96   
 97if (ONXSHOP_BENCHMARK && ONXSHOP_IS_DEBUG_HOST) {
 98    $time_end = microtime(true);
 99    $time = $time_end - $time_start;
100    $time = round($time, 4);
101    echo "<div class='onxshop_messages'><p class='onxshop_ok_msg'>Script total running time = $time sec.</p>";
102    echo "<p class='onxshop_ok_msg'>Total Memory Usage = " . round((memory_get_usage()/1024)/1024, 2) . "MB</p>";
103    echo '</div>';
104}
105
106if (ONXSHOP_DB_PROFILER) {
107	$db = Zend_Registry::get('onxshop_db');
108	$profiler = $db->getProfiler();
109	$db_profile = array();
110	$db_profile['total_num_queries'] = $profiler->getTotalNumQueries();
111	$db_profile['total_elapsed_secs'] = $profiler->getTotalElapsedSecs();
112	$db_profile['query_list'] = array();
113	
114	foreach ($profiler->getQueryProfiles() as $k=>$item) {
115	
116		$db_profile['query_list'][$k]['query'] = $item->getQuery();
117		$db_profile['query_list'][$k]['query_params'] = $item->getQueryParams();
118		$db_profile['query_list'][$k]['elapsed_secs'] = $item->getElapsedSecs();
119	}
120	
121	echo "<pre>" . htmlspecialchars(print_r($db_profile, true)) . "</pre>";
122}
123
124