87 |
87 |
88 return htmlspecialchars($message); |
88 return htmlspecialchars($message); |
89 } |
89 } |
90 |
90 |
91 /** |
91 /** |
92 * Basically a frontend to RenderMan::getPage(), with the ability to send valid data for nonexistent pages |
92 * DEPRECATED. Previously returned the full rendered contents of a page. |
93 * @param $page the full page id (Namespace:Pagename) |
93 * @param $page the full page id (Namespace:Pagename) |
94 * @param $send_headers true if the theme headers should be sent (still dependent on current page settings), false otherwise |
94 * @param $send_headers true if the theme headers should be sent (still dependent on current page settings), false otherwise |
95 * @return string |
95 * @return string |
96 */ |
96 */ |
97 |
97 |
98 public static function getpage($page, $send_headers = false, $hist_id = false) |
98 public static function getpage($page, $send_headers = false, $hist_id = false) |
99 { |
99 { |
100 die('PageUtils->getpage is deprecated.'); |
100 die('PageUtils->getpage is deprecated.'); |
101 global $db, $session, $paths, $template, $plugins; // Common objects |
|
102 ob_start(); |
|
103 $pid = RenderMan::strToPageID($page); |
|
104 //die('<pre>'.print_r($pid, true).'</pre>'); |
|
105 if(isset($paths->pages[$page]['password']) && strlen($paths->pages[$page]['password']) == 40) |
|
106 { |
|
107 password_prompt($page); |
|
108 } |
|
109 if(isset($paths->pages[$page])) |
|
110 { |
|
111 doStats($pid[0], $pid[1]); |
|
112 } |
|
113 if($paths->custom_page || $pid[1] == 'Special') |
|
114 { |
|
115 // If we don't have access to the page, get out and quick! |
|
116 if(!$session->get_permissions('read') && $pid[0] != 'Login' && $pid[0] != 'Register') |
|
117 { |
|
118 $template->tpl_strings['PAGE_NAME'] = 'Access denied'; |
|
119 |
|
120 if ( $send_headers ) |
|
121 { |
|
122 $template->header(); |
|
123 } |
|
124 |
|
125 echo '<div class="error-box"><b>Access to this page is denied.</b><br />This may be because you are not logged in or you have not met certain criteria for viewing this page.</div>'; |
|
126 |
|
127 if ( $send_headers ) |
|
128 { |
|
129 $template->footer(); |
|
130 } |
|
131 |
|
132 $r = ob_get_contents(); |
|
133 ob_end_clean(); |
|
134 return $r; |
|
135 } |
|
136 |
|
137 $fname = 'page_' . $pid[1] . '_' . $paths->pages[$page]['urlname_nons']; |
|
138 @call_user_func($fname); |
|
139 |
|
140 } |
|
141 else if ( $pid[1] == 'Admin' ) |
|
142 { |
|
143 // If we don't have access to the page, get out and quick! |
|
144 if(!$session->get_permissions('read')) |
|
145 { |
|
146 $template->tpl_strings['PAGE_NAME'] = 'Access denied'; |
|
147 if ( $send_headers ) |
|
148 { |
|
149 $template->header(); |
|
150 } |
|
151 echo '<div class="error-box"><b>Access to this page is denied.</b><br />This may be because you are not logged in or you have not met certain criteria for viewing this page.</div>'; |
|
152 if ( $send_headers ) |
|
153 { |
|
154 $template->footer(); |
|
155 } |
|
156 $r = ob_get_contents(); |
|
157 ob_end_clean(); |
|
158 return $r; |
|
159 } |
|
160 |
|
161 $fname = 'page_' . $pid[1] . '_' . $pid[0]; |
|
162 if ( !function_exists($fname) ) |
|
163 { |
|
164 $title = 'Page backend not found'; |
|
165 $message = "The administration page you are looking for was properly registered using the page API, but the backend function |
|
166 (<tt>$fname</tt>) was not found. If this is a plugin page, then this is almost certainly a bug with the plugin."; |
|
167 if ( $send_headers ) |
|
168 { |
|
169 die_friendly($title, "<p>$message</p>"); |
|
170 } |
|
171 else |
|
172 { |
|
173 echo "<h2>$title</h2>\n<p>$message</p>"; |
|
174 } |
|
175 } |
|
176 @call_user_func($fname); |
|
177 } |
|
178 else if ( !isset( $paths->pages[$page] ) ) |
|
179 { |
|
180 ob_start(); |
|
181 $code = $plugins->setHook('page_not_found'); |
|
182 foreach ( $code as $cmd ) |
|
183 { |
|
184 eval($cmd); |
|
185 } |
|
186 $text = ob_get_contents(); |
|
187 if ( $text != '' ) |
|
188 { |
|
189 ob_end_clean(); |
|
190 return $text; |
|
191 } |
|
192 $template->header(); |
|
193 if($m = $paths->sysmsg('Page_not_found')) |
|
194 { |
|
195 eval('?>'.RenderMan::render($m)); |
|
196 } |
|
197 else |
|
198 { |
|
199 header('HTTP/1.1 404 Not Found'); |
|
200 echo '<h3>There is no page with this title yet.</h3> |
|
201 <p>You have requested a page that doesn\'t exist yet.'; |
|
202 if($session->get_permissions('create_page')) echo ' You can <a href="'.makeUrl($paths->page, 'do=edit', true).'" onclick="ajaxEditor(); return false;">create this page</a>, or return to the <a href="'.makeUrl(getConfig('main_page')).'">homepage</a>.'; |
|
203 else echo ' Return to the <a href="'.makeUrl(getConfig('main_page')).'">homepage</a>.</p>'; |
|
204 if ( $session->get_permissions('history_rollback') ) |
|
205 { |
|
206 $e = $db->sql_query('SELECT * FROM ' . table_prefix.'logs WHERE action=\'delete\' AND page_id=\'' . $paths->page_id . '\' AND namespace=\'' . $pid[1] . '\' ORDER BY time_id DESC;'); |
|
207 if ( !$e ) |
|
208 { |
|
209 $db->_die('The deletion log could not be selected.'); |
|
210 } |
|
211 if ($db->numrows() > 0 ) |
|
212 { |
|
213 $r = $db->fetchrow(); |
|
214 echo '<p>This page also appears to have some log entries in the database - it seems that it was deleted on ' . enano_date('d M Y h:i a', intval($r['time_id'])) . '. You can probably <a href="'.makeUrl($paths->page, 'do=rollback&id=' . $r['time_id']) . '" onclick="ajaxRollback(\'' . $r['time_id'] . '\'); return false;">roll back</a> the deletion.</p>'; |
|
215 } |
|
216 $db->free_result(); |
|
217 } |
|
218 echo '<p> |
|
219 HTTP Error: 404 Not Found |
|
220 </p>'; |
|
221 } |
|
222 $template->footer(); |
|
223 } |
|
224 else |
|
225 { |
|
226 |
|
227 // If we don't have access to the page, get out and quick! |
|
228 if(!$session->get_permissions('read')) |
|
229 { |
|
230 $template->tpl_strings['PAGE_NAME'] = 'Access denied'; |
|
231 if($send_headers) $template->header(); |
|
232 echo '<div class="error-box"><b>Access to this page is denied.</b><br />This may be because you are not logged in or you have not met certain criteria for viewing this page.</div>'; |
|
233 if($send_headers) $template->footer(); |
|
234 $r = ob_get_contents(); |
|
235 ob_end_clean(); |
|
236 return $r; |
|
237 } |
|
238 |
|
239 ob_start(); |
|
240 $code = $plugins->setHook('page_custom_handler'); |
|
241 foreach ( $code as $cmd ) |
|
242 { |
|
243 eval($cmd); |
|
244 } |
|
245 $text = ob_get_contents(); |
|
246 if ( $text != '' ) |
|
247 { |
|
248 ob_end_clean(); |
|
249 return $text; |
|
250 } |
|
251 |
|
252 if ( $hist_id ) |
|
253 { |
|
254 $e = $db->sql_query('SELECT page_text,date_string,char_tag FROM ' . table_prefix.'logs WHERE page_id=\'' . $paths->pages[$page]['urlname_nons'] . '\' AND namespace=\'' . $pid[1] . '\' AND log_type=\'page\' AND action=\'edit\' AND time_id=' . $db->escape($hist_id) . ''); |
|
255 if($db->numrows() < 1) |
|
256 { |
|
257 $db->_die('There were no rows in the text table that matched the page text query.'); |
|
258 } |
|
259 $r = $db->fetchrow(); |
|
260 $db->free_result(); |
|
261 $message = '<div class="info-box" style="margin-left: 0; margin-top: 5px;"><b>Notice:</b><br />The page you are viewing was archived on ' . enano_date('d M Y h:i a', intval($r['time_id'])) . '.<br /><a href="'.makeUrl($page).'" onclick="ajaxReset(); return false;">View current version</a> | <a href="'.makeUrl($page, 'do=rollback&id=' . $hist_id) . '" onclick="ajaxRollback(\'' . $hist_id . '\')">Restore this version</a></div><br />'.RenderMan::render($r['page_text']); |
|
262 |
|
263 if( !$paths->pages[$page]['special'] ) |
|
264 { |
|
265 if($send_headers) |
|
266 { |
|
267 $template->header(); |
|
268 } |
|
269 display_page_headers(); |
|
270 } |
|
271 |
|
272 eval('?>' . $message); |
|
273 |
|
274 if( !$paths->pages[$page]['special'] ) |
|
275 { |
|
276 display_page_footers(); |
|
277 if($send_headers) |
|
278 { |
|
279 $template->footer(); |
|
280 } |
|
281 } |
|
282 |
|
283 } else { |
|
284 if(!$paths->pages[$page]['special']) |
|
285 { |
|
286 $message = RenderMan::getPage($paths->pages[$page]['urlname_nons'], $pid[1]); |
|
287 } |
|
288 else |
|
289 { |
|
290 $message = RenderMan::getPage($paths->pages[$page]['urlname_nons'], $pid[1], 0, false, false, false, false); |
|
291 } |
|
292 // This line is used to debug wikiformatted code |
|
293 // die('<pre>'.htmlspecialchars($message).'</pre>'); |
|
294 |
|
295 if( !$paths->pages[$page]['special'] ) |
|
296 { |
|
297 if($send_headers) |
|
298 { |
|
299 $template->header(); |
|
300 } |
|
301 display_page_headers(); |
|
302 } |
|
303 |
|
304 // This is it, this is what all of Enano has been working up to... |
|
305 |
|
306 eval('?>' . $message); |
|
307 |
|
308 if( !$paths->pages[$page]['special'] ) |
|
309 { |
|
310 display_page_footers(); |
|
311 if($send_headers) |
|
312 { |
|
313 $template->footer(); |
|
314 } |
|
315 } |
|
316 } |
|
317 } |
|
318 $ret = ob_get_contents(); |
|
319 ob_end_clean(); |
|
320 return $ret; |
|
321 } |
101 } |
322 |
102 |
323 /** |
103 /** |
324 * Writes page data to the database, after verifying permissions and running the XSS filter |
104 * Writes page data to the database, after verifying permissions and running the XSS filter |
325 * @param $page_id the page ID |
105 * @param $page_id the page ID |