Beispiel #1
0
 public function dispatchCached()
 {
     $cache_settings = Ak::getSettings('caching', false);
     if ($cache_settings['enabled']) {
         $null = null;
         $pageCache = new AkCacheHandler();
         $pageCache->init($null, $cache_settings);
         if (isset($_GET['allow_get'])) {
             $options['include_get_parameters'] = explode(',', $_GET['allow_get']);
         }
         if (isset($_GET['use_if_modified_since'])) {
             $options['use_if_modified_since'] = true;
         }
         if (($cachedPage = $pageCache->getCachedPage()) !== false) {
             return $cachedPage->render();
         }
     }
     return false;
 }
Beispiel #2
0
 public function _init($url, $constants = array(), $controllerVars = array())
 {
     $this->_reset();
     $this->_response = null;
     $this->_cacheHeaders = array();
     $this->_setConstants($constants);
     $parts = parse_url($url);
     $_REQUEST['ak'] = isset($parts['path']) ? $parts['path'] : '/';
     $_SERVER['AK_HOST'] = isset($parts['host']) ? $parts['host'] : 'localhost';
     $cache_settings = Ak::getSettings('caching', false);
     if ($cache_settings['enabled']) {
         $null = null;
         $pageCache = new AkCacheHandler();
         $pageCache->init($null, $cache_settings);
         if ($cachedPage = $pageCache->getCachedPage()) {
             static $_cachedHeaders = array();
             ob_start();
             global $sendHeaders, $returnHeaders, $exit;
             $sendHeaders = false;
             $returnHeaders = true;
             $exit = false;
             $headers = (include $cachedPage);
             //$headers = $cachedPage->render(false,false,true);
             $this->_response = ob_get_clean();
             if (is_array($headers)) {
                 $this->_cacheHeaders = $headers;
             }
             return true;
         }
     }
     $this->Dispatcher = new AkTestDispatcher($controllerVars);
 }
Beispiel #3
0
 static function &getInstance(AkActionController &$Controller)
 {
     if (!($CacheHandler = Ak::getStaticVar('AkCacheHandlerSingleton'))) {
         $settings = Ak::getSettings('caching', false);
         if (!empty($settings['enabled'])) {
             $CacheHandler = new AkCacheHandler();
             $CacheHandler->init($Controller);
             Ak::setStaticVar('AkCacheHandlerSingleton', $CacheHandler);
         }
     }
     return $CacheHandler;
 }
Beispiel #4
0
    /**
     * methods used statically from the pagecache files
     */
    function _handleIfModifiedSince($modifiedTimestamp, $exit=true,$sendHeaders = true, $returnHeaders = false)
    {
        $headers = array();
        $expiryTimestamp = time() + 60*60;
        $time = null;
        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
            $time = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
            $ifModifiedSince = preg_replace('/;.*$/', '', $time);
            $timestamp = strtotime($ifModifiedSince);
        } else {
            $timestamp = 0;
        }


        $gmTime = mktime(gmdate('H'), gmdate('i'), gmdate('s'), gmdate('m'), gmdate('d'), gmdate('Y'));
        $time = time();
        $diff = $time - $gmTime;
        if ($modifiedTimestamp <= $timestamp) {
            if ($sendHeaders) {
                header('HTTP/1.1 304 Not Modified');
            }
            if ($returnHeaders) {
                $headers[] = 'Status: 304';
            }
            $addHeaders = AkCacheHandler::_sendAdditionalHeaders($sendHeaders, $returnHeaders);
            $headers = array_merge($addHeaders, $headers);
            if ($exit) {
                exit;
            }

            if ($returnHeaders) {

                return $headers;
            }
        } else {
            if ($sendHeaders) {
                header('Last-Modified: '.gmdate('D, d M Y H:i:s', $modifiedTimestamp).' GMT');
            } else if ($returnHeaders) {
                $headers[]='Last-Modified: '.gmdate('D, d M Y H:i:s', $modifiedTimestamp).' GMT';
            }
        }
        return $headers;
    }
Beispiel #5
0
        @ini_set('display_errors', 1);
        require(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.
        'app'.DIRECTORY_SEPARATOR.'controllers'.DIRECTORY_SEPARATOR.'framework_setup_controller.php');
        exit;
    }else{
        include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');
    }
}
/**
 * Check cache here, render cache with headers
*/
$cache_settings = @include AK_CONFIG_DIR.DS.'cache'.DS.AK_ENVIRONMENT.DS.'caching.php';
if ($cache_settings!==false && $cache_settings['enabled']) {
    require(AK_LIB_DIR . DS . 'AkActionController'.DS.'AkCacheHandler.php');
    $null = null;
    $pageCache = new AkCacheHandler();
    $pageCache->init($null,$cache_settings);
    if (($cachedPage = $pageCache->getCachedPage())!==false) {
        global $sendHeaders, $returnHeaders, $exit;
        $sendHeaders = true;
        $returnHeaders = false; 
        $exit = true;
        include $cachedPage;
    }
}
require_once(AK_LIB_DIR . DS . 'AkDispatcher.php');
$Dispatcher =& new AkDispatcher();
$Dispatcher->dispatch();


?>