1
Updated 9/1/04 to work with 2.0.7.1 Zip FileI'm the curious type so I made this hack to find out who my normal visitors are that are just looking "anonymous"ly. This script is hard-coded for only admins.
./misc.php ~line 208 & 215 (red text)
create a folder called admintools in your modules directory (./modules/admintools/)
./modules/admintools/header.php
include "../../mainfile.php";
./modules/admintools/index.php
include "header.php";
include XOOPS_ROOT_PATH."/header.php";
global $xoopsDB;
$isadmin = ($xoopsUser && $xoopsUser->isAdmin()) ? 1 : 0;
if ($isadmin===1)
{
// find which tool to use
switch ($_GET['tool'])
{
case 'iplookup':
// convert the string of ip#s from the uri to an array
$iplist = explode('|',$_GET['ip']);
// go though each ip
foreach($iplist as $ip)
{
// separate ip into ocets
$ip_array = explode('.',$ip);
// find the possible user
$partial_ip = '';
echo 'Looking up '
.$ip.' ('.gethostbyaddr($ip).')';
// used to append the dotted decimal to the parial ip's;
// prevents matching 24% which could match 244. than the intendd 24.
$dot = '.';
$wild = '%';
foreach ($ip_array as $key=>$octet)
{
$lookup[$key]['result'] = '';
// removes the dotted decimal if on the last octet and wildcard
if ($key > 2)
{
$dot = '';
$wild = '';
}
$partial_ip .= $octet.$dot;
$sql = 'SELECT u.uname, bb.poster_ip, u.uid
FROM xoops_bb_posts as bb
INNER
JOIN xoops_users as u
ON bb.uid = u.uid
WHERE bb.poster_ip LIKE "'.$partial_ip.$wild.'"
GROUP BY u.uname';
$result = $xoopsDB->query($sql);
$sql.'
';
// display output
$lookup[$key]['ip'] = '
IP: '.$partial_ip.'
';
while ($user = $xoopsDB->fetchArray($result))
{
$lookup[$key]['result'] .= '.XOOPS_URL.'/userinfo.php?uid='.$user['uid'].'" target="_blank">'.$user['uname'].'
';
}
// append the dotted decimal to the octet
}
// display the results in reverse order (exact ip to broad)
// first flip the order of the array
rsort($lookup, SORT_NUMERIC);
foreach ($lookup as $output)
{
echo $output['ip'].$output['result'];
}
}
break;
default:
echo 'No tool selected';
}
}
else
{
echo 'You must have administrative access to enter this area';
}
include XOOPS_ROOT_PATH."/footer.php";
?>
The new popup box when clicking "more..." from who's online with "anonymous lookup"
The result page. It checks from exact to broad comparing against ip's from forum posts. eg: full ip is 1.2.3.4, it will check 1.2.3.4 then 1.2.3.% then 1.2.% then 1.% for every anonymous user. there were 2 in this example.
You might notice that my who's online popup shows the reverse dns, it's because i also edited the ./misc.php file ~line 194 to
$onlineUsers[$i]['ip'] =[b]gethostbyaddr([/b]$onlines[$i]['online_ip']);