From bb939454231a9281b5dbb3242606c5008c904ed6 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Wed, 29 Jan 2003 17:45:34 +0000 Subject: [PATCH] Move logging functions, change name, add mode + lang var case changes git-svn-id: file:///svn/phpbb/trunk@3401 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/admin/admin_ban.php | 4 +- phpBB/admin/admin_board.php | 3 +- phpBB/admin/admin_database.php | 5 +- phpBB/admin/admin_disallow.php | 4 +- phpBB/admin/admin_forums.php | 1 - phpBB/admin/admin_permissions.php | 1 - phpBB/admin/admin_prune.php | 3 +- phpBB/admin/admin_prune_users.php | 2 +- phpBB/admin/admin_styles.php | 4 +- phpBB/admin/admin_users.php | 1 - phpBB/admin/admin_viewlogs.php | 29 +++++------ phpBB/admin/admin_words.php | 5 +- phpBB/admin/index.php | 75 ++++++++++++++------------- phpBB/admin/pagestart.php | 85 ++----------------------------- 14 files changed, 69 insertions(+), 153 deletions(-) diff --git a/phpBB/admin/admin_ban.php b/phpBB/admin/admin_ban.php index e5fe736f3f..71b58cdd00 100644 --- a/phpBB/admin/admin_ban.php +++ b/phpBB/admin/admin_ban.php @@ -299,7 +299,7 @@ if (isset($_POST['bansubmit']) || isset($_GET['bansubmit'])) // Update log $log_entry = ($ban_exclude) ? 'LOG_BAN_EXCLUDE_' : 'log_ban_'; - add_admin_log($log_entry . $mode, $ban_reason, $ban_list_log); + add_log('admin', $log_entry . $mode, $ban_reason, $ban_list_log); } trigger_error($user->lang['BAN_UPDATE_SUCESSFUL']); @@ -319,7 +319,7 @@ else if (isset($_POST['unbansubmit'])) WHERE ban_id IN ($unban_sql)"; $db->sql_query($sql); - add_admin_log('log_unban_' . $mode, sizeof($_POST['unban'])); + add_log('admin', 'log_unban_' . $mode, sizeof($_POST['unban'])); } trigger_error($user->lang['BAN_UPDATE_SUCESSFUL']); diff --git a/phpBB/admin/admin_board.php b/phpBB/admin/admin_board.php index 1da74511b5..1235039013 100644 --- a/phpBB/admin/admin_board.php +++ b/phpBB/admin/admin_board.php @@ -37,7 +37,6 @@ define('IN_PHPBB', 1); $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); -require_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); // Get mode $mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : ''; @@ -104,7 +103,7 @@ while ($row = $db->sql_fetchrow($result)) if (isset($_POST['submit'])) { - add_admin_log('log_' . $mode . '_config'); + add_log('admin', 'log_' . $mode . '_config'); trigger_error($user->lang['Config_updated']); } diff --git a/phpBB/admin/admin_database.php b/phpBB/admin/admin_database.php index 0bdadf950e..6c07995c5e 100644 --- a/phpBB/admin/admin_database.php +++ b/phpBB/admin/admin_database.php @@ -38,7 +38,6 @@ define('IN_PHPBB', 1); $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); -require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); $mode = (isset($_GET['mode'])) ? $_GET['mode'] : ''; @@ -260,7 +259,7 @@ switch($mode) ob_end_clean(); } - add_admin_log('log_db_backup'); + add_log('admin', 'log_db_backup'); if (empty($store_path)) { @@ -373,7 +372,7 @@ switch($mode) } } - add_admin_log('log_db_restore'); + add_log('admin', 'log_db_restore'); trigger_error($user->lang['Restore_success']); } diff --git a/phpBB/admin/admin_disallow.php b/phpBB/admin/admin_disallow.php index 646f348347..af7c7fdf3d 100644 --- a/phpBB/admin/admin_disallow.php +++ b/phpBB/admin/admin_disallow.php @@ -61,7 +61,7 @@ if (isset($_POST['disallow'])) $message = $user->lang['Disallow_successful']; } - add_admin_log('log_disallow_add', str_replace('%', '*', $disallowed_user)); + add_log('admin', 'log_disallow_add', str_replace('%', '*', $disallowed_user)); trigger_error($message); } @@ -78,7 +78,7 @@ else if (isset($_POST['allow'])) WHERE disallow_id = $disallowed_id"; $db->sql_query($sql); - add_admin_log('log_disallow_delete'); + add_log('admin', 'log_disallow_delete'); trigger_error($user->lang['Disallowed_deleted']); } diff --git a/phpBB/admin/admin_forums.php b/phpBB/admin/admin_forums.php index 8ba708f26a..5fd1c80419 100644 --- a/phpBB/admin/admin_forums.php +++ b/phpBB/admin/admin_forums.php @@ -35,7 +35,6 @@ define('IN_PHPBB', 1); $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); -require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); // Get mode $mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : ''; diff --git a/phpBB/admin/admin_permissions.php b/phpBB/admin/admin_permissions.php index e7c2e4e3d2..70c7e3206e 100644 --- a/phpBB/admin/admin_permissions.php +++ b/phpBB/admin/admin_permissions.php @@ -38,7 +38,6 @@ define('IN_PHPBB', 1); $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); -require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); // Define some vars $forum_id = 0; diff --git a/phpBB/admin/admin_prune.php b/phpBB/admin/admin_prune.php index 396e7c61f4..5b0f5c48c9 100644 --- a/phpBB/admin/admin_prune.php +++ b/phpBB/admin/admin_prune.php @@ -36,7 +36,6 @@ define('IN_PHPBB', 1); $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); -require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); // Do we have permission? if (!$auth->acl_get('a_prune')) @@ -109,7 +108,7 @@ if (isset($_POST['doprune'])) } while($row = $db->sql_fetchrow($result)); - add_admin_log('log_prune', $log_data); + add_log('admin', 'log_prune', $log_data); } else diff --git a/phpBB/admin/admin_prune_users.php b/phpBB/admin/admin_prune_users.php index dd4eacc124..ef466b1be5 100644 --- a/phpBB/admin/admin_prune_users.php +++ b/phpBB/admin/admin_prune_users.php @@ -172,7 +172,7 @@ if (isset($_POST['prune'])) $where_sql"; // $db->sql_query($sql); - add_admin_log($l_admin_log, implode(', ', $usernames)); + add_log('admin', $l_admin_log, implode(', ', $usernames)); unset($user_ids); unset($usernames); diff --git a/phpBB/admin/admin_styles.php b/phpBB/admin/admin_styles.php index f2d1b052a3..0035c9f7fe 100644 --- a/phpBB/admin/admin_styles.php +++ b/phpBB/admin/admin_styles.php @@ -163,7 +163,7 @@ switch ($mode) @chmod($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 0644); - add_admin_log('log_template_edit', $tplname, $tplroot); + add_log('admin', 'log_template_edit', $tplname, $tplroot); exit; } @@ -266,7 +266,7 @@ switch ($mode) WHERE theme_id = $theme_id"; $db->sql_query($sql); - add_admin_log('log_theme_edit', $theme_name); + add_log('admin', 'log_theme_edit', $theme_name); message_die(MESSAGE, $user->lang['Success_theme_update']); } diff --git a/phpBB/admin/admin_users.php b/phpBB/admin/admin_users.php index 65a2c493e7..84e14d4c10 100644 --- a/phpBB/admin/admin_users.php +++ b/phpBB/admin/admin_users.php @@ -36,7 +36,6 @@ define('IN_PHPBB', 1); $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); -require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); // Set mode $mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : 'main'; diff --git a/phpBB/admin/admin_viewlogs.php b/phpBB/admin/admin_viewlogs.php index a31f27efed..6969233200 100644 --- a/phpBB/admin/admin_viewlogs.php +++ b/phpBB/admin/admin_viewlogs.php @@ -38,7 +38,6 @@ define('IN_PHPBB', 1); $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); -require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); // Do we have styles admin permissions? if (!$auth->acl_get('a_general')) @@ -73,7 +72,7 @@ if ((isset($_POST['delmarked']) || isset($_POST['delall'])) && $auth->acl_get('a $where_sql"; $db->sql_query($sql); - add_admin_log('log_' . $mode . '_clear'); + add_log('admin', 'log_' . $mode . '_clear'); } // Sorting ... this could become a function @@ -102,7 +101,7 @@ else } $previous_days = array(0 => $user->lang['All_Entries'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']); -$sort_by_text = array('u' => $user->lang['Sort_Username'], 't' => $user->lang['Sort_date'], 'i' => $user->lang['Sort_ip'], 'o' => $user->lang['Sort_action']); +$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']); $sort_by = array('u' => 'l.user_id', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation'); $sort_day_options = ''; @@ -119,7 +118,7 @@ foreach ($sort_by_text as $key => $text) $sort_key_options .= ''; } -$sort_order_options = ($sort_dir == 'a') ? '' : ''; +$sort_order_options = ($sort_dir == 'a') ? '' : ''; $sort_sql = $sort_by[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); @@ -138,13 +137,13 @@ page_header($l_title); // Define forum list if we're looking @ mod logs if ($mode == 'mod') { -//include($phpbb_root_path . '/includes/functions_admin.'.$phpEx); - $forum_box = make_forum_select($forum_id); + + $forum_box = '' . make_forum_select($forum_id, false, false); ?> - +
lang['SELECT_FORUM']; ?>: lang['SELECT_FORUM']; ?>:
- lang['Display_log']; ?>:   lang['Sort_by']; ?>   + lang['DISPLAY_LOG']; ?>:   lang['SORT_BY']; ?>   - lang['Username']; ?> + lang['USERNAME']; ?> lang['IP']; ?> - lang['Time']; ?> - lang['Action']; ?> - lang['Mark']; ?> + lang['TIME']; ?> + lang['ACTION']; ?> + lang['MARK']; ?> -     +     - lang['No_entries']; ?> + lang['NO_ENTRIES']; ?> lang['Mark_all']; ?> :: lang['Unmark_all']; ?> 

lang['MARK_ALL']; ?> :: lang['UNMARK_ALL']; ?> 

acl_get('a_words')) @@ -138,7 +137,7 @@ if ($mode != '') $cache->destroy('word_censors'); $log_action = ($word_id) ? 'log_edit_word' : 'log_add_word'; - add_admin_log($log_action, stripslashes($word)); + add_log('admin', $log_action, stripslashes($word)); $message = ($word_id) ? $user->lang['WORD_UPDATED'] : $user->lang['WORD_ADDED']; break; @@ -160,7 +159,7 @@ if ($mode != '') $cache->destroy('word_censors'); - add_admin_log('log_delete_word'); + add_log('admin', 'log_delete_word'); $message = $user->lang['WORD_REMOVE']; break; diff --git a/phpBB/admin/index.php b/phpBB/admin/index.php index 150a5f9b4b..2f285ca04a 100644 --- a/phpBB/admin/index.php +++ b/phpBB/admin/index.php @@ -19,12 +19,11 @@ * ***************************************************************************/ -define('IN_PHPBB', 1); - // Define some vars $pane = (isset($_GET['pane'])) ? $_GET['pane'] : ''; $update = ($pane == 'right') ? true : false; +define('IN_PHPBB', 1); // Include files $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); @@ -46,7 +45,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'top') - +
phpBB Logolang['Admin_title']; ?>      lang['ADMIN_TITLE']; ?>      
@@ -66,7 +65,7 @@ else if (isset($_GET['pane']) && $_GET['pane'] == 'left') $setmodules = 1; while ($file = @readdir($dir)) { - if (preg_match('/^admin_(.*?)\.' . $phpEx . '$/', $file)) + if (preg_match('#^admin_(.*?)\.' . $phpEx . '$#', $file)) { include($file); } @@ -260,9 +259,9 @@ elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') { $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; + $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; @@ -297,7 +296,7 @@ elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') $dbsize = $user->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"; @@ -315,7 +314,7 @@ elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') $dbsize = ($dbsize >= 1048576) ? sprintf('%.2f MB', ($dbsize / 1048576)) : (($dbsize >= 1024) ? sprintf('%.2f KB', ($dbsize / 1024)) : sprintf('%.2f Bytes', $dbsize)); } - page_header($user->lang['Admin_Index']); + page_header($user->lang['ADMIN_INDEX']); ?> @@ -331,47 +330,47 @@ elseif (isset($_GET['pane']) && $_GET['pane'] == 'right') //--> -

lang['Welcome_phpBB']; ?>

+

lang['WELCOME_PHPBB']; ?>

-

lang['Admin_intro']; ?>

+

lang['ADMIN_INTRO']; ?>

-

lang['Forum_stats']; ?>

+

lang['FORUM_STATS']; ?>

- - - - + + + + - + - + - + - + - + - + - + - + - + - +
lang['Statistic']; ?>lang['Value']; ?>lang['Statistic']; ?>lang['Value']; ?>lang['STATISTIC']; ?>lang['VALUE']; ?>lang['STATISTIC']; ?>lang['VALUE']; ?>
lang['Number_posts']; ?>:lang['NUMBER_POSTS']; ?>: lang['Posts_per_day']; ?>:lang['POSTS_PER_DAY']; ?>:
lang['Number_topics']; ?>:lang['NUMBER_TOPICS']; ?>: lang['Topics_per_day']; ?>:lang['TOPICS_PER_DAY']; ?>:
lang['Number_users']; ?>:lang['NUMBER_USERS']; ?>: lang['Users_per_day']; ?>:lang['USERS_PER_DAY']; ?>:
lang['Board_started']; ?>:lang['BOARD_STARTED']; ?>: lang['Avatar_dir_size']; ?>:lang['AVATAR_DIR_SIZE']; ?>:
lang['Database_size']; ?>:lang['DATABASE_SIZE']; ?>: lang['Gzip_compression']; ?>:lang['GZIP_COMPRESSION']; ?>: lang['ON'] : $user->lang['OFF']; ?>
-

lang['Admin_log']; ?>

+

lang['ADMIN_LOG']; ?>

-

lang['Admin_log_index_explain']; ?>

+

lang['ADMIN_LOG_INDEX_EXPLAIN']; ?>

- + - - + +
lang['Username']; ?>lang['USERNAME']; ?> lang['IP']; ?>lang['Time']; ?>lang['Action']; ?>lang['TIME']; ?>lang['ACTION']; ?>
-

lang['Inactive_users']; ?>

+

lang['INACTIVE_USERS']; ?>

-

lang['Inactive_users_explain']; ?>

+

lang['INACTIVE_USERS_EXPLAIN']; ?>

"> - - - + + + - + - + - +
lang['Username']; ?>lang['Joined']; ?>lang['Mark']; ?>lang['USERNAME']; ?>lang['JOINED']; ?>lang['MARK']; ?>
          
lang['No_inactive_users']; ?>lang['NO_INACTIVE_USERS']; ?>
lang['Mark_all']; ?> :: lang['Unmark_all']; ?>lang['MARK_ALL']; ?> :: lang['UNMARK_ALL']; ?>
diff --git a/phpBB/admin/pagestart.php b/phpBB/admin/pagestart.php index e2096baf4f..b4359312ce 100644 --- a/phpBB/admin/pagestart.php +++ b/phpBB/admin/pagestart.php @@ -26,7 +26,8 @@ if (!defined('IN_PHPBB')) define('IN_ADMIN', true); define('NEED_SID', true); -include($phpbb_root_path . 'common.'.$phpEx); +require($phpbb_root_path . 'common.'.$phpEx); +require_once($phpbb_root_path . 'includes/functions_admin.'.$phpEx); // Start session management $user->start($update); @@ -45,7 +46,7 @@ function page_header($sub_title, $meta = '', $table_html = true) // gzip_compression if ($config['gzip_compress']) { - if (extension_loaded('zlib') && strstr($HTTP_USER_AGENT,'compatible') && !headers_sent()) + if (extension_loaded('zlib') && !headers_sent()) { ob_start('ob_gzhandler'); } @@ -105,6 +106,7 @@ function page_footer($copyright_html = true) // Close our DB connection. $db->sql_close(); + ?> @@ -147,7 +149,7 @@ function page_message($title, $message, $show_header = false) - +
phpBB Logolang['Admin_title']; ?>      lang['ADMIN_TITLE']; ?>      
@@ -173,83 +175,6 @@ function page_message($title, $message, $show_header = false) data['user_id'] . ", '$user->ip', " . time() . ", '$action', '$data')"; - $db->sql_query($sql); - - return; -} - -function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC') -{ - global $db, $user, $phpEx, $SID; - - $table_sql = ($mode == 'admin') ? LOG_ADMIN_TABLE : LOG_MOD_TABLE; - $forum_sql = ($mode == 'mod' && $forum_id) ? "AND l.forum_id = $forum_id" : ''; - $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 $table_sql l, " . USERS_TABLE . " u - WHERE u.user_id = l.user_id - AND l.log_time >= $limit_days - $forum_sql - ORDER BY $sort_by - $limit_sql"; - $result = $db->sql_query($sql); - - $log = array(); - if ($row = $db->sql_fetchrow($result)) - { - $i = 0; - do - { - $log[$i]['id'] = $row['log_id']; - $log[$i]['username'] = '' . $row['username'] . ''; - $log[$i]['ip'] = $row['log_ip']; - $log[$i]['time'] = $row['log_time']; - - $log[$i]['action'] = (!empty($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : ucfirst(str_replace('_', ' ', $row['log_operation'])); - - if (!empty($row['log_data'])) - { - $log_data_ary = unserialize(stripslashes($row['log_data'])); - - foreach ($log_data_ary as $log_data) - { - $log[$i]['action'] = preg_replace('#%s#', $log_data, $log[$i]['action'], 1); - } - } - - $i++; - } - while ($row = $db->sql_fetchrow($result)); - } - - $db->sql_freeresult($result); - - $sql = "SELECT COUNT(*) AS total_entries - FROM $table_sql l - WHERE l.log_time >= $limit_days - $forum_sql"; - $result = $db->sql_query($sql); - - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $log_count = $row['total_entries']; - - return; -} // End Functions // -----------------------------