Location: PHPKode > projects > A Simple Yet Effective PHP Web Counter > a-simple-yet-effective-php-web-counter/header.php
<?php

// START LOGIC for both index.php and the iFramed cleanup.php

include("english.php"); /* translations and color codes to be shared between counter.php and index.php. Default language is English, choose your language of choice, or make a new translation yourself. Please sent the translated file to hide@address.com so i can add it to the distribution on the website. Please also change line 37 in counter.php to thelanguage you like best. */

/* IP-checking disabled by default, please enable for your security
////////////// Restrict acces to your IP-address only, using hard exit without any information //////////////

$ipaccess=@$REMOTE_ADDR;

if ($ipaccess == "127.0.0.1") { // replace with your own IP-addressses
echo $goodpeople;
} elseif ($ipaccess == "192.168.1.10") {
echo $goodpeople;
} elseif ($ipaccess == "192.168.1.10")  {
echo $goodpeople;
} elseif ($ipaccess == "192.168.1.10")  {
echo $goodpeople;
} elseif ($ipaccess == "192.168.1.10")  {
echo $goodpeople;
} elseif ($ipaccess == "192.168.1.10")  {
} else {
    header("Location: http://www.yoursite.com/"); // replace with your own site
}

////////////// End access restriction //////////////
*/

// Set facts and figures

$file_count = fopen('uniques.db', 'rb');
   $data = '';
   while (!feof($file_count)) $data .= fread($file_count, 4096);
   fclose($file_count);
   list($today, $yesterday, $total, $date, $days) = split("%", $data);

// Which day is it today?

$jd=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y"));
$todayis=(jddayofweek($jd,1));

$timenow=(date("h:i:s A")); /* not used right now */
$date_time = $todayis . " $timenow"; /* not used right now */

// Now we have the day we can set the right referrer.db to automatically include
// Again, never ever change the name of the day below, because it comes from the jddayofweek() function above

if ($todayis == "Monday") {
$file = 'mondaysreferrers.db';
} elseif ($todayis == "Tuesday") {
$file = 'tuesdaysreferrers.db';
} elseif ($todayis == "Wednesday") {
$file = 'wednesdaysreferrers.db';
} elseif ($todayis == "Thursday") {
$file = 'thursdaysreferrers.db';
} elseif ($todayis == "Friday") {
$file = 'fridaysreferrers.db';
} elseif ($todayis == "Saturday") {
$file = 'saturdaysreferrers.db';
} elseif ($todayis == "Sunday") {
$file = 'sundaysreferrers.db';
}
$file2 = 'hits.db';
$file3 = 'ip.db';
$file4 = 'uniques.db';
$file5 = 'keywords.db';

// GETting the day, if available, from the posted URL.
// This function is always invoked after the initial page has loaded and the user requested another day to view.
// We use it to include the requested referrer.db, and to design the bar with hyperlinks.

$dayvariable = $_GET['day'];

// Names of db-files
$file1w = "mondaysreferrers.db";
$file2w = "tuesdaysreferrers.db";
$file3w = "wednesdaysreferrers.db";
$file4w = "thursdaysreferrers.db";
$file5w = "fridaysreferrers.db";
$file6w = "saturdaysreferrers.db";
$file7w = "sundaysreferrers.db";

// calculate file sizes to have them printed on the buttons

$file_size1 = round ( (filesize("$file1w")) / 1024) . "kb";
$file_size2 = round ( (filesize("$file2w")) / 1024) . "kb";
$file_size3 = round ( (filesize("$file3w")) / 1024) . "kb";
$file_size4 = round ( (filesize("$file4w")) / 1024) . "kb";
$file_size5 = round ( (filesize("$file5w")) / 1024) . "kb";
$file_size6 = round ( (filesize("$file6w")) / 1024) . "kb";
$file_size7 = round ( (filesize("$file7w")) / 1024) . "kb";
$file_size8 = round ( (filesize("$file5")) / 1024) . "kb";
$file_size9 = round ( (filesize("$file2")) / 1024) . "kb";
$file_size10 = round ( (filesize("$file4")) / 1024) . "kb";
$file_size111 = count(file($file3)); // line 1 count lines in ip.db
$file_size11 = $file_size111 -1; // line2 small hack due to the fact that ip.db wrting always starts at line 2

// END OF LOGIC

// End Lay Out

// Just some more logic - to be placed here due to references to translations

$mondaysize  = $mondaytxt  . " $file_size1";
$tuesdaysize  = $tuesdaytxt  . " $file_size2";
$wednesdaysize  = $wednesdaytxt  . " $file_size3";
$thursdaysize  = $thursdaytxt  . " $file_size4";
$fridaysize  = $fridaytxt  . " $file_size5";
$saturdaysize  = $saturdaytxt  . " $file_size6";
$sundaysize  = $sundaytxt  . " $file_size7";
$keywordssize  = $keywordstxt_cleanup  . " $file_size8";
$hitssize  = $hitstxt_cleanup; /* size calculation is not relevant here */
$countersize  = $countertxt; /* size calculation is not relevant here */
$ipsize = $iptxt  . " $file_size11 " . $iptxt2;

?>

Return current item: A Simple Yet Effective PHP Web Counter