|
@@ -533,11 +533,7 @@ function BanEdit()
|
|
|
if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup']))
|
|
|
$context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']);
|
|
|
|
|
|
- // Borrowing a few language strings from profile.
|
|
|
- loadLanguage('Profile');
|
|
|
-
|
|
|
- $context['ban_suggestions']['message_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id'], 'messages', 'poster_ip');
|
|
|
- $context['ban_suggestions']['error_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id'], 'log_errors');
|
|
|
+ $context['ban_suggestions'] += banLoadAdditionalIPs($context['ban_suggestions']['member']['id']);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -690,37 +686,52 @@ function list_getNumBanItems()
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Finds additional IPs related to a certain user from a specified table (and column)
|
|
|
+ * Finds additional IPs related to a certain user from the messages and the log_errors tables
|
|
|
*
|
|
|
* @param int $member_id
|
|
|
- * @param string $table table name without prefix
|
|
|
- * @param string $column column to search in (default 'ip')
|
|
|
* @return array
|
|
|
*/
|
|
|
-function banLoadAdditionalIPs($member_id, $table, $column = 'ip')
|
|
|
+function banLoadAdditionalIPs($member_id)
|
|
|
{
|
|
|
- global $smcFunc;
|
|
|
+ global $context, $smcFunc;
|
|
|
+
|
|
|
+ // Borrowing a few language strings from profile.
|
|
|
+ loadLanguage('Profile');
|
|
|
|
|
|
// Find some additional IP's used by this member.
|
|
|
- $ips = array();
|
|
|
+ $message_ips = array();
|
|
|
$request = $smcFunc['db_query']('ban_suggest_message_ips', '
|
|
|
- SELECT DISTINCT {raw:column_name}
|
|
|
- FROM {db_prefix}{raw:table_name}
|
|
|
+ SELECT DISTINCT poster_ip
|
|
|
+ FROM {db_prefix}messages
|
|
|
+ WHERE id_member = {int:current_user}
|
|
|
+ AND poster_ip RLIKE {string:poster_ip_regex}
|
|
|
+ ORDER BY poster_ip',
|
|
|
+ array(
|
|
|
+ 'current_user' => $member_id,
|
|
|
+ 'poster_ip_regex' => '^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$',
|
|
|
+ )
|
|
|
+ );
|
|
|
+ while ($row = $smcFunc['db_fetch_assoc']($request))
|
|
|
+ $message_ips[] = $row['poster_ip'];
|
|
|
+ $smcFunc['db_free_result']($request);
|
|
|
+
|
|
|
+ $error_ips = array();
|
|
|
+ $request = $smcFunc['db_query']('ban_suggest_error_ips', '
|
|
|
+ SELECT DISTINCT ip
|
|
|
+ FROM {db_prefix}log_errors
|
|
|
WHERE id_member = {int:current_user}
|
|
|
- AND {raw:column_name} RLIKE {string:poster_ip_regex}
|
|
|
- ORDER BY {raw:column_name}',
|
|
|
+ AND ip RLIKE {string:poster_ip_regex}
|
|
|
+ ORDER BY ip',
|
|
|
array(
|
|
|
- 'table_name' => $table,
|
|
|
- 'column_name' => $column,
|
|
|
'current_user' => $member_id,
|
|
|
'poster_ip_regex' => '^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$',
|
|
|
)
|
|
|
);
|
|
|
while ($row = $smcFunc['db_fetch_assoc']($request))
|
|
|
- $ips[] = $row[$column];
|
|
|
+ $error_ips[] = $row['ip'];
|
|
|
$smcFunc['db_free_result']($request);
|
|
|
|
|
|
- return $ips;
|
|
|
+ return array('message_ips' => $message_ips, 'error_ips' => $error_ips);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -782,13 +793,7 @@ function banEdit2()
|
|
|
{
|
|
|
// Not strictly necessary, but it's nice
|
|
|
if (!empty($context['ban_suggestions']['member']['id']))
|
|
|
- {
|
|
|
- // Borrowing a few language strings from profile.
|
|
|
- loadLanguage('Profile');
|
|
|
-
|
|
|
- $context['ban_suggestions']['message_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id'], 'messages', 'poster_ip');
|
|
|
- $context['ban_suggestions']['error_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id'], 'log_errors');
|
|
|
- }
|
|
|
+ $context['ban_suggestions'] += banLoadAdditionalIPs($context['ban_suggestions']['member']['id']);
|
|
|
return BanEdit();
|
|
|
}
|
|
|
|