index.php
changeset 542 5841df0ab575
parent 536 218a627eb53e
child 547 0a2c1ce32d91
equal deleted inserted replaced
541:acb7e23b6ffa 542:5841df0ab575
    43   }
    43   }
    44   
    44   
    45   require('includes/common.php');
    45   require('includes/common.php');
    46   
    46   
    47   global $db, $session, $paths, $template, $plugins; // Common objects
    47   global $db, $session, $paths, $template, $plugins; // Common objects
       
    48   $page_timestamp = time();
    48   
    49   
    49   if ( !isset($_GET['do']) )
    50   if ( !isset($_GET['do']) )
    50   {
    51   {
    51     $_GET['do'] = 'view';
    52     $_GET['do'] = 'view';
    52   }
    53   }
    61       $page = new PageProcessor( $paths->page_id, $paths->namespace, $rev_id );
    62       $page = new PageProcessor( $paths->page_id, $paths->namespace, $rev_id );
    62       $page->send_headers = true;
    63       $page->send_headers = true;
    63       $pagepass = ( isset($_REQUEST['pagepass']) ) ? sha1($_REQUEST['pagepass']) : '';
    64       $pagepass = ( isset($_REQUEST['pagepass']) ) ? sha1($_REQUEST['pagepass']) : '';
    64       $page->password = $pagepass;
    65       $page->password = $pagepass;
    65       $page->send(true);
    66       $page->send(true);
       
    67       $page_timestamp = $page->revision_time;
    66       break;
    68       break;
    67     case 'comments':
    69     case 'comments':
    68       $template->header();
    70       $template->header();
    69       $sub = ( isset ($_GET['sub']) ) ? $_GET['sub'] : false;
    71       $sub = ( isset ($_GET['sub']) ) ? $_GET['sub'] : false;
    70       switch($sub)
    72       switch($sub)
   562     $html = aggressive_optimize_html($html);
   564     $html = aggressive_optimize_html($html);
   563     
   565     
   564     // Re-enable output buffering to allow the Gzip function (below) to work
   566     // Re-enable output buffering to allow the Gzip function (below) to work
   565     ob_start();
   567     ob_start();
   566     
   568     
       
   569     // Generate an ETag
       
   570     // format: first 10 digits of SHA1 of page name, user id in hex, page timestamp in hex
       
   571     $etag = substr(sha1($paths->namespace . ':' . $paths->page_id), 0, 10) . '-' .
       
   572             dechex($session->user_id) . '-' .
       
   573             dechex($page_timestamp);
       
   574             
       
   575     if ( isset($_SERVER['HTTP_IF_NONE_MATCH']) )
       
   576     {
       
   577       if ( "\"$etag\"" == $_SERVER['HTTP_IF_NONE_MATCH'] )
       
   578       {
       
   579         header('HTTP/1.1 304 Not Modified');
       
   580         exit();
       
   581       }
       
   582     }
       
   583             
       
   584     header("ETag: \"$etag\"");
       
   585     
   567     // Done, send it to the user
   586     // Done, send it to the user
   568     echo( $html );
   587     echo( $html );
   569   }
   588   }
   570 
   589 
   571   $db->close();  
   590   $db->close();  
   572   gzip_output();
   591   gzip_output();
   573   
   592   
       
   593   @ob_end_flush();
       
   594   
   574 ?>
   595 ?>