diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2009-03-22 16:34:26 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2009-03-22 16:34:26 +0000 |
commit | 4cbf6bc703bdadf716197b68a89b3438247ff022 (patch) | |
tree | 952f7fe84b9428d10e4d49d535c5108e06d4640a /phpBB/includes/functions_user.php | |
parent | fac9c024ff370eb4c34f7a7ffa9048732e5c74c7 (diff) | |
download | forums-4cbf6bc703bdadf716197b68a89b3438247ff022.tar forums-4cbf6bc703bdadf716197b68a89b3438247ff022.tar.gz forums-4cbf6bc703bdadf716197b68a89b3438247ff022.tar.bz2 forums-4cbf6bc703bdadf716197b68a89b3438247ff022.tar.xz forums-4cbf6bc703bdadf716197b68a89b3438247ff022.zip |
Merge most changes from 3.0.x branch since the 25th december.
(Captcha changes for refreshing captcha image not included)
git-svn-id: file:///svn/phpbb/trunk@9404 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r-- | phpBB/includes/functions_user.php | 79 |
1 files changed, 54 insertions, 25 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index d4bd9a78a8..58149b9527 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -272,7 +272,7 @@ function user_add($user_row, $cp_data = false) { set_config('newest_user_id', $user_id, true); set_config('newest_username', $user_row['username'], true); - set_config('num_users', phpbb::$config['num_users'] + 1, true); + set_config_count('num_users', 1, true); $sql = 'SELECT group_colour FROM ' . GROUPS_TABLE . ' @@ -479,7 +479,7 @@ function user_delete($mode, $user_id, $post_username = false) phpbb::$db->sql_transaction('begin'); - $table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE); + $table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE, SESSIONS_KEYS_TABLE); foreach ($table_ary as $table) { @@ -490,6 +490,16 @@ function user_delete($mode, $user_id, $post_username = false) phpbb::$acm->destroy_sql(MODERATOR_CACHE_TABLE); + // Delete the user_id from the banlist + $sql = 'DELETE FROM ' . BANLIST_TABLE . ' + WHERE ban_userid = ' . $user_id; + phpbb::$db->sql_query($sql); + + // Delete the user_id from the session table + $sql = 'DELETE FROM ' . SESSIONS_TABLE . ' + WHERE session_user_id = ' . $user_id; + phpbb::$db->sql_query($sql); + // Remove any undelivered mails... $sql = 'SELECT msg_id, user_id FROM ' . PRIVMSGS_TO_TABLE . ' @@ -558,7 +568,7 @@ function user_delete($mode, $user_id, $post_username = false) // Decrement number of users if this user is active if ($user_row['user_type'] != phpbb::USER_INACTIVE && $user_row['user_type'] != phpbb::USER_IGNORE) { - set_config('num_users', phpbb::$config['num_users'] - 1, true); + set_config_count('num_users', -1, true); } return false; @@ -637,12 +647,12 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL) if ($deactivated) { - set_config('num_users', phpbb::$config['num_users'] - $deactivated, true); + set_config_count('num_users', $deactivated * (-1), true); } if ($activated) { - set_config('num_users', phpbb::$config['num_users'] + $activated, true); + set_config_count('num_users', $activated, true); } // Update latest username @@ -1117,6 +1127,8 @@ function user_unban($mode, $ban) /** * Whois facility +* +* @link http://tools.ietf.org/html/rfc3912 RFC3912: WHOIS Protocol Specification */ function user_ipwhois($ip) { @@ -1129,16 +1141,10 @@ function user_ipwhois($ip) return ''; } - $match = array( - '#RIPE\.NET#is' => 'whois.ripe.net', - '#whois\.apnic\.net#is' => 'whois.apnic.net', - '#nic\.ad\.jp#is' => 'whois.nic.ad.jp', - '#whois\.registro\.br#is' => 'whois.registro.br' - ); - if (($fsk = @fsockopen('whois.arin.net', 43))) { - fputs($fsk, "$ip\n"); + // CRLF as per RFC3912 + fputs($fsk, "$ip\r\n"); while (!feof($fsk)) { $ipwhois .= fgets($fsk, 1024); @@ -1146,22 +1152,38 @@ function user_ipwhois($ip) @fclose($fsk); } - foreach (array_keys($match) as $server) + $match = array(); + + // Test for referrals from ARIN to other whois databases, roll on rwhois + if (preg_match('#ReferralServer: whois://(.+)#im', $ipwhois, $match)) { - if (preg_match($server, $ipwhois)) + if (strpos($match[1], ':') !== false) + { + $pos = strrpos($match[1], ':'); + $server = substr($match[1], 0, $pos); + $port = (int) substr($match[1], $pos + 1); + unset($pos); + } + else { - $ipwhois = ''; - if (($fsk = @fsockopen($match[$server], 43))) + $server = $match[1]; + $port = 43; + } + + $buffer = ''; + + if (($fsk = @fsockopen($server, $port))) + { + fputs($fsk, "$ip\r\n"); + while (!feof($fsk)) { - fputs($fsk, "$ip\n"); - while (!feof($fsk)) - { - $ipwhois .= fgets($fsk, 1024); - } - @fclose($fsk); + $buffer .= fgets($fsk, 1024); } - break; + @fclose($fsk); } + + // Use the result from ARIN if we don't get any result here + $ipwhois = (empty($buffer)) ? $ipwhois : $buffer; } $ipwhois = htmlspecialchars($ipwhois); @@ -2591,7 +2613,14 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, */ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false) { - $group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'REGISTERED_COPPA', 'REGISTERED', 'BOTS', 'GUESTS'); + if (phpbb::$config['coppa_enable']) + { + $group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'REGISTERED_COPPA', 'REGISTERED', 'BOTS', 'GUESTS'); + } + else + { + $group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'REGISTERED', 'BOTS', 'GUESTS'); + } // We need both username and user_id info $result = user_get_id_name($user_id_ary, $username_ary); |