diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2002-07-14 14:51:03 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2002-07-14 14:51:03 +0000 |
commit | fad21bcb01bdabaad234d812622555873fd48c4c (patch) | |
tree | d7e38f48c3df357721ba248048a1e9a2f0b895c4 /phpBB | |
parent | 71707ca5dba2110025ddb0634d0796bac23ea230 (diff) | |
download | forums-fad21bcb01bdabaad234d812622555873fd48c4c.tar forums-fad21bcb01bdabaad234d812622555873fd48c4c.tar.gz forums-fad21bcb01bdabaad234d812622555873fd48c4c.tar.bz2 forums-fad21bcb01bdabaad234d812622555873fd48c4c.tar.xz forums-fad21bcb01bdabaad234d812622555873fd48c4c.zip |
Hard-coded HTML into admin modules ... no point in continuing to template this stuff since no one (or few) rarely bother to make use of the feature. Lots of changes for permissions, sessions, etc. some new styling stuff present (inc. editing templates though not complete), lots of bugs and non-functioning stuff ... any 'existing' modules will cause the right hand panel to fail ... remove them. If I catch anyone nicking graphics from here I'll kill 'em ...
git-svn-id: file:///svn/phpbb/trunk@2675 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/admin/admin_board.php | 162 | ||||
-rw-r--r-- | phpBB/admin/admin_db_utilities.php | 749 | ||||
-rw-r--r-- | phpBB/admin/admin_email.php | 193 | ||||
-rw-r--r-- | phpBB/admin/admin_permissions.php | 253 | ||||
-rw-r--r-- | phpBB/admin/admin_prune.php | 200 | ||||
-rw-r--r-- | phpBB/admin/admin_search.php | 143 | ||||
-rw-r--r-- | phpBB/admin/admin_styles.php | 1128 | ||||
-rw-r--r-- | phpBB/admin/admin_users.php | 140 | ||||
-rw-r--r-- | phpBB/admin/admin_words.php | 283 | ||||
-rw-r--r-- | phpBB/admin/forms.css | 13 | ||||
-rw-r--r-- | phpBB/admin/images/cellpic1.gif | bin | 0 -> 246 bytes | |||
-rw-r--r-- | phpBB/admin/images/cellpic3.gif | bin | 0 -> 257 bytes | |||
-rw-r--r-- | phpBB/admin/images/header_bg.jpg | bin | 0 -> 385 bytes | |||
-rw-r--r-- | phpBB/admin/images/header_left.jpg | bin | 0 -> 6741 bytes | |||
-rw-r--r-- | phpBB/admin/index.php | 682 | ||||
-rw-r--r-- | phpBB/admin/page_footer_admin.php | 34 | ||||
-rw-r--r-- | phpBB/admin/page_header_admin.php | 125 | ||||
-rw-r--r-- | phpBB/admin/pagestart.php | 150 | ||||
-rw-r--r-- | phpBB/admin/subSilver.css | 2 |
19 files changed, 2090 insertions, 2167 deletions
diff --git a/phpBB/admin/admin_board.php b/phpBB/admin/admin_board.php index 56ddc946d7..ec5d4aeed1 100644 --- a/phpBB/admin/admin_board.php +++ b/phpBB/admin/admin_board.php @@ -8,120 +8,132 @@ * * $Id$ * - * ***************************************************************************/ -define('IN_PHPBB', 1); +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ -if( !empty($setmodules) ) +if ( !empty($setmodules) ) { + if ( !$acl->get_acl_admin('general') ) + { + return; + } + $file = basename(__FILE__); - $module['General']['Configuration'] = "$file?mode=config"; + $module['General']['Avatar_Setup'] = "$file?mode=avatars"; + $module['General']['Basic_Config'] = "$file?mode=basic"; + $module['General']['Cookie_Parameters'] = "$file?mode=cookies"; + $module['General']['Default_Settings'] = "$file?mode=gendefs"; + $module['Users']['Default_Settings'] = "$file?mode=userdefs"; return; } // // Let's set the root dir for phpBB // +define('IN_PHPBB', 1); $phpbb_root_path = "../"; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); -include($phpbb_root_path . 'includes/functions_selects.'.$phpEx); + +if ( !$acl->get_acl_admin('general') ) +{ + return; +} // // Pull all config data // $sql = "SELECT * FROM " . CONFIG_TABLE; -if(!$result = $db->sql_query($sql)) -{ - message_die(CRITICAL_ERROR, "Could not query config information in admin_board", "", __LINE__, __FILE__, $sql); -} -else +$result = $db->sql_query($sql); + +while ( $row = $db->sql_fetchrow($result) ) { - while( $row = $db->sql_fetchrow($result) ) + $config_name = $row['config_name']; + $config_value = $row['config_value']; + $default_config[$config_name] = $config_value; + + $new[$config_name] = ( isset($HTTP_POST_VARS[$config_name]) ) ? $HTTP_POST_VARS[$config_name] : $default_config[$config_name]; + + if ( isset($HTTP_POST_VARS['submit']) ) { - $config_name = $row['config_name']; - $config_value = $row['config_value']; - $default_config[$config_name] = $config_value; - - $new[$config_name] = ( isset($HTTP_POST_VARS[$config_name]) ) ? $HTTP_POST_VARS[$config_name] : $default_config[$config_name]; - - if( isset($HTTP_POST_VARS['submit']) ) - { - $sql = "UPDATE " . CONFIG_TABLE . " SET - config_value = '" . str_replace("\'", "''", $new[$config_name]) . "' - WHERE config_name = '$config_name'"; - if( !$db->sql_query($sql) ) - { - message_die(GENERAL_ERROR, "Failed to update general configuration for $config_name", "", __LINE__, __FILE__, $sql); - } - } + $sql = "UPDATE " . CONFIG_TABLE . " SET + config_value = '" . str_replace("\'", "''", $new[$config_name]) . "' + WHERE config_name = '$config_name'"; + $db->sql_query($sql); } +} - if( isset($HTTP_POST_VARS['submit']) ) - { - $message = $lang['Config_updated'] . "<br /><br />" . sprintf($lang['Click_return_config'], "<a href=\"" . append_sid("admin_board.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); +if ( isset($HTTP_POST_VARS['submit']) ) +{ + $message = $lang['Config_updated'] . "<br /><br />" . sprintf($lang['Click_return_config'], '<a href="' . "admin_board.$phpEx$SID" . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . "index.$phpEx$SID?pane=right" . '">', '</a>'); - message_die(GENERAL_MESSAGE, $message); - } + message_die(MESSAGE, $message); } -$style_select = style_select($new['default_style'], 'default_style', "../templates"); -$lang_select = language_select($new['default_lang'], 'default_lang', "../language"); +$style_select = style_select($new['default_style'], 'default_style', '../templates'); +$lang_select = language_select($new['default_lang'], 'default_lang', '../language'); $timezone_select = tz_select($new['board_timezone'], 'board_timezone'); -$disable_board_yes = ( $new['board_disable'] ) ? "checked=\"checked\"" : ""; -$disable_board_no = ( !$new['board_disable'] ) ? "checked=\"checked\"" : ""; +$disable_board_yes = ( $new['board_disable'] ) ? 'checked="checked"' : ''; +$disable_board_no = ( !$new['board_disable'] ) ? 'checked="checked"' : ''; -$cookie_secure_yes = ( $new['cookie_secure'] ) ? "checked=\"checked\"" : ""; -$cookie_secure_no = ( !$new['cookie_secure'] ) ? "checked=\"checked\"" : ""; +$cookie_secure_yes = ( $new['cookie_secure'] ) ? 'checked="checked"' : ''; +$cookie_secure_no = ( !$new['cookie_secure'] ) ? 'checked="checked"' : ''; $html_tags = $new['allow_html_tags']; -$override_user_style_yes = ( $new['override_user_style'] ) ? "checked=\"checked\"" : ""; -$override_user_style_no = ( !$new['override_user_style'] ) ? "checked=\"checked\"" : ""; +$override_user_style_yes = ( $new['override_user_style'] ) ? 'checked="checked"' : ''; +$override_user_style_no = ( !$new['override_user_style'] ) ? 'checked="checked"' : ''; -$html_yes = ( $new['allow_html'] ) ? "checked=\"checked\"" : ""; -$html_no = ( !$new['allow_html'] ) ? "checked=\"checked\"" : ""; +$html_yes = ( $new['allow_html'] ) ? 'checked="checked"' : ''; +$html_no = ( !$new['allow_html'] ) ? 'checked="checked"' : ''; -$bbcode_yes = ( $new['allow_bbcode'] ) ? "checked=\"checked\"" : ""; -$bbcode_no = ( !$new['allow_bbcode'] ) ? "checked=\"checked\"" : ""; +$bbcode_yes = ( $new['allow_bbcode'] ) ? 'checked="checked"' : ''; +$bbcode_no = ( !$new['allow_bbcode'] ) ? 'checked="checked"' : ''; -$activation_none = ( $new['require_activation'] == USER_ACTIVATION_NONE ) ? "checked=\"checked\"" : ""; -$activation_user = ( $new['require_activation'] == USER_ACTIVATION_SELF ) ? "checked=\"checked\"" : ""; -$activation_admin = ( $new['require_activation'] == USER_ACTIVATION_ADMIN ) ? "checked=\"checked\"" : ""; +$activation_none = ( $new['require_activation'] == USER_ACTIVATION_NONE ) ? 'checked="checked"' : ''; +$activation_user = ( $new['require_activation'] == USER_ACTIVATION_SELF ) ? 'checked="checked"' : ''; +$activation_admin = ( $new['require_activation'] == USER_ACTIVATION_ADMIN ) ? 'checked="checked"' : ''; -$board_email_form_yes = ( $new['board_email_form'] ) ? "checked=\"checked\"" : ""; -$board_email_form_no = ( !$new['board_email_form'] ) ? "checked=\"checked\"" : ""; +$board_email_form_yes = ( $new['board_email_form'] ) ? 'checked="checked"' : ''; +$board_email_form_no = ( !$new['board_email_form'] ) ? 'checked="checked"' : ''; -$gzip_yes = ( $new['gzip_compress'] ) ? "checked=\"checked\"" : ""; -$gzip_no = ( !$new['gzip_compress'] ) ? "checked=\"checked\"" : ""; +$gzip_yes = ( $new['gzip_compress'] ) ? 'checked="checked"' : ''; +$gzip_no = ( !$new['gzip_compress'] ) ? 'checked="checked"' : ''; -$privmsg_on = ( !$new['privmsg_disable'] ) ? "checked=\"checked\"" : ""; -$privmsg_off = ( $new['privmsg_disable'] ) ? "checked=\"checked\"" : ""; +$privmsg_on = ( !$new['privmsg_disable'] ) ? 'checked="checked"' : ''; +$privmsg_off = ( $new['privmsg_disable'] ) ? 'checked="checked"' : ''; -$prune_yes = ( $new['prune_enable'] ) ? "checked=\"checked\"" : ""; -$prune_no = ( !$new['prune_enable'] ) ? "checked=\"checked\"" : ""; +$prune_yes = ( $new['prune_enable'] ) ? 'checked="checked"' : ''; +$prune_no = ( !$new['prune_enable'] ) ? 'checked="checked"' : ''; -$smile_yes = ( $new['allow_smilies'] ) ? "checked=\"checked\"" : ""; -$smile_no = ( !$new['allow_smilies'] ) ? "checked=\"checked\"" : ""; +$smile_yes = ( $new['allow_smilies'] ) ? 'checked="checked"' : ''; +$smile_no = ( !$new['allow_smilies'] ) ? 'checked="checked"' : ''; -$sig_yes = ( $new['allow_sig'] ) ? "checked=\"checked\"" : ""; -$sig_no = ( !$new['allow_sig'] ) ? "checked=\"checked\"" : ""; +$sig_yes = ( $new['allow_sig'] ) ? 'checked="checked"' : ''; +$sig_no = ( !$new['allow_sig'] ) ? 'checked="checked"' : ''; -$namechange_yes = ( $new['allow_namechange'] ) ? "checked=\"checked\"" : ""; -$namechange_no = ( !$new['allow_namechange'] ) ? "checked=\"checked\"" : ""; +$namechange_yes = ( $new['allow_namechange'] ) ? 'checked="checked"' : ''; +$namechange_no = ( !$new['allow_namechange'] ) ? 'checked="checked"' : ''; -$avatars_local_yes = ( $new['allow_avatar_local'] ) ? "checked=\"checked\"" : ""; -$avatars_local_no = ( !$new['allow_avatar_local'] ) ? "checked=\"checked\"" : ""; -$avatars_remote_yes = ( $new['allow_avatar_remote'] ) ? "checked=\"checked\"" : ""; -$avatars_remote_no = ( !$new['allow_avatar_remote'] ) ? "checked=\"checked\"" : ""; -$avatars_upload_yes = ( $new['allow_avatar_upload'] ) ? "checked=\"checked\"" : ""; -$avatars_upload_no = ( !$new['allow_avatar_upload'] ) ? "checked=\"checked\"" : ""; +$avatars_local_yes = ( $new['allow_avatar_local'] ) ? 'checked="checked"' : ''; +$avatars_local_no = ( !$new['allow_avatar_local'] ) ? 'checked="checked"' : ''; +$avatars_remote_yes = ( $new['allow_avatar_remote'] ) ? 'checked="checked"' : ''; +$avatars_remote_no = ( !$new['allow_avatar_remote'] ) ? 'checked="checked"' : ''; +$avatars_upload_yes = ( $new['allow_avatar_upload'] ) ? 'checked="checked"' : ''; +$avatars_upload_no = ( !$new['allow_avatar_upload'] ) ? 'checked="checked"' : ''; -$smtp_yes = ( $new['smtp_delivery'] ) ? "checked=\"checked\"" : ""; -$smtp_no = ( !$new['smtp_delivery'] ) ? "checked=\"checked\"" : ""; +$smtp_yes = ( $new['smtp_delivery'] ) ? 'checked="checked"' : ''; +$smtp_no = ( !$new['smtp_delivery'] ) ? 'checked="checked"' : ''; $template->set_filenames(array( "body" => "admin/board_config_body.tpl") @@ -131,10 +143,8 @@ $template->set_filenames(array( // Escape any quotes in the site description for proper display in the text // box on the admin page // -$new['site_desc'] = str_replace('"', '"', $new['site_desc']); -$new['sitename'] = str_replace('"', '"', strip_tags($new['sitename'])); $template->assign_vars(array( - "S_CONFIG_ACTION" => append_sid("admin_board.$phpEx"), + "S_CONFIG_ACTION" => "admin_board.$phpEx$SID", "L_YES" => $lang['Yes'], "L_NO" => $lang['No'], @@ -232,8 +242,8 @@ $template->assign_vars(array( "SERVER_NAME" => $new['server_name'], "SCRIPT_PATH" => $new['script_path'], "SERVER_PORT" => $new['server_port'], - "SITENAME" => $new['sitename'], - "SITE_DESCRIPTION" => $new['site_desc'], + "SITENAME" => htmlentities($new['sitename']), + "SITE_DESCRIPTION" => htmlentities($new['site_desc']), "S_DISABLE_BOARD_YES" => $disable_board_yes, "S_DISABLE_BOARD_NO" => $disable_board_no, "ACTIVATION_NONE" => USER_ACTIVATION_NONE, @@ -309,8 +319,6 @@ $template->assign_vars(array( "COPPA_FAX" => $new['coppa_fax']) ); -$template->pparse("body"); - include('page_footer_admin.'.$phpEx); -?> +?>
\ No newline at end of file diff --git a/phpBB/admin/admin_db_utilities.php b/phpBB/admin/admin_db_utilities.php index 00762f567c..e1599fb272 100644 --- a/phpBB/admin/admin_db_utilities.php +++ b/phpBB/admin/admin_db_utilities.php @@ -30,21 +30,20 @@ define('IN_PHPBB', 1); -if( !empty($setmodules) ) +if ( !empty($setmodules) ) { - $filename = basename(__FILE__); - $module['General']['Backup_DB'] = $filename . "?perform=backup"; - if(@phpversion() >= '4.0.0') - { - $file_uploads = @ini_get('file_uploads'); - } - else + if ( !$acl->get_acl_admin('general') ) { - $file_uploads = @get_cfg_var('file_uploads'); + return; } + + $filename = basename(__FILE__); + $module['DB']['DB_Backup'] = $filename . "?perform=backup"; + + $file_uploads = @ini_get('file_uploads'); if( ($file_uploads != 0 || empty($file_uploads)) && (strtolower($file_uploads) != 'off') && (@phpversion() != '4.0.4pl1') ) { - $module['General']['Restore_DB'] = $filename . "?perform=restore"; + $module['DB']['DB_Restore'] = $filename . "?perform=restore"; } return; @@ -57,12 +56,12 @@ $no_page_header = TRUE; $phpbb_root_path = "../"; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); -include($phpbb_root_path . 'includes/sql_parse.'.$phpEx); +include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); -// -// Set VERBOSE to 1 for debugging info.. -// -define("VERBOSE", 0); +if ( !$acl->get_acl_admin('general') ) +{ + message_die(MESSAGE, $lang['No_admin']); +} // // Increase maximum execution time, but don't complain about it if it isn't @@ -70,6 +69,364 @@ define("VERBOSE", 0); // @set_time_limit(1200); +// +// Begin program proper +// + +if ( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) ) +{ + $perform = ( isset($HTTP_POST_VARS['perform']) ) ? $HTTP_POST_VARS['perform'] : $HTTP_GET_VARS['perform']; + + switch($perform) + { + case 'backup': + + if ( SQL_LAYER == 'oracle' || SQL_LAYER == 'odbc' || SQL_LAYER == 'mssql' ) + { + switch ( SQL_LAYER ) + { + case 'oracle': + $db_type = 'Oracle'; + break; + case 'odbc': + $db_type = 'ODBC'; + break; + case 'mssql': + $db_type = 'MSSQL'; + break; + } + + include('page_header_admin.'.$phpEx); + + $template->assign_vars(array( + "MESSAGE_TITLE" => $lang['Information'], + "MESSAGE_TEXT" => $lang['Backups_not_supported']) + ); + + break; + } + + $tables = array('auth_access', 'banlist', 'categories', 'config', 'disallow', 'forums', 'forum_prune', 'groups', 'posts', 'posts_text', 'privmsgs', 'privmsgs_text', 'ranks', 'search_results', 'search_results', 'search_wordlist', 'search_wordmatch', 'sessions', 'smilies', 'themes', 'themes_name', 'topics', 'topics_watch', 'user_group', 'users', 'vote_desc', 'vote_results', 'vote_voters', 'words'); + + $additional_tables = (isset($HTTP_POST_VARS['additional_tables'])) ? $HTTP_POST_VARS['additional_tables'] : ( ( isset($HTTP_GET_VARS['additional_tables']) ) ? $HTTP_GET_VARS['additional_tables'] : "" ); + + $backup_type = (isset($HTTP_POST_VARS['backup_type'])) ? $HTTP_POST_VARS['backup_type'] : ( ( isset($HTTP_GET_VARS['backup_type']) ) ? $HTTP_GET_VARS['backup_type'] : "" ); + + $gzipcompress = (!empty($HTTP_POST_VARS['gzipcompress'])) ? $HTTP_POST_VARS['gzipcompress'] : ( ( !empty($HTTP_GET_VARS['gzipcompress']) ) ? $HTTP_GET_VARS['gzipcompress'] : 0 ); + + if ( !empty($additional_tables) ) + { + if ( ereg(",", $additional_tables)) + { + $additional_tables = split(",", $additional_tables); + + for($i = 0; $i < count($additional_tables); $i++) + { + $tables[] = trim($additional_tables[$i]); + } + + } + else + { + $tables[] = trim($additional_tables); + } + } + + if ( !isset($HTTP_POST_VARS['backupstart']) && !isset($HTTP_GET_VARS['backupstart'])) + { + $s_hidden_fields = '<input type="hidden" name="perform" value="backup" /><input type="hidden" name="drop" value="1" /><input type="hidden" name="perform" value="$perform" />'; + + page_header($lang['DB']); +?> + +<h1><?php echo $lang['DB_Backup']; ?></h1> + +<p><?php echo $lang['Backup_explain']; ?></p> + +<form method="post" action="<?php echo "admin_db_utilities.$phpEx$SID"; ?>"><table cellspacing="1" cellpadding="4" border="0" align="center" bgcolor="#98AAB1"> + <tr> + <th colspan="2"><?php echo $lang['Backup_options']; ?></th> + </tr> + <tr> + <td class="row2"><?php echo $lang['Full_backup']; ?></td> + <td class="row2"><input type="radio" name="backup_type" value="full" checked /></td> + </tr> + <tr> + <td class="row1"><?php echo $lang['Structure_backup']; ?></td> + <td class="row1"><input type="radio" name="backup_type" value="structure" /></td> + </tr> + <tr> + <td class="row2"><?php echo $lang['Data_backup']; ?></td> + <td class="row2"><input type="radio" name="backup_type" value="data" /></td> + </tr> + <tr> + <td class="row1"><?php echo $lang['Additional_tables']; ?></td> + <td class="row1"><input type="text" name="additional_tables" /></td> + </tr> + <tr> + <td class="row1"><?php echo $lang['Gzip_compress']; ?></td> + <td class="row1"><?php echo $lang['No']; ?> <input type="radio" name="gzipcompress" value="0" checked /> <?php echo $lang['Yes']; ?> <input type="radio" name="gzipcompress" value="1" /></td> + </tr> + <tr> + <td class="cat" colspan="2" align="center"><?php echo $s_hidden_fields; ?><input type="submit" name="backupstart" value="<?php echo $lang['Start_backup']; ?>" class="mainoption" /></td> + </tr> +</table></form> + +<?php + + break; + + } + else if ( !isset($HTTP_POST_VARS['startdownload']) && !isset($HTTP_GET_VARS['startdownload']) ) + { + $template->assign_vars(array( + "META" => "<meta http-equiv=\"refresh\" content=\"0;url=admin_db_utilities.$phpEx?perform=backup&additional_tables=" . quotemeta($additional_tables) . "&backup_type=$backup_type&drop=1&backupstart=1&gzipcompress=$gzipcompress&startdownload=1\">", + + "MESSAGE_TITLE" => $lang['Database_Utilities'] . " : " . $lang['Backup'], + "MESSAGE_TEXT" => $lang['Backup_download']) + ); + + include('page_header_admin.php'); + + include('page_footer_admin.'.$phpEx); + + } + + header("Pragma: no-cache"); + $do_gzip_compress = FALSE; + + if( $gzipcompress ) + { + $phpver = phpversion(); + + if($phpver >= "4.0") + { + if(extension_loaded("zlib")) + { + $do_gzip_compress = TRUE; + } + } + } + if($do_gzip_compress) + { + @ob_start(); + @ob_implicit_flush(0); + header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.sql.gz\""); + header("Content-disposition: attachment; filename=phpbb_db_backup.sql.gz"); + } + else + { + header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.sql\""); + header("Content-disposition: attachment; filename=phpbb_db_backup.sql"); + } + + // + // Build the sql script file... + // + echo "#\n"; + echo "# phpBB Backup Script\n"; + echo "# Dump of tables for $dbname\n"; + echo "#\n# DATE : " . gmdate("d-m-Y H:i:s", time()) . " GMT\n"; + echo "#\n"; + + if(SQL_LAYER == 'postgresql') + { + echo "\n" . pg_get_sequences("\n", $backup_type); + } + for($i = 0; $i < count($tables); $i++) + { + $table_name = $tables[$i]; + if(SQL_LAYER != 'mysql4') + { + $table_def_function = "get_table_def_" . SQL_LAYER; + $table_content_function = "get_table_content_" . SQL_LAYER; + } + else + { + $table_def_function = "get_table_def_mysql"; + $table_content_function = "get_table_content_mysql"; + } + + if($backup_type != 'data') + { + echo "#\n# TABLE: " . $table_prefix . $table_name . "\n#\n"; + echo $table_def_function($table_prefix . $table_name, "\n") . "\n"; + } + + if($backup_type != 'structure') + { + $table_content_function($table_prefix . $table_name, "output_table_content"); + } + } + + if($do_gzip_compress) + { + $Size = ob_get_length(); + $Crc = crc32(ob_get_contents()); + $contents = gzcompress(ob_get_contents()); + ob_end_clean(); + echo "\x1f\x8b\x08\x00\x00\x00\x00\x00".substr($contents, 0, strlen($contents) - 4).gzip_PrintFourChars($Crc).gzip_PrintFourChars($Size); + } + exit; + + break; + + case 'restore': + + if ( !isset($restore_start) ) + { + $s_hidden_fields = '<input type="hidden" name="perform" value="restore" /><input type="hidden" name="perform" value="$perform" />'; + + page_header($lang['DB']); + +?> + +<h1><?php echo $lang['DB_Restore']; ?></h1> + +<p><?php echo $lang['Restore_explain']; ?></p> + +<form enctype="multipart/form-data" method="post" action="<?php echo "admin_db_utilities.$phpEx$SID"; ?>"><table cellspacing="1" cellpadding="4" border="0" align="center" bgcolor="#98AAB1"> + <tr> + <th class="th"><?php echo $lang['Select_file']; ?></th> + </tr> + <tr> + <td class="row1" align="center"><?php echo $s_hidden_fields; ?> <input type="file" name="backup_file"> <input type="submit" name="restore_start" value="<?php echo $lang['Start_Restore']; ?>" class="mainoption" /> </td> + </tr> +</table></form> + +<?php + + break; + + } + else + { + // + // Handle the file upload .... + // If no file was uploaded report an error... + // + $backup_file_name = (!empty($HTTP_POST_FILES['backup_file']['name'])) ? $HTTP_POST_FILES['backup_file']['name'] : ""; + $backup_file_tmpname = ($HTTP_POST_FILES['backup_file']['tmp_name'] != "none") ? $HTTP_POST_FILES['backup_file']['tmp_name'] : ""; + $backup_file_type = (!empty($HTTP_POST_FILES['backup_file']['type'])) ? $HTTP_POST_FILES['backup_file']['type'] : ""; + + if ( $backup_file_tmpname == "" || $backup_file_name == "" ) + { + message_die(MESSAGE, $lang['Restore_Error_no_file']); + } + // + // If I file was actually uploaded, check to make sure that we + // are actually passed the name of an uploaded file, and not + // a hackers attempt at getting us to process a local system + // file. + // + if( file_exists($backup_file_tmpname) ) + { + if( preg_match("/^(text\/[a-zA-Z]+)|(application\/(x\-)?gzip(\-compressed)?)|(application\/octet-stream)$/is", $backup_file_type) ) + { + if( preg_match("/\.gz$/is",$backup_file_name) ) + { + $do_gzip_compress = FALSE; + $phpver = phpversion(); + if($phpver >= "4.0") + { + if(extension_loaded("zlib")) + { + $do_gzip_compress = TRUE; + } + } + + if($do_gzip_compress) + { + $gz_ptr = gzopen($backup_file_tmpname, 'rb'); + $sql_query = ""; + while( !gzeof($gz_ptr) ) + { + $sql_query .= gzgets($gz_ptr, 100000); + } + } + else + { + include('page_header_admin.'.$phpEx); + message_die(ERROR, $lang['Restore_Error_decompress']); + } + } + else + { + $sql_query = fread(fopen($backup_file_tmpname, 'r'), filesize($backup_file_tmpname)); + } + // + // Comment this line out to see if this fixes the stuff... + // + //$sql_query = stripslashes($sql_query); + } + else + { + include('page_header_admin.'.$phpEx); + message_die(ERROR, $lang['Restore_Error_filename'] ." $backup_file_type $backup_file_name"); + } + } + else + { + include('page_header_admin.'.$phpEx); + message_die(ERROR, $lang['Restore_Error_uploading']); + } + + if($sql_query != "") + { + // Strip out sql comments... + $sql_query = remove_remarks($sql_query); + $pieces = split_sql_file($sql_query, ";"); + + $sql_count = count($pieces); + for($i = 0; $i < $sql_count; $i++) + { + $sql = trim($pieces[$i]); + + if(!empty($sql) and $sql[0] != "#") + { + if(DEBUG == 1) + { + echo "Executing: $sql\n<br>"; + flush(); + } + + $result = $db->sql_query($sql); + + if(!$result && ( !(SQL_LAYER == 'postgresql' && eregi("drop table", $sql) ) ) ) + { + //include('page_header_admin.'.$phpEx); + // echo "~~$sql~~"; + message_die(ERROR, "Error importing backup file", "", __LINE__, __FILE__, $sql); + } + } + } + } + + include('page_header_admin.'.$phpEx); + + $message = $lang['Restore_success']; + + $template->assign_vars(array( + "MESSAGE_TITLE" => $lang['Database_Utilities'] . " : " . $lang['Restore'], + "MESSAGE_TEXT" => $message) + ); + + break; + } + break; + } +} + +?> + + </td> + </tr> +</table> + +<?php + +page_footer(); + // ----------------------- // The following functions are adapted from phpMyAdmin and upgrade_20.php // @@ -83,8 +440,6 @@ function gzip_PrintFourChars($Val) return $return; } - - // // This function is used for grabbing the sequences for postgres... // @@ -410,10 +765,6 @@ function get_table_def_mysql($table, $crlf) // Get any Indexed fields from the database... // $result = $db->sql_query($key_query); - if(!$result) - { - message_die(GENERAL_ERROR, "FAILED IN get_table_def (show keys)", "", __LINE__, __FILE__, $key_query); - } while($row = $db->sql_fetchrow($result)) { @@ -667,358 +1018,4 @@ function output_table_content($content) // End Functions // ------------- - -// -// Begin program proper -// - -if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) ) -{ - $perform = (isset($HTTP_POST_VARS['perform'])) ? $HTTP_POST_VARS['perform'] : $HTTP_GET_VARS['perform']; - - switch($perform) - { - case 'backup': - - if( SQL_LAYER == 'oracle' || SQL_LAYER == 'odbc' || SQL_LAYER == 'mssql' ) - { - switch(SQL_LAYER) - { - case 'oracle': - $db_type = "Oracle"; - break; - case 'odbc': - $db_type = "ODBC"; - break; - case 'mssql': - $db_type = "MSSQL"; - break; - } - - include('page_header_admin.'.$phpEx); - - $template->set_filenames(array( - "body" => "admin/admin_message_body.tpl") - ); - - $template->assign_vars(array( - "MESSAGE_TITLE" => $lang['Information'], - "MESSAGE_TEXT" => $lang['Backups_not_supported']) - ); - - $template->pparse("body"); - - break; - } - - $tables = array('auth_access', 'banlist', 'categories', 'config', 'disallow', 'forums', 'forum_prune', 'groups', 'posts', 'posts_text', 'privmsgs', 'privmsgs_text', 'ranks', 'search_results', 'search_results', 'search_wordlist', 'search_wordmatch', 'sessions', 'smilies', 'themes', 'themes_name', 'topics', 'topics_watch', 'user_group', 'users', 'vote_desc', 'vote_results', 'vote_voters', 'words'); - - - $additional_tables = (isset($HTTP_POST_VARS['additional_tables'])) ? $HTTP_POST_VARS['additional_tables'] : ( (isset($HTTP_GET_VARS['additional_tables'])) ? $HTTP_GET_VARS['additional_tables'] : "" ); - - $backup_type = (isset($HTTP_POST_VARS['backup_type'])) ? $HTTP_POST_VARS['backup_type'] : ( (isset($HTTP_GET_VARS['backup_type'])) ? $HTTP_GET_VARS['backup_type'] : "" ); - - $gzipcompress = (!empty($HTTP_POST_VARS['gzipcompress'])) ? $HTTP_POST_VARS['gzipcompress'] : ( (!empty($HTTP_GET_VARS['gzipcompress'])) ? $HTTP_GET_VARS['gzipcompress'] : 0 ); - - if(!empty($additional_tables)) - { - if(ereg(",", $additional_tables)) - { - $additional_tables = split(",", $additional_tables); - - for($i = 0; $i < count($additional_tables); $i++) - { - $tables[] = trim($additional_tables[$i]); - } - - } - else - { - $tables[] = trim($additional_tables); - } - } - - if( !isset($HTTP_POST_VARS['backupstart']) && !isset($HTTP_GET_VARS['backupstart'])) - { - include('page_header_admin.'.$phpEx); - - $template->set_filenames(array( - "body" => "admin/db_utils_backup_body.tpl") - ); - - $s_hidden_fields = "<input type=\"hidden\" name=\"perform\" value=\"backup\" /><input type=\"hidden\" name=\"drop\" value=\"1\" /><input type=\"hidden\" name=\"perform\" value=\"$perform\" />"; - - $template->assign_vars(array( - "L_DATABASE_BACKUP" => $lang['Database_Utilities'] . " : " . $lang['Backup'], - "L_BACKUP_EXPLAIN" => $lang['Backup_explain'], - "L_FULL_BACKUP" => $lang['Full_backup'], - "L_STRUCTURE_BACKUP" => $lang['Structure_backup'], - "L_DATA_BACKUP" => $lang['Data_backup'], - "L_ADDITIONAL_TABLES" => $lang['Additional_tables'], - "L_START_BACKUP" => $lang['Start_backup'], - "L_BACKUP_OPTIONS" => $lang['Backup_options'], - "L_GZIP_COMPRESS" => $lang['Gzip_compress'], - "L_NO" => $lang['No'], - "L_YES" => $lang['Yes'], - - "S_HIDDEN_FIELDS" => $s_hidden_fields, - "S_DBUTILS_ACTION" => append_sid("admin_db_utilities.$phpEx")) - ); - $template->pparse("body"); - - break; - - } - else if( !isset($HTTP_POST_VARS['startdownload']) && !isset($HTTP_GET_VARS['startdownload']) ) - { - $template->set_filenames(array( - "body" => "admin/admin_message_body.tpl") - ); - - $template->assign_vars(array( - "META" => "<meta http-equiv=\"refresh\" content=\"0;url=admin_db_utilities.$phpEx?perform=backup&additional_tables=" . quotemeta($additional_tables) . "&backup_type=$backup_type&drop=1&backupstart=1&gzipcompress=$gzipcompress&startdownload=1\">", - - "MESSAGE_TITLE" => $lang['Database_Utilities'] . " : " . $lang['Backup'], - "MESSAGE_TEXT" => $lang['Backup_download']) - ); - - include('page_header_admin.php'); - - $template->pparse("body"); - - include('page_footer_admin.'.$phpEx); - - } - header("Pragma: no-cache"); - $do_gzip_compress = FALSE; - if( $gzipcompress ) - { - $phpver = phpversion(); - - if($phpver >= "4.0") - { - if(extension_loaded("zlib")) - { - $do_gzip_compress = TRUE; - } - } - } - if($do_gzip_compress) - { - @ob_start(); - @ob_implicit_flush(0); - header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.sql.gz\""); - header("Content-disposition: attachment; filename=phpbb_db_backup.sql.gz"); - } - else - { - header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.sql\""); - header("Content-disposition: attachment; filename=phpbb_db_backup.sql"); - } - - // - // Build the sql script file... - // - echo "#\n"; - echo "# phpBB Backup Script\n"; - echo "# Dump of tables for $dbname\n"; - echo "#\n# DATE : " . gmdate("d-m-Y H:i:s", time()) . " GMT\n"; - echo "#\n"; - - if(SQL_LAYER == 'postgresql') - { - echo "\n" . pg_get_sequences("\n", $backup_type); - } - for($i = 0; $i < count($tables); $i++) - { - $table_name = $tables[$i]; - if(SQL_LAYER != 'mysql4') - { - $table_def_function = "get_table_def_" . SQL_LAYER; - $table_content_function = "get_table_content_" . SQL_LAYER; - } - else - { - $table_def_function = "get_table_def_mysql"; - $table_content_function = "get_table_content_mysql"; - } - - if($backup_type != 'data') - { - echo "#\n# TABLE: " . $table_prefix . $table_name . "\n#\n"; - echo $table_def_function($table_prefix . $table_name, "\n") . "\n"; - } - - if($backup_type != 'structure') - { - $table_content_function($table_prefix . $table_name, "output_table_content"); - } - } - - if($do_gzip_compress) - { - $Size = ob_get_length(); - $Crc = crc32(ob_get_contents()); - $contents = gzcompress(ob_get_contents()); - ob_end_clean(); - echo "\x1f\x8b\x08\x00\x00\x00\x00\x00".substr($contents, 0, strlen($contents) - 4).gzip_PrintFourChars($Crc).gzip_PrintFourChars($Size); - } - exit; - - break; - - case 'restore': - if(!isset($restore_start)) - { - // - // Define Template files... - // - include('page_header_admin.'.$phpEx); - - $template->set_filenames(array( - "body" => "admin/db_utils_restore_body.tpl") - ); - - $s_hidden_fields = "<input type=\"hidden\" name=\"perform\" value=\"restore\" /><input type=\"hidden\" name=\"perform\" value=\"$perform\" />"; - - $template->assign_vars(array( - "L_DATABASE_RESTORE" => $lang['Database_Utilities'] . " : " . $lang['Restore'], - "L_RESTORE_EXPLAIN" => $lang['Restore_explain'], - "L_SELECT_FILE" => $lang['Select_file'], - "L_START_RESTORE" => $lang['Start_Restore'], - - "S_DBUTILS_ACTION" => append_sid("admin_db_utilities.$phpEx"), - "S_HIDDEN_FIELDS" => $s_hidden_fields) - ); - $template->pparse("body"); - - break; - - } - else - { - // - // Handle the file upload .... - // If no file was uploaded report an error... - // - $backup_file_name = (!empty($HTTP_POST_FILES['backup_file']['name'])) ? $HTTP_POST_FILES['backup_file']['name'] : ""; - $backup_file_tmpname = ($HTTP_POST_FILES['backup_file']['tmp_name'] != "none") ? $HTTP_POST_FILES['backup_file']['tmp_name'] : ""; - $backup_file_type = (!empty($HTTP_POST_FILES['backup_file']['type'])) ? $HTTP_POST_FILES['backup_file']['type'] : ""; - - if($backup_file_tmpname == "" || $backup_file_name == "") - { - include('page_header_admin.'.$phpEx); - message_die(GENERAL_MESSAGE, $lang['Restore_Error_no_file']); - } - // - // If I file was actually uploaded, check to make sure that we - // are actually passed the name of an uploaded file, and not - // a hackers attempt at getting us to process a local system - // file. - // - if( file_exists($backup_file_tmpname) ) - { - if( preg_match("/^(text\/[a-zA-Z]+)|(application\/(x\-)?gzip(\-compressed)?)|(application\/octet-stream)$/is", $backup_file_type) ) - { - if( preg_match("/\.gz$/is",$backup_file_name) ) - { - $do_gzip_compress = FALSE; - $phpver = phpversion(); - if($phpver >= "4.0") - { - if(extension_loaded("zlib")) - { - $do_gzip_compress = TRUE; - } - } - - if($do_gzip_compress) - { - $gz_ptr = gzopen($backup_file_tmpname, 'rb'); - $sql_query = ""; - while( !gzeof($gz_ptr) ) - { - $sql_query .= gzgets($gz_ptr, 100000); - } - } - else - { - include('page_header_admin.'.$phpEx); - message_die(GENERAL_ERROR, $lang['Restore_Error_decompress']); - } - } - else - { - $sql_query = fread(fopen($backup_file_tmpname, 'r'), filesize($backup_file_tmpname)); - } - // - // Comment this line out to see if this fixes the stuff... - // - //$sql_query = stripslashes($sql_query); - } - else - { - include('page_header_admin.'.$phpEx); - message_die(GENERAL_ERROR, $lang['Restore_Error_filename'] ." $backup_file_type $backup_file_name"); - } - } - else - { - include('page_header_admin.'.$phpEx); - message_die(GENERAL_ERROR, $lang['Restore_Error_uploading']); - } - - if($sql_query != "") - { - // Strip out sql comments... - $sql_query = remove_remarks($sql_query); - $pieces = split_sql_file($sql_query, ";"); - - $sql_count = count($pieces); - for($i = 0; $i < $sql_count; $i++) - { - $sql = trim($pieces[$i]); - - if(!empty($sql) and $sql[0] != "#") - { - if(VERBOSE == 1) - { - echo "Executing: $sql\n<br>"; - flush(); - } - - $result = $db->sql_query($sql); - - if(!$result && ( !(SQL_LAYER == 'postgresql' && eregi("drop table", $sql) ) ) ) - { - //include('page_header_admin.'.$phpEx); - // echo "~~$sql~~"; - message_die(GENERAL_ERROR, "Error importing backup file", "", __LINE__, __FILE__, $sql); - } - } - } - } - - include('page_header_admin.'.$phpEx); - - $template->set_filenames(array( - "body" => "admin/admin_message_body.tpl") - ); - - $message = $lang['Restore_success']; - - $template->assign_vars(array( - "MESSAGE_TITLE" => $lang['Database_Utilities'] . " : " . $lang['Restore'], - "MESSAGE_TEXT" => $message) - ); - - $template->pparse("body"); - break; - } - break; - } -} - -include('page_footer_admin.'.$phpEx); - -?> +?>
\ No newline at end of file diff --git a/phpBB/admin/admin_email.php b/phpBB/admin/admin_email.php new file mode 100644 index 0000000000..7faec69d40 --- /dev/null +++ b/phpBB/admin/admin_email.php @@ -0,0 +1,193 @@ +<?php +/*************************************************************************** +* admin_email.php +* ------------------- +* begin : Thu May 31, 2001 +* copyright : (C) 2001 The phpBB Group +* email : support@phpbb.com +* +* $Id$ +* +****************************************************************************/ + +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ + +if ( !empty($setmodules) ) +{ + if ( !$acl->get_acl_admin('general') ) + { + return; + } + + $filename = basename(__FILE__); + $module['Users']['Mass_Email'] = $filename; + + return; +} + +define('IN_PHPBB', 1); +// +// Include files +// +$phpbb_root_path = '../'; +require($phpbb_root_path . 'extension.inc'); +require('pagestart.' . $phpEx); + +// +// Do we have general admin permissions? +// +if ( !$acl->get_acl_admin('general') ) +{ + return; +} + +// +// Set some vars +// +$message = ''; +$subject = ''; + +// +// Do the job ... +// +if ( isset($HTTP_POST_VARS['submit']) ) +{ + // + // Increase maximum execution time in case of a lot of users, but don't complain about it if it isn't + // allowed. + // + @set_time_limit(1200); + + $group_id = intval($HTTP_POST_VARS['g']); + + $sql = ( $group_id != -1 ) ? "SELECT u.user_email FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug WHERE ug.group_id = $group_id AND ug.user_pending <> " . TRUE . " AND u.user_id = ug.user_id" : "SELECT user_email FROM " . USERS_TABLE; + $result = $db->sql_query($sql); + + if ( !($email_list = $db->sql_fetchrowset($g_result)) ) + { + // + // Output a relevant GENERAL_MESSAGE about users/group + // not existing + // + } + + $subject = stripslashes($HTTP_POST_VARS['subject']); + $message = stripslashes($HTTP_POST_VARS['message']); + + // + // Error checking needs to go here ... if no subject and/or + // no message then skip over the send and return to the form + // + $error = FALSE; + + if ( !$error ) + { + include($phpbb_root_path . 'includes/emailer.'.$phpEx); + // + // Let's do some checking to make sure that mass mail functions + // are working in win32 versions of php. + // + if ( preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$board_config['smtp_delivery']) + { + // We are running on windows, force delivery to use + // our smtp functions since php's are broken by default + $board_config['smtp_delivery'] = 1; + $board_config['smtp_host'] = get_cfg_var('SMTP'); + } + $emailer = new emailer($board_config['smtp_delivery']); + + $email_headers = 'From: ' . $board_config['board_email'] . "\n"; + + $bcc_list = ''; + for($i = 0; $i < count($email_list); $i++) + { + $bcc_list .= ( ( $bcc_list != '' ) ? ', ' : '' ) . $email_list[$i]['user_email']; + } + $email_headers .= "Bcc: $bcc_list\n"; + + $email_headers .= 'Return-Path: ' . $userdata['board_email'] . "\n"; + $email_headers .= 'X-AntiAbuse: Board servername - ' . $server_name . "\n"; + $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n"; + $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n"; + $email_headers .= 'X-AntiAbuse: User IP - ' . $user_ip . "\r\n"; + + $emailer->use_template('admin_send_email'); + $emailer->email_address($board_config['board_email']); + $emailer->set_subject($subject); + $emailer->extra_headers($email_headers); + + $emailer->assign_vars(array( + 'SITENAME' => $board_config['sitename'], + 'BOARD_EMAIL' => $board_config['board_email'], + 'MESSAGE' => $message) + ); + + $emailer->send(); + $emailer->reset(); + + $message = $lang['Email_sent'] . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . "index.$phpEx$SID?pane=right" . '">', '</a>'); + + message_die(MESSAGE, $message); + } +} + +// +// Initial selection +// + +$sql = "SELECT group_id, group_name + FROM ".GROUPS_TABLE; +$result = $db->sql_query($sql); + +$select_list = '<select name = "g"><option value = "-1">' . $lang['All_users'] . '</option>'; +if ( $row = $db->sql_fetchrow($result) ) +{ + do + { + $select_list .= '<option value = "' . $row['group_id'] . '">' . $row['group_name'] . '</option>'; + } + while ( $row = $db->sql_fetchrow($result) ); +} +$select_list .= '</select>'; + +page_header($lang['Users']); + +?> + +<h1><?php echo $lang['Email']; ?></h1> + +<p><?php echo $lang['Mass_email_explain']; ?></p> + +<form method="post" action="<?php echo "admin_mass_email.$phpEx$SID"; ?>"><table cellspacing="1" cellpadding="4" border="0" align="center" bgcolor="#98AAB1"> + <tr> + <th colspan="2"><?php echo $lang['Compose']; ?></th> + </tr> + <tr> + <td class="row1" align="right"><b><?php echo $lang['Recipients']; ?></b></td> + <td class="row2" align="left"><?php echo $select_list; ?></td> + </tr> + <tr> + <td class="row1" align="right"><b><?php echo $lang['Subject']; ?></b></td> + <td class="row2"><span class="gen"><input type="text" name="subject" size="45" maxlength="100" tabindex="2" class="post" value="<?php echo $subject; ?>" /></span></td> + </tr> + <tr> + <td class="row1" align="right" valign="top"><span class="gen"><b><?php echo $lang['Message']; ?></b></span> + <td class="row2"><textarea class="post" name="message" rows="15" cols="35" wrap="virtual" style="width:450px" tabindex="3"><?php echo $message; ?></textarea></td> + </tr> + <tr> + <td class="cat" colspan="2" align="center"><input type="submit" value="<?php echo $lang['Email']; ?>" name="submit" class="mainoption" /></td> + </tr> +</table></form> + +<?php + +page_footer(); + +?>
\ No newline at end of file diff --git a/phpBB/admin/admin_permissions.php b/phpBB/admin/admin_permissions.php index 7dfa0b597e..0c90f8aa34 100644 --- a/phpBB/admin/admin_permissions.php +++ b/phpBB/admin/admin_permissions.php @@ -21,14 +21,15 @@ if ( !empty($setmodules) ) { - if ( !$acl->get_acl_admin('forums') ) + if ( !$acl->get_acl_admin('auth') ) { return; } $filename = basename(__FILE__); $module['Forums']['Permissions'] = $filename . $SID . '&mode=forums'; - $module['General']['Set_Administrators'] = $filename . $SID . '&mode=admins'; + $module['Forums']['Moderators'] = $filename . $SID . '&mode=moderators'; + $module['General']['Administrators'] = $filename . $SID . '&mode=administrators'; return; } @@ -44,7 +45,7 @@ require('pagestart.' . $phpEx); // // Do we have forum admin permissions? // -if ( !$acl->get_acl_admin('forums') ) +if ( !$acl->get_acl_admin('auth') ) { message_die(MESSAGE, $lang['No_admin']); } @@ -55,7 +56,6 @@ if ( !$acl->get_acl_admin('forums') ) if ( isset($HTTP_GET_VARS['f']) || isset($HTTP_POST_VARS['f']) ) { $forum_id = ( isset($HTTP_POST_VARS['f']) ) ? intval($HTTP_POST_VARS['f']) : intval($HTTP_GET_VARS['f']); - $forum_sql = " WHERE forum_id = $forum_id"; } else @@ -64,31 +64,248 @@ else $forum_sql = ''; } +$mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; + // // Start program proper // +switch ( $mode ) +{ + case 'forums': + $l_title = $lang['Permissions']; + $l_title_explain = $lang['Permissions_explain']; + break; + case 'moderators': + $l_title = $lang['Moderators']; + $l_title_explain = $lang['Moderators_explain']; + break; + case 'administrators': + $l_title = $lang['Administrators']; + $l_title_explain = $lang['Administrators_explain']; + break; +} // // Get required information, either all forums if // no id was specified or just the requsted if it // was // -if ( !empty($forum_id) ) +if ( !empty($forum_id) || $mode == 'administrators' ) { // - // Output the selection table if no forum id was - // specified + // Clear some vars, grab some info if relevant ... // - $template->set_filenames(array( - "body" => "admin/auth_select_body.tpl") - ); + $s_hidden_fields = ''; + if ( !empty($forum_id) ) + { + $sql = "SELECT forum_name + FROM " . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query($sql); + + $forum_info = $db->sql_fetchrow($result); + + $l_title .= ' : <i>' . $forum_info['forum_name'] . '</i>'; + $s_hidden_fields = '<input type="hidden" name="f" value="' . $forum_id .'" />'; + } + + // + // Generate header + // + page_header($lang['Forums']); - $select_list = '<select name=f">'; - for($i = 0; $i < count($forum_rows); $i++) +?> + +<h1><?php echo $l_title; ?></h1> + +<p><?php echo $l_title_explain; ?></p> + +<?php + + switch ( $mode ) { - $select_list .= '<option value="' . $forum_rows[$i]['forum_id'] . '">' . $forum_rows[$i]['forum_name'] . '</option>'; + case 'forums': + +?> + +<form method="post" action="<?php echo "admin_permissions.$phpEx$SID&mode=$mode"; ?>"> + +<h3><?php echo $lang['Allowed_users']; ?></h3> + +<select name="user_allowed"><?php echo $user_allowed_options; ?></select> + +<p>[ <a href=""><?php echo $lang['Advanced']; ?></a> ]</p> + +<h3><?php echo $lang['Allowed_groups']; ?></h3> + +<select name="group_allowed"><?php echo $group_allowed_options; ?></select> + +<p>[ <a href=""><?php echo $lang['Advanced']; ?></a> ]</p> + +<h3><?php echo $lang['Disallowed_users']; ?></h3> + +<select name="user_disallowed"><?php echo $user_disallowed_options; ?></select> + +<p>[ <a href=""><?php echo $lang['Advanced']; ?></a> ]</p> + +<h3><?php echo $lang['Disallowed_groups']; ?></h3> + +<select name="group_disallowed"><?php echo $group_disallowed_options; ?></select> + +<p>[ <a href=""><?php echo $lang['Advanced']; ?></a> ]</p> + +<?php + break; + + case 'moderators': + $sql = "SELECT auth_option + FROM " . ACL_OPTIONS_TABLE . " + WHERE auth_type LIKE 'mod'"; + $result = $db->sql_query($sql); + + $auth_options = array(); + while ( $row = $db->sql_fetchrow($result) ) + { + $auth_options[] = $row; + } + + $sql = "SELECT u.user_id, u.username, ao.auth_option + FROM " . USERS_TABLE . " u, " . ACL_USERS_TABLE . " au, " . ACL_OPTIONS_TABLE . " ao + WHERE ao.auth_type LIKE 'mod' + AND au.auth_option_id = ao.auth_option_id + AND au.forum_id = $forum_id + AND u.user_id = au.user_id + ORDER BY u.username, u.user_regdate ASC"; + $result = $db->sql_query($sql); + + $auth_users = array(); + while ( $row = $db->sql_fetchrow($result) ) + { + $auth_users[$row['auth_option']] .= '<option value="' . $row['user_id'] . '">' . $row['username'] . '</option>'; + } + + $sql = "SELECT g.group_id, g.group_name, ao.auth_option + FROM " . GROUPS_TABLE . " g, " . ACL_GROUPS_TABLE . " ag, " . ACL_OPTIONS_TABLE . " ao + WHERE ao.auth_type LIKE 'mod' + AND ag.auth_option_id = ao.auth_option_id + AND ag.forum_id = $forum_id + AND g.group_id = ag.group_id + ORDER BY g.group_name ASC"; + $result = $db->sql_query($sql); + + $auth_groups = array(); + while ( $row = $db->sql_fetchrow($result) ) + { + $auth_groups[$row['auth_option']] .= '<option value="' . $row['group_id'] . '">' . $row['group_name'] . '</option>'; + } + +?> + +<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> + <tr> + <th>Setting</th> + <th>Users</th> + <th>Groups</th> + </tr> +<?php + for($i = 0; $i < sizeof($auth_options); $i++) + { + $cell_bg = ( $cell_bg == 'row1' ) ? 'row2' : 'row1'; + +?> + <tr> + <td class="<?php echo $cell_bg; ?>" align="center"><?php echo $auth_options[$i]['auth_option']; ?></td> + <td class="<?php echo $cell_bg; ?>" align="center"><select name="option[<?php echo $auth_options[$i]['auth_option']; ?>]" multiple="multiple"><?php echo $auth_users[$auth_options[$i]['auth_option']]; ?></select></td> + <td class="<?php echo $cell_bg; ?>" align="center"><select name="option[<?php echo $auth_options[$i]['auth_option']; ?>]" multiple="multiple"><?php echo $auth_groups[$auth_options[$i]['auth_option']]; ?></select></td> + </tr> + +<?php + } + +?> +</table> + +<?php + break; + + case 'administrators': + $sql = "SELECT auth_option + FROM " . ACL_OPTIONS_TABLE . " + WHERE auth_type LIKE 'admin'"; + $result = $db->sql_query($sql); + + $auth_options = array(); + while ( $row = $db->sql_fetchrow($result) ) + { + $auth_options[] = $row; + } + + $sql = "SELECT u.user_id, u.username, ao.auth_option + FROM " . USERS_TABLE . " u, " . ACL_USERS_TABLE . " au, " . ACL_OPTIONS_TABLE . " ao + WHERE ao.auth_type LIKE 'admin' + AND au.auth_option_id = ao.auth_option_id + AND u.user_id = au.user_id + ORDER BY u.username, u.user_regdate ASC"; + $result = $db->sql_query($sql); + + $auth_users = array(); + while ( $row = $db->sql_fetchrow($result) ) + { + $auth_users[$row['auth_option']] .= '<option value="' . $row['user_id'] . '">' . $row['username'] . '</option>'; + } + + $sql = "SELECT g.group_id, g.group_name, ao.auth_option + FROM " . GROUPS_TABLE . " g, " . ACL_GROUPS_TABLE . " ag, " . ACL_OPTIONS_TABLE . " ao + WHERE ao.auth_type LIKE 'admin' + AND ag.auth_option_id = ao.auth_option_id + AND g.group_id = ag.group_id + ORDER BY g.group_name ASC"; + $result = $db->sql_query($sql); + + $auth_groups = array(); + while ( $row = $db->sql_fetchrow($result) ) + { + $auth_groups[$row['auth_option']] .= '<option value="' . $row['group_id'] . '">' . ( ( $row['group_name'] == 'ADMINISTRATORS' ) ? $lang['Admin_group'] : $row['group_name'] ) . '</option>'; + } + +?> + +<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> + <tr> + <th>Setting</th> + <th>Users</th> + <th>Groups</th> + </tr> +<?php + for($i = 0; $i < sizeof($auth_options); $i++) + { + $cell_bg = ( $cell_bg == 'row1' ) ? 'row2' : 'row1'; + + $l_can_cell = ( !empty($lang['acl_admin_' . $auth_options[$i]['auth_option']]) ) ? $lang['acl_admin_' . $auth_options[$i]['auth_option']] : $auth_options[$i]['auth_option']; + +?> + <tr> + <td class="<?php echo $cell_bg; ?>"><?php echo $l_can_cell; ?></td> + <td class="<?php echo $cell_bg; ?>" align="center"><?php if ( !empty($auth_users[$auth_options[$i]['auth_option']]) ) { ?><select name="user_option[<?php echo $auth_options[$i]['auth_option']; ?>]"><?php echo $auth_users[$auth_options[$i]['auth_option']]; ?></select><?php } else { ?> <?php } ?></td> + <td class="<?php echo $cell_bg; ?>" align="center"><?php if ( !empty($auth_groups[$auth_options[$i]['auth_option']]) ) { ?><select name="group_option[<?php echo $auth_options[$i]['auth_option']; ?>]"><?php echo $auth_groups[$auth_options[$i]['auth_option']]; ?></select><?php } else { ?> <?php } ?></td> + </tr> + +<?php + } + +?> +</table> +<?php + break; } - $select_list .= '</select>'; + + +?> + +<?php echo $s_hidden_fields; ?></form> + +<?php + } else { @@ -108,16 +325,16 @@ else ?> -<h1><?php echo $lang['Permissions']; ?></h1> +<h1><?php echo $l_title; ?></h1> -<p><?php echo $lang['Permissions_explain']; ?></p> +<p><?php echo $l_title_explain ?></p> -<form method="post" action="<?php echo "admin_permissions.$phpEx$SID"; ?>"><table cellspacing="1" cellpadding="4" border="0" align="center" bgcolor="#98AAB1"> +<form method="post" action="<?php echo "admin_permissions.$phpEx$SID&mode=$mode"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> <tr> <th align="center"><?php echo $lang['Select_a_Forum']; ?></th> </tr> <tr> - <td class="row1" align="center"> <select name="f"><?php echo $select_list; ?></select> <input type="submit" value="<?php echo $lang['Look_up_Forum']; ?>" class="mainoption" /> </td> + <td class="row1" align="center"> <select name="f"><?php echo $select_list; ?></select> <input type="submit" value="<?php echo $lang['Look_up_Forum']; ?>" class="mainoption" /> </td> </tr> </table></form> diff --git a/phpBB/admin/admin_prune.php b/phpBB/admin/admin_prune.php new file mode 100644 index 0000000000..1660749a1f --- /dev/null +++ b/phpBB/admin/admin_prune.php @@ -0,0 +1,200 @@ +<?php +/*************************************************************************** +* admin_prune.php +* ------------------- +* begin : Mon Jul 31, 2001 +* copyright : (C) 2001 The phpBB Group +* email : support@phpbb.com +* +* $Id$ +* +****************************************************************************/ + +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + ***************************************************************************/ + +if ( !empty($setmodules) ) +{ + if ( !$acl->get_acl_admin('forum') ) + { + return; + } + + $filename = basename(__FILE__); + $module['Forums']['Prune'] = $filename . $SID . '&mode=forums'; + + return; +} + +define('IN_PHPBB', 1); +// +// Include files +// +$phpbb_root_path = '../'; +require($phpbb_root_path . 'extension.inc'); +require('pagestart.' . $phpEx); +require($phpbb_root_path . 'includes/functions_admin.'.$phpEx); + +// +// Do we have forum admin permissions? +// +if ( !$acl->get_acl_admin('forum') ) +{ + message_die(MESSAGE, $lang['No_admin']); +} + +// +// Get the forum ID for pruning +// +if ( isset($HTTP_GET_VARS['f']) || isset($HTTP_POST_VARS['f']) ) +{ + $forum_id = ( isset($HTTP_POST_VARS['f']) ) ? intval($HTTP_POST_VARS['f']) : intval($HTTP_GET_VARS['f']); + $forum_sql = ( $forum_id == -1 ) ? '' : "AND forum_id = $forum_id"; +} +else +{ + $forum_id = ''; + $forum_sql = ''; +} +// +// Get a list of forum's or the data for the forum that we are pruning. +// +$sql = "SELECT f.* + FROM " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE . " c + WHERE c.cat_id = f.cat_id + $forum_sql + ORDER BY c.cat_order ASC, f.forum_order ASC"; +$result = $db->sql_query($sql); + +$forum_rows = array(); +while( $row = $db->sql_fetchrow($result) ) +{ + $forum_rows[] = $row; +} + +// +// Check for submit to be equal to Prune. If so then proceed with the pruning. +// +if ( isset($HTTP_POST_VARS['doprune']) ) +{ + $prunedays = ( isset($HTTP_POST_VARS['prunedays']) ) ? intval($HTTP_POST_VARS['prunedays']) : 0; + + // Convert days to seconds for timestamp functions... + $prunedate = time() - ( $prunedays * 86400 ); + + $template->set_filenames(array( + 'body' => 'admin/forum_prune_result_body.tpl') + ); + + $log_data = ''; + for($i = 0; $i < count($forum_rows); $i++) + { + $p_result = prune($forum_rows[$i]['forum_id'], $prunedate); + sync('forum', $forum_rows[$i]['forum_id']); + + $template->assign_block_vars('prune_results', array( + 'ROW_COLOR' => '#' . $row_color, + 'ROW_CLASS' => $row_class, + 'FORUM_NAME' => $forum_rows[$i]['forum_name'], + 'FORUM_TOPICS' => $p_result['topics'], + 'FORUM_POSTS' => $p_result['posts']) + ); + + $log_data .= ( ( $log_data != '' ) ? ', ' : '' ) . $forum_rows[$i]['forum_name']; + } + + $template->assign_vars(array( + 'L_FORUM_PRUNE' => $lang['Forum_Prune'], + 'L_FORUM' => $lang['Forum'], + 'L_TOPICS_PRUNED' => $lang['Topics_pruned'], + 'L_POSTS_PRUNED' => $lang['Posts_pruned'], + 'L_PRUNE_RESULT' => $lang['Prune_success']) + ); + + add_admin_log('log_prune', $log_data); + +} +else +{ + page_header($lang['Forums']); + + // + // If they haven't selected a forum for pruning yet then + // display a select box to use for pruning. + // + if ( empty($forum_id) ) + { + // + // Output a selection table if no forum id has been specified. + // + $select_list .= '<option value="-1">' . $lang['All_Forums'] . '</option>'; + for($i = 0; $i < count($forum_rows); $i++) + { + $select_list .= '<option value="' . $forum_rows[$i]['forum_id'] . '">' . $forum_rows[$i]['forum_name'] . '</option>'; + } + +?> + +<h1><?php echo $lang['Prune']; ?></h1> + +<p><?php echo $lang['Forum_Prune_explain']; ?></p> + +<form method="post" action="<?php echo "admin_prune.$phpEx$SID"; ?>"><table cellspacing="1" cellpadding="4" border="0" align="center" bgcolor="#98AAB1"> + <tr> + <th align="center"><?php echo $lang['Select_a_Forum']; ?></th> + </tr> + <tr> + <td class="row1" align="center"><?php echo $s_hidden_fields; ?> <select name="f"><?php echo $select_list; ?></select> <input type="submit" value="<?php echo $lang['Look_up_Forum']; ?>" class="mainoption" /> </td> + </tr> +</table></form> + +<?php + + } + else + { + $forum_name = ( $forum_id == -1 ) ? $lang['All_Forums'] : $forum_rows[0]['forum_name']; + + $prune_data = $lang['Prune_topics_not_posted'] . " "; + $prune_data .= '<input type="text" name="prunedays" size="4"> ' . $lang['Days']; + + $s_hidden_fields = '<input type="hidden" name="f" value="' . $forum_id . '">'; + +?> + +<h1><?php echo $lang['Prune']; ?></h1> + +<p><?php echo $lang['Forum_Prune_explain']; ?></p> + +<h2><?php echo $lang['Forum'] . ': ' . $forum_name; ?></h2> + +<form method="post" action="<?php echo "admin_prune.$phpEx$SID"; ?>"><table cellspacing="1" cellpadding="4" border="0" align="center" bgcolor="#98AAB1"> + <tr> + <th class="th"><?php echo $lang['Forum_Prune']; ?></th> + </tr> + <tr> + <td class="row1"><?php echo $prune_data; ?></td> + </tr> + <tr> + <td class="cat" align="center"><?php echo $s_hidden_fields; ?><input type="submit" name="doprune" value="<?php echo $lang['Do_Prune']; ?>" class="mainoption"></td> + </tr> +</table></form> + +<?php + + } +} + +// +// Actually output the page here. +// + +page_footer(); + +?>
\ No newline at end of file diff --git a/phpBB/admin/admin_search.php b/phpBB/admin/admin_search.php index 6075fe0c2d..6372bcc79c 100644 --- a/phpBB/admin/admin_search.php +++ b/phpBB/admin/admin_search.php @@ -1,6 +1,6 @@ <?php /*************************************************************************** - * admin_search.php + * admin_search.php * ------------------- * begin : Saturday, Feb 13, 2001 * copyright : (C) 2001 The phpBB Group @@ -32,6 +32,10 @@ if ( !empty($setmodules) ) return; } +define('IN_PHPBB', 1); +// +// Include files +// $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); @@ -48,44 +52,68 @@ if ( !$acl->get_acl_admin('general') ) // // Start indexing // -if ( isset($HTTP_POST_VARS['start']) ) +if ( isset($HTTP_POST_VARS['start']) || isset($HTTP_GET_VARS['batchstart']) ) { // // Do not change anything below this line. // - set_time_limit(0); + @set_time_limit(0); $common_percent = 0.4; // Percentage of posts in which a word has to appear to be marked as common - print "<html>\n<body>\n"; - // // Try and load stopword and synonym files // // This needs fixing! Shouldn't be hardcoded to English files! - $stopword_array = file($phpbb_root_path . "language/lang_english/search_stopwords.txt"); - $synonym_array = file($phpbb_root_path . "language/lang_english/search_synonyms.txt"); + $stopword_array = array(); + $synonym_array = array(); + + $dir = opendir($phpbb_root_path . 'language/'); + while ( $file = readdir($dir) ) + { + if ( ereg('^lang_', $file) && !is_file($phpbb_root_path . 'language/' . $file) && !is_link($phpbb_root_path . 'language/' . $file) ) + { + unset($tmp_array); + $tmp_array = @file($phpbb_root_path . 'language/' . $file . '/search_stopwords.txt'); + + if ( is_array($tmp_array) ) + { + $stopword_array = array_merge($stopword_array, $tmp_array); + } + + unset($tmp_array); + $tmp_array = @file($phpbb_root_path . 'language/' . $file . '/search_synonyms.txt'); + + if ( is_array($tmp_array) ) + { + $synonym_array = array_merge($synonym_array, $tmp_array); + } + } + } + + closedir($dir); + + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = '1' + WHERE config_name = 'board_disable'"; + $db->sql_query($sql); // // Fetch a batch of posts_text entries // $sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id - FROM ". POSTS_TEXT_TABLE; - if ( !($result = $db->sql_query($sql)) ) - { - $error = $db->sql_error(); - die("Couldn't get maximum post ID :: " . $sql . " :: " . $error['message']); - } + FROM " . POSTS_TEXT_TABLE; + $result = $db->sql_query($sql); $max_post_id = $db->sql_fetchrow($result); $totalposts = $max_post_id['total']; $max_post_id = $max_post_id['max_post_id']; - $postcounter = (!isset($HTTP_GET_VARS['batchstart'])) ? 0 : $HTTP_GET_VARS['batchstart']; + $postcounter = ( !isset($HTTP_GET_VARS['batchstart']) ) ? 0 : $HTTP_GET_VARS['batchstart']; - $batchsize = 200; // Process this many posts per loop $batchcount = 0; + $batchsize = 200; // Process this many posts per loop for(;$postcounter <= $max_post_id; $postcounter += $batchsize) { $batchstart = $postcounter + 1; @@ -97,35 +125,20 @@ if ( isset($HTTP_POST_VARS['start']) ) WHERE post_id BETWEEN $batchstart AND $batchend"; - if( !($result = $db->sql_query($sql)) ) - { - $error = $db->sql_error(); - die("Couldn't get post_text :: " . $sql . " :: " . $error['message']); - } - - $rowset = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - $post_rows = count($rowset); + $result = $db->sql_query($sql); - if( $post_rows ) + if ( $row = $db->sql_fetchrow($result) ) { + do + { - // $sql = "LOCK TABLES ".POST_TEXT_TABLE." WRITE"; - // $result = $db->sql_query($sql); - print "\n<p>\n<a href='$PHP_SELF?batchstart=$batchstart'>Restart from posting $batchstart</a><br>\n"; +// print "\n<p>\n<a href='$PHP_SELF?batchstart=$batchstart'>Restart from posting $batchstart</a><br>\n"; - // For every post in the batch: - for($post_nr = 0; $post_nr < $post_rows; $post_nr++ ) - { - print "."; - flush(); - - $post_id = $rowset[$post_nr]['post_id']; + $post_id = $row['post_id']; $matches = array(); - $matches['text'] = split_words(clean_words("post", $rowset[$post_nr]['post_text'], $stopword_array, $synonym_array)); - $matches['title'] = split_words(clean_words("post", $rowset[$post_nr]['post_subject'], $stopword_array, $synonym_array)); + $matches['text'] = split_words(clean_words('post', $row['post_text'], $stopword_array, $synonym_array)); + $matches['title'] = split_words(clean_words('post', $row['post_subject'], $stopword_array, $synonym_array)); while( list($match_type, $match_ary) = @each($matches) ) { @@ -140,8 +153,7 @@ if ( isset($HTTP_POST_VARS['start']) ) } // For all words in the posting - $sql_in = ""; - + $sql_in = ''; $sql_insert = ''; $sql_select = ''; @@ -150,8 +162,7 @@ if ( isset($HTTP_POST_VARS['start']) ) for($j = 0; $j < $num_matches; $j++) { - $this_word = strtolower(trim($match_ary[$j])); - if ( $this_word != '' ) + if ( $this_word = strtolower(trim($match_ary[$j])) ) { $word_count[$this_word] = ( isset($word_count[$this_word]) ) ? $word_count[$this_word] + 1 : 0; $comma = ($sql_insert != '')? ', ': ''; @@ -163,66 +174,48 @@ if ( isset($HTTP_POST_VARS['start']) ) if ( $sql_insert == '' ) { - die("no words found"); + message_die(ERROR, 'No words found to index'); } - $sql = 'INSERT IGNORE INTO ' . SEARCH_WORD_TABLE . " - (word_text) + $sql = "INSERT IGNORE INTO " . SEARCH_WORD_TABLE . " (word_text) VALUES $sql_insert"; - if ( !$result = $db->sql_query($sql) ) - { - $error = $db->sql_error(); - die("Couldn't INSERT words :: " . $sql . " :: " . $error['message']); - } + $db->sql_query($sql); // Get the word_id's out of the DB (to see if they are already there) $sql = "SELECT word_id, word_text FROM " . SEARCH_WORD_TABLE . " WHERE word_text IN ($sql_select) GROUP BY word_text"; - $result = $db->sql_query($sql); - if ( !$result ) - { - $error = $db->sql_error(); - die("Couldn't select words :: " . $sql . " :: " . $error['message']); - } + $result2 = $db->sql_query($sql); $sql_insert = array(); - while( $row = $db->sql_fetchrow($result) ) + while( $row = $db->sql_fetchrow($result2) ) { $sql_insert[] = "($post_id, " . $row['word_id'] . ", $title_match)"; } - $db->sql_freeresult($result); + $db->sql_freeresult($result2); - $sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " - (post_id, word_id, title_match) - VALUES " . implode(", ", $sql_insert); - $result = $db->sql_query($sql); - if ( !$result ) - { - $error = $db->sql_error(); - die("Couldn't insert new word match :: " . $sql . " :: " . $error['message']); - } + $sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match) + VALUES " . implode(', ', $sql_insert); + $db->sql_query($sql); } // All posts } - - // $sql = "UNLOCK TABLES"; - // $result = $db->sql_query($sql); - + while ( $row = $db->sql_fetchrow($result) ); } // Remove common words after the first 2 batches and after every 4th batch after that. - if( $batchcount % 4 == 3 ) + if ( $batchcount % 4 == 3 ) { - print "<br>Removing common words (words that appear in more than $common_percent of the posts)<br>\n"; - flush(); - print "Removed ". remove_common("global", $common_percent) ." words that where too common.<br>"; +// print "<br>Removing common words (words that appear in more than $common_percent of the posts)<br>\n"; +// flush(); +// print "Removed ". remove_common("global", $common_percent) ." words that where too common.<br>"; } } echo "<br>Done"; + exit; } else if ( isset($HTTP_POST_VARS['cancel']) ) diff --git a/phpBB/admin/admin_styles.php b/phpBB/admin/admin_styles.php index 718726a5a5..af319680c3 100644 --- a/phpBB/admin/admin_styles.php +++ b/phpBB/admin/admin_styles.php @@ -1,937 +1,259 @@ <?php -/*************************************************************************** - * admin_styles.php - * ------------------- - * begin : Thursday, Jul 12, 2001 - * copyright : (C) 2001 The phpBB Group - * email : support@phpbb.com - * - * $Id$ - * - * - ***************************************************************************/ - -/*************************************************************************** - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - ***************************************************************************/ -define('IN_PHPBB', 1); - -if( !empty($setmodules) ) +if ( !empty($setmodules) ) { - $file = basename(__FILE__); - $module['Styles']['Add_new'] = "$file?mode=addnew"; - $module['Styles']['Create_new'] = "$file?mode=create"; - $module['Styles']['Manage'] = "$file"; - $module['Styles']['Export'] = "$file?mode=export"; + if ( !$acl->get_acl_admin('styles') ) + { + return; + } + + $filename = basename(__FILE__); + $module['Styles']['Edit_Styles'] = $filename . "$SID&mode=newstyle"; + $module['Styles']['Edit_Templates'] = $filename . "$SID&mode=edittemplate"; + $module['Styles']['Edit_Themes'] = $filename . "$SID&mode=newstyle"; + $module['Styles']['Edit_Imagesets'] = $filename . "$SID&mode=editimageset"; + return; } +define('IN_PHPBB', 1); // -// Load default header +// Include files // +$phpbb_root_path = '../'; +require($phpbb_root_path . 'extension.inc'); +require('pagestart.' . $phpEx); + // -// Check if the user has cancled a confirmation message. +// Do we have styles admin permissions? // -$phpbb_root_path = "../"; - -$confirm = ( isset($HTTP_POST_VARS['confirm']) ) ? TRUE : FALSE; -$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? TRUE : FALSE; - -if( empty($HTTP_POST_VARS['send_file']) ) +if ( !$acl->get_acl_admin('styles') ) { - $no_page_header = ( $cancel ) ? TRUE : FALSE; - require($phpbb_root_path . 'extension.inc'); - require('pagestart.' . $phpEx); + message_die(MESSAGE, $lang['No_admin']); } -if( $cancel ) +/* +$dp = opendir($phpbb_root_path . 'templates/cache/'); +while ( $file = readdir($dp) ) { - header("Location: " . append_sid("admin_styles.$phpEx")); + if ( !is_file($phpbb_root_path . 'templates/cache/' . $file) && !is_link($phpbb_root_path . 'templates/cache/' . $file) && $file != '.' && $file != '..' ) + { + $selected = ( $tplroot == $file ) ? ' selected="selected"' : ''; + $tplroot_options .= '<option name="' . $file . '"' . $selected . '>' . $file . '</option>'; + } } +closedir($dp); +*/ -if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) -{ - $mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; -} -else -{ - $mode = ""; -} +// +// +// +$mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; -switch( $mode ) +if ( $mode == 'editimageset' ) { - case "addnew": - $install_to = ( isset($HTTP_GET_VARS['install_to']) ) ? urldecode($HTTP_GET_VARS['install_to']) : $HTTP_POST_VARS['install_to']; - $style_name = ( isset($HTTP_GET_VARS['style']) ) ? urldecode($HTTP_GET_VARS['style']) : $HTTP_POST_VARS['style']; - - if( isset($install_to) ) - { - - include($phpbb_root_path. "templates/" . $install_to . "/theme_info.cfg"); - - $template_name = $$install_to; - $found = FALSE; - - for($i = 0; $i < count($template_name) && !$found; $i++) - { - if( $template_name[$i]['style_name'] == $style_name ) - { - while(list($key, $val) = each($template_name[$i])) - { - $db_fields[] = $key; - $db_values[] = str_replace("\'", "''" , $val); - } - } - } - - $sql = "INSERT INTO " . THEMES_TABLE . " ("; - - for($i = 0; $i < count($db_fields); $i++) - { - $sql .= $db_fields[$i]; - if($i != (count($db_fields) - 1)) - { - $sql .= ", "; - } - - } - - $sql .= ") VALUES ("; - - for($i = 0; $i < count($db_values); $i++) - { - $sql .= "'" . $db_values[$i] . "'"; - if($i != (count($db_values) - 1)) - { - $sql .= ", "; - } - } - $sql .= ")"; - - if( !$result = $db->sql_query($sql) ) - { - message_die(GENERAL_ERROR, "Could not insert theme data!", "", __LINE__, __FILE__, $sql); - } - - $message = $lang['Theme_installed'] . "<br /><br />" . sprintf($lang['Click_return_styleadmin'], "<a href=\"" . append_sid("admin_styles.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); - - message_die(GENERAL_MESSAGE, $message); - } - else - { - - $installable_themes = array(); - - if( $dir = @opendir($phpbb_root_path. "templates/") ) - { - while( $sub_dir = @readdir($dir) ) - { - if( !is_file($phpbb_root_path . 'templates/' .$sub_dir) && !is_link($phpbb_root_path . 'templates/' .$sub_dir) && $sub_dir != "." && $sub_dir != ".." && $sub_dir != "CVS" ) - { - if( @file_exists($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg") ) - { - include($phpbb_root_path. "templates/" . $sub_dir . "/theme_info.cfg"); - - for($i = 0; $i < count($$sub_dir); $i++) - { - $working_data = $$sub_dir; - - $style_name = $working_data[$i]['style_name']; - - $sql = "SELECT themes_id - FROM " . THEMES_TABLE . " - WHERE style_name = '" . str_replace("\'", "''", $style_name) . "'"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not query themes table!", "", __LINE__, __FILE__, $sql); - } - - if(!$db->sql_numrows($result)) - { - $installable_themes[] = $working_data[$i]; - } - } - } - } - } - - $template->set_filenames(array( - "body" => "admin/styles_addnew_body.tpl") - ); - - $template->assign_vars(array( - "L_STYLES_TITLE" => $lang['Styles_admin'], - "L_STYLES_ADD_TEXT" => $lang['Styles_addnew_explain'], - "L_STYLE" => $lang['Style'], - "L_TEMPLATE" => $lang['Template'], - "L_INSTALL" => $lang['Install'], - "L_ACTION" => $lang['Action']) - ); - - for($i = 0; $i < count($installable_themes); $i++) - { - $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; - $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; - - $template->assign_block_vars("styles", array( - "ROW_CLASS" => $row_class, - "ROW_COLOR" => "#" . $row_color, - "STYLE_NAME" => $installable_themes[$i]['style_name'], - "TEMPLATE_NAME" => $installable_themes[$i]['template_name'], - - "U_STYLES_INSTALL" => append_sid("admin_styles.$phpEx?mode=addnew&style=" . urlencode($installable_themes[$i]['style_name']) . "&install_to=" . urlencode($installable_themes[$i]['template_name']))) - ); - - } - $template->pparse("body"); - - } - closedir($dir); - } - break; - - case "create": - case "edit": - $submit = ( isset($HTTP_POST_VARS['submit']) ) ? TRUE : 0; - - if( $submit ) + $imgroot = ( isset($HTTP_POST_VARS['imgroot']) ) ? $HTTP_POST_VARS['imgroot'] : 'subSilver'; + + if ( isset($HTTP_POST_VARS['img_root']) ) + { + $sql = "SELECT * + FROM " . STYLES_IMAGE_TABLE . " + WHERE imageset_path LIKE '" . $HTTP_POST_VARS['imgroot'] . "'"; + $result = $db->sql_query($sql); + + $images = $db->sql_fetchrow($result); + } + if ( isset($HTTP_POST_VARS['img_addconfig']) ) + { + } + else if ( isset($HTTP_POST_VARS['img_addlocal']) ) + { + } + + $imageset = array('imageset_path', 'post_new', 'post_locked', 'post_pm', 'reply_new', 'reply_pm', 'reply_locked', 'icon_profile', 'icon_pm', 'icon_delete', 'icon_ip', 'icon_quote', 'icon_search', 'icon_edit', 'icon_email', 'icon_www', 'icon_icq', 'icon_aim', 'icon_yim', 'icon_msnm', 'icon_no_email', 'icon_no_www', 'icon_no_icq', 'icon_no_aim', 'icon_no_yim', 'icon_no_msnm', 'goto_post', 'goto_post_new', 'goto_post_latest', 'goto_post_newest', 'forum', 'forum_new', 'forum_locked', 'folder', 'folder_new', 'folder_hot', 'folder_hot_new', 'folder_locked', 'folder_locked_new', 'folder_sticky', 'folder_sticky_new', 'folder_announce', 'folder_announce_new', 'topic_watch', 'topic_unwatch', 'poll_left', 'poll_center', 'poll_right', 'rating'); + + $sql = "SELECT imageset_name, imageset_path + FROM " . STYLES_IMAGE_TABLE . " + ORDER BY imageset_name"; + $result = $db->sql_query($sql); + + $imgroot_options = ''; + while ( $row = $db->sql_fetchrow($result) ) + { + $selected = ( $imgroot == $row['imageset_path'] ) ? ' selected="selected"' : ''; + $imgroot_options .= '<option name="' . $row['imageset_path'] . '"' . $selected . '>' . $row['imageset_path'] . '</option>'; + } + + $imgname_options = ''; + $dp = opendir($phpbb_root_path . 'imagesets/' . $imgroot . '/'); + while ( $file = readdir($dp) ) + { + if ( preg_match('#\.(gif|png|jpg|jpeg)$#', $file) && is_file($phpbb_root_path . 'imagesets/' . $imgroot . '/' . $file) ) { - // - // DAMN! Thats alot of data to validate... - // - $updated['style_name'] = $HTTP_POST_VARS['style_name']; - $updated['template_name'] = $HTTP_POST_VARS['template_name']; - $updated['head_stylesheet'] = $HTTP_POST_VARS['head_stylesheet']; - $updated['body_background'] = $HTTP_POST_VARS['body_background']; - $updated['body_bgcolor'] = $HTTP_POST_VARS['body_bgcolor']; - $updated['body_text'] = $HTTP_POST_VARS['body_text']; - $updated['body_link'] = $HTTP_POST_VARS['body_link']; - $updated['body_vlink'] = $HTTP_POST_VARS['body_vlink']; - $updated['body_alink'] = $HTTP_POST_VARS['body_alink']; - $updated['body_hlink'] = $HTTP_POST_VARS['body_hlink']; - $updated['tr_color1'] = $HTTP_POST_VARS['tr_color1']; - $updated_name['tr_color1_name'] = $HTTP_POST_VARS['tr_color1_name']; - $updated['tr_color2'] = $HTTP_POST_VARS['tr_color2']; - $updated_name['tr_color2_name'] = $HTTP_POST_VARS['tr_color2_name']; - $updated['tr_color3'] = $HTTP_POST_VARS['tr_color3']; - $updated_name['tr_color3_name'] = $HTTP_POST_VARS['tr_color3_name']; - $updated['tr_class1'] = $HTTP_POST_VARS['tr_class1']; - $updated_name['tr_class1_name'] = $HTTP_POST_VARS['tr_class1_name']; - $updated['tr_class2'] = $HTTP_POST_VARS['tr_class2']; - $updated_name['tr_class2_name'] = $HTTP_POST_VARS['tr_class2_name']; - $updated['tr_class3'] = $HTTP_POST_VARS['tr_class3']; - $updated_name['tr_class3_name'] = $HTTP_POST_VARS['tr_class3_name']; - $updated['th_color1'] = $HTTP_POST_VARS['th_color1']; - $updated_name['th_color1_name'] = $HTTP_POST_VARS['th_color1_name']; - $updated['th_color2'] = $HTTP_POST_VARS['th_color2']; - $updated_name['th_color2_name'] = $HTTP_POST_VARS['th_color2_name']; - $updated['th_color3'] = $HTTP_POST_VARS['th_color3']; - $updated_name['th_color3_name'] = $HTTP_POST_VARS['th_color3_name']; - $updated['th_class1'] = $HTTP_POST_VARS['th_class1']; - $updated_name['th_class1_name'] = $HTTP_POST_VARS['th_class1_name']; - $updated['th_class2'] = $HTTP_POST_VARS['th_class2']; - $updated_name['th_class2_name'] = $HTTP_POST_VARS['th_class2_name']; - $updated['th_class3'] = $HTTP_POST_VARS['th_class3']; - $updated_name['th_class3_name'] = $HTTP_POST_VARS['th_class3_name']; - $updated['td_color1'] = $HTTP_POST_VARS['td_color1']; - $updated_name['td_color1_name'] = $HTTP_POST_VARS['td_color1_name']; - $updated['td_color2'] = $HTTP_POST_VARS['td_color2']; - $updated_name['td_color2_name'] = $HTTP_POST_VARS['td_color2_name']; - $updated['td_color3'] = $HTTP_POST_VARS['td_color3']; - $updated_name['td_color3_name'] = $HTTP_POST_VARS['td_color3_name']; - $updated['td_class1'] = $HTTP_POST_VARS['td_class1']; - $updated_name['td_class1_name'] = $HTTP_POST_VARS['td_class1_name']; - $updated['td_class2'] = $HTTP_POST_VARS['td_class2']; - $updated_name['td_class2_name'] = $HTTP_POST_VARS['td_class2_name']; - $updated['td_class3'] = $HTTP_POST_VARS['td_class3']; - $updated_name['td_class3_name'] = $HTTP_POST_VARS['td_class3_name']; - $updated['fontface1'] = $HTTP_POST_VARS['fontface1']; - $updated_name['fontface1_name'] = $HTTP_POST_VARS['fontface1_name']; - $updated['fontface2'] = $HTTP_POST_VARS['fontface2']; - $updated_name['fontface2_name'] = $HTTP_POST_VARS['fontface2_name']; - $updated['fontface3'] = $HTTP_POST_VARS['fontface3']; - $updated_name['fontface3_name'] = $HTTP_POST_VARS['fontface3_name']; - $updated['fontsize1'] = intval($HTTP_POST_VARS['fontsize1']); - $updated_name['fontsize1_name'] = $HTTP_POST_VARS['fontsize1_name']; - $updated['fontsize2'] = intval($HTTP_POST_VARS['fontsize2']); - $updated_name['fontsize2_name'] = $HTTP_POST_VARS['fontsize2_name']; - $updated['fontsize3'] = intval($HTTP_POST_VARS['fontsize3']); - $updated_name['fontsize3_name'] = $HTTP_POST_VARS['fontsize3_name']; - $updated['fontcolor1'] = $HTTP_POST_VARS['fontcolor1']; - $updated_name['fontcolor1_name'] = $HTTP_POST_VARS['fontcolor1_name']; - $updated['fontcolor2'] = $HTTP_POST_VARS['fontcolor2']; - $updated_name['fontcolor2_name'] = $HTTP_POST_VARS['fontcolor2_name']; - $updated['fontcolor3'] = $HTTP_POST_VARS['fontcolor3']; - $updated_name['fontcolor3_name'] = $HTTP_POST_VARS['fontcolor3_name']; - $updated['span_class1'] = $HTTP_POST_VARS['span_class1']; - $updated_name['span_class1_name'] = $HTTP_POST_VARS['span_class1_name']; - $updated['span_class2'] = $HTTP_POST_VARS['span_class2']; - $updated_name['span_class2_name'] = $HTTP_POST_VARS['span_class2_name']; - $updated['span_class3'] = $HTTP_POST_VARS['span_class3']; - $updated_name['span_class3_name'] = $HTTP_POST_VARS['span_class3_name']; - $style_id = intval($HTTP_POST_VARS['style_id']); - // - // Wheeeew! Thank heavens for copy and paste and search and replace :D - // - - if($mode == "edit") - { - $sql = "UPDATE " . THEMES_TABLE . " SET "; - $count = 0; - - while(list($key, $val) = each($updated)) - { - if($count != 0) - { - $sql .= ", "; - } - - // - // I don't like this but it'll keep MSSQL from throwing - // an error and save me alot of typing - // - $sql .= ( stristr($key, "fontsize") ) ? "$key = $val" : "$key = '" . str_replace("\'", "''", $val) . "'"; - - $count++; - } - - $sql .= " WHERE themes_id = $style_id"; - - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not update themes table!", "", __LINE__, __FILE__, $sql); - } - - // - // Check if there's a names table entry for this style - // - $sql = "SELECT themes_id - FROM " . THEMES_NAME_TABLE . " - WHERE themes_id = $style_id"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not get data from themes_name table", "", __LINE__, __FILE__, $sql); - } - - if($db->sql_numrows($result) > 0) - { - $sql = "UPDATE " . THEMES_NAME_TABLE . " - SET "; - $count = 0; - while(list($key, $val) = each($updated_name)) - { - if($count != 0) - { - $sql .= ", "; - } - - $sql .= "$key = '$val'"; - - $count++; - } - - $sql .= " WHERE themes_id = $style_id"; - } - else - { - // - // Nope, no names entry so we create a new one. - // - $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (themes_id, "; - while(list($key, $val) = each($updated_name)) - { - $fields[] = $key; - $vals[] = str_replace("\'", "''", $val); - } - - for($i = 0; $i < count($fields); $i++) - { - if($i > 0) - { - $sql .= ", "; - } - $sql .= $fields[$i]; - } - - $sql .= ") VALUES ($style_id, "; - for($i = 0; $i < count($vals); $i++) - { - if($i > 0) - { - $sql .= ", "; - } - $sql .= "'" . $vals[$i] . "'"; - } - - $sql .= ")"; - } - - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not update themes name table!", "", __LINE__, __FILE__, $sql); - } - - $message = $lang['Theme_updated'] . "<br /><br />" . sprintf($lang['Click_return_styleadmin'], "<a href=\"" . append_sid("admin_styles.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); - - message_die(GENERAL_MESSAGE, $message); - } - else - { - // - // First, check if we already have a style by this name - // - $sql = "SELECT themes_id - FROM " . THEMES_TABLE . " - WHERE style_name = '" . str_replace("\'", "''", $updated['style_name']) . "'"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not query themes table", "", __LINE__, __FILE__, $sql); - } - - if($db->sql_numrows($result)) - { - message_die(GENERAL_ERROR, $lang['Style_exists'], $lang['Error']); - } - - while(list($key, $val) = each($updated)) - { - $field_names[] = $key; - - if(stristr($key, "fontsize")) - { - $values[] = "$val"; - } - else - { - $values[] = "'" . str_replace("\'", "''", $val) . "'"; - } - } - - $sql = "INSERT - INTO " . THEMES_TABLE . " ("; - for($i = 0; $i < count($field_names); $i++) - { - if($i != 0) - { - $sql .= ", "; - } - $sql .= $field_names[$i]; - } - - $sql .= ") VALUES ("; - for($i = 0; $i < count($values); $i++) - { - if($i != 0) - { - $sql .= ", "; - } - $sql .= $values[$i]; - } - $sql .= ")"; - - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not update themes table!", "", __LINE__, __FILE__, $sql); - } - - $style_id = $db->sql_nextid(); - - // - // Insert names data - // - $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (themes_id, "; - while(list($key, $val) = each($updated_name)) - { - $fields[] = $key; - $vals[] = $val; - } - - for($i = 0; $i < count($fields); $i++) - { - if($i > 0) - { - $sql .= ", "; - } - $sql .= $fields[$i]; - } - - $sql .= ") VALUES ($style_id, "; - for($i = 0; $i < count($vals); $i++) - { - if($i > 0) - { - $sql .= ", "; - } - $sql .= "'" . $vals[$i] . "'"; - } - - $sql .= ")"; - - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not insert themes name table!", "", __LINE__, __FILE__, $sql); - } - - $message = $lang['Theme_created'] . "<br /><br />" . sprintf($lang['Click_return_styleadmin'], "<a href=\"" . append_sid("admin_styles.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); - - message_die(GENERAL_MESSAGE, $message); - } + $selected = ( $imgname == $file ) ? ' selected="selected"' : ''; + $imgname_options .= '<option value="' . $file . '"' . $selected . '>' . $file . '</option>'; } - else - { - if($mode == "edit") - { - $themes_title = $lang['Edit_theme']; - $themes_explain = $lang['Edit_theme_explain']; - - $style_id = $HTTP_GET_VARS['style_id']; - - $selected_names = array(); - $selected_values = array(); - // - // Fetch the Theme Info from the db - // - $sql = "SELECT * - FROM " . THEMES_TABLE . " - WHERE themes_id = $style_id"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not get data from themes table", "", __LINE__, __FILE__, $sql); - } - - if ( $selected_values = $db->sql_fetchrow($result) ) - { - while(list($key, $val) = @each($selected_values)) - { - $selected[$key] = $val; - } - } - - // - // Fetch the Themes Name data - // - $sql = "SELECT * - FROM " . THEMES_NAME_TABLE . " - WHERE themes_id = $style_id"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not get data from themes name table", "", __LINE__, __FILE__, $sql); - } - - if ( $selected_names = $db->sql_fetchrow($result) ) - { - while(list($key, $val) = @each($selected_names)) - { - $selected[$key] = $val; - } - } - - $s_hidden_fields = '<input type="hidden" name="style_id" value="' . $style_id . '" />'; - } - else - { - $themes_title = $lang['Create_theme']; - $themes_explain = $lang['Create_theme_explain']; - } - - $template->set_filenames(array( - "body" => "admin/styles_edit_body.tpl") - ); - - if( $dir = @opendir($phpbb_root_path . 'templates/') ) - { - $s_template_select = '<select name="template_name">'; - while( $file = @readdir($dir) ) - { - if( !is_file($phpbb_root_path . 'templates/' . $file) && !is_link($phpbb_root_path . 'templates/' . $file) && $file != "." && $file != ".." && $file != "CVS" ) - { - if($file == $selected['template_name']) - { - $s_template_select .= '<option value="' . $file . '" selected="selected">' . $file . "</option>\n"; - } - else - { - $s_template_select .= '<option value="' . $file . '">' . $file . "</option>\n"; - } - } - } - } - else - { - message_die(GENERAL_MESSAGE, $lang['No_template_dir']); - } - - $s_hidden_fields .= '<input type="hidden" name="mode" value="' . $mode . '" />'; - - $template->assign_vars(array( - "L_THEMES_TITLE" => $themes_title, - "L_THEMES_EXPLAIN" => $themes_explain, - "L_THEME_NAME" => $lang['Theme_name'], - "L_TEMPLATE" => $lang['Template'], - "L_THEME_SETTINGS" => $lang['Theme_settings'], - "L_THEME_ELEMENT" => $lang['Theme_element'], - "L_SIMPLE_NAME" => $lang['Simple_name'], - "L_VALUE" => $lang['Value'], - "L_STYLESHEET" => $lang['Stylesheet'], - "L_BACKGROUND_IMAGE" => $lang['Background_image'], - "L_BACKGROUND_COLOR" => $lang['Background_color'], - "L_BODY_TEXT_COLOR" => $lang['Text_color'], - "L_BODY_LINK_COLOR" => $lang['Link_color'], - "L_BODY_VLINK_COLOR" => $lang['VLink_color'], - "L_BODY_ALINK_COLOR" => $lang['ALink_color'], - "L_BODY_HLINK_COLOR" => $lang['HLink_color'], - "L_TR_COLOR1" => $lang['Tr_color1'], - "L_TR_COLOR2" => $lang['Tr_color2'], - "L_TR_COLOR3" => $lang['Tr_color3'], - "L_TR_CLASS1" => $lang['Tr_class1'], - "L_TR_CLASS2" => $lang['Tr_class2'], - "L_TR_CLASS3" => $lang['Tr_class3'], - "L_TH_COLOR1" => $lang['Th_color1'], - "L_TH_COLOR2" => $lang['Th_color2'], - "L_TH_COLOR3" => $lang['Th_color3'], - "L_TH_CLASS1" => $lang['Th_class1'], - "L_TH_CLASS2" => $lang['Th_class2'], - "L_TH_CLASS3" => $lang['Th_class3'], - "L_TD_COLOR1" => $lang['Td_color1'], - "L_TD_COLOR2" => $lang['Td_color2'], - "L_TD_COLOR3" => $lang['Td_color3'], - "L_TD_CLASS1" => $lang['Td_class1'], - "L_TD_CLASS2" => $lang['Td_class2'], - "L_TD_CLASS3" => $lang['Td_class3'], - "L_FONTFACE_1" => $lang['fontface1'], - "L_FONTFACE_2" => $lang['fontface2'], - "L_FONTFACE_3" => $lang['fontface3'], - "L_FONTSIZE_1" => $lang['fontsize1'], - "L_FONTSIZE_2" => $lang['fontsize2'], - "L_FONTSIZE_3" => $lang['fontsize3'], - "L_FONTCOLOR_1" => $lang['fontcolor1'], - "L_FONTCOLOR_2" => $lang['fontcolor2'], - "L_FONTCOLOR_3" => $lang['fontcolor3'], - "L_SPAN_CLASS_1" => $lang['span_class1'], - "L_SPAN_CLASS_2" => $lang['span_class2'], - "L_SPAN_CLASS_3" => $lang['span_class3'], - "L_SAVE_SETTINGS" => $lang['Save_Settings'], - "THEME_NAME" => $selected['style_name'], - "HEAD_STYLESHEET" => $selected['head_stylesheet'], - "BODY_BACKGROUND" => $selected['body_background'], - "BODY_BGCOLOR" => $selected['body_bgcolor'], - "BODY_TEXT_COLOR" => $selected['body_text'], - "BODY_LINK_COLOR" => $selected['body_link'], - "BODY_VLINK_COLOR" => $selected['body_vlink'], - "BODY_ALINK_COLOR" => $selected['body_alink'], - "BODY_HLINK_COLOR" => $selected['body_hlink'], - "TR_COLOR1" => $selected['tr_color1'], - "TR_COLOR2" => $selected['tr_color2'], - "TR_COLOR3" => $selected['tr_color3'], - "TR_CLASS1" => $selected['tr_class1'], - "TR_CLASS2" => $selected['tr_class2'], - "TR_CLASS3" => $selected['tr_class3'], - "TH_COLOR1" => $selected['th_color1'], - "TH_COLOR2" => $selected['th_color2'], - "TH_COLOR3" => $selected['th_color3'], - "TH_CLASS1" => $selected['th_class1'], - "TH_CLASS2" => $selected['th_class2'], - "TH_CLASS3" => $selected['th_class3'], - "TD_COLOR1" => $selected['td_color1'], - "TD_COLOR2" => $selected['td_color2'], - "TD_COLOR3" => $selected['td_color3'], - "TD_CLASS1" => $selected['td_class1'], - "TD_CLASS2" => $selected['td_class2'], - "TD_CLASS3" => $selected['td_class3'], - "FONTFACE1" => $selected['fontface1'], - "FONTFACE2" => $selected['fontface2'], - "FONTFACE3" => $selected['fontface3'], - "FONTSIZE1" => $selected['fontsize1'], - "FONTSIZE2" => $selected['fontsize2'], - "FONTSIZE3" => $selected['fontsize3'], - "FONTCOLOR1" => $selected['fontcolor1'], - "FONTCOLOR2" => $selected['fontcolor2'], - "FONTCOLOR3" => $selected['fontcolor3'], - "SPAN_CLASS1" => $selected['span_class1'], - "SPAN_CLASS2" => $selected['span_class2'], - "SPAN_CLASS3" => $selected['span_class3'], - - "TR_COLOR1_NAME" => $selected['tr_color1_name'], - "TR_COLOR2_NAME" => $selected['tr_color2_name'], - "TR_COLOR3_NAME" => $selected['tr_color3_name'], - "TR_CLASS1_NAME" => $selected['tr_class1_name'], - "TR_CLASS2_NAME" => $selected['tr_class2_name'], - "TR_CLASS3_NAME" => $selected['tr_class3_name'], - "TH_COLOR1_NAME" => $selected['th_color1_name'], - "TH_COLOR2_NAME" => $selected['th_color2_name'], - "TH_COLOR3_NAME" => $selected['th_color3_name'], - "TH_CLASS1_NAME" => $selected['th_class1_name'], - "TH_CLASS2_NAME" => $selected['th_class2_name'], - "TH_CLASS3_NAME" => $selected['th_class3_name'], - "TD_COLOR1_NAME" => $selected['td_color1_name'], - "TD_COLOR2_NAME" => $selected['td_color2_name'], - "TD_COLOR3_NAME" => $selected['td_color3_name'], - "TD_CLASS1_NAME" => $selected['td_class1_name'], - "TD_CLASS2_NAME" => $selected['td_class2_name'], - "TD_CLASS3_NAME" => $selected['td_class3_name'], - "FONTFACE1_NAME" => $selected['fontface1_name'], - "FONTFACE2_NAME" => $selected['fontface2_name'], - "FONTFACE3_NAME" => $selected['fontface3_name'], - "FONTSIZE1_NAME" => $selected['fontsize1_name'], - "FONTSIZE2_NAME" => $selected['fontsize2_name'], - "FONTSIZE3_NAME" => $selected['fontsize3_name'], - "FONTCOLOR1_NAME" => $selected['fontcolor1_name'], - "FONTCOLOR2_NAME" => $selected['fontcolor2_name'], - "FONTCOLOR3_NAME" => $selected['fontcolor3_name'], - "SPAN_CLASS1_NAME" => $selected['span_class1_name'], - "SPAN_CLASS2_NAME" => $selected['span_class2_name'], - "SPAN_CLASS3_NAME" => $selected['span_class3_name'], - - "S_THEME_ACTION" => append_sid("admin_styles.$phpEx"), - "S_TEMPLATE_SELECT" => $s_template_select, - "S_HIDDEN_FIELDS" => $s_hidden_fields) - ); - - $template->pparse("body"); - } - break; + } + closedir($dp); - case "export"; - if($HTTP_POST_VARS['export_template']) - { - $template_name = $HTTP_POST_VARS['export_template']; - - $sql = "SELECT * - FROM " . THEMES_TABLE . " - WHERE template_name = '$template_name'"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not get theme data for selected template", "", __LINE__, __FILE__, $sql); - } - - $theme_rowset = $db->sql_fetchrowset($result); - - if( count($theme_rowset) == 0 ) - { - message_die(GENERAL_MESSAGE, $lang['No_themes']); - } - - $theme_data = '<?php'."\n\n"; - $theme_data .= "//\n// phpBB 2.x auto-generated theme config file for $template_name\n// Do not change anything in this file!\n//\n\n"; - - for($i = 0; $i < count($theme_rowset); $i++) - { - while(list($key, $val) = each($theme_rowset[$i])) - { - if(!intval($key) && $key != "0" && $key != "themes_id") - { - $theme_data .= '$' . $template_name . "[$i]['$key'] = \"" . addslashes($val) . "\";\n"; - } - } - $theme_data .= "\n"; - } - - $theme_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused! - - @umask(0111); - - $fp = @fopen($phpbb_root_path . 'templates/' . $template_name . '/theme_info.cfg', 'w'); - - if( !$fp ) - { - // - // Unable to open the file writeable do something here as an attempt - // to get around that... - // - $s_hidden_fields = '<input type="hidden" name="theme_info" value="' . htmlspecialchars($theme_data) . '" />'; - $s_hidden_fields .= '<input type="hidden" name="send_file" value="1" /><input type="hidden" name="mode" value="export" />'; - - $download_form = '<form action="' . append_sid("admin_styles.$phpEx") . '" method="post"><input type="submit" name="submit" value="' . $lang['Download'] . '" />' . $s_hidden_fields; - - $template->set_filenames(array( - "body" => "message_body.tpl") - ); - - $template->assign_vars(array( - "MESSAGE_TITLE" => $lang['Export_themes'], - "MESSAGE_TEXT" => $lang['Download_theme_cfg'] . "<br /><br />" . $download_form) - ); - - $template->pparse('body'); - exit(); - } - - $result = @fputs($fp, $theme_data, strlen($theme_data)); - fclose($fp); - - $message = $lang['Theme_info_saved'] . "<br /><br />" . sprintf($lang['Click_return_styleadmin'], "<a href=\"" . append_sid("admin_styles.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); - - message_die(GENERAL_MESSAGE, $message); + // + // Output page + // + page_header($lang['Styles']); - } - else if($HTTP_POST_VARS['send_file']) - { - - header("Content-Type: text/x-delimtext; name=\"theme_info.cfg\""); - header("Content-disposition: attachment; filename=theme_info.cfg"); + echo '<form method="post" action="admin_styles.' . $phpEx . '?mode=editimageset">'; - echo stripslashes($HTTP_POST_VARS['theme_info']); - } - else - { - $template->set_filenames(array( - "body" => "admin/styles_exporter.tpl") - ); - - if( $dir = @opendir($phpbb_root_path . 'templates/') ) - { - $s_template_select = '<select name="export_template">'; - while( $file = @readdir($dir) ) - { - if( !is_file($phpbb_root_path . 'templates/' . $file) && !is_link($phpbb_root_path . 'templates/' .$file) && $file != "." && $file != ".." && $file != "CVS" ) - { - $s_template_select .= '<option value="' . $file . '">' . $file . "</option>\n"; - } - } - $s_template_select .= '</select>'; - } - else - { - message_die(GENERAL_MESSAGE, $lang['No_template_dir']); - } - - $template->assign_vars(array( - "L_STYLE_EXPORTER" => $lang['Export_themes'], - "L_EXPORTER_EXPLAIN" => $lang['Export_explain'], - "L_TEMPLATE_SELECT" => $lang['Select_template'], - "L_SUBMIT" => $lang['Submit'], - - "S_EXPORTER_ACTION" => append_sid("admin_styles.$phpEx?mode=export"), - "S_TEMPLATE_SELECT" => $s_template_select) - ); - - $template->pparse("body"); - - } - break; + echo '<h2>Edit Imageset</h2>'; - case "delete": - $style_id = ( isset($HTTP_GET_VARS['style_id']) ) ? intval($HTTP_GET_VARS['style_id']) : intval($HTTP_POST_VARS['style_id']); - - if( !$confirm ) - { - if($style_id == $board_config['default_style']) - { - message_die(GENERAL_MESSAGE, $lang['Cannot_remove_style']); - } - - $hidden_fields = '<input type="hidden" name="mode" value="'.$mode.'" /><input type="hidden" name="style_id" value="'.$style_id.'" />'; - - // - // Set template files - // - $template->set_filenames(array( - "confirm" => "confirm_body.tpl") - ); - - $template->assign_vars(array( - "MESSAGE_TITLE" => $lang['Confirm'], - "MESSAGE_TEXT" => $lang['Confirm_delete_style'], - - "L_YES" => $lang['Yes'], - "L_NO" => $lang['No'], - - "S_CONFIRM_ACTION" => append_sid("admin_styles.$phpEx"), - "S_HIDDEN_FIELDS" => $hidden_fields) - ); - - $template->pparse("confirm"); + echo '<p>Template set: <select name="imgroot">' . $imgroot_options . '</select> <input class="liteoption" type="submit" name="img_root" value="Select" /></p>'; - } - else - { - // - // The user has confirmed the delete. Remove the style, the style element - // names and update any users who might be using this style - // - $sql = "DELETE FROM " . THEMES_TABLE . " - WHERE themes_id = $style_id"; - if(!$result = $db->sql_query($sql, BEGIN_TRANSACTION)) - { - message_die(GENERAL_ERROR, "Could not remove style data!", "", __LINE__, __FILE__, $sql); - } - - // - // There may not be any theme name data so don't throw an error - // if the SQL dosan't work - // - $sql = "DELETE FROM " . THEMES_NAME_TABLE . " - WHERE themes_id = $style_id"; - $db->sql_query($sql); - - $sql = "UPDATE " . USERS_TABLE . " - SET user_style = " . $board_config['default_style'] . " - WHERE user_style = $style_id"; - if(!$result = $db->sql_query($sql, END_TRANSACTION)) - { - message_die(GENERAL_ERROR, "Could not update user style information", "", __LINE__, __FILE__, $sql); - } - - $message = $lang['Style_removed'] . "<br /><br />" . sprintf($lang['Click_return_styleadmin'], "<a href=\"" . append_sid("admin_styles.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); - - message_die(GENERAL_MESSAGE, $message); - } - break; - - default: - - $sql = "SELECT themes_id, template_name, style_name - FROM " . THEMES_TABLE . " - ORDER BY template_name"; - if(!$result = $db->sql_query($sql)) + echo '<p>Use this panel to edit or remove imagesets from the database.</p>'; + + echo '<table cellspacing="1" cellpadding="2" border="0" align="center" bgcolor="#98AAB1">'; + echo '<tr>'; + echo '<td class="cat" colspan="6" height="28" align="center"><span class="gen">Available images: <select name="imageset">' . $imgname_options . '</select></span></td>'; + echo '</tr>'; + echo '<tr>'; + echo '<th height="25">Image</th><th>Source</th><th>Width</th><th>Height</th><th>Border</th><th> </th>'; + echo '</tr>'; + + for($i = 0; $i < count($imageset); $i++) + { + $class = ( !($i%2) ) ? 'row1' : 'row2'; + + echo '<tr>'; + echo '<td class="' . $class . '" height="25"><span class="gen">' . ucfirst(str_replace('_', ' ', $imageset[$i])) . '</span></td>'; + echo '<td class="' . $class . '"><input class="text" type="text" name="src[' . $imageset[$i] . ']" value="' . ( ( !empty($images[$imageset[$i]]) ) ? $images[$imageset[$i]] : '' ) . '" size="20" maxsize="30" /></td>'; + echo '<td class="' . $class . '"><input class="text" type="text" name="width[' . $imageset[$i] . ']" size="3" maxsize="3" /></td>'; + echo '<td class="' . $class . '"><input class="text" type="text" name="height[' . $imageset[$i] . ']" size="3" maxsize="3" /></td>'; + echo '<td class="' . $class . '"><input class="text" type="text" name="border[' . $imageset[$i] . ']" size="2" maxsize="2" /></td>'; + echo '<td class="' . $class . '"><input class="liteoption" type="submit" value="Update" onclick="this.form.' . $imageset[$i] . '.value=this.form.imageset.options[this.form.imageset.selectedIndex].value;return false" /> <input class="liteoption" type="submit" value="Clear" onclick="this.form.' . $imageset[$i] . '.value=\'\';return false" /> </td>'; + echo '</tr>'; + } + + echo '<td class="cat" colspan="6" height="28" align="center"><input class="liteoption" type="submit" name="img_update" value="Update set" /> <input class="liteoption" type="submit" name="img_delete" value="Delete set" /> <input class="liteoption" type="reset" value="Undo" /></td>'; + echo '</tr>'; + echo '</table>'; + echo '</form>'; + +} +else if ( $mode == 'edittemplate' ) +{ + $tplcols = ( isset($HTTP_POST_VARS['tplcols']) ) ? max(60, intval($HTTP_POST_VARS['tplcols'])) : 76; + $tplrows = ( isset($HTTP_POST_VARS['tplrows']) ) ? max(4, intval($HTTP_POST_VARS['tplrows'])) : 30; + $tplname = ( isset($HTTP_POST_VARS['tplname']) ) ? $HTTP_POST_VARS['tplname'] : ''; + $tplroot = ( isset($HTTP_POST_VARS['tplroot']) ) ? $HTTP_POST_VARS['tplroot'] : 'subSilver'; + + $str = ''; + if ( isset($HTTP_POST_VARS['tpl_compile']) && !empty($HTTP_POST_VARS['decompile']) ) + { + $str = "<?php\n" . $template->compile(stripslashes($HTTP_POST_VARS['decompile'])) . "\n?".">"; + + $fp = fopen($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'w+'); + fwrite ($fp, $str); + fclose($fp); + + @chmod($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 0644); + + add_admin_log('log_template_edit', $tplname, $tplroot); + + exit; + } + else if ( !empty($tplname) && isset($HTTP_POST_VARS['tpl_name']) ) + { + $fp = fopen($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'r'); + while ( !feof($fp) ) { - message_die(GENERAL_ERROR, "Could not get style information!", "", __LINE__, __FILE__, $sql); + $str .= fread($fp, 4096); } - - $style_rowset = $db->sql_fetchrowset($result); - - $template->set_filenames(array( - "body" => "admin/styles_list_body.tpl") - ); - - $template->assign_vars(array( - "L_STYLES_TITLE" => $lang['Styles_admin'], - "L_STYLES_TEXT" => $lang['Styles_explain'], - "L_STYLE" => $lang['Style'], - "L_TEMPLATE" => $lang['Template'], - "L_EDIT" => $lang['Edit'], - "L_DELETE" => $lang['Delete']) - ); - - for($i = 0; $i < count($style_rowset); $i++) + @fclose($fp); + + $template->decompile($str); + } + else + { + $str = ( !empty($HTTP_POST_VARS['decompile']) ) ? stripslashes($HTTP_POST_VARS['decompile']) : ''; + } + + if ( isset($HTTP_POST_VARS['tpl_download']) ) + { + header("Content-Type: text/html; name=\"" . $tplname . ".html\""); + header("Content-disposition: attachment; filename=" . $tplname . ".html"); + echo $str; + exit; + + } + + $tplroot_options = get_templates($tplroot); + + $tplname_options = ''; + $dp = opendir($phpbb_root_path . 'templates/cache/' . $tplroot . '/'); + while ( $file = readdir($dp) ) + { + if ( strstr($file, '.html.' . $phpEx) && is_file($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $file) ) { - $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; - $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; - - $template->assign_block_vars("styles", array( - "ROW_CLASS" => $row_class, - "ROW_COLOR" => $row_color, - "STYLE_NAME" => $style_rowset[$i]['style_name'], - "TEMPLATE_NAME" => $style_rowset[$i]['template_name'], - - "U_STYLES_EDIT" => append_sid("admin_styles.$phpEx?mode=edit&style_id=" . $style_rowset[$i]['themes_id']), - "U_STYLES_DELETE" => append_sid("admin_styles.$phpEx?mode=delete&style_id=" . $style_rowset[$i]['themes_id'])) - ); + $tpl = substr($file, 0, strpos($file, '.')); + $selected = ( $tplname == $tpl ) ? ' selected="selected"' : ''; + $tplname_options .= '<option name="' . $tpl . '"' . $selected . '>' . $tpl . '</option>'; } - - $template->pparse("body"); - break; + } + closedir($dp); + + // + // + // + page_header($lang['Styles']); + + echo '<form method="post" action="admin_styles.' . $phpEx . '?mode=edittemplate">'; + + echo '<h2>Edit Template</h2>'; + + echo '<p>Use this panel to edit an existing compiled template set. When you have made the required changes you can recompile the template and (or) download it. Please remember that the existing HTML templates are <b>not</b> altered, only the compiled versions are affected. Therefore you should download any altered files if you wish to keep them for future use and for archival purposes.</p>'; + + echo '<p>Template set: <select name="tplroot">' . $tplroot_options . '</select> <input class="liteoption" type="submit" name="tpl_root" value="Select" /></p>'; + + echo '<table cellspacing="1" cellpadding="0" border="0" align="center" bgcolor="#98AAB1">'; + echo '<tr>'; + echo '<td class="cat"><table width="100%" cellspacing="0" cellpadding="0" border="0">'; + echo '<tr>'; + echo '<td> Template: <select name="tplname">' . $tplname_options . '</select> <input class="liteoption" type="submit" name="tpl_name" value="Select" /></td>'; + echo '<td align="right">Columns: <input type="text" name="tplcols" size="3" maxlength="3" value="' . $tplcols . '" /> Rows: <input type="text" name="tplrows" size="3" maxlength="3" value="' . $tplrows . '" /> <input class="liteoption" type="submit" name="tpl_layout" value="Update" /> </td>'; + echo '</tr>'; + echo '</table></td>'; + echo '</tr>'; + echo '<tr>'; + echo '<td colspan="2" align="center"><textarea style="background-color:#DEE3E7;font-size:9pt;font-family:Courier;line-height:125%" cols="' .$tplcols . '" rows="' .$tplrows . '" name="decompile">' . htmlentities($str) . '</textarea></td>'; + echo '</tr>'; + echo '<tr>'; + echo '<td class="cat" colspan="2" height="28" align="center"><input class="liteoption" type="submit" name="tpl_compile" value="Recompile" /> <input class="liteoption" type="submit" name="tpl_download" value="Download" /> <input class="liteoption" type="reset" value="Undo" /></td>'; + echo '</tr>'; + echo '</table>'; + echo '</form>'; + + page_footer(); } -if( !$HTTP_POST_VARS['send_file'] ) + +// +// +// +function get_templates($tplroot = '') { - include('page_footer_admin.'.$phpEx); + global $db; + + $sql = "SELECT template_name, template_path + FROM " . STYLES_TPL_TABLE . " + ORDER BY template_name"; + $result = $db->sql_query($sql); + + $tplroot_options = ''; + while ( $row = $db->sql_fetchrow($result) ) + { + $selected = ( $tplroot == $row['template_path'] ) ? ' selected="selected"' : ''; + $tplroot_options .= '<option name="' . $row['template_path'] . '"' . $selected . '>' . $row['template_path'] . '</option>'; + } + + return $tplroot_options; } -?> +?>
\ No newline at end of file diff --git a/phpBB/admin/admin_users.php b/phpBB/admin/admin_users.php index 86eb875175..752928021b 100644 --- a/phpBB/admin/admin_users.php +++ b/phpBB/admin/admin_users.php @@ -8,7 +8,6 @@ * * $Id$ * - * ***************************************************************************/ /*************************************************************************** @@ -20,25 +19,39 @@ * ***************************************************************************/ -define('IN_PHPBB', 1); - -if( !empty($setmodules) ) +if ( !empty($setmodules) ) { + if ( !$acl->get_acl_admin('user') ) + { + return; + } + $filename = basename(__FILE__); $module['Users']['Manage'] = $filename; return; } -$phpbb_root_path = "../"; +define('IN_PHPBB', 1); +// +// Include files +// +$phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); require($phpbb_root_path . 'includes/bbcode.'.$phpEx); -require($phpbb_root_path . 'includes/functions_post.'.$phpEx); -require($phpbb_root_path . 'includes/functions_selects.'.$phpEx); +require($phpbb_root_path . 'includes/functions_posting.'.$phpEx); require($phpbb_root_path . 'includes/functions_validate.'.$phpEx); // +// Do we have forum admin permissions? +// +if ( !$acl->get_acl_admin('user') ) +{ + return; +} + +// // Set mode // if( isset( $HTTP_POST_VARS['mode'] ) || isset( $HTTP_GET_VARS['mode'] ) ) @@ -53,7 +66,7 @@ else // // Begin program // -if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) || isset($HTTP_GET_VARS[POST_USERS_URL]) || isset( $HTTP_POST_VARS[POST_USERS_URL]) ) ) +if ( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) || isset($HTTP_GET_VARS['u']) || isset( $HTTP_POST_VARS['u']) ) ) { // // Ok, the profile has been modified and submitted, let's update @@ -65,7 +78,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | $this_userdata = get_userdata($user_id); if( !$this_userdata ) { - message_die(GENERAL_MESSAGE, $lang['No_user_id_specified'] ); + message_die(MESSAGE, $lang['No_user_id_specified'] ); } $username = ( !empty($HTTP_POST_VARS['username']) ) ? trim(strip_tags( $HTTP_POST_VARS['username'] ) ) : ''; @@ -204,10 +217,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | // User is (made) inactive. Delete all their sessions. $sql = "DELETE FROM " . SESSIONS_TABLE . " WHERE session_user_id = $user_id"; - if( !$db->sql_query($sql) ) - { - message_die(GENERAL_ERROR, 'Could not delete this users sessions', '', __LINE__, __FILE__, $sql); - } + $db->sql_query($sql); } if( $signature != "" ) @@ -239,7 +249,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | // // Avatar stuff // - $avatar_sql = ""; + $avatar_sql = ''; if( isset($HTTP_POST_VARS['avatardel']) ) { if( $this_userdata['user_avatar_type'] == USER_AVATAR_UPLOAD && $this_userdata['user_avatar'] != "" ) @@ -515,63 +525,44 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | WHERE ug.user_id = $user_id AND g.group_id = ug.group_id AND g.group_single_user = 1"; - if( !($result = $db->sql_query($sql)) ) - { - message_die(GENERAL_ERROR, 'Could not obtain group information for this user', '', __LINE__, __FILE__, $sql); - } + $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); - + $db->sql_freeresult($result); + + $db->sql_transaction(); + $sql = "UPDATE " . POSTS_TABLE . " SET poster_id = " . ANONYMOUS . ", post_username = '$username' WHERE poster_id = $user_id"; - if( !$db->sql_query($sql) ) - { - message_die(GENERAL_ERROR, 'Could not update posts for this user', '', __LINE__, __FILE__, $sql); - } + $db->sql_query($sql); $sql = "UPDATE " . TOPICS_TABLE . " SET topic_poster = " . ANONYMOUS . " WHERE topic_poster = $user_id"; - if( !$db->sql_query($sql) ) - { - message_die(GENERAL_ERROR, 'Could not update topics for this user', '', __LINE__, __FILE__, $sql); - } + $db->sql_query($sql); $sql = "DELETE FROM " . USERS_TABLE . " WHERE user_id = $user_id"; - if( !$db->sql_query($sql) ) - { - message_die(GENERAL_ERROR, 'Could not delete user', '', __LINE__, __FILE__, $sql); - } + $db->sql_query($sql); $sql = "DELETE FROM " . USER_GROUP_TABLE . " WHERE user_id = $user_id"; - if( !$db->sql_query($sql) ) - { - message_die(GENERAL_ERROR, 'Could not delete user from user_group table', '', __LINE__, __FILE__, $sql); - } + $db->sql_query($sql); $sql = "DELETE FROM " . GROUPS_TABLE . " WHERE group_id = " . $row['group_id']; - if( !$db->sql_query($sql) ) - { - message_die(GENERAL_ERROR, 'Could not delete group for this user', '', __LINE__, __FILE__, $sql); - } + $db->sql_query($sql); $sql = "DELETE FROM " . AUTH_ACCESS_TABLE . " WHERE group_id = " . $row['group_id']; - if( !$db->sql_query($sql) ) - { - message_die(GENERAL_ERROR, 'Could not delete group for this user', '', __LINE__, __FILE__, $sql); - } + $db->sql_query($sql); $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " WHERE user_id = $user_id"; - if ( !$db->sql_query($sql) ) - { - message_die(GENERAL_ERROR, 'Could not delete user from topic watch table', '', __LINE__, __FILE__, $sql); - } + $db->sql_query($sql); + + $db->sql_transaction('commit'); $message = $lang['User_deleted']; @@ -581,30 +572,22 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | $sql = "UPDATE " . USERS_TABLE . " SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) . "', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", $aim) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_sig_bbcode_uid = '$signature_bbcode_uid', user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowavatar = $user_allowavatar, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_allow_pm = $user_allowpm, user_notify_pm = $notifypm, user_popup_pm = $popuppm, user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_active = $user_status, user_rank = $user_rank" . $avatar_sql . " WHERE user_id = $user_id"; - if( $result = $db->sql_query($sql) ) - { - if( isset($rename_user) ) - { - $sql = "UPDATE " . GROUPS_TABLE . " - SET group_name = '".str_replace("\'", "''", $rename_user)."' - WHERE group_name = '".str_replace("\'", "''", $this_userdata['username'] )."'"; - if( !$result = $db->sql_query($sql) ) - { - message_die(GENERAL_ERROR, 'Could not rename users group', '', __LINE__, __FILE__, $sql); - } - } - $message .= $lang['Admin_user_updated']; - } - else + $result = $db->sql_query($sql); + + if ( isset($rename_user) ) { - $error = TRUE; - $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Admin_user_fail']; + $sql = "UPDATE " . GROUPS_TABLE . " + SET group_name = '".str_replace("\'", "''", $rename_user)."' + WHERE group_name = '".str_replace("\'", "''", $this_userdata['username'] )."'"; + $db->sql_query($sql); } + + $message .= $lang['Admin_user_updated']; } - $message .= '<br /><br />' . sprintf($lang['Click_return_useradmin'], '<a href="' . append_sid("admin_users.$phpEx") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>'); + $message .= '<br /><br />' . sprintf($lang['Click_return_useradmin'], '<a href="' . "admin_users.$phpEx$SID" . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . "index.$phpE$SID?pane=right" . '">', '</a>'); - message_die(GENERAL_MESSAGE, $message); + message_die(MESSAGE, $message); } else { @@ -646,7 +629,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | $this_userdata = get_userdata($user_id); if( !$this_userdata ) { - message_die(GENERAL_MESSAGE, $lang['No_user_id_specified'] ); + message_die(MESSAGE, $lang['No_user_id_specified'] ); } } else @@ -654,7 +637,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | $this_userdata = get_userdata( $HTTP_POST_VARS['username'] ); if( !$this_userdata ) { - message_die(GENERAL_MESSAGE, $lang['No_user_id_specified'] ); + message_die(MESSAGE, $lang['No_user_id_specified'] ); } } @@ -870,10 +853,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | $sql = "SELECT * FROM " . RANKS_TABLE . " WHERE rank_special = 1 ORDER BY rank_title"; - if ( !($result = $db->sql_query($sql)) ) - { - message_die(GENERAL_ERROR, 'Could not obtain ranks data', '', __LINE__, __FILE__, $sql); - } + $result = $db->sql_query($sql); $rank_select_box = '<option value="0">' . $lang['No_assigned_rank'] . '</option>'; while( $row = $db->sql_fetchrow($result) ) @@ -1001,7 +981,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | 'S_FORM_ENCTYPE' => $form_enctype, 'HTML_STATUS' => $html_status, - 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="../' . append_sid("faq.$phpEx?mode=bbcode") . '" target="_phpbbcode">', '</a>'), + 'BBCODE_STATUS' => sprintf($bbcode_status, '<a href="../' . "faq.$phpEx$SID&mode=bbcode" . '" target="_phpbbcode">', '</a>'), 'SMILIES_STATUS' => $smilies_status, 'L_DELETE_USER' => $lang['User_delete'], @@ -1009,7 +989,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | 'L_SELECT_RANK' => $lang['Rank_title'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'S_PROFILE_ACTION' => append_sid("admin_users.$phpEx")) + 'S_PROFILE_ACTION' => "admin_users.$phpEx$SID") ); if( file_exists('./../' . $board_config['avatar_path'] ) ) @@ -1027,7 +1007,7 @@ if( $mode == 'edit' || $mode == 'save' && ( isset($HTTP_POST_VARS['username']) | } } - $template->pparse('body'); + $template->display('body'); } else @@ -1041,7 +1021,7 @@ else ORDER BY username"; $result = $db->sql_query($sql); - $select_list = '<select name="' . POST_USERS_URL . '">'; + $select_list = '<select name="u">'; while( $row = $db->sql_fetchrow($result) ) { $select_list .= '<option value="' . $row['user_id'] . '">' . $row['username'] . '</option>'; @@ -1059,15 +1039,15 @@ else 'L_LOOK_UP' => $lang['Look_up_user'], 'L_FIND_USERNAME' => $lang['Find_username'], - 'U_SEARCH_USER' => append_sid("../search.$phpEx?mode=searchuser"), + 'U_SEARCH_USER' => "../search.$phpEx$SID&mode=searchuser", - 'S_USER_ACTION' => append_sid("admin_users.$phpEx"), + 'S_USER_ACTION' => "admin_users.$phpEx$SID", 'S_USER_SELECT' => $select_list) ); - $template->pparse('body'); + $template->display('body'); } include('page_footer_admin.'.$phpEx); -?> +?>
\ No newline at end of file diff --git a/phpBB/admin/admin_words.php b/phpBB/admin/admin_words.php index 72380a43bb..db17648178 100644 --- a/phpBB/admin/admin_words.php +++ b/phpBB/admin/admin_words.php @@ -8,7 +8,6 @@ * * $Id$ * - * ***************************************************************************/ /*************************************************************************** @@ -20,216 +19,214 @@ * ***************************************************************************/ -define('IN_PHPBB', 1); - -if( !empty($setmodules) ) +if ( !empty($setmodules) ) { + if ( !$acl->get_acl_admin('general') ) + { + return; + } + $file = basename(__FILE__); $module['General']['Word_Censor'] = "$file"; return; } +define('IN_PHPBB', 1); // -// Load default header +// Include files // -$phpbb_root_path = "../"; +$phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); -if( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) +// +// Do we have forum admin permissions? +// +if ( !$acl->get_acl_admin('general') ) { - $mode = ($HTTP_GET_VARS['mode']) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; + return; +} + +// +// +// +if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) ) +{ + $mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; } else { // // These could be entered via a form button // - if( isset($HTTP_POST_VARS['add']) ) + if ( isset($HTTP_POST_VARS['add']) ) { - $mode = "add"; + $mode = 'add'; } - else if( isset($HTTP_POST_VARS['save']) ) + else if ( isset($HTTP_POST_VARS['save']) ) { - $mode = "save"; + $mode = 'save'; } else { - $mode = ""; + $mode = ''; } } -if( $mode != "" ) +if( $mode != '' ) { - if( $mode == "edit" || $mode == "add" ) + switch ( $mode ) { - $word_id = ( isset($HTTP_GET_VARS['id']) ) ? $HTTP_GET_VARS['id'] : 0; + case 'edit': + case 'add': + $word_id = ( isset($HTTP_GET_VARS['id']) ) ? $HTTP_GET_VARS['id'] : 0; - $template->set_filenames(array( - "body" => "admin/words_edit_body.tpl") - ); - - $s_hidden_fields = ''; - - if( $mode == "edit" ) - { - if( $word_id ) + $s_hidden_fields = ''; + if ( $mode == 'edit' ) { + if ( !$word_id ) + { + message_die(MESSAGE, $lang['No_word_selected']); + } + $sql = "SELECT * FROM " . WORDS_TABLE . " WHERE word_id = $word_id"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not query words table", "Error", __LINE__, __FILE__, $sql); - } + $result = $db->sql_query($sql); $word_info = $db->sql_fetchrow($result); $s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />'; } - else - { - message_die(GENERAL_MESSAGE, $lang['No_word_selected']); - } - } - $template->assign_vars(array( - "WORD" => $word_info['word'], - "REPLACEMENT" => $word_info['replacement'], + page_header($lang['General']); - "L_WORDS_TITLE" => $lang['Words_title'], - "L_WORDS_TEXT" => $lang['Words_explain'], - "L_WORD_CENSOR" => $lang['Edit_word_censor'], - "L_WORD" => $lang['Word'], - "L_REPLACEMENT" => $lang['Replacement'], - "L_SUBMIT" => $lang['Submit'], +?> - "S_WORDS_ACTION" => append_sid("admin_words.$phpEx"), - "S_HIDDEN_FIELDS" => $s_hidden_fields) - ); +<h1><?php echo $lang['Words_title']; ?></h1> - $template->pparse("body"); +<p><?php echo $lang['Words_explain']; ?></p> - include('page_footer_admin.'.$phpEx); - } - else if( $mode == "save" ) - { - $word_id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : 0; - $word = ( isset($HTTP_POST_VARS['word']) ) ? trim($HTTP_POST_VARS['word']) : ""; - $replacement = ( isset($HTTP_POST_VARS['replacement']) ) ? trim($HTTP_POST_VARS['replacement']) : ""; +<form method="post" action="<?php echo "admin_words.$phpEx$SID"; ?>"><table cellspacing="1" cellpadding="4" border="0" align="center" bgcolor="#98AAB1"> + <tr> + <th colspan="2"><?php echo $lang['Edit_word_censor']; ?></th> + </tr> + <tr> + <td class="row1"><?php echo $lang['Word']; ?></td> + <td class="row2"><input type="text" name="word" value="<?php echo $word_info['word']; ?>" /></td> + </tr> + <tr> + <td class="row1"><?php echo $lang['Replacement']; ?></td> + <td class="row2"><input type="text" name="replacement" value="<?php echo $word_info['replacement']; ?>" /></td> + </tr> + <tr> + <td class="cat" colspan="2" align="center"><?php echo $s_hidden_fields; ?><input class="mainoption" type="submit" name="save" value="<?php echo $lang['Submit']; ?>" /></td> + </tr> +</table></form> - if($word == "" || $replacement == "") - { - message_die(GENERAL_MESSAGE, $lang['Must_enter_word']); - } +<?php - if( $word_id ) - { - $sql = "UPDATE " . WORDS_TABLE . " - SET word = '" . str_replace("\'", "''", $word) . "', replacement = '" . str_replace("\'", "''", $replacement) . "' - WHERE word_id = $word_id"; - $message = $lang['Word_updated']; - } - else - { - $sql = "INSERT INTO " . WORDS_TABLE . " (word, replacement) - VALUES ('" . str_replace("\'", "''", $word) . "', '" . str_replace("\'", "''", $replacement) . "')"; - $message = $lang['Word_added']; - } + break; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Could not insert data into words table", $lang['Error'], __LINE__, __FILE__, $sql); - } + case 'save': + $word_id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : 0; + $word = ( isset($HTTP_POST_VARS['word']) ) ? trim($HTTP_POST_VARS['word']) : ''; + $replacement = ( isset($HTTP_POST_VARS['replacement']) ) ? trim($HTTP_POST_VARS['replacement']) : ''; + + if ( $word == '' || $replacement == '' ) + { + message_die(MESSAGE, $lang['Must_enter_word']); + } - $message .= "<br /><br />" . sprintf($lang['Click_return_wordadmin'], "<a href=\"" . append_sid("admin_words.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); + $sql = ( $word_id ) ? "UPDATE " . WORDS_TABLE . " SET word = '" . str_replace("\'", "''", $word) . "', replacement = '" . str_replace("\'", "''", $replacement) . "' WHERE word_id = $word_id" : "INSERT INTO " . WORDS_TABLE . " (word, replacement) VALUES ('" . str_replace("\'", "''", $word) . "', '" . str_replace("\'", "''", $replacement) . "')"; + $db->sql_query($sql); - message_die(GENERAL_MESSAGE, $message); - } - else if( $mode == "delete" ) - { - if( isset($HTTP_POST_VARS['id']) || isset($HTTP_GET_VARS['id']) ) - { - $word_id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; - } - else - { - $word_id = 0; - } + $log_action = ( $word_id ) ? 'log_edit_word' : 'log_add_word'; + add_admin_log($log_action, stripslashes($word)); - if( $word_id ) - { - $sql = "DELETE FROM " . WORDS_TABLE . " - WHERE word_id = $word_id"; + $message = ( $word_id ) ? $lang['Word_updated'] : $lang['Word_added']; + $message .= '<br /><br />' . sprintf($lang['Click_return_wordadmin'], '<a href="' . "admin_words.$phpEx$SID" . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . "index.$phpEx$SID&pane=right" . '">', '</a>'); - if(!$result = $db->sql_query($sql)) + message_die(MESSAGE, $message); + break; + + case 'delete': + + if ( isset($HTTP_POST_VARS['id']) || isset($HTTP_GET_VARS['id']) ) + { + $word_id = ( isset($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; + } + else { - message_die(GENERAL_ERROR, "Could not remove data from words table", $lang['Error'], __LINE__, __FILE__, $sql); + message_die(MESSAGE, $lang['Must_specify_word']); } - $message = $lang['Word_removed'] . "<br /><br />" . sprintf($lang['Click_return_wordadmin'], "<a href=\"" . append_sid("admin_words.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); + $sql = "DELETE FROM " . WORDS_TABLE . " + WHERE word_id = $word_id"; + $db->sql_query($sql); - message_die(GENERAL_MESSAGE, $message); - } - else - { - message_die(GENERAL_MESSAGE, $lang['Must_specify_word']); - } + add_admin_log('log_delete_word'); + + $message = $lang['Word_removed'] . '<br /><br />' . sprintf($lang['Click_return_wordadmin'], '<a href="' . "admin_words.$phpEx$SID" . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . "index.$phpEx$SID&pane=right" . '">', '</a>'); + + message_die(MESSAGE, $message); + break; } + } else { - $template->set_filenames(array( - "body" => "admin/words_list_body.tpl") - ); + + page_header($lang['General']); + +?> + +<h1><?php echo $lang['Words_title']; ?></h1> + +<p><?php echo $lang['Words_explain']; ?></p> + +<form method="post" action="<?php echo "admin_words.$phpEx$SID"; ?>"><table cellspacing="1" cellpadding="4" border="0" align="center" bgcolor="#98AAB1"> + <tr> + <th><?php echo $lang['Word']; ?></th> + <th><?php echo $lang['Replacement']; ?></th> + <th colspan="2"><?php echo $lang['Action']; ?></th> + </tr> + +<?php $sql = "SELECT * FROM " . WORDS_TABLE . " ORDER BY word"; - if( !$result = $db->sql_query($sql) ) + $result = $db->sql_query($sql); + + if ( $row = $db->sql_fetchrow($result) ) { - message_die(GENERAL_ERROR, "Could not query words table", $lang['Error'], __LINE__, __FILE__, $sql); - } + do + { + $cell_bg = ( $cell_bg == 'row1' ) ? 'row2' : 'row1'; + +?> + <tr> + <td class="<?php echo $cell_bg; ?>" align="center"><?php echo $row['word']; ?></td> + <td class="<?php echo $cell_bg; ?>" align="center"><?php echo $row['replacement']; ?></td> + <td class="<?php echo $cell_bg; ?>"> <a href="<?php echo "admin_words.$phpEx$SID&mode=edit&id=" . $row['word_id']; ?>"><?php echo $lang['Edit']; ?></a> </td> + <td class="<?php echo $cell_bg; ?>"> <a href="<?php echo "admin_words.$phpEx$SID&mode=delete&id=" . $row['word_id']; ?>"><?php echo $lang['Delete']; ?></a> </td> + </tr> +<?php - $word_rows = $db->sql_fetchrowset($result); - $word_count = count($word_rows); + } + while ( $row = $db->sql_fetchrow($result) ); + } - $template->assign_vars(array( - "L_WORDS_TITLE" => $lang['Words_title'], - "L_WORDS_TEXT" => $lang['Words_explain'], - "L_WORD" => $lang['Word'], - "L_REPLACEMENT" => $lang['Replacement'], - "L_EDIT" => $lang['Edit'], - "L_DELETE" => $lang['Delete'], - "L_ADD_WORD" => $lang['Add_new_word'], - "L_ACTION" => $lang['Action'], +?> + <tr> + <td class="cat" colspan="5" height="28" align="center"><?php echo $s_hidden_fields; ?><input class="mainoption" type="submit" name="add" value="<?php echo $lang['Add_new_word']; ?>" /></td> + </tr> +</table></form> - "S_WORDS_ACTION" => append_sid("admin_words.$phpEx"), - "S_HIDDEN_FIELDS" => '') - ); +<?php - for($i = 0; $i < $word_count; $i++) - { - $word = $word_rows[$i]['word']; - $replacement = $word_rows[$i]['replacement']; - $word_id = $word_rows[$i]['word_id']; - - $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; - $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; - - $template->assign_block_vars("words", array( - "ROW_COLOR" => "#" . $row_color, - "ROW_CLASS" => $row_class, - "WORD" => $word, - "REPLACEMENT" => $replacement, - - "U_WORD_EDIT" => append_sid("admin_words.$phpEx?mode=edit&id=$word_id"), - "U_WORD_DELETE" => append_sid("admin_words.$phpEx?mode=delete&id=$word_id")) - ); - } } -$template->pparse("body"); - -include('page_footer_admin.'.$phpEx); +page_footer() ?>
\ No newline at end of file diff --git a/phpBB/admin/forms.css b/phpBB/admin/forms.css new file mode 100644 index 0000000000..ff9c6dc922 --- /dev/null +++ b/phpBB/admin/forms.css @@ -0,0 +1,13 @@ +/* Fancy form styles for IE */ + +input, textarea, select { + border-width: 1px; +} + +input { + text-indent: 2px; +} + +.postbody { + line-height: 18px +} diff --git a/phpBB/admin/images/cellpic1.gif b/phpBB/admin/images/cellpic1.gif Binary files differnew file mode 100644 index 0000000000..715b8d4aa8 --- /dev/null +++ b/phpBB/admin/images/cellpic1.gif diff --git a/phpBB/admin/images/cellpic3.gif b/phpBB/admin/images/cellpic3.gif Binary files differnew file mode 100644 index 0000000000..ecf70e1fd1 --- /dev/null +++ b/phpBB/admin/images/cellpic3.gif diff --git a/phpBB/admin/images/header_bg.jpg b/phpBB/admin/images/header_bg.jpg Binary files differnew file mode 100644 index 0000000000..5ecec5360b --- /dev/null +++ b/phpBB/admin/images/header_bg.jpg diff --git a/phpBB/admin/images/header_left.jpg b/phpBB/admin/images/header_left.jpg Binary files differnew file mode 100644 index 0000000000..aaebf33c7a --- /dev/null +++ b/phpBB/admin/images/header_left.jpg diff --git a/phpBB/admin/index.php b/phpBB/admin/index.php index 79e26edfa2..cfa9e85779 100644 --- a/phpBB/admin/index.php +++ b/phpBB/admin/index.php @@ -1,6 +1,6 @@ <?php /*************************************************************************** - * (admin) index.php + * index.php [ admin/ ] * ------------------- * begin : Saturday, Feb 13, 2001 * copyright : (C) 2001 The phpBB Group @@ -8,7 +8,6 @@ * * $Id$ * - * ***************************************************************************/ /*************************************************************************** @@ -21,24 +20,66 @@ ***************************************************************************/ define('IN_PHPBB', 1); -$no_page_header = TRUE; -$phpbb_root_path = "../"; + +// +// Define some vars +// +$pane = ( isset($HTTP_GET_VARS['pane']) ) ? $HTTP_GET_VARS['pane'] : ''; +$update = ( $pane == 'right' ) ? true : false; + +// +// Include files +// +$phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); +require('pagestart.' . $phpEx); + +// +// Do we have any admin permissions at all? +// +if ( !$acl->get_acl_admin() ) +{ + message_die(MESSAGE, 'No_admin'); +} // // Generate relevant output // -if( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'left' ) +if ( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'top' ) { - $update = false; - require('pagestart.' . $phpEx); + include('page_header_admin.'.$phpEx); + +?> +<table width="100%" cellspacing="0" cellpadding="0" border="0"> + <tr> + <td><a href="index.<?php echo $phpEx; ?>?pane=right" target="main"><img src="images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td> + <td width="100%" background="images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle"><?php echo $lang['Admin_title']; ?></span> </td> + </tr> +</table> + +<?php + + include('page_footer_admin.'.$phpEx); + +} +else if ( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'left' ) +{ + // + // Cheat and use the meta tag to change some stylesheet info + // + $meta = '<style type="text/css">body {background-color: #98AAB1}</style>'; + include('page_header_admin.'.$phpEx); + + // + // Grab module information using Bart's "neat-o-module" system (tm) + // $dir = @opendir('.'); $setmodules = 1; - while( $file = @readdir($dir) ) + while ( $file = @readdir($dir) ) { - if( preg_match('/^admin_.*?\.' . $phpEx . '$/', $file) ) + if ( preg_match('/^admin_(.*?)\.' . $phpEx . '$/', $file) ) { include($file); } @@ -48,90 +89,96 @@ if( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'left' ) unset($setmodules); - include('page_header_admin.'.$phpEx); - - $template->set_filenames(array( - 'body' => 'admin/index_navigate.tpl') - ); - - $template->assign_vars(array( - 'U_FORUM_INDEX' => append_sid("../index.$phpEx"), - 'U_ADMIN_INDEX' => "index.$phpEx$SID&pane=right", - - 'L_FORUM_INDEX' => $lang['Main_index'], - 'L_ADMIN_INDEX' => $lang['Admin_Index'], - 'L_PREVIEW_FORUM' => $lang['Preview_forum']) - ); +?> + +<table width="100%" cellpadding="0" cellspacing="0" border="0"> + <tr> + <td width="100%"><table width="100%" cellpadding="4" cellspacing="1" border="0"> + <tr> + <th class="menu" height="25">» <?php echo $lang['Return_to']; ?></th> + </tr> + <tr> + <td class="row1"><a class="genmed" href="index.<?php echo $phpEx; ?>?pane=right" target="main"><?php echo $lang['Admin_Index']; ?></a></td> + </tr> + <tr> + <td class="row2"><a class="genmed" href="../" target="_top"><?php echo $lang['Forum_index']; ?></a></td> + </tr> +<?php - ksort($module); + @ksort($module); - while( list($cat, $action_array) = each($module) ) + foreach ( $module as $cat => $action_ary ) { $cat = ( !empty($lang[$cat]) ) ? $lang[$cat] : preg_replace('/_/', ' ', $cat); - $template->assign_block_vars('catrow', array( - 'ADMIN_CATEGORY' => $cat) - ); +?> + <tr> + <th class="menu" height="25">» <?php echo $cat; ?></th> + </tr> +<?php - ksort($action_array); + ksort($action_ary); - $row_count = 0; - while( list($action, $file) = each($action_array) ) + foreach ( $action_ary as $action => $file ) { - $row_color = ( !($row_count%2) ) ? $theme['td_color1'] : $theme['td_color2']; - $row_class = ( !($row_count%2) ) ? $theme['td_class1'] : $theme['td_class2']; - $action = ( !empty($lang[$action]) ) ? $lang[$action] : preg_replace('/_/', ' ', $action); - $template->assign_block_vars('catrow.modulerow', array( - 'ROW_COLOR' => "#" . $row_color, - 'ROW_CLASS' => $row_class, + $cell_bg = ( $cell_bg == 'row1' ) ? 'row2' : 'row1'; +?> + <tr> + <td class="<?php echo $cell_bg; ?>"><a class="genmed" href="<?php echo $file; ?>" target="main"><?php echo $action; ?></a></td> + </tr> +<?php - 'ADMIN_MODULE' => $action, - 'U_ADMIN_MODULE' => append_sid($file)) - ); - $row_count++; } } - $template->pparse("body"); +?> + </table></td> + </tr> +</table> +</body> +</html> +<?php + // + // Output footer but don't include copyright info + // + $ignore_copyright = true; include('page_footer_admin.'.$phpEx); + } -elseif( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' ) +elseif ( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' ) { - $update = true; - require('pagestart.' . $phpEx); + if ( ( isset($HTTP_POST_VARS['activate']) || isset($HTTP_POST_VARS['delete']) ) && !empty($HTTP_POST_VARS['mark']) ) + { + if ( is_array($HTTP_POST_VARS['mark']) ) + { + $in_sql = ''; + foreach( $HTTP_POST_VARS['mark'] as $user_id ) + { + $in_sql .= ( ( $in_sql != '' ) ? ', ' : '' ) . $user_id; + } - include('page_header_admin.'.$phpEx); + if ( $in_sql != '' ) + { + $sql = ( isset($HTTP_POST_VARS['activate']) ) ? "UPDATE " . USERS_TABLE . " SET user_active = 1 WHERE user_id IN ($in_sql)" : "DELETE FROM " . USERS_TABLE . " WHERE user_id IN ($in_sql)"; + $db->sql_query($sql); - $template->set_filenames(array( - 'body' => 'admin/index_body.tpl') - ); - - $template->assign_vars(array( - 'L_WELCOME' => $lang['Welcome_phpBB'], - 'L_ADMIN_INTRO' => $lang['Admin_intro'], - 'L_FORUM_STATS' => $lang['Forum_stats'], - 'L_WHO_IS_ONLINE' => $lang['Who_is_Online'], - 'L_LOCATION' => $lang['Location'], - 'L_LAST_UPDATE' => $lang['Last_updated'], - 'L_IP_ADDRESS' => $lang['IP_Address'], - 'L_STATISTIC' => $lang['Statistic'], - 'L_VALUE' => $lang['Value'], - 'L_NUMBER_POSTS' => $lang['Number_posts'], - 'L_POSTS_PER_DAY' => $lang['Posts_per_day'], - 'L_NUMBER_TOPICS' => $lang['Number_topics'], - 'L_TOPICS_PER_DAY' => $lang['Topics_per_day'], - 'L_NUMBER_USERS' => $lang['Number_users'], - 'L_USERS_PER_DAY' => $lang['Users_per_day'], - 'L_BOARD_STARTED' => $lang['Board_started'], - 'L_AVATAR_DIR_SIZE' => $lang['Avatar_dir_size'], - 'L_DB_SIZE' => $lang['Database_size'], - 'L_FORUM_LOCATION' => $lang['Forum_Location'], - 'L_STARTED' => $lang['Login'], - 'L_GZIP_COMPRESSION' => $lang['Gzip_compression']) - ); + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = config_value - " . sizeof($HTTP_POST_VARS['mark']) . " + WHERE config_name = 'num_users'"; + $db->sql_query($sql); + + $log_action = ( isset($HTTP_POST_VARS['activate']) ) ? 'log_index_activate' : 'log_index_delete'; + add_admin_log($log_action, sizeof($HTTP_POST_VARS['mark'])); + } + } + } + else if ( isset($HTTP_POST_VARS['remind']) ) + { + + } // // Get forum statistics @@ -150,11 +197,11 @@ elseif( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' ) $avatar_dir_size = 0; - if ($avatar_dir = @opendir($phpbb_root_path . $board_config['avatar_path'])) + if ( $avatar_dir = @opendir($phpbb_root_path . $board_config['avatar_path']) ) { - while( $file = @readdir($avatar_dir) ) + while ( $file = @readdir($avatar_dir) ) { - if( $file != '.' && $file != '..' ) + if ( $file != '.' && $file != '..' ) { $avatar_dir_size += @filesize($phpbb_root_path . $board_config['avatar_path'] . '/' . $file); } @@ -166,11 +213,11 @@ elseif( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' ) // Borrowed the code from the PHP.net annoted manual, origanally written by: // Jesse (jesse@jess.on.ca) // - if($avatar_dir_size >= 1048576) + if ( $avatar_dir_size >= 1048576 ) { $avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 . ' MB'; } - else if($avatar_dir_size >= 1024) + else if ( $avatar_dir_size >= 1024 ) { $avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 . ' KB'; } @@ -186,17 +233,17 @@ elseif( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' ) $avatar_dir_size = $lang['Not_available']; } - if($posts_per_day > $total_posts) + if ( $posts_per_day > $total_posts ) { $posts_per_day = $total_posts; } - if($topics_per_day > $total_topics) + if ( $topics_per_day > $total_topics ) { $topics_per_day = $total_topics; } - if($users_per_day > $total_users) + if ( $users_per_day > $total_users ) { $users_per_day = $total_users; } @@ -207,43 +254,40 @@ elseif( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' ) // This code is heavily influenced by a similar routine // in phpMyAdmin 2.2.0 // - if( preg_match('/^mysql/', SQL_LAYER) ) + if ( preg_match('/^mysql/', SQL_LAYER) ) { - $sql = "SELECT VERSION() AS mysql_version"; - if($result = $db->sql_query($sql)) + $result = $db->sql_query('SELECT VERSION() AS mysql_version'); + + if ( $row = $db->sql_fetchrow($result) ) { - $row = $db->sql_fetchrow($result); $version = $row['mysql_version']; - if( preg_match('/^(3\.23|4\.)/', $version) ) + if ( preg_match('/^(3\.23|4\.)/', $version) ) { $db_name = ( preg_match('/^(3\.23\.[6-9])|(3\.23\.[1-9][1-9])|(4\.)/', $version) ) ? "`$dbname`" : $dbname; $sql = "SHOW TABLE STATUS FROM " . $db_name; - if($result = $db->sql_query($sql)) + $result = $db->sql_query($sql); + + $dbsize = 0; + while ( $row = $db->sql_fetchrow($result) ) { - $tabledata_ary = $db->sql_fetchrowset($result); - - $dbsize = 0; - for($i = 0; $i < count($tabledata_ary); $i++) + if ( $row['Type'] != 'MRG_MyISAM' ) { - if( $tabledata_ary[$i]['Type'] != 'MRG_MyISAM' ) + if ( $table_prefix != '' ) { - if( $table_prefix != "" ) + if ( strstr($row['Name'], $table_prefix) ) { - if( strstr($tabledata_ary[$i]['Name'], $table_prefix) ) - { - $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length']; - } - } - else - { - $dbsize += $tabledata_ary[$i]['Data_length'] + $tabledata_ary[$i]['Index_length']; + $dbsize += $row['Data_length'] + $row['Index_length']; } } + else + { + $dbsize += $row['Data_length'] + $row['Index_length']; + } } - } // Else we couldn't get the table status. + } } else { @@ -255,18 +299,13 @@ elseif( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' ) $dbsize = $lang['Not_available']; } } - else if( preg_match('/^mssql/', SQL_LAYER) ) + else if ( preg_match('/^mssql/', SQL_LAYER) ) { $sql = "SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize FROM sysfiles"; - if( $result = $db->sql_query($sql) ) - { - $dbsize = ( $row = $db->sql_fetchrow($result) ) ? intval($row['dbsize']) : $lang['Not_available']; - } - else - { - $dbsize = $lang['Not_available']; - } + $result = $db->sql_query($sql); + + $dbsize = ( $row = $db->sql_fetchrow($result) ) ? intval($row['dbsize']) : $lang['Not_available']; } else { @@ -275,298 +314,205 @@ elseif( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' ) if ( is_integer($dbsize) ) { - if( $dbsize >= 1048576 ) - { - $dbsize = sprintf('%.2f MB', ( $dbsize / 1048576 )); - } - else if( $dbsize >= 1024 ) - { - $dbsize = sprintf('%.2f KB', ( $dbsize / 1024 )); - } - else - { - $dbsize = sprintf('%.2f Bytes', $dbsize); - } - } - - $template->assign_vars(array( - 'NUMBER_OF_POSTS' => $total_posts, - 'NUMBER_OF_TOPICS' => $total_topics, - 'NUMBER_OF_USERS' => $total_users, - 'START_DATE' => $start_date, - 'POSTS_PER_DAY' => $posts_per_day, - 'TOPICS_PER_DAY' => $topics_per_day, - 'USERS_PER_DAY' => $users_per_day, - 'AVATAR_DIR_SIZE' => $avatar_dir_size, - 'DB_SIZE' => $dbsize, - 'GZIP_COMPRESSION' => ( $board_config['gzip_compress'] ) ? $lang['ON'] : $lang['OFF']) - ); - // - // End forum statistics - // - - // - // Get users online information. - // - $sql = "SELECT u.user_id, u.username, u.user_session_time, u.user_session_page, s.session_ip, s.session_start - FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE . " s - WHERE s.session_logged_in = " . TRUE . " - AND u.user_id = s.session_user_id - AND u.user_id <> " . ANONYMOUS . " - AND u.user_session_time >= " . ( time() - 300 ) . " - ORDER BY u.user_session_time DESC"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Couldn't obtain regd user/online information.", "", __LINE__, __FILE__, $sql); + $dbsize = ( $dbsize >= 1048576 ) ? sprintf('%.2f MB', ( $dbsize / 1048576 )) : ( ( $dbsize >= 1024 ) ? sprintf('%.2f KB', ( $dbsize / 1024 )) : sprintf('%.2f Bytes', $dbsize) ); } - $onlinerow_reg = $db->sql_fetchrowset($result); - - $sql = "SELECT session_page, session_time, session_ip, session_start - FROM " . SESSIONS_TABLE . " - WHERE session_logged_in = 0 - AND session_time >= " . ( time() - 300 ) . " - ORDER BY session_time DESC"; - if(!$result = $db->sql_query($sql)) - { - message_die(GENERAL_ERROR, "Couldn't obtain guest user/online information.", "", __LINE__, __FILE__, $sql); - } - $onlinerow_guest = $db->sql_fetchrowset($result); - $sql = "SELECT forum_name, forum_id - FROM " . FORUMS_TABLE; - if($forums_result = $db->sql_query($sql)) - { - while($forumsrow = $db->sql_fetchrow($forums_result)) - { - $forum_data[$forumsrow['forum_id']] = $forumsrow['forum_name']; - } - } - else - { - message_die(GENERAL_ERROR, "Couldn't obtain user/online forums information.", "", __LINE__, __FILE__, $sql); - } + page_header($lang['Admin_Index']); + +?> + +<h1><?php echo $lang['Welcome_phpBB']; ?></h1> + +<p><?php echo $lang['Admin_intro']; ?></p> + +<h1><?php echo $lang['Forum_stats']; ?></h1> + +<table class="bg" width="100%" cellpadding="4" cellspacing="1" border="0"> + <tr> + <th width="25%" nowrap="nowrap" height="25"><?php echo $lang['Statistic']; ?></th> + <th width="25%"><?php echo $lang['Value']; ?></th> + <th width="25%" nowrap="nowrap"><?php echo $lang['Statistic']; ?></th> + <th width="25%"><?php echo $lang['Value']; ?></th> + </tr> + <tr> + <td class="row1" nowrap="nowrap"><?php echo $lang['Number_posts']; ?>:</td> + <td class="row2"><b><?php echo $total_posts; ?></b></td> + <td class="row1" nowrap="nowrap"><?php echo $lang['Posts_per_day']; ?>:</td> + <td class="row2"><b><?php echo $posts_per_day; ?></b></td> + </tr> + <tr> + <td class="row1" nowrap="nowrap"><?php echo $lang['Number_topics']; ?>:</td> + <td class="row2"><b><?php echo $total_topics; ?></b></td> + <td class="row1" nowrap="nowrap"><?php echo $lang['Topics_per_day']; ?>:</td> + <td class="row2"><b><?php echo $topics_per_day; ?></b></td> + </tr> + <tr> + <td class="row1" nowrap="nowrap"><?php echo $lang['Number_users']; ?>:</td> + <td class="row2"><b><?php echo $total_users; ?></b></td> + <td class="row1" nowrap="nowrap"><?php echo $lang['Users_per_day']; ?>:</td> + <td class="row2"><b><?php echo $users_per_day; ?></b></td> + </tr> + <tr> + <td class="row1" nowrap="nowrap"><?php echo $lang['Board_started']; ?>:</td> + <td class="row2"><b><?php echo $start_date; ?></b></td> + <td class="row1" nowrap="nowrap"><?php echo $lang['Avatar_dir_size']; ?>:</td> + <td class="row2"><b><?php echo $avatar_dir_size; ?></b></td> + </tr> + <tr> + <td class="row1" nowrap="nowrap"><?php echo $lang['Database_size']; ?>:</td> + <td class="row2"><b><?php echo $dbsize; ?></b></td> + <td class="row1" nowrap="nowrap"><?php echo $lang['Gzip_compression']; ?>:</td> + <td class="row2"><b><?php echo ( $board_config['gzip_compress'] ) ? $lang['ON'] : $lang['OFF']; ?></b></td> + </tr> +</table> + +<h1><?php echo $lang['Admin_log']; ?></h1> + +<p><?php echo $lang['Admin_log_index_explain']; ?></p> + +<table class="bg" width="100%" cellpadding="4" cellspacing="1" border="0"> + <tr> + <th width="15%" height="25" nowrap="nowrap"><?php echo $lang['Username']; ?></th> + <th width="15%"><?php echo $lang['IP']; ?></th> + <th width="20%"><?php echo $lang['Time']; ?></th> + <th width="45%" nowrap="nowrap"><?php echo $lang['Action']; ?></th> + </tr> +<?php - $reg_userid_ary = array(); + $log_data = view_admin_log(5); - if( count($onlinerow_reg) ) + for($i = 0; $i < sizeof($log_data); $i++) { - $registered_users = 0; + $cell_bg = ( $cell_bg == 'row1' ) ? 'row2' : 'row1'; + +?> + <tr> + <td class="<?php echo $cell_bg; ?>"><?php echo $log_data[$i]['username']; ?></td> + <td class="<?php echo $cell_bg; ?>" align="center"><?php echo $log_data[$i]['ip']; ?></td> + <td class="<?php echo $cell_bg; ?>" align="center"><?php echo create_date($board_config['default_dateformat'], $log_data[$i]['time'], $board_config['board_timezone']); ?></td> + <td class="<?php echo $cell_bg; ?>"><?php echo $log_data[$i]['action']; ?></td> + </tr> +<?php - for($i = 0; $i < count($onlinerow_reg); $i++) - { - if( !inarray($onlinerow_reg[$i]['user_id'], $reg_userid_ary) ) - { - $reg_userid_ary[] = $onlinerow_reg[$i]['user_id']; + } - $username = $onlinerow_reg[$i]['username']; +?> +</table> - if( $onlinerow_reg[$i]['user_allow_viewonline'] || $userdata['user_level'] == ADMIN ) - { - $registered_users++; - $hidden = FALSE; - } - else - { - $hidden_users++; - $hidden = TRUE; - } +<h1><?php echo $lang['Inactive_users']; ?></h1> - if( $onlinerow_reg[$i]['user_session_page'] < 1 ) - { - switch($onlinerow_reg[$i]['user_session_page']) - { - case PAGE_INDEX: - $location = $lang['Forum_index']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_POSTING: - $location = $lang['Posting_message']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_LOGIN: - $location = $lang['Logging_on']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_SEARCH: - $location = $lang['Searching_forums']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_PROFILE: - $location = $lang['Viewing_profile']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_VIEWONLINE: - $location = $lang['Viewing_online']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_VIEWMEMBERS: - $location = $lang['Viewing_member_list']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_PRIVMSGS: - $location = $lang['Viewing_priv_msgs']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_FAQ: - $location = $lang['Viewing_FAQ']; - $location_url = "index.$phpEx?pane=right"; - break; - default: - $location = $lang['Forum_index']; - $location_url = "index.$phpEx?pane=right"; - } - } - else - { - $location_url = append_sid("admin_forums.$phpEx?mode=editforum&" . POST_FORUM_URL . "=" . $onlinerow_reg[$i]['user_session_page']); - $location = $forum_data[$onlinerow_reg[$i]['user_session_page']]; - } +<p><?php echo $lang['Inactive_users_explain']; ?></p> - $row_color = ( $registered_users % 2 ) ? $theme['td_color1'] : $theme['td_color2']; - $row_class = ( $registered_users % 2 ) ? $theme['td_class1'] : $theme['td_class2']; - - $reg_ip = $onlinerow_reg[$i]['session_ip']; +<form method="post" name="inactive" action="<?php echo "index.$phpEx$SID&pane=right"; ?>"><table class="bg" width="100%" cellpadding="4" cellspacing="1" border="0"> + <tr> + <th width="45%" height="25" nowrap="nowrap"><?php echo $lang['Username']; ?></th> + <th width="45%"><?php echo $lang['Joined']; ?></th> + <th width="5%" nowrap="nowrap"><?php echo $lang['Mark']; ?></th> + </tr> +<?php - $template->assign_block_vars("reg_user_row", array( - 'ROW_COLOR' => "#" . $row_color, - 'ROW_CLASS' => $row_class, - 'USERNAME' => $username, - 'STARTED' => create_date($board_config['default_dateformat'], $onlinerow_reg[$i]['session_start'], $board_config['board_timezone']), - 'LASTUPDATE' => create_date($board_config['default_dateformat'], $onlinerow_reg[$i]['user_session_time'], $board_config['board_timezone']), - 'FORUM_LOCATION' => $location, - 'IP_ADDRESS' => $reg_ip, + $sql = "SELECT user_id, username, user_regdate + FROM " . USERS_TABLE . " + WHERE user_active = 0 + ORDER BY user_regdate ASC"; + $result = $db->sql_query($sql); - 'U_WHOIS_IP' => "http://www.samspade.org/t/ipwhois?a=$reg_ip", - 'U_USER_PROFILE' => append_sid("admin_users.$phpEx?mode=edit&" . POST_USERS_URL . "=" . $onlinerow_reg[$i]['user_id']), - 'U_FORUM_LOCATION' => append_sid($location_url)) - ); - } + if ( $row = $db->sql_fetchrow($result) ) + { + do + { + $cell_bg = ( $cell_bg == 'row1' ) ? 'row2' : 'row1'; +?> + <tr> + <td class="<?php echo $cell_bg; ?>"><a href="<?php echo 'admin_users.' . $phpEx . $SID . '&u=' . $row['user_id']; ?>"><?php echo $row['username']; ?></a></td> + <td class="<?php echo $cell_bg; ?>"><?php echo create_date($board_config['default_dateformat'], $row['user_regdate'], $board_config['board_timezone']); ?></td> + <td class="<?php echo $cell_bg; ?>"> <input type="checkbox" name="mark[]" value="<?php echo $row['user_id']; ?>" /> </td> + </tr> +<?php } + while ( $row = $db->sql_fetchrow($result) ); + +?> + <tr> + <td class="cat" colspan="3" height="28" align="right"><input class="liteoption" type="submit" name="activate" value="Activate" /> <input class="liteoption" type="submit" name="remind" value="Remind" /> <input class="liteoption" type="submit" name="delete" value="Delete" /> </td> + </tr> +<?php } else { - $template->assign_vars(array( - "L_NO_REGISTERED_USERS_BROWSING" => $lang['No_users_browsing']) - ); - } - // - // Guest users - // - if( count($onlinerow_guest) ) - { - $guest_users = 0; - - for($i = 0; $i < count($onlinerow_guest); $i++) - { - $guest_userip_ary[] = $onlinerow_guest[$i]['session_ip']; - $guest_users++; +?> + <tr> + <td class="row1" colspan="3" align="center"><?php echo $lang['No_inactive_users']; ?></td> + </tr> +<?php - if( $onlinerow_guest[$i]['session_page'] < 1 ) - { - switch( $onlinerow_guest[$i]['session_page'] ) - { - case PAGE_INDEX: - $location = $lang['Forum_index']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_POSTING: - $location = $lang['Posting_message']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_LOGIN: - $location = $lang['Logging_on']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_SEARCH: - $location = $lang['Searching_forums']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_PROFILE: - $location = $lang['Viewing_profile']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_VIEWONLINE: - $location = $lang['Viewing_online']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_VIEWMEMBERS: - $location = $lang['Viewing_member_list']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_PRIVMSGS: - $location = $lang['Viewing_priv_msgs']; - $location_url = "index.$phpEx?pane=right"; - break; - case PAGE_FAQ: - $location = $lang['Viewing_FAQ']; - $location_url = "index.$phpEx?pane=right"; - break; - default: - $location = $lang['Forum_index']; - $location_url = "index.$phpEx?pane=right"; - } - } - else - { - $location_url = append_sid("admin_forums.$phpEx?mode=editforum&" . POST_FORUM_URL . "=" . $onlinerow_guest[$i]['session_page']); - $location = $forum_data[$onlinerow_guest[$i]['session_page']]; - } + } - $row_color = ( $guest_users % 2 ) ? $theme['td_color1'] : $theme['td_color2']; - $row_class = ( $guest_users % 2 ) ? $theme['td_class1'] : $theme['td_class2']; - $guest_ip = $onlinerow_guest[$i]['session_ip']; +?> +</table> - $template->assign_block_vars('guest_user_row', array( - 'ROW_COLOR' => "#" . $row_color, - 'ROW_CLASS' => $row_class, - 'USERNAME' => $lang['Guest'], - 'STARTED' => create_date($board_config['default_dateformat'], $onlinerow_guest[$i]['session_start'], $board_config['board_timezone']), - 'LASTUPDATE' => create_date($board_config['default_dateformat'], $onlinerow_guest[$i]['session_time'], $board_config['board_timezone']), - 'FORUM_LOCATION' => $location, - 'IP_ADDRESS' => $guest_ip, +<table width="100%" cellspacing="1" cellpadding="4" border="0" align="center"> + <tr> + <td align="right" valign="top" nowrap="nowrap"><b><span class="gensmall"><a href="javascript:marklist(true);" class="gensmall"><?php echo $lang['Mark_all']; ?></a> :: <a href="javascript:marklist(false);" class="gensmall"><?php echo $lang['Unmark_all']; ?></a></span></b></td> + </tr> +</table></form> - 'U_WHOIS_IP' => "http://www.samspade.org/t/ipwhois?a=$guest_ip", - 'U_FORUM_LOCATION' => append_sid($location_url)) - ); - } + </td> + </tr> +</table> - } - else +<script language="Javascript" type="text/javascript"> + // + // Should really check the browser to stop this whining ... + // + function marklist(status) { - $template->assign_vars(array( - 'L_NO_GUESTS_BROWSING' => $lang['No_users_browsing']) - ); + for (i = 0; i < document.inactive.length; i++) + { + document.inactive.elements[i].checked = status; + } } +</script> - $template->pparse('body'); +<?php - include('page_footer_admin.'.$phpEx); + page_footer(); } else { - $update = false; - require('pagestart.' . $phpEx); - // - // Generate frameset + // Output the frameset ... // - $template->set_filenames(array( - "body" => "admin/index_frameset.tpl") - ); - - $template->assign_vars(array( - 'S_FRAME_NAV' => "index.$phpEx$SID&pane=left", - 'S_FRAME_MAIN' => "index.$phpEx$SID&pane=right") - ); - - header ('Expires: ' . gmdate("D, d M Y H:i:s", time()) . ' GMT'); - header ('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT'); + header("Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); + header("Content-type: text/html; charset=" . $lang['ENCODING']); + +?> +<html> +<head> +<title><?php echo $lang['Admin_title']; ?></title> +</head> + +<frameset rows="60, *" border="0" framespacing="0" frameborder="NO"> + <frame src="<?php echo "index.$phpEx$SID&pane=top"; ?>" name="title" noresize marginwidth="0" marginheight="0" scrolling="NO"> + <frameset cols="155,*" rows="*" border="2" framespacing="0" frameborder="yes"> + <frame src="<?php echo "index.$phpEx$SID&pane=left"; ?>" name="nav" marginwidth="3" marginheight="3" scrolling="yes"> + <frame src="<?php echo "index.$phpEx$SID&pane=right"; ?>" name="main" marginwidth="0" marginheight="0" scrolling="auto"> + </frameset> +</frameset> + +<noframes> + <body bgcolor="white" text="#000000"> + <p><?php echo $lang['No_frames']; ?></p> + </body> +</noframes> +</html> +<?php - $template->pparse("body"); exit; } diff --git a/phpBB/admin/page_footer_admin.php b/phpBB/admin/page_footer_admin.php index e181640451..96ba8a40e6 100644 --- a/phpBB/admin/page_footer_admin.php +++ b/phpBB/admin/page_footer_admin.php @@ -8,7 +8,6 @@ * * $Id$ * - * ***************************************************************************/ /*************************************************************************** @@ -22,22 +21,23 @@ if ( !defined('IN_PHPBB') ) { - die("Hacking attempt"); + die('Hacking attempt'); } -// -// Show the overall footer. -// -$template->set_filenames(array( - 'page_footer' => 'admin/page_footer.tpl') -); +if ( !$ignore_copyright ) +{ + +?> -$template->assign_vars(array( - 'PHPBB_VERSION' => '2' . $board_config['version'], - 'TRANSLATION_INFO' => $lang['TRANSLATION_INFO']) -); +<div align="center"><span class="copyright">Powered by phpBB <?php echo $board_config['version']; ?> © 2002 <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a></span></div> -$template->pparse('page_footer'); +<br clear="all" /> + +</body> +</html> +<?php + +} // // Close our DB connection. @@ -48,7 +48,7 @@ $db->sql_close(); // Compress buffered output if required // and send to browser // -if( $do_gzip_compress ) +if ( $do_gzip_compress ) { // // Borrowed from php.net! @@ -62,10 +62,10 @@ if( $do_gzip_compress ) $gzip_contents = gzcompress($gzip_contents, 9); $gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4); - echo '\x1f\x8b\x08\x00\x00\x00\x00\x00'; + echo "\x1f\x8b\x08\x00\x00\x00\x00\x00"; echo $gzip_contents; - echo pack('V', $gzip_crc); - echo pack('V', $gzip_size); + echo pack("V", $gzip_crc); + echo pack("V", $gzip_size); } exit; diff --git a/phpBB/admin/page_header_admin.php b/phpBB/admin/page_header_admin.php index 7786d464c4..dffbc6cd12 100644 --- a/phpBB/admin/page_header_admin.php +++ b/phpBB/admin/page_header_admin.php @@ -22,7 +22,7 @@ if ( !defined('IN_PHPBB') ) { - die("Hacking attempt"); + die('Hacking attempt'); } define('HEADER_INC', true); @@ -31,124 +31,57 @@ define('HEADER_INC', true); // gzip_compression // $do_gzip_compress = FALSE; -if($board_config['gzip_compress']) +if ( $board_config['gzip_compress'] ) { $phpver = phpversion(); - if($phpver >= '4.0.4pl1') + if ( $phpver >= '4.0.4pl1' && strstr($HTTP_USER_AGENT,'compatible') ) { - if(extension_loaded('zlib')) + if ( extension_loaded('zlib') ) { ob_start('ob_gzhandler'); } } - else if($phpver > '4.0') + else if ( $phpver > '4.0' ) { - if(strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip')) + if ( strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip') ) { - if(extension_loaded('zlib')) + if ( extension_loaded('zlib') ) { $do_gzip_compress = TRUE; ob_start(); ob_implicit_flush(0); - header('Content-Encoding: gzip'); + header("Content-Encoding: gzip"); } } } } -$template->set_filenames(array( - 'header' => 'admin/page_header.tpl') -); +header("Content-type: text/html; charset=" . $lang['ENCODING']); -// -// The following assigns all _common_ variables that may be used at any point -// in a template. Note that all URL's should be wrapped in append_sid, as -// should all S_x_ACTIONS for forms. -// -$template->assign_vars(array( - 'SITENAME' => $board_config['sitename'], - 'PAGE_TITLE' => $page_title, - - 'L_ADMIN' => $lang['Admin'], - 'L_USERNAME' => $lang['Username'], - 'L_PASSWORD' => $lang['Password'], - 'L_INDEX' => $lang['Forum_Index'], - 'L_REGISTER' => $lang['Register'], - 'L_PROFILE' => $lang['Profile'], - 'L_SEARCH' => $lang['Search'], - 'L_PRIVATEMSGS' => $lang['Private_msgs'], - 'L_MEMBERLIST' => $lang['Memberlist'], - 'L_FAQ' => $lang['FAQ'], - 'L_USERGROUPS' => $lang['Usergroups'], - 'L_FORUM' => $lang['Forum'], - 'L_TOPICS' => $lang['Topics'], - 'L_REPLIES' => $lang['Replies'], - 'L_VIEWS' => $lang['Views'], - 'L_POSTS' => $lang['Posts'], - 'L_LASTPOST' => $lang['Last_Post'], - 'L_MODERATOR' => $lang['Moderator'], - 'L_NONEWPOSTS' => $lang['No_new_posts'], - 'L_NEWPOSTS' => $lang['New_posts'], - 'L_POSTED' => $lang['Posted'], - 'L_JOINED' => $lang['Joined'], - 'L_AUTHOR' => $lang['Author'], - 'L_MESSAGE' => $lang['Message'], - 'L_BY' => $lang['by'], - - 'U_INDEX' => append_sid('../index.'.$phpEx), - - 'S_TIMEZONE' => sprintf($lang['All_times'], $lang[$board_config['board_timezone']]), - 'S_LOGIN_ACTION' => append_sid('../login.'.$phpEx), - 'S_JUMPBOX_ACTION' => append_sid('../viewforum.'.$phpEx), - 'S_CURRENT_TIME' => sprintf($lang['Current_time'], create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])), - 'S_CONTENT_DIRECTION' => $lang['DIRECTION'], - 'S_CONTENT_ENCODING' => $lang['ENCODING'], - 'S_CONTENT_DIR_LEFT' => $lang['LEFT'], - 'S_CONTENT_DIR_RIGHT' => $lang['RIGHT'], +?> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<link rel="stylesheet" href="subSilver.css" type="text/css"> +<?php - 'T_HEAD_STYLESHEET' => $theme['head_stylesheet'], - 'T_BODY_BACKGROUND' => $theme['body_background'], - 'T_BODY_BGCOLOR' => '#'.$theme['body_bgcolor'], - 'T_BODY_TEXT' => '#'.$theme['body_text'], - 'T_BODY_LINK' => '#'.$theme['body_link'], - 'T_BODY_VLINK' => '#'.$theme['body_vlink'], - 'T_BODY_ALINK' => '#'.$theme['body_alink'], - 'T_BODY_HLINK' => '#'.$theme['body_hlink'], - 'T_TR_COLOR1' => '#'.$theme['tr_color1'], - 'T_TR_COLOR2' => '#'.$theme['tr_color2'], - 'T_TR_COLOR3' => '#'.$theme['tr_color3'], - 'T_TR_CLASS1' => $theme['tr_class1'], - 'T_TR_CLASS2' => $theme['tr_class2'], - 'T_TR_CLASS3' => $theme['tr_class3'], - 'T_TH_COLOR1' => '#'.$theme['th_color1'], - 'T_TH_COLOR2' => '#'.$theme['th_color2'], - 'T_TH_COLOR3' => '#'.$theme['th_color3'], - 'T_TH_CLASS1' => $theme['th_class1'], - 'T_TH_CLASS2' => $theme['th_class2'], - 'T_TH_CLASS3' => $theme['th_class3'], - 'T_TD_COLOR1' => '#'.$theme['td_color1'], - 'T_TD_COLOR2' => '#'.$theme['td_color2'], - 'T_TD_COLOR3' => '#'.$theme['td_color3'], - 'T_TD_CLASS1' => $theme['td_class1'], - 'T_TD_CLASS2' => $theme['td_class2'], - 'T_TD_CLASS3' => $theme['td_class3'], - 'T_FONTFACE1' => $theme['fontface1'], - 'T_FONTFACE2' => $theme['fontface2'], - 'T_FONTFACE3' => $theme['fontface3'], - 'T_FONTSIZE1' => $theme['fontsize1'], - 'T_FONTSIZE2' => $theme['fontsize2'], - 'T_FONTSIZE3' => $theme['fontsize3'], - 'T_FONTCOLOR1' => '#'.$theme['fontcolor1'], - 'T_FONTCOLOR2' => '#'.$theme['fontcolor2'], - 'T_FONTCOLOR3' => '#'.$theme['fontcolor3'], - 'T_SPAN_CLASS1' => $theme['span_class1'], - 'T_SPAN_CLASS2' => $theme['span_class2'], - 'T_SPAN_CLASS3' => $theme['span_class3']) -); + echo $meta; + +?> +<style type="text/css"> +<!-- +th { background-image: url('images/cellpic3.gif') } +td.cat { background-image: url('images/cellpic1.gif') } +//--> +</style> +<title><?php echo $board_config['sitename'] . ' - ' . $page_title; ?></title> +</head> +<body> +<a name="top"></a> -$template->pparse('header'); +<?php ?>
\ No newline at end of file diff --git a/phpBB/admin/pagestart.php b/phpBB/admin/pagestart.php index c6e074a89d..3addac5dd4 100644 --- a/phpBB/admin/pagestart.php +++ b/phpBB/admin/pagestart.php @@ -8,7 +8,6 @@ * * $Id$ * - * ***************************************************************************/ /*************************************************************************** @@ -22,35 +21,160 @@ if ( !defined('IN_PHPBB') ) { - die("Hacking attempt"); + die('Hacking attempt'); } define('IN_ADMIN', true); - include($phpbb_root_path . 'common.'.$phpEx); // // Start session management // -$userdata = session_pagestart($user_ip, PAGE_INDEX); -init_userprefs($userdata); +$userdata = $session->start($update); +$acl = new auth('admin', $userdata); // // End session management // -if( !$userdata['session_logged_in'] ) + +// +// Configure style, language, etc. +// +$session->configure($userdata); + +// ----------------------------- +// Functions +// +function page_header($sub_title) { - header("Location: ../" . append_sid("login.$phpEx?redirect=admin/")); + global $db, $lang, $phpEx; + + include('page_header_admin.'.$phpEx); + +?> + +<table width="100%" cellspacing="0" cellpadding="0" border="0"> + <tr> + <td colspan="2" height="25" align="right" nowrap="nowrap"><span class="subtitle">» <i><?php echo $sub_title; ?></i></span> </td> + </tr> +</table> + +<table width="95%" cellspacing="0" cellpadding="0" border="0" align="center"> + <tr> + <td><br clear="all" /> + +<?php + } -else if( $userdata['user_level'] != ADMIN ) + +function page_footer($ignore_copyright = false) { - message_die(GENERAL_MESSAGE, $lang['Not_admin']); + global $db, $lang, $phpEx; + +?> + + </td> + </tr> +</table> + +<?php + + include('page_footer_admin.'.$phpEx); + } -if ( empty($no_page_header) ) +function page_message($title, $message) { - // Not including the pageheader can be neccesarry if META tags are - // needed in the calling script. - include('page_header_admin.'.$phpEx); + global $lang; + +?> + +<table width="100%" cellspacing="0" cellpadding="0" border="0"> + <tr> + <td><a href="../"><img src="images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td> + <td width="100%" background="images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle"><?php echo $lang['Admin_title']; ?></span> </td> + </tr> +</table> + +<br /><br /> + +<table class="bg" width="80%" cellpadding="4" cellspacing="1" border="0" align="center"> + <tr> + <th><?php echo $title; ?></th> + </tr> + <tr> + <td class="row1" align="center"><?php echo $message; ?></td> + </tr> +</table> + +<br /> + +<?php + +} + +function add_admin_log() +{ + global $db, $userdata, $user_ip; + + $arguments = func_get_args(); + + $action = array_shift($arguments); + $data = ( !sizeof($arguments) ) ? '' : serialize($arguments); + + $sql = "INSERT INTO " . LOG_ADMIN_TABLE . " (user_id, log_ip, log_time, log_operation, log_data) + VALUES (" . $userdata['user_id'] . ", '$user_ip', " . time() . ", '$action', '$data')"; + $db->sql_query($sql); + + return; } +function view_admin_log($limit = 0, $offset = 0, $limit_days = 0, $sort_by = 'l.log_time DESC') +{ + global $db, $lang, $phpEx, $SID; + + $limit_sql = ( $limit ) ? ( ( $offset ) ? "LIMIT $offset, $limit" : "LIMIT $limit" ) : ''; + $sql = "SELECT l.log_id, l.user_id, l.log_ip, l.log_time, l.log_operation, l.log_data, u.username + FROM " . LOG_ADMIN_TABLE . " l, " . USERS_TABLE . " u + WHERE u.user_id = l.user_id + AND l.log_time >= $limit_days + ORDER BY $sort_by + $limit_sql"; + $result = $db->sql_query($sql); + + $admin_log = array(); + if ( $row = $db->sql_fetchrow($result) ) + { + $i = 0; + do + { + $admin_log[$i]['id'] = $row['log_id']; + $admin_log[$i]['username'] = '<a href="admin_users.'.$phpEx . $SID . '&u=' . $row['user_id'] . '">' . $row['username'] . '</a>'; + $admin_log[$i]['ip'] = $row['log_ip']; + $admin_log[$i]['time'] = $row['log_time']; + + $admin_log[$i]['action'] = ( !empty($lang[$row['log_operation']]) ) ? $lang[$row['log_operation']] : ucfirst(str_replace('_', ' ', $row['log_operation'])); + + if ( !empty($row['log_data']) ) + { + $log_data_ary = unserialize($row['log_data']); + + foreach ( $log_data_ary as $log_data ) + { + $admin_log[$i]['action'] = preg_replace('#%s#', $log_data, $admin_log[$i]['action'], 1); + } + } + + $i++; + } + while ( $row = $db->sql_fetchrow($result) ); + } + + $db->sql_freeresult($result); + + return $admin_log; +} +// +// End Functions +// ----------------------------- + ?>
\ No newline at end of file diff --git a/phpBB/admin/subSilver.css b/phpBB/admin/subSilver.css index 2209e500dd..59818273af 100644 --- a/phpBB/admin/subSilver.css +++ b/phpBB/admin/subSilver.css @@ -198,4 +198,4 @@ input.liteoption { } /* Import the fancy styles for IE only (NS4.x doesn't use the @import function) */ -@import url("formIE.css"); +@import url("forms.css"); |