예제 #1
0
파일: loader.php 프로젝트: poef/ariadne
 public static function http($options, $ariadne = null, $session = null, $nls = null)
 {
     ar_error::$throwExceptions = true;
     if (!isset($ariadne)) {
         $ariadne = ar_core_ariadne::create($options['AR']);
     }
     if (!isset($session)) {
         if (!isset($options['session']['hideSessionIDFromURL'])) {
             $options['session']['hideSessionIDFromURL'] = $options['AR']->hideSessionIDFromURL;
         }
         $session = new ar_core_session($options['session']);
     }
     if (!isset($nls)) {
         $nlsOptions = $options['AR']->nls;
         $nlsOptions->root = $options['AR']->dir->install . 'lib/nls/';
         $nls = new ar_core_nls($nlsOptions);
     }
     return new ar_core_loader_http($options, $ariadne, $session, $nls);
 }
예제 #2
0
파일: ariadne.php 프로젝트: poef/ariadne
 public function handleRequest($request)
 {
     $loader = $request['loader'];
     $cacheImage = $this->cache->getCacheFilename($request);
     if (isset($request['cache']) && $request['cache'] && $this->isFresh($cacheImage)) {
         $cacheControl = $request['cache'];
         if (is_array($cacheControl)) {
             if ($ifModifiedSince = $cacheControl['if-modified-since'] && strtotime($ifModifiedSince) >= $this->cache->getCreatedTime($cacheImage)) {
                 $loader->header('HTTP/1.1 304 Not Modified');
                 $loader->header('Expires: ' . gmdate(DATE_RFC1123, $this->cache->getStaleTime($cacheImage)));
                 return;
             } else {
                 if ((!isset($cacheControl['max-age']) || ($maxAge = $cacheControl['max-age'] && $this->cache->isYounger($cacheImage, $maxAge))) && (!isset($cacheControl['min-fresh']) || ($minFresh = $cacheControl['min-fresh'] && !$this->cache->isFresher($cacheImage, $minFresh)))) {
                     echo $this->cache->headers($cacheImage);
                     $this->cache->passThru($cacheImage);
                     return;
                 }
             }
         }
     }
     // check only-if-cache here
     // check if we may cache the request result if so start the cache
     $this->cache->start();
     parent::handleRequest($request);
     // check if we may still cache the result
     if ($this->cache->enabled) {
         $this->cache->save($cacheImage, $this->cache->freshness);
     }
 }