Version: 1.0
Type: Full Script
Category: Other
License: Other
Description: This is a simple counter, which shows you the number of visitors. An IP-function is included!
PKcounter.php<? /* ////////////////////////////////////////////////////// ////////// P O W E R C O U N T E R 1 . 0 ////////// ////////// http://www.ks1.ch/phpscripts ////////// ///////////////// Andreas B. ///////////////// ////////////////////////////////////////////////////// Installation: 1. Set the variables 2. Upload the counter.php 3. Run the counter.php 4. You can include the number of hits into your Website with the include()-function! Exemple: <? include("counter.php"); ?> 5. FINISH :-)) Have fun! */ $configfile = "powercounter.inc"; // Name of the file, which the data is stored in $localip = "127.0.0.1"; // Local IP Adresse $serverip = "127.0.0.1"; // IP Adresse of your Server // -------------------- C O D E -------------------------------- // function text($count) { echo"Visitors: $count"; // Text } if (file_exists ($configfile)) { $fp = fopen ($configfile,"r+"); $daten = fgets ($fp,25); $ip = chop (substr($daten,0,15)); $count = substr($daten,15); if ($REMOTE_ADDR == $localip or $REMOTE_ADDR == $serverip) $np = $ip; else $np = $REMOTE_ADDR; if ($np != $ip) $count += 1; rewind ($fp); fputs ($fp,substr($np." ",0,15).$count); fclose ($fp); text($count); } else { $fp = fopen($configfile,"w"); $np = $REMOTE_ADDR; $count = "1"; fputs ($fp,substr($np." ",0,15).$count); fclose ($fp); chmod("$configfile", 0777); text($count); } // ---------------------- E N D -------------------------------- //