%PDF- %PDF-
| Direktori : /www/varak.net/www.varak.net/ |
| Current File : /www/varak.net/www.varak.net/count.php |
<?php
$othcnt = 0;
set_time_limit(0);
function cnt_p($val, $key)
{
$key = $key ? $key : "Ostatni";
echo "$key: $val\n";
}
function cnt_ag($val, $key)
{
global $othcnt;
global $http;
if($val < ($http/30))
{
$othcnt += $val;
return;
}
echo "$key: $val\n";
}
function getmicrotime()
{
list($usec,$sec)=explode(" ",microtime());
return ((float)$usec+(float)$sec);
}
$tzac=getmicrotime();
$subs = array();
$lin = scandir("/www/varak.net/htdocs80/");
foreach($lin as $sub)
{
if(is_dir("/www/varak.net/htdocs80/$sub") && $sub != "." && $sub != "..")
{
$subs[] = $sub.".varak.net";
}
}
unset($lin);
$cnts = array();
$slohovka = 0;
$vse = 0;
$serpent = 0;
$eye = 0;
$hyjal = 0;
$bt = 0;
$project = 0;
$avatar = 0;
$http = 0;
$templars = 0;
$nirthy = 0;
$tos = 0;
$sign = 0;
$fulnek2008 = 0;
$bilovec2008 = 0;
$amael = 0;
$showloot = 0;
$bpa08 = 0;
$agents = array();
$f = fopen("/www/varak.net/logs/custom_log", "r");
while(!feof($f))
{
$line = fgets($f);
$http++;
$wtmp = explode(" ", $line);
$ag = "";
for($i = 12; $i < count($wtmp); $i++)
{
$ag .= $wtmp[$i];
}
$ag = trim($ag);
$agents[$ag]++;
$p = strpos($line, " ");
$doma = substr($line, 0, $p);
if(!in_array($doma, $subs))
{
$doma = "0";
}
$cnts[$doma]++;
if(strstr($line, "text.html"))
{
$slohovka++;
continue;
}
if(strstr($line, "WoWScrn"))
{
$vse++;
}
if(strstr($line, "serpentshrine"))
{
$serpent++;
continue;
}
if(strstr($line, "the_eye"))
{
$eye++;
continue;
}
if(strstr($line, "hyjal"))
{
$hyjal++;
continue;
}
if(strstr($line, "drevarny-bpa"))
{
$bpa08++;
continue;
}
if(strstr($line, "black_temple"))
{
$bt++;
continue;
}
if(strstr($line, "waritko_avatar_og.jpg"))
{
$avatar++;
continue;
}
if(strstr($line, "pxangel.png"))
{
$project++;
continue;
}
if(strstr($line, "GET /loot/showloot.php"))
{
$showloot++;
continue;
}
if(strstr($line, "Templars%20Of%20Steel.mp3"))
{
$tos++;
continue;
}
if(strstr($line, "- templars"))
{
$templars++;
continue;
}
if(strstr($line, "/sig/sig.php/4shlIV.png"))
{
$nirthy++;
}
if(strstr($line, "/sig/sig.php/140TlCmc.png"))
{
$amael++;
}
if(strstr($line, "/sig/sig.php"))
{
$sign++;
continue;
}
if(strstr($line, "/fulnek2008"))
{
$fulnek2008++;
continue;
}
if(strstr($line, "/bilovec2008"))
{
$bilovec2008++;
continue;
}
}
arsort($cnts);
arsort($agents);
header("Content-type: text/plain");
echo "Slohovka: $slohovka\n";
echo "Vse dohromady: $vse\n";
echo "Serpentshrine: $serpent\n";
echo "The Eye: $eye\n";
echo "Hyjal Summit: $hyjal\n";
echo "Black Temple: $bt\n";
echo "Project Podpis: $project\n";
echo "Waritko Avatar: $avatar\n";
echo "Templars of Steel: $tos\n";
echo "Nalogovani Templari: $templars\n";
echo "Nirthy Signature: $nirthy\n";
echo "Amael Signature: $amael\n";
echo "WoW Signatures: $sign\n";
echo "Fulnek 2008: $fulnek2008\n";
echo "Bilovec 2008: $bilovec2008\n";
echo "Showloot: $showloot\n";
echo "BPA 08: $bpa08\n";
echo "HTTP: $http\n\n\n";
array_walk($cnts, "cnt_p");
echo "\n\n";
array_walk($agents, "cnt_ag");
echo "Ostatni: $othcnt\n";
/*header("Content-type: text/plain");
//passthru("gcc -o count -O4 -fomit-frame-pointer -pipe count.c");
passthru("./count /www/varak.net/logs/custom_log"); */
$mem = sprintf("%01.2f", memory_get_peak_usage(true)/(1024*2024));
$tkon=getmicrotime();
$time=$tkon-$tzac;
printf("\n\nTime wasted: %01.4f sec\nMemory used: %s Mbytes\n", $time, $mem);
?>