From 7abe67c821e9c0f81f135494d527f86b7357910a Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Sat, 10 Jan 2004 18:41:53 +0000 Subject: [PATCH] Add IP/rDNS/whois info to viewonline ... doing away with need to visit ACP git-svn-id: file:///svn/phpbb/trunk@4742 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/language/en/lang_main.php | 9 ++-- .../subSilver/template/overall_header.html | 4 +- .../subSilver/template/viewonline_body.html | 2 +- .../subSilver/template/viewonline_whois.html | 15 +++++++ phpBB/viewonline.php | 45 +++++++++++++++++-- 5 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 phpBB/styles/subSilver/template/viewonline_whois.html diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php index 97abf7d5d2..70dd941910 100644 --- a/phpBB/language/en/lang_main.php +++ b/phpBB/language/en/lang_main.php @@ -358,6 +358,7 @@ $lang = array( 'LOGIN' => 'Login', + 'LOGIN_INFO' => 'In order to login you must be registered. Registering takes only a few seconds but gives you increased capabilies. The board administrator may also grant additional permissions to registered users. Before you login please ensure you are familiar with our terms of use and related policies. Please ensure you read any forum rules as you navigate around the board.', 'TERMS_USE' => 'Terms of Use', 'PRIVACY' => 'Privacy Policy', 'FORGOT_PASS' => 'I forgot my password', @@ -1222,18 +1223,14 @@ $lang += array( 'VIEW_ONLINE_TIMES' => 'This data is based on users active over the past %d minutes', // 2 minutes, etc. 'FORUM_LOCATION' => 'Forum Location', 'LAST_UPDATED' => 'Last Updated', + 'IP' => 'IP', // IP: x.x.x.x or somedomain.com + 'WHOIS' => 'Whois', 'READING_FORUM' => 'Viewing topics in %s', 'READING_TOPIC' => 'Reading topic in %s', 'POSTING_MESSAGE' => 'Posting message in %s', 'REPLYING_MESSAGE' => 'Replying to message in %s', 'READING_GLOBAL_ANNOUNCE' => 'Reading global announcement', 'REPLYING_GLOBAL_ANNOUNCE' => 'Replying to global announcement', - 'SEARCHING_FORUMS' => 'Searching forums', - 'VIEWING_ONLINE' => 'Viewing who is online', - 'VIEWING_MEMBERS' => 'Viewing member details', - 'VIEWING_MESSAGES' => 'Viewing Private Messages', - 'VIEWING_FAQ' => 'Viewing FAQ', - 'SEARCHING_FORUMS' => 'Searching forums', 'VIEWING_ONLINE' => 'Viewing who is online', 'VIEWING_MEMBERS' => 'Viewing member details', diff --git a/phpBB/styles/subSilver/template/overall_header.html b/phpBB/styles/subSilver/template/overall_header.html index 93bafe4e74..c4be311a5c 100644 --- a/phpBB/styles/subSilver/template/overall_header.html +++ b/phpBB/styles/subSilver/template/overall_header.html @@ -26,9 +26,9 @@ if ({S_NEW_PM}) } -function im_popup(url, width, height) +function popup(url, width, height) { - window.open(url, '_contact', 'HEIGHT=' + height + ',resizable=yes,scrollbars=yes, WIDTH=' + width); + window.open(url, '_popup', 'HEIGHT=' + height + ',resizable=yes,scrollbars=yes, WIDTH=' + width); return false; } diff --git a/phpBB/styles/subSilver/template/viewonline_body.html b/phpBB/styles/subSilver/template/viewonline_body.html index a679352fc2..ba504700f9 100644 --- a/phpBB/styles/subSilver/template/viewonline_body.html +++ b/phpBB/styles/subSilver/template/viewonline_body.html @@ -17,7 +17,7 @@ -  {reg_user_row.USERNAME}  +

{reg_user_row.USERNAME} 

{L_IP}: {reg_user_row.USER_IP} » {L_WHOIS}

 {reg_user_row.LASTUPDATE}   {reg_user_row.FORUM_LOCATION}  diff --git a/phpBB/styles/subSilver/template/viewonline_whois.html b/phpBB/styles/subSilver/template/viewonline_whois.html new file mode 100644 index 0000000000..8d939befc6 --- /dev/null +++ b/phpBB/styles/subSilver/template/viewonline_whois.html @@ -0,0 +1,15 @@ + + + + + + + + + + + +
{L_WHOIS}
{WHOIS}
+ + + \ No newline at end of file diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index 0f363fcf70..293bdf070d 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -22,9 +22,11 @@ $auth->acl($user->data); $user->setup(); // Get and set some variables -$start = request_var('start', 0); -$sort_key = request_var('sk', 'b'); -$sort_dir = request_var('sd', 'd'); +$mode = request_var('mode', ''); +$user_id = request_var('u', 0); +$start = request_var('start', 0); +$sort_key = request_var('sk', 'b'); +$sort_dir = request_var('sd', 'd'); $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED']); $sort_key_sql = array('a' => 'username', 'b' => 'session_time', 'c' => 'session_page'); @@ -32,6 +34,39 @@ $sort_key_sql = array('a' => 'username', 'b' => 'session_time', 'c' => 'session_ // Sorting and order $order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); +// Whois requested +if ($mode == 'whois') +{ + include($phpbb_root_path.'includes/functions_admin.'.$phpEx); + + $sql = 'SELECT u.user_id, u.username, u.user_type, s.session_ip + FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . " s + WHERE u.user_id = $user_id + AND s.session_user_id = u.user_id"; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + $whois = ipwhois($row['session_ip']); + $whois = preg_replace('#(\s+?)([\w\-\._\+]+?@[\w\-\.]+?)(\s+?)#s', '\1\2\3', $whois); + $whois = preg_replace('#(\s+?)(http://.*?)(\s+?)#s', '\1\2\3', $whois); + + $template->assign_vars(array( + 'WHOIS' => trim($whois)) + ); + } + $db->sql_freeresult($result); + + // Output the page + page_header($user->lang['WHO_IS_ONLINE']); + + $template->set_filenames(array( + 'body' => 'viewonline_whois.html') + ); + make_jumpbox('viewforum.'.$phpEx); + + page_footer(); +} // Forum info $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, left_id, right_id @@ -187,11 +222,13 @@ while ($row = $db->sql_fetchrow($result)) 'USERNAME' => $username, 'LASTUPDATE' => $user->format_date($row['session_time']), 'FORUM_LOCATION'=> $location, - 'USER_IP' => ($auth->acl_get('a_')) ? $row['session_ip'] : $user->lang['HIDDEN'], + 'USER_IP' => ($auth->acl_get('a_')) ? (($mode == 'lookup' && $user_id == $row['user_id']) ? gethostbyaddr($row['session_ip']) : $row['session_ip']) : '', 'S_ROW_COUNT' => $$which_counter, 'U_USER_PROFILE' => ($row['user_type'] <> USER_IGNORE) ? "memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'] : '', + 'U_USER_IP' => "viewonline.$phpEx$SID" . (($mode != 'lookup') ? '&mode=lookup&u=' . $row['user_id'] : ''), + 'U_WHOIS' => "viewonline.$phpEx$SID&mode=whois&u=" . $row['user_id'], 'U_FORUM_LOCATION' => $location_url) );