includes/pageprocess.php
changeset 32 4d87aad3c4c0
parent 31 dc8741857bde
child 37 7267c2a67a93
equal deleted inserted replaced
31:dc8741857bde 32:4d87aad3c4c0
    58    */
    58    */
    59   
    59   
    60   var $perms = null;
    60   var $perms = null;
    61   
    61   
    62   /**
    62   /**
       
    63    * The SHA1 hash of the user-inputted password for the page
       
    64    * @var string
       
    65    */
       
    66    
       
    67   var $password = '';
       
    68   
       
    69   /**
    63    * Switch to track if redirects are allowed. Defaults to true.
    70    * Switch to track if redirects are allowed. Defaults to true.
    64    * @var bool
    71    * @var bool
    65    */
    72    */
    66   
    73   
    67   var $allow_redir = true;
    74   var $allow_redir = true;
   140     {
   147     {
   141       if ( $paths->pages[$pathskey]['special'] == 1 )
   148       if ( $paths->pages[$pathskey]['special'] == 1 )
   142       {
   149       {
   143         $this->send_headers = false;
   150         $this->send_headers = false;
   144         $strict_no_headers = true;
   151         $strict_no_headers = true;
       
   152       }
       
   153       if ( $paths->pages[$pathskey]['password'] != '' && $paths->pages[$pathskey]['password'] != sha1('') )
       
   154       {
       
   155         $password =& $paths->pages[$pathskey]['password'];
       
   156         if ( $this->password != $password )
       
   157         {
       
   158           $this->err_wrong_password();
       
   159           return false;
       
   160         }
   145       }
   161       }
   146     }
   162     }
   147     if ( $this->namespace == 'Special' || $this->namespace == 'Admin' )
   163     if ( $this->namespace == 'Special' || $this->namespace == 'Admin' )
   148     {
   164     {
   149       if ( !$this->page_exists )
   165       if ( !$this->page_exists )
   470    */
   486    */
   471    
   487    
   472   function _handle_userpage()
   488   function _handle_userpage()
   473   {
   489   {
   474     global $db, $session, $paths, $template, $plugins; // Common objects
   490     global $db, $session, $paths, $template, $plugins; // Common objects
       
   491     global $email;
   475     
   492     
   476     if ( $this->page_id == $paths->cpage['urlname_nons'] && $this->namespace == $paths->namespace )
   493     if ( $this->page_id == $paths->cpage['urlname_nons'] && $this->namespace == $paths->namespace )
   477     {
   494     {
   478       $page_name = ( isset($paths->cpage['name']) ) ? $paths->cpage['name'] : $this->page_id;
   495       $page_name = ( isset($paths->cpage['name']) ) ? $paths->cpage['name'] : $this->page_id;
   479     }
   496     }
   687     $class = 'row3';
   704     $class = 'row3';
   688     
   705     
   689     if ( $userdata['email_public'] == 1 )
   706     if ( $userdata['email_public'] == 1 )
   690     {
   707     {
   691       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   708       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   692       global $email;
       
   693       $email_link = $email->encryptEmail($userdata['email']);
   709       $email_link = $email->encryptEmail($userdata['email']);
   694       echo '<tr><td class="'.$class.'">E-mail address: ' . $email_link . '</td></tr>';
   710       echo '<tr><td class="'.$class.'">E-mail address: ' . $email_link . '</td></tr>';
   695     }
   711     }
   696     
   712     
   697     $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   713     $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   806     }
   822     }
   807     echo $ob;
   823     echo $ob;
   808   }
   824   }
   809   
   825   
   810   /**
   826   /**
       
   827    * Inform the user of an incorrect or absent password
       
   828    * @access private
       
   829    */
       
   830    
       
   831   function err_wrong_password()
       
   832   {
       
   833     global $db, $session, $paths, $template, $plugins; // Common objects
       
   834     
       
   835     $title = 'Password required';
       
   836     $message = ( empty($this->password) ) ? '<p>Access to this page requires a password. Please enter the password for this page below:</p>' : '<p>The password you entered for this page was incorrect. Please enter the password for this page below:</p>';
       
   837     $message .= '<form action="' . makeUrlNS($this->namespace, $this->page_id) . '" method="post">
       
   838                    <p>
       
   839                      <label>Password: <input name="pagepass" type="password" /></label>&nbsp;&nbsp;<input type="submit" value="Submit" />
       
   840                    </p>
       
   841                  </form>';
       
   842     if ( $this->send_headers )
       
   843     {
       
   844       $template->tpl_strings['PAGE_NAME'] = $title;
       
   845       $template->header();
       
   846       echo "$message";
       
   847       $template->footer();
       
   848     }
       
   849     else
       
   850     {
       
   851       echo "<h2>$title</h2>
       
   852             $message";
       
   853     }
       
   854   }
       
   855   
       
   856   /**
   811    * Send the error message to the user complaining that there weren't any rows.
   857    * Send the error message to the user complaining that there weren't any rows.
   812    * @access private
   858    * @access private
   813    */
   859    */
   814   
   860   
   815   function err_no_rows()
   861   function err_no_rows()