Location: PHPKode > projects > A Simple Yet Effective PHP Web Counter > a-simple-yet-effective-php-web-counter/index.php
<?php include("header.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
   <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
   <link rel="stylesheet" type="text/css" href="sye.css" title="sye" media="screen,projection" />
   <title><?php echo $titletxt; ?></title>
</head>

<body>

<div id="container" >
   <div id="header">
      <h1><?php echo $headertxt; ?></h1>
      <h2>&nbsp;</h2>
      <h3>
      <?php echo $number; ?>
      <?php echo $todaytxt; ?> <font color=<?php echo $highlightedcolor; ?>><b><?php echo $today; ?></b></font> |
      <?php echo $yesterdaytxt; ?> <font color=<?php echo $highlightedcolor; ?>><b><?php echo $yesterday; ?></b></font> |
      <?php echo $averagetxt; ?>: <font color=<?php echo $highlightedcolor; ?>><b><?php echo ceil($total/$days); ?></b></font><br>
      <?php echo $hitstxt; ?>: <font color=<?php echo $whitecolor; ?>><?php include("$file2"); ?></font> |
      <?php echo $totaltxt; ?> <font color=<?php echo $highlightedcolor; ?>><b><?php echo $total; ?></b></font>
      <p></p>
      <?php echo $keywordstxt; ?>: <font color=<?php echo $highlightedcolor; ?>><?php include("$file5"); ?></font>
      </h3>
   </div>

   <div id="navigation">
      <ul>
<?php

if ($day == "Monday") {
echo("<li class=\"selected\"><a href=\"index.php?day=Monday\">$mondaytxt</a></li>
<li><a href=\"index.php?day=Tuesday\">$tuesdaytxt</a></li>
<li><a href=\"index.php?day=Wednesday\">$wednesdaytxt</a></li>
<li><a href=\"index.php?day=Thursday\">$thursdaytxt</a></li>
<li><a href=\"index.php?day=Friday\">$fridaytxt</a></li>
<li><a href=\"index.php?day=Saturday\">$saturdaytxt</a></li>
<li><a href=\"index.php?day=Sunday\">$sundaytxt</a></li>");
} elseif ($dayvariable == "Tuesday") {
echo("<li><a href=\"index.php?day=Monday\">$mondaytxt</a></li>
<li class=\"selected\"><a href=\"index.php?day=Tuesday\">$tuesdaytxt</a></li>
<li><a href=\"index.php?day=Wednesday\">$wednesdaytxt</a></li>
<li><a href=\"index.php?day=Thursday\">$thursdaytxt</a></li>
<li><a href=\"index.php?day=Friday\">$fridaytxt</a></li>
<li><a href=\"index.php?day=Saturday\">$saturdaytxt</a></li>
<li><a href=\"index.php?day=Sunday\">$sundaytxt</a></li>");
} elseif ($dayvariable == "Wednesday") {
echo("<li><a href=\"index.php?day=Monday\">$mondaytxt</a></li>
<li><a href=\"index.php?day=Tuesday\">$tuesdaytxt</a></li>
<li class=\"selected\"><a href=\"index.php?day=Wednesday\">$wednesdaytxt</a></li>
<li><a href=\"index.php?day=Thursday\">$thursdaytxt</a></li>
<li><a href=\"index.php?day=Friday\">$fridaytxt</a></li>
<li><a href=\"index.php?day=Saturday\">$saturdaytxt</a></li>
<li><a href=\"index.php?day=Sunday\">$sundaytxt</a></li>");
} elseif ($dayvariable == "Thursday") {
echo("<li><a href=\"index.php?day=Monday\">$mondaytxt</a></li>
<li><a href=\"index.php?day=Tuesday\">$tuesdaytxt</a></li>
<li><a href=\"index.php?day=Wednesday\">$wednesdaytxt</a></li>
<li class=\"selected\"><a href=\"index.php?day=Thursday\">$thursdaytxt</a></li>
<li><a href=\"index.php?day=Friday\">$fridaytxt</a></li>
<li><a href=\"index.php?day=Saturday\">$saturdaytxt</a></li>
<li><a href=\"index.php?day=Sunday\">$sundaytxt</a></li>");
} elseif ($dayvariable == "Friday") {
echo("<li><a href=\"index.php?day=Monday\">$mondaytxt</a></li>
<li><a href=\"index.php?day=Tuesday\">$tuesdaytxt</a></li>
<li><a href=\"index.php?day=Wednesday\">$wednesdaytxt</a></li>
<li><a href=\"index.php?day=Thursday\">$thursdaytxt</a></li>
<li class=\"selected\"><a href=\"index.php?day=Friday\">$fridaytxt</a></li>
<li><a href=\"index.php?day=Saturday\">$saturdaytxt</a></li>
<li><a href=\"index.php?day=Sunday\">$sundaytxt</a></li>");
} elseif ($dayvariable == "Saturday") {
echo("<li><a href=\"index.php?day=Monday\">$mondaytxt</a></li>
<li><a href=\"index.php?day=Tuesday\">$tuesdaytxt</a></li>
<li><a href=\"index.php?day=Wednesday\">$wednesdaytxt</a></li>
<li><a href=\"index.php?day=Thursday\">$thursdaytxt</a></li>
<li><a href=\"index.php?day=Friday\">$fridaytxt</a></li>
<li class=\"selected\"><a href=\"index.php?day=Saturday\">$saturdaytxt</a></li>
<li><a href=\"index.php?day=Sunday\">$sundaytxt</a></li>");
} elseif ($dayvariable == "Sunday") {
echo("<li><a href=\"index.php?day=Monday\">$mondaytxt</a></li>
<li><a href=\"index.php?day=Tuesday\">$tuesdaytxt</a></li>
<li><a href=\"index.php?day=Wednesday\">$wednesdaytxt</a></li>
<li><a href=\"index.php?day=Thursday\">$thursdaytxt</a></li>
<li><a href=\"index.php?day=Friday\">$fridaytxt</a></li>
<li><a href=\"index.php?day=Saturday\">$saturdaytxt</a></li>
<li class=\"selected\"><a href=\"index.php?day=Sunday\">$sundaytxt</a></li>");
} else {
echo("<li><a href=\"index.php?day=Monday\">$mondaytxt</a></li>
<li><a href=\"index.php?day=Tuesday\">$tuesdaytxt</a></li>
<li><a href=\"index.php?day=Wednesday\">$wednesdaytxt</a></li>
<li><a href=\"index.php?day=Thursday\">$thursdaytxt</a></li>
<li><a href=\"index.php?day=Friday\">$fridaytxt</a></li>
<li><a href=\"index.php?day=Saturday\">$saturdaytxt</a></li>
<li><a href=\"index.php?day=Sunday\">$sundaytxt</a></li>");
}

?>
     <li>
<?php
if ($day == "Cleanup") {
echo("<li class=\"selected\"><a href=\"index.php?day=Cleanup\">(clean up)</a></li>");
} else {
echo("<li><a href=\"index.php?day=Cleanup\">(clean up)</a></li>");
}
?>

      </ul>
   </div>

   <div id="content">
      <h3><?php echo $wherefromtxt; ?></h3>

<?php

// And now read the correct referrer.db file into string

if ($day == "Monday") {
$str = file_get_contents($file1w);
} elseif ($dayvariable == "Tuesday") {
$str = file_get_contents($file2w);
} elseif ($dayvariable == "Wednesday") {
$str = file_get_contents($file3w);
} elseif ($dayvariable == "Thursday") {
$str = file_get_contents($file4w);
} elseif ($dayvariable == "Friday") {
$str = file_get_contents($file5w);
} elseif ($dayvariable == "Saturday") {
$str = file_get_contents($file6w);
} elseif ($dayvariable == "Sunday") {
$str = file_get_contents($file7w);
} elseif ($dayvariable == "Cleanup") {
include("cleanup.php");
echo "<p></p>";
} else {
$str = file_get_contents($file);
}

// declare new function to truncate that string to 5000 characters to make it easier to view on screen, database-file is still intact of course!

function truncate ($str, $length=10, $trailing='&nbsp;&nbsp;...')
{
/*
** $str -String to truncate
** $length - length to truncate
** $trailing - the trailing character, default: "&nbsp;&nbsp;..."
*/
      // take off chars for the trailing
      $length-=mb_strlen($trailing);
      if (mb_strlen($str)> $length)
      {
         // string exceeded length, truncate and add trailing dots
        return mb_substr($str,0,$length).$trailing; // we want to truncate the last part of the file
//         return substr($str,$length);

      }
      else
      {
         // string was already short enough, return the string
         $res = $str;
      }

      return $res;

}

$printfile = truncate($str, 5000);

echo $printfile; // print the file, at least, part of it. Adjust the number 5000 above to suit your own need.

?>


   </div>

   <div id="footer">
      <p><a href="http://www.martijndemeulder.com/webcounter" target="_blank"><font style="font-size:10px;">Simple yet effective web counter, by Martijn de Meulder.</a> | Original template design by <a href="http://andreasviklund.com/" target="_blank">Andreas Viklund</a></font></p>
   </div>

   </div>
</body>
</html>
Return current item: A Simple Yet Effective PHP Web Counter