09-Mar-2012, 01:58 AM
I'm very pleased by the script commentics, I want to thank the author for this great job. Here is my small addition to the script . With this addition you are able to see the image of the search engine instead of the image of the spider in the
admin panel->Tools->viewers
the change is in the file
/comments/admin_/includes/pages/tool_viewers.php
line 69 was:
admin panel->Tools->viewers
the change is in the file
/comments/admin_/includes/pages/tool_viewers.php
line 69 was:
PHP Code:
<?php
while ($viewer = mysql_fetch_assoc($viewers)) {
?>
<tr>
<?php if (!empty($viewer["user_agent"]) && is_spider($viewer["user_agent"])) { ?> <td><img src="<?php echo "images/viewers/spider.png";?>" class="viewer" title="Spider" alt="Spider"></td> <?php } else { ?> <td><img src="<?php echo "images/viewers/person.png";?>" class="viewer" title="Person" alt="Person"></td> <?php } ?>
<td><?php echo $viewer["ip_address"]; ?></td>
<td><?php echo $viewer["page_reference"]; ?></td>
<td><?php echo "<a href='" . $viewer["page_url"] . "' target='_blank'>" . $viewer["page_url"] . "</a>"; ?></td>
<td><span style="display:none;"><?php echo $viewer["timestamp"]; ?></span><?php echo date("i\m s\s", $timestamp - $viewer["timestamp"]); ?></td>
</tr>
<?php } ?>
has to become:
PHP Code:
<?php
function ipOrSpider($user_agent,$ip_address){
$ipOrSpider=Array();
if (preg_match('/Googlebot|naver\.com|YoudaoBot|bingbot|Baiduspider|(?:Sogou web spider)|Sosospider|(?:Yahoo. Slurp)/',$user_agent)){
if (preg_match('/http(.*?\\.com)/',$user_agent, $spiderA)) {
$spider = $spiderA[0];
$domain = parse_url($spider, PHP_URL_HOST);
$domain = preg_replace('/(.*?)\\.(.*?)\\./si', '$2.', $domain);
if (preg_match('/YoudaoBot/',$user_agent)){
$ipOrSpider['img'] = "http://shared.ydstatic.com/images/favicon.ico";
}else if (preg_match('/naver/',$user_agent)){
$ipOrSpider['img'] = "http://www.naver.com/favicon.ico";
}else{
$ipOrSpider['img'] = htmlspecialchars($spider)."/favicon.ico";
}
$ipOrSpider['name'] = htmlspecialchars($domain);
return $ipOrSpider;
} else {
$ipOrSpider['img'] = "images/viewers/spider.png";
$ipOrSpider['name'] = htmlspecialchars($user_agent);
return $ipOrSpider;
}
}
$ipOrSpider['img'] = "images/viewers/person.png";
$ipOrSpider['name'] = $ip_address;
return $ipOrSpider;
}
$viewers = mysql_query("SELECT * FROM `".$mysql_table_prefix."viewers` ORDER BY timestamp DESC LIMIT 0,200");
while ($viewer = mysql_fetch_assoc($viewers)) {
$ipOrSpider = ipOrSpider($viewer["user_agent"],$viewer["ip_address"]);
?>
<tr>
<td><img src="<?php echo $ipOrSpider['img']; ?>" class="viewer" title="" alt=""></td>
<td><?php echo $ipOrSpider['name']; ?></td>
<td><?php echo $viewer["page_reference"]; ?></td>
<td><?php echo "<a href='" . $viewer["page_url"] . "' target='_blank'>" . $viewer["page_url"] . "</a>"; ?></td>
<td><span style="display:none;"><?php echo $viewer["timestamp"]; ?></span><?php echo date("i\m s\s", $timestamp - $viewer["timestamp"]); ?></td>
</tr>
<?php } ?>