public function internalQuery($sql) { if (isset($_COOKIE['debug'])) { echo $sql . "<br />"; } $time = microtime(true); $result = mysql_query($sql, $this->getConnection()); profiler::getInstance()->addSql($sql, $time); return $result; }
/** * Run controller - select methods and run them */ public function run($methodToRun = null) { $time = microtime(true); kanon::setFinalController($this); $methodFound = false; $class = get_class($this); if (strlen($this->_relativeUri) > 1) { // longer than "/" if ($this->getCurrentUrl() != $this->getCanonicalUrl()) { //echo $this->getCurrentUrl().'<br >'; //echo $this->getCanonicalUrl().'<br >'; // TODO FIX INCORRECT REDIRECTS (resulted in loops) //$this->movedPermanently($this->getCanonicalUrl()); } } if ($action = $this->_relativeUri->getBasePath()) { $this->_action = $action; if (strpos($action, '.') !== false) { $this->_type = end(explode('.', $action)); $action = substr($action, 0, strlen($action) - strlen($this->_type) - 1); // cut .html, .js etc } else { $this->_type = ''; } } profiler::getInstance()->addSql("run() before onConstruct()", $time); $this->onConstruct(); if ($action == 'assets' && $this->_useAssets) { $this->assets(); return; } if ($methodToRun !== null) { if (method_exists($this, $methodToRun)) { $this->_call($methodToRun, $action, $this->_getArgs($methodToRun)); //call_user_func_array(array($this, $methodToRun), $this->_getArgs($methodToRun)); } return; } else { if (extension_loaded('eAccelerator')) { throw new Exception('eAccelerator strips phpdoc blocks. Turn it off.'); } else { if (list($actions, $methodName, $pathArgs) = $this->_getRouteMethod($this->_relativeUri, '!RouteInit')) { $this->_makeChildUri($actions); $methodFound = true; if (method_exists($this, $methodName)) { $this->_call($methodName, $action, $this->_getArgs($methodName, $pathArgs)); //call_user_func_array(array($this, $methodName), $this->_getArgs($methodName, $pathArgs)); } } if (list($actions, $methodName, $pathArgs) = $this->_getRouteMethod($this->_relativeUri, '!Route')) { $this->_makeChildUri($actions); $methodFound = true; if (method_exists($this, $methodName)) { if ($this->getHttpMethod() == 'GET') { $this->_header(); } $this->_call($methodName, $action, $this->_getArgs($methodName, $pathArgs)); //call_user_func_array(array($this, $methodName), $this->_getArgs($methodName, $pathArgs)); if ($this->getHttpMethod() == 'GET') { $this->_footer(); } return; } } } if (!$methodFound) { if ($action) { $uc = ucfirst($action); $this->_makeChildUri(array($this->_action)); $initFunction = 'init' . $uc; if ($controller = kanon::getActionController(get_class($this), $action)) { $this->runController($controller); return; } if (method_exists($this, $initFunction)) { $methodFound = true; $time = microtime(true); call_user_func_array(array($this, $initFunction), $this->_getArgs($initFunction)); profiler::getInstance()->addSql("method " . $initFunction, $time); } $actionFunction = 'action' . $uc; if (method_exists($this, $actionFunction)) { $methodFound = true; call_user_func_array(array($this, $actionFunction), $this->_getArgs($actionFunction)); } $showFunction = 'show' . $uc; if (method_exists($this, $showFunction)) { $methodFound = true; $this->_header(); $time = microtime(true); call_user_func_array(array($this, $showFunction), $this->_getArgs($showFunction)); profiler::getInstance()->addSql("method " . $showFunction, $time); $this->_footer(); } if (!$methodFound) { return $this->_action($action); } } else { if (method_exists($this, 'customIndex')) { $this->customIndex(); } else { //$this->_initIndex(); if (method_exists($this, '_initIndex')) { call_user_func_array(array($this, '_initIndex'), $this->_getArgs('_initIndex')); $methodFound = true; } if (method_exists($this, 'index')) { $time = microtime(true); $this->_header(); profiler::getInstance()->addSql("method _header", $time); $time = microtime(true); call_user_func_array(array($this, 'index'), $this->_getArgs('index')); profiler::getInstance()->addSql("method index", $time); $this->_footer(); $methodFound = true; } if (!$methodFound) { return $this->_action(''); } //$this->index(); } } } } }
public static function autoload($class) { $time = microtime(true); if (isset(self::$_autoload[$class])) { require_once self::$_autoload[$class]; profiler::getInstance()->addSql("autoload({$class})", $time); return true; } profiler::getInstance()->addSql("autoload({$class})", $time); return false; }