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
192
9237767a23ae
Implemented cron image into Oxygen and St Patty as promised; fixed way-outdated version numbers in plugins
Dan
diff
changeset
+ − 7
Version: 1.0.2
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
192
9237767a23ae
Implemented cron image into Oxygen and St Patty as promised; fixed way-outdated version numbers in plugins
Dan
diff
changeset
+ − 13
* Version 1.0.2
0
+ − 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
));
83
+ − 61
+ − 62
$paths->add_page(Array(
+ − 63
\'name\'=>\'Tag cloud\',
+ − 64
\'urlname\'=>\'TagCloud\',
+ − 65
\'namespace\'=>\'Special\',
+ − 66
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
+ − 67
));
0
+ − 68
');
+ − 69
+ − 70
// function names are IMPORTANT!!! The name pattern is: page_<namespace ID>_<page URLname, without namespace>
+ − 71
22
+ − 72
function page_Special_CreatePage()
+ − 73
{
0
+ − 74
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 75
if ( isset($_POST['do']) )
+ − 76
{
+ − 77
$p = $_POST['pagename'];
+ − 78
$k = array_keys($paths->nslist);
+ − 79
for ( $i = 0; $i < sizeof( $paths->nslist ); $i++ )
+ − 80
{
+ − 81
$ln = strlen( $paths->nslist[$k[$i]] );
+ − 82
if ( substr($p, 0, $ln) == $paths->nslist[$k[$i]] )
+ − 83
{
+ − 84
$namespace = $k[$i];
+ − 85
}
+ − 86
}
+ − 87
if ( $namespace == 'Special' || ( $namespace == 'System' && $session->user_level < USER_LEVEL_ADMIN ) || $namespace == 'Admin')
+ − 88
{
+ − 89
$template->header();
+ − 90
+ − 91
echo '<h3>The page could not be created.</h3><p>The name "'.$p.'" is invalid.</p>';
+ − 92
+ − 93
$template->footer();
+ − 94
$db->close();
+ − 95
+ − 96
exit;
+ − 97
}
+ − 98
$name = $db->escape(str_replace('_', ' ', $p));
22
+ − 99
$urlname = str_replace(' ', '_', $p);
0
+ − 100
$namespace = $_POST['namespace'];
+ − 101
if ( $namespace == 'Special' || ( $namespace == 'System' && $session->user_level < USER_LEVEL_ADMIN ) || $namespace == 'Admin')
+ − 102
{
+ − 103
$template->header();
+ − 104
+ − 105
echo '<h3>The page could not be created.</h3><p>The name "'.$paths->nslist[$namespace].$p.'" is invalid.</p>';
+ − 106
+ − 107
$template->footer();
+ − 108
$db->close();
+ − 109
+ − 110
exit;
+ − 111
}
194
bf0fdec102e9
SECURITY: Fixed possible SQL injection in PageUtils page protection; general cleanup of PageUtils; blocked using Project: prefix for page URL strings
Dan
diff
changeset
+ − 112
if ( substr($urlname, 0, 8) == 'Project:' )
bf0fdec102e9
SECURITY: Fixed possible SQL injection in PageUtils page protection; general cleanup of PageUtils; blocked using Project: prefix for page URL strings
Dan
diff
changeset
+ − 113
{
bf0fdec102e9
SECURITY: Fixed possible SQL injection in PageUtils page protection; general cleanup of PageUtils; blocked using Project: prefix for page URL strings
Dan
diff
changeset
+ − 114
$template->header();
bf0fdec102e9
SECURITY: Fixed possible SQL injection in PageUtils page protection; general cleanup of PageUtils; blocked using Project: prefix for page URL strings
Dan
diff
changeset
+ − 115
bf0fdec102e9
SECURITY: Fixed possible SQL injection in PageUtils page protection; general cleanup of PageUtils; blocked using Project: prefix for page URL strings
Dan
diff
changeset
+ − 116
echo '<h3>The page could not be created.</h3><p>The page title can\'t start with "Project:" because this prefix is reserved for a parser shortcut.</p>';
bf0fdec102e9
SECURITY: Fixed possible SQL injection in PageUtils page protection; general cleanup of PageUtils; blocked using Project: prefix for page URL strings
Dan
diff
changeset
+ − 117
bf0fdec102e9
SECURITY: Fixed possible SQL injection in PageUtils page protection; general cleanup of PageUtils; blocked using Project: prefix for page URL strings
Dan
diff
changeset
+ − 118
$template->footer();
bf0fdec102e9
SECURITY: Fixed possible SQL injection in PageUtils page protection; general cleanup of PageUtils; blocked using Project: prefix for page URL strings
Dan
diff
changeset
+ − 119
$db->close();
bf0fdec102e9
SECURITY: Fixed possible SQL injection in PageUtils page protection; general cleanup of PageUtils; blocked using Project: prefix for page URL strings
Dan
diff
changeset
+ − 120
bf0fdec102e9
SECURITY: Fixed possible SQL injection in PageUtils page protection; general cleanup of PageUtils; blocked using Project: prefix for page URL strings
Dan
diff
changeset
+ − 121
exit;
bf0fdec102e9
SECURITY: Fixed possible SQL injection in PageUtils page protection; general cleanup of PageUtils; blocked using Project: prefix for page URL strings
Dan
diff
changeset
+ − 122
}
0
+ − 123
+ − 124
$tn = $paths->nslist[$_POST['namespace']] . $urlname;
+ − 125
if ( isset($paths->pages[$tn]) )
+ − 126
{
+ − 127
die_friendly('Error creating page', '<p>The page already exists.</p>');
+ − 128
}
+ − 129
+ − 130
if ( $paths->nslist[$namespace] == substr($urlname, 0, strlen($paths->nslist[$namespace]) ) )
+ − 131
{
+ − 132
$urlname = substr($urlname, strlen($paths->nslist[$namespace]), strlen($urlname));
+ − 133
}
+ − 134
+ − 135
$k = array_keys( $paths->nslist );
+ − 136
if(!in_array($_POST['namespace'], $k))
+ − 137
{
+ − 138
$db->_die('An SQL injection attempt was caught at '.dirname(__FILE__).':'.__LINE__.'.');
+ − 139
}
+ − 140
112
+ − 141
$ips = array(
+ − 142
'ip' => array(),
+ − 143
'u' => array()
+ − 144
);
+ − 145
$ips = $db->escape(serialize($ips));
+ − 146
22
+ − 147
$urlname = sanitize_page_id($urlname);
+ − 148
$urlname = $db->escape($urlname);
+ − 149
0
+ − 150
$perms = $session->fetch_page_acl($urlname, $namespace);
+ − 151
if ( !$perms->get_permissions('create_page') )
+ − 152
die_friendly('Error creating page', '<p>An access control rule is preventing you from creating pages.</p>');
+ − 153
+ − 154
$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'].'\');');
+ − 155
if ( !$q )
+ − 156
{
+ − 157
$db->_die('The page log could not be updated.');
+ − 158
}
+ − 159
112
+ − 160
$q = $db->sql_query('INSERT INTO '.table_prefix.'pages(name,urlname,namespace,delvote_ips) VALUES(\''.$name.'\', \''.$urlname.'\', \''.$_POST['namespace'].'\',\'' . $ips . '\');');
0
+ − 161
if ( !$q )
+ − 162
{
+ − 163
$db->_die('The page entry could not be inserted.');
+ − 164
}
157
+ − 165
$q = $db->sql_query('INSERT INTO '.table_prefix.'page_text(page_id,namespace,page_text) VALUES(\''.$urlname.'\', \''.$_POST['namespace'].'\', \''.'\');');
0
+ − 166
if ( !$q )
+ − 167
{
+ − 168
$db->_die('The page text entry could not be inserted.');
+ − 169
}
+ − 170
157
+ − 171
header('Location: '.makeUrlNS($_POST['namespace'], sanitize_page_id($p)) . '#do:edit');
0
+ − 172
exit;
+ − 173
}
+ − 174
$template->header();
285
7846d45bd250
Changed all urlname/page_id columns to varchar(255) because 63 characters just isn't long enough
Dan
diff
changeset
+ − 175
/*
0
+ − 176
if ( !$session->get_permissions('create_page') )
+ − 177
{
+ − 178
echo 'Wiki mode is disabled, only admins can create pages.';
+ − 179
+ − 180
$template->footer();
+ − 181
$db->close();
+ − 182
+ − 183
exit;
+ − 184
}
285
7846d45bd250
Changed all urlname/page_id columns to varchar(255) because 63 characters just isn't long enough
Dan
diff
changeset
+ − 185
*/
0
+ − 186
echo RenderMan::render('Using the form below you can create a page.');
+ − 187
?>
+ − 188
<form action="" method="post">
+ − 189
<p>
+ − 190
<select name="namespace">
+ − 191
<?php
+ − 192
$k = array_keys($paths->nslist);
+ − 193
for ( $i = 0; $i < sizeof($k); $i++ )
+ − 194
{
+ − 195
if ( $paths->nslist[$k[$i]] == '' )
+ − 196
{
+ − 197
$s = '[No prefix]';
+ − 198
}
+ − 199
else
+ − 200
{
+ − 201
$s = $paths->nslist[$k[$i]];
+ − 202
}
+ − 203
if ( ( $k[$i] != 'System' || $session->user_level >= USER_LEVEL_ADMIN ) && $k[$i] != 'Admin' && $k[$i] != 'Special')
+ − 204
{
+ − 205
echo '<option value="'.$k[$i].'">'.$s.'</option>';
+ − 206
}
+ − 207
}
+ − 208
?>
+ − 209
</select> <input type="text" name="pagename" /></p>
+ − 210
<p><input type="submit" name="do" value="Create Page" /></p>
+ − 211
</form>
+ − 212
<?php
+ − 213
$template->footer();
+ − 214
}
+ − 215
116
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 216
function PagelistingFormatter($id, $row)
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 217
{
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 218
global $db, $session, $paths, $template, $plugins; // Common objects
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 219
static $rowtracker = 0;
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 220
static $tdclass = 'row2';
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 221
static $per_row = 2;
117
+ − 222
static $first = true;
116
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 223
$return = '';
117
+ − 224
if ( $id === false && $row === false )
116
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 225
{
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 226
$rowtracker = 0;
117
+ − 227
$first = true;
116
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 228
return false;
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 229
}
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 230
$rowtracker++;
117
+ − 231
if ( $rowtracker == $per_row || $first )
116
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 232
{
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 233
$rowtracker = 0;
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 234
$tdclass = ( $tdclass == 'row2' ) ? 'row1' : 'row2';
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 235
}
117
+ − 236
if ( $rowtracker == 0 && !$first )
+ − 237
$return .= "</tr>\n<tr>";
+ − 238
+ − 239
$first = false;
116
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 240
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 241
preg_match('/^ns=(' . implode('|', array_keys($paths->nslist)) . ');pid=(.*?)$/i', $id, $match);
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 242
$namespace =& $match[1];
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 243
$page_id =& $match[2];
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 244
$page_id = sanitize_page_id($page_id);
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 245
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 246
$url = makeUrlNS($namespace, $page_id);
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 247
$url = htmlspecialchars($url);
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 248
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 249
$link = '<a href="' . $url . '">' . htmlspecialchars($row['name']) . '</a>';
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 250
$td = '<td class="' . $tdclass . '" style="width: 50%;">' . $link . '</td>';
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 251
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 252
$return .= $td;
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 253
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 254
return $return;
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 255
}
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 256
0
+ − 257
function page_Special_AllPages()
+ − 258
{
+ − 259
// This should be an easy one
+ − 260
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 261
$template->header();
+ − 262
$sz = sizeof( $paths->pages ) / 2;
116
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 263
echo '<p>Below is a list of all of the pages on this website.</p>';
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 264
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 265
$q = $db->sql_query('SELECT COUNT(urlname) FROM '.table_prefix.'pages WHERE visible!=0;');
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 266
if ( !$q )
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 267
$db->_die();
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 268
$row = $db->fetchrow_num();
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 269
$count = $row[0];
117
+ − 270
+ − 271
switch($count % 4)
+ − 272
{
+ − 273
case 0:
+ − 274
case 2:
+ − 275
// even number of results; do nothing
+ − 276
$last_cell = '';
+ − 277
break;
+ − 278
case 1:
+ − 279
// odd number of results and odd number of rows, use row1
+ − 280
$last_cell = '<td class="row1"></td>';
+ − 281
break;
+ − 282
case 3:
+ − 283
// odd number of results and even number of rows, use row2
+ − 284
$last_cell = '<td class="row2"></td>';
+ − 285
break;
+ − 286
}
+ − 287
116
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 288
$db->free_result();
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 289
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 290
$q = $db->sql_unbuffered_query('SELECT CONCAT("ns=",namespace,";pid=",urlname) AS identifier, name FROM '.table_prefix.'pages WHERE visible!=0 ORDER BY name ASC;');
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 291
if ( !$q )
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 292
$db->_die();
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 293
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 294
$offset = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0;
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 295
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 296
// reset formatter
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 297
PagelistingFormatter(false, false);
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 298
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 299
$result = paginate(
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 300
$q, // result resource
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 301
'{identifier}', // formatting template
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 302
$count, // # of results
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 303
makeUrlNS('Special', 'AllPages', 'offset=%s'), // result URL
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 304
$offset, // start offset
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 305
40, // results per page
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 306
array( 'identifier' => 'PagelistingFormatter' ), // hooks
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 307
'<div class="tblholder">
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 308
<table border="0" cellspacing="1" cellpadding="4">
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 309
<tr>', // print at start
117
+ − 310
' ' . $last_cell . '</tr>
116
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 311
</table>
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 312
</div>' // print at end
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 313
);
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 314
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 315
echo $result;
77c75179bb95
Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
Dan
diff
changeset
+ − 316
0
+ − 317
$template->footer();
+ − 318
}
+ − 319
+ − 320
function page_Special_SpecialPages()
+ − 321
{
+ − 322
// This should be an easy one
+ − 323
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 324
$template->header();
+ − 325
$sz = sizeof($paths->pages) / 2;
+ − 326
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">';
+ − 327
$cclass='row1';
+ − 328
for ( $i = 0; $i < $sz; $i = $i)
+ − 329
{
+ − 330
if ( $cclass == 'row1' )
+ − 331
{
+ − 332
$cclass = 'row3';
+ − 333
}
+ − 334
else if ( $cclass == 'row3')
+ − 335
{
+ − 336
$cclass='row1';
+ − 337
}
+ − 338
echo '<tr>';
+ − 339
for ( $j = 0; $j < 2; $j = $j )
+ − 340
{
+ − 341
if ( $i < $sz && $paths->pages[$i]['namespace'] == 'Special' && $paths->pages[$i]['visible'] == 1)
+ − 342
{
+ − 343
echo '<td style="width: 50%" class="'.$cclass.'"><a href="'.makeUrl($paths->pages[$i]['urlname']).'">';
+ − 344
echo $paths->pages[$i]['name'].'</a></td>';
+ − 345
$j++;
+ − 346
}
+ − 347
else if ( $i >= $sz )
+ − 348
{
+ − 349
echo '<td style="width: 50%" class="row2"></td>';
+ − 350
$j++;
+ − 351
}
+ − 352
$i++;
+ − 353
}
+ − 354
echo '</tr>';
+ − 355
}
+ − 356
echo '</table></div>';
+ − 357
$template->footer();
+ − 358
}
+ − 359
+ − 360
function page_Special_About_Enano()
+ − 361
{
+ − 362
global $db, $session, $paths, $template, $plugins; // Common objects
221
+ − 363
global $lang;
+ − 364
0
+ − 365
$platform = 'Unknown';
+ − 366
$uname = @file_get_contents('/proc/sys/kernel/ostype');
+ − 367
if($uname == "Linux\n")
+ − 368
$platform = 'Linux';
+ − 369
else if(file_exists('/hurd/pfinet')) // I have a little experience with GNU/Hurd :-) http://hurdvm.enanocms.org/
+ − 370
$platform = 'GNU/Hurd';
+ − 371
else if(file_exists('C:\Windows\system32\ntoskrnl.exe'))
+ − 372
$platform = 'Windows NT';
+ − 373
else if(file_exists('C:\Windows\system\krnl386.exe'))
+ − 374
$platform = 'Windows 9x/DOS';
+ − 375
else if(file_exists('/bin/bash'))
+ − 376
$platform = 'Other GNU/Mac OS X';
+ − 377
else if(is_dir('/bin'))
+ − 378
$platform = 'Other POSIX';
+ − 379
$template->header();
+ − 380
?>
+ − 381
<br />
+ − 382
<div class="tblholder">
+ − 383
<table border="0" cellspacing="1" cellpadding="4">
+ − 384
<tr><th colspan="2" style="text-align: left;">About the Enano Content Management System</th></tr>
221
+ − 385
<tr><td colspan="2" class="row3">
+ − 386
<?php
+ − 387
echo $lang->get('meta_enano_about_poweredby');
+ − 388
$subst = array(
+ − 389
'gpl_link' => makeUrlNS('Special', 'GNU_General_Public_License')
+ − 390
);
+ − 391
echo $lang->get('meta_enano_about_gpl', $subst);
+ − 392
if ( $lang->lang_code != 'eng' ):
+ − 393
// Do not remove this block of code. Doing so is a violation of the GPL. (A copy of the GPL in other languages
+ − 394
// must be accompanied by a copy of the English GPL.)
+ − 395
?>
+ − 396
<h3>(English)</h3>
+ − 397
<p>
+ − 398
This website is powered by <a href="http://enanocms.org/">Enano</a>, the lightweight and open source CMS that everyone can use.
+ − 399
Enano is copyright © 2006-2007 Dan Fuhry. For legal information, along with a list of libraries that Enano uses, please
+ − 400
see <a href="http://enanocms.org/Legal_information">Legal Information</a>.
+ − 401
</p>
+ − 402
<p>
+ − 403
The developers and maintainers of Enano strongly believe that software should not only be free to use, but free to be modified,
+ − 404
distributed, and used to create derivative works. For more information about Free Software, check out the
+ − 405
<a href="http://en.wikipedia.org/wiki/Free_Software" onclick="window.open(this.href); return false;">Wikipedia page</a> or
+ − 406
the <a href="http://www.fsf.org/" onclick="window.open(this.href); return false;">Free Software Foundation's</a> homepage.
+ − 407
</p>
+ − 408
<p>
+ − 409
This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU General Public License
+ − 410
as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+ − 411
</p>
+ − 412
<p>
+ − 413
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ − 414
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ − 415
</p>
+ − 416
<p>
+ − 417
You should have received <a href="<?php echo makeUrlNS('Special', 'GNU_General_Public_License'); ?>">a copy of
+ − 418
the GNU General Public License</a> along with this program; if not, write to:
+ − 419
</p>
+ − 420
<p style="margin-left 2em;">
+ − 421
Free Software Foundation, Inc.,<br />
+ − 422
51 Franklin Street, Fifth Floor<br />
+ − 423
Boston, MA 02110-1301, USA
+ − 424
</p>
+ − 425
<p>
+ − 426
Alternatively, you can <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">read it online</a>.
+ − 427
</p>
+ − 428
<?php
+ − 429
endif;
+ − 430
?>
0
+ − 431
</td></tr>
+ − 432
<tr>
+ − 433
<td class="row2" colspan="2">
53
+ − 434
<table border="0" style="margin: 0 auto; background: none; width: 100%;" cellpadding="5">
0
+ − 435
<tr>
53
+ − 436
<td style="text-align: center;">
87
570f68c3fe36
Redid stupid fading button code and fixed several RC2 bugs in the upgrade schema; 1.0.1 release candidate
Dan
diff
changeset
+ − 437
<?php echo $template->fading_button; ?>
0
+ − 438
</td>
+ − 439
<td style="text-align: center;">
+ − 440
<a href="http://www.php.net/" onclick="window.open(this.href); return false;" style="background: none; padding: 0;">
+ − 441
<img alt="Written in PHP" src="<?php echo scriptPath; ?>/images/about-powered-php.png" style="border-width: 0px;" width="88" height="31" />
+ − 442
</a>
+ − 443
</td>
+ − 444
<td style="text-align: center;">
+ − 445
<a href="http://www.mysql.com/" onclick="window.open(this.href); return false;" style="background: none; padding: 0;">
+ − 446
<img alt="Database engine powered by MySQL" src="<?php echo scriptPath; ?>/images/about-powered-mysql.png" style="border-width: 0px;" width="88" height="31" />
+ − 447
</a>
+ − 448
</td>
+ − 449
</tr>
+ − 450
</table>
+ − 451
</td>
+ − 452
</tr>
221
+ − 453
<tr><td style="width: 100px;" class="row1"><?php echo $lang->get('meta_enano_about_lbl_enanoversion'); ?></td><td class="row1"><?php echo enano_version(true) . ' (' . enano_codename() . ')'; ?></td></tr>
+ − 454
<tr><td style="width: 100px;" class="row2"><?php echo $lang->get('meta_enano_about_lbl_webserver'); ?></td><td class="row2"><?php if(isset($_SERVER['SERVER_SOFTWARE'])) echo $_SERVER['SERVER_SOFTWARE']; else echo 'Unable to determine web server software.'; ?></td></tr>
+ − 455
<tr><td style="width: 100px;" class="row1"><?php echo $lang->get('meta_enano_about_lbl_serverplatform'); ?></td><td class="row1"><?php echo $platform; ?></td></tr>
+ − 456
<tr><td style="width: 100px;" class="row2"><?php echo $lang->get('meta_enano_about_lbl_phpversion'); ?></td><td class="row2"><?php echo PHP_VERSION; ?></td></tr>
+ − 457
<tr><td style="width: 100px;" class="row1"><?php echo $lang->get('meta_enano_about_lbl_mysqlversion'); ?></td><td class="row1"><?php echo mysql_get_server_info($db->_conn); ?></td></tr>
0
+ − 458
</table>
+ − 459
</div>
+ − 460
<?php
+ − 461
$template->footer();
+ − 462
}
+ − 463
+ − 464
function page_Special_GNU_General_Public_License()
+ − 465
{
+ − 466
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 467
$template->header();
+ − 468
if(file_exists(ENANO_ROOT.'/GPL'))
+ − 469
{
+ − 470
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>';
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
diff
changeset
+ − 471
echo RenderMan::render( file_get_contents ( ENANO_ROOT . '/GPL' ) );
0
+ − 472
}
+ − 473
else
+ − 474
{
36
+ − 475
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
+ − 476
}
+ − 477
$template->footer();
+ − 478
}
+ − 479
83
+ − 480
function page_Special_TagCloud()
+ − 481
{
+ − 482
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 483
+ − 484
$template->header();
+ − 485
+ − 486
if ( $tag = $paths->getParam(0) )
+ − 487
{
+ − 488
$tag = sanitize_tag($tag);
+ − 489
$q = $db->sql_query('SELECT page_id, namespace FROM '.table_prefix.'tags WHERE tag_name=\'' . $db->escape($tag) . '\';');
+ − 490
if ( !$q )
+ − 491
$db->_die();
+ − 492
if ( $row = $db->fetchrow() )
+ − 493
{
+ − 494
echo '<div class="tblholder">
+ − 495
<table border="0" cellspacing="1" cellpadding="4">';
+ − 496
echo '<tr><th colspan="2">Pages tagged "' . htmlspecialchars($tag) . '"</th></tr>';
+ − 497
echo '<tr>';
+ − 498
$i = 0;
+ − 499
$td_class = 'row1';
+ − 500
do
+ − 501
{
+ − 502
if ( $i % 2 == 0 && $i > 1 )
+ − 503
{
+ − 504
$td_class = ( $td_class == 'row2' ) ? 'row1' : 'row2';
+ − 505
echo '</tr><tr>';
+ − 506
}
+ − 507
$i++;
+ − 508
$title = get_page_title_ns($row['page_id'], $row['namespace']);
+ − 509
if ( $row['namespace'] != 'Article' && isset($paths->nslist[$row['namespace']]) )
+ − 510
$title = $paths->nslist[$row['namespace']] . $title;
+ − 511
$url = makeUrlNS($row['namespace'], $row['page_id']);
+ − 512
$class = ( isPage( $paths->nslist[$row['namespace']] . $row['page_id'] ) ) ? '' : ' class="wikilink-nonexistent"';
+ − 513
$link = '<a href="' . htmlspecialchars($url) . '"' . $class . '>' . htmlspecialchars($title) . '</a>';
+ − 514
echo "<td class=\"$td_class\" style=\"width: 50%;\">$link</td>";
+ − 515
// " workaround for jEdit highlighting bug
+ − 516
}
+ − 517
while ( $row = $db->fetchrow() );
+ − 518
while ( $i % 2 > 0 )
+ − 519
{
+ − 520
$i++;
+ − 521
echo "<td class=\"$td_class\" style=\"width: 50%;\"></td>";
+ − 522
}
+ − 523
// " workaround for jEdit highlighting bug
+ − 524
echo '<tr>
+ − 525
<th colspan="2" class="subhead"><a href="' . makeUrlNS('Special', 'TagCloud') . '" style="color: white;">« Return to tag cloud</a></th>
+ − 526
</tr>';
+ − 527
echo '</table>';
+ − 528
echo '</div>';
+ − 529
}
+ − 530
}
+ − 531
else
+ − 532
{
+ − 533
$cloud = new TagCloud();
+ − 534
+ − 535
$q = $db->sql_query('SELECT tag_name FROM '.table_prefix.'tags;');
+ − 536
if ( !$q )
+ − 537
$db->_die();
+ − 538
if ( $db->numrows() < 1 )
+ − 539
{
+ − 540
echo '<p>No pages are tagged yet.</p>';
+ − 541
}
+ − 542
else
+ − 543
{
+ − 544
echo '<h3>Summary of page tagging</h3>';
+ − 545
while ( $row = $db->fetchrow() )
+ − 546
{
+ − 547
$cloud->add_word($row['tag_name']);
+ − 548
}
+ − 549
echo $cloud->make_html('normal');
+ − 550
echo '<p>Hover your mouse over a tag to see how many pages have the tag. Click on a tag to see a list of the pages that have it.</p>';
+ − 551
}
+ − 552
}
+ − 553
+ − 554
$template->footer();
+ − 555
}
+ − 556
+ − 557
// tag cloud sidebar block
+ − 558
function sidebar_add_tag_cloud()
+ − 559
{
+ − 560
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 561
$cloud = new TagCloud();
+ − 562
+ − 563
$q = $db->sql_query('SELECT tag_name FROM '.table_prefix.'tags;');
+ − 564
if ( !$q )
+ − 565
$db->_die();
+ − 566
if ( $db->numrows() < 1 )
+ − 567
{
+ − 568
$sb_html = 'No pages are tagged yet.';
+ − 569
}
+ − 570
else
+ − 571
{
+ − 572
while ( $row = $db->fetchrow() )
+ − 573
{
+ − 574
$cloud->add_word($row['tag_name']);
+ − 575
}
+ − 576
$sb_html = $cloud->make_html('small', 'justify') . '<br /><a style="text-align: center;" href="' . makeUrlNS('Special', 'TagCloud') . '">Larger version</a>';
+ − 577
}
+ − 578
$template->sidebar_widget('Tag cloud', "<div style='padding: 5px;'>$sb_html</div>");
+ − 579
}
+ − 580
+ − 581
$plugins->attachHook('compile_template', 'sidebar_add_tag_cloud();');
+ − 582
0
+ − 583
?>