diff -r ac34de920762 -r eefe9ab7fe7c plugins/SpecialAdmin.php --- a/plugins/SpecialAdmin.php Fri Dec 28 16:52:03 2007 -0500 +++ b/plugins/SpecialAdmin.php Sun Dec 30 01:13:24 2007 -0500 @@ -1,8 +1,8 @@ ' . $lang->get('acphome_heading_main') . ''; + echo '

' . $lang->get('acphome_welcome_line1') . '

'; + echo '

' . $lang->get('acphome_welcome_line2') . '

'; // Demo mode if ( defined('ENANO_DEMO_MODE') ) { - echo '

Enano is running in demo mode.

-

If you borked something up, or if you\'re done testing, you can reset this site. 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.

'; + echo '

' . $lang->get('acphome_msg_demo_title') . '

+

' . $lang->get('acphome_msg_demo_body', array('reset_url' => makeUrlNS('Special', 'DemoReset', false, true))) . '

'; } // Check for the installer scripts if( ( file_exists(ENANO_ROOT.'/install.php') || file_exists(ENANO_ROOT.'/schema.sql') ) && !defined('ENANO_DEMO_MODE') ) { - echo '
NOTE: 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.
'; + echo '
+ ' . $lang->get('acphome_msg_install_files') . ' +
'; } - echo '

Check for updates

'; - echo '

Periodically, new releases of Enano will be made available. Click the button below to check for updates to Enano. During this process, a request will be sent to the Enano CMS server (germantown.enanocms.org) over HTTP for an XML file containing a list of the latest releases. No information about your Enano installation will be transmitted.

'; - echo '
'; + echo '

' . $lang->get('acphome_heading_updates') . '

'; + echo '

' . $lang->get('acphome_msg_updates_info', array('updates_url' => 'http://germantown.enanocms.org/meta/updates.xml')) . '

'; + echo '
'; // Inactive users - $q = $db->sql_query('SELECT * FROM '.table_prefix.'logs WHERE log_type=\'admin\' AND action=\'activ_req\';'); - if($q) - if($db->numrows() > 0) + $q = $db->sql_query('SELECT time_id FROM '.table_prefix.'logs WHERE log_type=\'admin\' AND action=\'activ_req\';'); + if ( $q ) + { + if ( $db->numrows() > 0 ) { $n = $db->numrows(); - if($n == 1) $s = $n . ' user is'; - else $s = $n . ' users are'; - echo '
It appears that '.$s.' awaiting account activation. You can activate those accounts by going to the User Manager.
'; + $um_flags = 'href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'UserManager\'); return false;"'; + if ( $n == 1 ) + $s = $lang->get('acphome_msg_inactive_users_one', array('um_flags' => $um_flags)); + else + $s = $lang->get('acphome_msg_inactive_users_plural', array('um_flags' => $um_flags)); + echo '
+ ' . $s . ' +
'; } + } $db->free_result(); // Stats if(getConfig('log_hits') == '1') @@ -132,23 +139,32 @@ //die('
'.print_r($stats,true).'
'); $c = 0; $cls = 'row2'; - echo '

Most requested pages

'; + echo '

' . $lang->get('acphome_heading_top_pages') . '

+
+
PageHits
+ + + + '; foreach($stats as $data) { - echo ''; + echo ''; $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; - echo ''; - echo ''; + echo ''; + echo ''; } - echo '
' . $lang->get('acphome_th_toppages_page') . '' . $lang->get('acphome_th_toppages_hits') . '
'.$data['page_title'].''.$data['num_hits'].'
+ '.$data['page_title'].''.$data['num_hits'] + . '
'; + echo ' + '; } // Security log - echo '

Security log

'; + echo '

' . $lang->get('acphome_heading_seclog') . '

'; $seclog = get_security_log(5); echo $seclog; - echo '

Full security log

'; + echo '

' . $lang->get('acphome_btn_seclog_full') . '

'; } @@ -278,15 +294,15 @@ } else { - echo '
You have entered an invalid avatar directory.
'; + echo '
' . $lang->get('acpgc_err_avatar_dir_invalid') . '
'; } } else { - echo '
You have entered an invalid avatar directory.
'; + echo '
' . $lang->get('acpgc_err_avatar_dir_invalid') . '
'; } - echo '
Your changes to the site configuration have been saved.

'; + echo '
' . $lang->get('acpgc_msg_save_success') . '

'; } else if ( isset($_POST['submit']) && defined('ENANO_DEMO_MODE') ) @@ -300,28 +316,28 @@ - Global site options - These options control the entire site. + get('acpgc_heading_main'); ?> + get('acpgc_heading_submain'); ?> - Site name: - Site description: - Main page: pagename_field('main_page', htmlspecialchars(str_replace('_', ' ', getConfig('main_page')))); ?> - Copyright notice shown on pages: - Hint: If you're using Windows, you can make a "©" symbol by holding ALT and pressing 0169 on the numeric keypad. - Contact e-mail
All e-mail sent from this site will appear to have come from the address shown here. + get('acpgc_field_site_name'); ?> + get('acpgc_field_site_desc'); ?> + get('acpgc_field_main_page'); ?> pagename_field('main_page', htmlspecialchars(str_replace('_', ' ', getConfig('main_page')))); ?> + get('acpgc_field_copyright'); ?> + get('acpgc_field_copyright_hint'); ?> + get('acpgc_field_contactemail'); ?>
get('acpgc_field_contactemail_hint'); ?> - Wiki mode + get('acpgc_heading_wikimode'); ?> - Enano can also act as a wiki, meaning anyone can edit and create pages. To enable Wiki Mode, check the box to the right.

- 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.

- Also, Enano keeps complete page history, which makes restoring vandalized pages easy. You can also protect pages so that they cannot be edited. + get('acpgc_field_wikimode_intro'); ?>

+ get('acpgc_field_wikimode_info_sanitize'); ?>

+ get('acpgc_field_wikimode_info_history'); ?> - /> + /> @@ -329,11 +345,12 @@ - Edit page notice
- 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. + get('acpgc_field_editnotice_title'); ?>
+ get('acpgc_field_editnotice_info'); ?> - /> + /> + @@ -345,34 +362,86 @@ - Require visual confirmation for guests editing pages
- If this is enabled, guests will be asked to enter a visual confirmation code before saving changes to a page. + get('acpgc_field_edit_require_captcha_title'); ?>
+ get('acpgc_field_edit_require_captcha_hint'); ?> - Statistics and hit counting + get('acpgc_heading_stats'); ?> - 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.

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. -
This excludes special and administration pages. + + get('acpgc_stats_intro'); ?>

+ get('acpgc_stats_hint_privacy'); ?> + + +
+ get('acpgc_field_stats_hint'); ?> + - Comment system - /> - /> - Guest comment posting allowed - - + + + get('acpgc_heading_comments'); ?> + + + + + + + + + /> + + + + + + + + + /> + + + + + + get('acpgc_field_comment_allow_guests'); ?> + + + + + + + + + - Disable all site access + get('acpgc_heading_disablesite'); ?> - Disabling the site allows you to work on the site without letting non-administrators see or use it. - + + get('acpgc_field_disablesite_hint'); ?> + + + + @@ -412,41 +488,41 @@ - + - + - - + - + - - - - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + +
Users and communicationget('acpgc_heading_users'); ?>
User account activation
get('acpgc_heading_activate'); ?>
- 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.

- You may also disable registration completely if needed.

- Note: because of abuse by project administrators, sending account activation e-mails will not work on SourceForge.net servers. + get('acpgc_activate_intro_line1'); ?>

+ get('acpgc_activate_intro_line2'); ?>

+ get('acpgc_activate_intro_sfnet_warning'); ?>
Account activation: + get('acpgc_field_activate'); ?> Disable registration
'; - echo ''; - echo ''; - echo ''; + echo '
'; + echo ''; + echo ''; + echo ''; ?>
Account lockouts
get('acpgc_heading_lockout'); ?>
Configure Enano to prevent or restrict logins for a specified period of time if a user enters an incorrect password a specific number of times.
get('acpgc_lockout_intro'); ?>
Lockout threshold:
- How many times can a user enter wrong credentials before a lockout goes into effect? +
get('acpgc_field_lockout_threshold'); ?>
+ get('acpgc_field_lockout_threshold_hint'); ?>
@@ -454,8 +530,8 @@
Lockout duration:
- This is how long an account lockout should last, in minutes. +
get('acpgc_field_lockout_duration'); ?>
+ get('acpgc_field_lockout_duration_hint'); ?>
@@ -463,34 +539,34 @@
Lockout policy:
- What should be done when a lockout goes into effect? +
get('acpgc_field_lockout_policy'); ?>
+ get('acpgc_field_lockout_policy_hint'); ?>
-
-
- +
+
+
Password strength
get('acpgc_heading_passstrength'); ?>
- Enable password strength analysis
- This should be enabled in most cases. When this is enabled, a strength meter and a numerical score will be displayed wherever a password can be changed. + get('acpgc_field_passstrength_title'); ?>
+ get('acpgc_field_passstrength_hint'); ?>
- +
- Minimum strength score
- This is the lowest score a password will be allowed to have. -10 will allow any password. A score of under -3 is considered weak, under 1 is fair, under 4 is good, under 10 is strong, and 10 and above are very strong. The scale is open-ended. This only has an effect if the meter is enabled above. + get('acpgc_field_passminimum_title'); ?>
+ get('acpgc_field_passminimum_hint'); ?>
@@ -499,87 +575,130 @@ -
E-mail sent from the site
E-mail sending method:
Try using the built-in e-mail method first. If that doesn't work, you will need to enter valid SMTP information here.

-
SMTP hostname:
This option only applies to the external SMTP mode.
SMTP credentials:
This option only applies to the external SMTP mode.
Username:
- Password:
Avatars
- Avatars are small images that users can display on their profiles and in comments. + + get('acpgc_heading_email'); ?>
- Enable avatar support:
- Supported formats are JPEG, PNG, and GIF™. + get('acpgc_field_email_method'); ?>
+ get('acpgc_field_email_method_hint'); ?>
- + + +
+ +
- Maximum avatar file size:
- For smaller sites, the highest value for this should be about 50KB, 51200. Larger sites with more visitors will likely want to use something much smaller, such as 10KB. + get('acpgc_field_email_smtp_hostname'); ?>
+ get('acpgc_field_email_smtp_hostname_hint'); ?>
- /> bytes +
- Maximum avatar dimensions:
- The format is width × height. Typically you want to have this square (the same width and height). These are only maximum dimensions; users are not prevented from having smaller images. + get('acpgc_field_email_smtp_auth'); ?>
+ get('acpgc_field_email_smtp_hostname_hint'); ?>
- /> × - /> pixels + get('acpgc_field_email_smtp_username'); ?>
+ get('acpgc_field_email_smtp_password'); ?> +
get('acpgc_heading_avatars'); ?>
+ get('acpgc_avatars_intro'); ?> + +
+ get('acpgc_field_avatar_enable'); ?>
+ get('acpgc_field_avatar_enable_hint'); ?> +
+
- Allow animated avatars:
- If this is checked, users can upload APNG and Animated GIF™ avatars. Sometimes such images can be specifically made to be distracting, like rapidly flashing images. If this is unchecked, these formats will be blocked, and only still PNGs and GIFs will be allowed. + get('acpgc_field_avatar_max_filesize'); ?>
+ get('acpgc_field_avatar_max_filesize_hint'); ?>
- + /> get('etc_unit_bytes'); ?>
- Allowed upload methods:
- + get('acpgc_field_avatar_max_dimensions'); ?>
+ get('acpgc_field_avatar_max_dimensions_hint'); ?>
-
- + /> × + /> get('etc_unit_pixels'); ?>
- Avatar storage directory:
- This should be relative to your Enano root and should contain only alphanumeric characters and forward slashes, even if your server runs Windows. + get('acpgc_field_avatar_allow_anim_title'); ?>
+ get('acpgc_field_avatar_allow_anim_hint'); ?> +
+ +
+ get('acpgc_field_avatar_upload_methods'); ?>
+ +
+ + +
+ + +
+ get('acpgc_field_avatar_directory'); ?>
+ get('acpgc_field_avatar_directory_hint'); ?>
/> @@ -593,90 +712,114 @@ - + - - + + - - + - + - + - + - - + + - - - - - - + + + + + + - - - + + + + + + + + + + + + @@ -686,7 +829,7 @@
Sidebar linksget('acpgc_heading_sidebar'); ?>
Promote Enano
get('acpgc_heading_promoteenano'); ?>
- 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 - 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 - 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 - using this link. + + get('acpgc_field_enano_link_title'); ?>
SourceForge.net logo
get('acpgc_heading_sfnet_logo'); ?>
- All projects hosted by SourceForge.net are required to display an official SourceForge.net logo on their pages. If you want - to display a SourceForge.net logo on the sidebar, check the box below, enter your group ID, and select an image type. + get('acpgc_sfnet_intro'); ?>
Display the SourceForge.net logo on the right sidebarget('acpgc_field_sfnet_display'); ?> />
Group ID:get('acpgc_field_sfnet_group_id'); ?>
Logo style:get('acpgc_field_sfnet_logo_style'); ?>
W3C compliance logos
Enano generates (by default) Valid XHTML 1.1 code, plus valid CSS. If you want to show this off, check the appropriate boxes below.
get('acpgc_heading_w3clogos'); ?>
get('acpgc_w3clogos_intro'); ?>
id="w3c-vh32" name="w3c-vh32" />
id="w3c-vh40" name="w3c-vh40" />
id="w3c-vh401" name="w3c-vh401" />
id="w3c-vxhtml10" name="w3c-vxhtml10" />
id="w3c-vxhtml11" name="w3c-vxhtml11" />
id="w3c-vcss" name="w3c-vcss" />
id="w3c-vh32" name="w3c-vh32" />
id="w3c-vh40" name="w3c-vh40" />
id="w3c-vh401" name="w3c-vh401" />
id="w3c-vxhtml10" name="w3c-vxhtml10" />
id="w3c-vxhtml11" name="w3c-vxhtml11" />
id="w3c-vcss" name="w3c-vcss" />
Defective By Design Anti-DRM button
The Enano project is strongly against Digital Restrictions Management. 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 DefectiveByDesign.org on your sidebar.
/>
+ get('acpgc_heading_dbd'); ?> +
+ get('acpgc_dbd_intro'); ?> + get('acpgc_dbd_explain'); ?> +
+ + + /> +
- +
@@ -783,39 +926,138 @@ } echo '
'; ?> -

File upload configuration

-

Enano supports the ability to upload files to your website and store the files in the database. This enables you to embed images - and such into pages without manually writing the HTML. However, the upload feature can sometimes pose a risk to your site, as viruses - and executable files can sometimes be uploaded.

-

-

Maximum file size:

-

You can allow Enano to generate thumbnails of images automatically. This feature requires ImageMagick to work properly. If your server - 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 - are uploading large (>100KB) images and embedding them inside of pages, you should try to enable ImageMagick because transferring these - large images many times can cost you quite a lot of bandwidth.

-


- Path to ImageMagick:
- 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 - ImageMagick is most likely to be C:\Windows\Convert.exe or C:\Windows\System32\Convert.exe. -

-

If you use ImageMagick to scale images, your server will be very busy constantly scaling images if your website is busy, and your site - may experience slowdowns. You can dramatically speed up this scaling process if you use a directory to cache thumbnail images.

-

Please note: the cache/ directory on your server must be writable by the server. While this is not usually a problem on - Windows servers, most Linux/Unix servers will require you to CHMOD the cache/ directory to 777. See your FTP client's user guide for - more information on how to do this.At present, it seems that the cache directory - is not writable. The checkbox below has been disabled to maintain the stability of Enano.'; ?>

-

-

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 - changes made to uploaded files, but this requires a significant amount of database storage. You should probably leave this option - enabled unless you have less than 250MB of MySQL database space.

-

+

get('acpup_heading_main'); ?>

+ +

+ get('acpup_intro'); ?> +

+

+ +

+

+ get('acpup_field_max_size'); ?> + + +

+ +

get('acpup_info_magick'); ?>

+

+ +
+ get('acpup_field_magick_path'); ?>
+ get('acpup_field_magick_path_hint'); ?> +

+ +

get('acpup_info_cache'); ?>

+

+ get('acpup_info_cache_chmod'); ?> + + get('acpup_msg_cache_not_writable'); + ?> +

+ +

+ +

+ +

get('acpup_info_history'); ?>

+

+ +

+
-

+

'; } -function page_Admin_PluginManager() { +function page_Admin_UploadAllowedMimeTypes() +{ + global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; + if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) + { + $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true); + echo '

' . $lang->get('adm_err_not_auth_title') . '

'; + echo '

' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '

'; + return; + } + + global $mime_types, $mimetype_exps, $mimetype_extlist; + if(isset($_POST['save']) && !defined('ENANO_DEMO_MODE')) + { + $bits = ''; + $keys = array_keys($mime_types); + foreach($keys as $i => $k) + { + if(isset($_POST['ext_'.$k])) $bits .= '1'; + else $bits .= '0'; + } + $bits = compress_bitfield($bits); + setConfig('allowed_mime_types', $bits); + echo '
' . $lang->get('acpft_msg_saved') . '
'; + } + else if ( isset($_POST['save']) && defined('ENANO_DEMO_MODE') ) + { + echo '
' . $lang->get('acpft_msg_demo_mode') . '
'; + } + $allowed = fetch_allowed_extensions(); + ?> +

get('acpft_heading_main'); ?>

+

get('acpft_hint'); ?>

+ nslist['Special'].'Administration', (( isset($_GET['sqldbg'])) ? 'sqldbg&' : '') .'module='.$paths->cpage['module']).'" method="post">'; + $c = -1; + $t = -1; + $cl = 'row1'; + echo "\n".'
'."\n".' '."\n".' '."\n "; + ksort($mime_types); + foreach($mime_types as $e => $m) + { + $c++; + $t++; + if($c == 3) + { + $c = 0; + $cl = ( $cl == 'row1' ) ? 'row2' : 'row1'; + echo ''."\n".' '."\n "; + } + $seed = "extchkbx_{$e}_".md5(microtime() . mt_rand()); + $chk = (!empty($allowed[$e])) ? ' checked="checked"' : ''; + echo " \n "; + } + while($c < 2) + { + $c++; + echo " \n "; + } + echo ''; + echo ''."\n".'
\n \n
'."\n".'
'; + echo '
'; + ?> + auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) @@ -828,32 +1070,46 @@ if(isset($_GET['action'])) { - switch($_GET['action']) + if ( !isset($_GET['plugin']) ) + { + echo '
No plugin specified.
'; + } + else if ( !preg_match('/^[A-z0-9_-]+\.php$/', $_GET['plugin']) ) { - case "enable": - $q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author,page_text) VALUES(\'security\',\'plugin_enable\',' . time() . ',\'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\',"' . $db->escape($session->username) . '","' . $db->escape($_GET['plugin']) . '");'); - if ( !$q ) - $db->_die(); - setConfig('plugin_'.$_GET['plugin'], '1'); - break; - case "disable": - if ( defined('ENANO_DEMO_MODE') && strstr($_GET['plugin'], 'Demo') ) - { - echo('

Error disabling plugin

The demo lockdown plugin cannot be disabled in demo mode.

'); - break; - } - if ( !in_array($_GET['plugin'], $plugins->system_plugins) ) - { - $q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author,page_text) VALUES(\'security\',\'plugin_disable\',' . time() . ',\'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\',"' . $db->escape($session->username) . '","' . $db->escape($_GET['plugin']) . '");'); + echo '
Hacking attempt
'; + } + else + { + $plugin =& $_GET['plugin']; + switch($_GET['action']) + { + case "enable": + $q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author,page_text) VALUES(\'security\',\'plugin_enable\',' . time() . ',\'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\',"' . $db->escape($session->username) . '","' . $db->escape($_GET['plugin']) . '");'); if ( !$q ) $db->_die(); - setConfig('plugin_'.$_GET['plugin'], '0'); - } - else - { - echo('

Error disabling plugin

The plugin you selected cannot be disabled because it is a system plugin.

'); - } - break; + setConfig("plugin_$plugin", '1'); + break; + case "disable": + if ( defined('ENANO_DEMO_MODE') && strstr($_GET['plugin'], 'Demo') ) + { + echo('

' . $lang->get('acppl_err_heading') . '

+

' . $lang->get('acppl_err_demo_plugin') . '

'); + break; + } + if ( !in_array($plugin, $plugins->system_plugins) ) + { + $q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,edit_summary,author,page_text) VALUES(\'security\',\'plugin_disable\',' . time() . ',\'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\',"' . $db->escape($session->username) . '","' . $db->escape($_GET['plugin']) . '");'); + if ( !$q ) + $db->_die(); + setConfig("plugin_$plugin", '0'); + } + else + { + echo '

' . $lang->get('acppl_err_heading') . '

+

' . $lang->get('acppl_err_system_plugin') . '

'; + } + break; + } } } $dir = './plugins/'; @@ -896,23 +1152,37 @@ $thelist[$file]['auth'] = $f[3]; $thelist[$file]['vers'] = $f[4]; $thelist[$file]['aweb'] = $f[5]; + + if ( preg_match('/^[a-z0-9]+_[a-z0-9_]+$/', $thelist[$file]['name']) ) + $thelist[$file]['name'] = $lang->get($thelist[$file]['name']); + + if ( preg_match('/^[a-z0-9]+_[a-z0-9_]+$/', $thelist[$file]['desc']) ) + $thelist[$file]['desc'] = $lang->get($thelist[$file]['desc']); + } } closedir($dh); } else { - echo '
The plugins/ directory could not be opened.
'; + echo '
' . $lang->get('acppl_err_open_dir') . '
'; return; } } else { - echo '
The plugins/ directory is missing from your Enano installation.
'; + echo '
' . $lang->get('acppl_err_missing_dir') . '
'; return; } echo('
- '); + + + + + + + + '); $plugin_files_1 = array_keys($plugin_list); $plugin_files_2 = array_keys($system); $plugin_files = array_values(array_merge($plugin_files_1, $plugin_files_2)); @@ -938,27 +1208,343 @@ { if ( getConfig('plugin_'.$plugin_files[$i]) == '1' ) { - echo 'Disable'; + echo '' . $lang->get('acppl_btn_disable') . ''; } else { - echo 'Enable'; + echo '' . $lang->get('acppl_btn_enable') . ''; } } else { - echo '[System]'; + echo $lang->get('acppl_lbl_system_plugin'); } echo ''; } $showhide_link = ( $show_system ) ? - 'Hide system plugins' : - 'Show system plugins' ; + '' . $lang->get('acppl_btn_hide_system') . '' : + '' . $lang->get('acppl_btn_show_system') . '' ; echo ''; echo '
Plugin filenamePlugin nameDescriptionAuthorVersion
' . $lang->get('acppl_col_filename') . '' . $lang->get('acppl_col_name') . '' . $lang->get('acppl_col_description') . '' . $lang->get('acppl_col_author') . '' . $lang->get('acppl_col_version') . '
'.$showhide_link.'
'; } -function page_Admin_UploadAllowedMimeTypes() +/* +function page_Admin_PageManager() +{ + global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; + if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) + { + $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true); + echo '

' . $lang->get('adm_err_not_auth_title') . '

'; + echo '

' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '

'; + return; + } + + echo '

Page management

'; + + if ( isset($_POST['search']) || isset($_POST['select']) || ( isset($_GET['source']) && $_GET['source'] == 'ajax' ) ) + { + // The object of the game: using only the text a user entered, guess the page ID and namespace. *sigh* I HATE writing search algorithms... + $source = ( isset($_GET['source']) ) ? $_GET['source'] : false; + if ( $source == 'ajax' ) + { + $_POST['search'] = true; + $_POST['page_url'] = $_GET['page_id']; + } + if ( isset($_POST['search']) ) + { + $pid = $_POST['page_url']; + } + elseif ( isset($_POST['select']) ) + { + $pid = $_POST['page_force_url']; + } + else + { + echo 'Internal error selecting page search terms'; + return false; + } + // Look for a namespace prefix in the urlname, and assign a different namespace, if necessary + $k = array_keys($paths->nslist); + for ( $i = 0; $i < sizeof($paths->nslist); $i++ ) + { + $ln = strlen($paths->nslist[$k[$i]]); + if(substr($pid, 0, $ln) == $paths->nslist[$k[$i]]) + { + $ns = $k[$i]; + $page_id = substr($pid, $ln, strlen($pid)); + } + } + // The namespace is in $ns and the page name or ID (we don't know which yet) is in $page_id + // Now, iterate through $paths->pages searching for a page with this name or ID + for ( $i = 0; $i < sizeof($paths->pages) / 2; $i++ ) + { + if ( !isset($final_pid) ) + { + if ( $paths->pages[$i]['urlname_nons'] == str_replace(' ', '_', $page_id) ) + { + $final_pid = str_replace(' ', '_', $page_id); + } + else if ( $paths->pages[$i]['name'] == $page_id ) + { + $final_pid = $paths->pages[$i]['urlname_nons']; + } + else if ( strtolower($paths->pages[$i]['urlname_nons']) == strtolower(str_replace(' ', '_', $page_id)) ) + { + $final_pid = $paths->pages[$i]['urlname_nons']; + } + else if ( strtolower($paths->pages[$i]['name']) == strtolower(str_replace('_', ' ', $page_id)) ) + { + $final_pid = $paths->pages[$i]['urlname_nons']; + } + if ( isset($final_pid) ) + { + $_POST['name'] = $paths->pages[$i]['name']; + $_POST['urlname'] = $paths->pages[$i]['urlname_nons']; + } + } + } + if ( !isset($final_pid) ) + { + echo 'The page you searched for cannot be found. Back'; + return false; + } + $_POST['namespace'] = $ns; + $_POST['old_namespace'] = $ns; + $_POST['page_id'] = $final_pid; + $_POST['old_page_id'] = $final_pid; + if ( !isset($paths->pages[$paths->nslist[$_POST['namespace']].$_POST['urlname']]) ) + { + echo 'The page you searched for cannot be found. Back'; + return false; + } + } + + if ( isset($_POST['page_id']) && isset($_POST['namespace']) && !isset($_POST['cancel']) ) + { + $cpage = $paths->pages[$paths->nslist[$_POST['old_namespace']].$_POST['old_page_id']]; + if(isset($_POST['submit'])) + { + switch(true) + { + case true: + // Create a list of things to update + $page_info = Array( + 'name'=>$_POST['name'], + 'urlname'=>sanitize_page_id($_POST['page_id']), + 'namespace'=>$_POST['namespace'], + 'special'=>isset($_POST['special']) ? '1' : '0', + 'visible'=>isset($_POST['visible']) ? '1' : '0', + 'comments_on'=>isset($_POST['comments_on']) ? '1' : '0', + 'protected'=>isset($_POST['protected']) ? '1' : '0' + ); + + $updating_urlname_or_namespace = ( $page_info['namespace'] != $cpage['namespace'] || $page_info['urlname'] != $cpage['urlname_nons'] ); + + if ( !isset($paths->nslist[ $page_info['namespace'] ]) ) + { + echo '
The namespace you selected is not properly registered.
'; + break; + } + if ( isset($paths->pages[ $paths->nslist[$page_info['namespace']] . $page_info[ 'urlname' ] ]) && $updating_urlname_or_namespace ) + { + echo '
There is already a page that exists with that URL string and namespace.
'; + break; + } + // Build the query + $q = 'UPDATE '.table_prefix.'pages SET '; + $k = array_keys($page_info); + foreach($k as $c) + { + $q .= $c.'=\''.$db->escape($page_info[$c]).'\','; + } + $q = substr($q, 0, strlen($q)-1); + // Build the WHERE statements + $q .= ' WHERE '; + $k = array_keys($cpage); + if ( !isset($cpage) ) + die('[internal] no cpage'); + foreach($k as $c) + { + if($c != 'urlname_nons' && $c != 'urlname' && $c != 'really_protected') + { + $q .= $c.'=\''.$db->escape($cpage[$c]).'\' AND '; + } + else if($c == 'urlname') + { + $q .= $c.'=\''.$db->escape($cpage['urlname_nons']).'\' AND '; + } + } + // Trim off the last " AND " and append a semicolon + $q = substr($q, 0, strlen($q)-5) . ';'; + // Send the completed query to MySQL + $e = $db->sql_query($q); + if(!$e) $db->_die('The page data could not be updated.'); + // Update any additional tables + $q = Array( + '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']) . '\';', + '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']) . '\';', + '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']) . '\';', + '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']) . '\';', + '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']) . '\';' + ); + foreach($q as $cq) + { + $e = $db->sql_query($cq); + if(!$e) $db->_die('Some of the additional tables containing page information could not be updated.'); + } + // Update $cpage + $cpage = $page_info; + $cpage['urlname_nons'] = $cpage['urlname']; + $cpage['urlname'] = $paths->nslist[$cpage['namespace']].$cpage['urlname']; + $_POST['old_page_id'] = $page_info['urlname']; + $_POST['old_namespace'] = $page_info['namespace']; + echo '
Your changes have been saved.
'; + break; + } + } elseif(isset($_POST['delete'])) { + $q = Array( + 'DELETE FROM '.table_prefix.'categories WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', + 'DELETE FROM '.table_prefix.'comments WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', + 'DELETE FROM '.table_prefix.'logs WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', + 'DELETE FROM '.table_prefix.'page_text WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', + ); + foreach($q as $cq) + { + $e = $db->sql_query($cq); + if(!$e) $db->_die('Some of the additional tables containing page information could not be updated.'); + } + + if(!$db->sql_query( + 'DELETE FROM '.table_prefix.'pages WHERE urlname="'.$db->escape($_POST['old_page_id']).'" AND namespace="'.$db->escape($_POST['old_namespace']).'";' + )) $db->_die('The page could not be deleted.'); + echo '
This page has been deleted.

Return to Page manager
Admin home

'; + return; + } + $url = makeUrlNS('Special', 'Administration', 'module='.$paths->cpage['module'], true); + echo '
'; + ?> +

Modify page:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Namespace: + +
+ Page title: + + +
+ Page URL string:
+ No spaces, and don't enter the namespace prefix (e.g. User:).
+ Changing this value is usually not a good idea, especially for templates and project pages.
+
+ +
+ name="comments_on" type="checkbox" id="cmt" /> + +
+ name="special" type="checkbox" id="spc" /> +
+ 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. +
+ name="visible" type="checkbox" id="vis" /> +
+ 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 nslist['Special']; ?>SearchRebuild. +
+ name="protected" type="checkbox" id="prt" /> +
+ This option only has an effect when Wiki Mode is enabled. +
+ +
+
+
+ + + + +
+ '; + } + else + { + echo '

Please select a page

'; + echo ''; + ?> +

Search for page title (remember prefixes like User: and File:) pagename_field('page_url'); ?>

+

Select page title from a list:

+ '; + + } +} +*/ + +function page_Admin_PageEditor() { global $db, $session, $paths, $template, $plugins; // Common objects global $lang; @@ -970,63 +1556,99 @@ return; } - global $mime_types, $mimetype_exps, $mimetype_extlist; - if(isset($_POST['save']) && !defined('ENANO_DEMO_MODE')) - { - $bits = ''; - $keys = array_keys($mime_types); - foreach($keys as $i => $k) + + echo '

Edit page content

'; + + if(isset($_POST['search']) || isset($_POST['select'])) { + // The object of the game: using only the text a user entered, guess the page ID and namespace. *sigh* I HATE writing search algorithms... + if(isset($_POST['search'])) $pid = $_POST['page_url']; + elseif(isset($_POST['select'])) $pid = $_POST['page_force_url']; + else { echo 'Internal error selecting page search terms'; return false; } + // Look for a namespace prefix in the urlname, and assign a different namespace, if necessary + $k = array_keys($paths->nslist); + for($i=0;$inslist);$i++) { - if(isset($_POST['ext_'.$k])) $bits .= '1'; - else $bits .= '0'; + $ln = strlen($paths->nslist[$k[$i]]); + if(substr($pid, 0, $ln) == $paths->nslist[$k[$i]]) + { + $ns = $k[$i]; + $page_id = substr($pid, $ln, strlen($pid)); + } } - $bits = compress_bitfield($bits); - setConfig('allowed_mime_types', $bits); - echo '
Your changes have been saved.
'; - } - else if ( isset($_POST['save']) && defined('ENANO_DEMO_MODE') ) - { - echo '
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.
'; + // The namespace is in $ns and the page name or ID (we don't know which yet) is in $page_id + // Now, iterate through $paths->pages searching for a page with this name or ID + for($i=0;$ipages)/2;$i++) + { + if(!isset($final_pid)) + { + if ($paths->pages[$i]['urlname_nons'] == str_replace(' ', '_', $page_id)) $final_pid = str_replace(' ', '_', $page_id); + elseif($paths->pages[$i]['name'] == $page_id) $final_pid = $paths->pages[$i]['urlname_nons']; + elseif(strtolower($paths->pages[$i]['urlname_nons']) == strtolower(str_replace(' ', '_', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons']; + elseif(strtolower($paths->pages[$i]['name']) == strtolower(str_replace('_', ' ', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons']; + if(isset($final_pid)) { $_POST['name'] = $paths->pages[$i]['name']; $_POST['urlname'] = $paths->pages[$i]['urlname_nons']; } + } + } + if(!isset($final_pid)) { echo 'The page you searched for cannot be found. Back'; return false; } + $_POST['namespace'] = $ns; + $_POST['page_id'] = $final_pid; + if(!isset($paths->pages[$paths->nslist[$_POST['namespace']].$_POST['urlname']])) { echo 'The page you searched for cannot be found. Back'; return false; } } - $allowed = fetch_allowed_extensions(); - ?> -

Allowed file types

-

Using the form below, you can decide which file types are allowed to be uploaded to this site.

- nslist['Special'].'Administration', (( isset($_GET['sqldbg'])) ? 'sqldbg&' : '') .'module='.$paths->cpage['module']).'" method="post">'; - $c = -1; - $t = -1; - $cl = 'row1'; - echo "\n".'
'."\n".' '."\n".' '."\n "; - ksort($mime_types); - foreach($mime_types as $e => $m) + + if(isset($_POST['page_id']) && !isset($_POST['cancel'])) + { + echo ''; + if(!isset($_POST['content']) || isset($_POST['revert'])) $content = RenderMan::getPage($_POST['page_id'], $_POST['namespace'], 0, false, false, false, false); + else $content = $_POST['content']; + if(isset($_POST['save'])) { - $c++; - $t++; - if($c == 3) - { - $c = 0; - $cl = ( $cl == 'row1' ) ? 'row2' : 'row1'; - echo ''."\n".' '."\n "; - } - $seed = "extchkbx_{$e}_".md5(microtime() . mt_rand()); - $chk = (!empty($allowed[$e])) ? ' checked="checked"' : ''; - echo " \n "; + $data = $content; + $id = md5( microtime() . mt_rand() ); + + $minor = isset($_POST['minor']) ? 'true' : 'false'; + $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']) . '\', \''.$db->escape($data).'\', \''.$id.'\', \''.$session->username.'\', \''.$db->escape(htmlspecialchars($_POST['summary'])).'\', '.$minor.');'; + if(!$db->sql_query($q)) $db->_die('The history (log) entry could not be inserted into the logs table.'); + + $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']) . '\';'; + $e = $db->sql_query($query); + if(!$e) echo '
The page data could not be saved. MySQL said: '.mysql_error().'

Query:
'.$query.'
'; + else echo '
Your page has been saved. View page...
'; + } elseif(isset($_POST['preview'])) { + echo '

Preview

Reminder: This is only a preview; your changes to this page have not yet been saved.

'.RenderMan::render($content).'
'; } - while($c < 2) - { - $c++; - echo " \n "; - } - echo ''; - echo ''."\n".'
\n \n
'."\n".'
'; + ?> +

+
+ Edit summary:
+ +

+

+ + +        +

+ '; - ?> - Please select a page'; + echo ''; + ?> +

Search for page title (remember prefixes like User: and File:) pagename_field('page_url'); ?>

+

Select page title from a list:

+ '; + } } -function page_Admin_Sidebar() +function page_Admin_ThemeManager() { + global $db, $session, $paths, $template, $plugins; // Common objects global $lang; if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) @@ -1037,52 +1659,258 @@ return; } - ?> -

Editing and managing the Enano sidebar

-

The Enano sidebar is a versatile tool when scripted correctly. You don't have to be a programmer to enjoy the features the Sidebar - provides; however, editing the sidebar requires a small bit of programming knowledge and an understanding of Enano's system message - markup language. + + // Get the list of styles in the themes/ dir + $h = opendir('./themes'); + $l = Array(); + if(!$h) die('Error opening directory "./themes" for reading.'); + while(false !== ($n = readdir($h))) { + if($n != '.' && $n != '..' && is_dir('./themes/'.$n)) + $l[] = $n; + } + closedir($h); + echo(' +

Theme Management

+

Install, uninstall, and manage Enano themes.

+ '); + if(isset($_POST['disenable'])) { + $q = 'SELECT enabled FROM '.table_prefix.'themes WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\''; + $s = $db->sql_query($q); + if(!$s) die('Error selecting enabled/disabled state value: '.mysql_error().'
SQL:
'.$q); + $r = $db->fetchrow_num($s); + $db->free_result(); + if($r[0] == 1) $e = 0; + else $e = 1; + $s=true; + if($e==0) + { + $c = $db->sql_query('SELECT * FROM '.table_prefix.'themes WHERE enabled=1'); + if(!$c) $db->_die('The backup check for having at least on theme enabled failed.'); + if($db->numrows() <= 1) { echo '
You cannot disable the last remaining theme.
'; $s=false; } + } + $db->free_result(); + if($s) { + $q = 'UPDATE '.table_prefix.'themes SET enabled='.$e.' WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\''; + $a = $db->sql_query($q); + if(!$a) die('Error updating enabled/disabled state value: '.mysql_error().'
SQL:
'.$q); + else echo('
The theme "'.$_POST['theme_id'].'" has been '. ( ( $e == '1' ) ? 'enabled' : 'disabled' ).'.
'); + } + } + elseif(isset($_POST['edit'])) { + + $dir = './themes/'.$_POST['theme_id'].'/css/'; + $list = Array(); + // Open a known directory, and proceed to read its contents + if (is_dir($dir)) { + if ($dh = opendir($dir)) { + while (($file = readdir($dh)) !== false) { + if(preg_match('#^(.*?)\.css$#is', $file) && $file != '_printable.css') { + $list[$file] = capitalize_first_letter(substr($file, 0, strlen($file)-4)); + } + } + closedir($dh); + } + } + $lk = array_keys($list); + + $q = 'SELECT theme_name,default_style FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\''; + $s = $db->sql_query($q); + if(!$s) die('Error selecting name value: '.mysql_error().'
SQL:
'.$q); + $r = $db->fetchrow_num($s); + $db->free_result(); + echo(''); + echo('
+ Theme name displayed to users:

+ Default stylesheet:

+ +
'); + echo(''); + } + elseif(isset($_POST['editsave'])) { + $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']) . '\''; + $s = $db->sql_query($q); + if(!$s) die('Error updating name value: '.mysql_error().'
SQL:
'.$q); + else echo('
Theme data updated.
'); + } + elseif(isset($_POST['up'])) { + // If there is only one theme or if the selected theme is already at the top, do nothing + $q = 'SELECT theme_order FROM '.table_prefix.'themes ORDER BY theme_order;'; + $s = $db->sql_query($q); + if(!$s) die('Error selecting order information: '.mysql_error().'
SQL:
'.$q); + $q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\''; + $sn = $db->sql_query($q); + if(!$sn) die('Error selecting order information: '.mysql_error().'
SQL:
'.$q); + $r = $db->fetchrow_num($sn); + if( /* check for only one theme... */ $db->numrows($s) < 2 || $r[0] == 1 /* ...and check if this theme is already at the top */ ) { echo('
This theme is already at the top of the list, or there is only one theme installed.
'); } else { + // Get the order IDs of the selected theme and the theme before it + $q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\''; + $s = $db->sql_query($q); + if(!$s) die('Error selecting order information: '.mysql_error().'
SQL:
'.$q); + $r = $db->fetchrow_num($s); + $r = $r[0]; + $rb = $r - 1; + // Thank God for jEdit's rectangular selection and the ablity to edit multiple lines at the same time ;) + $q = 'UPDATE '.table_prefix.'themes SET theme_order=0 WHERE theme_order='.$rb.''; /* Check for errors... */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'
SQL:
'.$q); + $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$rb.' WHERE theme_order='.$r.''; /* Check for errors... */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'
SQL:
'.$q); + $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$r.' WHERE theme_order=0'; /* Check for errors... */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'
SQL:
'.$q); + echo('
Theme moved up.
'); + } + $db->free_result($s); + $db->free_result($sn); + } + elseif(isset($_POST['down'])) { + // If there is only one theme or if the selected theme is already at the top, do nothing + $q = 'SELECT theme_order FROM '.table_prefix.'themes ORDER BY theme_order;'; + $s = $db->sql_query($q); + if(!$s) die('Error selecting order information: '.mysql_error().'
SQL:
'.$q); + $r = $db->fetchrow_num($s); + 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('
This theme is already at the bottom of the list, or there is only one theme installed.
'); } else { + // Get the order IDs of the selected theme and the theme before it + $q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\''; + $s = $db->sql_query($q); + if(!$s) die('Error selecting order information: '.mysql_error().'
SQL:
'.$q); + $r = $db->fetchrow_num($s); + $r = $r[0]; + $rb = $r + 1; + // Thank God for jEdit's rectangular selection and the ablity to edit multiple lines at the same time ;) + $q = 'UPDATE '.table_prefix.'themes SET theme_order=0 WHERE theme_order='.$rb.''; /* Check for errors... */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'
SQL:
'.$q); + $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$rb.' WHERE theme_order='.$r.''; /* Check for errors... */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'
SQL:
'.$q); + $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$r.' WHERE theme_order=0'; /* Check for errors... */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'
SQL:
'.$q); + echo('
Theme moved down.
'); + } + } + else if(isset($_POST['uninstall'])) + { + $q = 'SELECT * FROM '.table_prefix.'themes;'; + $s = $db->sql_query($q); + if ( !$s ) + { + die('Error getting theme count: '.mysql_error().'
SQL:
'.$q); + } + $n = $db->numrows($s); + $db->free_result(); + + if ( $_POST['theme_id'] == 'oxygen' ) + { + echo '
The Oxygen theme is used by Enano for installation, upgrades, and error messages, and cannot be uninstalled.
'; + } + else + { + if($n < 2) + { + echo '
The theme could not be uninstalled because it is the only theme left.
'; + } + else + { + $q = 'DELETE FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\' LIMIT 1;'; + $s = $db->sql_query($q); + if ( !$s ) + { + die('Error deleting theme data: '.mysql_error().'
SQL:
'.$q); + } + else + { + echo('
Theme uninstalled.
'); + } + } + } + } + elseif(isset($_POST['install'])) { + $q = 'SELECT theme_id FROM '.table_prefix.'themes;'; + $s = $db->sql_query($q); + if(!$s) die('Error getting theme count: '.mysql_error().'
SQL:
'.$q); + $n = $db->numrows($s); + $n++; + $theme_id = $_POST['theme_id']; + $theme = Array(); + include('./themes/'.$theme_id.'/theme.cfg'); + if ( !isset($theme['theme_id']) ) + { + echo '
Could not load theme.cfg (theme metadata file)
'; + } + else + { + $default_style = false; + if ( $dh = opendir('./themes/' . $theme_id . '/css') ) + { + while ( $file = readdir($dh) ) + { + if ( $file != '_printable.css' && preg_match('/\.css$/i', $file) ) + { + $default_style = $file; + break; + } + } + closedir($dh); + } + else + { + die('The /css subdirectory could not be located in the theme\'s directory'); + } + + if ( $default_style ) + { + $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) . '\')'; + $s = $db->sql_query($q); + if(!$s) die('Error inserting theme data: '.mysql_error().'
SQL:
'.$q); + else echo('
Theme "'.$theme['theme_name'].'" installed.
'); + } + else + { + echo '
Could not determine the default style for the theme.
'; + } + } + } + echo(' +

Currently installed themes

+
+

+

-

The Enano system markup language is somewhat similar to HTML, in that it uses tags (<example>like this</example>) for the - main syntax. However, Enano uses curly brackets ({ and }) as opposed to less-than and greater-than signs (< and >).

-

Programming the Enano sidebar requires the use of two tags: {slider} and {if}. The {slider} tag is used to create a new heading - 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, - use an equals sign (=) after the "slider" text. Then insert any links (they should be wiki-formatted) to internal Enano pages and - external sites.

-

So here is what the language for the default sidebar's "Navigation" heading looks like:

-
{slider=Navigation}
-  [[Main Page|Home]]
-  [[Enano:Sidebar|Edit the sidebar]]
-{/slider}
-

Pretty simple, huh? Good, now we're going to learn another common aspect of Enano programming: conditionals. The {if} tag allows you - to decide whether a portion of the sidebar will be displayed based on a template variable. Currently the only available conditions are - "user_logged_in" and "auth_admin", but more will be added soon. To use a conditional, enter {if conditional_name}, and then the - 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 - effect with {!if}. With {!if}, the closing tag is still {/if}, so keep that in mind. An {else} tag will be supported soon.

-

Now it's time for some real fun: variables. All template variables can be accessed from the sidebar. A variable is simply the - variable name, prefixed by a dollar sign ($). Some of the most common variables are $USERNAME, $SITE_NAME, $SITE_DESC, and $PAGE_NAME. - 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 - the "change theme" button can be added with $STYLE_LINK.

-

So here is the Enano markup for the portion of the sidebar that contains the user tools:

-
{slider=$USERNAME}
-  [[User:$USERNAME|User page]]
-  [[Special:Contributions?user=$USERNAME|My Contributions]]
-  {if user_logged_in}
-    [[Special:Preferences|Preferences]]
-    $THEME_LINK
-  {/if}
-  {if auth_admin}
-    [[Special:Administration|Administration]]
-  {/if}
-  {if user_logged_in}
-    $LOGOUT_LINK
-  {/if}
-  {!if user_logged_in}
-    Create an account
-    Log in
-  {/if}
-{/slider}
- +

Install a new theme

+ '); + $theme = Array(); + $obb = ''; + for($i=0;$isql_query($q); + if(!$s) die('Error selecting list of currently installed themes: '.mysql_error().'
Attempted SQL:
'.$q); + if($db->numrows($s) < 1) { + $obb .= ''; + } + $db->free_result(); + } + } + if($obb != '') { + echo('

'); + echo(''); + echo(' + +

'); + } else echo('

All themes are currently installed.

'); } function page_Admin_GroupManager() @@ -1523,574 +2351,6 @@ } -function page_Admin_PageManager() -{ - global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; - if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) - { - $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true); - echo '

' . $lang->get('adm_err_not_auth_title') . '

'; - echo '

' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '

'; - return; - } - - - echo '

Page management

'; - - if(isset($_POST['search']) || isset($_POST['select']) || ( isset($_GET['source']) && $_GET['source'] == 'ajax' )) { - // The object of the game: using only the text a user entered, guess the page ID and namespace. *sigh* I HATE writing search algorithms... - $source = ( isset($_GET['source']) ) ? $_GET['source'] : false; - if ( $source == 'ajax' ) - { - $_POST['search'] = true; - $_POST['page_url'] = $_GET['page_id']; - } - if(isset($_POST['search'])) $pid = $_POST['page_url']; - elseif(isset($_POST['select'])) $pid = $_POST['page_force_url']; - else { echo 'Internal error selecting page search terms'; return false; } - // Look for a namespace prefix in the urlname, and assign a different namespace, if necessary - $k = array_keys($paths->nslist); - for($i=0;$inslist);$i++) - { - $ln = strlen($paths->nslist[$k[$i]]); - if(substr($pid, 0, $ln) == $paths->nslist[$k[$i]]) - { - $ns = $k[$i]; - $page_id = substr($pid, $ln, strlen($pid)); - } - } - // The namespace is in $ns and the page name or ID (we don't know which yet) is in $page_id - // Now, iterate through $paths->pages searching for a page with this name or ID - for($i=0;$ipages)/2;$i++) - { - if(!isset($final_pid)) - { - if ($paths->pages[$i]['urlname_nons'] == str_replace(' ', '_', $page_id)) $final_pid = str_replace(' ', '_', $page_id); - elseif($paths->pages[$i]['name'] == $page_id) $final_pid = $paths->pages[$i]['urlname_nons']; - elseif(strtolower($paths->pages[$i]['urlname_nons']) == strtolower(str_replace(' ', '_', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons']; - elseif(strtolower($paths->pages[$i]['name']) == strtolower(str_replace('_', ' ', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons']; - if(isset($final_pid)) { $_POST['name'] = $paths->pages[$i]['name']; $_POST['urlname'] = $paths->pages[$i]['urlname_nons']; } - } - } - if(!isset($final_pid)) { echo 'The page you searched for cannot be found. Back'; return false; } - $_POST['namespace'] = $ns; - $_POST['old_namespace'] = $ns; - $_POST['page_id'] = $final_pid; - $_POST['old_page_id'] = $final_pid; - if(!isset($paths->pages[$paths->nslist[$_POST['namespace']].$_POST['urlname']])) { echo 'The page you searched for cannot be found. Back'; return false; } - } - - if(isset($_POST['page_id']) && isset($_POST['namespace']) && !isset($_POST['cancel'])) - { - $cpage = $paths->pages[$paths->nslist[$_POST['old_namespace']].$_POST['old_page_id']]; - if(isset($_POST['submit'])) - { - switch(true) - { - case true: - // Create a list of things to update - $page_info = Array( - 'name'=>$_POST['name'], - 'urlname'=>sanitize_page_id($_POST['page_id']), - 'namespace'=>$_POST['namespace'], - 'special'=>isset($_POST['special']) ? '1' : '0', - 'visible'=>isset($_POST['visible']) ? '1' : '0', - 'comments_on'=>isset($_POST['comments_on']) ? '1' : '0', - 'protected'=>isset($_POST['protected']) ? '1' : '0' - ); - - $updating_urlname_or_namespace = ( $page_info['namespace'] != $cpage['namespace'] || $page_info['urlname'] != $cpage['urlname_nons'] ); - - if ( !isset($paths->nslist[ $page_info['namespace'] ]) ) - { - echo '
The namespace you selected is not properly registered.
'; - break; - } - if ( isset($paths->pages[ $paths->nslist[$page_info['namespace']] . $page_info[ 'urlname' ] ]) && $updating_urlname_or_namespace ) - { - echo '
There is already a page that exists with that URL string and namespace.
'; - break; - } - // Build the query - $q = 'UPDATE '.table_prefix.'pages SET '; - $k = array_keys($page_info); - foreach($k as $c) - { - $q .= $c.'=\''.$db->escape($page_info[$c]).'\','; - } - $q = substr($q, 0, strlen($q)-1); - // Build the WHERE statements - $q .= ' WHERE '; - $k = array_keys($cpage); - if ( !isset($cpage) ) - die('[internal] no cpage'); - foreach($k as $c) - { - if($c != 'urlname_nons' && $c != 'urlname' && $c != 'really_protected') - { - $q .= $c.'=\''.$db->escape($cpage[$c]).'\' AND '; - } - else if($c == 'urlname') - { - $q .= $c.'=\''.$db->escape($cpage['urlname_nons']).'\' AND '; - } - } - // Trim off the last " AND " and append a semicolon - $q = substr($q, 0, strlen($q)-5) . ';'; - // Send the completed query to MySQL - $e = $db->sql_query($q); - if(!$e) $db->_die('The page data could not be updated.'); - // Update any additional tables - $q = Array( - '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']) . '\';', - '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']) . '\';', - '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']) . '\';', - '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']) . '\';', - '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']) . '\';' - ); - foreach($q as $cq) - { - $e = $db->sql_query($cq); - if(!$e) $db->_die('Some of the additional tables containing page information could not be updated.'); - } - // Update $cpage - $cpage = $page_info; - $cpage['urlname_nons'] = $cpage['urlname']; - $cpage['urlname'] = $paths->nslist[$cpage['namespace']].$cpage['urlname']; - $_POST['old_page_id'] = $page_info['urlname']; - $_POST['old_namespace'] = $page_info['namespace']; - echo '
Your changes have been saved.
'; - break; - } - } elseif(isset($_POST['delete'])) { - $q = Array( - 'DELETE FROM '.table_prefix.'categories WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', - 'DELETE FROM '.table_prefix.'comments WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', - 'DELETE FROM '.table_prefix.'logs WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', - 'DELETE FROM '.table_prefix.'page_text WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', - ); - foreach($q as $cq) - { - $e = $db->sql_query($cq); - if(!$e) $db->_die('Some of the additional tables containing page information could not be updated.'); - } - - if(!$db->sql_query( - 'DELETE FROM '.table_prefix.'pages WHERE urlname="'.$db->escape($_POST['old_page_id']).'" AND namespace="'.$db->escape($_POST['old_namespace']).'";' - )) $db->_die('The page could not be deleted.'); - echo '
This page has been deleted.

Return to Page manager
Admin home

'; - return; - } - $url = makeUrlNS('Special', 'Administration', 'module='.$paths->cpage['module'], true); - echo '
'; - ?> -

Modify page:

- - - - - - - - - - - -
Namespace:
Page title:
Page URL string:
No spaces, and don't enter the namespace prefix (e.g. User:).
Changing this value is usually not a good idea, especially for templates and project pages.
name="comments_on" type="checkbox" id="cmt" />
name="special" type="checkbox" id="spc" />
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.
name="visible" type="checkbox" id="vis" />
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 nslist['Special']; ?>SearchRebuild.
name="protected" type="checkbox" id="prt" />
This option only has an effect when Wiki Mode is enabled.

- - -
- '; - } else { - echo '

Please select a page

'; - echo ''; - ?> -

Search for page title (remember prefixes like User: and File:) pagename_field('page_url'); ?>

-

Select page title from a list:

- '; - - } -} - -function page_Admin_PageEditor() -{ - global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; - if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) - { - $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true); - echo '

' . $lang->get('adm_err_not_auth_title') . '

'; - echo '

' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '

'; - return; - } - - - echo '

Edit page content

'; - - if(isset($_POST['search']) || isset($_POST['select'])) { - // The object of the game: using only the text a user entered, guess the page ID and namespace. *sigh* I HATE writing search algorithms... - if(isset($_POST['search'])) $pid = $_POST['page_url']; - elseif(isset($_POST['select'])) $pid = $_POST['page_force_url']; - else { echo 'Internal error selecting page search terms'; return false; } - // Look for a namespace prefix in the urlname, and assign a different namespace, if necessary - $k = array_keys($paths->nslist); - for($i=0;$inslist);$i++) - { - $ln = strlen($paths->nslist[$k[$i]]); - if(substr($pid, 0, $ln) == $paths->nslist[$k[$i]]) - { - $ns = $k[$i]; - $page_id = substr($pid, $ln, strlen($pid)); - } - } - // The namespace is in $ns and the page name or ID (we don't know which yet) is in $page_id - // Now, iterate through $paths->pages searching for a page with this name or ID - for($i=0;$ipages)/2;$i++) - { - if(!isset($final_pid)) - { - if ($paths->pages[$i]['urlname_nons'] == str_replace(' ', '_', $page_id)) $final_pid = str_replace(' ', '_', $page_id); - elseif($paths->pages[$i]['name'] == $page_id) $final_pid = $paths->pages[$i]['urlname_nons']; - elseif(strtolower($paths->pages[$i]['urlname_nons']) == strtolower(str_replace(' ', '_', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons']; - elseif(strtolower($paths->pages[$i]['name']) == strtolower(str_replace('_', ' ', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons']; - if(isset($final_pid)) { $_POST['name'] = $paths->pages[$i]['name']; $_POST['urlname'] = $paths->pages[$i]['urlname_nons']; } - } - } - if(!isset($final_pid)) { echo 'The page you searched for cannot be found. Back'; return false; } - $_POST['namespace'] = $ns; - $_POST['page_id'] = $final_pid; - if(!isset($paths->pages[$paths->nslist[$_POST['namespace']].$_POST['urlname']])) { echo 'The page you searched for cannot be found. Back'; return false; } - } - - if(isset($_POST['page_id']) && !isset($_POST['cancel'])) - { - echo ''; - if(!isset($_POST['content']) || isset($_POST['revert'])) $content = RenderMan::getPage($_POST['page_id'], $_POST['namespace'], 0, false, false, false, false); - else $content = $_POST['content']; - if(isset($_POST['save'])) - { - $data = $content; - $id = md5( microtime() . mt_rand() ); - - $minor = isset($_POST['minor']) ? 'true' : 'false'; - $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']) . '\', \''.$db->escape($data).'\', \''.$id.'\', \''.$session->username.'\', \''.$db->escape(htmlspecialchars($_POST['summary'])).'\', '.$minor.');'; - if(!$db->sql_query($q)) $db->_die('The history (log) entry could not be inserted into the logs table.'); - - $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']) . '\';'; - $e = $db->sql_query($query); - if(!$e) echo '
The page data could not be saved. MySQL said: '.mysql_error().'

Query:
'.$query.'
'; - else echo '
Your page has been saved. View page...
'; - } elseif(isset($_POST['preview'])) { - echo '

Preview

Reminder: This is only a preview; your changes to this page have not yet been saved.

'.RenderMan::render($content).'
'; - } - ?> -

-
- Edit summary:
- -

-

- - -        -

- '; - } else { - echo '

Please select a page

'; - echo ''; - ?> -

Search for page title (remember prefixes like User: and File:) pagename_field('page_url'); ?>

-

Select page title from a list:

- '; - } -} - -function page_Admin_ThemeManager() -{ - - global $db, $session, $paths, $template, $plugins; // Common objects - global $lang; - if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) - { - $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true); - echo '

' . $lang->get('adm_err_not_auth_title') . '

'; - echo '

' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '

'; - return; - } - - - // Get the list of styles in the themes/ dir - $h = opendir('./themes'); - $l = Array(); - if(!$h) die('Error opening directory "./themes" for reading.'); - while(false !== ($n = readdir($h))) { - if($n != '.' && $n != '..' && is_dir('./themes/'.$n)) - $l[] = $n; - } - closedir($h); - echo(' -

Theme Management

-

Install, uninstall, and manage Enano themes.

- '); - if(isset($_POST['disenable'])) { - $q = 'SELECT enabled FROM '.table_prefix.'themes WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\''; - $s = $db->sql_query($q); - if(!$s) die('Error selecting enabled/disabled state value: '.mysql_error().'
SQL:
'.$q); - $r = $db->fetchrow_num($s); - $db->free_result(); - if($r[0] == 1) $e = 0; - else $e = 1; - $s=true; - if($e==0) - { - $c = $db->sql_query('SELECT * FROM '.table_prefix.'themes WHERE enabled=1'); - if(!$c) $db->_die('The backup check for having at least on theme enabled failed.'); - if($db->numrows() <= 1) { echo '
You cannot disable the last remaining theme.
'; $s=false; } - } - $db->free_result(); - if($s) { - $q = 'UPDATE '.table_prefix.'themes SET enabled='.$e.' WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\''; - $a = $db->sql_query($q); - if(!$a) die('Error updating enabled/disabled state value: '.mysql_error().'
SQL:
'.$q); - else echo('
The theme "'.$_POST['theme_id'].'" has been '. ( ( $e == '1' ) ? 'enabled' : 'disabled' ).'.
'); - } - } - elseif(isset($_POST['edit'])) { - - $dir = './themes/'.$_POST['theme_id'].'/css/'; - $list = Array(); - // Open a known directory, and proceed to read its contents - if (is_dir($dir)) { - if ($dh = opendir($dir)) { - while (($file = readdir($dh)) !== false) { - if(preg_match('#^(.*?)\.css$#is', $file) && $file != '_printable.css') { - $list[$file] = capitalize_first_letter(substr($file, 0, strlen($file)-4)); - } - } - closedir($dh); - } - } - $lk = array_keys($list); - - $q = 'SELECT theme_name,default_style FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\''; - $s = $db->sql_query($q); - if(!$s) die('Error selecting name value: '.mysql_error().'
SQL:
'.$q); - $r = $db->fetchrow_num($s); - $db->free_result(); - echo(''); - echo('
- Theme name displayed to users:

- Default stylesheet:

- -
'); - echo(''); - } - elseif(isset($_POST['editsave'])) { - $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']) . '\''; - $s = $db->sql_query($q); - if(!$s) die('Error updating name value: '.mysql_error().'
SQL:
'.$q); - else echo('
Theme data updated.
'); - } - elseif(isset($_POST['up'])) { - // If there is only one theme or if the selected theme is already at the top, do nothing - $q = 'SELECT theme_order FROM '.table_prefix.'themes ORDER BY theme_order;'; - $s = $db->sql_query($q); - if(!$s) die('Error selecting order information: '.mysql_error().'
SQL:
'.$q); - $q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\''; - $sn = $db->sql_query($q); - if(!$sn) die('Error selecting order information: '.mysql_error().'
SQL:
'.$q); - $r = $db->fetchrow_num($sn); - if( /* check for only one theme... */ $db->numrows($s) < 2 || $r[0] == 1 /* ...and check if this theme is already at the top */ ) { echo('
This theme is already at the top of the list, or there is only one theme installed.
'); } else { - // Get the order IDs of the selected theme and the theme before it - $q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\''; - $s = $db->sql_query($q); - if(!$s) die('Error selecting order information: '.mysql_error().'
SQL:
'.$q); - $r = $db->fetchrow_num($s); - $r = $r[0]; - $rb = $r - 1; - // Thank God for jEdit's rectangular selection and the ablity to edit multiple lines at the same time ;) - $q = 'UPDATE '.table_prefix.'themes SET theme_order=0 WHERE theme_order='.$rb.''; /* Check for errors... */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'
SQL:
'.$q); - $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$rb.' WHERE theme_order='.$r.''; /* Check for errors... */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'
SQL:
'.$q); - $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$r.' WHERE theme_order=0'; /* Check for errors... */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'
SQL:
'.$q); - echo('
Theme moved up.
'); - } - $db->free_result($s); - $db->free_result($sn); - } - elseif(isset($_POST['down'])) { - // If there is only one theme or if the selected theme is already at the top, do nothing - $q = 'SELECT theme_order FROM '.table_prefix.'themes ORDER BY theme_order;'; - $s = $db->sql_query($q); - if(!$s) die('Error selecting order information: '.mysql_error().'
SQL:
'.$q); - $r = $db->fetchrow_num($s); - 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('
This theme is already at the bottom of the list, or there is only one theme installed.
'); } else { - // Get the order IDs of the selected theme and the theme before it - $q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\''; - $s = $db->sql_query($q); - if(!$s) die('Error selecting order information: '.mysql_error().'
SQL:
'.$q); - $r = $db->fetchrow_num($s); - $r = $r[0]; - $rb = $r + 1; - // Thank God for jEdit's rectangular selection and the ablity to edit multiple lines at the same time ;) - $q = 'UPDATE '.table_prefix.'themes SET theme_order=0 WHERE theme_order='.$rb.''; /* Check for errors... */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'
SQL:
'.$q); - $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$rb.' WHERE theme_order='.$r.''; /* Check for errors... */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'
SQL:
'.$q); - $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$r.' WHERE theme_order=0'; /* Check for errors... */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'
SQL:
'.$q); - echo('
Theme moved down.
'); - } - } - else if(isset($_POST['uninstall'])) - { - $q = 'SELECT * FROM '.table_prefix.'themes;'; - $s = $db->sql_query($q); - if ( !$s ) - { - die('Error getting theme count: '.mysql_error().'
SQL:
'.$q); - } - $n = $db->numrows($s); - $db->free_result(); - - if ( $_POST['theme_id'] == 'oxygen' ) - { - echo '
The Oxygen theme is used by Enano for installation, upgrades, and error messages, and cannot be uninstalled.
'; - } - else - { - if($n < 2) - { - echo '
The theme could not be uninstalled because it is the only theme left.
'; - } - else - { - $q = 'DELETE FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\' LIMIT 1;'; - $s = $db->sql_query($q); - if ( !$s ) - { - die('Error deleting theme data: '.mysql_error().'
SQL:
'.$q); - } - else - { - echo('
Theme uninstalled.
'); - } - } - } - } - elseif(isset($_POST['install'])) { - $q = 'SELECT theme_id FROM '.table_prefix.'themes;'; - $s = $db->sql_query($q); - if(!$s) die('Error getting theme count: '.mysql_error().'
SQL:
'.$q); - $n = $db->numrows($s); - $n++; - $theme_id = $_POST['theme_id']; - $theme = Array(); - include('./themes/'.$theme_id.'/theme.cfg'); - if ( !isset($theme['theme_id']) ) - { - echo '
Could not load theme.cfg (theme metadata file)
'; - } - else - { - $default_style = false; - if ( $dh = opendir('./themes/' . $theme_id . '/css') ) - { - while ( $file = readdir($dh) ) - { - if ( $file != '_printable.css' && preg_match('/\.css$/i', $file) ) - { - $default_style = $file; - break; - } - } - closedir($dh); - } - else - { - die('The /css subdirectory could not be located in the theme\'s directory'); - } - - if ( $default_style ) - { - $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) . '\')'; - $s = $db->sql_query($q); - if(!$s) die('Error inserting theme data: '.mysql_error().'
SQL:
'.$q); - else echo('
Theme "'.$theme['theme_name'].'" installed.
'); - } - else - { - echo '
Could not determine the default style for the theme.
'; - } - } - } - echo(' -

Currently installed themes

-
-

- -

-
-

Install a new theme

- '); - $theme = Array(); - $obb = ''; - for($i=0;$isql_query($q); - if(!$s) die('Error selecting list of currently installed themes: '.mysql_error().'
Attempted SQL:
'.$q); - if($db->numrows($s) < 1) { - $obb .= ''; - } - $db->free_result(); - } - } - if($obb != '') { - echo('

'); - echo(''); - echo(' - -

'); - } else echo('

All themes are currently installed.

'); -} - function page_Admin_BanControl() { global $db, $session, $paths, $template, $plugins; // Common objects