Ejemplo n.º 1
0
 /**
  * methods used statically from the pagecache files
  */
 public static 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;
 }