equal
deleted
inserted
replaced
155 } |
155 } |
156 |
156 |
157 if ( !is_int($revision_id) ) |
157 if ( !is_int($revision_id) ) |
158 $revision_id = 0; |
158 $revision_id = 0; |
159 |
159 |
160 profiler_log("PageProcessor [{$namespace}:{$page_id}]: Ran initial checks"); |
|
161 |
|
162 $this->_setup( $page_id, $namespace, $revision_id ); |
160 $this->_setup( $page_id, $namespace, $revision_id ); |
163 } |
161 } |
164 |
162 |
165 /** |
163 /** |
166 * The main method to send the page content. Also responsible for checking permissions and calling the statistics counter. |
164 * The main method to send the page content. Also responsible for checking permissions and calling the statistics counter. |
170 function send( $do_stats = false ) |
168 function send( $do_stats = false ) |
171 { |
169 { |
172 global $db, $session, $paths, $template, $plugins; // Common objects |
170 global $db, $session, $paths, $template, $plugins; // Common objects |
173 global $lang; |
171 global $lang; |
174 |
172 |
175 profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Started send process"); |
173 profiler_log('PageProcessor: send() called'); |
176 |
174 |
177 if ( !$this->perms->get_permissions('read') ) |
175 if ( !$this->perms->get_permissions('read') ) |
178 { |
176 { |
179 if ( $this->send_headers ) |
177 if ( $this->send_headers ) |
180 { |
178 { |
188 } |
186 } |
189 else |
187 else |
190 { |
188 { |
191 // Page isn't whitelisted, behave as normal |
189 // Page isn't whitelisted, behave as normal |
192 $this->err_access_denied(); |
190 $this->err_access_denied(); |
193 profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Finished send process"); |
|
194 return false; |
191 return false; |
195 } |
192 } |
196 } |
193 } |
197 |
194 |
198 // Is there a custom function registered for handling this namespace? |
195 // Is there a custom function registered for handling this namespace? |
235 { |
232 { |
236 $password =& $paths->pages[$pathskey]['password']; |
233 $password =& $paths->pages[$pathskey]['password']; |
237 if ( $this->password != $password ) |
234 if ( $this->password != $password ) |
238 { |
235 { |
239 $this->err_wrong_password(); |
236 $this->err_wrong_password(); |
240 profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Finished send process"); |
|
241 return false; |
237 return false; |
242 } |
238 } |
243 } |
239 } |
244 } |
240 } |
245 } |
241 } |
246 if ( $this->page_exists && $this->namespace != 'Special' && $this->namespace != 'Admin' && $do_stats ) |
242 if ( $this->page_exists && $this->namespace != 'Special' && $this->namespace != 'Admin' && $do_stats ) |
247 { |
243 { |
|
244 require_once(ENANO_ROOT.'/includes/stats.php'); |
248 doStats($this->page_id, $this->namespace); |
245 doStats($this->page_id, $this->namespace); |
249 } |
246 } |
250 if ( $this->namespace == 'Special' || $this->namespace == 'Admin' ) |
247 if ( $this->namespace == 'Special' || $this->namespace == 'Admin' ) |
251 { |
248 { |
252 if ( $this->send_headers ) |
249 if ( $this->send_headers ) |
263 die_semicritical($lang->get('page_msg_admin_404_title'), $lang->get('page_msg_admin_404_body', array('func_name' => $func_name)), (!$this->send_headers)); |
260 die_semicritical($lang->get('page_msg_admin_404_title'), $lang->get('page_msg_admin_404_body', array('func_name' => $func_name)), (!$this->send_headers)); |
264 } |
261 } |
265 $func_name = "page_{$this->namespace}_{$this->page_id}"; |
262 $func_name = "page_{$this->namespace}_{$this->page_id}"; |
266 if ( function_exists($func_name) ) |
263 if ( function_exists($func_name) ) |
267 { |
264 { |
268 profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Calling special/admin page"); |
|
269 $result = @call_user_func($func_name); |
265 $result = @call_user_func($func_name); |
270 profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Finished send process"); |
|
271 return $result; |
266 return $result; |
272 } |
267 } |
273 else |
268 else |
274 { |
269 { |
275 $title = $lang->get('page_err_custompage_function_missing_title'); |
270 $title = $lang->get('page_err_custompage_function_missing_title'); |
285 else |
280 else |
286 { |
281 { |
287 echo "<h2>$title</h2> |
282 echo "<h2>$title</h2> |
288 <p>$message</p>"; |
283 <p>$message</p>"; |
289 } |
284 } |
290 profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Finished send process"); |
|
291 return false; |
285 return false; |
292 } |
286 } |
293 } |
287 } |
294 else if ( $this->namespace == 'User' && strpos($this->page_id, '/') === false ) |
288 else if ( $this->namespace == 'User' && strpos($this->page_id, '/') === false ) |
295 { |
289 { |
370 if ( $this->send_headers ) |
364 if ( $this->send_headers ) |
371 { |
365 { |
372 $template->init_vars($this); |
366 $template->init_vars($this); |
373 } |
367 } |
374 |
368 |
375 // die($this->page_id); |
|
376 |
|
377 $text = $this->fetch_text(); |
369 $text = $this->fetch_text(); |
|
370 |
378 if ( $text == 'err_no_text_rows' ) |
371 if ( $text == 'err_no_text_rows' ) |
379 { |
372 { |
380 $this->err_no_rows(); |
373 $this->err_no_rows(); |
381 profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Finished send process"); |
|
382 return false; |
374 return false; |
383 } |
375 } |
384 else |
376 else |
385 { |
377 { |
386 $redirect = ( isset($_GET['redirect']) ) ? $_GET['redirect'] : 'YES YOU IDIOT'; |
378 $redirect = ( isset($_GET['redirect']) ) ? $_GET['redirect'] : 'YES YOU IDIOT'; |
407 { |
399 { |
408 $this->render( (!$strict_no_headers) ); |
400 $this->render( (!$strict_no_headers) ); |
409 } |
401 } |
410 } |
402 } |
411 } |
403 } |
412 profiler_log("PageProcessor [{$this->namespace}:{$this->page_id}]: Finished send process"); |
|
413 } |
404 } |
414 |
405 |
415 /** |
406 /** |
416 * Fetches the wikitext or HTML source for the page. |
407 * Fetches the wikitext or HTML source for the page. |
417 * @return string |
408 * @return string |
1027 { |
1018 { |
1028 global $db, $session, $paths, $template, $plugins; // Common objects |
1019 global $db, $session, $paths, $template, $plugins; // Common objects |
1029 global $lang; |
1020 global $lang; |
1030 |
1021 |
1031 $text = $this->fetch_text(); |
1022 $text = $this->fetch_text(); |
|
1023 |
1032 $text = preg_replace('/([\s]*)__NOBREADCRUMBS__([\s]*)/', '', $text); |
1024 $text = preg_replace('/([\s]*)__NOBREADCRUMBS__([\s]*)/', '', $text); |
1033 $text = preg_replace('/([\s]*)__NOTOC__([\s]*)/', '', $text); |
1025 $text = preg_replace('/([\s]*)__NOTOC__([\s]*)/', '', $text); |
1034 |
1026 |
1035 $redir_enabled = false; |
1027 $redir_enabled = false; |
1036 if ( preg_match('/^#redirect \[\[([^\]]+?)\]\]/i', $text, $match ) ) |
1028 if ( preg_match('/^#redirect \[\[([^\]]+?)\]\]/i', $text, $match ) ) |
1226 $db->free_result(); |
1218 $db->free_result(); |
1227 |
1219 |
1228 } |
1220 } |
1229 else |
1221 else |
1230 { |
1222 { |
1231 |
|
1232 $q = $db->sql_query('SELECT t.page_text, t.char_tag, l.time_id FROM '.table_prefix."page_text AS t\n" |
1223 $q = $db->sql_query('SELECT t.page_text, t.char_tag, l.time_id FROM '.table_prefix."page_text AS t\n" |
1233 . " LEFT JOIN " . table_prefix . "logs AS l\n" |
1224 . " LEFT JOIN " . table_prefix . "logs AS l\n" |
1234 . " ON ( l.page_id = t.page_id AND l.namespace = t.namespace )\n" |
1225 . " ON ( l.page_id = t.page_id AND l.namespace = t.namespace )\n" |
1235 . " WHERE t.page_id='$this->page_id' AND t.namespace='$this->namespace'\n" |
1226 . " WHERE t.page_id='$this->page_id' AND t.namespace='$this->namespace'\n" |
1236 . " ORDER BY l.time_id DESC LIMIT 1;"); |
1227 . " ORDER BY l.time_id DESC LIMIT 1;"); |