includes/pageprocess.php
changeset 372 5bd429428101
parent 369 d0825e599853
child 377 bb3e6c3bd4f4
equal deleted inserted replaced
371:dc6026376919 372:5bd429428101
   129   
   129   
   130   function __construct( $page_id, $namespace, $revision_id = 0 )
   130   function __construct( $page_id, $namespace, $revision_id = 0 )
   131   {
   131   {
   132     global $db, $session, $paths, $template, $plugins; // Common objects
   132     global $db, $session, $paths, $template, $plugins; // Common objects
   133     
   133     
       
   134     profiler_log("PageProcessor [{$namespace}:{$page_id}]: Started constructor");
       
   135     
   134     // See if we can get some debug info
   136     // See if we can get some debug info
   135     if ( function_exists('debug_backtrace') && $this->debug['enable'] )
   137     if ( function_exists('debug_backtrace') && $this->debug['enable'] )
   136     {
   138     {
   137       $this->debug['works'] = true;
   139       $this->debug['works'] = true;
   138       $this->debug['backtrace'] = enano_debug_print_backtrace(true);
   140       $this->debug['backtrace'] = enano_debug_print_backtrace(true);
   146     }
   148     }
   147     
   149     
   148     if ( !is_int($revision_id) )
   150     if ( !is_int($revision_id) )
   149       $revision_id = 0;
   151       $revision_id = 0;
   150     
   152     
       
   153     profiler_log("PageProcessor [{$namespace}:{$page_id}]: Ran initial checks");
       
   154     
   151     $this->_setup( $page_id, $namespace, $revision_id );
   155     $this->_setup( $page_id, $namespace, $revision_id );
   152     
       
   153   }
   156   }
   154   
   157   
   155   /**
   158   /**
   156    * The main method to send the page content. Also responsible for checking permissions and calling the statistics counter.
   159    * The main method to send the page content. Also responsible for checking permissions and calling the statistics counter.
   157    * @param bool If true, the stat counter is called. Defaults to false.
   160    * @param bool If true, the stat counter is called. Defaults to false.
   160   function send( $do_stats = false )
   163   function send( $do_stats = false )
   161   {
   164   {
   162     global $db, $session, $paths, $template, $plugins; // Common objects
   165     global $db, $session, $paths, $template, $plugins; // Common objects
   163     global $lang;
   166     global $lang;
   164     
   167     
       
   168     profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Started send process");
       
   169     
   165     if ( !$this->perms->get_permissions('read') )
   170     if ( !$this->perms->get_permissions('read') )
   166     {
   171     {
   167       $this->err_access_denied();
   172       $this->err_access_denied();
       
   173       profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Finished send process");
   168       return false;
   174       return false;
   169     }
   175     }
   170     $pathskey = $paths->nslist[ $this->namespace ] . $this->page_id;
   176     $pathskey = $paths->nslist[ $this->namespace ] . $this->page_id;
   171     $strict_no_headers = false;
   177     $strict_no_headers = false;
   172     if ( $this->namespace == 'Admin' && strstr($this->page_id, '/') )
   178     if ( $this->namespace == 'Admin' && strstr($this->page_id, '/') )
   191         {
   197         {
   192           $password =& $paths->pages[$pathskey]['password'];
   198           $password =& $paths->pages[$pathskey]['password'];
   193           if ( $this->password != $password )
   199           if ( $this->password != $password )
   194           {
   200           {
   195             $this->err_wrong_password();
   201             $this->err_wrong_password();
       
   202             profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Finished send process");
   196             return false;
   203             return false;
   197           }
   204           }
   198         }
   205         }
   199       }
   206       }
   200     }
   207     }
   209         die_semicritical('Exception in PageProcessor', '<p>Special page not existent but exception not previously caught by path manager.</p>');
   216         die_semicritical('Exception in PageProcessor', '<p>Special page not existent but exception not previously caught by path manager.</p>');
   210       }
   217       }
   211       $func_name = "page_{$this->namespace}_{$this->page_id}";
   218       $func_name = "page_{$this->namespace}_{$this->page_id}";
   212       if ( function_exists($func_name) )
   219       if ( function_exists($func_name) )
   213       {
   220       {
   214         return @call_user_func($func_name);
   221         profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Calling special/admin page");
       
   222         $result = @call_user_func($func_name);
       
   223         profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Finished send process");
       
   224         return $result;
   215       }
   225       }
   216       else
   226       else
   217       {
   227       {
   218         $title = $lang->get('page_err_custompage_function_missing_title');
   228         $title = $lang->get('page_err_custompage_function_missing_title');
   219         $message = $lang->get('page_err_custompage_function_missing_body', array( 'function_name' => $fname ));
   229         $message = $lang->get('page_err_custompage_function_missing_body', array( 'function_name' => $fname ));
   228         else
   238         else
   229         {
   239         {
   230           echo "<h2>$title</h2>
   240           echo "<h2>$title</h2>
   231                 <p>$message</p>";
   241                 <p>$message</p>";
   232         }
   242         }
       
   243         profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Finished send process");
   233         return false;
   244         return false;
   234       }
   245       }
   235     }
   246     }
   236     else if ( $this->namespace == 'User' && strpos($this->page_id, '/') === false )
   247     else if ( $this->namespace == 'User' && strpos($this->page_id, '/') === false )
   237     {
   248     {
   295       
   306       
   296       $text = $this->fetch_text();
   307       $text = $this->fetch_text();
   297       if ( $text == 'err_no_text_rows' )
   308       if ( $text == 'err_no_text_rows' )
   298       {
   309       {
   299         $this->err_no_rows();
   310         $this->err_no_rows();
       
   311         profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Finished send process");
   300         return false;
   312         return false;
   301       }
   313       }
   302       else
   314       else
   303       {
   315       {
   304         $redirect = ( isset($_GET['redirect']) ) ? $_GET['redirect'] : 'YES YOU IDIOT';
   316         $redirect = ( isset($_GET['redirect']) ) ? $_GET['redirect'] : 'YES YOU IDIOT';
   325         {
   337         {
   326           $this->render( (!$strict_no_headers) );
   338           $this->render( (!$strict_no_headers) );
   327         }
   339         }
   328       }
   340       }
   329     }
   341     }
       
   342     profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Finished send process");
   330   }
   343   }
   331   
   344   
   332   /**
   345   /**
   333    * Fetches the wikitext or HTML source for the page.
   346    * Fetches the wikitext or HTML source for the page.
   334    * @return string
   347    * @return string
   594       
   607       
   595     }
   608     }
   596     
   609     
   597     $this->title = get_page_title_ns($this->page_id, $this->namespace);
   610     $this->title = get_page_title_ns($this->page_id, $this->namespace);
   598     
   611     
       
   612     profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Ran _setup()");
   599   }
   613   }
   600   
   614   
   601   /**
   615   /**
   602    * Renders it all in one go, and echoes it out. This assumes that the text is in the DB.
   616    * Renders it all in one go, and echoes it out. This assumes that the text is in the DB.
   603    * @access private
   617    * @access private