includes/pageprocess.php
changeset 15 ad5986a53197
parent 9 1e61232606d6
child 16 64e0d3d4cf14
equal deleted inserted replaced
14:ce6053bb48d8 15:ad5986a53197
    30   
    30   
    31   var $page_id;
    31   var $page_id;
    32   var $namespace;
    32   var $namespace;
    33   
    33   
    34   /**
    34   /**
       
    35    * Unsanitized page ID.
       
    36    * @var string
       
    37    */
       
    38   
       
    39   var $page_id_unclean;
       
    40   
       
    41   /**
    35    * Tracks if the page we're loading exists in the database or not.
    42    * Tracks if the page we're loading exists in the database or not.
    36    * @var bool
    43    * @var bool
    37    */
    44    */
    38   
    45   
    39   var $page_exists = false;
    46   var $page_exists = false;
   146                 <p>$message</p>";
   153                 <p>$message</p>";
   147         }
   154         }
   148         return false;
   155         return false;
   149       }
   156       }
   150     }
   157     }
       
   158     else if ( $this->namespace == 'User' )
       
   159     {
       
   160       $this->_handle_userpage();
       
   161     }
   151     else if ( ( $this->namespace == 'Template' || $this->namespace == 'System' ) && $this->page_exists )
   162     else if ( ( $this->namespace == 'Template' || $this->namespace == 'System' ) && $this->page_exists )
   152     {
   163     {
   153       $this->header();
   164       $this->header();
   154       
   165       
   155       $text = $this->fetch_text();
   166       $text = $this->fetch_text();
   179       if ( empty($ob) )
   190       if ( empty($ob) )
   180       {
   191       {
   181         $this->err_page_not_existent();
   192         $this->err_page_not_existent();
   182       }
   193       }
   183     }
   194     }
   184     else // if ( in_array($this->namespace, array('Article', 'User', 'Project', 'Help', 'File', 'Category')) && $this->page_exists )
   195     else // (disabled for compatibility reasons) if ( in_array($this->namespace, array('Article', 'User', 'Project', 'Help', 'File', 'Category')) && $this->page_exists )
   185     {
   196     {
   186       // Send as regular page
   197       // Send as regular page
   187       $text = $this->fetch_text();
   198       $text = $this->fetch_text();
   188       if ( $text == 'err_no_text_rows' )
   199       if ( $text == 'err_no_text_rows' )
   189       {
   200       {
   193       else
   204       else
   194       {
   205       {
   195         $this->render();
   206         $this->render();
   196       }
   207       }
   197     }
   208     }
   198     
       
   199     
       
   200   }
   209   }
   201   
   210   
   202   /**
   211   /**
   203    * Sets internal variables.
   212    * Sets internal variables.
   204    * @access private
   213    * @access private
   210     
   219     
   211     $page_id_cleaned = sanitize_page_id($page_id);
   220     $page_id_cleaned = sanitize_page_id($page_id);
   212     
   221     
   213     $this->page_id = $page_id_cleaned;
   222     $this->page_id = $page_id_cleaned;
   214     $this->namespace = $namespace;
   223     $this->namespace = $namespace;
       
   224     $this->page_id_unclean = dirtify_page_id($page_id);
   215     
   225     
   216     $this->perms = $session->fetch_page_acl( $page_id, $namespace );
   226     $this->perms = $session->fetch_page_acl( $page_id, $namespace );
   217     
   227     
   218     // Exception for Admin: pages
   228     // Exception for Admin: pages
   219     if ( $this->namespace == 'Admin' )
   229     if ( $this->namespace == 'Admin' )
   330     return $row['page_text'];
   340     return $row['page_text'];
   331     
   341     
   332   }
   342   }
   333   
   343   
   334   /**
   344   /**
       
   345    * Handles the extra overhead required for user pages.
       
   346    * @access private
       
   347    */
       
   348    
       
   349   function _handle_userpage()
       
   350   {
       
   351     global $db, $session, $paths, $template, $plugins; // Common objects
       
   352     
       
   353     if ( $this->page_id == $paths->cpage['urlname_nons'] && $this->namespace == $paths->namespace )
       
   354     {
       
   355       $page_name = ( isset($paths->cpage['name']) ) ? $paths->cpage['name'] : $this->page_id;
       
   356     }
       
   357     else
       
   358     {
       
   359       $page_name = ( isset($paths->pages[$this->page_id]) ) ? $paths->pages[$this->page_id]['name'] : $this->page_id;
       
   360     }
       
   361     
       
   362     if ( $page_name == str_replace('_', ' ', $this->page_id) || $page_name == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) )
       
   363     {
       
   364       $target_username = strtr($page_name, 
       
   365         Array(
       
   366           '_' => ' ',
       
   367           '<' => '&lt;',
       
   368           '>' => '&gt;'
       
   369           ));
       
   370       $target_username = preg_replace('/^' . preg_quote($paths->nslist['User']) . '/', '', $target_username);
       
   371       $page_name = "$target_username's user page";
       
   372     }
       
   373     else
       
   374     {
       
   375       // User has a custom title for their userpage
       
   376       $page_name = $paths->pages[ $paths->nslist[$this->namespace] . $this->page_id ]['name'];
       
   377     }
       
   378     
       
   379     $template->tpl_strings['PAGE_NAME'] = htmlspecialchars($page_name);
       
   380     
       
   381     $this->header();
       
   382     
       
   383     if ( $send_headers )
       
   384     {
       
   385       display_page_headers();
       
   386     }
       
   387     
       
   388     // Start left sidebar: basic user info, latest comments
       
   389     
       
   390     echo '<table border="0" cellspacing="4" cellpadding="0" style="width: 100%;">';
       
   391     echo '<tr><td style="width: 150px;">';
       
   392     
       
   393     echo '<div class="tblholder">
       
   394             <table border="0" cellspacing="1" cellpadding="4">';
       
   395     
       
   396     // Main part of sidebar
       
   397             
       
   398     echo '  </table>
       
   399           </div>';
       
   400     
       
   401     echo '</td><td>';
       
   402     
       
   403     // User's own content
       
   404     
       
   405     $send_headers = $this->send_headers;
       
   406     $this->send_headers = false;
       
   407     
       
   408     if ( $this->page_exists )
       
   409     {
       
   410       $this->render();
       
   411     }
       
   412     else
       
   413     {
       
   414       $this->err_page_not_existent();
       
   415     }
       
   416     
       
   417     // Right sidebar
       
   418     
       
   419     echo '</td><td style="width: 150px;">';
       
   420     
       
   421     echo '<div class="tblholder">
       
   422             <table border="0" cellspacing="1" cellpadding="4">';
       
   423     
       
   424     // Main part of sidebar
       
   425             
       
   426     echo '  </table>
       
   427           </div>';
       
   428           
       
   429     echo '</tr></table>';
       
   430     
       
   431     if ( $send_headers )
       
   432     {
       
   433       display_page_footers();
       
   434     }
       
   435     
       
   436     $this->send_headers = $send_headers;
       
   437     unset($send_headers);
       
   438     
       
   439     $this->footer();
       
   440     
       
   441   }
       
   442   
       
   443   /**
   335    * Send the error message to the user that the access to this page is denied.
   444    * Send the error message to the user that the access to this page is denied.
   336    * @access private
   445    * @access private
   337    */
   446    */
   338   
   447   
   339   function err_access_denied()
   448   function err_access_denied()