<?php

error_reporting
(E_ERROR); 
ini_set("display_errors"1); 

define('IN_BOTS'true);

define('TIME_INTERVAL'5);    // Last activity interval in minutes
define('SHOW_AS_LINKS'false);    // Show bot names as links to bots.php

require_once('bots_settings.php');

$interval time() - TIME_INTERVAL 60;
$date date('Y-m-d'$interval);
$time date('H:i:s'$interval);

$bots = @file_get_contents(dirname(__FILE__) . '/bot_stat.txt');
$bots explode("\n"$bots);
if (
$bots)
{
    
$out = array();
    foreach(
$bots as $bot)
    {
        list(
$b_ua$b_ip$b_date$b_time) = explode("\t"$bot5);
        if (
$b_date >= $date && $b_time >= $time)
            
$out[] = GetBotTitle($b_uaSHOW_AS_LINKS);
    }
    if (!
SHOW_AS_LINKS)
        
$out array_unique($out);
    echo 
implode(', '$out);
}

function 
GetBotTitle($bot$link true)
{
    global 
$bot_names$strings;
    foreach (
$bot_names as $value => $title)
        if (
stripos($bot$value) !== false)
            return 
Tag('strong'$link '<a href="?bot=' urlencode($bot) . '" title="' $strings['details'] . '">' $title '</a>' $title);
    return 
$link '<a class="unknown" href="?bot=' urlencode($bot) . '" title="' $strings['edit_settings'] . '">' $strings['unknown_bot'] . '</a>'
        
'<abbr class="unknown" title="' $strings['edit_settings'] . '">' $strings['unknown_bot'] . '</abbr>';
}

function 
Tag($tag$text)
{
    return 
"<$tag>$text</$tag>";
}

?>