Wenn es mal jemand schnell braucht, hier ein kleiner simpler Benutzerzähler im Anhang.
[Blockierte Grafik: http://wolf.wolfgang-m.de/beispiele/counter.png]
An die stelle wo der Zähler hin soll:
Eventuell Pfad anpassen, der Server muss PHP unterstützen und die Datei die Endung .php.
//Der Code:
counter.php
PHP
- <?php
- /*
- * Counter:
- *
- * Code by Wolf Wortmann / wolf.wolfgang-m.de
- * License: nobody cares..
- *
- */
- if ($Configuration){if (file_exists("counter_conf.php")){include 'counter_conf.php';}}
- //RESET:
- if (empty($COHeight)){$COHeight="43px";}
- if (empty($COWidth)){$COWidth="105px";}
- if (empty($BGColor)){$BGColor="#666666";}
- if (empty($NUMColor)){$NUMColor="#E6E6E6";}
- if (empty($NUMSize)){$NUMSize="19px";}
- if (empty($IPColor)){$IPColor="#A4A4A4";}
- if (empty($COTime)){$COTime=1*24;}
- if (empty($IPShow)){$IPShow=true;}
- if (empty($IPSize)){$IPSize="9px";}
- /* IP des benutzers */
- if (! isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- $LIP = $_SERVER['REMOTE_ADDR'];
- }
- else {
- $LIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
- }
- //Zahl des Zählers
- if (file_exists("counter.txt")) {
- $file = @fopen("counter.txt", "r");
- if ($file) {
- $zahl = fgets($file, 10);
- }
- fclose($file);
- }
- //Wenn die Datei Leer ist
- if (empty($zahl)){$zahl = 0;}
- //Wenn der Benutzer inerhalb der Cookie Zeit schon besucht hat
- if ($_COOKIE["ip"] == $LIP) {
- //Cookie neu setzen
- if(!$COTime){$COTime = 0.5;}
- setcookie("ip", $LIP, time()+3600*$COTime);
- }
- //Wenn der Benutzer neu ist
- else{
- //Cookie Setzen
- if(!$COTime){$COTime = 0.5;}
- setcookie("ip", $LIP, time()+3600*$COTime);
- $zahl = $zahl+1;
- if (file_exists("counter.txt")) {
- $file = @fopen("counter.txt","w");
- if ($file) {
- fputs($file, $zahl);
- fclose($file);
- }
- }
- }
- //output
- echo "
- <div class='counter'>
- <span class='num' >$zahl</span>
- ";
- if ($IPShow) {echo "<span class='ip' >Ihre Ip: $LIP</span>";}
- echo "
- </div>
- <style type='text/css'>
- .counter span{
- display:block;
- }
- .counter{
- background-color: $BGColor;
- text-align: center;
- width: $COWidth;
- height: $COHeight;
- font-family: 'Avenir Light',Arial,sans-serif;
- border-radius: 4px;
- }
- .num{
- padding: 2px;
- color: $NUMColor;
- font-weight: bold;
- font-size: $NUMSize;
- }
- .ip{
- color: $IPColor;
- font-size: $IPSize;
- padding-left: 2px;
- padding-right: 2px;
- }
- </style>
- ";
- ?>
counter_conf.php
PHP
- <?php
- /*
- *Counter Configuration File
- *
- *Code by Wolf Wortmann / wolf.wolfgang-m.de
- * License: nobody cares..
- *
- *Immer so notiert:
- * VARIABLE = WERT; // STANDART-WERT // Optionen
- *
- * WERT darf auch leergelassen werden
- * und wird durch den Standart ersetzt.
- */
- //GRUNDSATZ
- //Höhe: (mit Art)
- $COHeight = "43px"; // "43px"
- //Breite: (mt Art)
- $COWidth = "105px"; // "105px"
- //Hintergrund Farbe
- $BGColor = "#666666"; // "#666666"
- //INHALT
- //Farbe der Nummer:
- $NUMColor = "#E6E6E6"; // "#E6E6E6"
- //Schrift Größe der Nummer: (mit Art)
- $NUMSize = "19px"; // "19px"
- //Farbe der IP:
- $IPColor = "#A4A4A4"; // "#A4A4A4"
- //Schrift Größe der IP: (mit Art)
- $IPSize = "9px"; // "9px"
- //IP zeigen
- $IPShow = true; // true // true/false
- //SONNSTIGES
- //Verfall des Cookies:(in Stunden)
- /*
- * Nach dieser zeit, wird ein Aufruf der Seite als neuer Aufruf gezählt.
- *
- * z.B:
- * 0.5 für eine halbe Stunde
- * 3 für 3 Stunden
- * 3*24 für 3 Tage
- * weil 3 mal 24 stunden = 3 Tage
- */
- $COTime = 1*24; // 1*24
- ?>
Hoffe ihr könnt was damit anfangen