Find user by posted IP

git-svn-id: file:///svn/phpbb/trunk@3510 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2003-02-22 17:18:44 +00:00
parent 5fc4d66994
commit a1f4ba0ed3
3 changed files with 226 additions and 180 deletions

View file

@ -422,7 +422,6 @@ $lang = array_merge($lang, array(
'Send_a_reply' => 'Reply to a private message',
'Edit_message' => 'Edit private message',
'Notification_subject' => 'New Private Message has arrived',
'FIND_USERNAME' => 'Find a username',
'Find' => 'Find',
'No_match' => 'No matches found',
'No_such_folder' => 'No such folder exists',
@ -564,6 +563,10 @@ $lang = array_merge($lang, array(
'Empty_message_email' => 'You must enter a message to be emailed',
'FIND_USERNAME' => 'Find a member',
'FIND_USERNAME_EXPLAIN' => 'Use this form to search for specific members. You do not need to fill out all fields, to partialy match data use * as a wildcard. When entering dates use the format yyyy-mm-dd, e.g. 2002-01-01. Click the username to automatically enter it into the form you are viewing (several usernames may be accepted depending on the form itself). Alternatively you can mark the users required and click the Insert Marked button.',
'NO_MEMBERS' => 'No members found for this search criteria',
'SEND_MESSAGE' => 'Message',
'POST_IP' => 'Posted from IP/domain',
'SELECT_SORT_METHOD' => 'Select sort method',
'SORT' => 'Sort',
@ -644,7 +647,6 @@ $lang = array_merge($lang, array(
'Search_keywords_explain' => 'You can use <u>AND</u> to define words which must be in the results, <u>OR</u> to define words which may be in the result and <u>NOT</u> to define words which should not be in the result. Use * as a wildcard for partial matches',
'Search_author' => 'Search for Author',
'Search_author_explain' => 'Use * as a wildcard for partial matches',
'Find_username_explain' => 'Use this form to search for specific usernames. You do not need to fill out all fields, to partialy match data use * as a wildcard. When entering dates use the format yyyy-mm-dd, e.g. 2002-01-01. Click the username to automatically enter it into the form you are viewing (several usernames may be accepted depending on the form itself). Alternatively you can mark the users required and click the Insert Marked button.',
'Last_active' => 'Last active',
'Select_marked' => 'Select Marked',
'Search_for_any' => 'Search for any terms or use query as entered',
@ -743,6 +745,7 @@ $lang = array_merge($lang, array(
'logm_lock' => 'Locked following topic/s => %s',
'All_times' => 'All times are %s %s',
'-13' => 'GMT - 13 Hours',
'-12' => 'GMT - 12 Hours',
@ -756,6 +759,7 @@ $lang = array_merge($lang, array(
'-4' => 'GMT - 4 Hours',
'-3.5' => 'GMT - 3.5 Hours',
'-3' => 'GMT - 3 Hours',
'-2.5' => 'GMT - 2.5 Hours',
'-2' => 'GMT - 2 Hours',
'-1' => 'GMT - 1 Hours',
'0' => 'GMT',
@ -774,6 +778,7 @@ $lang = array_merge($lang, array(
'9' => 'GMT + 9 Hours',
'9.5' => 'GMT + 9.5 Hours',
'10' => 'GMT + 10 Hours',
'10.5' => 'GMT + 10.5 Hours',
'11' => 'GMT + 11 Hours',
'12' => 'GMT + 12 Hours',
'13' => 'GMT + 13 Hours',
@ -790,6 +795,7 @@ $lang = array_merge($lang, array(
'-4' => 'GMT - 4 Hours',
'-3.5' => 'GMT - 3.5 Hours',
'-3' => 'GMT - 3 Hours',
'-2.5' => 'GMT - 2.5 Hours',
'-2' => 'GMT - 2 Hours',
'-1' => 'GMT - 1 Hours',
'0' => 'GMT',
@ -808,11 +814,14 @@ $lang = array_merge($lang, array(
'9' => 'GMT + 9 Hours',
'9.5' => 'GMT + 9.5 Hours',
'10' => 'GMT + 10 Hours',
'10.5' => 'GMT + 10.5 Hours',
'11' => 'GMT + 11 Hours',
'12' => 'GMT + 12 Hours',
'13' => 'GMT + 13 Hours',
'dst' => '[ DST ]'
),
'AM' => 'AM',
'PM' => 'PM',
'datetime' => array(
'Sunday' => 'Sunday',
'Monday' => 'Monday',
@ -851,8 +860,6 @@ $lang = array_merge($lang, array(
'Oct' => 'Oct',
'Nov' => 'Nov',
'Dec' => 'Dec',
'AM' => 'AM',
'PM' => 'PM'
),
'Information' => 'Information',

View file

@ -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,7 +163,7 @@ $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')
@ -144,9 +178,8 @@ if ($mode == 'searchuser')
'JOINED' => implode('-', $joined),
'ACTIVE' => implode('-', $active),
'COUNT' => $count,
'IP' => $ipdomain,
'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'],
@ -162,7 +195,7 @@ if ($mode == 'searchuser')
'S_FIELD_NAME' => $field,
'S_COUNT_OPTIONS' => $s_find_count,
'S_SORT_OPTIONS' => $s_sort_key,
'S_USERNAME_OPTIONS'=> $username_list,
'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")
@ -275,7 +308,7 @@ if ($row = $db->sql_fetchrow($result))
'EMAIL' => $email,
'WWW_IMG' => $www_img,
'WWW' => $www,
'ICQ_STATUS_IMG' => $icq_status_img,
'ICQ_STATUS_IMG'=> $icq_status_img,
'ICQ_IMG' => $icq_img,
'ICQ' => $icq,
'AIM_IMG' => $aim_img,
@ -315,8 +348,10 @@ $template->assign_vars(array(
'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_ORDER_SELECT'=> $s_sort_dir,
'S_MODE_ACTION' => "memberlist.$phpEx$SID&amp;mode=$mode&amp;form=$form")
);

View file

@ -76,7 +76,7 @@ function marklist(status)
</tr>
<tr>
<td class="row1"><span class="gen">{L_POST_IP}:</span></td>
<td class="row2"><input class="post" type="text" name="msn" value="{MSNM}" /></td>
<td class="row2"><input class="post" type="text" name="ip" value="{IP}" /></td>
</tr>
<tr>
<td class="row1"><span class="gen">{L_SORT_BY}:&nbsp;</td>
@ -91,6 +91,7 @@ function marklist(status)
<!-- IF S_SEARCH_USER --><form method="post" name="results" action="{S_MODE_ACTION}" onsubmit="insert_marked(this.user);return false"><!-- ELSE --><form method="post" action="{S_MODE_ACTION}"><!-- ENDIF --><table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td class="nav" align="left"><a href="{U_INDEX}">{L_INDEX}</a></td>
<!-- IF S_SEARCH_USER eq false --><td class="gensmall" align="right"><a href="{U_FIND_MEMBER}">{L_FIND_USERNAME}</a></td><!-- ENDIF -->
</tr>
</table>
@ -122,12 +123,15 @@ function marklist(status)
<td class="gen" align="center">&nbsp;{memberrow.WWW_IMG}&nbsp;</td>
<!-- IF S_SEARCH_USER --><td align="center" valign="middle"><input type="checkbox" name="user" value="{memberrow.USERNAME}" /></td><!-- ENDIF -->
</tr>
<!-- BEGINELSE -->
<tr>
<td class="row1" colspan="<!-- IF S_SEARCH_USER -->9<!-- ELSE -->8<!-- ENDIF -->" height="30" align="center" valign="middle"><span class="gen">{L_NO_MEMBERS}</span></td>
</tr>
<!-- END memberrow -->
<tr>
<td class="cat" colspan="<!-- IF S_SEARCH_USER -->9<!-- ELSE -->8<!-- ENDIF -->" height="28"><table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="center"><span class="gensmall">{L_SELECT_SORT_METHOD}:</span>&nbsp;{S_MODE_SELECT}&nbsp; <span class="gensmall">{L_ORDER}</span>&nbsp;{S_ORDER_SELECT}&nbsp; <input type="submit" name="submit" value="{L_SUBMIT}" class="liteoption" /></td>
<!-- IF S_SEARCH_USER --><td align="right"><input class="liteoption" type="submit" value="{L_SELECT_MARKED}" /></td><!-- ENDIF -->
<td align="center"><!-- IF S_SEARCH_USER --><input class="liteoption" type="submit" value="{L_SELECT_MARKED}" /><!-- ELSE --><span class="gensmall">{L_SELECT_SORT_METHOD}:</span>&nbsp;{S_MODE_SELECT}&nbsp; <span class="gensmall">{L_ORDER}</span>&nbsp;{S_ORDER_SELECT}&nbsp; <input type="submit" name="submit" value="{L_SUBMIT}" class="liteoption" /><!-- ENDIF --></td>
</tr>
</table></td>
</tr>