Beispiel #1
0
 public function getwidget()
 {
     $this->load->model('tool/nitro');
     require_once DIR_SYSTEM . 'nitro/core/top.php';
     if (!empty($_SESSION['NitroRenderTime']) && !empty($_SESSION['NitroNameOfCacheFile'])) {
         if (decideToShowFrontWidget()) {
             $renderTime = $_SESSION['NitroRenderTime'];
             $nameOfCacheFile = $_SESSION['NitroNameOfCacheFile'];
             $originalRenderTime = (double) getLoadTime($nameOfCacheFile);
             $faster = (int) ($originalRenderTime / $renderTime);
             require_once NITRO_FOLDER . 'core/frontwidget.php';
             exit;
         }
     }
 }
<?php

if (function_exists('passesPageCacheValidation') && (passesPageCacheValidation() || isPreCacheRequest()) && decideToShowFrontWidget()) {
    ?>
<script type="text/javascript">
var xhr;
if (window.XMLHttpRequest){xhr=new XMLHttpRequest();}
else{xhr=new ActiveXObject("Microsoft.XMLHTTP");}
xhr.onreadystatechange=function(){if (xhr.readyState==4 && xhr.status==200){$('body').append(xhr.responseText);}}
xhr.open("GET","index.php?route=tool/nitro/getwidget",true);
xhr.send();
</script>
<?php 
}
Beispiel #3
0
function serveCacheIfNecessary()
{
    if (!isset($_SESSION)) {
        session_start();
    }
    if (passesPageCacheValidation() == false) {
        return false;
    }
    $cachefile = NITRO_PAGECACHE_FOLDER . generateNameOfCacheFile();
    if (file_exists($cachefile) && time() - NITROCACHE_TIME < filemtime($cachefile)) {
        $before = microtime(true);
        header('Content-type: text/html; charset=utf-8');
        serveBrowserCacheHeadersIfNecessary();
        if (loadGzipHeadersIfNecessary() == true) {
            readfile($cachefile . '.gz');
        } else {
            readfile($cachefile);
        }
        $after = microtime(true);
        if (decideToShowFrontWidget()) {
            $renderTime = $after - $before;
            $nameOfCacheFile = generateNameOfCacheFile();
            $originalRenderTime = (double) getLoadTime();
            $faster = (int) ($originalRenderTime / $renderTime);
            include NITRO_FOLDER . 'core/frontwidget.php';
        }
        exit;
    }
}