0
+ − 1
<?php
+ − 2
/*
+ − 3
Plugin Name: Runt - the Enano administration panel
+ − 4
Plugin URI: http://enanocms.org/
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 5
Description: Provides the page Special:Administration, which is the AJAX frontend to the various Admin pagelets. This plugin cannot be disabled.
0
+ − 6
Author: Dan Fuhry
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
+ − 7
Version: 1.0.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
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
+ − 13
* Version 1.0.1 (Loch Ness)
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\'=>\'Administration\',
+ − 29
\'urlname\'=>\'Administration\',
+ − 30
\'namespace\'=>\'Special\',
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
+ − 31
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
0
+ − 32
));
+ − 33
+ − 34
$paths->add_page(Array(
+ − 35
\'name\'=>\'Manage the Sidebar\',
+ − 36
\'urlname\'=>\'EditSidebar\',
+ − 37
\'namespace\'=>\'Special\',
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
+ − 38
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
0
+ − 39
));
+ − 40
');
+ − 41
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
diff
changeset
+ − 42
// Admin pages that were too enormous to be in this file were split off into the plugins/admin/ directory in 1.0.1
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
diff
changeset
+ − 43
require(ENANO_ROOT . '/plugins/admin/PageGroups.php');
109
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 44
require(ENANO_ROOT . '/plugins/admin/SecurityLog.php');
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
diff
changeset
+ − 45
0
+ − 46
// function names are IMPORTANT!!! The name pattern is: page_<namespace ID>_<page URLname, without namespace>
+ − 47
+ − 48
function page_Admin_Home() {
+ − 49
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 50
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 51
{
+ − 52
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 53
return;
+ − 54
}
+ − 55
+ − 56
// Basic information
+ − 57
echo RenderMan::render(
+ − 58
'== Welcome to Runt, the Enano administration panel. ==
+ − 59
+ − 60
Thank you for choosing Enano as your CMS. This screen allows you to see some information about your website, plus some details about how your site is doing statistically.
+ − 61
+ − 62
Using the links on the left you can control every aspect of your website\'s look and feel, plus you can manage users, work with pages, and install plugins to make your Enano installation even better.');
+ − 63
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 64
// Demo mode
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 65
if ( defined('ENANO_DEMO_MODE') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 66
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 67
echo '<h3>Enano is running in demo mode.</h3>
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 68
<p>If you borked something up, or if you\'re done testing, you can <a href="' . makeUrlNS('Special', 'DemoReset', false, true) . '">reset this site</a>. The site is reset automatically once every two hours. When a reset is performed, all custom modifications to the site are lost and replaced with default values.</p>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 69
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 70
0
+ − 71
// Check for the installer scripts
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 72
if( ( file_exists(ENANO_ROOT.'/install.php') || file_exists(ENANO_ROOT.'/schema.sql') ) && !defined('ENANO_DEMO_MODE') )
0
+ − 73
{
+ − 74
echo '<div class="error-box"><b>NOTE:</b> It appears that your install.php and/or schema.sql files still exist. It is HIGHLY RECOMMENDED that you delete or rename these files, to prevent getting your server hacked.</div>';
+ − 75
}
+ − 76
+ − 77
// Inactive users
+ − 78
$q = $db->sql_query('SELECT * FROM '.table_prefix.'logs WHERE log_type=\'admin\' AND action=\'activ_req\';');
+ − 79
if($q)
+ − 80
if($db->numrows() > 0)
+ − 81
{
+ − 82
$n = $db->numrows();
+ − 83
if($n == 1) $s = $n . ' user is';
+ − 84
else $s = $n . ' users are';
+ − 85
echo '<div class="warning-box">It appears that '.$s.' awaiting account activation. You can activate those accounts by going to the <a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'UserManager\'); return false;">User Manager</a>.</div>';
+ − 86
}
+ − 87
$db->free_result();
+ − 88
// Stats
+ − 89
if(getConfig('log_hits') == '1')
+ − 90
{
+ − 91
$stats = stats_top_pages(10);
61
+ − 92
//die('<pre>'.print_r($stats,true).'</pre>');
0
+ − 93
$c = 0;
+ − 94
$cls = 'row2';
+ − 95
echo '<h3>Most requested pages</h3><div class="tblholder"><table style="width: 100%;" border="0" cellspacing="1" cellpadding="4"><tr><th>Page</th><th>Hits</th></tr>';
61
+ − 96
foreach($stats as $data)
0
+ − 97
{
61
+ − 98
echo '<tr>';
+ − 99
$cls = ( $cls == 'row1' ) ? 'row2' : 'row1';
+ − 100
echo '<td class="'.$cls.'"><a href="'.makeUrl($data['page_urlname']).'">'.$data['page_title'].'</a></td><td style="text-align: center;" class="'.$cls.'">'.$data['num_hits'].'</td>';
+ − 101
echo '</tr>';
0
+ − 102
}
+ − 103
echo '</table></div>';
+ − 104
}
+ − 105
+ − 106
// Security log
+ − 107
echo '<h3>Security log</h3>';
109
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 108
$seclog = get_security_log(5);
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 109
echo $seclog;
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 110
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 111
echo '<p><a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'SecurityLog\'); return false;">Full security log</a></p>';
0
+ − 112
+ − 113
}
+ − 114
+ − 115
function page_Admin_GeneralConfig() {
+ − 116
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 117
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 118
{
+ − 119
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 120
return;
+ − 121
}
+ − 122
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 123
if(isset($_POST['submit']) && !defined('ENANO_DEMO_MODE') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 124
{
0
+ − 125
+ − 126
// Global site options
+ − 127
setConfig('site_name', $_POST['site_name']);
+ − 128
setConfig('site_desc', $_POST['site_desc']);
+ − 129
setConfig('main_page', str_replace(' ', '_', $_POST['main_page']));
+ − 130
setConfig('copyright_notice', $_POST['copyright']);
+ − 131
setConfig('contact_email', $_POST['contact_email']);
+ − 132
+ − 133
// Wiki mode
+ − 134
if(isset($_POST['wikimode'])) setConfig('wiki_mode', '1');
+ − 135
else setConfig('wiki_mode', '0');
+ − 136
if(isset($_POST['wiki_mode_require_login'])) setConfig('wiki_mode_require_login', '1');
+ − 137
else setConfig('wiki_mode_require_login', '0');
+ − 138
if(isset($_POST['editmsg'])) setConfig('wiki_edit_notice', '1');
+ − 139
else setConfig('wiki_edit_notice', '0');
+ − 140
setConfig('wiki_edit_notice_text', $_POST['editmsg_text']);
+ − 141
+ − 142
// Stats
+ − 143
if(isset($_POST['log_hits'])) setConfig('log_hits', '1');
+ − 144
else setConfig('log_hits', '0');
+ − 145
+ − 146
// Disablement
+ − 147
if(isset($_POST['site_disabled'])) { setConfig('site_disabled', '1'); setConfig('site_disabled_notice', $_POST['site_disabled_notice']); }
+ − 148
else setConfig('site_disabled', '0');
+ − 149
+ − 150
// Account activation
+ − 151
setConfig('account_activation', $_POST['account_activation']);
+ − 152
+ − 153
// W3C compliance buttons
+ − 154
if(isset($_POST['w3c-vh32'])) setConfig("w3c_vh32", "1");
+ − 155
else setConfig("w3c_vh32", "0");
+ − 156
if(isset($_POST['w3c-vh40'])) setConfig("w3c_vh40", "1");
+ − 157
else setConfig("w3c_vh40", "0");
+ − 158
if(isset($_POST['w3c-vh401'])) setConfig("w3c_vh401", "1");
+ − 159
else setConfig("w3c_vh401", "0");
+ − 160
if(isset($_POST['w3c-vxhtml10'])) setConfig("w3c_vxhtml10", "1");
+ − 161
else setConfig("w3c_vxhtml10", "0");
+ − 162
if(isset($_POST['w3c-vxhtml11'])) setConfig("w3c_vxhtml11", "1");
+ − 163
else setConfig("w3c_vxhtml11", "0");
+ − 164
if(isset($_POST['w3c-vcss'])) setConfig("w3c_vcss", "1");
+ − 165
else setConfig("w3c_vcss", "0");
+ − 166
+ − 167
// SourceForge.net logo
+ − 168
if(isset($_POST['showsf'])) setConfig('sflogo_enabled', '1');
+ − 169
else setConfig('sflogo_enabled', '0');
+ − 170
setConfig('sflogo_groupid', $_POST['sfgroup']);
+ − 171
setConfig('sflogo_type', $_POST['sflogo']);
+ − 172
+ − 173
// Comment options
+ − 174
if(isset($_POST['comment-approval'])) setConfig('approve_comments', '1');
+ − 175
else setConfig('approve_comments', '0');
+ − 176
if(isset($_POST['enable-comments'])) setConfig('enable_comments', '1');
+ − 177
else setConfig('enable_comments', '0');
+ − 178
setConfig('comments_need_login', $_POST['comments_need_login']);
+ − 179
+ − 180
// Powered by link
+ − 181
if ( isset($_POST['enano_powered_link']) ) setConfig('powered_btn', '1');
+ − 182
else setConfig('powered_btn', '0');
+ − 183
+ − 184
if(isset($_POST['dbdbutton'])) setConfig('dbd_button', '1');
+ − 185
else setConfig('dbd_button', '0');
+ − 186
+ − 187
if($_POST['emailmethod'] == 'phpmail') setConfig('smtp_enabled', '0');
+ − 188
else setConfig('smtp_enabled', '1');
+ − 189
+ − 190
setConfig('smtp_server', $_POST['smtp_host']);
+ − 191
setConfig('smtp_user', $_POST['smtp_user']);
+ − 192
if($_POST['smtp_pass'] != 'XXXXXXXXXXXX') setConfig('smtp_password', $_POST['smtp_pass']);
+ − 193
+ − 194
echo '<div class="info-box">Your changes to the site configuration have been saved.</div><br />';
+ − 195
+ − 196
}
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 197
else if ( isset($_POST['submit']) && defined('ENANO_DEMO_MODE') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 198
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 199
echo '<div class="error-box">Saving the general site configuration is blocked in the administration demo.</div>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 200
}
0
+ − 201
echo('<form name="main" action="'.htmlspecialchars(makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module'])).'" method="post" onsubmit="if(!submitAuthorized) return false;">');
+ − 202
?>
+ − 203
<div class="tblholder">
+ − 204
<table border="0" width="100%" cellspacing="1" cellpadding="4">
+ − 205
+ − 206
<!-- Global options -->
+ − 207
+ − 208
<tr><th colspan="2">Global site options</th></tr>
+ − 209
<tr><th colspan="2" class="subhead">These options control the entire site.</th></tr>
+ − 210
40
+ − 211
<tr><td class="row1" style="width: 50%;">Site name:</td> <td class="row1" style="width: 50%;"><input type="text" name="site_name" size="30" value="<?php echo htmlspecialchars(getConfig('site_name')); ?>" /></td></tr>
+ − 212
<tr><td class="row2">Site description:</td> <td class="row2"><input type="text" name="site_desc" size="30" value="<?php echo htmlspecialchars(getConfig('site_desc')); ?>" /></td></tr>
+ − 213
<tr><td class="row1">Main page:</td> <td class="row1"><?php echo $template->pagename_field('main_page', htmlspecialchars(str_replace('_', ' ', getConfig('main_page')))); ?></td></tr>
+ − 214
<tr><td class="row2">Copyright notice shown on pages:</td><td class="row2"><input type="text" name="copyright" size="30" value="<?php echo htmlspecialchars(getConfig('copyright_notice')); ?>" /></td></tr>
0
+ − 215
<tr><td class="row1" colspan="2">Hint: If you're using Windows, you can make a "©" symbol by holding ALT and pressing 0169 on the numeric keypad.</td></tr>
+ − 216
<tr><td class="row2">Contact e-mail<br /><small>All e-mail sent from this site will appear to have come from the address shown here.</small></td><td class="row2"><input name="contact_email" type="text" size="40" value="<?php echo htmlspecialchars(getConfig('contact_email')); ?>" /></td></tr>
+ − 217
+ − 218
<!-- Wiki mode -->
+ − 219
+ − 220
<tr><th colspan="2">Wiki mode</th></tr>
+ − 221
+ − 222
<tr>
+ − 223
<td class="row3" rowspan="2">
+ − 224
Enano can also act as a wiki, meaning anyone can edit and create pages. To enable Wiki Mode, check the box to the right.<br /><br />
+ − 225
In Wiki Mode, certain HTML tags such as <script> and <object> are disabled, and all PHP code is disabled, except if the person editing the page is an administrator.<br /><br />
+ − 226
Also, Enano keeps complete page history, which makes restoring vandalized pages easy. You can also protect pages so that they cannot be edited.
+ − 227
</td>
+ − 228
<td class="row1">
+ − 229
<input type="checkbox" name="wikimode" id="wikimode" <?php if(getConfig('wiki_mode')=='1') echo('CHECKED '); ?> /><label for="wikimode">Enable Wiki Mode</label>
+ − 230
</td>
+ − 231
</tr>
+ − 232
+ − 233
<tr><td class="row2"><label><input type="checkbox" name="wiki_mode_require_login"<?php if(getConfig('wiki_mode_require_login')=='1') echo('CHECKED '); ?>/> Only for logged in users</label></td></tr>
+ − 234
+ − 235
<tr>
+ − 236
<td class="row3" rowspan="2">
+ − 237
<b>Edit page notice</b><br />
+ − 238
When Wiki Mode is enabled, anyone can edit pages. Check the box below and enter a message to display it whenever the page editor is opened.
+ − 239
</td>
+ − 240
<td class="row1">
+ − 241
<input onclick="if(this.checked) document.getElementById('editmsg_text').style.display='block'; else document.getElementById('editmsg_text').style.display='none';" type="checkbox" name="editmsg" id="editmsg" <?php if(getConfig('wiki_edit_notice')=='1') echo('CHECKED '); ?>/> <label for="editmsg">Show a message whenever pages are edited</label>
+ − 242
</td>
+ − 243
</tr>
+ − 244
+ − 245
<tr>
+ − 246
<td class="row2">
+ − 247
<textarea <?php if(getConfig('wiki_edit_notice')!='1') echo('style="display:none" '); ?>rows="5" cols="30" name="editmsg_text" id="editmsg_text"><?php echo getConfig('wiki_edit_notice_text'); ?></textarea>
+ − 248
</td>
+ − 249
</tr>
+ − 250
+ − 251
<!-- Site statistics -->
+ − 252
+ − 253
<tr><th colspan="2">Statistics and hit counting</th></tr>
+ − 254
+ − 255
<tr>
+ − 256
<td class="row1">Enano has the ability to show statistics for every page on the site. This allows you to keep very close track of who is visiting your site, and from where.<br /><br />Unfortunately, some users don't like being logged. For this reason, you should state clearly what is logged (usually the username or IP address, current time, page name, and referer URL) in your privacy policy. If your site is primarily geared towards children, and you are a United States citizen, you are required to have a privacy policy stating exactly what is being logged under the terms of the Childrens' Online Privacy Protection Act.</td>
+ − 257
<td class="row1"><label><input type="checkbox" name="log_hits" <?php if(getConfig('log_hits') == '1') echo 'checked="checked" '; ?>/> Log all page hits</label><br /><small>This excludes special and administration pages.</small></td>
+ − 258
</tr>
+ − 259
+ − 260
<!-- Comment options -->
+ − 261
+ − 262
<tr><th colspan="2">Comment system</th></tr>
+ − 263
<tr><td class="row1"><label for="enable-comments"><b>Enable the comment system</b></label> </td><td class="row1"><input name="enable-comments" id="enable-comments" type="checkbox" <?php if(getConfig('enable_comments')=='1') echo('CHECKED '); ?>/></td></tr>
+ − 264
<tr><td class="row2"><label for="comment-approval">Require approval before article comments can be shown</label></td><td class="row2"><input name="comment-approval" id="comment-approval" type="checkbox" <?php if(getConfig('approve_comments')=='1') echo('CHECKED '); ?>/></td></tr>
+ − 265
<tr><td class="row1">Guest comment posting allowed </td><td class="row1"><label><input name="comments_need_login" type="radio" value="0" <?php if(getConfig('comments_need_login')=='0') echo 'CHECKED '; ?>/> Yes</label>
+ − 266
<label><input name="comments_need_login" type="radio" value="1" <?php if(getConfig('comments_need_login')=='1') echo 'CHECKED '; ?>/> Require visual confirmation</label>
+ − 267
<!-- Default permissions --> <label><input name="comments_need_login" type="radio" value="2" <?php if(getConfig('comments_need_login')=='2') echo 'CHECKED '; ?>/> No (require login)</label></td></tr>
+ − 268
+ − 269
<!--
+ − 270
+ − 271
READ: Do not try to enable this, backend support for it has been disabled. To edit default
+ − 272
permissions, select The Entire Website in any permissions editor window.
+ − 273
+ − 274
<tr><th colspan="2">Default permissions for pages</th></tr>
+ − 275
+ − 276
<tr>
+ − 277
<td class="row1">You can edit the default set of permissions used when no other permissions are available. Permissions set here are used when no other permissions are available. As with other ACL rules, you can assign these defaults to every user or one specific user or group.</td>
+ − 278
<td class="row1"><a href="#" onclick="ajaxOpenACLManager('__DefaultPermissions', 'Special'); return false;">Manage default permissions</a></td>
+ − 279
</tr>
+ − 280
+ − 281
-->
+ − 282
+ − 283
<!-- enanocms.org link -->
+ − 284
+ − 285
<tr>
+ − 286
<th colspan="2">Promote Enano</th>
+ − 287
</tr>
+ − 288
<tr>
+ − 289
<td class="row3">
+ − 290
If you think Enano is nice, or if you want to show your support for the Enano team, you can do so by placing a link to the Enano
+ − 291
homepage in your Links sidebar block. You absolutely don't have to do this, and you won't get degraded support if you don't. Because
+ − 292
Enano is still relatively new in the CMS world, it needs all the attention it can get - and you can easily help to spread the word
+ − 293
using this link.
+ − 294
</td>
+ − 295
<td class="row1">
+ − 296
<label>
36
+ − 297
<input name="enano_powered_link" type="checkbox" <?php if(getConfig('powered_btn') == '1') echo 'checked="checked"'; ?> /> Place a link to enanocms.org on the sidebar
0
+ − 298
</label>
+ − 299
</td>
+ − 300
</tr>
+ − 301
+ − 302
<!-- Site disablement -->
+ − 303
+ − 304
<tr><th colspan="2">Disable all site access</th></tr>
+ − 305
+ − 306
<tr>
+ − 307
<td class="row3" rowspan="2">Disabling the site allows you to work on the site without letting non-administrators see or use it.</td>
+ − 308
<td class="row1"><label><input onclick="if(this.checked) document.getElementById('site_disabled_notice').style.display='block'; else document.getElementById('site_disabled_notice').style.display='none';" type="checkbox" name="site_disabled" <?php if(getConfig('site_disabled') == '1') echo 'checked="checked" '; ?>/> Disable this site</label></td>
+ − 309
</tr>
+ − 310
<tr>
+ − 311
<td class="row2">
30
+ − 312
<div id="site_disabled_notice"<?php if(getConfig('site_disabled')!='1') echo(' style="display:none"'); ?>>
0
+ − 313
Message to show to users:<br />
+ − 314
<textarea name="site_disabled_notice" rows="7" cols="30"><?php echo getConfig('site_disabled_notice'); ?></textarea>
+ − 315
</div>
+ − 316
</td>
+ − 317
</tr>
+ − 318
+ − 319
<!-- Account activation -->
+ − 320
+ − 321
<tr><th colspan="2">User account activation</th></tr>
+ − 322
+ − 323
<tr>
+ − 324
<td class="row3" colspan="2">
+ − 325
If you would like to require users to confirm their e-mail addresses by way of account activation, you can enable this behavior here. If this option is set to "None", users will be able to register and use this site without confirming their e-mail addresses. If this option is set to "User", users will automatically be sent e-mails upon registration with a link to activate their accounts. And lastly, if this option is set to "Admin", users' accounts will not be active until an administrator activates the account.<br /><br />
+ − 326
You may also disable registration completely if needed.<br /><br />
+ − 327
<b>Note: because of abuse by project administrators, sending account activation e-mails will not work on SourceForge.net servers.</b>
+ − 328
</td>
+ − 329
</tr>
+ − 330
+ − 331
<tr>
+ − 332
<td class="row1">Account activation:</td><td class="row1">
+ − 333
<?php
+ − 334
echo '<label><input'; if(getConfig('account_activation') == 'disable') echo ' checked="checked"'; echo ' type="radio" name="account_activation" value="disable" /> Disable registration</label><br />';
+ − 335
echo '<label><input'; if(getConfig('account_activation') != 'user' && getConfig('account_activation') != 'admin') echo ' checked="checked"'; echo ' type="radio" name="account_activation" value="none" /> None</label>';
+ − 336
echo '<label><input'; if(getConfig('account_activation') == 'user') echo ' checked="checked"'; echo ' type="radio" name="account_activation" value="user" /> User</label>';
+ − 337
echo '<label><input'; if(getConfig('account_activation') == 'admin') echo ' checked="checked"'; echo ' type="radio" name="account_activation" value="admin" /> Admin</label>';
+ − 338
?>
+ − 339
</td>
+ − 340
</tr>
+ − 341
+ − 342
<!-- E-mail options -->
+ − 343
+ − 344
<tr><th colspan="2">E-mail sent from the site</th></tr>
+ − 345
<tr><td class="row1">E-mail sending method:<br /><small>Try using the built-in e-mail method first. If that doesn't work, you will need to enter valid SMTP information here.</small></td>
+ − 346
<td class="row1"><label><input <?php if(getConfig('smtp_enabled') != '1') echo 'checked="checked"'; ?> type="radio" name="emailmethod" value="phpmail" />PHP's built-in mail() function</label><br />
+ − 347
<label><input <?php if(getConfig('smtp_enabled') == '1') echo 'checked="checked"'; ?> type="radio" name="emailmethod" value="smtp" />Use an external SMTP server</label></td>
+ − 348
</tr>
+ − 349
<tr><td class="row2">SMTP hostname:<br /><small>This option only applies to the external SMTP mode.</small></td>
+ − 350
<td class="row2"><input value="<?php echo getConfig('smtp_server'); ?>" name="smtp_host" type="text" size="30" /></td>
+ − 351
</tr>
+ − 352
<tr><td class="row1">SMTP credentials:<br /><small>This option only applies to the external SMTP mode.</small></td>
+ − 353
<td class="row1">Username: <input value="<?php echo getConfig('smtp_user'); ?>" name="smtp_user" type="text" size="30" /><br />
+ − 354
Password: <input value="<?php if(getConfig('smtp_password') != false) echo 'XXXXXXXXXXXX'; ?>" name="smtp_pass" type="password" size="30" /></td>
+ − 355
</tr>
+ − 356
+ − 357
<!-- SourceForge.net logo -->
+ − 358
+ − 359
<tr><th colspan="2">SourceForge.net logo</th></tr>
+ − 360
+ − 361
<tr>
+ − 362
<td colspan="2" class="row3">
+ − 363
All projects hosted by SourceForge.net are required to display an official SourceForge.net logo on their pages. If you want
+ − 364
to display a SourceForge.net logo on the sidebar, check the box below, enter your group ID, and select an image type.
+ − 365
</td>
+ − 366
</tr>
+ − 367
+ − 368
<?php
+ − 369
if(getConfig("sflogo_enabled")=='1') $c='CHECKED ';
+ − 370
else $c='';
+ − 371
if(getConfig("sflogo_groupid")) $g=getConfig("sflogo_groupid");
+ − 372
else $g='';
+ − 373
if(getConfig("sflogo_type")) $t=getConfig("sflogo_type");
+ − 374
else $t='1';
+ − 375
?>
+ − 376
+ − 377
<tr>
+ − 378
<td class="row1">Display the SourceForge.net logo on the right sidebar</td>
+ − 379
<td class="row1"><input type=checkbox name="showsf" id="showsf" <?php echo $c; ?> /></td>
+ − 380
</tr>
+ − 381
+ − 382
<tr>
+ − 383
<td class="row2">Group ID:</td>
+ − 384
<td class="row2"><input value="<?php echo $g; ?>" type=text size=15 name=sfgroup /></td>
+ − 385
</tr>
+ − 386
+ − 387
<tr>
+ − 388
<td class="row1">Logo style:</td>
+ − 389
<td class="row1">
+ − 390
<select name="sflogo">
+ − 391
<option <?php if($t=='1') echo('SELECTED '); ?>value=1>88x31px, white</option>
+ − 392
<option <?php if($t=='2') echo('SELECTED '); ?>value=2>125x37px, white</option>
+ − 393
<option <?php if($t=='3') echo('SELECTED '); ?>value=3>125x37px, black</option>
+ − 394
<option <?php if($t=='4') echo('SELECTED '); ?>value=4>125x37px, blue</option>
+ − 395
<option <?php if($t=='5') echo('SELECTED '); ?>value=5>210x62px, white</option>
+ − 396
<option <?php if($t=='6') echo('SELECTED '); ?>value=6>210x62px, black</option>
+ − 397
<option <?php if($t=='7') echo('SELECTED '); ?>value=7>210x62px, blue</option>
+ − 398
</select>
+ − 399
</td>
+ − 400
</tr>
+ − 401
+ − 402
<!-- W3C validator buttons -->
+ − 403
+ − 404
<tr><th colspan="2">W3C compliance logos</th></tr>
+ − 405
<tr><th colspan="2" class="subhead">Enano generates (by default) Valid XHTML 1.1 code, plus valid CSS. If you want to show this off, check the appropriate boxes below.</th></tr>
+ − 406
+ − 407
<tr><td class="row1"><label for="w3c-vh32">HTML 3.2</label> </td><td class="row1"><input type="checkbox" <?php if(getConfig('w3c_vh32')=='1') echo('CHECKED '); ?> id="w3c-vh32" name="w3c-vh32" /></td></tr>
+ − 408
<tr><td class="row2"><label for="w3c-vh40">HTML 4.0</label> </td><td class="row2"><input type="checkbox" <?php if(getConfig('w3c_vh40')=='1') echo('CHECKED '); ?> id="w3c-vh40" name="w3c-vh40" /></td></tr>
+ − 409
<tr><td class="row1"><label for="w3c-vh401">HTML 4.01</label> </td><td class="row1"><input type="checkbox" <?php if(getConfig('w3c_vh401')=='1') echo('CHECKED '); ?> id="w3c-vh401" name="w3c-vh401" /></td></tr>
+ − 410
<tr><td class="row2"><label for="w3c-vxhtml10">XHTML 1.0</label></td><td class="row2"><input type="checkbox" <?php if(getConfig('w3c_vxhtml10')=='1') echo('CHECKED '); ?> id="w3c-vxhtml10" name="w3c-vxhtml10" /></td></tr>
+ − 411
<tr><td class="row1"><label for="w3c-vxhtml11">XHTML 1.1</label></td><td class="row1"><input type="checkbox" <?php if(getConfig('w3c_vxhtml11')=='1') echo('CHECKED '); ?> id="w3c-vxhtml11" name="w3c-vxhtml11" /></td></tr>
+ − 412
<tr><td class="row2"><label for="w3c-vcss">CSS</label> </td><td class="row2"><input type="checkbox" <?php if(getConfig('w3c_vcss')=='1') echo('CHECKED '); ?> id="w3c-vcss" name="w3c-vcss" /></td></tr>
+ − 413
+ − 414
<!-- DefectiveByDesign.org ad -->
+ − 415
+ − 416
<tr><th colspan="2">Defective By Design Anti-DRM button</th></tr>
+ − 417
<tr><td colspan="2" class="row3"><b>The Enano project is strongly against Digital Restrictions Management.</b> DRM removes the freedoms that every consumer should have: to freely copy and use digital media items they legally purchased to their own devices. Showing your opposition to DRM is as easy as checking the box below to place a link to <a href="http://www.defectivebydesign.org">DefectiveByDesign.org</a> on your sidebar.</td></tr>
+ − 418
<tr><td class="row1"><label for="dbdbutton">Help stop DRM by placing a link to DBD on the sidebar!</label></td><td class="row1"><input type="checkbox" name="dbdbutton" id="dbdbutton" <?php if(getConfig('dbd_button')=='1') echo('checked="checked" '); ?>/></td></tr>
+ − 419
+ − 420
<!-- Save button -->
+ − 421
+ − 422
<tr><th style="text-align: right" class="subhead" colspan="2"><input type=submit name=submit value="Save changes" /></th></tr>
+ − 423
+ − 424
</table>
+ − 425
</div>
+ − 426
</form>
+ − 427
<?php
+ − 428
}
+ − 429
+ − 430
function page_Admin_UploadConfig()
+ − 431
{
+ − 432
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 433
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 434
{
+ − 435
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 436
return;
+ − 437
}
+ − 438
+ − 439
if(isset($_POST['save']))
+ − 440
{
109
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 441
if(isset($_POST['enable_uploads']) && getConfig('enable_uploads') != '1')
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 442
{
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 443
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author) VALUES("security","upload_enable",UNIX_TIMESTAMP(),"' . $db->escape($_SERVER['REMOTE_ADDR']) . '","' . $db->escape($session->username) . '");');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 444
if ( !$q )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 445
$db->_die();
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 446
setConfig('enable_uploads', '1');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 447
}
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 448
else if ( !isset($_POST['enable_uploads']) && getConfig('enable_uploads') == '1' )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 449
{
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 450
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author) VALUES("security","upload_disable",UNIX_TIMESTAMP(),"' . $db->escape($_SERVER['REMOTE_ADDR']) . '","' . $db->escape($session->username) . '");');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 451
if ( !$q )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 452
$db->_die();
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 453
setConfig('enable_uploads', '0');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 454
}
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 455
if(isset($_POST['enable_imagemagick']) && getConfig('enable_imagemagick') != '1')
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 456
{
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 457
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author) VALUES("security","magick_enable",UNIX_TIMESTAMP(),"' . $db->escape($_SERVER['REMOTE_ADDR']) . '","' . $db->escape($session->username) . '");');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 458
if ( !$q )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 459
$db->_die();
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 460
setConfig('enable_imagemagick', '1');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 461
}
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 462
else if ( !isset($_POST['enable_imagemagick']) && getConfig('enable_imagemagick') == '1' )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 463
{
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 464
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author) VALUES("security","magick_disable",UNIX_TIMESTAMP(),"' . $db->escape($_SERVER['REMOTE_ADDR']) . '","' . $db->escape($session->username) . '");');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 465
if ( !$q )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 466
$db->_die();
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 467
setConfig('enable_imagemagick', '0');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 468
}
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 469
if(isset($_POST['cache_thumbs']))
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 470
{
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 471
setConfig('cache_thumbs', '1');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 472
}
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 473
else
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 474
{
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 475
setConfig('cache_thumbs', '0');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 476
}
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 477
if(isset($_POST['file_history']) && getConfig('file_history') != '1' )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 478
{
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 479
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author) VALUES("security","filehist_enable",UNIX_TIMESTAMP(),"' . $db->escape($_SERVER['REMOTE_ADDR']) . '","' . $db->escape($session->username) . '");');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 480
if ( !$q )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 481
$db->_die();
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 482
setConfig('file_history', '1');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 483
}
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 484
else if ( !isset($_POST['file_history']) && getConfig('file_history') == '1' )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 485
{
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 486
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author) VALUES("security","filehist_disable",UNIX_TIMESTAMP(),"' . $db->escape($_SERVER['REMOTE_ADDR']) . '","' . $db->escape($session->username) . '");');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 487
if ( !$q )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 488
$db->_die();
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 489
setConfig('file_history', '0');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 490
}
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 491
if(file_exists($_POST['imagemagick_path']) && $_POST['imagemagick_path'] != getConfig('imagemagick_path'))
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 492
{
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 493
$old = getConfig('imagemagick_path');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 494
$oldnew = "{$old}||{$_POST['imagemagick_path']}";
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 495
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author,page_text) VALUES("security","magick_path",UNIX_TIMESTAMP(),"' . $db->escape($_SERVER['REMOTE_ADDR']) . '","' . $db->escape($session->username) . '","' . $db->escape($oldnew) . '");');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 496
if ( !$q )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 497
$db->_die();
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 498
setConfig('imagemagick_path', $_POST['imagemagick_path']);
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 499
}
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 500
else if ( $_POST['imagemagick_path'] != getConfig('imagemagick_path') )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 501
{
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 502
echo '<span style="color: red"><b>Warning:</b> the file "'.htmlspecialchars($_POST['imagemagick_path']).'" was not found, and the ImageMagick file path was not updated.</span>';
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 503
}
0
+ − 504
$max_upload = floor((float)$_POST['max_file_size'] * (int)$_POST['fs_units']);
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 505
if ( $max_upload > 1048576 && defined('ENANO_DEMO_MODE') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 506
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 507
echo '<div class="error-box">Wouldn\'t want the server DoS\'ed now. Stick to under a megabyte for the demo, please.</div>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 508
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 509
else
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 510
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 511
setConfig('max_file_size', $max_upload.'');
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 512
}
0
+ − 513
}
+ − 514
echo '<form name="main" action="'.htmlspecialchars(makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module'])).'" method="post">';
+ − 515
?>
+ − 516
<h3>File upload configuration</h3>
+ − 517
<p>Enano supports the ability to upload files to your website and store the files in the database. This enables you to embed images
+ − 518
and such into pages without manually writing the HTML. However, the upload feature can sometimes pose a risk to your site, as viruses
+ − 519
and executable files can sometimes be uploaded.</p>
+ − 520
<p><label><input type="checkbox" name="enable_uploads" <?php if(getConfig('enable_uploads')=='1') echo 'checked="checked"'; ?> /> <b>Enable file uploads</b></label></p>
+ − 521
<p>Maximum file size: <input name="max_file_size" onkeyup="if(!this.value.match(/^([0-9\.]+)$/ig)) this.value = this.value.substr(0,this.value.length-1);" value="<?php echo getConfig('max_file_size'); ?>" /> <select name="fs_units"><option value="1" selected="selected">bytes</option><option value="1024">KB</option><option value="1048576">MB</option></select></p>
+ − 522
<p>You can allow Enano to generate thumbnails of images automatically. This feature requires ImageMagick to work properly. If your server
+ − 523
does not have ImageMagick on it, Enano will simply make your users' browsers scale the images. In most cases this is fine, but if you
+ − 524
are uploading large (>100KB) images and embedding them inside of pages, you should try to enable ImageMagick because transferring these
+ − 525
large images many times can cost you quite a lot of bandwidth.</p>
+ − 526
<p><label><input type="checkbox" name="enable_imagemagick" <?php if(getConfig('enable_imagemagick')=='1') echo 'checked="checked"'; ?> /> Use ImageMagick to scale images</label><br />
+ − 527
Path to ImageMagick: <input type="text" name="imagemagick_path" value="<?php if(getConfig('imagemagick_path')) echo getConfig('imagemagick_path'); else echo '/usr/bin/convert'; ?>" /><br />
+ − 528
On Linux and Unix servers, the most likely options here are /usr/bin/convert and /usr/local/bin/convert. If you server runs Windows, then
+ − 529
ImageMagick is most likely to be C:\Windows\Convert.exe or C:\Windows\System32\Convert.exe.
+ − 530
</p>
+ − 531
<p>If you use ImageMagick to scale images, your server will be very busy constantly scaling images if your website is busy, and your site
+ − 532
may experience slowdowns. You can dramatically speed up this scaling process if you use a directory to cache thumbnail images.</p>
+ − 533
<p><b>Please note:</b> the cache/ directory on your server <u>must</u> be writable by the server. While this is not usually a problem on
+ − 534
Windows servers, most Linux/Unix servers will require you to CHMOD the cache/ directory to 777. See your FTP client's user guide for
+ − 535
more information on how to do this.<?php if(!is_writable(ENANO_ROOT.'/cache/')) echo ' <b>At present, it seems that the cache directory
+ − 536
is not writable. The checkbox below has been disabled to maintain the stability of Enano.</b>'; ?></p>
+ − 537
<p><label><input type="checkbox" name="cache_thumbs" <?php if(getConfig('cache_thumbs')=='1' && is_writable(ENANO_ROOT.'/cache/')) echo 'checked="checked"'; elseif(!is_writable(ENANO_ROOT.'/cache/')) echo 'readonly="readonly"'; ?> /> Cache thumbnailed images</label></p>
+ − 538
<p>Lastly, you can choose whether file history will be saved. If this option is turned on, you will be able to roll back any malicious
+ − 539
changes made to uploaded files, but this requires a significant amount of database storage. You should probably leave this option
+ − 540
enabled unless you have less than 250MB of MySQL database space.</p>
109
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 541
<p><label><input type="checkbox" name="file_history" <?php if(getConfig('file_history')=='1') echo 'checked="checked"'; ?> /> Keep a history of uploaded files</label></p>
0
+ − 542
<hr style="margin-left: 1em;" />
+ − 543
<p><input type="submit" name="save" value="Save changes" style="font-weight: bold;" /></p>
+ − 544
<?php
+ − 545
echo '</form>';
+ − 546
}
+ − 547
+ − 548
function page_Admin_PluginManager() {
+ − 549
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 550
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 551
{
+ − 552
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 553
return;
+ − 554
}
+ − 555
9
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 556
if(isset($_GET['action']))
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 557
{
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 558
switch($_GET['action'])
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 559
{
0
+ − 560
case "enable":
109
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 561
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author,page_text) VALUES("security","plugin_enable",UNIX_TIMESTAMP(),"' . $db->escape($_SERVER['REMOTE_ADDR']) . '","' . $db->escape($session->username) . '","' . $db->escape($_GET['plugin']) . '");');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 562
if ( !$q )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 563
$db->_die();
0
+ − 564
setConfig('plugin_'.$_GET['plugin'], '1');
+ − 565
break;
+ − 566
case "disable":
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 567
if ( defined('ENANO_DEMO_MODE') && strstr($_GET['plugin'], 'Demo') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 568
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 569
echo('<h3>Error disabling plugin</h3><p>The demo lockdown plugin cannot be disabled in demo mode.</p>');
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 570
break;
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 571
}
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 572
if ( !in_array($_GET['plugin'], $plugins->system_plugins) )
9
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 573
{
109
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 574
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author,page_text) VALUES("security","plugin_disable",UNIX_TIMESTAMP(),"' . $db->escape($_SERVER['REMOTE_ADDR']) . '","' . $db->escape($session->username) . '","' . $db->escape($_GET['plugin']) . '");');
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 575
if ( !$q )
93ef7df77847
Added a ton of new log points for administrator actions; restructured security log view and enabled pagination for security logs; string change in ajax.php for RDNS operation failure
Dan
diff
changeset
+ − 576
$db->_die();
9
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 577
setConfig('plugin_'.$_GET['plugin'], '0');
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 578
}
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 579
else
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 580
{
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 581
echo('<h3>Error disabling plugin</h3><p>The plugin you selected cannot be disabled because it is a system plugin.</p>');
9
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 582
}
0
+ − 583
break;
+ − 584
}
+ − 585
}
+ − 586
$dir = './plugins/';
+ − 587
$plugin_list = Array();
+ − 588
$system = Array();
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 589
$show_system = ( isset($_GET['show_system']) && $_GET['show_system'] == 'yes' );
9
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 590
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 591
if (is_dir($dir))
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 592
{
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 593
if ($dh = opendir($dir))
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 594
{
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 595
while (($file = readdir($dh)) !== false)
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 596
{
0
+ − 597
if(preg_match('#^(.*?)\.php$#is', $file) && $file != 'index.php')
+ − 598
{
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 599
unset($thelist);
0
+ − 600
if ( in_array($file, $plugins->system_plugins) )
+ − 601
{
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 602
if ( !$show_system )
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 603
continue;
0
+ − 604
$thelist =& $system;
+ − 605
}
+ − 606
else
+ − 607
{
+ − 608
$thelist =& $plugin_list;
+ − 609
}
+ − 610
$f = file_get_contents($dir . $file);
+ − 611
$f = explode("\n", $f);
+ − 612
$f = array_slice($f, 2, 7);
+ − 613
$f[0] = substr($f[0], 13, strlen($f[0]));
+ − 614
$f[1] = substr($f[1], 12, strlen($f[1]));
+ − 615
$f[2] = substr($f[2], 13, strlen($f[2]));
+ − 616
$f[3] = substr($f[3], 8, strlen($f[3]));
+ − 617
$f[4] = substr($f[4], 9, strlen($f[4]));
+ − 618
$f[5] = substr($f[5], 12, strlen($f[5]));
+ − 619
$thelist[$file] = Array();
+ − 620
$thelist[$file]['name'] = $f[0];
+ − 621
$thelist[$file]['uri'] = $f[1];
+ − 622
$thelist[$file]['desc'] = $f[2];
+ − 623
$thelist[$file]['auth'] = $f[3];
+ − 624
$thelist[$file]['vers'] = $f[4];
+ − 625
$thelist[$file]['aweb'] = $f[5];
+ − 626
}
+ − 627
}
+ − 628
closedir($dh);
+ − 629
}
9
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 630
else
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 631
{
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 632
echo '<div class="error-box">The plugins/ directory could not be opened.</div>';
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 633
return;
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 634
}
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 635
}
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 636
else
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 637
{
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 638
echo '<div class="error-box">The plugins/ directory is missing from your Enano installation.</div>';
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
diff
changeset
+ − 639
return;
0
+ − 640
}
+ − 641
echo('<div class="tblholder"><table border="0" width="100%" cellspacing="1" cellpadding="4">
+ − 642
<tr><th>Plugin filename</th><th>Plugin name</th><th>Description</th><th>Author</th><th>Version</th><th></th></tr>');
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 643
$plugin_files_1 = array_keys($plugin_list);
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 644
$plugin_files_2 = array_keys($system);
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 645
$plugin_files = array_values(array_merge($plugin_files_1, $plugin_files_2));
0
+ − 646
$cls = 'row2';
+ − 647
for ( $i = 0; $i < sizeof($plugin_files); $i++ )
+ − 648
{
+ − 649
$cls = ( $cls == 'row2' ) ? 'row3' : 'row2';
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 650
$this_plugin = ( isset($system[$plugin_files[$i]]) ) ? $system[$plugin_files[$i]] : $plugin_list[$plugin_files[$i]];
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 651
$is_system = ( $system[$plugin_files[$i]] );
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 652
$bgcolor = '';
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 653
if ( $is_system && $cls == 'row2' )
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 654
$bgcolor = ' style="background-color: #FFD8D8;"';
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 655
else if ( $is_system && $cls == 'row3' )
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 656
$bgcolor = ' style="background-color: #FFD0D0;"';
0
+ − 657
echo '<tr>
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 658
<td class="'.$cls.'"'.$bgcolor.'>'.$plugin_files[$i].'</td>
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 659
<td class="'.$cls.'"'.$bgcolor.'><a href="'.$this_plugin['uri'].'">'.$this_plugin['name'].'</a></td>
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 660
<td class="'.$cls.'"'.$bgcolor.'>'.$this_plugin['desc'].'</td>
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 661
<td class="'.$cls.'"'.$bgcolor.'><a href="'.$this_plugin['aweb'].'">'.$this_plugin['auth'].'</a></td>
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 662
<td class="'.$cls.'"'.$bgcolor.'>'.$this_plugin['vers'].'</td>
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 663
<td class="'.$cls.'"'.$bgcolor.'>';
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 664
if ( !in_array($plugin_files[$i], $plugins->system_plugins) )
0
+ − 665
{
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 666
if ( getConfig('plugin_'.$plugin_files[$i]) == '1' )
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 667
{
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 668
echo '<a href="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'&show_system=' . ( $show_system ? 'yes' : 'no' ) . '&action=disable&plugin='.$plugin_files[$i].'">Disable</a>';
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 669
}
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 670
else
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 671
{
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 672
echo '<a href="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'&show_system=' . ( $show_system ? 'yes' : 'no' ) . '&action=enable&plugin='.$plugin_files[$i].'">Enable</a>';
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 673
}
0
+ − 674
}
+ − 675
else
+ − 676
{
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 677
echo '[System]';
0
+ − 678
}
+ − 679
echo '</td></tr>';
+ − 680
}
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 681
$showhide_link = ( $show_system ) ?
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 682
'<a style="color: white;" href="' . makeUrlNS('Special', 'Administration', 'module=' . $paths->cpage['module'] . '&show_system=no', true) . '">Hide system plugins</a>' :
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 683
'<a style="color: white;" href="' . makeUrlNS('Special', 'Administration', 'module=' . $paths->cpage['module'] . '&show_system=yes', true) . '">Show system plugins</a>' ;
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 684
echo '<tr><th colspan="6" class="subhead">'.$showhide_link.'</th></tr>';
0
+ − 685
echo '</table></div>';
+ − 686
}
+ − 687
+ − 688
function page_Admin_UploadAllowedMimeTypes()
+ − 689
{
+ − 690
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 691
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 692
{
+ − 693
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 694
return;
+ − 695
}
+ − 696
+ − 697
global $mime_types, $mimetype_exps, $mimetype_extlist;
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 698
if(isset($_POST['save']) && !defined('ENANO_DEMO_MODE'))
0
+ − 699
{
+ − 700
$bits = '';
+ − 701
$keys = array_keys($mime_types);
+ − 702
foreach($keys as $i => $k)
+ − 703
{
+ − 704
if(isset($_POST['ext_'.$k])) $bits .= '1';
+ − 705
else $bits .= '0';
+ − 706
}
+ − 707
$bits = compress_bitfield($bits);
+ − 708
setConfig('allowed_mime_types', $bits);
+ − 709
echo '<div class="info-box">Your changes have been saved.</div>';
+ − 710
}
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 711
else if ( isset($_POST['save']) && defined('ENANO_DEMO_MODE') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 712
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 713
echo '<div class="error-box">Hmm, enabling executables, are we? Tsk tsk. I\'d love to know what\'s in that EXE file you want to upload. OK, maybe you didn\'t enable EXEs. But nevertheless, changing allowed filetypes is disabled in the demo.</div>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 714
}
0
+ − 715
$allowed = fetch_allowed_extensions();
+ − 716
?>
+ − 717
<h3>Allowed file types</h3>
+ − 718
<p>Using the form below, you can decide which file types are allowed to be uploaded to this site.</p>
+ − 719
<?php
+ − 720
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', (( isset($_GET['sqldbg'])) ? 'sqldbg&' : '') .'module='.$paths->cpage['module']).'" method="post">';
+ − 721
$c = -1;
+ − 722
$t = -1;
+ − 723
$cl = 'row1';
+ − 724
echo "\n".' <div class="tblholder">'."\n".' <table cellspacing="1" cellpadding="2" style="margin: 0; padding: 0;" border="0">'."\n".' <tr>'."\n ";
+ − 725
foreach($mime_types as $e => $m)
+ − 726
{
+ − 727
$c++;
+ − 728
$t++;
+ − 729
if($c == 3)
+ − 730
{
+ − 731
$c = 0;
+ − 732
$cl = ( $cl == 'row1' ) ? 'row2' : 'row1';
+ − 733
echo '</tr>'."\n".' <tr>'."\n ";
+ − 734
}
+ − 735
$seed = "extchkbx_{$e}_".md5(microtime() . mt_rand());
+ − 736
$chk = (!empty($allowed[$e])) ? ' checked="checked"' : '';
+ − 737
echo " <td class='$cl'>\n <label><input id='{$seed}' type='checkbox' name='ext_{$e}'{$chk} />.{$e}\n ({$m})</label>\n </td>\n ";
+ − 738
}
+ − 739
while($c < 2)
+ − 740
{
+ − 741
$c++;
+ − 742
echo " <td class='{$cl}'></td>\n ";
+ − 743
}
+ − 744
echo '<tr><th class="subhead" colspan="3"><input type="submit" name="save" value="Save changes" /></th></tr>';
+ − 745
echo '</tr>'."\n".' </table>'."\n".' </div>';
+ − 746
echo '</form>';
+ − 747
?>
+ − 748
<?php
+ − 749
}
+ − 750
+ − 751
function page_Admin_Sidebar()
+ − 752
{
+ − 753
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 754
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 755
{
+ − 756
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 757
return;
+ − 758
}
+ − 759
+ − 760
?>
+ − 761
<h2>Editing and managing the Enano sidebar</h2>
+ − 762
<p>The Enano sidebar is a versatile tool when scripted correctly. You don't have to be a programmer to enjoy the features the Sidebar
+ − 763
provides; however, editing the sidebar requires a small bit of programming knowledge and an understanding of Enano's system message
+ − 764
markup language.
+ − 765
</p>
+ − 766
<p>The Enano system markup language is somewhat similar to HTML, in that it uses tags (<example>like this</example>) for the
+ − 767
main syntax. However, Enano uses curly brackets ({ and }) as opposed to less-than and greater-than signs (< and >).</p>
+ − 768
<p>Programming the Enano sidebar requires the use of two tags: {slider} and {if}. The {slider} tag is used to create a new heading
+ − 769
on the sidebar, and all text enclosed in that tag will be collapsed when the heading is clicked. To specify the text on the heading,
+ − 770
use an equals sign (=) after the "slider" text. Then insert any links (they should be wiki-formatted) to internal Enano pages and
+ − 771
external sites.</p>
+ − 772
<p>So here is what the language for the default sidebar's "Navigation" heading looks like:</p>
+ − 773
<pre>{slider=Navigation}
+ − 774
[[Main Page|Home]]
+ − 775
[[Enano:Sidebar|Edit the sidebar]]
+ − 776
{/slider}</pre>
+ − 777
<p>Pretty simple, huh? Good, now we're going to learn another common aspect of Enano programming: conditionals. The {if} tag allows you
+ − 778
to decide whether a portion of the sidebar will be displayed based on a template variable. Currently the only available conditions are
+ − 779
"user_logged_in" and "auth_admin", but more will be added soon. To use a conditional, enter {if conditional_name}, and then the
+ − 780
wiki-formatted text that you want to be under that condition, and then close the tag with {/if}. In the same way, you can reverse the
+ − 781
effect with {!if}. With {!if}, the closing tag is still {/if}, so keep that in mind. An {else} tag will be supported soon.</p>
+ − 782
<p>Now it's time for some real fun: variables. All template variables can be accessed from the sidebar. A variable is simply the
+ − 783
variable name, prefixed by a dollar sign ($). Some of the most common variables are $USERNAME, $SITE_NAME, $SITE_DESC, and $PAGE_NAME.
+ − 784
The sidebar also has some special variables that it uses for some of its links. The logout link can be added with $LOGOUT_LINK, and
+ − 785
the "change theme" button can be added with $STYLE_LINK.</p>
+ − 786
<p>So here is the Enano markup for the portion of the sidebar that contains the user tools:</p>
+ − 787
<pre>{slider=$USERNAME}
+ − 788
[[User:$USERNAME|User page]]
+ − 789
[[Special:Contributions?user=$USERNAME|My Contributions]]
+ − 790
{if user_logged_in}
+ − 791
[[Special:Preferences|Preferences]]
+ − 792
$THEME_LINK
+ − 793
{/if}
+ − 794
{if auth_admin}
+ − 795
[[Special:Administration|Administration]]
+ − 796
{/if}
+ − 797
{if user_logged_in}
+ − 798
$LOGOUT_LINK
+ − 799
{/if}
+ − 800
{!if user_logged_in}
+ − 801
Create an account
+ − 802
Log in
+ − 803
{/if}
+ − 804
{/slider}</pre>
+ − 805
<?php
+ − 806
}
+ − 807
+ − 808
function page_Admin_UserManager() {
+ − 809
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 810
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 811
{
+ − 812
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 813
return;
+ − 814
}
+ − 815
103
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
diff
changeset
+ − 816
if ( isset($_GET['src']) && $_GET['src'] == 'get' && !empty($_GET['user']) )
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
diff
changeset
+ − 817
{
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
diff
changeset
+ − 818
$_POST['go'] = true;
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
diff
changeset
+ − 819
$_POST['username'] = $_GET['user'];
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
diff
changeset
+ − 820
}
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
diff
changeset
+ − 821
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 822
if(isset($_POST['go']))
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 823
{
0
+ − 824
// We need the user ID before we can do anything
102
+ − 825
$q = $db->sql_query('SELECT user_id,username,email,real_name,style,user_level,account_active FROM '.table_prefix.'users WHERE username=\'' . $db->escape($_POST['username']) . '\'');
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 826
if ( !$q )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 827
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 828
die('Error selecting user ID: '.mysql_error());
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 829
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 830
if ( $db->numrows() < 1 )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 831
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 832
echo('User does not exist, please enter another username.');
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 833
return;
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 834
}
0
+ − 835
$r = $db->fetchrow();
+ − 836
$db->free_result();
+ − 837
if(isset($_POST['save']))
+ − 838
{
+ − 839
$_POST['level'] = intval($_POST['level']);
+ − 840
+ − 841
$new_level = $_POST['level'];
+ − 842
$old_level = intval($r['user_level']);
+ − 843
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 844
if ( defined('ENANO_DEMO_MODE') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 845
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 846
echo '<div class="error-box">You cannot delete or modify user accounts in demo mode - they are cleaned up once every two hours.</div>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 847
$re = Array('permission denied');
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 848
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 849
else
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 850
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 851
$re = $session->update_user((int)$r['user_id'], $_POST['new_username'], false, $_POST['new_pass'], $_POST['email'], $_POST['real_name'], false, $_POST['level']);
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 852
}
0
+ − 853
+ − 854
if($re == 'success')
+ − 855
{
+ − 856
+ − 857
if ( $new_level != $old_level )
+ − 858
{
+ − 859
$user_id = intval($r['user_id']);
+ − 860
// We need to update group memberships
+ − 861
if ( $old_level == USER_LEVEL_ADMIN )
+ − 862
{
+ − 863
$session->remove_user_from_group($user_id, GROUP_ID_ADMIN);
+ − 864
}
+ − 865
else if ( $old_level == USER_LEVEL_MOD )
+ − 866
{
+ − 867
$session->remove_user_from_group($user_id, GROUP_ID_MOD);
+ − 868
}
+ − 869
+ − 870
if ( $new_level == USER_LEVEL_ADMIN )
+ − 871
{
+ − 872
$session->add_user_to_group($user_id, GROUP_ID_ADMIN, false);
+ − 873
}
+ − 874
else if ( $new_level == USER_LEVEL_MOD )
+ − 875
{
+ − 876
$session->add_user_to_group($user_id, GROUP_ID_MOD, false);
+ − 877
}
+ − 878
}
+ − 879
102
+ − 880
// update account activation
+ − 881
if ( isset($_POST['account_active']) )
+ − 882
{
+ − 883
// activate account
+ − 884
$q = $db->sql_query('UPDATE '.table_prefix.'users SET account_active=1 WHERE user_id=' . intval($r['user_id']) . ';');
+ − 885
if ( !$q )
+ − 886
$db->_die();
+ − 887
}
+ − 888
else
+ − 889
{
+ − 890
// deactivate account and throw away the old key
+ − 891
$actkey = sha1 ( microtime() . mt_rand() );
+ − 892
$q = $db->sql_query('UPDATE '.table_prefix.'users SET account_active=0,activation_key=\'' . $actkey . '\' WHERE user_id=' . intval($r['user_id']) . ';');
+ − 893
if ( !$q )
+ − 894
$db->_die();
+ − 895
}
+ − 896
0
+ − 897
echo('<div class="info-box">Your changes have been saved.</div>');
+ − 898
}
+ − 899
else
+ − 900
{
+ − 901
echo('<div class="error-box">Error saving changes: '.implode('<br />', $re).'</div>');
+ − 902
}
102
+ − 903
$q = $db->sql_query('SELECT user_id,username,email,real_name,style,user_level,account_active FROM '.table_prefix.'users WHERE username=\''.$db->escape($_POST['username']).'\'');
0
+ − 904
if ( !$q )
+ − 905
{
+ − 906
die('Error selecting user ID: '.mysql_error());
+ − 907
}
+ − 908
if($db->numrows($q) < 1)
+ − 909
{
+ − 910
die('User does not exist, please enter another username.');
+ − 911
}
+ − 912
$r = mysql_fetch_object($q);
+ − 913
$db->free_result();
+ − 914
}
+ − 915
elseif(isset($_POST['deleteme']) && isset($_POST['delete_conf']))
+ − 916
{
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 917
if ( defined('ENANO_DEMO_MODE') )
0
+ − 918
{
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 919
echo '<div class="error-box">You cannot delete or modify user accounts in demo mode - they are cleaned up once every two hours.</div>';
0
+ − 920
}
+ − 921
else
+ − 922
{
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 923
$q = $db->sql_query('DELETE FROM users WHERE user_id='.$r['user_id'].';');
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 924
if($q)
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 925
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 926
echo '<div class="error-box">The user account "'.$r['username'].'" was deleted.</div>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 927
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 928
else
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 929
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 930
echo '<div class="error-box">The user account "'.$r['username'].'" could not be deleted due to a database error.<br /><br />'.$db->get_error().'</div>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 931
}
0
+ − 932
}
+ − 933
}
+ − 934
else
+ − 935
{
22
+ − 936
$disabled = ( $r['user_id'] == $session->user_id ) ? ' disabled="disabled" ' : '';
0
+ − 937
echo('
+ − 938
<h3>Edit User Info</h3>
+ − 939
<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post">
+ − 940
<table border="0" style="margin-left: 0.2in;">
+ − 941
<tr><td>Username:</td><td><input type="text" name="new_username" value="'.$r['username'].'" /></td></tr>
22
+ − 942
<tr><td>New Password:</td><td><input ' . $disabled . ' type="password" name="new_pass" /></td></tr>
+ − 943
<tr><td>E-mail:</td><td><input ' . $disabled . ' type="text" name="email" value="'.$r['email'].'" /></td></tr>
+ − 944
<tr><td>Real Name:</td><td><input ' . $disabled . ' type="text" name="real_name" value="'.$r['real_name'].'" /></td></tr>
+ − 945
' . ( ( !empty($disabled) ) ? '<tr><td colspan="2"><small>To change your e-mail address, password, or real name, please use the user control panel.</small></td></tr>' : '' ) . '
0
+ − 946
<tr><td>User level:</td><td><select name="level"><option '); if($r['user_level']==USER_LEVEL_CHPREF) echo('SELECTED'); echo(' value="'.USER_LEVEL_CHPREF.'">Regular User</option><option '); if($r['user_level']==USER_LEVEL_MOD) echo('SELECTED'); echo(' value="'.USER_LEVEL_MOD.'">Moderator</option><option '); if($r['user_level']==USER_LEVEL_ADMIN) echo('SELECTED'); echo(' value="'.USER_LEVEL_ADMIN.'">Administrator</option></select></td></tr>
102
+ − 947
<tr><td></td><td><label><input type="checkbox" name="account_active"' . ( $r['account_active'] == '1' ? ' checked="checked"' : '' ) . ' /> Account is active</label><br /><small>If this is unchecked, the activation key will be reset, meaning that any activation e-mails sent will be invalidated.</small></td></tr>
0
+ − 948
<tr><td>Delete user:</td><td><input type="hidden" name="go" /><input type="hidden" name="username" value="'.$r['username'].'" /><input onclick="return confirm(\'This is your last warning.\n\nAre you sure you want to delete this user account? Even if you delete this user account, the username will be shown in page edit history, comments, and other areas of the site.\n\nDeleting a user account CANNOT BE UNDONE and should only be done in extreme circumstances.\n\nIf the user has violated the site policy, deleting the account will not prevent him from using the site, for that you need to add a new ban rule.\n\nContinue deleting this user account?\')" type="submit" name="deleteme" value="Delete this user" style="color: red;" /> <label><input type="checkbox" name="delete_conf" /> I\'m absolutely sure</label>
+ − 949
<tr><td align="center" colspan="2">
+ − 950
<input type="submit" name="save" value="Save Changes" /></td></tr>
+ − 951
</table>
+ − 952
</form>
+ − 953
');
+ − 954
}
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 955
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 956
else if(isset($_POST['clearsessions']))
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 957
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 958
if ( defined('ENANO_DEMO_MODE') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 959
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 960
echo '<div class="error-box">Sorry Charlie, no can do. You might mess up other people logged into the demo site.</div>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 961
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 962
else
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 963
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 964
// Get the current session information so the user doesn't get logged out
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 965
$aes = new AESCrypt();
22
+ − 966
$sk = md5(strrev($session->sid_super));
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 967
$qb = $db->sql_query('SELECT session_key,salt,auth_level,source_ip,time FROM '.table_prefix.'session_keys WHERE session_key=\''.$sk.'\' AND user_id='.$session->user_id.' AND auth_level='.USER_LEVEL_ADMIN);
22
+ − 968
if ( !$qb )
+ − 969
{
+ − 970
die('Error selecting session key info block B: '.$db->get_error());
+ − 971
}
+ − 972
if ( $db->numrows($qb) < 1 )
+ − 973
{
+ − 974
die('Error: cannot read admin session info block B, aborting table clear process');
+ − 975
}
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 976
$qa = $db->sql_query('SELECT session_key,salt,auth_level,source_ip,time FROM '.table_prefix.'session_keys WHERE session_key=\''.md5($session->sid).'\' AND user_id='.$session->user_id.' AND auth_level='.USER_LEVEL_MEMBER);
22
+ − 977
if ( !$qa )
+ − 978
{
+ − 979
die('Error selecting session key info block A: '.$db->get_error());
+ − 980
}
+ − 981
if ( $db->numrows($qa) < 1 )
+ − 982
{
+ − 983
die('Error: cannot read user session info block A, aborting table clear process');
+ − 984
}
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 985
$ra = mysql_fetch_object($qa);
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 986
$rb = mysql_fetch_object($qb);
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 987
$db->free_result($qa);
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 988
$db->free_result($qb);
22
+ − 989
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 990
$db->sql_query('DELETE FROM '.table_prefix.'session_keys;');
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 991
$db->sql_query('INSERT INTO '.table_prefix.'session_keys( session_key,salt,user_id,auth_level,source_ip,time ) VALUES( \''.$ra->session_key.'\', \''.$ra->salt.'\', \''.$session->user_id.'\', \''.$ra->auth_level.'\', \''.$ra->source_ip.'\', '.$ra->time.' ),( \''.$rb->session_key.'\', \''.$rb->salt.'\', \''.$session->user_id.'\', \''.$rb->auth_level.'\', \''.$rb->source_ip.'\', '.$rb->time.' )');
22
+ − 992
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 993
echo('
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 994
<div class="info-box">The session key table has been cleared. Your database should be a little bit smaller now.</div>
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 995
');
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 996
}
0
+ − 997
}
+ − 998
echo('
+ − 999
<h3>User Management</h3>
+ − 1000
<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;">
+ − 1001
<p>Username: '.$template->username_field('username').' <input type="submit" name="go" value="Go" /></p>
+ − 1002
<h3>Clear session keys table</h3>
+ − 1003
<p>It\'s a good idea to clean out your session keys table every once in a while, since this helps to reduce database size. During this process you will be logged off and (hopefully) logged back on automatically. The side effects of this include all users except you being logged off.</p>
+ − 1004
<p><input type="submit" name="clearsessions" value="Clear session keys table" /></p>
+ − 1005
</form>
+ − 1006
');
+ − 1007
if(isset($_GET['action']) && isset($_GET['user']))
+ − 1008
{
+ − 1009
switch($_GET['action'])
+ − 1010
{
+ − 1011
case "activate":
+ − 1012
$e = $db->sql_query('SELECT activation_key FROM '.table_prefix.'users WHERE username=\'' . $db->escape($_GET['user']) . '\'');
+ − 1013
if($e)
+ − 1014
{
+ − 1015
$row = $db->fetchrow();
+ − 1016
$db->free_result();
+ − 1017
if($session->activate_account($_GET['user'], $row['activation_key'])) { echo '<div class="info-box">The user account "'.$_GET['user'].'" has been activated.</div>'; $db->sql_query('DELETE FROM '.table_prefix.'logs WHERE time_id=' . $db->escape($_GET['logid'])); }
+ − 1018
else echo '<div class="warning-box">The user account "'.$_GET['user'].'" has NOT been activated, possibly because the account is already active.</div>';
+ − 1019
} else echo '<div class="error-box">Error activating account: '.mysql_error().'</div>';
+ − 1020
break;
+ − 1021
case "sendemail":
+ − 1022
if($session->send_activation_mail($_GET['user'])) { echo '<div class="info-box">The user "'.$_GET['user'].'" has been sent an e-mail with an activation link.</div>'; $db->sql_query('DELETE FROM '.table_prefix.'logs WHERE time_id=' . $db->escape($_GET['logid'])); }
+ − 1023
else echo '<div class="error-box">The user account "'.$_GET['user'].'" has not been activated, probably because of a bad SMTP configuration.</div>';
+ − 1024
break;
+ − 1025
case "deny":
+ − 1026
$e = $db->sql_query('DELETE FROM '.table_prefix.'logs WHERE log_type=\'admin\' AND action=\'activ_req\' AND edit_summary=\'' . $db->escape($_GET['user']) . '\';');
+ − 1027
if(!$e) echo '<div class="error-box">Error during row deletion: '.mysql_error().'</div>';
+ − 1028
else echo '<div class="info-box">All activation requests for the user "'.$_GET['user'].'" have been deleted.</div>';
+ − 1029
break;
+ − 1030
}
+ − 1031
}
30
+ − 1032
$q = $db->sql_query('SELECT l.log_type, l.action, l.time_id, l.date_string, l.author, l.edit_summary, u.user_coppa FROM '.table_prefix.'logs AS l
+ − 1033
LEFT JOIN '.table_prefix.'users AS u
+ − 1034
ON ( u.username = l.edit_summary OR u.username IS NULL )
+ − 1035
WHERE log_type=\'admin\' AND action=\'activ_req\' ORDER BY time_id DESC;');
0
+ − 1036
if($q)
+ − 1037
{
+ − 1038
if($db->numrows() > 0)
+ − 1039
{
+ − 1040
$n = $db->numrows();
+ − 1041
if($n == 1) $s = $n . ' user is';
+ − 1042
else $s = $n . ' users are';
+ − 1043
echo '<h3>'.$s . ' awaiting account activation</h3>';
+ − 1044
echo '<div class="tblholder">
+ − 1045
<table border="0" cellspacing="1" cellpadding="4" width="100%">
30
+ − 1046
<tr><th>Date of request</th><th>Requested by</th><th>Requested for</th><th>COPPA user</th><th colspan="3">Actions</th></tr>';
0
+ − 1047
$cls = 'row2';
+ − 1048
while($row = $db->fetchrow())
+ − 1049
{
+ − 1050
if($cls == 'row2') $cls = 'row1';
+ − 1051
else $cls = 'row2';
30
+ − 1052
$coppa = ( $row['user_coppa'] == '1' ) ? '<b>Yes</b>' : 'No';
+ − 1053
echo '<tr><td class="'.$cls.'">'.date('F d, Y h:i a', $row['time_id']).'</td><td class="'.$cls.'">'.$row['author'].'</td><td class="'.$cls.'">'.$row['edit_summary'].'</td><td style="text-align: center;" class="' . $cls . '">' . $coppa . '</td><td class="'.$cls.'" style="text-align: center;"><a href="'.makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'UserManager&action=activate&user='.$row['edit_summary'].'&logid='.$row['time_id']).'">Activate now</a></td><td class="'.$cls.'" style="text-align: center;"><a href="'.makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'UserManager&action=sendemail&user='.$row['edit_summary'].'&logid='.$row['time_id']).'">Send activation e-mail</a></td><td class="'.$cls.'" style="text-align: center;"><a href="'.makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'UserManager&action=deny&user='.$row['edit_summary'].'&logid='.$row['time_id']).'">Deny request</a></td></tr>';
0
+ − 1054
}
+ − 1055
echo '</table>';
+ − 1056
}
+ − 1057
$db->free_result();
+ − 1058
}
+ − 1059
}
+ − 1060
+ − 1061
function page_Admin_GroupManager()
+ − 1062
{
+ − 1063
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 1064
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 1065
{
+ − 1066
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 1067
return;
+ − 1068
}
+ − 1069
+ − 1070
if(isset($_POST['do_create_stage1']))
+ − 1071
{
+ − 1072
if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['create_group_name']))
+ − 1073
{
+ − 1074
echo '<p>The group name you chose is invalid.</p>';
+ − 1075
return;
+ − 1076
}
+ − 1077
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
+ − 1078
echo '<div class="tblholder">
+ − 1079
<table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
+ − 1080
<tr><th colspan="2">Creating group: '.$_POST['create_group_name'].'</th></tr>
+ − 1081
<tr>
+ − 1082
<td class="row1">Group moderator</td><td class="row1">' . $template->username_field('group_mod') . '</td>
+ − 1083
</tr>
+ − 1084
<tr><td class="row2">Group status</td><td class="row2">
+ − 1085
<label><input type="radio" name="group_status" value="'.GROUP_CLOSED.'" checked="checked" /> Closed to new members</label><br />
+ − 1086
<label><input type="radio" name="group_status" value="'.GROUP_REQUEST.'" /> Members can ask to be added</label><br />
+ − 1087
<label><input type="radio" name="group_status" value="'.GROUP_OPEN.'" /> Members can join freely</label><br />
+ − 1088
<label><input type="radio" name="group_status" value="'.GROUP_HIDDEN.'" /> Group is hidden</label>
+ − 1089
</td></tr>
+ − 1090
<tr>
+ − 1091
<th class="subhead" colspan="2">
+ − 1092
<input type="hidden" name="create_group_name" value="'.$_POST['create_group_name'].'" />
+ − 1093
<input type="submit" name="do_create_stage2" value="Create group" />
+ − 1094
</th>
+ − 1095
</tr>
+ − 1096
</table>
+ − 1097
</div>';
+ − 1098
echo '</form>';
+ − 1099
return;
+ − 1100
}
+ − 1101
elseif(isset($_POST['do_create_stage2']))
+ − 1102
{
+ − 1103
if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['create_group_name']))
+ − 1104
{
+ − 1105
echo '<p>The group name you chose is invalid.</p>';
+ − 1106
return;
+ − 1107
}
+ − 1108
if(!in_array(intval($_POST['group_status']), Array(GROUP_CLOSED, GROUP_OPEN, GROUP_HIDDEN, GROUP_REQUEST)))
+ − 1109
{
+ − 1110
echo '<p>Hacking attempt</p>';
+ − 1111
return;
+ − 1112
}
+ − 1113
$e = $db->sql_query('SELECT group_id FROM '.table_prefix.'groups WHERE group_name=\''.$db->escape($_POST['create_group_name']).'\';');
+ − 1114
if(!$e)
+ − 1115
{
+ − 1116
echo $db->get_error();
+ − 1117
return;
+ − 1118
}
+ − 1119
if($db->numrows() > 0)
+ − 1120
{
+ − 1121
echo '<p>The group name you entered already exists.</p>';
+ − 1122
return;
+ − 1123
}
+ − 1124
$db->free_result();
+ − 1125
$q = $db->sql_query('INSERT INTO '.table_prefix.'groups(group_name,group_type) VALUES( \''.$db->escape($_POST['create_group_name']).'\', ' . intval($_POST['group_status']) . ' )');
+ − 1126
if(!$q)
+ − 1127
{
+ − 1128
echo $db->get_error();
+ − 1129
return;
+ − 1130
}
+ − 1131
$e = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\''.$db->escape($_POST['group_mod']).'\';');
+ − 1132
if(!$e)
+ − 1133
{
+ − 1134
echo $db->get_error();
+ − 1135
return;
+ − 1136
}
+ − 1137
if($db->numrows() < 1)
+ − 1138
{
+ − 1139
echo '<p>The username you entered could not be found.</p>';
+ − 1140
return;
+ − 1141
}
+ − 1142
$row = $db->fetchrow();
+ − 1143
$id = $row['user_id'];
+ − 1144
$db->free_result();
+ − 1145
$e = $db->sql_query('SELECT group_id FROM '.table_prefix.'groups WHERE group_name=\''.$db->escape($_POST['create_group_name']).'\';');
+ − 1146
if(!$e)
+ − 1147
{
+ − 1148
echo $db->get_error();
+ − 1149
return;
+ − 1150
}
+ − 1151
if($db->numrows() < 1)
+ − 1152
{
+ − 1153
echo '<p>The group ID could not be looked up.</p>';
+ − 1154
return;
+ − 1155
}
+ − 1156
$row = $db->fetchrow();
+ − 1157
$gid = $row['group_id'];
+ − 1158
$db->free_result();
+ − 1159
$e = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES('.$gid.', '.$id.', 1);');
+ − 1160
if(!$e)
+ − 1161
{
+ − 1162
echo $db->get_error();
+ − 1163
return;
+ − 1164
}
+ − 1165
echo "<div class='info-box'>
+ − 1166
<b>Information</b><br />
+ − 1167
The group {$_POST['create_group_name']} has been created successfully.
+ − 1168
</div>";
+ − 1169
}
+ − 1170
if(isset($_POST['do_edit']) || isset($_POST['edit_do']))
+ − 1171
{
+ − 1172
// Fetch the group name
+ − 1173
$q = $db->sql_query('SELECT group_name,system_group FROM '.table_prefix.'groups WHERE group_id='.intval($_POST['group_edit_id']).';');
+ − 1174
if(!$q)
+ − 1175
{
+ − 1176
echo $db->get_error();
+ − 1177
return;
+ − 1178
}
+ − 1179
if($db->numrows() < 1)
+ − 1180
{
+ − 1181
echo '<p>Error: couldn\'t look up group name</p>';
+ − 1182
}
+ − 1183
$row = $db->fetchrow();
+ − 1184
$name = $row['group_name'];
+ − 1185
$db->free_result();
+ − 1186
if(isset($_POST['edit_do']))
+ − 1187
{
+ − 1188
if(isset($_POST['edit_do']['del_group']))
+ − 1189
{
+ − 1190
if ( $row['system_group'] == 1 )
+ − 1191
{
+ − 1192
echo '<div class="error-box">The group "' . $name . '" could not be deleted because it is a system group required for site functionality.</div>';
+ − 1193
}
+ − 1194
else
+ − 1195
{
+ − 1196
$q = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE group_id='.intval($_POST['group_edit_id']).';');
+ − 1197
if(!$q)
+ − 1198
{
+ − 1199
echo $db->get_error();
+ − 1200
return;
+ − 1201
}
+ − 1202
$q = $db->sql_query('DELETE FROM '.table_prefix.'groups WHERE group_id='.intval($_POST['group_edit_id']).';');
+ − 1203
if(!$q)
+ − 1204
{
+ − 1205
echo $db->get_error();
+ − 1206
return;
+ − 1207
}
+ − 1208
echo '<div class="info-box">The group "'.$name.'" has been deleted. Return to the <a href="javascript:ajaxPage(\'Admin:GroupManager\');">group manager</a>.</div>';
+ − 1209
return;
+ − 1210
}
+ − 1211
}
+ − 1212
if(isset($_POST['edit_do']['save_name']))
+ − 1213
{
+ − 1214
if(!preg_match('/^([A-z0-9 -]+)$/', $_POST['group_name']))
+ − 1215
{
+ − 1216
echo '<p>The group name you chose is invalid.</p>';
+ − 1217
return;
+ − 1218
}
+ − 1219
$q = $db->sql_query('UPDATE '.table_prefix.'groups SET group_name=\''.$db->escape($_POST['group_name']).'\'
+ − 1220
WHERE group_id='.intval($_POST['group_edit_id']).';');
+ − 1221
if(!$q)
+ − 1222
{
+ − 1223
echo $db->get_error();
+ − 1224
return;
+ − 1225
}
+ − 1226
else
+ − 1227
{
+ − 1228
echo '<div class="info-box" style="margin: 0 0 10px 0;"">
+ − 1229
The group name has been updated.
+ − 1230
</div>';
+ − 1231
}
+ − 1232
$name = $_POST['group_name'];
+ − 1233
+ − 1234
}
+ − 1235
$q = $db->sql_query('SELECT member_id FROM '.table_prefix.'group_members
+ − 1236
WHERE group_id='.intval($_POST['group_edit_id']).';');
+ − 1237
if(!$q)
+ − 1238
{
+ − 1239
echo $db->get_error();
+ − 1240
return;
+ − 1241
}
+ − 1242
if($db->numrows() > 0)
+ − 1243
{
+ − 1244
while($row = $db->fetchrow($q))
+ − 1245
{
+ − 1246
if(isset($_POST['edit_do']['del_' . $row['member_id']]))
+ − 1247
{
+ − 1248
$e = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE member_id='.$row['member_id']);
+ − 1249
if(!$e)
+ − 1250
{
+ − 1251
echo $db->get_error();
+ − 1252
return;
+ − 1253
}
+ − 1254
}
+ − 1255
}
+ − 1256
}
+ − 1257
$db->free_result();
+ − 1258
if(isset($_POST['edit_do']['add_member']))
+ − 1259
{
+ − 1260
$q = $db->sql_query('SELECT user_id FROM '.table_prefix.'users WHERE username=\''.$db->escape($_POST['edit_add_username']).'\';');
+ − 1261
if(!$q)
+ − 1262
{
+ − 1263
echo $db->get_error();
+ − 1264
return;
+ − 1265
}
+ − 1266
if($db->numrows() > 0)
+ − 1267
{
+ − 1268
$row = $db->fetchrow();
+ − 1269
$user_id = $row['user_id'];
+ − 1270
$is_mod = ( isset( $_POST['add_mod'] ) ) ? '1' : '0';
+ − 1271
$q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES('.intval($_POST['group_edit_id']).','.$user_id.','.$is_mod.');');
+ − 1272
if(!$q)
+ − 1273
{
+ − 1274
echo $db->get_error();
+ − 1275
return;
+ − 1276
}
+ − 1277
else
+ − 1278
{
+ − 1279
echo '<div class="info-box" style="margin: 0 0 10px 0;"">
+ − 1280
The user "'.$_POST['edit_add_username'].'" has been added to this usergroup.
+ − 1281
</div>';
+ − 1282
}
+ − 1283
}
+ − 1284
else
+ − 1285
echo '<div class="warning-box"><b>The user "'.$_POST['edit_add_username'].'" could not be added.</b><br />This username does not exist.</div>';
+ − 1286
}
+ − 1287
}
+ − 1288
$sg_disabled = ( $row['system_group'] == 1 ) ? ' value="Can\'t delete system group" disabled="disabled" style="color: #FF9773" ' : ' value="Delete this group" style="color: #FF3713" ';
+ − 1289
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
+ − 1290
echo '<div class="tblholder">
+ − 1291
<table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
+ − 1292
<tr><th>Edit group name</th></tr>
+ − 1293
<tr>
+ − 1294
<td class="row1">
+ − 1295
Group name: <input type="text" name="group_name" value="'.$name.'" />
+ − 1296
</td>
+ − 1297
</tr>
+ − 1298
<tr>
+ − 1299
<th class="subhead">
+ − 1300
<input type="submit" name="edit_do[save_name]" value="Save name" />
+ − 1301
<input type="submit" name="edit_do[del_group]" '.$sg_disabled.' />
+ − 1302
</th>
+ − 1303
</tr>
+ − 1304
</table>
+ − 1305
</div>
+ − 1306
<input type="hidden" name="group_edit_id" value="'.$_POST['group_edit_id'].'" />';
+ − 1307
echo '</form>';
+ − 1308
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
+ − 1309
echo '<div class="tblholder">
+ − 1310
<table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
+ − 1311
<tr><th colspan="3">Edit group members</th></tr>';
+ − 1312
$q = $db->sql_query('SELECT m.member_id,m.is_mod,u.username FROM '.table_prefix.'group_members AS m
+ − 1313
LEFT JOIN '.table_prefix.'users AS u
+ − 1314
ON u.user_id=m.user_id
+ − 1315
WHERE m.group_id='.intval($_POST['group_edit_id']).'
+ − 1316
ORDER BY m.is_mod DESC, u.username ASC;');
+ − 1317
if(!$q)
+ − 1318
{
+ − 1319
echo $db->get_error();
+ − 1320
return;
+ − 1321
}
+ − 1322
if($db->numrows() < 1)
+ − 1323
{
+ − 1324
echo '<tr><td colspan="3" class="row1">This group has no members.</td></tr>';
+ − 1325
}
+ − 1326
else
+ − 1327
{
+ − 1328
$cls = 'row2';
+ − 1329
while($row = $db->fetchrow())
+ − 1330
{
+ − 1331
$cls = ( $cls == 'row1' ) ? 'row2' : 'row1';
+ − 1332
$mod = ( $row['is_mod'] == 1 ) ? 'Mod' : '';
+ − 1333
echo '<tr>
+ − 1334
<td class="'.$cls.'" style="width: 100%;">
+ − 1335
' . $row['username'] . '
+ − 1336
</td>
+ − 1337
<td class="'.$cls.'">
+ − 1338
'.$mod.'
+ − 1339
</td>
+ − 1340
<td class="'.$cls.'">
+ − 1341
<input type="submit" name="edit_do[del_'.$row['member_id'].']" value="Remove member" />
+ − 1342
</td>
+ − 1343
</tr>';
+ − 1344
}
+ − 1345
}
+ − 1346
$db->free_result();
+ − 1347
echo '</table>
+ − 1348
</div>
+ − 1349
<input type="hidden" name="group_edit_id" value="'.$_POST['group_edit_id'].'" />';
+ − 1350
echo '</form>';
+ − 1351
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
+ − 1352
echo '<div class="tblholder">
+ − 1353
<table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
+ − 1354
<tr>
+ − 1355
<th>Add a new member</th>
+ − 1356
</tr>
+ − 1357
<tr>
+ − 1358
<td class="row1">
+ − 1359
Username: ' . $template->username_field('edit_add_username') . '
+ − 1360
</td>
+ − 1361
</tr>
+ − 1362
<tr>
+ − 1363
<td class="row2">
+ − 1364
<label><input type="checkbox" name="add_mod" /> Is a group moderator</label> (can add and delete other members)
+ − 1365
</td>
+ − 1366
</tr>
+ − 1367
<tr>
+ − 1368
<th class="subhead">
+ − 1369
<input type="submit" name="edit_do[add_member]" value="Add user to group" />
+ − 1370
</th>
+ − 1371
</tr>
+ − 1372
</table>
+ − 1373
</div>
+ − 1374
<input type="hidden" name="group_edit_id" value="'.$_POST['group_edit_id'].'" />';
+ − 1375
echo '</form>';
+ − 1376
return;
+ − 1377
}
+ − 1378
echo '<h3>Manage Usergroups</h3>';
+ − 1379
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
+ − 1380
$q = $db->sql_query('SELECT group_id,group_name FROM '.table_prefix.'groups ORDER BY group_name ASC;');
+ − 1381
if(!$q)
+ − 1382
{
+ − 1383
echo $db->get_error();
+ − 1384
}
+ − 1385
else
+ − 1386
{
+ − 1387
echo '<div class="tblholder">
+ − 1388
<table border="0" cellspacing="1" cellpadding="4" style="width: 100%;">
+ − 1389
<tr>
+ − 1390
<th>Edit an existing group</th>
+ − 1391
</tr>';
+ − 1392
echo '<tr><td class="row2"><select name="group_edit_id">';
+ − 1393
while ( $row = $db->fetchrow() )
+ − 1394
{
+ − 1395
if ( $row['group_name'] != 'Everyone' )
+ − 1396
{
+ − 1397
echo '<option value="' . $row['group_id'] . '">' . htmlspecialchars( $row['group_name'] ) . '</option>';
+ − 1398
}
+ − 1399
}
+ − 1400
$db->free_result();
+ − 1401
echo '</select></td></tr>';
+ − 1402
echo '<tr><td class="row1" style="text-align: center;"><input type="submit" name="do_edit" value="Edit group" /></td></tr>
+ − 1403
</table>
+ − 1404
</div>
+ − 1405
</form><br />';
+ − 1406
}
+ − 1407
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
+ − 1408
echo '<div class="tblholder">
+ − 1409
<table border="0" cellspacing="1" cellpadding="4" style="width: 100%;">
+ − 1410
<tr>
+ − 1411
<th colspan="2">Create a new group</th>
+ − 1412
</tr>';
+ − 1413
echo '<tr><td class="row2">Group name:</td><td class="row2"><input type="text" name="create_group_name" /></td></tr>';
+ − 1414
echo '<tr><td colspan="2" class="row1" style="text-align: center;"><input type="submit" name="do_create_stage1" value="Continue >" /></td></tr>
+ − 1415
</table>
+ − 1416
</div>';
+ − 1417
echo '</form>';
+ − 1418
}
+ − 1419
30
+ − 1420
function page_Admin_COPPA()
+ − 1421
{
+ − 1422
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 1423
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 1424
{
+ − 1425
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 1426
return;
+ − 1427
}
+ − 1428
+ − 1429
echo '<h2>Background information</h2>';
+ − 1430
echo '<p>
+ − 1431
The United States Childrens\' Online Privacy Protection Act (COPPA) was a law passed in 2001 that requires sites oriented towards
+ − 1432
children under 13 years old or with a significant amount of under-13 children clearly state what information is being collected
+ − 1433
in a privacy policy and obtain authorization from a parent or legal guardian before allowing children to use the site. Enano
+ − 1434
provides an easy way to allow you, as the website administrator, to obtain this authorization.
+ − 1435
</p>';
+ − 1436
+ − 1437
// Start form
+ − 1438
+ − 1439
if ( isset($_POST['coppa_address']) )
+ − 1440
{
+ − 1441
// Saving changes
+ − 1442
$enable_coppa = ( isset($_POST['enable_coppa']) ) ? '1' : '0';
+ − 1443
setConfig('enable_coppa', $enable_coppa);
+ − 1444
+ − 1445
$address = $_POST['coppa_address']; // RenderMan::preprocess_text($_POST['coppa_address'], true, false);
+ − 1446
setConfig('coppa_address', $address);
+ − 1447
+ − 1448
echo '<div class="info-box">Your changes have been saved.</div>';
+ − 1449
}
+ − 1450
+ − 1451
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', (( isset($_GET['sqldbg'])) ? 'sqldbg&' : '') .'module='.$paths->cpage['module']).'" method="post">';
+ − 1452
+ − 1453
echo '<div class="tblholder">';
+ − 1454
echo '<table border="0" cellspacing="1" cellpadding="4">';
+ − 1455
echo '<tr>
+ − 1456
<th colspan="2">
+ − 1457
COPPA support
+ − 1458
</th>
+ − 1459
</tr>';
+ − 1460
+ − 1461
echo '<tr>
+ − 1462
<td class="row1">
+ − 1463
Enable COPPA support:
+ − 1464
</td>
+ − 1465
<td class="row2">
+ − 1466
<label><input type="checkbox" name="enable_coppa" ' . ( ( getConfig('enable_coppa') == '1' ) ? 'checked="checked"' : '' ) . ' /> COPPA enabled</label><br />
+ − 1467
<small>If this is checked, users will be asked if they are under 13 years of age before registering</small>
+ − 1468
</td>
+ − 1469
</tr>';
+ − 1470
+ − 1471
echo '<tr>
+ − 1472
<td class="row1">
+ − 1473
Your mailing address:<br />
+ − 1474
<small>This is the address to which parents will send authorization forms.</small>
+ − 1475
</td>
+ − 1476
<td class="row2">
+ − 1477
<textarea name="coppa_address" rows="7" cols="40">' . getConfig('coppa_address') . '</textarea>
+ − 1478
</td>
+ − 1479
</tr>';
+ − 1480
+ − 1481
echo '<tr>
+ − 1482
<th colspan="2" class="subhead">
+ − 1483
<input type="submit" value="Save changes" />
+ − 1484
</th>
+ − 1485
</tr>';
+ − 1486
+ − 1487
echo '</table>';
+ − 1488
+ − 1489
echo '</form>';
+ − 1490
+ − 1491
}
+ − 1492
0
+ − 1493
function page_Admin_PageManager()
+ − 1494
{
+ − 1495
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 1496
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 1497
{
+ − 1498
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 1499
return;
+ − 1500
}
+ − 1501
+ − 1502
+ − 1503
echo '<h2>Page management</h2>';
+ − 1504
+ − 1505
if(isset($_POST['search']) || isset($_POST['select']) || ( isset($_GET['source']) && $_GET['source'] == 'ajax' )) {
+ − 1506
// The object of the game: using only the text a user entered, guess the page ID and namespace. *sigh* I HATE writing search algorithms...
+ − 1507
$source = ( isset($_GET['source']) ) ? $_GET['source'] : false;
+ − 1508
if ( $source == 'ajax' )
+ − 1509
{
+ − 1510
$_POST['search'] = true;
+ − 1511
$_POST['page_url'] = $_GET['page_id'];
+ − 1512
}
+ − 1513
if(isset($_POST['search'])) $pid = $_POST['page_url'];
+ − 1514
elseif(isset($_POST['select'])) $pid = $_POST['page_force_url'];
+ − 1515
else { echo 'Internal error selecting page search terms'; return false; }
+ − 1516
// Look for a namespace prefix in the urlname, and assign a different namespace, if necessary
+ − 1517
$k = array_keys($paths->nslist);
+ − 1518
for($i=0;$i<sizeof($paths->nslist);$i++)
+ − 1519
{
+ − 1520
$ln = strlen($paths->nslist[$k[$i]]);
+ − 1521
if(substr($pid, 0, $ln) == $paths->nslist[$k[$i]])
+ − 1522
{
+ − 1523
$ns = $k[$i];
+ − 1524
$page_id = substr($pid, $ln, strlen($pid));
+ − 1525
}
+ − 1526
}
+ − 1527
// The namespace is in $ns and the page name or ID (we don't know which yet) is in $page_id
+ − 1528
// Now, iterate through $paths->pages searching for a page with this name or ID
+ − 1529
for($i=0;$i<sizeof($paths->pages)/2;$i++)
+ − 1530
{
+ − 1531
if(!isset($final_pid))
+ − 1532
{
+ − 1533
if ($paths->pages[$i]['urlname_nons'] == str_replace(' ', '_', $page_id)) $final_pid = str_replace(' ', '_', $page_id);
+ − 1534
elseif($paths->pages[$i]['name'] == $page_id) $final_pid = $paths->pages[$i]['urlname_nons'];
+ − 1535
elseif(strtolower($paths->pages[$i]['urlname_nons']) == strtolower(str_replace(' ', '_', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons'];
+ − 1536
elseif(strtolower($paths->pages[$i]['name']) == strtolower(str_replace('_', ' ', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons'];
+ − 1537
if(isset($final_pid)) { $_POST['name'] = $paths->pages[$i]['name']; $_POST['urlname'] = $paths->pages[$i]['urlname_nons']; }
+ − 1538
}
+ − 1539
}
+ − 1540
if(!isset($final_pid)) { echo 'The page you searched for cannot be found. <a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'PageManager\'); return false;">Back</a>'; return false; }
+ − 1541
$_POST['namespace'] = $ns;
+ − 1542
$_POST['old_namespace'] = $ns;
+ − 1543
$_POST['page_id'] = $final_pid;
+ − 1544
$_POST['old_page_id'] = $final_pid;
+ − 1545
if(!isset($paths->pages[$paths->nslist[$_POST['namespace']].$_POST['urlname']])) { echo 'The page you searched for cannot be found. <a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'PageManager\'); return false;">Back</a>'; return false; }
+ − 1546
}
+ − 1547
+ − 1548
if(isset($_POST['page_id']) && isset($_POST['namespace']) && !isset($_POST['cancel']))
+ − 1549
{
40
+ − 1550
$cpage = $paths->pages[$paths->nslist[$_POST['old_namespace']].$_POST['old_page_id']];
0
+ − 1551
if(isset($_POST['submit']))
+ − 1552
{
22
+ − 1553
switch(true)
0
+ − 1554
{
22
+ − 1555
case true:
+ − 1556
// Create a list of things to update
+ − 1557
$page_info = Array(
+ − 1558
'name'=>$_POST['name'],
+ − 1559
'urlname'=>sanitize_page_id($_POST['page_id']),
+ − 1560
'namespace'=>$_POST['namespace'],
+ − 1561
'special'=>isset($_POST['special']) ? '1' : '0',
+ − 1562
'visible'=>isset($_POST['visible']) ? '1' : '0',
+ − 1563
'comments_on'=>isset($_POST['comments_on']) ? '1' : '0',
+ − 1564
'protected'=>isset($_POST['protected']) ? '1' : '0'
+ − 1565
);
+ − 1566
40
+ − 1567
$updating_urlname_or_namespace = ( $page_info['namespace'] != $cpage['namespace'] || $page_info['urlname'] != $cpage['urlname_nons'] );
22
+ − 1568
+ − 1569
if ( !isset($paths->nslist[ $page_info['namespace'] ]) )
+ − 1570
{
+ − 1571
echo '<div class="error-box">The namespace you selected is not properly registered.</div>';
+ − 1572
break;
+ − 1573
}
+ − 1574
if ( isset($paths->pages[ $paths->nslist[$page_info['namespace']] . $page_info[ 'urlname' ] ]) && $updating_urlname_or_namespace )
+ − 1575
{
+ − 1576
echo '<div class="error-box">There is already a page that exists with that URL string and namespace.</div>';
+ − 1577
break;
+ − 1578
}
+ − 1579
// Build the query
+ − 1580
$q = 'UPDATE '.table_prefix.'pages SET ';
+ − 1581
$k = array_keys($page_info);
+ − 1582
foreach($k as $c)
+ − 1583
{
+ − 1584
$q .= $c.'=\''.$db->escape($page_info[$c]).'\',';
+ − 1585
}
+ − 1586
$q = substr($q, 0, strlen($q)-1);
+ − 1587
// Build the WHERE statements
+ − 1588
$q .= ' WHERE ';
+ − 1589
$k = array_keys($cpage);
40
+ − 1590
if ( !isset($cpage) )
110
+ − 1591
die('[internal] no cpage');
22
+ − 1592
foreach($k as $c)
+ − 1593
{
+ − 1594
if($c != 'urlname_nons' && $c != 'urlname' && $c != 'really_protected')
+ − 1595
{
+ − 1596
$q .= $c.'=\''.$db->escape($cpage[$c]).'\' AND ';
+ − 1597
}
+ − 1598
else if($c == 'urlname')
+ − 1599
{
+ − 1600
$q .= $c.'=\''.$db->escape($cpage['urlname_nons']).'\' AND ';
+ − 1601
}
+ − 1602
}
+ − 1603
// Trim off the last " AND " and append a semicolon
+ − 1604
$q = substr($q, 0, strlen($q)-5) . ';';
+ − 1605
// Send the completed query to MySQL
+ − 1606
$e = $db->sql_query($q);
+ − 1607
if(!$e) $db->_die('The page data could not be updated.');
+ − 1608
// Update any additional tables
+ − 1609
$q = Array(
+ − 1610
'UPDATE '.table_prefix.'categories SET page_id=\''.$page_info['urlname'].'\',namespace=\''.$page_info['namespace'].'\' WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';',
+ − 1611
'UPDATE '.table_prefix.'comments SET page_id=\''.$page_info['urlname'].'\',namespace=\''.$page_info['namespace'].'\' WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';',
+ − 1612
'UPDATE '.table_prefix.'logs SET page_id=\''.$page_info['urlname'].'\',namespace=\''.$page_info['namespace'].'\' WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';',
+ − 1613
'UPDATE '.table_prefix.'page_text SET page_id=\''.$page_info['urlname'].'\',namespace=\''.$page_info['namespace'].'\' WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';',
72
bda11e521e8a
Fixed a few presentation bugs in installer, made installer more "legally binding", and fixed global permissions inheritance in $session->fetch_page_acl()
Dan
diff
changeset
+ − 1614
'UPDATE '.table_prefix.'acl SET page_id=\''.$page_info['urlname'].'\',namespace=\''.$page_info['namespace'].'\' WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';'
22
+ − 1615
);
+ − 1616
foreach($q as $cq)
+ − 1617
{
+ − 1618
$e = $db->sql_query($cq);
+ − 1619
if(!$e) $db->_die('Some of the additional tables containing page information could not be updated.');
+ − 1620
}
+ − 1621
// Update $cpage
+ − 1622
$cpage = $page_info;
+ − 1623
$cpage['urlname_nons'] = $cpage['urlname'];
+ − 1624
$cpage['urlname'] = $paths->nslist[$cpage['namespace']].$cpage['urlname'];
+ − 1625
$_POST['old_page_id'] = $page_info['urlname'];
+ − 1626
$_POST['old_namespace'] = $page_info['namespace'];
+ − 1627
echo '<div class="info-box">Your changes have been saved.</div>';
+ − 1628
break;
0
+ − 1629
}
+ − 1630
} elseif(isset($_POST['delete'])) {
+ − 1631
$q = Array(
+ − 1632
'DELETE FROM '.table_prefix.'categories WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';',
+ − 1633
'DELETE FROM '.table_prefix.'comments WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';',
+ − 1634
'DELETE FROM '.table_prefix.'logs WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';',
+ − 1635
'DELETE FROM '.table_prefix.'page_text WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';',
+ − 1636
);
+ − 1637
foreach($q as $cq)
+ − 1638
{
+ − 1639
$e = $db->sql_query($cq);
+ − 1640
if(!$e) $db->_die('Some of the additional tables containing page information could not be updated.');
+ − 1641
}
+ − 1642
+ − 1643
if(!$db->sql_query(
+ − 1644
'DELETE FROM '.table_prefix.'pages WHERE urlname="'.$db->escape($_POST['old_page_id']).'" AND namespace="'.$db->escape($_POST['old_namespace']).'";'
+ − 1645
)) $db->_die('The page could not be deleted.');
+ − 1646
echo '<div class="info-box">This page has been deleted.</p><p><a href="javascript:ajaxPage(\''.$paths->nslist['Admin'].'PageManager\');">Return to Page manager</a><br /><a href="javascript:ajaxPage(\''.$paths->nslist['Admin'].'Home\');">Admin home</a></div>';
+ − 1647
return;
+ − 1648
}
+ − 1649
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration'.htmlspecialchars(urlSeparator).(( isset($_GET['sqldbg']) ) ? 'sqldbg&' : '') .'module='.$paths->cpage['module']).'" method="post">';
+ − 1650
?>
89
+ − 1651
<h3>Modify page: <?php echo htmlspecialchars($_POST['name']); ?></h3>
0
+ − 1652
<table border="0">
+ − 1653
<tr><td>Namespace:</td><td><select name="namespace"><?php $nm = array_keys($paths->nslist); foreach($nm as $ns) { if($ns != 'Special' && $ns != 'Admin') { echo '<option '; if($_POST['namespace']==$ns) echo 'selected="selected" '; echo 'value="'.$ns.'">'; if($paths->nslist[$ns] == '') echo '[No prefix]'; else echo $paths->nslist[$ns]; echo '</option>'; } } ?></select></td></tr>
89
+ − 1654
<tr><td>Page title:</td><td><input type="text" name="name" value="<?php echo htmlspecialchars($cpage['name']); ?>" /></td></tr>
22
+ − 1655
<tr><td>Page URL string:<br /><small>No spaces, and don't enter the namespace prefix (e.g. User:).<br />Changing this value is usually not a good idea, especially for templates and project pages.</small></td><td><input type="text" name="page_id" value="<?php echo htmlspecialchars(dirtify_page_id($cpage['urlname_nons'])); ?>" /></td></tr>
0
+ − 1656
<tr><td></td><td><input <?php if($cpage['comments_on']) echo 'checked="checked"'; ?> name="comments_on" type="checkbox" id="cmt" /> <label for="cmt">Enable comments for this page</label></td></tr>
+ − 1657
<tr><td></td><td><input <?php if($cpage['special']) echo 'checked="checked"'; ?> name="special" type="checkbox" id="spc" /> <label for="spc">Bypass the template engine for this page</label><br /><small>This option enables you to use your own HTML headers and other code. It is recommended that only advanced users enable this feature. As with other Enano pages, you may use PHP code in your pages, meaning you can use Enano's API on the page.</small></td></tr>
+ − 1658
<tr><td></td><td><input <?php if($cpage['visible']) echo 'checked="checked"'; ?> name="visible" type="checkbox" id="vis" /> <label for="vis">Allow this page to be shown in page lists</label><br /><small>Unchecking this checkbox prevents the page for being indexed for searching. The index is rebuilt each time a page is saved, and you can force an index rebuild by going to the page <?php echo $paths->nslist['Special']; ?>SearchRebuild.</small></td></tr>
+ − 1659
<tr><td></td><td><input <?php if($cpage['protected']) echo 'checked="checked"'; ?> name="protected" type="checkbox" id="prt" /> <label for="prt">Prevent non-administrators from editing this page</label><br /><small>This option only has an effect when Wiki Mode is enabled.</small></td></tr>
+ − 1660
<tr><td></td><td><input type="submit" name="delete" value="Delete page" style="color: red" onclick="return confirm('Do you REALLY want to delete this page?')" /></td></tr>
+ − 1661
<tr><td colspan="2" style="text-align: center;"><hr /></td></tr>
+ − 1662
<tr><td colspan="2" style="text-align: right;">
+ − 1663
<input type="hidden" name="old_page_id" value="<?php echo $_POST['old_page_id']; ?>" />
+ − 1664
<input type="hidden" name="old_namespace" value="<?php echo $_POST['old_namespace']; ?>" />
+ − 1665
<input type="Submit" name="submit" value="Save changes" style="font-weight: bold;" /> <input type="submit" name="cancel" value="Cancel changes" /></td></tr>
+ − 1666
</table>
+ − 1667
<?php
+ − 1668
echo '</form>';
+ − 1669
} else {
+ − 1670
echo '<h3>Please select a page</h3>';
+ − 1671
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
+ − 1672
?>
+ − 1673
<p>Search for page title (remember prefixes like User: and File:) <?php echo $template->pagename_field('page_url'); ?> <input type="submit" style="font-weight: bold;" name="search" value="Search" /></p>
+ − 1674
<p>Select page title from a list: <select name="page_force_url">
+ − 1675
<?php
+ − 1676
for($i=0;$i<sizeof($paths->pages)/2;$i++)
+ − 1677
{
89
+ − 1678
if($paths->pages[$i]['namespace'] != 'Admin' && $paths->pages[$i]['namespace'] != 'Special') echo '<option value="'.$paths->nslist[$paths->pages[$i]['namespace']].$paths->pages[$i]['urlname_nons'].'">'.htmlspecialchars($paths->nslist[$paths->pages[$i]['namespace']].$paths->pages[$i]['name']).'</option>'."\n";
0
+ − 1679
}
+ − 1680
?>
+ − 1681
</select> <input type="submit" name="select" value="Select" /></p>
+ − 1682
<?php
+ − 1683
echo '</form>';
+ − 1684
+ − 1685
}
+ − 1686
}
+ − 1687
+ − 1688
function page_Admin_PageEditor()
+ − 1689
{
+ − 1690
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 1691
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 1692
{
+ − 1693
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 1694
return;
+ − 1695
}
+ − 1696
+ − 1697
+ − 1698
echo '<h2>Edit page content</h2>';
+ − 1699
+ − 1700
if(isset($_POST['search']) || isset($_POST['select'])) {
+ − 1701
// The object of the game: using only the text a user entered, guess the page ID and namespace. *sigh* I HATE writing search algorithms...
+ − 1702
if(isset($_POST['search'])) $pid = $_POST['page_url'];
+ − 1703
elseif(isset($_POST['select'])) $pid = $_POST['page_force_url'];
+ − 1704
else { echo 'Internal error selecting page search terms'; return false; }
+ − 1705
// Look for a namespace prefix in the urlname, and assign a different namespace, if necessary
+ − 1706
$k = array_keys($paths->nslist);
+ − 1707
for($i=0;$i<sizeof($paths->nslist);$i++)
+ − 1708
{
+ − 1709
$ln = strlen($paths->nslist[$k[$i]]);
+ − 1710
if(substr($pid, 0, $ln) == $paths->nslist[$k[$i]])
+ − 1711
{
+ − 1712
$ns = $k[$i];
+ − 1713
$page_id = substr($pid, $ln, strlen($pid));
+ − 1714
}
+ − 1715
}
+ − 1716
// The namespace is in $ns and the page name or ID (we don't know which yet) is in $page_id
+ − 1717
// Now, iterate through $paths->pages searching for a page with this name or ID
+ − 1718
for($i=0;$i<sizeof($paths->pages)/2;$i++)
+ − 1719
{
+ − 1720
if(!isset($final_pid))
+ − 1721
{
+ − 1722
if ($paths->pages[$i]['urlname_nons'] == str_replace(' ', '_', $page_id)) $final_pid = str_replace(' ', '_', $page_id);
+ − 1723
elseif($paths->pages[$i]['name'] == $page_id) $final_pid = $paths->pages[$i]['urlname_nons'];
+ − 1724
elseif(strtolower($paths->pages[$i]['urlname_nons']) == strtolower(str_replace(' ', '_', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons'];
+ − 1725
elseif(strtolower($paths->pages[$i]['name']) == strtolower(str_replace('_', ' ', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons'];
+ − 1726
if(isset($final_pid)) { $_POST['name'] = $paths->pages[$i]['name']; $_POST['urlname'] = $paths->pages[$i]['urlname_nons']; }
+ − 1727
}
+ − 1728
}
+ − 1729
if(!isset($final_pid)) { echo 'The page you searched for cannot be found. <a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'PageManager\'); return false;">Back</a>'; return false; }
+ − 1730
$_POST['namespace'] = $ns;
+ − 1731
$_POST['page_id'] = $final_pid;
+ − 1732
if(!isset($paths->pages[$paths->nslist[$_POST['namespace']].$_POST['urlname']])) { echo 'The page you searched for cannot be found. <a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'PageManager\'); return false;">Back</a>'; return false; }
+ − 1733
}
+ − 1734
+ − 1735
if(isset($_POST['page_id']) && !isset($_POST['cancel']))
+ − 1736
{
+ − 1737
echo '<form name="main" action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post">';
+ − 1738
if(!isset($_POST['content']) || isset($_POST['revert'])) $content = RenderMan::getPage($_POST['page_id'], $_POST['namespace'], 0, false, false, false, false);
+ − 1739
else $content = $_POST['content'];
+ − 1740
if(isset($_POST['save']))
+ − 1741
{
+ − 1742
$data = $content;
+ − 1743
$id = md5( microtime() . mt_rand() );
+ − 1744
+ − 1745
$minor = isset($_POST['minor']) ? 'true' : 'false';
+ − 1746
$q='INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,page_id,namespace,page_text,char_tag,author,edit_summary,minor_edit) VALUES(\'page\', \'edit\', '.time().', \''.date('d M Y h:i a').'\', \'' . $db->escape($_POST['page_id']) . '\', \'' . $db->escape($_POST['namespace']) . '\', \''.$data.'\', \''.$id.'\', \''.$session->username.'\', \''.$db->escape(htmlspecialchars($_POST['summary'])).'\', '.$minor.');';
+ − 1747
if(!$db->sql_query($q)) $db->_die('The history (log) entry could not be inserted into the logs table.');
+ − 1748
+ − 1749
$query = 'UPDATE '.table_prefix.'page_text SET page_text=\''.$db->escape($data).'\',char_tag=\''.$id.'\' WHERE page_id=\'' . $db->escape($_POST['page_id']) . '\' AND namespace=\'' . $db->escape($_POST['namespace']) . '\';';
+ − 1750
$e = $db->sql_query($query);
+ − 1751
if(!$e) echo '<div class="warning-box">The page data could not be saved. MySQL said: '.mysql_error().'<br /><br />Query:<br /><pre>'.$query.'</pre></div>';
+ − 1752
else echo '<div class="info-box">Your page has been saved. <a href="'.makeUrlNS($_POST['namespace'], $_POST['page_id']).'">View page...</a></div>';
+ − 1753
} elseif(isset($_POST['preview'])) {
+ − 1754
echo '<h3>Preview</h3><p><b>Reminder:</b> This is only a preview; your changes to this page have not yet been saved.</p><div style="margin: 1em; padding: 10px; border: 1px dashed #606060; background-color: #F8F8F8; max-height: 200px; overflow: auto;">'.RenderMan::render($content).'</div>';
+ − 1755
}
+ − 1756
?>
+ − 1757
<p>
+ − 1758
<textarea name="content" rows="20" cols="60" style="width: 100%;"><?php echo htmlspecialchars($content); ?></textarea><br />
+ − 1759
Edit summary: <input name="summary" value="<?php if(isset($_POST['summary'])) echo $_POST['summary']; ?>" size="40" /><br />
+ − 1760
<label><input type="checkbox" name="minor" <?php if(isset($_POST['minor'])) echo 'checked="checked" '; ?>/> This is a minor edit</label>
+ − 1761
</p>
+ − 1762
<p>
+ − 1763
<input type="hidden" name="page_id" value="<?php echo $_POST['page_id']; ?>" />
+ − 1764
<input type="hidden" name="namespace" value="<?php echo $_POST['namespace']; ?>" />
+ − 1765
<input type="submit" name="save" value="Save changes" style="font-weight: bold;" /> <input type="submit" name="preview" value="Show preview" /> <input type="submit" name="revert" value="Revert changes" onclick="return confirm('Do you really want to revert your changes?');" /> <input type="submit" name="cancel" value="Cancel" onclick="return confirm('Do you really want to cancel your changes?');" />
+ − 1766
</p>
+ − 1767
<?php
+ − 1768
echo '</form>';
+ − 1769
} else {
+ − 1770
echo '<h3>Please select a page</h3>';
+ − 1771
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
+ − 1772
?>
+ − 1773
<p>Search for page title (remember prefixes like User: and File:) <?php echo $template->pagename_field('page_url'); ?> <input type="submit" style="font-weight: bold;" name="search" value="Search" /></p>
+ − 1774
<p>Select page title from a list: <select name="page_force_url">
+ − 1775
<?php
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
+ − 1776
for ( $i = 0; $i < sizeof($paths->pages) / 2; $i++ )
0
+ − 1777
{
+ − 1778
if($paths->pages[$i]['namespace'] != 'Admin' && $paths->pages[$i]['namespace'] != 'Special') echo '<option value="'.$paths->nslist[$paths->pages[$i]['namespace']].$paths->pages[$i]['urlname_nons'].'">'.$paths->nslist[$paths->pages[$i]['namespace']].$paths->pages[$i]['name'].'</option>'."\n";
+ − 1779
}
+ − 1780
?>
+ − 1781
</select> <input type="submit" name="select" value="Select" /></p>
+ − 1782
<?php
+ − 1783
echo '</form>';
+ − 1784
}
+ − 1785
}
+ − 1786
+ − 1787
function page_Admin_ThemeManager()
+ − 1788
{
+ − 1789
+ − 1790
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 1791
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 1792
{
+ − 1793
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 1794
return;
+ − 1795
}
+ − 1796
+ − 1797
+ − 1798
// Get the list of styles in the themes/ dir
+ − 1799
$h = opendir('./themes');
+ − 1800
$l = Array();
+ − 1801
if(!$h) die('Error opening directory "./themes" for reading.');
+ − 1802
while(false !== ($n = readdir($h))) {
+ − 1803
if($n != '.' && $n != '..' && is_dir('./themes/'.$n))
+ − 1804
$l[] = $n;
+ − 1805
}
+ − 1806
closedir($h);
+ − 1807
echo('
+ − 1808
<h3>Theme Management</h3>
+ − 1809
<p>Install, uninstall, and manage Enano themes.</p>
+ − 1810
');
+ − 1811
if(isset($_POST['disenable'])) {
+ − 1812
$q = 'SELECT enabled FROM '.table_prefix.'themes WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\'';
+ − 1813
$s = $db->sql_query($q);
+ − 1814
if(!$s) die('Error selecting enabled/disabled state value: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1815
$r = $db->fetchrow_num($s);
+ − 1816
$db->free_result();
+ − 1817
if($r[0] == 1) $e = 0;
+ − 1818
else $e = 1;
+ − 1819
$s=true;
+ − 1820
if($e==0)
+ − 1821
{
+ − 1822
$c = $db->sql_query('SELECT * FROM '.table_prefix.'themes WHERE enabled=1');
+ − 1823
if(!$c) $db->_die('The backup check for having at least on theme enabled failed.');
+ − 1824
if($db->numrows() <= 1) { echo '<div class="warning-box">You cannot disable the last remaining theme.</div>'; $s=false; }
+ − 1825
}
+ − 1826
$db->free_result();
+ − 1827
if($s) {
+ − 1828
$q = 'UPDATE '.table_prefix.'themes SET enabled='.$e.' WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\'';
+ − 1829
$a = $db->sql_query($q);
+ − 1830
if(!$a) die('Error updating enabled/disabled state value: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1831
else echo('<div class="info-box">The theme "'.$_POST['theme_id'].'" has been '. ( ( $e == '1' ) ? 'enabled' : 'disabled' ).'.</div>');
+ − 1832
}
+ − 1833
}
+ − 1834
elseif(isset($_POST['edit'])) {
+ − 1835
+ − 1836
$dir = './themes/'.$_POST['theme_id'].'/css/';
+ − 1837
$list = Array();
+ − 1838
// Open a known directory, and proceed to read its contents
+ − 1839
if (is_dir($dir)) {
+ − 1840
if ($dh = opendir($dir)) {
+ − 1841
while (($file = readdir($dh)) !== false) {
+ − 1842
if(preg_match('#^(.*?)\.css$#is', $file) && $file != '_printable.css') {
+ − 1843
$list[$file] = capitalize_first_letter(substr($file, 0, strlen($file)-4));
+ − 1844
}
+ − 1845
}
+ − 1846
closedir($dh);
+ − 1847
}
+ − 1848
}
+ − 1849
$lk = array_keys($list);
+ − 1850
+ − 1851
$q = 'SELECT theme_name,default_style FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\'';
+ − 1852
$s = $db->sql_query($q);
+ − 1853
if(!$s) die('Error selecting name value: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1854
$r = $db->fetchrow_num($s);
+ − 1855
$db->free_result();
+ − 1856
echo('<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post">');
+ − 1857
echo('<div class="question-box">
+ − 1858
Theme name displayed to users: <input type="text" name="name" value="'.$r[0].'" /><br /><br />
+ − 1859
Default stylesheet: <select name="defaultcss">');
+ − 1860
foreach ($lk as $l)
+ − 1861
{
+ − 1862
if($r[1] == $l) $v = ' selected="selected"';
+ − 1863
else $v = '';
+ − 1864
echo "<option value='{$l}'$v>{$list[$l]}</option>";
+ − 1865
}
+ − 1866
echo('</select><br /><br />
+ − 1867
<input type="submit" name="editsave" value="OK" /><input type="hidden" name="theme_id" value="'.$_POST['theme_id'].'" />
+ − 1868
</div>');
+ − 1869
echo('</form>');
+ − 1870
}
+ − 1871
elseif(isset($_POST['editsave'])) {
+ − 1872
$q = 'UPDATE '.table_prefix.'themes SET theme_name=\'' . $db->escape($_POST['name']) . '\',default_style=\''.$db->escape($_POST['defaultcss']).'\' WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\'';
+ − 1873
$s = $db->sql_query($q);
+ − 1874
if(!$s) die('Error updating name value: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1875
else echo('<div class="info-box">Theme data updated.</div>');
+ − 1876
}
+ − 1877
elseif(isset($_POST['up'])) {
+ − 1878
// If there is only one theme or if the selected theme is already at the top, do nothing
+ − 1879
$q = 'SELECT theme_order FROM '.table_prefix.'themes ORDER BY theme_order;';
+ − 1880
$s = $db->sql_query($q);
+ − 1881
if(!$s) die('Error selecting order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1882
$q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\'';
+ − 1883
$sn = $db->sql_query($q);
+ − 1884
if(!$sn) die('Error selecting order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1885
$r = $db->fetchrow_num($sn);
+ − 1886
if( /* check for only one theme... */ $db->numrows($s) < 2 || $r[0] == 1 /* ...and check if this theme is already at the top */ ) { echo('<div class="warning-box">This theme is already at the top of the list, or there is only one theme installed.</div>'); } else {
+ − 1887
// Get the order IDs of the selected theme and the theme before it
+ − 1888
$q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\'';
+ − 1889
$s = $db->sql_query($q);
+ − 1890
if(!$s) die('Error selecting order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1891
$r = $db->fetchrow_num($s);
+ − 1892
$r = $r[0];
+ − 1893
$rb = $r - 1;
+ − 1894
// Thank God for jEdit's rectangular selection and the ablity to edit multiple lines at the same time ;)
+ − 1895
$q = 'UPDATE '.table_prefix.'themes SET theme_order=0 WHERE theme_order='.$rb.''; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1896
$q = 'UPDATE '.table_prefix.'themes SET theme_order='.$rb.' WHERE theme_order='.$r.''; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1897
$q = 'UPDATE '.table_prefix.'themes SET theme_order='.$r.' WHERE theme_order=0'; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1898
echo('<div class="info-box">Theme moved up.</div>');
+ − 1899
}
+ − 1900
$db->free_result($s);
+ − 1901
$db->free_result($sn);
+ − 1902
}
+ − 1903
elseif(isset($_POST['down'])) {
+ − 1904
// If there is only one theme or if the selected theme is already at the top, do nothing
+ − 1905
$q = 'SELECT theme_order FROM '.table_prefix.'themes ORDER BY theme_order;';
+ − 1906
$s = $db->sql_query($q);
+ − 1907
if(!$s) die('Error selecting order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1908
$r = $db->fetchrow_num($s);
+ − 1909
if( /* check for only one theme... */ $db->numrows($s) < 2 || $r[0] == $db->numrows($s) /* ...and check if this theme is already at the bottom */ ) { echo('<div class="warning-box">This theme is already at the bottom of the list, or there is only one theme installed.</div>'); } else {
+ − 1910
// Get the order IDs of the selected theme and the theme before it
+ − 1911
$q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\'';
+ − 1912
$s = $db->sql_query($q);
+ − 1913
if(!$s) die('Error selecting order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1914
$r = $db->fetchrow_num($s);
+ − 1915
$r = $r[0];
+ − 1916
$rb = $r + 1;
+ − 1917
// Thank God for jEdit's rectangular selection and the ablity to edit multiple lines at the same time ;)
+ − 1918
$q = 'UPDATE '.table_prefix.'themes SET theme_order=0 WHERE theme_order='.$rb.''; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1919
$q = 'UPDATE '.table_prefix.'themes SET theme_order='.$rb.' WHERE theme_order='.$r.''; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1920
$q = 'UPDATE '.table_prefix.'themes SET theme_order='.$r.' WHERE theme_order=0'; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1921
echo('<div class="info-box">Theme moved down.</div>');
+ − 1922
}
+ − 1923
}
+ − 1924
else if(isset($_POST['uninstall']))
+ − 1925
{
+ − 1926
$q = 'SELECT * FROM '.table_prefix.'themes;';
+ − 1927
$s = $db->sql_query($q);
+ − 1928
if ( !$s )
+ − 1929
{
+ − 1930
die('Error getting theme count: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1931
}
+ − 1932
$n = $db->numrows($s);
+ − 1933
$db->free_result();
+ − 1934
+ − 1935
if ( $_POST['theme_id'] == 'oxygen' )
+ − 1936
{
+ − 1937
echo '<div class="error-box">The Oxygen theme is used by Enano for installation, upgrades, and error messages, and cannot be uninstalled.</div>';
+ − 1938
}
+ − 1939
else
+ − 1940
{
+ − 1941
if($n < 2)
+ − 1942
{
+ − 1943
echo '<div class="error-box">The theme could not be uninstalled because it is the only theme left.</div>';
+ − 1944
}
+ − 1945
else
+ − 1946
{
+ − 1947
$q = 'DELETE FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\' LIMIT 1;';
+ − 1948
$s = $db->sql_query($q);
+ − 1949
if ( !$s )
+ − 1950
{
+ − 1951
die('Error deleting theme data: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1952
}
+ − 1953
else
+ − 1954
{
+ − 1955
echo('<div class="info-box">Theme uninstalled.</div>');
+ − 1956
}
+ − 1957
}
+ − 1958
}
+ − 1959
}
+ − 1960
elseif(isset($_POST['install'])) {
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1961
$q = 'SELECT theme_id FROM '.table_prefix.'themes;';
0
+ − 1962
$s = $db->sql_query($q);
+ − 1963
if(!$s) die('Error getting theme count: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
+ − 1964
$n = $db->numrows($s);
+ − 1965
$n++;
+ − 1966
$theme_id = $_POST['theme_id'];
+ − 1967
$theme = Array();
+ − 1968
include('./themes/'.$theme_id.'/theme.cfg');
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1969
if ( !isset($theme['theme_id']) )
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1970
{
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1971
echo '<div class="error-box">Could not load theme.cfg (theme metadata file)</div>';
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1972
}
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1973
else
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1974
{
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1975
$default_style = false;
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1976
if ( $dh = opendir('./themes/' . $theme_id . '/css') )
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1977
{
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1978
while ( $file = readdir($dh) )
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1979
{
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1980
if ( $file != '_printable.css' && preg_match('/\.css$/i', $file) )
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1981
{
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1982
$default_style = $file;
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1983
break;
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1984
}
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1985
}
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1986
closedir($dh);
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1987
}
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1988
else
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1989
{
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1990
die('The /css subdirectory could not be located in the theme\'s directory');
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1991
}
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1992
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1993
if ( $default_style )
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1994
{
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1995
$q = 'INSERT INTO '.table_prefix.'themes(theme_id,theme_name,theme_order,enabled,default_style) VALUES(\''.$db->escape($theme['theme_id']).'\', \''.$db->escape($theme['theme_name']).'\', '.$n.', 1, \'' . $db->escape($default_style) . '\')';
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1996
$s = $db->sql_query($q);
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1997
if(!$s) die('Error inserting theme data: '.mysql_error().'<br /><u>SQL:</u><br />'.$q);
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1998
else echo('<div class="info-box">Theme "'.$theme['theme_name'].'" installed.</div>');
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 1999
}
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 2000
else
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 2001
{
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 2002
echo '<div class="error-box">Could not determine the default style for the theme.</div>';
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 2003
}
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
diff
changeset
+ − 2004
}
0
+ − 2005
}
+ − 2006
echo('
+ − 2007
<h3>Currently installed themes</h3>
+ − 2008
<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post">
+ − 2009
<p>
+ − 2010
<select name="theme_id">
+ − 2011
');
+ − 2012
$q = 'SELECT theme_id,theme_name,enabled FROM '.table_prefix.'themes ORDER BY theme_order';
+ − 2013
$s = $db->sql_query($q);
+ − 2014
if(!$s) die('Error selecting theme data: '.mysql_error().'<br /><u>Attempted SQL:</u><br />'.$q);
+ − 2015
while ( $r = $db->fetchrow_num($s) ) {
+ − 2016
if($r[2] < 1) $r[1] .= ' (disabled)';
+ − 2017
echo('<option value="'.$r[0].'">'.$r[1].'</option>');
+ − 2018
}
+ − 2019
$db->free_result();
+ − 2020
echo('
+ − 2021
</select> <input type="submit" name="disenable" value="Enable/Disable" /> <input type="submit" name="edit" value="Change settings" /> <input type="submit" name="up" value="Move up" /> <input type="submit" name="down" value="Move down" /> <input type="submit" name="uninstall" value="Uninstall" style="color: #DD3300; font-weight: bold;" />
+ − 2022
</p>
+ − 2023
</form>
+ − 2024
<h3>Install a new theme</h3>
+ − 2025
');
+ − 2026
$theme = Array();
+ − 2027
$obb = '';
+ − 2028
for($i=0;$i<sizeof($l);$i++) {
+ − 2029
if(is_file('./themes/'.$l[$i].'/theme.cfg') && file_exists('./themes/'.$l[$i].'/theme.cfg')) {
+ − 2030
include('./themes/'.$l[$i].'/theme.cfg');
+ − 2031
$q = 'SELECT * FROM '.table_prefix.'themes WHERE theme_id=\''.$theme['theme_id'].'\'';
+ − 2032
$s = $db->sql_query($q);
+ − 2033
if(!$s) die('Error selecting list of currently installed themes: '.mysql_error().'<br /><u>Attempted SQL:</u><br />'.$q);
+ − 2034
if($db->numrows($s) < 1) {
+ − 2035
$obb .= '<option value="'.$theme['theme_id'].'">'.$theme['theme_name'].'</option>';
+ − 2036
}
+ − 2037
$db->free_result();
+ − 2038
}
+ − 2039
}
+ − 2040
if($obb != '') {
+ − 2041
echo('<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post"><p>');
+ − 2042
echo('<select name="theme_id">');
+ − 2043
echo($obb);
+ − 2044
echo('</select>');
+ − 2045
echo('
+ − 2046
<input type="submit" name="install" value="Install this theme" />
+ − 2047
</p></form>');
+ − 2048
} else echo('<p>All themes are currently installed.</p>');
+ − 2049
}
+ − 2050
+ − 2051
function page_Admin_BanControl()
+ − 2052
{
+ − 2053
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 2054
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 2055
{
+ − 2056
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 2057
return;
+ − 2058
}
+ − 2059
+ − 2060
if(isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['id']) && $_GET['id'] != '')
+ − 2061
{
+ − 2062
$e = $db->sql_query('DELETE FROM '.table_prefix.'banlist WHERE ban_id=' . $db->escape($_GET['id']) . '');
+ − 2063
if(!$e) $db->_die('The ban list entry was not deleted.');
+ − 2064
}
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2065
if(isset($_POST['create']) && !defined('ENANO_DEMO_MODE'))
0
+ − 2066
{
+ − 2067
$q = 'INSERT INTO '.table_prefix.'banlist(ban_type,ban_value,reason,is_regex) VALUES( ' . $db->escape($_POST['type']) . ', \'' . $db->escape($_POST['value']) . '\', \''.$db->escape($_POST['reason']).'\'';
+ − 2068
if(isset($_POST['regex'])) $q .= ', 1';
+ − 2069
else $q .= ', 0';
+ − 2070
$q .= ');';
+ − 2071
$e = $db->sql_query($q);
+ − 2072
if(!$e) $db->_die('The banlist could not be updated.');
+ − 2073
}
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2074
else if ( isset($_POST['create']) && defined('ENANO_DEMO_MODE') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2075
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2076
echo '<div class="error-box">This function is disabled in the demo. Just because <i>you</i> don\'t like ' . htmlspecialchars($_POST['value']) . ' doesn\'t mean <i>we</i> don\'t like ' . htmlspecialchars($_POST['value']) . '.</div>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2077
}
0
+ − 2078
$q = $db->sql_query('SELECT ban_id,ban_type,ban_value,is_regex FROM '.table_prefix.'banlist ORDER BY ban_type;');
+ − 2079
if(!$q) $db->_die('The banlist data could not be selected.');
+ − 2080
echo '<table border="0" cellspacing="1" cellpadding="4">';
+ − 2081
echo '<tr><th>Type</th><th>Value</th><th>Regular Expression</th><th></th></tr>';
+ − 2082
if($db->numrows() < 1) echo '<td colspan="4">No ban rules yet.</td>';
+ − 2083
while($r = $db->fetchrow())
+ − 2084
{
+ − 2085
if($r['ban_type']==BAN_IP) $t = 'IP address';
+ − 2086
elseif($r['ban_type']==BAN_USER) $t = 'Username';
+ − 2087
elseif($r['ban_type']==BAN_EMAIL) $t = 'E-mail address';
+ − 2088
if($r['is_regex']) $g = 'Yes'; else $g = 'No';
+ − 2089
echo '<tr><td>'.$t.'</td><td>'.$r['ban_value'].'</td><td>'.$g.'</td><td><a href="'.makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'BanControl&action=delete&id='.$r['ban_id']).'">Delete</a></td></tr>';
+ − 2090
}
+ − 2091
$db->free_result();
+ − 2092
echo '</table>';
+ − 2093
echo '<h3>Create new ban rule</h3>';
+ − 2094
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post">';
+ − 2095
?>
+ − 2096
Type: <select name="type"><option value="<?php echo BAN_IP; ?>">IP address</option><option value="<?php echo BAN_USER; ?>">Username</option><option value="<?php echo BAN_EMAIL; ?>">E-mail address</option></select><br />
+ − 2097
Rule: <input type="text" name="value" size="30" /><br />
+ − 2098
Reason to show to the banned user: <textarea name="reason" rows="7" cols="20"></textarea><br />
+ − 2099
<input type="checkbox" name="regex" id="regex" /> <label for="regex">This rule is a regular expression</label> (advanced users only)<br />
+ − 2100
<input type="submit" style="font-weight: bold;" name="create" value="Create new ban rule" />
+ − 2101
<?php
+ − 2102
echo '</form>';
+ − 2103
}
+ − 2104
+ − 2105
function page_Admin_MassEmail()
+ − 2106
{
+ − 2107
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 2108
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 2109
{
+ − 2110
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 2111
return;
+ − 2112
}
+ − 2113
+ − 2114
global $enano_config;
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2115
if ( isset($_POST['do_send']) && !defined('ENANO_DEMO_MODE') )
0
+ − 2116
{
+ − 2117
$use_smtp = getConfig('smtp_enabled') == '1';
+ − 2118
+ − 2119
//
+ − 2120
// Let's do some checking to make sure that mass mail functions
+ − 2121
// are working in win32 versions of php. (copied from phpBB)
+ − 2122
//
+ − 2123
if ( preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$use_smtp)
+ − 2124
{
+ − 2125
$ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';
+ − 2126
+ − 2127
// We are running on windows, force delivery to use our smtp functions
+ − 2128
// since php's are broken by default
+ − 2129
$use_smtp = true;
+ − 2130
$enano_config['smtp_server'] = @$ini_val('SMTP');
+ − 2131
}
+ − 2132
+ − 2133
$mail = new emailer( !empty($use_smtp) );
+ − 2134
+ − 2135
// Validate subject/message body
+ − 2136
$subject = stripslashes(trim($_POST['subject']));
+ − 2137
$message = stripslashes(trim($_POST['message']));
+ − 2138
+ − 2139
if ( empty($subject) )
+ − 2140
$errors[] = 'Please enter a subject.';
+ − 2141
if ( empty($message) )
+ − 2142
$errors[] = 'Please enter a message.';
+ − 2143
+ − 2144
// Get list of members
+ − 2145
if ( !empty($_POST['userlist']) )
+ − 2146
{
+ − 2147
$userlist = str_replace(', ', ',', $_POST['userlist']);
+ − 2148
$userlist = explode(',', $userlist);
+ − 2149
foreach ( $userlist as $k => $u )
+ − 2150
{
+ − 2151
if ( $u == $session->username )
+ − 2152
{
+ − 2153
// Message is automatically sent to the sender
+ − 2154
unset($userlist[$k]);
+ − 2155
}
+ − 2156
else
+ − 2157
{
+ − 2158
$userlist[$k] = $db->escape($u);
+ − 2159
}
+ − 2160
}
+ − 2161
$userlist = 'WHERE username=\'' . implode('\' OR username=\'', $userlist) . '\'';
+ − 2162
+ − 2163
$q = $db->sql_query('SELECT email FROM '.table_prefix.'users ' . $userlist . ';');
+ − 2164
if ( !$q )
+ − 2165
$db->_die();
+ − 2166
+ − 2167
if ( $row = $db->fetchrow() )
+ − 2168
{
+ − 2169
do {
+ − 2170
$mail->cc($row['email']);
+ − 2171
} while ( $row = $db->fetchrow() );
+ − 2172
}
+ − 2173
+ − 2174
$db->free_result();
+ − 2175
+ − 2176
}
+ − 2177
else
+ − 2178
{
+ − 2179
// Sending to a usergroup
+ − 2180
+ − 2181
$group_id = intval($_POST['group_id']);
+ − 2182
if ( $group_id < 1 )
+ − 2183
{
+ − 2184
$errors[] = 'Invalid group ID';
+ − 2185
}
+ − 2186
else
+ − 2187
{
+ − 2188
$q = $db->sql_query('SELECT u.email FROM '.table_prefix.'group_members AS g
+ − 2189
LEFT JOIN '.table_prefix.'users AS u
+ − 2190
ON (u.user_id=g.user_id)
+ − 2191
WHERE g.group_id=' . $group_id . ';');
+ − 2192
if ( !$q )
+ − 2193
$db->_die();
+ − 2194
+ − 2195
if ( $row = $db->fetchrow() )
+ − 2196
{
+ − 2197
do {
+ − 2198
$mail->cc($row['email']);
+ − 2199
} while ( $row = $db->fetchrow() );
+ − 2200
}
+ − 2201
+ − 2202
$db->free_result();
+ − 2203
}
+ − 2204
}
+ − 2205
+ − 2206
if ( sizeof($errors) < 1 )
+ − 2207
{
+ − 2208
+ − 2209
$mail->from(getConfig('contact_email'));
+ − 2210
$mail->replyto(getConfig('contact_email'));
+ − 2211
$mail->set_subject($subject);
+ − 2212
$mail->email_address(getConfig('contact_email'));
+ − 2213
+ − 2214
// Copied/modified from phpBB
+ − 2215
$email_headers = 'X-AntiAbuse: Website server name - ' . $_SERVER['SERVER_NAME'] . "\n";
+ − 2216
$email_headers .= 'X-AntiAbuse: User_id - ' . $session->user_id . "\n";
+ − 2217
$email_headers .= 'X-AntiAbuse: Username - ' . $session->username . "\n";
+ − 2218
$email_headers .= 'X-AntiAbuse: User IP - ' . $_SERVER['REMOTE_ADDR'] . "\n";
+ − 2219
+ − 2220
$mail->extra_headers($email_headers);
+ − 2221
+ − 2222
$tpl = 'The following message was mass-mailed by {SENDER}, one of the administrators from {SITE_NAME}. If this message contains spam or any comments which you find abusive or offensive, please contact the administration team at:
+ − 2223
+ − 2224
{CONTACT_EMAIL}
+ − 2225
+ − 2226
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ − 2227
{MESSAGE}
+ − 2228
';
+ − 2229
+ − 2230
$mail->use_template($tpl);
+ − 2231
+ − 2232
$mail->assign_vars(array(
+ − 2233
'SENDER' => $session->username,
+ − 2234
'SITE_NAME' => getConfig('site_name'),
+ − 2235
'CONTACT_EMAIL' => getConfig('contact_email'),
+ − 2236
'MESSAGE' => $message
+ − 2237
));
+ − 2238
+ − 2239
//echo '<pre>'.print_r($mail,true).'</pre>';
+ − 2240
+ − 2241
// All done
+ − 2242
$mail->send();
+ − 2243
$mail->reset();
+ − 2244
+ − 2245
echo '<div class="info-box">Your message has been sent.</div>';
+ − 2246
+ − 2247
}
+ − 2248
else
+ − 2249
{
+ − 2250
echo '<div class="warning-box">Could not send message for the following reason(s):<ul><li>' . implode('</li><li>', $errors) . '</li></ul></div>';
+ − 2251
}
+ − 2252
+ − 2253
}
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2254
else if ( isset($_POST['do_send']) && defined('ENANO_DEMO_MODE') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2255
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2256
echo '<div class="error-box">This function is disabled in the demo. You think demo@enanocms.org likes getting "test" mass e-mails?</div>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2257
}
0
+ − 2258
echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post">';
+ − 2259
?>
+ − 2260
<div class="tblholder">
+ − 2261
<table border="0" cellspacing="1" cellpadding="4">
+ − 2262
<tr>
+ − 2263
<th colspan="2">Send mass e-mail</th>
+ − 2264
</tr>
+ − 2265
<tr>
+ − 2266
<td class="row2" rowspan="2" style="width: 30%; min-width: 200px;">
+ − 2267
Send message to:<br />
+ − 2268
<small>
+ − 2269
By default, this message will be sent to the group selected here. You may instead send the message to a specific
+ − 2270
list of users by entering them in the second row, with usernames separated by a single comma (no space).
+ − 2271
</small>
+ − 2272
</td>
+ − 2273
<td class="row1">
+ − 2274
<select name="group_id">
+ − 2275
<?php
+ − 2276
$q = $db->sql_query('SELECT group_name,group_id FROM '.table_prefix.'groups ORDER BY group_name ASC;');
+ − 2277
if ( !$q )
+ − 2278
$db->_die();
+ − 2279
while ( $row = $db->fetchrow() )
+ − 2280
{
+ − 2281
echo '<option value="' . $row['group_id'] . '">' . $row['group_name'] . '</option>';
+ − 2282
}
+ − 2283
?>
+ − 2284
</select>
+ − 2285
</td>
+ − 2286
</tr>
+ − 2287
<tr>
+ − 2288
<td class="row1">
+ − 2289
Usernames: <input type="text" name="userlist" size="50" />
+ − 2290
</td>
+ − 2291
</tr>
+ − 2292
<tr>
+ − 2293
<td class="row2" style="width: 30%; min-width: 200px;">
+ − 2294
Subject:
+ − 2295
</td>
+ − 2296
<td class="row1">
+ − 2297
<input name="subject" type="text" size="50" />
+ − 2298
</td>
+ − 2299
</tr>
+ − 2300
<tr>
+ − 2301
<td class="row2" style="width: 30%; min-width: 200px;">
+ − 2302
Message:
+ − 2303
</td>
+ − 2304
<td class="row1">
+ − 2305
<textarea name="message" rows="30" cols="60" style="width: 100%;"></textarea>
+ − 2306
</td>
+ − 2307
</tr>
+ − 2308
<tr>
+ − 2309
<th class="subhead" colspan="2" style="text-align: left;" valign="middle">
+ − 2310
<div style="float: right;"><input type="submit" name="do_send" value="Send message" /></div>
+ − 2311
<small style="font-weight: normal;">Please be warned: it may take a LONG time to send this message. <b>Please do not stop the script until the process is finished.</b></small>
+ − 2312
</th>
+ − 2313
</tr>
+ − 2314
+ − 2315
</table>
+ − 2316
</div>
+ − 2317
<?php
+ − 2318
echo '</form>';
+ − 2319
}
+ − 2320
+ − 2321
function page_Admin_DBBackup()
+ − 2322
{
+ − 2323
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 2324
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 2325
{
+ − 2326
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 2327
return;
+ − 2328
}
+ − 2329
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2330
if(isset($_GET['submitting']) && $_GET['submitting'] == 'yes' && defined('ENANO_DEMO_MODE') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2331
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2332
redirect(makeUrlComplete('Special', 'Administration'), 'Access denied', 'You\'ve got to be kidding me. Forget it, kid.', 4 );
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2333
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2334
0
+ − 2335
global $system_table_list;
+ − 2336
if(isset($_GET['submitting']) && $_GET['submitting'] == 'yes')
+ − 2337
{
+ − 2338
+ − 2339
if(defined('SQL_BACKUP_CRYPT'))
+ − 2340
// Try to increase our time limit
+ − 2341
@set_time_limit(300); // five minutes
+ − 2342
// Do the actual export
+ − 2343
$aesext = ( defined('SQL_BACKUP_CRYPT') ) ? '.tea' : '';
103
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
diff
changeset
+ − 2344
$filename = 'enano_backup_' . date('ymd') . '.sql' . $aesext;
0
+ − 2345
ob_start();
+ − 2346
header('Content-disposition: attachment, filename="'.$filename.'";');
+ − 2347
header('Content-type: application/transact-sql');
+ − 2348
// Spew some headers
+ − 2349
$headdate = date('F d, Y \a\t h:i a');
+ − 2350
echo <<<HEADER
+ − 2351
-- Enano CMS SQL backup
+ − 2352
-- Generated on {$headdate} by {$session->username}
+ − 2353
+ − 2354
HEADER;
+ − 2355
// build the table list
+ − 2356
$base = ( isset($_POST['do_system_tables']) ) ? $system_table_list : Array();
+ − 2357
$add = ( isset($_POST['additional_tables'])) ? $_POST['additional_tables'] : Array();
+ − 2358
$tables = array_merge($base, $add);
+ − 2359
+ − 2360
// Log it!
+ − 2361
$e = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'db_backup\', '.time().', \''.date('d M Y h:i a').'\', \''.$db->escape($session->username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', \'' . $db->escape(implode(', ', $tables)) . '\')');
+ − 2362
if ( !$e )
+ − 2363
$db->_die();
+ − 2364
+ − 2365
foreach($tables as $i => $t)
+ − 2366
{
+ − 2367
if(!preg_match('#^([a-z0-9_]+)$#i', $t))
+ − 2368
die('Hacking attempt');
+ − 2369
// if($t == table_prefix.'files' && isset($_POST['do_data']))
+ − 2370
// unset($tables[$i]);
+ − 2371
}
+ − 2372
foreach($tables as $t)
+ − 2373
{
103
a8891e108c95
Several major improvements: Memberlist page added (planned since about beta 2), page group support added for non-JS ACL editor (oops!), and attempting to view a page for which you lack read permissions will get you logged.
Dan
diff
changeset
+ − 2374
// THE FOLLOWING COMMENT DOES NOT APPLY AS OF 1.0.
0
+ − 2375
// Sorry folks - this script CAN'T backup enano_files, enano_search_index, and enano_search_cache due to the sheer size of the tables.
+ − 2376
// If encryption is enabled the log data will be excluded too.
+ − 2377
echo export_table(
+ − 2378
$t,
+ − 2379
isset($_POST['do_struct']),
+ − 2380
( isset($_POST['do_data']) /* && $t != table_prefix.'files' && $t != table_prefix.'search_index' && $t != table_prefix.'search_cache' && ( !defined('SQL_BACKUP_CRYPT') || ( defined('SQL_BACKUP_CRYPT') && $t != table_prefix.'logs' ) ) */ ),
+ − 2381
false
+ − 2382
) . "\n";
+ − 2383
}
+ − 2384
$data = ob_get_contents();
+ − 2385
ob_end_clean();
+ − 2386
if(defined('SQL_BACKUP_CRYPT'))
+ − 2387
{
+ − 2388
// Free some memory, we don't need this stuff any more
+ − 2389
$db->close();
+ − 2390
unset($paths, $db, $template, $plugins);
+ − 2391
$tea = new TEACrypt();
+ − 2392
$data = $tea->encrypt($data, $session->private_key);
+ − 2393
}
+ − 2394
header('Content-length: '.strlen($data));
+ − 2395
echo $data;
+ − 2396
exit;
+ − 2397
}
+ − 2398
else
+ − 2399
{
+ − 2400
// Show the UI
+ − 2401
echo '<form action="'.makeUrlNS('Admin', 'DBBackup', 'submitting=yes', true).'" method="post" enctype="multipart/form-data">';
+ − 2402
?>
+ − 2403
<p>This page allows you to back up your Enano database should something go miserably wrong.</p>
+ − 2404
<p><label><input type="checkbox" name="do_system_tables" checked="checked" /> Export tables that are part of the Enano core</label><p>
+ − 2405
<p>Additional tables to export:</p>
+ − 2406
<p><select name="additional_tables[]" multiple="multiple">
+ − 2407
<?php
+ − 2408
$q = $db->sql_query('SHOW TABLES;') or $db->_die('Somehow we were denied the request to get the list of tables.');
+ − 2409
while($row = $db->fetchrow_num())
+ − 2410
{
+ − 2411
if(!in_array($row[0], $system_table_list)) echo '<option value="'.$row[0].'">'.$row[0].'</option>';
+ − 2412
}
+ − 2413
?>
+ − 2414
</select>
+ − 2415
</p>
+ − 2416
<p><label><input type="checkbox" name="do_struct" checked="checked" /> Include table structure</label><br />
+ − 2417
<label><input type="checkbox" name="do_data" checked="checked" /> Include table data</label>
+ − 2418
</p>
+ − 2419
<p><input type="submit" value="Create backup" /></p>
+ − 2420
<?php
+ − 2421
echo '</form>';
+ − 2422
}
+ − 2423
}
+ − 2424
+ − 2425
function page_Admin_AdminLogout()
+ − 2426
{
+ − 2427
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 2428
if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ − 2429
{
+ − 2430
echo '<h3>Error: Not authenticated</h3><p>It looks like your administration session is invalid or you are not authorized to access this administration page. Please <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true) . '">re-authenticate</a> to continue.</p>';
+ − 2431
return;
+ − 2432
}
+ − 2433
+ − 2434
$session->logout(USER_LEVEL_ADMIN);
+ − 2435
echo '<h3>You have now been logged out of the administration panel.</h3><p>You will continue to be logged into the website, but you will need to re-authenticate before you can access the administration panel again.</p><p>Return to the <a href="'.makeUrl(getConfig('main_page')).'">Main Page</a>.</p>';
+ − 2436
}
+ − 2437
+ − 2438
function page_Special_Administration()
+ − 2439
{
+ − 2440
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 2441
+ − 2442
if($session->auth_level < USER_LEVEL_ADMIN) {
+ − 2443
redirect(makeUrlNS('Special', 'Login/'.$paths->page, 'level='.USER_LEVEL_ADMIN), 'Not authorized', 'You need an authorization level of '.USER_LEVEL_ADMIN.' to use this page, your auth level is: ' . $session->auth_level, 0);
+ − 2444
exit;
+ − 2445
}
+ − 2446
else
+ − 2447
{
+ − 2448
$template->load_theme('admin', 'default');
+ − 2449
$template->init_vars();
+ − 2450
if( !isset( $_GET['noheaders'] ) )
+ − 2451
{
+ − 2452
$template->header();
+ − 2453
}
+ − 2454
echo 'Administer your Enano website.';
+ − 2455
?>
+ − 2456
<script type="text/javascript">
+ − 2457
function ajaxPage(t)
+ − 2458
{
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2459
if ( KILL_SWITCH )
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2460
{
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2461
document.getElementById('ajaxPageContainer').innerHTML = '<div class="error-box">Because of the lack of AJAX support, support for Internet Explorer versions less than 6.0 has been disabled in Runt. You can download and use Mozilla Firefox (or Seamonkey under Windows 95); both have an up-to-date standards-compliant rendering engine that has been tested thoroughly with Enano.</div>';
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2462
return false;
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2463
}
0
+ − 2464
if ( t == namespace_list.Admin + 'AdminLogout' )
+ − 2465
{
+ − 2466
var mb = new messagebox(MB_YESNO|MB_ICONQUESTION, 'Are you sure you want to de-authenticate?', 'If you de-authenticate, you will no longer be able to use the administration panel until you re-authenticate again. You may do so at any time using the Administration button on the sidebar.');
+ − 2467
mb.onclick['Yes'] = function() {
+ − 2468
var tigraentry = document.getElementById('i_div0_0').parentNode;
+ − 2469
var tigraobj = $(tigraentry);
+ − 2470
var div = document.createElement('div');
+ − 2471
div.style.backgroundColor = '#FFFFFF';
+ − 2472
domObjChangeOpac(70, div);
+ − 2473
div.style.position = 'absolute';
+ − 2474
var top = tigraobj.Top();
+ − 2475
var left = tigraobj.Left();
+ − 2476
var width = tigraobj.Width();
+ − 2477
var height = tigraobj.Height();
+ − 2478
div.style.top = top + 'px';
+ − 2479
div.style.left = left + 'px';
+ − 2480
div.style.width = width + 'px';
+ − 2481
div.style.height = height + 'px';
+ − 2482
var body = document.getElementsByTagName('body')[0];
+ − 2483
enlighten(true);
+ − 2484
body.appendChild(div);
+ − 2485
ajaxPageBin(namespace_list.Admin + 'AdminLogout');
+ − 2486
}
+ − 2487
return;
+ − 2488
}
+ − 2489
ajaxPageBin(t);
+ − 2490
}
+ − 2491
function ajaxPageBin(t)
+ − 2492
{
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2493
if ( KILL_SWITCH )
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2494
{
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2495
document.getElementById('ajaxPageContainer').innerHTML = '<div class="error-box">Because of the lack of AJAX support, support for Internet Explorer versions less than 6.0 has been disabled in Runt. You can download and use Mozilla Firefox (or Seamonkey under Windows 95); both have an up-to-date standards-compliant rendering engine that has been tested thoroughly with Enano.</div>';
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2496
return false;
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2497
}
0
+ − 2498
document.getElementById('ajaxPageContainer').innerHTML = '<div class="wait-box">Loading page...</div>';
+ − 2499
ajaxGet('<?php echo scriptPath; ?>/ajax.php?title='+t+'&_mode=getpage&noheaders&auth=<?php echo $session->sid_super; ?>', function() {
+ − 2500
if(ajax.readyState == 4) {
+ − 2501
document.getElementById('ajaxPageContainer').innerHTML = ajax.responseText;
+ − 2502
fadeInfoBoxes();
+ − 2503
}
+ − 2504
});
+ − 2505
}
+ − 2506
function _enanoAdminOnload() { ajaxPage('<?php echo $paths->nslist['Admin']; ?>Home'); }
+ − 2507
var TREE_TPL = {
+ − 2508
'target' : '_self', // name of the frame links will be opened in
+ − 2509
// other possible values are: _blank, _parent, _search, _self and _top
+ − 2510
+ − 2511
'icon_e' : '<?php echo scriptPath; ?>/images/icons/empty.gif', // empty image
+ − 2512
'icon_l' : '<?php echo scriptPath; ?>/images/icons/line.gif', // vertical line
+ − 2513
'icon_32' : '<?php echo scriptPath; ?>/images/icons/base.gif', // root leaf icon normal
+ − 2514
'icon_36' : '<?php echo scriptPath; ?>/images/icons/base.gif', // root leaf icon selected
+ − 2515
'icon_48' : '<?php echo scriptPath; ?>/images/icons/base.gif', // root icon normal
+ − 2516
'icon_52' : '<?php echo scriptPath; ?>/images/icons/base.gif', // root icon selected
+ − 2517
'icon_56' : '<?php echo scriptPath; ?>/images/icons/base.gif', // root icon opened
+ − 2518
'icon_60' : '<?php echo scriptPath; ?>/images/icons/base.gif', // root icon selected
+ − 2519
'icon_16' : '<?php echo scriptPath; ?>/images/icons/folder.gif', // node icon normal
+ − 2520
'icon_20' : '<?php echo scriptPath; ?>/images/icons/folderopen.gif', // node icon selected
+ − 2521
'icon_24' : '<?php echo scriptPath; ?>/images/icons/folder.gif', // node icon opened
+ − 2522
'icon_28' : '<?php echo scriptPath; ?>/images/icons/folderopen.gif', // node icon selected opened
+ − 2523
'icon_0' : '<?php echo scriptPath; ?>/images/icons/page.gif', // leaf icon normal
+ − 2524
'icon_4' : '<?php echo scriptPath; ?>/images/icons/page.gif', // leaf icon selected
+ − 2525
'icon_8' : '<?php echo scriptPath; ?>/images/icons/page.gif', // leaf icon opened
+ − 2526
'icon_12' : '<?php echo scriptPath; ?>/images/icons/page.gif', // leaf icon selected
+ − 2527
'icon_2' : '<?php echo scriptPath; ?>/images/icons/joinbottom.gif', // junction for leaf
+ − 2528
'icon_3' : '<?php echo scriptPath; ?>/images/icons/join.gif', // junction for last leaf
+ − 2529
'icon_18' : '<?php echo scriptPath; ?>/images/icons/plusbottom.gif', // junction for closed node
+ − 2530
'icon_19' : '<?php echo scriptPath; ?>/images/icons/plus.gif', // junction for last closed node
+ − 2531
'icon_26' : '<?php echo scriptPath; ?>/images/icons/minusbottom.gif',// junction for opened node
+ − 2532
'icon_27' : '<?php echo scriptPath; ?>/images/icons/minus.gif' // junction for last opended node
+ − 2533
};
123
+ − 2534
addOnloadHook(keepalive_onload);
0
+ − 2535
<?php
+ − 2536
echo $paths->parseAdminTree(); // Make a Javascript array that defines the tree
+ − 2537
if(!isset($_GET['module'])) { echo 'addOnloadHook(_enanoAdminOnload);'; } ?>
+ − 2538
</script>
+ − 2539
<table border="0" width="100%">
+ − 2540
<tr>
+ − 2541
<td class="holder" valign="top">
+ − 2542
<div class="pad" style="padding-right: 20px;">
+ − 2543
<script type="text/javascript">
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2544
if ( !KILL_SWITCH )
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2545
{
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2546
new tree(TREE_ITEMS, TREE_TPL);
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2547
}
0
+ − 2548
</script>
+ − 2549
</div>
+ − 2550
</td>
+ − 2551
<td width="100%" valign="top">
+ − 2552
<div class="pad" id="ajaxPageContainer">
+ − 2553
<?php
+ − 2554
if(isset($_GET['module']))
+ − 2555
{
+ − 2556
// Look for a namespace prefix in the urlname, and assign a different namespace, if necessary
+ − 2557
$k = array_keys($paths->nslist);
+ − 2558
for ( $i = 0; $i < sizeof($paths->nslist); $i++ )
+ − 2559
{
+ − 2560
$ln = strlen( $paths->nslist[ $k[ $i ] ] );
+ − 2561
if ( substr($_GET['module'], 0, $ln) == $paths->nslist[$k[$i]] )
+ − 2562
{
+ − 2563
$ns = $k[$i];
+ − 2564
$nm = substr($_GET['module'], $ln, strlen($_GET['module']));
+ − 2565
}
+ − 2566
}
+ − 2567
$fname = 'page_'.$ns.'_'.$nm;
+ − 2568
$s = strpos($fname, '?noheaders');
+ − 2569
if($s) $fname = substr($fname, 0, $s);
+ − 2570
$paths->cpage['module'] = $_GET['module'];
+ − 2571
if ( function_exists($fname) && $_GET['module'] != $paths->nslist['Special'] . 'Administration' )
+ − 2572
{
+ − 2573
eval($fname.'();');
+ − 2574
}
+ − 2575
}
+ − 2576
else
+ − 2577
{
+ − 2578
echo '<div class="wait-box">Please wait while the administration panel loads. You need to be using a recent browser with AJAX support in order to use Runt.</div>';
+ − 2579
}
+ − 2580
?>
+ − 2581
</div>
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2582
<script type="text/javascript">
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2583
if ( KILL_SWITCH )
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2584
{
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2585
document.getElementById('ajaxPageContainer').innerHTML = '<div class="error-box">Because of the lack of AJAX support, support for Internet Explorer versions less than 6.0 has been disabled in Runt. You can download and use Mozilla Firefox (or Seamonkey under Windows 95); both have an up-to-date standards-compliant rendering engine that has been tested thoroughly with Enano.</div>';
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2586
}
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
diff
changeset
+ − 2587
</script>
0
+ − 2588
</td>
+ − 2589
</tr>
+ − 2590
</table>
+ − 2591
+ − 2592
<?php
+ − 2593
}
+ − 2594
if(!isset($_GET['noheaders']))
+ − 2595
{
+ − 2596
$template->footer();
+ − 2597
}
+ − 2598
}
+ − 2599
+ − 2600
function page_Special_EditSidebar()
+ − 2601
{
+ − 2602
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 2603
+ − 2604
if($session->auth_level < USER_LEVEL_ADMIN)
+ − 2605
{
+ − 2606
redirect(makeUrlNS('Special', 'Login/'.$paths->page, 'level='.USER_LEVEL_ADMIN), '', '', false);
+ − 2607
exit;
+ − 2608
}
+ − 2609
else
+ − 2610
{
+ − 2611
+ − 2612
$template->add_header('<script type="text/javascript" src="'.scriptPath.'/includes/clientside/dbx.js"></script>');
+ − 2613
$template->add_header('<script type="text/javascript" src="'.scriptPath.'/includes/clientside/dbx-key.js"></script>');
+ − 2614
$template->add_header('<script type="text/javascript" src="'.scriptPath.'/includes/clientside/sbedit.js"></script>');
+ − 2615
$template->add_header('<link rel="stylesheet" type="text/css" href="'.scriptPath.'/includes/clientside/dbx.css" />');
+ − 2616
+ − 2617
// Knock the sidebars dead to keep javascript in plugins from interfering
+ − 2618
$template->tpl_strings['SIDEBAR_LEFT'] = '';
+ − 2619
$template->tpl_strings['SIDEBAR_RIGHT'] = '';
+ − 2620
+ − 2621
$template->load_theme('oxygen', 'bleu');
+ − 2622
$template->init_vars();
+ − 2623
+ − 2624
$template->header();
+ − 2625
+ − 2626
if(isset($_POST['save']))
+ − 2627
{
+ − 2628
// Write the new block order to the database
+ − 2629
// The only way to do this is with tons of queries (one per block + one select query at the start to count everything) but afaik its safe...
+ − 2630
// Anyone know a better way to do this?
+ − 2631
$q = $db->sql_query('SELECT item_order,item_id,sidebar_id FROM '.table_prefix.'sidebar ORDER BY sidebar_id ASC, item_order ASC;');
+ − 2632
if ( !$q )
+ − 2633
{
+ − 2634
$db->_die('The sidebar order data could not be selected.');
+ − 2635
}
+ − 2636
$orders = Array();
+ − 2637
while($row = $db->fetchrow())
+ − 2638
{
+ − 2639
$orders[] = Array(
+ − 2640
count($orders),
+ − 2641
$row['item_id'],
+ − 2642
$row['sidebar_id'],
+ − 2643
);
+ − 2644
}
+ − 2645
$db->free_result();
+ − 2646
+ − 2647
// We now have an array with each sidebar ID in its respective order. Explode the order string in $_POST['order_(left|right)'] and use it to build a set of queries.
+ − 2648
$ol = explode(',', $_POST['order_left']);
+ − 2649
$odr = explode(',', $_POST['order_right']);
+ − 2650
$om = array_merge($ol, $odr);
+ − 2651
unset($ol, $odr);
+ − 2652
$queries = Array();
+ − 2653
foreach($orders as $k => $v)
+ − 2654
{
+ − 2655
$queries[] = 'UPDATE '.table_prefix.'sidebar SET item_order='.$om[$k].' WHERE item_id='.$v[1].';';
+ − 2656
}
+ − 2657
foreach($queries as $sql)
+ − 2658
{
+ − 2659
$q = $db->sql_query($sql);
+ − 2660
if(!$q)
+ − 2661
{
+ − 2662
$t = $db->get_error();
+ − 2663
echo $t;
+ − 2664
$template->footer();
+ − 2665
exit;
+ − 2666
}
+ − 2667
}
+ − 2668
echo '<div class="info-box" style="margin: 10px 0;">The sidebar order information was updated successfully.</div>';
+ − 2669
}
+ − 2670
elseif(isset($_POST['create']))
+ − 2671
{
+ − 2672
switch((int)$_POST['type'])
+ − 2673
{
+ − 2674
case BLOCK_WIKIFORMAT:
+ − 2675
$content = $_POST['wikiformat_content'];
+ − 2676
break;
+ − 2677
case BLOCK_TEMPLATEFORMAT:
+ − 2678
$content = $_POST['templateformat_content'];
+ − 2679
break;
+ − 2680
case BLOCK_HTML:
+ − 2681
$content = $_POST['html_content'];
+ − 2682
break;
+ − 2683
case BLOCK_PHP:
+ − 2684
$content = $_POST['php_content'];
+ − 2685
break;
+ − 2686
case BLOCK_PLUGIN:
+ − 2687
$content = $_POST['plugin_id'];
+ − 2688
break;
+ − 2689
}
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2690
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2691
if ( defined('ENANO_DEMO_MODE') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2692
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2693
// Sanitize the HTML
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2694
$content = sanitize_html($content, true);
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2695
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2696
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2697
if ( defined('ENANO_DEMO_MODE') && intval($_POST['type']) == BLOCK_PHP )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2698
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2699
echo '<div class="error-box" style="margin: 10px 0 10px 0;">Adding PHP code blocks in the Enano administration demo has been disabled for security reasons.</div>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2700
$_POST['php_content'] = '?><Nulled>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2701
$content = $_POST['php_content'];
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2702
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2703
0
+ − 2704
// Get the value of item_order
+ − 2705
+ − 2706
$q = $db->sql_query('SELECT * FROM '.table_prefix.'sidebar WHERE sidebar_id='.$db->escape($_POST['sidebar_id']).';');
+ − 2707
if(!$q) $db->_die('The order number could not be selected');
+ − 2708
$io = $db->numrows();
+ − 2709
+ − 2710
$db->free_result();
+ − 2711
+ − 2712
$q = 'INSERT INTO '.table_prefix.'sidebar(block_name, block_type, sidebar_id, block_content, item_order) VALUES ( \''.$db->escape($_POST['title']).'\', \''.$db->escape($_POST['type']).'\', \''.$db->escape($_POST['sidebar_id']).'\', \''.$db->escape($content).'\', '.$io.' );';
+ − 2713
$result = $db->sql_query($q);
+ − 2714
if(!$result)
+ − 2715
{
+ − 2716
echo $db->get_error();
+ − 2717
$template->footer();
+ − 2718
exit;
+ − 2719
}
+ − 2720
+ − 2721
echo '<div class="info-box" style="margin: 10px 0;">The item was added.</div>';
+ − 2722
+ − 2723
}
+ − 2724
+ − 2725
if(isset($_GET['action']) && isset($_GET['id']))
+ − 2726
{
+ − 2727
if(preg_match('#^([0-9]*)$#', $_GET['id']))
+ − 2728
{
+ − 2729
} else {
+ − 2730
echo '<div class="warning-box">Error with action: $_GET["id"] was not an integer, aborting to prevent SQL injection</div>';
+ − 2731
}
+ − 2732
switch($_GET['action'])
+ − 2733
{
+ − 2734
case 'new':
+ − 2735
?>
+ − 2736
<script type="text/javascript">
+ − 2737
function setType(input)
+ − 2738
{
+ − 2739
val = input.value;
+ − 2740
if(!val)
+ − 2741
{
+ − 2742
return false;
+ − 2743
}
+ − 2744
var divs = getElementsByClassName(document, 'div', 'sbadd_block');
+ − 2745
for(var i in divs)
+ − 2746
{
+ − 2747
if(divs[i].id == 'blocktype_'+val) divs[i].style.display = 'block';
+ − 2748
else divs[i].style.display = 'none';
+ − 2749
}
+ − 2750
}
+ − 2751
</script>
+ − 2752
+ − 2753
<form action="<?php echo makeUrl($paths->page); ?>" method="post">
+ − 2754
+ − 2755
<p>
+ − 2756
What type of block should this be?
+ − 2757
</p>
+ − 2758
<p>
+ − 2759
<select name="type" onchange="setType(this)"> <?php /* (NOT WORKING, at least in firefox 2) onload="var thingy = this; setTimeout('setType(thingy)', 500);" */ ?>
+ − 2760
<option value="<?php echo BLOCK_WIKIFORMAT; ?>">Wiki-formatted block</option>
+ − 2761
<option value="<?php echo BLOCK_TEMPLATEFORMAT; ?>">Template-formatted block (old pre-beta 3 behavior)</option>
+ − 2762
<option value="<?php echo BLOCK_HTML; ?>">Raw HTML block</option>
+ − 2763
<option value="<?php echo BLOCK_PHP; ?>">PHP code block (danger, Will Robinson!)</option>
+ − 2764
<option value="<?php echo BLOCK_PLUGIN; ?>">Use code from a plugin</option>
+ − 2765
</select>
+ − 2766
</p>
+ − 2767
+ − 2768
<p>
+ − 2769
+ − 2770
Block title: <input name="title" type="text" size="40" /><br />
+ − 2771
Which sidebar: <select name="sidebar_id"><option value="<?php echo SIDEBAR_LEFT; ?>">Left</option><option value="<?php echo SIDEBAR_RIGHT; ?>">Right</option></select>
+ − 2772
+ − 2773
</p>
+ − 2774
+ − 2775
<div class="sbadd_block" id="blocktype_<?php echo BLOCK_WIKIFORMAT; ?>">
+ − 2776
<p>
+ − 2777
Wikitext:
+ − 2778
</p>
+ − 2779
<p>
+ − 2780
<textarea style="width: 98%;" name="wikiformat_content" rows="15" cols="50"></textarea>
+ − 2781
</p>
+ − 2782
</div>
+ − 2783
+ − 2784
<div class="sbadd_block" id="blocktype_<?php echo BLOCK_TEMPLATEFORMAT; ?>">
+ − 2785
<p>
+ − 2786
Template code:
+ − 2787
</p>
+ − 2788
<p>
+ − 2789
<textarea style="width: 98%;" name="templateformat_content" rows="15" cols="50"></textarea>
+ − 2790
</p>
+ − 2791
</div>
+ − 2792
+ − 2793
<div class="sbadd_block" id="blocktype_<?php echo BLOCK_HTML; ?>">
+ − 2794
<p>
+ − 2795
HTML to place inside the sidebar:
+ − 2796
</p>
+ − 2797
<p>
+ − 2798
<textarea style="width: 98%;" name="html_content" rows="15" cols="50"></textarea>
+ − 2799
</p>
+ − 2800
</div>
+ − 2801
+ − 2802
<div class="sbadd_block" id="blocktype_<?php echo BLOCK_PHP; ?>">
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2803
<?php if ( defined('ENANO_DEMO_MODE') ) { ?>
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2804
<p>Creating PHP blocks in demo mode is disabled for security reasons.</p>
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2805
<?php } else { ?>
0
+ − 2806
<p>
+ − 2807
<b>WARNING:</b> If you don't know what you're doing, or if you are not fluent in PHP, stop now and choose a different block type. You will brick your Enano installation if you are not careful here.
+ − 2808
ALWAYS remember to write secure code! The Enano team is not responsible if someone drops all your tables because of an SQL injection vulnerability in your sidebar code. You are probably better off using the template-formatted block type.
+ − 2809
</p>
+ − 2810
<p>
+ − 2811
<span style="color: red;">
+ − 2812
It is especially important to note that this code is NOT checked for errors! If there is a syntax error in your code here, it will prevent any pages from loading AT ALL. So you need to use an external PHP editor (like <a href="http://www.jedit.org">jEdit</a>) to check your syntax before you hit save.
+ − 2813
</span> You have been warned.
+ − 2814
</p>
+ − 2815
<p>
+ − 2816
Also, you should avoid using output buffering functions (ob_[start|end|get_contents|clean]) here, because Enano uses those to track output from this script.
+ − 2817
</p>
+ − 2818
<p>
+ − 2819
The standard <?php and ?> tags work here. Don't use an initial "<?php" or it will cause a parse error.
+ − 2820
</p>
+ − 2821
<p>
+ − 2822
PHP code:
+ − 2823
</p>
+ − 2824
<p>
+ − 2825
<textarea style="width: 98%;" name="php_content" rows="15" cols="50"></textarea>
+ − 2826
</p>
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2827
<?php } ?>
0
+ − 2828
</div>
+ − 2829
+ − 2830
<div class="sbadd_block" id="blocktype_<?php echo BLOCK_PLUGIN; ?>">
+ − 2831
<p>
+ − 2832
Plugin:
+ − 2833
</p>
+ − 2834
<p>
+ − 2835
<select name="plugin_id">
+ − 2836
<?php
+ − 2837
foreach($template->plugin_blocks as $k => $c)
+ − 2838
{
+ − 2839
echo '<option value="'.$k.'">'.$k.'</option>';
+ − 2840
}
+ − 2841
?>
+ − 2842
</select>
+ − 2843
</p>
+ − 2844
</div>
+ − 2845
+ − 2846
<p>
+ − 2847
+ − 2848
<input type="submit" name="create" value="Create new block" style="font-weight: bold;" />
+ − 2849
<input type="submit" name="cancel" value="Cancel" />
+ − 2850
+ − 2851
</p>
+ − 2852
+ − 2853
</form>
+ − 2854
+ − 2855
<script type="text/javascript">
+ − 2856
var divs = getElementsByClassName(document, 'div', 'sbadd_block');
+ − 2857
for(var i in divs)
+ − 2858
{
+ − 2859
if(divs[i].id != 'blocktype_<?php echo BLOCK_WIKIFORMAT; ?>') setTimeout("document.getElementById('"+divs[i].id+"').style.display = 'none';", 500);
+ − 2860
}
+ − 2861
</script>
+ − 2862
+ − 2863
<?php
+ − 2864
$template->footer();
+ − 2865
return;
+ − 2866
break;
+ − 2867
case 'move':
+ − 2868
if( !isset($_GET['side']) || ( isset($_GET['side']) && !preg_match('#^([0-9]+)$#', $_GET['side']) ) )
+ − 2869
{
+ − 2870
echo '<div class="warning-box" style="margin: 10px 0;">$_GET[\'side\'] contained an SQL injection attempt</div>';
+ − 2871
break;
+ − 2872
}
+ − 2873
$query = $db->sql_query('UPDATE '.table_prefix.'sidebar SET sidebar_id=' . $db->escape($_GET['side']) . ' WHERE item_id=' . $db->escape($_GET['id']) . ';');
+ − 2874
if(!$query)
+ − 2875
{
+ − 2876
echo $db->get_error();
+ − 2877
$template->footer();
+ − 2878
exit;
+ − 2879
}
+ − 2880
echo '<div class="info-box" style="margin: 10px 0;">Item moved.</div>';
+ − 2881
break;
+ − 2882
case 'delete':
+ − 2883
$query = $db->sql_query('DELETE FROM '.table_prefix.'sidebar WHERE item_id=' . $db->escape($_GET['id']) . ';'); // Already checked for injection attempts ;-)
+ − 2884
if(!$query)
+ − 2885
{
+ − 2886
echo $db->get_error();
+ − 2887
$template->footer();
+ − 2888
exit;
+ − 2889
}
+ − 2890
if(isset($_GET['ajax']))
+ − 2891
{
+ − 2892
ob_end_clean();
+ − 2893
die('GOOD');
+ − 2894
}
+ − 2895
echo '<div class="error-box" style="margin: 10px 0;">Item deleted.</div>';
+ − 2896
break;
+ − 2897
case 'disenable';
+ − 2898
$q = $db->sql_query('SELECT item_enabled FROM '.table_prefix.'sidebar WHERE item_id=' . $db->escape($_GET['id']) . ';');
+ − 2899
if(!$q)
+ − 2900
{
+ − 2901
echo $db->get_error();
+ − 2902
$template->footer();
+ − 2903
exit;
+ − 2904
}
+ − 2905
$r = $db->fetchrow();
+ − 2906
$db->free_result();
+ − 2907
$e = ( $r['item_enabled'] == 1 ) ? '0' : '1';
+ − 2908
$q = $db->sql_query('UPDATE '.table_prefix.'sidebar SET item_enabled='.$e.' WHERE item_id=' . $db->escape($_GET['id']) . ';');
+ − 2909
if(!$q)
+ − 2910
{
+ − 2911
echo $db->get_error();
+ − 2912
$template->footer();
+ − 2913
exit;
+ − 2914
}
+ − 2915
if(isset($_GET['ajax']))
+ − 2916
{
+ − 2917
ob_end_clean();
+ − 2918
die('GOOD');
+ − 2919
}
+ − 2920
break;
+ − 2921
case 'getsource':
+ − 2922
$q = $db->sql_query('SELECT block_content,block_type FROM '.table_prefix.'sidebar WHERE item_id=' . $db->escape($_GET['id']) . ';');
+ − 2923
if(!$q)
+ − 2924
{
+ − 2925
echo $db->get_error();
+ − 2926
$template->footer();
+ − 2927
exit;
+ − 2928
}
+ − 2929
ob_end_clean();
+ − 2930
$r = $db->fetchrow();
+ − 2931
$db->free_result();
+ − 2932
if($r['block_type'] == BLOCK_PLUGIN) die('HOUSTON_WE_HAVE_A_PLUGIN');
+ − 2933
die($r['block_content']);
+ − 2934
break;
+ − 2935
case 'save':
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2936
if ( defined('ENANO_DEMO_MODE') )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2937
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2938
$q = $db->sql_query('SELECT block_type FROM '.table_prefix.'sidebar WHERE item_id=' . $db->escape($_GET['id']) . ';');
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2939
if(!$q)
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2940
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2941
echo 'var status=unescape(\''.hexencode($db->get_error()).'\');';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2942
exit;
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2943
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2944
$row = $db->fetchrow();
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2945
if ( $row['block_type'] == BLOCK_PHP )
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2946
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2947
$_POST['content'] = '?><Nulled>';
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2948
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2949
else
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2950
{
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2951
$_POST['content'] = sanitize_html($_POST['content'], true);
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2952
}
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
diff
changeset
+ − 2953
}
0
+ − 2954
$q = $db->sql_query('UPDATE '.table_prefix.'sidebar SET block_content=\''.$db->escape(rawurldecode($_POST['content'])).'\' WHERE item_id=' . $db->escape($_GET['id']) . ';');
+ − 2955
if(!$q)
+ − 2956
{
+ − 2957
echo 'var status=unescape(\''.hexencode($db->get_error()).'\');';
+ − 2958
exit;
+ − 2959
}
+ − 2960
$q = $db->sql_query('SELECT block_type,block_content FROM '.table_prefix.'sidebar WHERE item_id=' . $db->escape($_GET['id']) . ';');
+ − 2961
if(!$q)
+ − 2962
{
+ − 2963
echo 'var status=unescape(\''.hexencode($db->get_error()).'\');';
+ − 2964
exit;
+ − 2965
}
+ − 2966
$row = $db->fetchrow();
+ − 2967
$db->free_result();
+ − 2968
switch($row['block_type'])
+ − 2969
{
+ − 2970
case BLOCK_WIKIFORMAT:
+ − 2971
default:
+ − 2972
$c = RenderMan::render($row['block_content']);
+ − 2973
break;
+ − 2974
case BLOCK_TEMPLATEFORMAT:
+ − 2975
$c = $template->tplWikiFormat($row['block_content'], false, 'sidebar-editor.tpl');
+ − 2976
$c = preg_replace('#<a (.*?)>(.*?)</a>#is', '<a href="#" onclick="return false;">\\2</a>', $c);
+ − 2977
break;
+ − 2978
case BLOCK_HTML:
+ − 2979
$c = $row['block_content'];
+ − 2980
$c = preg_replace('#<a (.*?)>(.*?)</a>#is', '<a href="#" onclick="return false;">\\2</a>', $c);
+ − 2981
break;
+ − 2982
case BLOCK_PHP:
+ − 2983
ob_start();
+ − 2984
eval($row['block_content']);
+ − 2985
$c = ob_get_contents();
+ − 2986
ob_end_clean();
+ − 2987
$c = preg_replace('#<a (.*?)>(.*?)</a>#is', '<a href="#" onclick="return false;">\\2</a>', $c);
+ − 2988
break;
+ − 2989
case BLOCK_PLUGIN:
+ − 2990
$c = ($template->fetch_block($row['block_content'])) ? $template->fetch_block($row['block_content']) : 'Can\'t find plugin block';
+ − 2991
break;
+ − 2992
}
+ − 2993
die('var status = \'GOOD\'; var content = unescape(\''.hexencode($c).'\');');
+ − 2994
break;
+ − 2995
}
+ − 2996
}
+ − 2997
+ − 2998
$q = $db->sql_query('SELECT item_id,sidebar_id,item_enabled,block_name,block_type,block_content FROM '.table_prefix.'sidebar ORDER BY sidebar_id ASC, item_order ASC;');
+ − 2999
if(!$q) $db->_die('The sidebar text data could not be selected.');
+ − 3000
+ − 3001
$vars = $template->extract_vars('sidebar-editor.tpl');
+ − 3002
+ − 3003
$parser = $template->makeParserText($vars['sidebar_button']);
+ − 3004
$parser->assign_vars(Array(
+ − 3005
'HREF'=>'#',
+ − 3006
'FLAGS'=>'onclick="return false;"',
+ − 3007
'TEXT'=>'Change theme'
+ − 3008
));
+ − 3009
$template->tpl_strings['THEME_LINK'] = $parser->run();
+ − 3010
$parser->assign_vars(Array(
+ − 3011
'TEXT'=>'Log out',
+ − 3012
));
+ − 3013
$template->tpl_strings['LOGOUT_LINK'] = $parser->run();
+ − 3014
+ − 3015
$n1 = Array();
+ − 3016
$n2 = Array();
+ − 3017
$n =& $n1;
+ − 3018
+ − 3019
echo '<table border="0"><tr><td valign="top"><div class="dbx-group" id="sbedit_left">';
+ − 3020
//if(isset($vars['sidebar_top'])) echo $template->parse($vars['sidebar_top']);
+ − 3021
+ − 3022
// Time for the loop
+ − 3023
// what this loop does is fetch the row data, then send it out to the appropriate parser for formatting,
+ − 3024
// then puts the result into $c, which is then sent to the template compiler for insertion into the TPL code.
+ − 3025
while($row = $db->fetchrow())
+ − 3026
{
+ − 3027
if(isset($current_side))
+ − 3028
{
+ − 3029
if($current_side != $row['sidebar_id'])
+ − 3030
{
+ − 3031
// Time to switch!
+ − 3032
//if(isset($vars['sidebar_top'])) echo $template->parse($vars['sidebar_bottom']);
+ − 3033
echo '</div></td><td valign="top"><div class="dbx-group" id="sbedit_right">';
+ − 3034
//echo '</td><td valign="top">';
+ − 3035
//if(isset($vars['sidebar_top'])) echo $template->parse($vars['sidebar_top']);
+ − 3036
$n =& $n2;
+ − 3037
}
+ − 3038
}
+ − 3039
$n[] = count($n);
+ − 3040
$current_side = $row['sidebar_id'];
+ − 3041
switch($row['block_type'])
+ − 3042
{
+ − 3043
case BLOCK_WIKIFORMAT:
+ − 3044
default:
+ − 3045
$parser = $template->makeParserText($vars['sidebar_section']);
+ − 3046
$c = RenderMan::render($row['block_content']);
+ − 3047
break;
+ − 3048
case BLOCK_TEMPLATEFORMAT:
+ − 3049
$parser = $template->makeParserText($vars['sidebar_section']);
+ − 3050
$c = $template->tplWikiFormat($row['block_content'], false, 'sidebar-editor.tpl');
+ − 3051
$c = preg_replace('#<a (.*?)>(.*?)</a>#is', '<a href="#" onclick="return false;">\\2</a>', $c);
+ − 3052
break;
+ − 3053
case BLOCK_HTML:
+ − 3054
$parser = $template->makeParserText($vars['sidebar_section_raw']);
+ − 3055
$c = $row['block_content'];
+ − 3056
$c = preg_replace('#<a (.*?)>(.*?)</a>#is', '<a href="#" onclick="return false;">\\2</a>', $c);
+ − 3057
break;
+ − 3058
case BLOCK_PHP:
+ − 3059
$parser = $template->makeParserText($vars['sidebar_section_raw']);
+ − 3060
ob_start();
+ − 3061
eval($row['block_content']);
+ − 3062
$c = ob_get_contents();
+ − 3063
ob_end_clean();
+ − 3064
$c = preg_replace('#<a (.*?)>(.*?)</a>#is', '<a href="#" onclick="return false;">\\2</a>', $c);
+ − 3065
break;
+ − 3066
case BLOCK_PLUGIN:
+ − 3067
$parser = $template->makeParserText($vars['sidebar_section_raw']);
+ − 3068
$c = ($template->fetch_block($row['block_content'])) ? $template->fetch_block($row['block_content']) : 'Can\'t find plugin block';
+ − 3069
break;
+ − 3070
}
+ − 3071
$t = $template->tplWikiFormat($row['block_name']);
+ − 3072
if($row['item_enabled'] == 0) $t .= ' <span id="disabled_'.$row['item_id'].'" style="color: red;">(disabled)</span>';
+ − 3073
else $t .= ' <span id="disabled_'.$row['item_id'].'" style="color: red; display: none;">(disabled)</span>';
+ − 3074
$side = ( $row['sidebar_id'] == SIDEBAR_LEFT ) ? SIDEBAR_RIGHT : SIDEBAR_LEFT;
+ − 3075
$tb = '<a title="Enable or disable this block" href="'.makeUrl($paths->page, 'action=disenable&id='.$row['item_id'].'' , true).'" onclick="ajaxDisenableBlock(\''.$row['item_id'].'\'); return false;" ><img alt="Enable/disable this block" style="border-width: 0;" src="'.scriptPath.'/images/disenable.png" /></a>
+ − 3076
<a title="Edit the contents of this block" href="'.makeUrl($paths->page, 'action=edit&id='.$row['item_id'].'' , true).'" onclick="ajaxEditBlock(\''.$row['item_id'].'\', this); return false;"><img alt="Edit this block" style="border-width: 0;" src="'.scriptPath.'/images/edit.png" /></a>
+ − 3077
<a title="Permanently delete this block" href="'.makeUrl($paths->page, 'action=delete&id='.$row['item_id'].'' , true).'" onclick="if(confirm(\'Do you really want to delete this block?\')) { ajaxDeleteBlock(\''.$row['item_id'].'\', this); } return false;"><img alt="Delete this block" style="border-width: 0;" src="'.scriptPath.'/images/delete.png" /></a>
+ − 3078
<a title="Move this block to the other sidebar" href="'.makeUrl($paths->page, 'action=move&id='.$row['item_id'].'&side='.$side, true).'"><img alt="Move this block" style="border-width: 0;" src="'.scriptPath.'/images/move.png" /></a>';
+ − 3079
$as = '';
+ − 3080
$ae = ' '.$tb;
+ − 3081
$parser->assign_vars(Array('CONTENT'=>$c,'TITLE'=>$t,'ADMIN_START'=>$as,'ADMIN_END'=>$ae));
+ − 3082
echo $parser->run();
+ − 3083
unset($parser);
+ − 3084
+ − 3085
}
+ − 3086
$db->free_result();
+ − 3087
//if(isset($vars['sidebar_top'])) echo $template->parse($vars['sidebar_bottom']);
+ − 3088
echo '</div></td></tr></table>';
+ − 3089
echo '<form action="'.makeUrl($paths->page).'" method="post">';
+ − 3090
$order = implode(',', $n1);
+ − 3091
echo "<input type='hidden' id='divOrder_Left' name='order_left' value='{$order}' />";
+ − 3092
$order = implode(',', $n2);
+ − 3093
echo "<input type='hidden' id='divOrder_Right' name='order_right' value='{$order}' />";
+ − 3094
echo '
+ − 3095
<div style="margin: 0 auto 0 auto; text-align: center;">
+ − 3096
<input type="submit" name="save" style="font-weight: bold;" value="Save changes" />
+ − 3097
<input type="submit" name="revert" style="font-weight: normal;" value="Revert" onclick="return confirm(\'Do you really want to revert your changes?\nNote: this does not revert edits or deletions, those are saved as soon as you confirm the action.\')" />
+ − 3098
<br />
+ − 3099
<a href="'.makeUrl($paths->page, 'action=new&id=0', true).'">Create new block</a> | <a href="'.makeUrl(getConfig('main_page'), false, true).'">Main Page</a>
+ − 3100
</div>
+ − 3101
</form>
+ − 3102
';
+ − 3103
}
+ − 3104
+ − 3105
$template->footer();
+ − 3106
}
+ − 3107
+ − 3108
?>