diff -r 40105681f495 -r 663fcf528726 includes/pageprocess.php --- a/includes/pageprocess.php Sat Jun 23 19:27:41 2007 -0400 +++ b/includes/pageprocess.php Tue Jun 26 17:28:18 2007 -0400 @@ -1,7 +1,7 @@ true, + 'enable' => false, 'works' => false ); @@ -87,9 +94,10 @@ * Constructor. * @param string The page ID (urlname) of the page * @param string The namespace of the page + * @param int Optional. The revision ID to send. */ - function __construct( $page_id, $namespace ) + function __construct( $page_id, $namespace, $revision_id = 0 ) { global $db, $session, $paths, $template, $plugins; // Common objects @@ -107,7 +115,10 @@ $this->send_error('The namespace "' . htmlspecialchars($namespace) . '" does not exist.'); } - $this->_setup( $page_id, $namespace ); + if ( !is_int($revision_id) ) + $revision_id = 0; + + $this->_setup( $page_id, $namespace, $revision_id ); } @@ -195,6 +206,9 @@ else // (disabled for compatibility reasons) if ( in_array($this->namespace, array('Article', 'User', 'Project', 'Help', 'File', 'Category')) && $this->page_exists ) { // Send as regular page + + // die($this->page_id); + $text = $this->fetch_text(); if ( $text == 'err_no_text_rows' ) { @@ -213,7 +227,7 @@ * @access private */ - function _setup($page_id, $namespace) + function _setup($page_id, $namespace, $revision_id) { global $db, $session, $paths, $template, $plugins; // Common objects @@ -221,6 +235,7 @@ $this->page_id = $page_id_cleaned; $this->namespace = $namespace; + $this->revision_id = $revision_id; $this->page_id_unclean = dirtify_page_id($page_id); $this->perms = $session->fetch_page_acl( $page_id, $namespace ); @@ -244,6 +259,27 @@ { $this->page_exists = true; } + + // Compatibility with older databases + if ( strstr($this->page_id, '.2e') && !$this->page_exists ) + { + $page_id = str_replace('.2e', '.', $page_id); + + if ( $paths->cpage['urlname_nons'] == $page_id && $paths->namespace == $namespace && !$paths->page_exists && ( $this->namespace != 'Admin' || ($this->namespace == 'Admin' && !function_exists($fname) ) ) ) + { + $this->page_exists = false; + } + else if ( !isset( $paths->pages[ $paths->nslist[$namespace] . $page_id ] ) && ( $this->namespace == 'Admin' && !function_exists($fname) ) ) + { + $this->page_exists = false; + } + else + { + $this->page_exists = true; + } + + } + } /** @@ -256,19 +292,24 @@ $text = $this->fetch_text(); $this->header(); - if ( $this->send_headers ) + // if ( $this->send_headers ) + // { + display_page_headers(); + // } + + if ( $this->revision_id ) { - display_page_headers(); + echo '
Notice:
The page you are viewing was archived on '.date('F d, Y \a\t h:i a', $this->revision_id).'.
View current version | Restore this version

'; } $text = '?>' . RenderMan::render($text); // echo('
'.htmlspecialchars($text).'
'); eval ( $text ); - if ( $this->send_headers ) - { + // if ( $this->send_headers ) + // { display_page_footers(); - } + // } $this->footer(); } @@ -309,19 +350,83 @@ return $this->text_cache; } - $q = $db->sql_query('SELECT page_text, char_tag FROM '.table_prefix.'page_text WHERE page_id=\'' . $this->page_id . '\' AND namespace=\'' . $this->namespace . '\';'); - if ( !$q ) - { - $this->send_error('Error during SQL query.', true); - } - if ( $db->numrows() < 1 ) + if ( $this->revision_id > 0 && is_int($this->revision_id) ) { - $this->page_exists = false; - return 'err_no_text_rows'; + + $q = $db->sql_query('SELECT page_text, char_tag, date_string FROM '.table_prefix.'logs WHERE page_id=\'' . $this->page_id . '\' AND namespace=\'' . $this->namespace . '\' AND time_id=' . $this->revision_id . ';'); + if ( !$q ) + { + $this->send_error('Error during SQL query.', true); + } + if ( $db->numrows() < 1 ) + { + // Compatibility fix for old pages with dots in the page ID + if ( strstr($this->page_id, '.2e') ) + { + $db->free_result(); + $page_id = str_replace('.2e', '.', $this->page_id); + $q = $db->sql_query('SELECT page_text, char_tag, date_string FROM '.table_prefix.'logs WHERE page_id=\'' . $page_id . '\' AND namespace=\'' . $this->namespace . '\' AND time_id=' . $this->revision_id . ';'); + if ( !$q ) + { + $this->send_error('Error during SQL query.', true); + } + if ( $db->numrows() < 1 ) + { + $this->page_exists = false; + return 'err_no_text_rows'; + } + } + else + { + $this->page_exists = false; + return 'err_no_text_rows'; + } + } + else + { + $row = $db->fetchrow(); + } + + $db->free_result(); + } - - $row = $db->fetchrow(); - $db->free_result(); + else + { + + $q = $db->sql_query('SELECT page_text, char_tag FROM '.table_prefix.'page_text WHERE page_id=\'' . $this->page_id . '\' AND namespace=\'' . $this->namespace . '\';'); + if ( !$q ) + { + $this->send_error('Error during SQL query.', true); + } + if ( $db->numrows() < 1 ) + { + // Compatibility fix for old pages with dots in the page ID + if ( strstr($this->page_id, '.2e') ) + { + $db->free_result(); + $page_id = str_replace('.2e', '.', $this->page_id); + $q = $db->sql_query('SELECT page_text, char_tag FROM '.table_prefix.'page_text WHERE page_id=\'' . $page_id . '\' AND namespace=\'' . $this->namespace . '\';'); + if ( !$q ) + { + $this->send_error('Error during SQL query.', true); + } + if ( $db->numrows() < 1 ) + { + $this->page_exists = false; + return 'err_no_text_rows'; + } + } + else + { + $this->page_exists = false; + return 'err_no_text_rows'; + } + } + + $row = $db->fetchrow(); + $db->free_result(); + + } if ( !empty($row['char_tag']) ) { @@ -380,12 +485,11 @@ $this->header(); - if ( $send_headers ) - { + // if ( $send_headers ) + // { display_page_headers(); - } + // } - /* // Start left sidebar: basic user info, latest comments echo ''; @@ -400,7 +504,6 @@ '; echo '
'; - */ // User's own content @@ -416,8 +519,6 @@ $this->err_page_not_existent(); } - /* - // Right sidebar echo ''; @@ -432,12 +533,10 @@ echo '
'; - if ( $send_headers ) - { + // if ( $send_headers ) + // { display_page_footers(); - } - - */ + // } $this->send_headers = $send_headers; unset($send_headers); @@ -543,13 +642,13 @@ * @see PageProcessor::__construct() */ - function PageProcessor( $page_id, $namespace ) + function PageProcessor( $page_id, $namespace, $revision_id = 0 ) { - $this->__construct($page_id, $namespace); + $this->__construct($page_id, $namespace, $revision_id); } /** - * Send an error message and die + * Send an error message and die. For debugging or critical technical errors only - nothing that would under normal circumstances be shown to the user. * @var string Error message * @var bool If true, send DBAL's debugging information as well */