diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acm/acm_file.php | 21 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_ban.php | 71 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_forums.php | 7 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_icons.php | 4 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_modules.php | 3 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions_module.php | 13 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 35 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_ban.php | 140 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_queue.php | 2 | ||||
-rw-r--r-- | phpBB/includes/session.php | 18 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_main.php | 26 |
12 files changed, 258 insertions, 84 deletions
diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index 3a11f5b6d6..c5162a36d3 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -154,11 +154,6 @@ class acm { global $phpEx; - if (!$this->_exists($var_name)) - { - return; - } - if ($var_name == 'sql' && !empty($table)) { $regex = '(' . ((is_array($table)) ? implode('|', $table) : $table) . ')'; @@ -166,7 +161,7 @@ class acm $dir = opendir($this->cache_dir); while ($entry = readdir($dir)) { - if (substr($entry, 0, 4) != 'sql_') + if (strpos($entry, 'sql_') !== 0) { continue; } @@ -181,8 +176,16 @@ class acm } } @closedir($dir); + + return; } - else if ($var_name{0} == '_') + + if (!$this->_exists($var_name)) + { + return; + } + + if ($var_name{0} == '_') { @unlink($this->cache_dir . 'data' . $var_name . ".$phpEx"); } @@ -251,7 +254,7 @@ class acm // Remove extra spaces and tabs $query = preg_replace('/[\n\r\s\t]+/', ' ', $query); - $query_id = 'Cache id #' . sizeof($this->sql_rowset); + $query_id = sizeof($this->sql_rowset); if (!file_exists($this->cache_dir . 'sql_' . md5($query) . ".$phpEx")) { @@ -285,7 +288,7 @@ class acm @flock($fp, LOCK_EX); $lines = array(); - $query_id = 'Cache id #' . sizeof($this->sql_rowset); + $query_id = sizeof($this->sql_rowset); $this->sql_rowset[$query_id] = array(); while ($row = $db->sql_fetchrow($query_result)) diff --git a/phpBB/includes/acp/acp_ban.php b/phpBB/includes/acp/acp_ban.php index 4c8a1a0dfc..6b4f2f843b 100644 --- a/phpBB/includes/acp/acp_ban.php +++ b/phpBB/includes/acp/acp_ban.php @@ -53,15 +53,6 @@ class acp_ban trigger_error($user->lang['BAN_UPDATE_SUCESSFUL'] . adm_back_link($this->u_action)); } - // Ban length options - $ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['UNTIL'] . ' -> '); - - $ban_end_options = ''; - foreach ($ban_end_text as $length => $text) - { - $ban_end_options .= '<option value="' . $length . '">' . $text . '</option>'; - } - // Define language vars $this->page_title = $user->lang[strtoupper($mode) . '_BAN']; @@ -74,6 +65,53 @@ class acp_ban switch ($mode) { case 'user': + $l_ban_cell = $user->lang['USERNAME']; + break; + + case 'ip': + $l_ban_cell = $user->lang['IP_HOSTNAME']; + break; + + case 'email': + $l_ban_cell = $user->lang['EMAIL_ADDRESS']; + break; + } + + $this->display_ban_options($mode); + + $template->assign_vars(array( + 'L_TITLE' => $this->page_title, + 'L_EXPLAIN' => $l_ban_explain, + 'L_UNBAN_TITLE' => $l_unban_title, + 'L_UNBAN_EXPLAIN' => $l_unban_explain, + 'L_BAN_CELL' => $l_ban_cell, + 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, + 'L_NO_BAN_CELL' => $l_no_ban_cell, + + 'S_USERNAME_BAN' => ($mode == 'user') ? true : false, + + 'U_ACTION' => $this->u_action, + 'U_FIND_USER' => $phpbb_root_path . "memberlist.$phpEx$SID&mode=searchuser&form=acp_ban&field=ban", + ) + ); + } + + function display_ban_options($mode) + { + global $user, $db, $template; + + // Ban length options + $ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['UNTIL'] . ' -> '); + + $ban_end_options = ''; + foreach ($ban_end_text as $length => $text) + { + $ban_end_options .= '<option value="' . $length . '">' . $text . '</option>'; + } + + switch ($mode) + { + case 'user': $field = 'username'; $l_ban_cell = $user->lang['USERNAME']; @@ -163,22 +201,9 @@ class acp_ban } $template->assign_vars(array( - 'L_TITLE' => $this->page_title, - 'L_EXPLAIN' => $l_ban_explain, - 'L_UNBAN_TITLE' => $l_unban_title, - 'L_UNBAN_EXPLAIN' => $l_unban_explain, - 'L_BAN_CELL' => $l_ban_cell, - 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, - 'L_NO_BAN_CELL' => $l_no_ban_cell, - - 'S_USERNAME_BAN' => ($mode == 'user') ? true : false, 'S_BAN_END_OPTIONS' => $ban_end_options, 'S_BANNED_OPTIONS' => ($banned_options) ? true : false, - 'BANNED_OPTIONS' => $banned_options, - - 'U_ACTION' => $this->u_action, - 'U_FIND_USER' => $phpbb_root_path . "memberlist.$phpEx$SID&mode=searchuser&form=acp_ban&field=ban", - ) + 'BANNED_OPTIONS' => $banned_options) ); } } diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 3869a3ac4a..e6630e36d2 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -75,6 +75,8 @@ class acp_forums } $auth->acl_clear_prefetch(); + $cache->destroy('sql', FORUMS_TABLE); + recalc_btree('forum_id', FORUMS_TABLE); trigger_error($user->lang['FORUM_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); @@ -174,6 +176,8 @@ class acp_forums } $auth->acl_clear_prefetch(); + $cache->destroy('sql', FORUMS_TABLE); + recalc_btree('forum_id', FORUMS_TABLE); $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; @@ -306,6 +310,8 @@ class acp_forums add_log('admin', $log_action, $forum_data['forum_name'], $move_forum_name); unset($forum_data); + $cache->destroy('sql', FORUMS_TABLE); + break; case 'sync': @@ -328,6 +334,7 @@ class acp_forums sync('forum', 'forum_id', $forum_id); add_log('admin', 'LOG_FORUM_SYNC', $row['forum_name']); + $cache->destroy('sql', FORUMS_TABLE); $template->assign_var('L_FORUM_RESYNCED', sprintf($user->lang['FORUM_RESYNCED'], $row['forum_name'])); diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index dd581475f2..44e9f450a5 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -303,6 +303,7 @@ class acp_icons } $cache->destroy('icons'); + $cache->destroy('sql', $table); if ($action == 'modify') { @@ -427,6 +428,8 @@ class acp_icons } $cache->destroy('icons'); + $cache->destroy('sql', $table); + trigger_error($user->lang[$lang . '_IMPORT_SUCCESS'] . adm_back_link($this->u_action)); } else @@ -553,6 +556,7 @@ class acp_icons $db->sql_query($sql); $cache->destroy('icons'); + $cache->destroy('sql', $table); break; } diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 927fed7502..8065080e30 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -755,6 +755,9 @@ class acp_modules $p_class = str_replace(array('.', '/', '\\'), '', basename($this->module_class)); $cache->destroy('_modules_' . $p_class); + + // Additionally remove sql cache + $cache->destroy('sql', MODULES_TABLE); } /** diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4c3b0609d9..57aa3f9593 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2302,7 +2302,7 @@ function page_footer() if (!defined('IN_CRON')) { $cron_type = ''; - + if (time() - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx)) { // Process email queue diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index b7af1c4b17..cbd689a3ff 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -209,7 +209,7 @@ class p_master /** * Check module authorisation - * @todo implement $this->is_module_id + * @todo Have a look at the eval statement and replace with other code... */ function module_auth($module_auth) { @@ -291,7 +291,7 @@ class p_master */ function load_active($mode = false) { - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID; + global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $user; $module_path = $phpbb_root_path . 'includes/' . $this->p_class; $icat = request_var('icat', ''); @@ -322,7 +322,14 @@ class p_master $this->module = new $instance($this); // We pre-define the action parameter we are using all over the place - $this->module->u_action = "{$phpbb_admin_path}index.$phpEx$SID" . (($icat) ? '&icat=' . $icat : '') . "&i={$this->p_id}&mode={$this->p_mode}"; + if (defined('IN_ADMIN')) + { + $this->module->u_action = "{$phpbb_admin_path}index.$phpEx$SID" . (($icat) ? '&icat=' . $icat : '') . "&i={$this->p_id}&mode={$this->p_mode}"; + } + else + { + $this->module->u_action = "{$phpbb_root_path}{$user->page['page_dir']}{$user->page['page_name']}$SID" . (($icat) ? '&icat=' . $icat : '') . "&i={$this->p_id}&mode={$this->p_mode}"; + } // Execute the main method for the new instance, we send the module // id and mode as parameters diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 269fee2c26..3cf2c4ec4a 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -923,40 +923,7 @@ function validate_email($email) return 'EMAIL_INVALID'; } - /** - * @todo This is a duplication of code from session->check_ban() - */ - $sql = 'SELECT ban_ip, ban_userid, ban_email, ban_exclude, ban_give_reason, ban_end - FROM ' . BANLIST_TABLE . ' - WHERE ban_end >= ' . time() . ' - OR ban_end = 0'; - $result = $db->sql_query($sql); - - $banned = false; - if ($row = $db->sql_fetchrow($result)) - { - do - { - if (!empty($row['ban_email']) && preg_match('#^' . str_replace('*', '.*?', $row['ban_email']) . '$#i', $email)) - { - if (!empty($row['ban_exclude'])) - { - $banned = false; - break; - } - else - { - $banned = true; - $ban_row = $row; - // Don't break. Check if there is an exclude rule for this user - } - } - } - while ($row = $db->sql_fetchrow($result)); - } - $db->sql_freeresult($result); - - if ($banned == true) + if ($user->check_ban('', '', $email, true) == true) { return 'EMAIL_BANNED'; } diff --git a/phpBB/includes/mcp/mcp_ban.php b/phpBB/includes/mcp/mcp_ban.php new file mode 100644 index 0000000000..2ae9710d03 --- /dev/null +++ b/phpBB/includes/mcp/mcp_ban.php @@ -0,0 +1,140 @@ +<?php +/** +* +* @package mcp +* @version $Id$ +* @copyright (c) 2005 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @package mcp +*/ +class mcp_ban +{ + var $u_action; + + function main($id, $mode) + { + global $config, $db, $user, $auth, $template, $cache; + global $SID, $phpbb_root_path, $phpEx; + + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + + // Include the admin banning interface... + include($phpbb_root_path . 'includes/acp/acp_ban.' . $phpEx); + + $bansubmit = (isset($_POST['bansubmit'])) ? true : false; + $unbansubmit= (isset($_POST['unbansubmit'])) ? true : false; + $current_time = time(); + + $user->add_lang('acp/ban'); + $this->tpl_name = 'mcp_ban'; + + // Ban submitted? + if ($bansubmit) + { + // Grab the list of entries + $ban = request_var('ban', ''); + $ban_len = request_var('banlength', 0); + $ban_len_other = request_var('banlengthother', ''); + $ban_exclude = request_var('banexclude', 0); + $ban_reason = request_var('banreason', ''); + $ban_give_reason = request_var('bangivereason', ''); + + user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason); + + trigger_error($user->lang['BAN_UPDATE_SUCESSFUL']); + } + else if ($unbansubmit) + { + $ban = request_var('unban', array('')); + + user_unban($mode, $ban); + + trigger_error($user->lang['BAN_UPDATE_SUCESSFUL']); + } + + // Ban length options + $ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['UNTIL'] . ' -> '); + + $ban_end_options = ''; + foreach ($ban_end_text as $length => $text) + { + $ban_end_options .= '<option value="' . $length . '">' . $text . '</option>'; + } + + // Define language vars + $this->page_title = $user->lang[strtoupper($mode) . '_BAN']; + + $l_ban_explain = $user->lang[strtoupper($mode) . '_BAN_EXPLAIN']; + $l_ban_exclude_explain = $user->lang[strtoupper($mode) . '_BAN_EXCLUDE_EXPLAIN']; + $l_unban_title = $user->lang[strtoupper($mode) . '_UNBAN']; + $l_unban_explain = $user->lang[strtoupper($mode) . '_UNBAN_EXPLAIN']; + $l_no_ban_cell = $user->lang[strtoupper($mode) . '_NO_BANNED']; + + switch ($mode) + { + case 'user': + $l_ban_cell = $user->lang['USERNAME']; + break; + + case 'ip': + $l_ban_cell = $user->lang['IP_HOSTNAME']; + break; + + case 'email': + $l_ban_cell = $user->lang['EMAIL_ADDRESS']; + break; + } + + acp_ban::display_ban_options($mode); + + $template->assign_vars(array( + 'L_TITLE' => $this->page_title, + 'L_EXPLAIN' => $l_ban_explain, + 'L_UNBAN_TITLE' => $l_unban_title, + 'L_UNBAN_EXPLAIN' => $l_unban_explain, + 'L_BAN_CELL' => $l_ban_cell, + 'L_BAN_EXCLUDE_EXPLAIN' => $l_ban_exclude_explain, + 'L_NO_BAN_CELL' => $l_no_ban_cell, + + 'S_USERNAME_BAN' => ($mode == 'user') ? true : false, + + 'U_ACTION' => $this->u_action, + 'U_FIND_USER' => $phpbb_root_path . "memberlist.$phpEx$SID&mode=searchuser&form=mcp_ban&field=ban", + ) + ); + } +} + +/** +* @package module_install +*/ +class mcp_ban_info +{ + function module() + { + return array( + 'filename' => 'mcp_ban', + 'title' => 'MCP_BAN', + 'version' => '1.0.0', + 'modes' => array( + 'email' => array('title' => 'MCP_BAN_EMAILS', 'auth' => 'acl_m_ban'), + 'ip' => array('title' => 'MCP_BAN_IPS', 'auth' => 'acl_m_ban'), + 'user' => array('title' => 'MCP_BAN_USERNAMES', 'auth' => 'acl_m_ban'), + ), + ); + } + + function install() + { + } + + function uninstall() + { + } +} + +?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index e447184b55..8929520851 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -557,7 +557,7 @@ function disapprove_post($post_id_list, $mode) else { // If the reason is defined within the language file, we will use the localized version, else just use the database entry... - $disapprove_reason = ($row['reason_title'] != 'other') ? ((isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description']) : ''; + $disapprove_reason = ($row['reason_title'] != 'other') ? ((isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description']) : ''; $disapprove_reason .= ($reason) ? "\n\n" . $_REQUEST['reason'] : ''; unset($reason); } diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 354a77bcec..4340a77605 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -643,11 +643,11 @@ class session * Check for banned user * * Checks whether the supplied user is banned by id, ip or email. If no parameters - * are passed to the method pre-existing session data is used. This routine does - * not return on finding a banned user, it outputs a relevant message and stops - * execution. + * are passed to the method pre-existing session data is used. If $return is false + * this routine does not return on finding a banned user , it outputs a relevant + * message and stops execution. */ - function check_ban($user_id = false, $user_ip = false, $user_email = false) + function check_ban($user_id = false, $user_ip = false, $user_email = false, $return = false) { global $config, $db; @@ -684,7 +684,7 @@ class session } $db->sql_freeresult($result); - if ($banned) + if ($banned && !$return) { // Initiate environment ... since it won't be set at this stage $this->setup(); @@ -703,6 +703,11 @@ class session trigger_error($message); } + if ($banned) + { + return true; + } + return false; } @@ -928,8 +933,7 @@ class user extends session $this->img_lang = (file_exists($phpbb_root_path . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . $this->lang_name)) ? $this->lang_name : $config['default_lang']; // Is board disabled and user not an admin or moderator? - // TODO - // New ACL enabling board access while offline? + // @todo new ACL enabling board access while offline? if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_')) { $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 44eadc2628..dda436cba2 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -85,7 +85,7 @@ class ucp_main } $db->sql_freeresult($result); - $topic_tracking_info = get_topic_tracking(0, $topic_list, $rowset, array(0 => false), $topic_list); + $topic_tracking_info = get_topic_tracking(0, $topic_list, $rowset, false, $topic_list); foreach ($topic_list as $topic_id) { @@ -334,12 +334,15 @@ class ucp_main ORDER BY t.topic_last_post_time DESC'; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); - $topic_list = $global_announce_list = $rowset = array(); + $topic_list = $topic_forum_list = $global_announce_list = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $topic_list[] = $row['topic_id']; $rowset[$row['topic_id']] = $row; + $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread']) ? $row['forum_mark_time'] : 0; + $topic_forum_list[$row['forum_id']]['topics'][] = $row['topic_id']; + if ($row['topic_type'] == POST_GLOBAL) { $global_announce_list[] = $row['topic_id']; @@ -347,10 +350,21 @@ class ucp_main } $db->sql_freeresult($result); - /** - * @todo get_topic_tracking able to fetch from multiple forums - */ - $topic_tracking_info = get_topic_tracking(0, $topic_list, $rowset, array(0 => false), $global_announce_list); + $topic_tracking_info = array(); + if ($config['load_db_lastread']) + { + foreach ($topic_forum_list as $f_id => $topic_row) + { + $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), ($f_id == 0) ? $global_announce_list : false); + } + } + else + { + foreach ($topic_forum_list as $f_id => $topic_row) + { + $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], $global_announce_list); + } + } foreach ($topic_list as $topic_id) { |