function contains($substring, $string) {
$pos = strpos($string, $substring);
if($pos === false) {
// string needle NOT found in haystack
return false;
}
else {
// string needle found in haystack
return true;
}
}
$flExists = FALSE;
$mamy_bota = FALSE;
$czy_agent_file = "/data/www/zareklamuj.org/robotscounter/czyagent.db";
$RobotDB = "/data/www/zareklamuj.org/robotscounter/robot.db";
$RobotArray = array("googlebot", "bingbot", "msn", "yandex", "netsprint", "onet", "szukacz");
$counter = array(0,0,0,0,0,0,0);
$readcounter = array(0,0,0,0,0,0,0);
$czy_agent_dozapisu = array("",0);
$CurrentBot = strtolower($_SERVER['HTTP_USER_AGENT']);
If (filesize($RobotDB)==0)
{
$DBHandle = fopen($RobotDB, "w+");
fwrite($DBHandle, serialize($readcounter));
fclose($DBHandle);
}
foreach ($RobotArray as $key => $value){
if (contains($value, $CurrentBot) === true ) {
$mamy_bota = TRUE;
}
};
If ($mamy_bota)
{
$readcounter = unserialize (file_get_contents($RobotDB));
foreach ($RobotArray as $key => $value){
if (contains($value, $CurrentBot) === true ) {
$readcounter[$key]++;
}
};
$DBHandle = fopen($RobotDB, "w+");
fwrite($DBHandle, serialize($readcounter));
fclose($DBHandle);
}
else
{
$readcounter = unserialize (file_get_contents($RobotDB));
}
$PageInfo = array_combine($RobotArray, $readcounter);
//****** czy agent *****
//* $plik1 = fopen($czy_agent_file,"w+");
//* fwrite($plik1, $CurrentBot);
//* fwrite($plik1, "\n");
//* fwrite($plik1, $mamy_bota);
//* fwrite($plik1, "\n");
//* fclose($plik1);
//****** test *****
$plik = fopen("/data/www/zareklamuj.org/robotscounter/test.db","r");
$licznik = fgets($plik);
fclose($plik);
settype($licznik, "int");
$licznik++;
$plik = fopen("/data/www/zareklamuj.org/robotscounter/test.db","w");
fwrite($plik, $licznik);
fclose($plik);
?>
Powered by
Arfooo directory © 2008 - 2010 Generated in 0.093 Queries: 5
Kontakt