573 ob_start(); |
573 ob_start(); |
574 $db->sql_report(); |
574 $db->sql_report(); |
575 break; |
575 break; |
576 } |
576 } |
577 |
577 |
578 // |
578 // Generate an ETag |
579 // Optimize HTML by replacing newlines with spaces (excludes <pre>, <script>, and <style> blocks) |
579 /* |
580 // |
580 // format: first 10 digits of SHA1 of page name, user id in hex, user and auth levels, page timestamp in hex |
581 if ($aggressive_optimize_html) |
581 $etag = substr(sha1($paths->namespace . ':' . $paths->page_id), 0, 10) . '-' . |
|
582 "u{$session->user_id}l{$session->user_level}a{$session->auth_level}-" . |
|
583 dechex($page_timestamp); |
|
584 |
|
585 if ( isset($_SERVER['HTTP_IF_NONE_MATCH']) ) |
582 { |
586 { |
583 // Load up the HTML |
587 if ( "\"$etag\"" == $_SERVER['HTTP_IF_NONE_MATCH'] ) |
584 $html = ob_get_contents(); |
588 { |
585 @ob_end_clean(); |
589 header('HTTP/1.1 304 Not Modified'); |
586 |
590 exit(); |
587 $html = aggressive_optimize_html($html); |
591 } |
588 |
592 } |
589 // Re-enable output buffering to allow the Gzip function (below) to work |
|
590 ob_start(); |
|
591 |
|
592 // Generate an ETag |
|
593 // format: first 10 digits of SHA1 of page name, user id in hex, user and auth levels, page timestamp in hex |
|
594 $etag = substr(sha1($paths->namespace . ':' . $paths->page_id), 0, 10) . '-' . |
|
595 "u{$session->user_id}l{$session->user_level}a{$session->auth_level}-" . |
|
596 dechex($page_timestamp); |
|
597 |
593 |
598 if ( isset($_SERVER['HTTP_IF_NONE_MATCH']) ) |
594 header("ETag: \"$etag\""); |
599 { |
595 */ |
600 if ( "\"$etag\"" == $_SERVER['HTTP_IF_NONE_MATCH'] ) |
|
601 { |
|
602 header('HTTP/1.1 304 Not Modified'); |
|
603 exit(); |
|
604 } |
|
605 } |
|
606 |
|
607 // header("ETag: \"$etag\""); |
|
608 |
|
609 // Done, send it to the user |
|
610 echo( $html ); |
|
611 } |
|
612 |
596 |
613 $db->close(); |
597 $db->close(); |
614 gzip_output(); |
598 gzip_output(); |
615 |
599 |
616 @ob_end_flush(); |
600 @ob_end_flush(); |