<?
////////////////////////////////////////////////////////////////////////////////////////////
//+--------------------------------------------------------------------------------------+//
//| file : ./countit.php |//
//| project : AllMyVisitors |//
//| last modified : 11.04.2002 |//
//+-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --+//
//| |//
//| global working counter file. include this script where ever you want ... |//
//| |//
//+--------------------------------------------------------------------------------------+//
//| (c) 2002 by Armin Gerhardts http://php-resource.net |//
//+--------------------------------------------------------------------------------------+//
////////////////////////////////////////////////////////////////////////////////////////////
if(!$AMV_openconfig){
echo "Can not open config file for reading";
} else {
///////////////////
//+-------------+//
//| read config |//
//+-------------+//
///////////////////
@$AMV_getconfig = mysql_query("SELECT * FROM $AMV_scriptconfigtbl");
if($AMV_getconfig){
$AMV_config = mysql_fetch_array($AMV_getconfig);
$AMV_enablenewcount = $AMV_config[enablenewcount];
$AMV_howtoshow = $AMV_config[howtoshow];
$AMV_dropuser = $AMV_config[dropuser];
$AMV_invisible = $AMV_config[invisible];
$AMV_showallvisitors = $AMV_config[showallvisitors];
$AMV_showallvisitorstext = $AMV_config[showallvisitorstext];
$AMV_showtodayvisitors = $AMV_config[showtodayvisitors];
$AMV_showtodayvisitorstext = $AMV_config[showtodayvisitorstext];
$AMV_showyesterdayvisitors = $AMV_config[showyesterdayvisitors];
$AMV_showyesterdayvisitorstext = $AMV_config[showyesterdayvisitorstext];
$AMV_showcurrentvisitors = $AMV_config[showcurrentvisitors];
$AMV_showcurrentvisitorstext = $AMV_config[showcurrentvisitorstext];
$AMV_showrecordvisitors = $AMV_config[showdayrecordvisitors];
$AMV_showrecordvisitorstext = $AMV_config[showrecordvisitorstext];
$AMV_showcurrentrecordvisitors = $AMV_config[showcurrentrecordvisitors];
$AMV_showcurrentrecordvisitorstext = $AMV_config[showcurrentrecordvisitorstext];
if($AMV_howtoshow== '1'){
$AMV_showit = " | ";
}
if($AMV_howtoshow== '2'){
$AMV_showit = "<br>";
}
} else {
echo "Error in your configuration, please check your config.inc.php<br>All processes stopped in order to fix it";
exit;
}
$AMV_getmaxdata = mysql_query("SELECT * FROM $AMV_countermaxdata");
$AMV_maxdata = mysql_fetch_array($AMV_getmaxdata);
$AMV_pmaxcurrent = $AMV_maxdata[maxcurrent];
$AMV_pmaxperday = $AMV_maxdata[maxperday];
$AMV_stamp = mktime(0, 0, 0, date("m"), date("d")-2, date("y"));
$AMV_twodaysago = date("d.m.y", $AMV_stamp);
$AMV_deleteblockedip=mysql_query("DELETE FROM $AMV_counteripblock WHERE del < $AMV_countflag - $AMV_enablenewcount");
$AMV_deleteoldcount=mysql_query("DELETE FROM $AMV_counterhits WHERE date = '$AMV_twodaysago' ");
$AMV_deletebycountflag = mysql_query("DELETE FORM $AMV_counterhits WHERE countflag <= $AMV_countflag - 172800");
$AMV_checkip=mysql_query("SELECT * FROM $AMV_counteripblock where ipadr='$AMV_ipadr' ");
$AMV_resultipcheck=mysql_num_rows($AMV_checkip);
$AMV_checkclient_host = mysql_query("SELECT * FROM $AMV_counteripblock WHERE client = '$AMV_client' AND host = '$AMV_host'");
$AMV_resultclient_hostcheck = mysql_num_rows($AMV_checkclient_host);
if($AMV_resultipcheck == "0" && $AMV_resultclient_hostcheck =="0"){
$AMV_query=mysql_query("INSERT INTO $AMV_counterhits VALUES ('', '$AMV_ipadr','$AMV_client','$AMV_countflag','$AMV_dateonly')" );
$AMV_query=mysql_query("INSERT INTO $AMV_counteripblock VALUES ('$AMV_dateonly', '$AMV_countflag','$AMV_ipadr','$AMV_client','$AMV_host')" );
}
//////////////////////////////////////////////////
//+--------------------------------------------+//
//| print all users, by reading the highest id |//
//+--------------------------------------------+//
//////////////////////////////////////////////////
if($AMV_showallvisitors == '1'){
$AMV_hitquery=mysql_query("SELECT * FROM $AMV_counterhits order by id DESC");
$AMV_visits=mysql_fetch_array($AMV_hitquery);
if($AMV_invisible == '1'){
echo "$AMV_showallvisitorstext $AMV_visits[id]$AMV_showit";
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//+-----------------------------------------------------------------------------------------------------+//
//| show all "today user" if set and add new record if current counts are higher than the record values |//
//+-----------------------------------------------------------------------------------------------------+//
///////////////////////////////////////////////////////////////////////////////////////////////////////////
if($AMV_showtodayvisitors == '1'){
$AMV_todayuser =mysql_query("SELECT count(*) as total FROM $AMV_counterhits where date='$AMV_dateonly'");
$AMV_todayuserarray = mysql_fetch_array($AMV_todayuser);
$AMV_todayvalue = $AMV_todayuserarray[total];
if ($AMV_pmaxperday < "$AMV_todayvalue"){
$AMV_newmaxperdayvalue = $AMV_todayuserarray[total];
$AMV_updatemaxdata=mysql_query("UPDATE $AMV_countermaxdata SET maxperday = '$AMV_newmaxperdayvalue'");
}
if($AMV_invisible == '1'){
echo "$AMV_showtodayvisitorstext $AMV_todayuserarray[total]$AMV_showit";
}
}
/////////////////////////////////////////
//+-----------------------------------+//
//| show all "yesterday users" if set |//
//+-----------------------------------+//
/////////////////////////////////////////
if($AMV_showyesterdayvisitors == '1'){
$AMV_stamp = mktime(0, 0, 0, date("m"), date("d")-1, date("y"));
$AMV_yesterday = date("d.m.y", $AMV_stamp);
$AMV_todayuseryesterday =mysql_query("SELECT count(*) as total FROM $AMV_counterhits where date='$AMV_yesterday'");
$AMV_todayuseryesterdayarray = mysql_fetch_array($AMV_todayuseryesterday);
if($AMV_invisible == '1'){
echo "$AMV_showyesterdayvisitorstext $AMV_todayuseryesterdayarray[total]$AMV_showit";
}
}
//////////////////////////////////////////////
//+----------------------------------------+//
//| manage user online and print it if set |//
//+----------------------------------------+//
//////////////////////////////////////////////
if($AMV_showcurrentvisitors == '1'){
$AMV_deleteuser= mysql_query( "delete from $AMV_countercurrentonline where DATE < $AMV_countflag - $AMV_dropuser");
$AMV_deleteip= mysql_query( "delete from $AMV_countercurrentonline where IP = '$AMV_ipadr'");
$AMV_deleteuser= mysql_query( "delete from $AMV_countercurrentonline where IP = '' "); // Wenn User 'ohne' IP Browsen z.B. WebWasher etc..
$AMV_insertuser =mysql_query( "INSERT INTO $AMV_countercurrentonline VALUES ('','$AMV_ipadr','$AMV_countflag')");
$AMV_resultuser = mysql_query( "SELECT Count(*) as total FROM $AMV_countercurrentonline");
$AMV_numberonline = mysql_fetch_array($AMV_resultuser);
$AMV_currentvalue = $AMV_numberonline[total];
if ($AMV_pmaxcurrent < "$AMV_currentvalue"){
$AMV_newmaxcurrentvalue = $AMV_numberonline[total];
$AMV_updatemaxdata=mysql_query("UPDATE $AMV_countermaxdata SET maxcurrent = '$AMV_newmaxcurrentvalue'");
}
if($AMV_invisible == '1'){
echo "$AMV_showcurrentvisitorstext $AMV_numberonline[total]$AMV_showit";
}
}
////////////////////////////////////
//+------------------------------+//
//| print counter records if set |//
//+------------------------------+//
////////////////////////////////////
if($AMV_showrecordvisitors == '1'){
if($AMV_invisible == '1'){
echo "<br><br>$AMV_showrecordvisitorstext $AMV_pmaxperday$AMV_showit";
}
}
if($AMV_showcurrentrecordvisitors == '1'){
if($AMV_invisible == '1'){
echo "$AMV_showcurrentrecordvisitorstext $AMV_pmaxcurrent$AMV_showit";
}
}
//////////////////////////////////////////////////////////////////
//+------------------------------------------------------------+//
//| ...and the copyright, no justification to edit or remove ! |//
//+------------------------------------------------------------+//
//////////////////////////////////////////////////////////////////
}
if($AMV_invisible == '1'){
?>
<br>
<div align="center"><font size="1" face="Georgia, Times New Roman, Times, serif"><a href="http://php-resource.net" target="_blank">©
AllMyVisitors</a></font></div>
<?
}
?>