/** * spousti zobrazeni pozadovane stranky * @throws LBoxException */ public static function run() { try { // starting timer LBoxTimer::getInstance(); // init acces AccesRecord::getInstance(); if (self::getPageCfg()->cache_off) { LBoxCacheManagerFront::getInstance()->switchListeningOff(); } self::executeInit(); // caching //var_dump(LBoxCacheManagerFront::getInstance()->wasFormSentNow());die; //if (self::getPage()->showConnivance()) { //LBoxFirePHP::table($_SERVER, "_SERVER"); if (LBoxCacheManagerFront::getInstance()->isCacheON()) { if (!LBoxXTProject::isLoggedSuperAdmin() && !LBoxXTDBFree::isLogged() && !LBoxCacheManagerFront::getInstance()->wasFormSentNow()) { if (count(self::getDataPost()) < 1) { if (LBoxCacheManagerFront::getInstance()->doesCacheExists()) { // send last modification header LBoxFirePHP::warn("cache loaded in " . LBoxTimer::getInstance()->getTimeOfLife() . "s"); header("Last-Modified: " . gmdate("D, d M Y H:i:s", LBoxCacheManagerFront::getInstance()->getLastCacheModificationTime()) . " GMT"); echo LBoxCacheManagerFront::getInstance()->getData(); LBoxCacheManagerFront::getInstance()->__destruct(); return; } } } $content = self::getRequestContent(); echo $content; if (!LBoxXTProject::isLoggedSuperAdmin() && !LBoxXTDBFree::isLogged() && !LBoxCacheManagerFront::getInstance()->wasFormSentNow()) { if (count(self::getDataPost()) < 1) { // vystup z nenalezenych URL neukladame - mohlo by umoznit snadno zahltit cache! if (self::getPageCfg()->id != LBoxConfigSystem::getInstance()->getParamByPath("pages/page404")) { //kontrola jestli vystup neni jen vypis exception if (strlen(strip_tags($content)) > 0) { LBoxCacheManagerFront::getInstance()->saveData($content); LBoxFirePHP::warn("cache stored in " . LBoxTimer::getInstance()->getTimeOfLife() . "s"); } else { LBoxFirePHP::error("cache NOT stored because output suppose to contain only exception message!"); } } } } LBoxCacheManagerFront::getInstance()->__destruct(); } else { LBoxFirePHP::warn("cache VYPNUTA"); echo self::getRequestContent(); } /*} else { echo self::getRequestContent(); }*/ } catch (Exception $e) { throw $e; } }
/** * @return LBoxTimer */ public static function getInstance() { $className = __CLASS__; try { if (!self::$instance instanceof $className) { self::$instance = new $className(); } return self::$instance; } catch (Exception $e) { throw $e; } }
/** * autosave - pohodlnejsi nez nutne volat store * @throws Exception */ public function __destruct() { try { if (LBoxConfigManagerProperties::getPropertyContentByName("log_access") < 1) { return; } $this->params["queries"] = DbControl::getQueryCount() + 1; $this->params["time_execution"] = LBoxTimer::getInstance()->getTimeOfLife(); $this->params["cache_read"] = LBoxCache::getInstance()->getFilesOpenedRead(); $this->params["cache_write"] = LBoxCache::getInstance()->getFilesOpenedWrite(); $this->params["memory"] = memory_get_peak_usage(true); $this->params["memory_limit"] = ini_get("memory_limit") * 1024 * 1024; $this->synchronized = false; $this->store(); } catch (Exception $e) { throw $e; } }
protected function debug($sql) { if (!self::$debug) { return; } if (strtolower(self::$debug) == "firephp") { switch (true) { case is_numeric(strpos($sql, "UPDATE")): case is_numeric(strpos($sql, "DELETE")): LBoxFirePHP::warn(round(LBoxTimer::getInstance()->getTimeOfLife(), 5) . " - " . str_replace("\n", "", self::$queryCount . ": " . $sql)); break; default: LBoxFirePHP::log(round(LBoxTimer::getInstance()->getTimeOfLife(), 5) . " - " . str_replace("\n", "", self::$queryCount . ": " . $sql)); } } else { switch (true) { case is_numeric(strpos($sql, "UPDATE")): case is_numeric(strpos($sql, "DELETE")): $bg = "#962C2C"; break; case is_numeric(strpos($sql, "INSERT")): $bg = "#6BC764"; break; default: $bg = "#5D5D5D"; } $color = "#ffffff"; $msg = "<table><th bgcolor='{$bg}' align='left'><font color='#C0C0C0'>" . round(LBoxTimer::getInstance()->getTimeOfLife(), 5) . "</font></th><th bgcolor='{$bg}' align='left'><b><font color='{$color}'>" . nl2br(self::$queryCount . ": " . $sql) . "</font></b></th></table>\n"; echo $msg; flush(); } }