$Storage_Dir = "STORE_COUNTER";
$HANDLE = opendir($Storage_Dir);
$webpages = array();
$hits = array();
$ctime = array();
while (false !== ($file = readdir($HANDLE))) {
if ($file != "." && $file != "..") {
$webpage = preg_replace("/_/", "/", $file); ## change _ to /
$webpage = preg_replace("/^\//", "http://", $webpage); ## change _ to http://
$webpage = preg_replace("/\.txt$/", "", $webpage); ## remove .txt
array_push($webpages, $webpage);
$HITFILE = "STORE_COUNTER/$file";
$fp = fopen($HITFILE,"r");
if(filesize($HITFILE)) array_push( $hits, fread($fp,filesize($HITFILE)));
else array_push( $hits, 0);
fclose($fp);
array_push($ctime,filectime($HITFILE));
}
}
closedir($HANDLE);
array_multisort($hits,SORT_DESC,$webpages,$ctime);
#==========================================================================================
$COMMAND = 'cat nlog | awk \'{print $1" "$2}\'|sed 1,2d>nlog.plot';
exec("$COMMAND");
#$NPLOT = fopen('nlog.plot','r+');
#$lines = file('nlog.plot');
#fclose($NPLOT);
# make plotmtv data files
//$DATA = "$ DATA = CURVE2D\n";
//$TOPLABEL = "% toplabel = \"Visiting time intervals\"\n";
//$XLABEL = "% xlabel = \"UnixTime\"\n";
//$YLABEL = "% ylabel = \"From last visit (sec)\"\n";
#$ZLABEL = "% zlabel = \"UnixTime\"\n";
//$OPTIONS_1 = "% equalscale = False\n";
//$OPTIONS_2 = "% ylog = True\n";
//$OPTIONS_3 = "% fitpage = True\n";
//$OPTIONS_4 = "% grid = False\n";
//$LINETYPE = "% linetype = 0 marktype = 1\n";
//array_unshift($lines, "$DATA", "$TOPLABEL", "$XLABEL", "$YLABEL", "$OPTIONS_1", "$OPTIONS_2", "$OPTIONS_3", "$OPTIONS_4", "$LINETYPE");
//array_push($lines, "\n\$END");
//$count = count($lines);
//$NPLOT = fopen('nlog.plot','w');
//for($i=0;$i<$count;$i++) {
// fwrite($NPLOT, $lines[$i]);
//}
//fclose($NPLOT);
##===================================== HTML OUTPUT ==============================================
print "
..::: Coolest Counter Statistics :::..
| |
| Web pages width Coolest Counter | The hit values | Last Access | ";
$last_hour_hits = 0;
for($i=0;$i<$limit;$i++) {
if ($ctime[$i]<(time()-1209600)) {
$link_color = "gray";
$webpages[$i] = $webpages[$i];
if(isset($no_dead_links)) continue;
}
elseif ($ctime[$i]>(time()-3600)) {
$link_color = "red";
$last_hour_hits += $hits[$i];
$webpages[$i] = "$webpages[$i]";
}
else {
$link_color = 'black';
$webpages[$i] = "$webpages[$i]";
}
print " | $webpages[$i] |
$hits[$i] |
".date ("F d. Y H:i:s", $ctime[$i])." | ";
}
$sum = array_sum($hits);
print "| Sum total: | $sum | |
| Red pages sum total: | $last_hour_hits | |
| |
";
#virtual("/cgi-bin/plotting.cgi?URL=/var/www/kornel.zool.klte.hu/pub/counter");
#print "
#
print "
";
?>