author | Dan |
Wed, 11 Jul 2007 14:28:34 -0400 | |
changeset 64 | 60e450d2e8c3 |
parent 53 | 3dea509d88ae |
child 69 | 63638a42cee9 |
permissions | -rwxr-xr-x |
0 | 1 |
<?php |
2 |
/* |
|
3 |
Plugin Name: Special page-related pages |
|
4 |
Plugin URI: http://enanocms.org/ |
|
5 |
Description: Provides the page Special:CreatePage, which can be used to create new pages. Also adds the About Enano and GNU General Public License pages. |
|
6 |
Author: Dan Fuhry |
|
7 |
Version: 1.0 |
|
8 |
Author URI: http://enanocms.org/ |
|
9 |
*/ |
|
10 |
||
11 |
/* |
|
12 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
|
13 |
* Version 1.0 release candidate 2 |
|
14 |
* Copyright (C) 2006-2007 Dan Fuhry |
|
15 |
* |
|
16 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
18 |
* |
|
19 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
20 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
21 |
*/ |
|
22 |
||
23 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
24 |
||
25 |
$plugins->attachHook('base_classes_initted', ' |
|
26 |
global $paths; |
|
27 |
$paths->add_page(Array( |
|
28 |
\'name\'=>\'Create page\', |
|
29 |
\'urlname\'=>\'CreatePage\', |
|
30 |
\'namespace\'=>\'Special\', |
|
31 |
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
32 |
)); |
|
33 |
||
34 |
$paths->add_page(Array( |
|
35 |
\'name\'=>\'All pages\', |
|
36 |
\'urlname\'=>\'AllPages\', |
|
37 |
\'namespace\'=>\'Special\', |
|
38 |
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
39 |
)); |
|
40 |
||
41 |
$paths->add_page(Array( |
|
42 |
\'name\'=>\'List of special pages\', |
|
43 |
\'urlname\'=>\'SpecialPages\', |
|
44 |
\'namespace\'=>\'Special\', |
|
45 |
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
46 |
)); |
|
47 |
||
48 |
$paths->add_page(Array( |
|
49 |
\'name\'=>\'About Enano\', |
|
50 |
\'urlname\'=>\'About_Enano\', |
|
51 |
\'namespace\'=>\'Special\', |
|
52 |
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
53 |
)); |
|
54 |
||
55 |
$paths->add_page(Array( |
|
56 |
\'name\'=>\'GNU General Public License\', |
|
57 |
\'urlname\'=>\'GNU_General_Public_License\', |
|
58 |
\'namespace\'=>\'Special\', |
|
59 |
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
60 |
)); |
|
61 |
'); |
|
62 |
||
63 |
// function names are IMPORTANT!!! The name pattern is: page_<namespace ID>_<page URLname, without namespace> |
|
64 |
||
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
65 |
function page_Special_CreatePage() |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
66 |
{ |
0 | 67 |
global $db, $session, $paths, $template, $plugins; // Common objects |
68 |
if ( isset($_POST['do']) ) |
|
69 |
{ |
|
70 |
$p = $_POST['pagename']; |
|
71 |
$k = array_keys($paths->nslist); |
|
72 |
for ( $i = 0; $i < sizeof( $paths->nslist ); $i++ ) |
|
73 |
{ |
|
74 |
$ln = strlen( $paths->nslist[$k[$i]] ); |
|
75 |
if ( substr($p, 0, $ln) == $paths->nslist[$k[$i]] ) |
|
76 |
{ |
|
77 |
$namespace = $k[$i]; |
|
78 |
} |
|
79 |
} |
|
80 |
if ( $namespace == 'Special' || ( $namespace == 'System' && $session->user_level < USER_LEVEL_ADMIN ) || $namespace == 'Admin') |
|
81 |
{ |
|
82 |
$template->header(); |
|
83 |
||
84 |
echo '<h3>The page could not be created.</h3><p>The name "'.$p.'" is invalid.</p>'; |
|
85 |
||
86 |
$template->footer(); |
|
87 |
$db->close(); |
|
88 |
||
89 |
exit; |
|
90 |
} |
|
91 |
$name = $db->escape(str_replace('_', ' ', $p)); |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
92 |
$urlname = str_replace(' ', '_', $p); |
0 | 93 |
$namespace = $_POST['namespace']; |
94 |
if ( $namespace == 'Special' || ( $namespace == 'System' && $session->user_level < USER_LEVEL_ADMIN ) || $namespace == 'Admin') |
|
95 |
{ |
|
96 |
$template->header(); |
|
97 |
||
98 |
echo '<h3>The page could not be created.</h3><p>The name "'.$paths->nslist[$namespace].$p.'" is invalid.</p>'; |
|
99 |
||
100 |
$template->footer(); |
|
101 |
$db->close(); |
|
102 |
||
103 |
exit; |
|
104 |
} |
|
105 |
||
106 |
$tn = $paths->nslist[$_POST['namespace']] . $urlname; |
|
107 |
if ( isset($paths->pages[$tn]) ) |
|
108 |
{ |
|
109 |
die_friendly('Error creating page', '<p>The page already exists.</p>'); |
|
110 |
} |
|
111 |
||
112 |
if ( $paths->nslist[$namespace] == substr($urlname, 0, strlen($paths->nslist[$namespace]) ) ) |
|
113 |
{ |
|
114 |
$urlname = substr($urlname, strlen($paths->nslist[$namespace]), strlen($urlname)); |
|
115 |
} |
|
116 |
||
117 |
$k = array_keys( $paths->nslist ); |
|
118 |
if(!in_array($_POST['namespace'], $k)) |
|
119 |
{ |
|
120 |
$db->_die('An SQL injection attempt was caught at '.dirname(__FILE__).':'.__LINE__.'.'); |
|
121 |
} |
|
122 |
||
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
123 |
$urlname = sanitize_page_id($urlname); |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
124 |
$urlname = $db->escape($urlname); |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
125 |
|
0 | 126 |
$perms = $session->fetch_page_acl($urlname, $namespace); |
127 |
if ( !$perms->get_permissions('create_page') ) |
|
128 |
die_friendly('Error creating page', '<p>An access control rule is preventing you from creating pages.</p>'); |
|
129 |
||
130 |
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(time_id,date_string,log_type,action,author,page_id,namespace) VALUES('.time().', \''.date('d M Y h:i a').'\', \'page\', \'create\', \''.$session->username.'\', \''.$urlname.'\', \''.$_POST['namespace'].'\');'); |
|
131 |
if ( !$q ) |
|
132 |
{ |
|
133 |
$db->_die('The page log could not be updated.'); |
|
134 |
} |
|
135 |
||
136 |
$q = $db->sql_query('INSERT INTO '.table_prefix.'pages(name,urlname,namespace) VALUES(\''.$name.'\', \''.$urlname.'\', \''.$_POST['namespace'].'\');'); |
|
137 |
if ( !$q ) |
|
138 |
{ |
|
139 |
$db->_die('The page entry could not be inserted.'); |
|
140 |
} |
|
141 |
$q = $db->sql_query('INSERT INTO '.table_prefix.'page_text(page_id,namespace,page_text) VALUES(\''.$urlname.'\', \''.$_POST['namespace'].'\', \''.$db->escape('Please edit this page! <nowiki><script type="text/javascript">ajaxEditor();</script></nowiki>').'\');'); |
|
142 |
if ( !$q ) |
|
143 |
{ |
|
144 |
$db->_die('The page text entry could not be inserted.'); |
|
145 |
} |
|
146 |
||
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
147 |
header('Location: '.makeUrlNS($_POST['namespace'], sanitize_page_id($p))); |
0 | 148 |
exit; |
149 |
} |
|
150 |
$template->header(); |
|
151 |
if ( !$session->get_permissions('create_page') ) |
|
152 |
{ |
|
153 |
echo 'Wiki mode is disabled, only admins can create pages.'; |
|
154 |
||
155 |
$template->footer(); |
|
156 |
$db->close(); |
|
157 |
||
158 |
exit; |
|
159 |
} |
|
160 |
echo RenderMan::render('Using the form below you can create a page.'); |
|
161 |
?> |
|
162 |
<form action="" method="post"> |
|
163 |
<p> |
|
164 |
<select name="namespace"> |
|
165 |
<?php |
|
166 |
$k = array_keys($paths->nslist); |
|
167 |
for ( $i = 0; $i < sizeof($k); $i++ ) |
|
168 |
{ |
|
169 |
if ( $paths->nslist[$k[$i]] == '' ) |
|
170 |
{ |
|
171 |
$s = '[No prefix]'; |
|
172 |
} |
|
173 |
else |
|
174 |
{ |
|
175 |
$s = $paths->nslist[$k[$i]]; |
|
176 |
} |
|
177 |
if ( ( $k[$i] != 'System' || $session->user_level >= USER_LEVEL_ADMIN ) && $k[$i] != 'Admin' && $k[$i] != 'Special') |
|
178 |
{ |
|
179 |
echo '<option value="'.$k[$i].'">'.$s.'</option>'; |
|
180 |
} |
|
181 |
} |
|
182 |
?> |
|
183 |
</select> <input type="text" name="pagename" /></p> |
|
184 |
<p><input type="submit" name="do" value="Create Page" /></p> |
|
185 |
</form> |
|
186 |
<?php |
|
187 |
$template->footer(); |
|
188 |
} |
|
189 |
||
190 |
function page_Special_AllPages() |
|
191 |
{ |
|
192 |
// This should be an easy one |
|
193 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
194 |
$template->header(); |
|
195 |
$sz = sizeof( $paths->pages ) / 2; |
|
196 |
echo '<p>Below is a list of all of the pages on this website.</p><div class="tblholder"><table border="0" width="100%" cellspacing="1" cellpadding="4">'; |
|
197 |
$cclass = 'row1'; |
|
198 |
for ( $i = 0; $i < $sz; $i = $i ) |
|
199 |
{ |
|
200 |
if ( $cclass == 'row1') |
|
201 |
{ |
|
202 |
$cclass='row3'; |
|
203 |
} |
|
204 |
else if ( $cclass == 'row3') |
|
205 |
{ |
|
206 |
$cclass='row1'; |
|
207 |
} |
|
208 |
echo '<tr>'; |
|
209 |
for ( $j = 0; $j < 2; $j = $j ) |
|
210 |
{ |
|
211 |
if ( $i < $sz && $paths->pages[$i]['namespace'] != 'Special' && $paths->pages[$i]['namespace'] != 'Admin' && $paths->pages[$i]['visible'] == 1) |
|
212 |
{ |
|
213 |
echo '<td style="width: 50%" class="'.$cclass.'"><a href="'.makeUrl($paths->pages[$i]['urlname']).'">'; |
|
214 |
if ( $paths->pages[$i]['namespace'] != 'Article' ) |
|
215 |
{ |
|
216 |
echo '('.$paths->pages[$i]['namespace'].') '; |
|
217 |
} |
|
218 |
echo $paths->pages[$i]['name'].'</a></td>'; |
|
219 |
$j++; |
|
220 |
} |
|
221 |
else if ( $i >= $sz ) |
|
222 |
{ |
|
223 |
echo '<td style="width: 50%" class="row2"></td>'; |
|
224 |
$j++; |
|
225 |
} |
|
226 |
$i++; |
|
227 |
} |
|
228 |
echo '</tr>'; |
|
229 |
} |
|
230 |
echo '</table></div>'; |
|
231 |
$template->footer(); |
|
232 |
} |
|
233 |
||
234 |
function page_Special_SpecialPages() |
|
235 |
{ |
|
236 |
// This should be an easy one |
|
237 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
238 |
$template->header(); |
|
239 |
$sz = sizeof($paths->pages) / 2; |
|
240 |
echo '<p>Below is a list of all of the special pages on this website.</p><div class="tblholder"><table border="0" width="100%" cellspacing="1" cellpadding="4">'; |
|
241 |
$cclass='row1'; |
|
242 |
for ( $i = 0; $i < $sz; $i = $i) |
|
243 |
{ |
|
244 |
if ( $cclass == 'row1' ) |
|
245 |
{ |
|
246 |
$cclass = 'row3'; |
|
247 |
} |
|
248 |
else if ( $cclass == 'row3') |
|
249 |
{ |
|
250 |
$cclass='row1'; |
|
251 |
} |
|
252 |
echo '<tr>'; |
|
253 |
for ( $j = 0; $j < 2; $j = $j ) |
|
254 |
{ |
|
255 |
if ( $i < $sz && $paths->pages[$i]['namespace'] == 'Special' && $paths->pages[$i]['visible'] == 1) |
|
256 |
{ |
|
257 |
echo '<td style="width: 50%" class="'.$cclass.'"><a href="'.makeUrl($paths->pages[$i]['urlname']).'">'; |
|
258 |
echo $paths->pages[$i]['name'].'</a></td>'; |
|
259 |
$j++; |
|
260 |
} |
|
261 |
else if ( $i >= $sz ) |
|
262 |
{ |
|
263 |
echo '<td style="width: 50%" class="row2"></td>'; |
|
264 |
$j++; |
|
265 |
} |
|
266 |
$i++; |
|
267 |
} |
|
268 |
echo '</tr>'; |
|
269 |
} |
|
270 |
echo '</table></div>'; |
|
271 |
$template->footer(); |
|
272 |
} |
|
273 |
||
274 |
function page_Special_About_Enano() |
|
275 |
{ |
|
276 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
277 |
$platform = 'Unknown'; |
|
278 |
$uname = @file_get_contents('/proc/sys/kernel/ostype'); |
|
279 |
if($uname == "Linux\n") |
|
280 |
$platform = 'Linux'; |
|
281 |
else if(file_exists('/hurd/pfinet')) // I have a little experience with GNU/Hurd :-) http://hurdvm.enanocms.org/ |
|
282 |
$platform = 'GNU/Hurd'; |
|
283 |
else if(file_exists('C:\Windows\system32\ntoskrnl.exe')) |
|
284 |
$platform = 'Windows NT'; |
|
285 |
else if(file_exists('C:\Windows\system\krnl386.exe')) |
|
286 |
$platform = 'Windows 9x/DOS'; |
|
287 |
else if(file_exists('/bin/bash')) |
|
288 |
$platform = 'Other GNU/Mac OS X'; |
|
289 |
else if(is_dir('/bin')) |
|
290 |
$platform = 'Other POSIX'; |
|
291 |
$template->header(); |
|
292 |
?> |
|
293 |
<br /> |
|
294 |
<div class="tblholder"> |
|
295 |
<table border="0" cellspacing="1" cellpadding="4"> |
|
296 |
<tr><th colspan="2" style="text-align: left;">About the Enano Content Management System</th></tr> |
|
23
320acf077276
At last, I fixed all those phased-out enano.homelinux.org links!
Dan
parents:
22
diff
changeset
|
297 |
<tr><td colspan="2" class="row3"><p>This website is powered by <a href="http://enanocms.org/">Enano</a>, the lightweight and open source |
38 | 298 |
CMS that everyone can use. Enano is copyright © 2006-2007 Dan Fuhry. For legal information, along with a list of libraries that Enano |
23
320acf077276
At last, I fixed all those phased-out enano.homelinux.org links!
Dan
parents:
22
diff
changeset
|
299 |
uses, please see <a href="http://enanocms.org/Legal_information">Legal Information</a>.</p> |
0 | 300 |
<p>The developers and maintainers of Enano strongly believe that software should not only be free to use, but free to be modified, |
301 |
distributed, and used to create derivative works. For more information about Free Software, check out the |
|
302 |
<a href="http://en.wikipedia.org/wiki/Free_Software" onclick="window.open(this.href); return false;">Wikipedia page</a> or |
|
303 |
the <a href="http://www.fsf.org/" onclick="window.open(this.href); return false;">Free Software Foundation's</a> homepage.</p> |
|
304 |
<p>This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU General Public License |
|
305 |
as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p> |
|
306 |
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
307 |
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.</p> |
|
308 |
<p>You should have received <a href="<?php echo makeUrlNS('Special', 'GNU_General_Public_License'); ?>">a copy of |
|
309 |
the GNU General Public License</a> along with this program; if not, write to:</p> |
|
310 |
<p style="margin-left 2em;">Free Software Foundation, Inc.,<br /> |
|
311 |
51 Franklin Street, Fifth Floor<br /> |
|
312 |
Boston, MA 02110-1301, USA</p> |
|
313 |
<p>Alternatively, you can <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a>.</p> |
|
314 |
</td></tr> |
|
315 |
<tr> |
|
316 |
<td class="row2" colspan="2"> |
|
53 | 317 |
<table border="0" style="margin: 0 auto; background: none; width: 100%;" cellpadding="5"> |
0 | 318 |
<tr> |
53 | 319 |
<td style="text-align: center;"> |
36
425261984266
Added "page hint" on search page; deprecated "www." on EnanoCMS.org links
Dan
parents:
23
diff
changeset
|
320 |
<a href="http://enanocms.org/" onclick="window.open(this.href); return false;" style="background: none; padding: 0;"> |
53 | 321 |
<img alt="Powered by Enano" |
322 |
src="<?php echo scriptPath; ?>/images/about-powered-enano.png" |
|
323 |
onmouseover="this.src='<?php echo scriptPath; ?>/images/about-powered-enano-hover.png';" |
|
324 |
onmouseout="this.src='<?php echo scriptPath; ?>/images/about-powered-enano.png';" |
|
325 |
style="border-width: 0px;" width="88" height="31" /> |
|
326 |
</a> |
|
0 | 327 |
</td> |
328 |
<td style="text-align: center;"> |
|
329 |
<a href="http://www.php.net/" onclick="window.open(this.href); return false;" style="background: none; padding: 0;"> |
|
330 |
<img alt="Written in PHP" src="<?php echo scriptPath; ?>/images/about-powered-php.png" style="border-width: 0px;" width="88" height="31" /> |
|
331 |
</a> |
|
332 |
</td> |
|
333 |
<td style="text-align: center;"> |
|
334 |
<a href="http://www.mysql.com/" onclick="window.open(this.href); return false;" style="background: none; padding: 0;"> |
|
335 |
<img alt="Database engine powered by MySQL" src="<?php echo scriptPath; ?>/images/about-powered-mysql.png" style="border-width: 0px;" width="88" height="31" /> |
|
336 |
</a> |
|
337 |
</td> |
|
338 |
</tr> |
|
339 |
</table> |
|
340 |
</td> |
|
341 |
</tr> |
|
36
425261984266
Added "page hint" on search page; deprecated "www." on EnanoCMS.org links
Dan
parents:
23
diff
changeset
|
342 |
<tr><td style="width: 100px;" class="row1"><a href="http://enanocms.org">Enano</a> version:</td><td class="row1"><?php echo enano_version(true); ?></td></tr> |
0 | 343 |
<tr><td style="width: 100px;" class="row2">Web server:</td><td class="row2"><?php if(isset($_SERVER['SERVER_SOFTWARE'])) echo $_SERVER['SERVER_SOFTWARE']; else echo 'Unable to determine web server software.'; ?></td></tr> |
344 |
<tr><td style="width: 100px;" class="row1">Server platform:</td><td class="row1"><?php echo $platform; ?></td></tr> |
|
345 |
<tr><td style="width: 100px;" class="row2"><a href="http://www.php.net/">PHP</a> version:</td><td class="row2"><?php echo PHP_VERSION; ?></td></tr> |
|
346 |
<tr><td style="width: 100px;" class="row1"><a href="http://www.mysql.com/">MySQL</a> version:</td><td class="row1"><?php echo mysql_get_server_info($db->_conn); ?></td></tr> |
|
347 |
</table> |
|
348 |
</div> |
|
349 |
<?php |
|
350 |
$template->footer(); |
|
351 |
} |
|
352 |
||
353 |
function page_Special_GNU_General_Public_License() |
|
354 |
{ |
|
355 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
356 |
$template->header(); |
|
357 |
if(file_exists(ENANO_ROOT.'/GPL')) |
|
358 |
{ |
|
359 |
echo '<p>The following text represents the license that the <a href="'.makeUrlNS('Special', 'About_Enano').'">Enano</a> content management system is under. To make it easier to read, the text has been wiki-formatted; in no other way has it been changed.</p>'; |
|
360 |
echo RenderMan::render( htmlspecialchars ( file_get_contents ( ENANO_ROOT . '/GPL' ) ) ); |
|
361 |
} |
|
362 |
else |
|
363 |
{ |
|
36
425261984266
Added "page hint" on search page; deprecated "www." on EnanoCMS.org links
Dan
parents:
23
diff
changeset
|
364 |
echo '<p>It appears that the file "GPL" is missing from your Enano installation. You may find a wiki-formatted copy of the GPL at: <a href="http://enanocms.org/GPL">http://enanocms.org/GPL</a>.</p>'; |
0 | 365 |
} |
366 |
$template->footer(); |
|
367 |
} |
|
368 |
||
369 |
?> |