<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/REC-html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>PHP-test 8</TITLE>
<META NAME="Author" CONTENT="Bo Johansson">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<link REL="SHORTCUT ICON" href="../bj16html.ico">
<STYLE TYPE="text/css">
<!--
.tdimg TD IMG {display: block;}
//-->
</STYLE>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
var jsNavBase = "../"
//-->
</SCRIPT>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript" SRC="../navbt/button_updwn.js">
<!--
//-->
</SCRIPT>
<?php
$navBase = "../";
$altLang = ""; // no Swedish version
$actPage = 99; // this page not in navbar
require("../navbt/nav_eng.php");
?>
</HEAD>
<BODY>
<?php require("../navbt/nav_horz.php"); ?>
<H1 ALIGN=CENTER>PHP-test 8</H1>
<H2 ALIGN=CENTER>Access counter</H2>
<HR>
<DIV ALIGN=CENTER>You are visitor number
<?php
//********************** access counter *******************
//
// This is the access counter code.
// The file "8_counter.inc" contains the count and the IP of
// the last visitor. The count is increased if the IP of the
// current visitor is different, and not equal to "$localip"
// or "$serverip".
//
// Bo Johansson 2002-01-02
// Modified by Bo Johansson 2003-08-29
//
//***************************************************************
$cfile = "8_counter.inc";
$localip = "127.0.0.1";
$serverip = $_SERVER['SERVER_ADDR'];
$remoteip = $_SERVER['REMOTE_ADDR'];
if (file_exists ($cfile))
{
$fp = fopen ($cfile,"r+");
$data = fgets ($fp,25);
$ip = chop (substr($data,0,15));
$count = substr($data,15);
if ( ( $remoteip == $localip ) ||
( $remoteip == $serverip ) )
$np = $ip;
else
$np = $remoteip;
if ($np != $ip)
$count += 1;
rewind ($fp);
fputs ($fp,substr($np." ",0,15).$count);
fclose ($fp);
print($count);
}
else
{
$fp = fopen($cfile,"w");
$np = $remoteip;
$count = "1";
fputs ($fp,substr($np." ",0,15).$count);
fclose ($fp);
print($count);
}
?>
since 2002-01-02 (January 2, 2002).</DIV>
<HR>
<P><A HREF="8_counter.php?code"><B>View code:</B></A> Click this
link to see the code for this page.
<HR>
<?php
if( $_SERVER['QUERY_STRING'] == "code")
{
print('<TABLE ALIGN=CENTER BGCOLOR="#FFFFCC" WIDTH="95%">');
print('<TR><TD>');
highlight_file("8_counter.php");
print('</TD></TR></TABLE>');
print('<HR>');
}
?>
PHP test number 8 used to be a script to let you
create a text-only NavBar for the
<A HREF="http://d.webring.com/hub?ring=lmb">Lois McMaster
Bujold WebRing</A>.
<P>The old script <A HREF="8_webring.php">8_webring.php</A> is
still here if you want to look at it, but Webring now provides
its own text-only NavBar, so my script is no longer useful.
<HR>
<FONT SIZE="-2">Page created 2002-01-02, last changed
<?php
print(date("Y-m-d H:i", getlastmod() ));
?>
</FONT>
<P>©
<?php
print(date("Y", getlastmod() ));
?>
Bo Johansson
</BODY>
</HTML>
|