Hi,
ich habe mir den encountV1.1 installiert.
Nach dem Sprung auf 10.000 Besucher zeigt er allerdings nun falsch an. Die Anzeige für 10.012 sieht dann so aus: 01012
Habe mir das Script (s. Anhang) angeschaut, komme aber nicht ganz klar.
Vieleicht hat von Euch jemand eine Idee.
Gruß und schon mal Danke!
Didl
<?php
########################################################################
# PHP-Nuke Block: ecount v1.1 #
# #
# Counterscript mit Ip-Sperre by Pa<-Man (www.TheBitboys.de) Support: #
# Mail@TheBitboys.de oder im Forum @TheBitboys.de #
# Total_Hits Copyright (c) 2001 by C. Verhoef (cverhoef@gmx.net) #
# Modified for PhpNuke 5.5 Rene Henschke (admin@windowshelpdesk.de) #
# #
########################################################################
# This program is free software. You can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License. #
########################################################################
if (eregi("block-ecount.php", $PHP_SELF)) {
Header("Location: index.php");
die();
}
global $nukeurl, $prefix, $startdate, $dbi;
$result = sql_query("SELECT count FROM ".$prefix."_counter WHERE type='total' AND var='hits'", $dbi);
$result = sql_fetch_row($result, $dbi);
if (!($ignore==1)){ //Wird die Variable ignore=1 übermittelt, so wird das Script übersprungen
function Schreibeip($ip){ //Schreibt IP
$datei=fopen("blocks/counter/ip.log", "a+");
fwrite($datei, "$ip\n");
fclose;
}
function AddiereUndSchreibe(){ //Liest Zahl, +1, schreibt Zahl
$datei=fopen("blocks/counter/counter.log","r+");
fseek($datei, 1);
$count=(int)fgets($datei,5);
$count++;
rewind($datei);
//Entsprechend den Counterstand mit Nullen auffüllen.
$null=3;
if ($count>9){if ($count<100){$null=2;}}
if ($count>99){if ($count<1000){$null=1;}}
if ($count>999){if ($count<10000){$null=0;}}
if ($count>9999){if ($count<100000){$null=-1;}}
while ($i<=$null){ //Schleife, die Nullen vor die Zahl macht
$i++;
fwrite($datei, "0");
}
fwrite($datei, $count); //Schreibt die Zahl in die File
fclose;
}
//Diese Funktion löscht die IP-Liste, wenn sich mehr als 100 Einträge in der Logfile befinden
function ListeLoeschen(){
$File = file("blocks/counter/ip.log");
if (sizeof($File)>=100){
$datei=fopen("blocks/counter/ip.log", "w+");
//+w ..> Öffnet die Datei zum Lesen und Schreiben und löscht den Inhalt der Datei,...
//...bzw. erstellt sie, wenn sie noch nicht existiert.
fclose;
}
}
//--HAUPTPROGRAMM--
$ip = getenv("REMOTE_ADDR"); //Holt die Ip des Users
$ipAusFile = file("blocks/counter/ip.log");
//Schleife zum Vergleichen der IP's (solange widerholen, bis das Ende von der IP-Liste...
//...[sizeof(Filename)=Zeilen der Datei] erreicht ist
for($i=0; $i<sizeof($ipAusFile); $i++) {
$Ip1=rtrim($ipAusFile[$i]); //rtrim entfernt nicht sichtbare Zeichen am Ende der Zeichenkette -> Sonst können die...
$Ip2=rtrim($ip); //...IP's nicht verglichen werden
if ($Ip1==$Ip2){$gleich=1;} //Wenn die IP gleich ist ..> $gleich=1
}
if ($gleich!=1){
ListeLoeschen();
AddiereUndSchreibe();
Schreibeip($ip);
}
} //Das Ende der Klammern für das überspringen des Scriptes (ignore=1)
$datei=fopen("blocks/counter/counter.log", "r");
$count = fgets($datei,6);
fclose;
$content="<center><small>"._WERECEIVED."</small><br><b>$count</b> Besucher und<br> <a href=\"modules.php?name=Statistics\">$result[0] </a></b><small>"._PAGESVIEWS."<br> $startdate</small></center>";
?>