コード例 #1
0
ファイル: module.php プロジェクト: Prescia/Prescia
 function onEcho(&$PAGE)
 {
     if ($this->parent->layout == 2 || $this->parent->servingFile) {
         return;
     }
     # don't mess with ajax
     # Happens just after the template has been parsed (note it received the page as a STRING now), after this, is ECHO and DIE
     ###### -> Construct should add this module to the onEcho array
     if (!$this->devDisable) {
         $thereAreErrors = false;
         if ($this->devCheckHTML || isset($_REQUEST['dev_test'])) {
             if (!function_exists('checkHTML')) {
                 include CONS_PATH_INCLUDE . "checkHTML.php";
             }
             $log = checkHTML($PAGE, false);
             if (count($log) > 0) {
                 $thereAreErrors = true;
                 $this->log[] = implode("<br/>", $log);
                 // for dev_test
             }
             unset($log);
         }
         if (isset($_REQUEST['dev_test'])) {
             if (count($this->parent->log) > 0 || count($this->parent->warning) > 0) {
                 # failed basic test , log it
                 $_SESSION['affbidevut'][2][] = $this->parent->context_str . $this->parent->action . " Reports errors:";
                 foreach ($this->parent->log as $log) {
                     $_SESSION['affbidevut'][2][] = $log;
                 }
                 foreach ($this->parent->warning as $log) {
                     $_SESSION['affbidevut'][2][] = $log;
                 }
             }
             $this->unitTest();
         } else {
             $qs = $this->parent->action . ".html?" . arrayToString(false, array("login", "gfc", "haveinfo", "password", "debugmode", "nosession", "nocache", "dev_html"));
             $totalTime = scriptTime() * 1000;
             // ###############################---
             // ## This is the info strip that stays on top of the site:
             array_unshift($this->log, number_format($totalTime, 2) . "ms (" . CONS_AFF_DATABASECONNECTOR . ": " . number_format($this->parent->dbo->dbt, 2) . "ms, framework: " . number_format($this->overheadTime, 2) . " ms), SQL(s): " . $this->parent->dbo->dbc . ", caches: " . number_format($this->parent->cachetime / 1000) . "ms main, " . number_format($this->parent->cachetimeObj / 1000) . "ms obj" . (isset($this->parent->storage['CORE_CACHECONTROL']) ? " avg: " . number_format($this->parent->storage['CORE_CACHECONTROL'][0] / 1000) . "s factor " . number_format($this->parent->storage['CORE_CACHECONTROL'][1], 2) : "") . " (" . $_SESSION[CONS_SESSION_LANG] . ") (" . ($this->devCheckHTML ? "<a style='color:#" . $this->textColor . "' href='{$qs}&dev_html=0'><strong>checkHTML</strong> is on</a>" : "<a style='color:#" . $this->textColor . "' href='{$qs}&dev_html=1'><strong>checkHTML</strong> is off</a>") . ") (" . ($thereAreErrors ? "<strong><a style='color:#" . $this->textColor . "' href='?dev_log=1'>Errors!</a></strong>" : "no errors") . ") (<a style='color:#" . $this->textColor . "' href='?debugmode=true&nosession=true&nocache=true'>RESET</a>)" . " (<a style='color:#" . $this->textColor . "' href='?dev_help=1'>DEVELOPER OPTIONS</a>) (<a style='color:#" . $this->textColor . "' href=\"" . $qs . "&dev_disable=1\">disable</a>)" . ($this->parent->cacheControl->contentFromCache ? " CACHED CONTENT" : ""));
             // ###############################---
             $pl = strlen($PAGE);
             $tp = new CKTemplate();
             $tp->fetch(CONS_PATH_SYSTEM . "plugins/" . $this->name . "/payload/overlay.html");
             $tp->assign("AFFBIDEV_CONTENT", implode("<br/>", $this->log) . (count($this->parent->warning) != 0 ? "<br/>Warnings:" . implode("<br/>", $this->parent->warning) : ""));
             $arrowColor = $this->parent->cacheControl->contentFromCache ? "#000099" : ($thereAreErrors ? "#BB0000" : "#000000");
             $tp->assign("ARROWCOLOR", $arrowColor);
             $tp->assign("ARROWSIZE", $thereAreErrors ? 20 : 12);
             $PAGE = str_replace("</body>", $tp->techo() . "</body>", $PAGE);
             if (strlen($PAGE) == $pl) {
                 $this->log[] = "WARNING: no /body on page";
                 $PAGE .= $tp->techo();
             }
             $PAGE .= "<!-- bi_dev output logs. To stop this output, disable bi_dev";
             $PAGE .= "\nDbLOG:\n" . implode("\n", $this->parent->dbo->log);
             $C = $_SESSION;
             unset($C['prescia_cache']);
             // the cache can contain whole HTML that would cause havok
             $PAGE .= "\n" . print_r($C, 1) . "\n";
             $PAGE .= "-->";
         }
     }
 }
コード例 #2
0
ファイル: index.php プロジェクト: Prescia/Prescia
foreach ($core->onEcho as $scriptName) {
    $core->loadedPlugins[$scriptName]->onEcho($PAGE);
}
# -- collect and serve
$error = ob_get_contents();
ob_end_clean();
# unexpected error? dump after the page
if ($error != "") {
    if ($core->layout < 2) {
        $PAGE .= $core->errorControl->dumpUnexpectedOutput($error);
    } else {
        $PAGE .= $error;
    }
}
# -- performance monitor
$totalTime = scriptTime() * 1000;
if (CONS_CACHE) {
    $core->cacheControl->updateCacheControl($totalTime);
}
if ($totalTime > CONS_PM_TIME) {
    $fd = fopen(CONS_PATH_LOGS . $_SESSION['CODE'] . "/pm.log", "a");
    if ($fd) {
        fwrite($fd, date("Y-m-d H:i:s") . " took " . number_format($totalTime, 2) . "ms :" . $core->context_str . $core->original_action . " (caller IP: " . CONS_IP . ")\n");
        fclose($fd);
    }
}
# -- we are done here, close up whatever is no longer necessary and prepare to echo
$core->close(false);
# -- outputs gzip if on normal layout and browser supports gzip
if (CONS_GZIP_OK && $core->layout < 2 && strlen($PAGE) > CONS_GZIP_MINSIZE) {
    header("Content-Encoding: gzip");
コード例 #3
0
ファイル: core.php プロジェクト: Prescia/Prescia
 function nearTimeLimit()
 {
     # returns TRUE if we are too near time's up
     if (scriptTime() > CONS_TIMEWARNING) {
         $this->errorControl->raise(167, $this->context_str . "/" . $this->action, '', scriptTime());
         return true;
     }
     return false;
 }
コード例 #4
0
ファイル: module.php プロジェクト: Prescia/Prescia
 function onCron($isDay = false)
 {
     # cron Triggered, isDay or isHour
     if (!$isDay) {
         # hourly
         $totalTime = scriptTime() * 1000;
         $data = array(date("H"), 0, 0, 0, 0, 0);
         $data[0] = date("H");
         if (CONS_CACHE && $this->parent->cacheControl->contentFromCache) {
             $data[2] = $totalTime;
         } else {
             $data[1] = $totalTime;
         }
         $this->resetSTdata($data);
     } else {
         # daily
         $core =& $this->parent;
         # daily statistics:
         $previousDay = datecalc(date("Y-m-d"), 0, 0, -1);
         $x = $core->dbo->fetch("SELECT hits FROM " . $core->modules['statsdaily']->dbname . " WHERE data='" . $previousDay . "'");
         if ($x === false) {
             # nothing yet registered on history
             if ($core->dbo->query("SELECT SUM(hits), SUM(uhits), SUM(bhits), SUM(rhits), hid, page,lang FROM " . $core->modules['stats']->dbname . " WHERE data='" . $previousDay . "' GROUP BY hid, page, lang", $r, $n)) {
                 for ($c = 0; $c < $n; $c++) {
                     list($hits, $uhits, $bhits, $rhits, $hid, $page, $lang) = $core->dbo->fetch_row($r);
                     $core->dbo->simpleQuery("INSERT INTO " . $core->modules['statsdaily']->dbname . " SET lang='{$lang}', hid='{$hid}', data='{$previousDay}', page=\"{$page}\", hits={$hits}, uhits={$uhits}, bhits={$bhits}, rhits={$rhits}");
                 }
             }
         }
         # daily referers:
         $x = $core->dbo->fetch("SELECT hits FROM " . $core->modules['statsrefdaily']->dbname . " WHERE data='" . $previousDay . "'");
         if ($x === false) {
             # nothing yet registered on history
             if ($core->dbo->query("SELECT referer,entrypage,hits FROM " . $core->modules['statsref']->dbname . " WHERE data='" . $previousDay . "'", $r, $n)) {
                 for ($c = 0; $c < $n; $c++) {
                     list($ref, $ep, $hits) = $core->dbo->fetch_row($r);
                     $core->dbo->simpleQuery("INSERT INTO " . $core->modules['statsrefdaily']->dbname . " SET data='{$previousDay}', referer=\"{$ref}\", hits={$hits}, entrypage=\"{$ep}\"");
                 }
             }
         }
     }
     # done
 }