aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/memberlist.php
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2003-02-22 17:18:44 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2003-02-22 17:18:44 +0000
commita1f4ba0ed3fce73ad27e4ee71439d143240b64c1 (patch)
tree70c998cf498c2e2397ca24a7b279a5271b030353 /phpBB/memberlist.php
parent5fc4d66994717c52098422ab6b69aa02b5333976 (diff)
downloadforums-a1f4ba0ed3fce73ad27e4ee71439d143240b64c1.tar
forums-a1f4ba0ed3fce73ad27e4ee71439d143240b64c1.tar.gz
forums-a1f4ba0ed3fce73ad27e4ee71439d143240b64c1.tar.bz2
forums-a1f4ba0ed3fce73ad27e4ee71439d143240b64c1.tar.xz
forums-a1f4ba0ed3fce73ad27e4ee71439d143240b64c1.zip
Find user by posted IP
git-svn-id: file:///svn/phpbb/trunk@3510 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/memberlist.php')
-rw-r--r--phpBB/memberlist.php221
1 files changed, 128 insertions, 93 deletions
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index b2351e78f9..e031431b78 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -40,22 +40,26 @@ $field = (isset($_GET['field'])) ? $_GET['field'] : 'username';
$sort_key = (!empty($_REQUEST['sort_key'])) ? intval($_REQUEST['sort_key']) : 0;
$sort_dir = (!empty($_REQUEST['sort_dir'])) ? $_REQUEST['sort_dir'] : 'd';
-$username = (!empty($_REQUEST['username'])) ? $_REQUEST['username'] : '';
-$email = (!empty($_REQUEST['email'])) ? $_REQUEST['email'] : '';
+$username = (!empty($_REQUEST['username'])) ? trim($_REQUEST['username']) : '';
+$email = (!empty($_REQUEST['email'])) ? trim($_REQUEST['email']) : '';
$icq = (!empty($_REQUEST['icq'])) ? intval($_REQUEST['icq']) : '';
-$aim = (!empty($_REQUEST['aim'])) ? $_REQUEST['aim'] : '';
-$yahoo = (!empty($_REQUEST['yahoo'])) ? $_REQUEST['yahoo'] : '';
-$msn = (!empty($_REQUEST['msn'])) ? $_REQUEST['msn'] : '';
+$aim = (!empty($_REQUEST['aim'])) ? trim($_REQUEST['aim']) : '';
+$yahoo = (!empty($_REQUEST['yahoo'])) ? trim($_REQUEST['yahoo']) : '';
+$msn = (!empty($_REQUEST['msn'])) ? trim($_REQUEST['msn']) : '';
$joined_select = (!empty($_REQUEST['joined_select'])) ? $_REQUEST['joined_select'] : 'lt';
$active_select = (!empty($_REQUEST['active_select'])) ? $_REQUEST['active_select'] : 'lt';
$count_select = (!empty($_REQUEST['count_select'])) ? $_REQUEST['count_select'] : 'eq';
-$joined = (!empty($_REQUEST['joined'])) ? explode('-', $_REQUEST['joined']) : array();
-$active = (!empty($_REQUEST['active'])) ? explode('-', $_REQUEST['active']) : array();
+$joined = (!empty($_REQUEST['joined'])) ? explode('-', trim($_REQUEST['joined'])) : array();
+$active = (!empty($_REQUEST['active'])) ? explode('-', trim($_REQUEST['active'])) : array();
$count = (!empty($_REQUEST['count'])) ? intval($_REQUEST['count']) : '';
+$ipdomain = (!empty($_REQUEST['ip'])) ? trim($_REQUEST['ip']) : '';
+
+
+
// Memberlist sorting
-$sort_key_text = array($user->lang['Sort_Joined'], $user->lang['Sort_Username'], $user->lang['Sort_Email'], $user->lang['Sort_Location'], $user->lang['Sort_Post_count'], $user->lang['Sort_Last_active']);
+$sort_key_text = array($user->lang['SORT_JOINED'], $user->lang['SORT_USERNAME'], $user->lang['SORT_EMAIL'], $user->lang['SORT_LOCATION'], $user->lang['SORT_POST_COUNT'], $user->lang['SORT_LAST_ACTIVE']);
$sort_key_fields = array('user_regdate', 'username', 'user_email', 'user_from', 'user_posts', 'user_lastvisit');
$s_sort_key = '<select name="sort_key">';
for($i = 0; $i < count($sort_key_text); $i++)
@@ -65,7 +69,7 @@ for($i = 0; $i < count($sort_key_text); $i++)
}
$s_sort_key .= '</select>';
-$sort_dir_text = array('a' => $user->lang['Ascending'], 'd' => $user->lang['Descending']);
+$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
$s_sort_dir = '<select name="sort_dir">';
foreach ($sort_dir_text as $key => $value)
{
@@ -74,6 +78,9 @@ foreach ($sort_dir_text as $key => $value)
}
$s_sort_dir .= '</select>';
+
+
+
// Clear var for where sql
$where_sql = '';
@@ -82,7 +89,7 @@ if ($mode == 'searchuser')
{
$find_key_match = array('lt' => '<', 'gt' => '>', 'eq' => '=');
- $find_count = array('lt' => $user->lang['Less_than'], 'eq' => $user->lang['Equal_to'], 'gt' => $user->lang['More_than']);
+ $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']);
$s_find_count = '';
foreach ($find_count as $key => $value)
{
@@ -90,13 +97,14 @@ if ($mode == 'searchuser')
$s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
}
- $find_time = array('lt' => $user->lang['Before'], 'gt' => $user->lang['After']);
+ $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']);
$s_find_join_time = '';
foreach ($find_time as $key => $value)
{
$selected = ($joined_select == $key) ? ' selected="selected"' : '';
$s_find_join_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
}
+
$s_find_active_time = '';
foreach ($find_time as $key => $value)
{
@@ -104,16 +112,42 @@ if ($mode == 'searchuser')
$s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
}
- $where_sql .= ($username) ? " AND username LIKE '" . str_replace('*', '%', sql_quote($username)) ."'" : '';
- $where_sql .= ($email) ? " AND user_email LIKE '" . str_replace('*', '%', sql_quote($email)) ."' " : '';
- $where_sql .= ($icq) ? " AND user_icq LIKE '" . str_replace('*', '%', sql_quote($icq)) ."' " : '';
- $where_sql .= ($aim) ? " AND user_aim LIKE '" . str_replace('*', '%', sql_quote($aim)) ."' " : '';
- $where_sql .= ($yahoo) ? " AND user_yim LIKE '" . str_replace('*', '%', sql_quote($yahoo)) ."' " : '';
- $where_sql .= ($msn) ? " AND user_msnm LIKE '" . str_replace('*', '%', sql_quote($msn)) ."' " : '';
+ $where_sql .= ($username) ? " AND username LIKE '" . str_replace('*', '%', $db->sql_escape($username)) ."'" : '';
+ $where_sql .= ($email) ? " AND user_email LIKE '" . str_replace('*', '%', $db->sql_escape($email)) ."' " : '';
+ $where_sql .= ($icq) ? " AND user_icq LIKE '" . str_replace('*', '%', $db->sql_escape($icq)) ."' " : '';
+ $where_sql .= ($aim) ? " AND user_aim LIKE '" . str_replace('*', '%', $db->sql_escape($aim)) ."' " : '';
+ $where_sql .= ($yahoo) ? " AND user_yim LIKE '" . str_replace('*', '%', $db->sql_escape($yahoo)) ."' " : '';
+ $where_sql .= ($msn) ? " AND user_msnm LIKE '" . str_replace('*', '%', $db->sql_escape($msn)) ."' " : '';
$where_sql .= ($joined) ? " AND user_regdate " . $find_key_match[$joined_select] . " " . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : '';
$where_sql .= ($count) ? " AND user_posts " . $find_key_match[$count_select] . " $count " : '';
$where_sql .= ($active) ? " AND user_lastvisit " . $find_key_match[$active_select] . " " . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : '';
+ if (!empty($ipdomain))
+ {
+ $ips = (preg_match('#[a-z]#', $ipdomain)) ? implode(', ', preg_replace('#([0-9]{1,3}\.[0-9]{1,3}[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#', "'\\1'", gethostbynamel($ipdomain))) : "'" . str_replace('*', '%', $ipdomain) . "'";
+
+ $sql = "SELECT DISTINCT poster_id
+ FROM " . POSTS_TABLE . "
+ WHERE poster_ip " . ((preg_match('#%#', $ips)) ? 'LIKE' : 'IN') . " ($ips)";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $ip_sql = '';
+ do
+ {
+ $ip_sql .= (($ip_sql != '') ? ', ' : '') . $row['poster_id'];
+ }
+ while ($row = $db->sql_fetchrow($result));
+
+ $where_sql .= " AND user_id IN ($ip_sql)";
+ }
+ else
+ {
+ // A minor fudge but it does the job :D
+ $where_sql .= " AND user_id IN ('-1')";
+ }
+ }
}
// Sorting and order
@@ -129,43 +163,42 @@ $result = $db->sql_query($sql);
$total_users = ($row = $db->sql_fetchrow($result)) ? $row['total_users'] : 0;
// Pagination string
-$pagination_url = ($mode == 'searchuser') ? "memberlist.$phpEx$SID&amp;mode=searchuser&amp;form=$form&amp;field=$field&amp;username=" . urlencode($username) . "&amp;email=" . urlencode($email) . "&amp;icq=$icq&amp;aim=" . urlencode($aim) . "&amp;yahoo=" . urlencode($yahoo) . "&amp;msn=" . urlencode($msn) . "&amp;joined=" . urlencode(implode('-', $joined)) . "&amp;active=" . urlencode(implode('-', $active)) . "&amp;count=$count&amp;sort_dir=$sort_dir&amp;sort_key=$sort_key&amp;joined_select=$joined_select&amp;active_select=$active_select&amp;count_select=$count_select" : "memberlist.$phpEx$SID&amp;mode=$mode&amp;sort_dir=$sort_dir";
+$pagination_url = ($mode == 'searchuser') ? "memberlist.$phpEx$SID&amp;mode=searchuser&amp;form=$form&amp;field=$field&amp;username=" . urlencode($username) . "&amp;email=" . urlencode($email) . "&amp;icq=$icq&amp;aim=" . urlencode($aim) . "&amp;yahoo=" . urlencode($yahoo) . "&amp;msn=" . urlencode($msn) . "&amp;joined=" . urlencode(implode('-', $joined)) . "&amp;active=" . urlencode(implode('-', $active)) . "&amp;count=$count&amp;ip=" . urlencode($ipdomain) . "&amp;sort_dir=$sort_dir&amp;sort_key=$sort_key&amp;joined_select=$joined_select&amp;active_select=$active_select&amp;count_select=$count_select" : "memberlist.$phpEx$SID&amp;mode=$mode&amp;sort_dir=$sort_dir";
// Some search user specific data
if ($mode == 'searchuser')
{
$template->assign_vars(array(
- 'USERNAME' => $username,
- 'EMAIL' => $email,
- 'ICQ' => $icq,
- 'AIM' => $aim,
- 'YAHOO' => $yahoo,
- 'MSNM' => $msn,
- 'JOINED' => implode('-', $joined),
- 'ACTIVE' => implode('-', $active),
- 'COUNT' => $count,
-
- 'L_SEARCH_USERNAME' => $user->lang['Find_username'],
- 'L_SEARCH_EXPLAIN' => $user->lang['Find_username_explain'],
- 'L_RESET' => $user->lang['Reset'],
- 'L_ACTIVE' => $user->lang['Last_active'],
- 'L_SORT_BY' => $user->lang['Sort_by'],
- 'L_SORT_ASCENDING' => $user->lang['Sort_Ascending'],
+ 'USERNAME' => $username,
+ 'EMAIL' => $email,
+ 'ICQ' => $icq,
+ 'AIM' => $aim,
+ 'YAHOO' => $yahoo,
+ 'MSNM' => $msn,
+ 'JOINED' => implode('-', $joined),
+ 'ACTIVE' => implode('-', $active),
+ 'COUNT' => $count,
+ 'IP' => $ipdomain,
+
+ 'L_RESET' => $user->lang['Reset'],
+ 'L_ACTIVE' => $user->lang['Last_active'],
+ 'L_SORT_BY' => $user->lang['Sort_by'],
+ 'L_SORT_ASCENDING' => $user->lang['Sort_Ascending'],
'L_SORT_DESCENDING' => $user->lang['Sort_Descending'],
- 'L_SELECT_MARKED' => $user->lang['Select_marked'],
- 'L_MARK' => $user->lang['Mark'],
- 'L_MARK_ALL' => $user->lang['Mark_all'],
- 'L_UNMARK_ALL' => $user->lang['Unmark_all'],
-
- 'S_SEARCH_USER' => true,
- 'S_FORM_NAME' => $form,
- 'S_FIELD_NAME' => $field,
- 'S_COUNT_OPTIONS' => $s_find_count,
- 'S_SORT_OPTIONS' => $s_sort_key,
- 'S_USERNAME_OPTIONS'=> $username_list,
+ 'L_SELECT_MARKED' => $user->lang['Select_marked'],
+ 'L_MARK' => $user->lang['Mark'],
+ 'L_MARK_ALL' => $user->lang['Mark_all'],
+ 'L_UNMARK_ALL' => $user->lang['Unmark_all'],
+
+ 'S_SEARCH_USER' => true,
+ 'S_FORM_NAME' => $form,
+ 'S_FIELD_NAME' => $field,
+ 'S_COUNT_OPTIONS' => $s_find_count,
+ 'S_SORT_OPTIONS' => $s_sort_key,
+ 'S_USERNAME_OPTIONS' => $username_list,
'S_JOINED_TIME_OPTIONS' => $s_find_join_time,
'S_ACTIVE_TIME_OPTIONS' => $s_find_active_time,
- 'S_SEARCH_ACTION' => "memberslist.$phpEx$SID&amp;mode=searchuser&amp;field=$field")
+ 'S_SEARCH_ACTION' => "memberslist.$phpEx$SID&amp;mode=searchuser&amp;field=$field")
);
}
@@ -259,36 +292,36 @@ if ($row = $db->sql_fetchrow($result))
$search = '<a href="' . $temp_url . '">' . $user->lang['Search_user_posts'] . '</a>';
$template->assign_block_vars('memberrow', array(
- 'ROW_NUMBER' => $i + ($start + 1),
- 'USERNAME' => $username,
- 'FROM' => $from,
- 'JOINED' => $joined,
- 'POSTS' => $posts,
- 'AVATAR_IMG' => $poster_avatar,
- 'PROFILE_IMG' => $profile_img,
- 'PROFILE' => $profile,
- 'SEARCH_IMG' => $search_img,
- 'SEARCH' => $search,
- 'PM_IMG' => $pm_img,
- 'PM' => $pm,
- 'EMAIL_IMG' => $email_img,
- 'EMAIL' => $email,
- 'WWW_IMG' => $www_img,
- 'WWW' => $www,
- 'ICQ_STATUS_IMG' => $icq_status_img,
- 'ICQ_IMG' => $icq_img,
- 'ICQ' => $icq,
- 'AIM_IMG' => $aim_img,
- 'AIM' => $aim,
- 'MSN_IMG' => $msn_img,
- 'MSN' => $msn,
- 'YIM_IMG' => $yim_img,
- 'YIM' => $yim,
- 'ACTIVE' => $row['user_last_active'],
-
- 'S_ROW_COUNT' => $i,
-
- 'U_VIEWPROFILE' => "ucp.$phpEx$SID&amp;mode=viewprofile&amp;u=$user_id")
+ 'ROW_NUMBER' => $i + ($start + 1),
+ 'USERNAME' => $username,
+ 'FROM' => $from,
+ 'JOINED' => $joined,
+ 'POSTS' => $posts,
+ 'AVATAR_IMG' => $poster_avatar,
+ 'PROFILE_IMG' => $profile_img,
+ 'PROFILE' => $profile,
+ 'SEARCH_IMG' => $search_img,
+ 'SEARCH' => $search,
+ 'PM_IMG' => $pm_img,
+ 'PM' => $pm,
+ 'EMAIL_IMG' => $email_img,
+ 'EMAIL' => $email,
+ 'WWW_IMG' => $www_img,
+ 'WWW' => $www,
+ 'ICQ_STATUS_IMG'=> $icq_status_img,
+ 'ICQ_IMG' => $icq_img,
+ 'ICQ' => $icq,
+ 'AIM_IMG' => $aim_img,
+ 'AIM' => $aim,
+ 'MSN_IMG' => $msn_img,
+ 'MSN' => $msn,
+ 'YIM_IMG' => $yim_img,
+ 'YIM' => $yim,
+ 'ACTIVE' => $row['user_last_active'],
+
+ 'S_ROW_COUNT' => $i,
+
+ 'U_VIEWPROFILE' => "ucp.$phpEx$SID&amp;mode=viewprofile&amp;u=$user_id")
);
$i++;
@@ -301,23 +334,25 @@ $template->assign_vars(array(
'PAGINATION' => generate_pagination($pagination_url, $total_users, $config['topics_per_page'], $start). '&nbsp;',
'PAGE_NUMBER' => on_page($total_users, $config['topics_per_page'], $start),
- 'L_EMAIL' => $user->lang['Email'],
- 'L_WEBSITE' => $user->lang['Website'],
- 'L_FROM' => $user->lang['Location'],
- 'L_ORDER' => $user->lang['Order'],
- 'L_SORT' => $user->lang['Sort'],
- 'L_SUBMIT' => $user->lang['Sort'],
- 'L_AIM' => $user->lang['AIM'],
- 'L_YIM' => $user->lang['YIM'],
- 'L_MSNM' => $user->lang['MSNM'],
- 'L_ICQ' => $user->lang['ICQ'],
- 'L_JOINED' => $user->lang['Joined'],
- 'L_POSTS' => $user->lang['Posts'],
- 'L_GOTO_PAGE' => $user->lang['Goto_page'],
-
- 'S_MODE_SELECT' => $s_sort_key,
- 'S_ORDER_SELECT' => $s_sort_dir,
- 'S_MODE_ACTION' => "memberlist.$phpEx$SID&amp;mode=$mode&amp;form=$form")
+ 'L_EMAIL' => $user->lang['Email'],
+ 'L_WEBSITE' => $user->lang['Website'],
+ 'L_FROM' => $user->lang['Location'],
+ 'L_ORDER' => $user->lang['Order'],
+ 'L_SORT' => $user->lang['Sort'],
+ 'L_SUBMIT' => $user->lang['Sort'],
+ 'L_AIM' => $user->lang['AIM'],
+ 'L_YIM' => $user->lang['YIM'],
+ 'L_MSNM' => $user->lang['MSNM'],
+ 'L_ICQ' => $user->lang['ICQ'],
+ 'L_JOINED' => $user->lang['Joined'],
+ 'L_POSTS' => $user->lang['Posts'],
+ 'L_GOTO_PAGE' => $user->lang['Goto_page'],
+
+ 'U_FIND_MEMBER' => "memberlist.$phpEx$SID&amp;mode=searchuser",
+
+ 'S_MODE_SELECT' => $s_sort_key,
+ 'S_ORDER_SELECT'=> $s_sort_dir,
+ 'S_MODE_ACTION' => "memberlist.$phpEx$SID&amp;mode=$mode&amp;form=$form")
);
// Output the page