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 |
|
|
65 |
function page_Special_CreatePage() {
|
|
66 |
global $db, $session, $paths, $template, $plugins; // Common objects
|
|
67 |
if ( isset($_POST['do']) )
|
|
68 |
{
|
|
69 |
$p = $_POST['pagename'];
|
|
70 |
$k = array_keys($paths->nslist);
|
|
71 |
for ( $i = 0; $i < sizeof( $paths->nslist ); $i++ )
|
|
72 |
{
|
|
73 |
$ln = strlen( $paths->nslist[$k[$i]] );
|
|
74 |
if ( substr($p, 0, $ln) == $paths->nslist[$k[$i]] )
|
|
75 |
{
|
|
76 |
$namespace = $k[$i];
|
|
77 |
}
|
|
78 |
}
|
|
79 |
if ( $namespace == 'Special' || ( $namespace == 'System' && $session->user_level < USER_LEVEL_ADMIN ) || $namespace == 'Admin')
|
|
80 |
{
|
|
81 |
$template->header();
|
|
82 |
|
|
83 |
echo '<h3>The page could not be created.</h3><p>The name "'.$p.'" is invalid.</p>';
|
|
84 |
|
|
85 |
$template->footer();
|
|
86 |
$db->close();
|
|
87 |
|
|
88 |
exit;
|
|
89 |
}
|
|
90 |
$name = $db->escape(str_replace('_', ' ', $p));
|
|
91 |
$urlname = $db->escape(str_replace(' ', '_', $p));
|
|
92 |
$namespace = $_POST['namespace'];
|
|
93 |
if ( $namespace == 'Special' || ( $namespace == 'System' && $session->user_level < USER_LEVEL_ADMIN ) || $namespace == 'Admin')
|
|
94 |
{
|
|
95 |
$template->header();
|
|
96 |
|
|
97 |
echo '<h3>The page could not be created.</h3><p>The name "'.$paths->nslist[$namespace].$p.'" is invalid.</p>';
|
|
98 |
|
|
99 |
$template->footer();
|
|
100 |
$db->close();
|
|
101 |
|
|
102 |
exit;
|
|
103 |
}
|
|
104 |
|
|
105 |
$tn = $paths->nslist[$_POST['namespace']] . $urlname;
|
|
106 |
if ( isset($paths->pages[$tn]) )
|
|
107 |
{
|
|
108 |
die_friendly('Error creating page', '<p>The page already exists.</p>');
|
|
109 |
}
|
|
110 |
|
|
111 |
if ( $paths->nslist[$namespace] == substr($urlname, 0, strlen($paths->nslist[$namespace]) ) )
|
|
112 |
{
|
|
113 |
$urlname = substr($urlname, strlen($paths->nslist[$namespace]), strlen($urlname));
|
|
114 |
}
|
|
115 |
|
|
116 |
$k = array_keys( $paths->nslist );
|
|
117 |
if(!in_array($_POST['namespace'], $k))
|
|
118 |
{
|
|
119 |
$db->_die('An SQL injection attempt was caught at '.dirname(__FILE__).':'.__LINE__.'.');
|
|
120 |
}
|
|
121 |
|
|
122 |
$perms = $session->fetch_page_acl($urlname, $namespace);
|
|
123 |
if ( !$perms->get_permissions('create_page') )
|
|
124 |
die_friendly('Error creating page', '<p>An access control rule is preventing you from creating pages.</p>');
|
|
125 |
|
|
126 |
$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'].'\');');
|
|
127 |
if ( !$q )
|
|
128 |
{
|
|
129 |
$db->_die('The page log could not be updated.');
|
|
130 |
}
|
|
131 |
|
|
132 |
$q = $db->sql_query('INSERT INTO '.table_prefix.'pages(name,urlname,namespace) VALUES(\''.$name.'\', \''.$urlname.'\', \''.$_POST['namespace'].'\');');
|
|
133 |
if ( !$q )
|
|
134 |
{
|
|
135 |
$db->_die('The page entry could not be inserted.');
|
|
136 |
}
|
|
137 |
$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>').'\');');
|
|
138 |
if ( !$q )
|
|
139 |
{
|
|
140 |
$db->_die('The page text entry could not be inserted.');
|
|
141 |
}
|
|
142 |
|
|
143 |
header('Location: '.makeUrl($paths->nslist[$_POST['namespace']].$p));
|
|
144 |
exit;
|
|
145 |
}
|
|
146 |
$template->header();
|
|
147 |
if ( !$session->get_permissions('create_page') )
|
|
148 |
{
|
|
149 |
echo 'Wiki mode is disabled, only admins can create pages.';
|
|
150 |
|
|
151 |
$template->footer();
|
|
152 |
$db->close();
|
|
153 |
|
|
154 |
exit;
|
|
155 |
}
|
|
156 |
echo RenderMan::render('Using the form below you can create a page.');
|
|
157 |
?>
|
|
158 |
<form action="" method="post">
|
|
159 |
<p>
|
|
160 |
<select name="namespace">
|
|
161 |
<?php
|
|
162 |
$k = array_keys($paths->nslist);
|
|
163 |
for ( $i = 0; $i < sizeof($k); $i++ )
|
|
164 |
{
|
|
165 |
if ( $paths->nslist[$k[$i]] == '' )
|
|
166 |
{
|
|
167 |
$s = '[No prefix]';
|
|
168 |
}
|
|
169 |
else
|
|
170 |
{
|
|
171 |
$s = $paths->nslist[$k[$i]];
|
|
172 |
}
|
|
173 |
if ( ( $k[$i] != 'System' || $session->user_level >= USER_LEVEL_ADMIN ) && $k[$i] != 'Admin' && $k[$i] != 'Special')
|
|
174 |
{
|
|
175 |
echo '<option value="'.$k[$i].'">'.$s.'</option>';
|
|
176 |
}
|
|
177 |
}
|
|
178 |
?>
|
|
179 |
</select> <input type="text" name="pagename" /></p>
|
|
180 |
<p><input type="submit" name="do" value="Create Page" /></p>
|
|
181 |
</form>
|
|
182 |
<?php
|
|
183 |
$template->footer();
|
|
184 |
}
|
|
185 |
|
|
186 |
function page_Special_AllPages()
|
|
187 |
{
|
|
188 |
// This should be an easy one
|
|
189 |
global $db, $session, $paths, $template, $plugins; // Common objects
|
|
190 |
$template->header();
|
|
191 |
$sz = sizeof( $paths->pages ) / 2;
|
|
192 |
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">';
|
|
193 |
$cclass = 'row1';
|
|
194 |
for ( $i = 0; $i < $sz; $i = $i )
|
|
195 |
{
|
|
196 |
if ( $cclass == 'row1')
|
|
197 |
{
|
|
198 |
$cclass='row3';
|
|
199 |
}
|
|
200 |
else if ( $cclass == 'row3')
|
|
201 |
{
|
|
202 |
$cclass='row1';
|
|
203 |
}
|
|
204 |
echo '<tr>';
|
|
205 |
for ( $j = 0; $j < 2; $j = $j )
|
|
206 |
{
|
|
207 |
if ( $i < $sz && $paths->pages[$i]['namespace'] != 'Special' && $paths->pages[$i]['namespace'] != 'Admin' && $paths->pages[$i]['visible'] == 1)
|
|
208 |
{
|
|
209 |
echo '<td style="width: 50%" class="'.$cclass.'"><a href="'.makeUrl($paths->pages[$i]['urlname']).'">';
|
|
210 |
if ( $paths->pages[$i]['namespace'] != 'Article' )
|
|
211 |
{
|
|
212 |
echo '('.$paths->pages[$i]['namespace'].') ';
|
|
213 |
}
|
|
214 |
echo $paths->pages[$i]['name'].'</a></td>';
|
|
215 |
$j++;
|
|
216 |
}
|
|
217 |
else if ( $i >= $sz )
|
|
218 |
{
|
|
219 |
echo '<td style="width: 50%" class="row2"></td>';
|
|
220 |
$j++;
|
|
221 |
}
|
|
222 |
$i++;
|
|
223 |
}
|
|
224 |
echo '</tr>';
|
|
225 |
}
|
|
226 |
echo '</table></div>';
|
|
227 |
$template->footer();
|
|
228 |
}
|
|
229 |
|
|
230 |
function page_Special_SpecialPages()
|
|
231 |
{
|
|
232 |
// This should be an easy one
|
|
233 |
global $db, $session, $paths, $template, $plugins; // Common objects
|
|
234 |
$template->header();
|
|
235 |
$sz = sizeof($paths->pages) / 2;
|
|
236 |
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">';
|
|
237 |
$cclass='row1';
|
|
238 |
for ( $i = 0; $i < $sz; $i = $i)
|
|
239 |
{
|
|
240 |
if ( $cclass == 'row1' )
|
|
241 |
{
|
|
242 |
$cclass = 'row3';
|
|
243 |
}
|
|
244 |
else if ( $cclass == 'row3')
|
|
245 |
{
|
|
246 |
$cclass='row1';
|
|
247 |
}
|
|
248 |
echo '<tr>';
|
|
249 |
for ( $j = 0; $j < 2; $j = $j )
|
|
250 |
{
|
|
251 |
if ( $i < $sz && $paths->pages[$i]['namespace'] == 'Special' && $paths->pages[$i]['visible'] == 1)
|
|
252 |
{
|
|
253 |
echo '<td style="width: 50%" class="'.$cclass.'"><a href="'.makeUrl($paths->pages[$i]['urlname']).'">';
|
|
254 |
echo $paths->pages[$i]['name'].'</a></td>';
|
|
255 |
$j++;
|
|
256 |
}
|
|
257 |
else if ( $i >= $sz )
|
|
258 |
{
|
|
259 |
echo '<td style="width: 50%" class="row2"></td>';
|
|
260 |
$j++;
|
|
261 |
}
|
|
262 |
$i++;
|
|
263 |
}
|
|
264 |
echo '</tr>';
|
|
265 |
}
|
|
266 |
echo '</table></div>';
|
|
267 |
$template->footer();
|
|
268 |
}
|
|
269 |
|
|
270 |
function page_Special_About_Enano()
|
|
271 |
{
|
|
272 |
global $db, $session, $paths, $template, $plugins; // Common objects
|
|
273 |
$platform = 'Unknown';
|
|
274 |
$uname = @file_get_contents('/proc/sys/kernel/ostype');
|
|
275 |
if($uname == "Linux\n")
|
|
276 |
$platform = 'Linux';
|
|
277 |
else if(file_exists('/hurd/pfinet')) // I have a little experience with GNU/Hurd :-) http://hurdvm.enanocms.org/
|
|
278 |
$platform = 'GNU/Hurd';
|
|
279 |
else if(file_exists('C:\Windows\system32\ntoskrnl.exe'))
|
|
280 |
$platform = 'Windows NT';
|
|
281 |
else if(file_exists('C:\Windows\system\krnl386.exe'))
|
|
282 |
$platform = 'Windows 9x/DOS';
|
|
283 |
else if(file_exists('/bin/bash'))
|
|
284 |
$platform = 'Other GNU/Mac OS X';
|
|
285 |
else if(is_dir('/bin'))
|
|
286 |
$platform = 'Other POSIX';
|
|
287 |
$template->header();
|
|
288 |
?>
|
|
289 |
<br />
|
|
290 |
<div class="tblholder">
|
|
291 |
<table border="0" cellspacing="1" cellpadding="4">
|
|
292 |
<tr><th colspan="2" style="text-align: left;">About the Enano Content Management System</th></tr>
|
|
293 |
<tr><td colspan="2" class="row3"><p>This website is powered by <a href="http://enano.homelinux.org/">Enano</a>, the lightweight and open source
|
|
294 |
CMS that everyone can use. Enano is copyright © 2006 Dan Fuhry. For legal information, along with a list of libraries that Enano
|
|
295 |
uses, please see <a href="http://enano.homelinux.org/Legal_information">Legal Information</a>.</p>
|
|
296 |
<p>The developers and maintainers of Enano strongly believe that software should not only be free to use, but free to be modified,
|
|
297 |
distributed, and used to create derivative works. For more information about Free Software, check out the
|
|
298 |
<a href="http://en.wikipedia.org/wiki/Free_Software" onclick="window.open(this.href); return false;">Wikipedia page</a> or
|
|
299 |
the <a href="http://www.fsf.org/" onclick="window.open(this.href); return false;">Free Software Foundation's</a> homepage.</p>
|
|
300 |
<p>This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU General Public License
|
|
301 |
as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p>
|
|
302 |
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
303 |
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.</p>
|
|
304 |
<p>You should have received <a href="<?php echo makeUrlNS('Special', 'GNU_General_Public_License'); ?>">a copy of
|
|
305 |
the GNU General Public License</a> along with this program; if not, write to:</p>
|
|
306 |
<p style="margin-left 2em;">Free Software Foundation, Inc.,<br />
|
|
307 |
51 Franklin Street, Fifth Floor<br />
|
|
308 |
Boston, MA 02110-1301, USA</p>
|
|
309 |
<p>Alternatively, you can <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a>.</p>
|
|
310 |
</td></tr>
|
|
311 |
<tr>
|
|
312 |
<td class="row2" colspan="2">
|
|
313 |
<table border="0" style="margin: 0 auto; background: none; width: 100%;" cellpadding="5">
|
|
314 |
<tr>
|
|
315 |
<td style="text-align: center;">
|
|
316 |
<a href="http://www.enanocms.org/" onclick="window.open(this.href); return false;" style="background: none; padding: 0;">
|
|
317 |
<img alt="Powered by Enano"
|
|
318 |
src="<?php echo scriptPath; ?>/images/about-powered-enano.png"
|
|
319 |
onmouseover="this.src='<?php echo scriptPath; ?>/images/about-powered-enano-hover.png';"
|
|
320 |
onmouseout="this.src='<?php echo scriptPath; ?>/images/about-powered-enano.png';"
|
|
321 |
style="border-width: 0px;" width="88" height="31" />
|
|
322 |
</a>
|
|
323 |
</td>
|
|
324 |
<td style="text-align: center;">
|
|
325 |
<a href="http://www.php.net/" onclick="window.open(this.href); return false;" style="background: none; padding: 0;">
|
|
326 |
<img alt="Written in PHP" src="<?php echo scriptPath; ?>/images/about-powered-php.png" style="border-width: 0px;" width="88" height="31" />
|
|
327 |
</a>
|
|
328 |
</td>
|
|
329 |
<td style="text-align: center;">
|
|
330 |
<a href="http://www.mysql.com/" onclick="window.open(this.href); return false;" style="background: none; padding: 0;">
|
|
331 |
<img alt="Database engine powered by MySQL" src="<?php echo scriptPath; ?>/images/about-powered-mysql.png" style="border-width: 0px;" width="88" height="31" />
|
|
332 |
</a>
|
|
333 |
</td>
|
|
334 |
</tr>
|
|
335 |
</table>
|
|
336 |
</td>
|
|
337 |
</tr>
|
|
338 |
<tr><td style="width: 100px;" class="row1"><a href="http://www.enanocms.org">Enano</a> version:</td><td class="row1"><?php echo enano_version(true); ?></td></tr>
|
|
339 |
<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>
|
|
340 |
<tr><td style="width: 100px;" class="row1">Server platform:</td><td class="row1"><?php echo $platform; ?></td></tr>
|
|
341 |
<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>
|
|
342 |
<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>
|
|
343 |
</table>
|
|
344 |
</div>
|
|
345 |
<?php
|
|
346 |
$template->footer();
|
|
347 |
}
|
|
348 |
|
|
349 |
function page_Special_GNU_General_Public_License()
|
|
350 |
{
|
|
351 |
global $db, $session, $paths, $template, $plugins; // Common objects
|
|
352 |
$template->header();
|
|
353 |
if(file_exists(ENANO_ROOT.'/GPL'))
|
|
354 |
{
|
|
355 |
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>';
|
|
356 |
echo RenderMan::render( htmlspecialchars ( file_get_contents ( ENANO_ROOT . '/GPL' ) ) );
|
|
357 |
}
|
|
358 |
else
|
|
359 |
{
|
|
360 |
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://www.enanocms.org/GPL">http://www.enanocms.org/GPL</a>.</p>';
|
|
361 |
}
|
|
362 |
$template->footer();
|
|
363 |
}
|
|
364 |
|
|
365 |
?> |