mirror of
https://gitlab.com/harald.mueller/aktuelle.kurse.git
synced 2024-10-19 09:55:03 +02:00
261 lines
30 KiB
HTML
261 lines
30 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/transitional.dtd">
|
||
|
||
<html>
|
||
|
||
<head>
|
||
<title>Besucherstatistik integrieren</title>
|
||
<link rel="stylesheet" type="text/css" href="../../src/self.css">
|
||
<meta name="description" content="Script um die Anzahl der Besucher, wie viele Leute gerade auf der Seite sind und was das Maximum an gleichzeitigen Besuchern war.">
|
||
<meta name="keywords" content="SELFPHP, PHP, Statistiken">
|
||
<meta name="author" content="Damir Enseleit, mail@selfphp3.de">
|
||
<meta name="DC.Contributer" content="Matthias Hupp, m.hupp@selfphp3.de">
|
||
<meta name="DC.Publisher" content="Damir Enseleit, mail@selfphp3.de">
|
||
<meta name="DC.Date" content="2003-07-17T16:54:05+02:00">
|
||
<meta name="DC.Identifier" content="http://www.selfphp.info/tipps_tricks/statistiken/besucherzaehler_integrieren.php">
|
||
<meta name="DC.Language" content="de">
|
||
<meta name="DC.Rights" content="../../editorial/index.php">
|
||
<meta name="SELF.Firstdate" content="2001-08-02T02:08+01:00">
|
||
<meta name="SELF.Version" content="1">
|
||
<meta name="SELF.Pagetype" content="Ordner">
|
||
<meta name="SELF.Path" content="SELFPHP == ../../index.php">
|
||
</head>
|
||
|
||
<body bgcolor="#FFFFFF" text="#000000" link="#AA5522" vlink="#772200" alink="#000000">
|
||
<table width="100%" border="0" cellspacing="0" cellpadding="4">
|
||
<tr>
|
||
|
||
<td bgcolor="#FFEEDD" colspan="3" class="nav"><a name="top" class="an"><img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"></a>
|
||
<a href="../../index.html"><b>SELFPHP</b></a>/<a href="../../navigation/index.html">Navigationshilfen</a>
|
||
<img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von">
|
||
<a href="../index.html"><b>Tipps & Tricks</b></a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von">
|
||
<a href="index.html"><b>Statistiken</b></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td width="11%" bgcolor="#EEEEEE" class="doc"><img src="../../src/logo.gif" width="106" height="109" border="0" alt="SELFPHP"></td>
|
||
<td bgcolor="#EEEEEE" valign="bottom" class="doc"><h2>Besucherstatistik integrieren</h2></td>
|
||
|
||
<td bgcolor="#EEEEEE" align="right" valign="bottom" class="doc"> </td>
|
||
</tr>
|
||
<tr>
|
||
<td bgcolor="#EEEEEE" align="center" valign="top" class="doc"><img src="../../src/dokx.gif" width="30" height="20" border="0" alt="Informationsseite" /></td>
|
||
<td bgcolor="#FFFFFF" valign="top" nowrap colspan="2"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten" /> <a href="#autor"><b>Autor</b></a><br />
|
||
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"> <a href="#beispiel"><b>Beispiel</b></a><br />
|
||
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"> <a href="#beschreibung"><b>Beschreibung</b></a><br />
|
||
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"> <a href="#download"><b>Download</b></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="3" class="doc"><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a></td>
|
||
</tr>
|
||
</table>
|
||
<h2 class="Sh2"><a name="autor" class="an">Autor</a></h2>
|
||
<table width="100%" cellpadding="10">
|
||
<tr>
|
||
<td bgcolor="#E4EEFF" class="xmpcode"><b>Name:</b> Carsten Franke<br /><b>Email:</b> <a href="mailto:mail@dbCF.de">mail@dbCF.de</a><br /><b>Website:</b> <a href="http://www.dbCF.de/" target="_blank">http://www.dbCF.de/</a></td>
|
||
</tr>
|
||
</table>
|
||
<br /><br />
|
||
<table width="100%" class="doc">
|
||
<tr>
|
||
<td><a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben" /></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten" /></a></td>
|
||
</tr>
|
||
</table>
|
||
<h2 class="Sh2"><a name="beispiel" class="an">Beispiel</a></h2>
|
||
|
||
<img src="../../src/dokf.gif" width="15" height="10" border="0" /> <a href="http://www.selfphp.com/tipps_tricks/statistiken/besucherzaehler_integrieren_script.php" target="_blank"><b>Anzeigebeispiel:
|
||
So sieht's aus (Online)</b></a> <br />
|
||
<br />
|
||
<table width="100%" cellpadding="10">
|
||
<tr>
|
||
<td bgcolor="#E4EEFF" class="xmpcode"><code><font color="#000000">
|
||
<font color="#0000BB"><?php
|
||
<br /> </font><font color="#FF8000">// wie lange gilt wird eine ip nicht als neuer besucher gewertet (in minuten)
|
||
<br /> </font><font color="#0000BB">$t_counter</font><font color="#007700">=</font><font color="#0000BB">120</font><font color="#007700">;
|
||
<br /> </font><font color="#FF8000">// wie lange gilt besucher als online (in minuten)
|
||
<br /> </font><font color="#0000BB">$t_user_online</font><font color="#007700">=</font><font color="#0000BB">5</font><font color="#007700">;
|
||
<br /> </font><font color="#FF8000">// pfad zum besucherzaehler
|
||
<br /> </font><font color="#0000BB">$p_counter</font><font color="#007700">=</font><font color="#DD0000">'counter.log'</font><font color="#007700">;
|
||
<br /> </font><font color="#FF8000">// pfad zur datei, die maximale zahl gleichzeitiger nutzer speichert
|
||
<br /> </font><font color="#0000BB">$p_counter_max</font><font color="#007700">=</font><font color="#DD0000">'counter_max.log'</font><font color="#007700">;
|
||
<br /> </font><font color="#FF8000">// pfad zur datei, die die ips des besucherzaehlers speichert
|
||
<br /> </font><font color="#0000BB">$p_ips_counter</font><font color="#007700">=</font><font color="#DD0000">'ips_counter.log'</font><font color="#007700">;
|
||
<br /> </font><font color="#FF8000">// pfad zur datei, die die ips der aktuell auf der seite befindlichen user speichert
|
||
<br /> </font><font color="#0000BB">$p_ips_user_online</font><font color="#007700">=</font><font color="#DD0000">'ips_user_online.log'</font><font color="#007700">;
|
||
<br />
|
||
<br /> </font><font color="#FF8000">// nicht vorhandene dateien erstellen
|
||
<br /> // wenn dateien vorhanden sind und skript einwandfrei laeuft, dann diese zeilen auskommentieren (// davor)
|
||
<br /> </font><font color="#007700">if (!</font><font color="#0000BB">file_exists</font><font color="#007700">(</font><font color="#0000BB">$p_counter</font><font color="#007700">))
|
||
<br /> { </font><font color="#0000BB">$fh</font><font color="#007700">=</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#0000BB">$p_counter</font><font color="#007700">, </font><font color="#DD0000">'w'</font><font color="#007700">); </font><font color="#0000BB">fwrite</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">, </font><font color="#DD0000">"0"</font><font color="#007700">); </font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">); }
|
||
<br /> if (!</font><font color="#0000BB">file_exists</font><font color="#007700">(</font><font color="#0000BB">$p_counter_max</font><font color="#007700">))
|
||
<br /> { </font><font color="#0000BB">$fh</font><font color="#007700">=</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#0000BB">$p_counter_max</font><font color="#007700">, </font><font color="#DD0000">'w'</font><font color="#007700">); </font><font color="#0000BB">fwrite</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">, </font><font color="#0000BB">time</font><font color="#007700">().</font><font color="#DD0000">'#0'</font><font color="#007700">); </font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">); }
|
||
<br /> if (!</font><font color="#0000BB">file_exists</font><font color="#007700">(</font><font color="#0000BB">$p_ips_counter</font><font color="#007700">))
|
||
<br /> { </font><font color="#0000BB">$fh</font><font color="#007700">=</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#0000BB">$p_ips_counter</font><font color="#007700">, </font><font color="#DD0000">'w'</font><font color="#007700">); </font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">); }
|
||
<br /> if (!</font><font color="#0000BB">file_exists</font><font color="#007700">(</font><font color="#0000BB">$p_ips_user_online</font><font color="#007700">))
|
||
<br /> { </font><font color="#0000BB">$fh</font><font color="#007700">=</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#0000BB">$p_ips_user_online</font><font color="#007700">, </font><font color="#DD0000">'w'</font><font color="#007700">); </font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">); }
|
||
<br />
|
||
<br /> </font><font color="#FF8000">// daten einlesen
|
||
<br /> </font><font color="#0000BB">$temp</font><font color="#007700">=</font><font color="#0000BB">file</font><font color="#007700">(</font><font color="#0000BB">$p_counter</font><font color="#007700">); </font><font color="#0000BB">$counter</font><font color="#007700">=</font><font color="#0000BB">$temp</font><font color="#007700">[</font><font color="#0000BB">0</font><font color="#007700">];
|
||
<br /> </font><font color="#0000BB">$temp</font><font color="#007700">=</font><font color="#0000BB">file</font><font color="#007700">(</font><font color="#0000BB">$p_counter_max</font><font color="#007700">); </font><font color="#0000BB">$counter_max</font><font color="#007700">=</font><font color="#0000BB">explode</font><font color="#007700">(</font><font color="#DD0000">'#'</font><font color="#007700">, </font><font color="#0000BB">$temp</font><font color="#007700">[</font><font color="#0000BB">0</font><font color="#007700">]);
|
||
<br /> </font><font color="#0000BB">$ips_counter</font><font color="#007700">=</font><font color="#0000BB">file</font><font color="#007700">(</font><font color="#0000BB">$p_ips_counter</font><font color="#007700">);
|
||
<br /> </font><font color="#0000BB">$ips_user_online</font><font color="#007700">=</font><font color="#0000BB">file</font><font color="#007700">(</font><font color="#0000BB">$p_ips_user_online</font><font color="#007700">);
|
||
<br /> </font><font color="#0000BB">$ip</font><font color="#007700">=</font><font color="#0000BB">$_SERVER</font><font color="#007700">[</font><font color="#DD0000">'REMOTE_ADDR'</font><font color="#007700">];
|
||
<br />
|
||
<br /> </font><font color="#FF8000">// user online - noch gueltige ips raussuchen
|
||
<br /> </font><font color="#0000BB">$i</font><font color="#007700">=</font><font color="#0000BB">0</font><font color="#007700">; </font><font color="#0000BB">$j</font><font color="#007700">=</font><font color="#0000BB">0</font><font color="#007700">; </font><font color="#0000BB">$ip_exists</font><font color="#007700">=</font><font color="#0000BB">0</font><font color="#007700">;
|
||
<br /> while (</font><font color="#0000BB">$i </font><font color="#007700">< </font><font color="#0000BB">count</font><font color="#007700">(</font><font color="#0000BB">$ips_user_online</font><font color="#007700">))
|
||
<br /> {
|
||
<br /> </font><font color="#0000BB">$temp</font><font color="#007700">=</font><font color="#0000BB">explode</font><font color="#007700">(</font><font color="#DD0000">'#'</font><font color="#007700">, </font><font color="#0000BB">trim</font><font color="#007700">(</font><font color="#0000BB">$ips_user_online</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">]));
|
||
<br /> if (</font><font color="#0000BB">time</font><font color="#007700">() < </font><font color="#0000BB">$temp</font><font color="#007700">[</font><font color="#0000BB">0</font><font color="#007700">]+</font><font color="#0000BB">$t_user_online</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">)
|
||
<br /> {
|
||
<br /> </font><font color="#0000BB">$ips</font><font color="#007700">[</font><font color="#0000BB">$j</font><font color="#007700">]=</font><font color="#0000BB">$ips_user_online</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">]; </font><font color="#0000BB">$j</font><font color="#007700">++;
|
||
<br /> </font><font color="#FF8000">// wenn ip des aktuellen besuchers gefunden, dann vermerken
|
||
<br /> </font><font color="#007700">if (</font><font color="#0000BB">$temp</font><font color="#007700">[</font><font color="#0000BB">1</font><font color="#007700">]==</font><font color="#0000BB">$ip</font><font color="#007700">) { </font><font color="#0000BB">$ip_exists</font><font color="#007700">=</font><font color="#0000BB">1</font><font color="#007700">; }
|
||
<br /> }
|
||
<br /> </font><font color="#0000BB">$i</font><font color="#007700">++;
|
||
<br /> }
|
||
<br /> </font><font color="#FF8000">// wenn aktuelle ip nicht gefunden wurde ($ip_exists==0) oder alle entsorgt wurden, dann diese hinzufuegen
|
||
<br /> </font><font color="#007700">if (!isset(</font><font color="#0000BB">$ips</font><font color="#007700">) && </font><font color="#0000BB">$ip_exists</font><font color="#007700">==</font><font color="#0000BB">1 </font><font color="#007700">|| </font><font color="#0000BB">$ip_exists</font><font color="#007700">==</font><font color="#0000BB">0</font><font color="#007700">)
|
||
<br /> { </font><font color="#0000BB">$ips</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">]=</font><font color="#0000BB">time</font><font color="#007700">().</font><font color="#DD0000">'#'</font><font color="#007700">.</font><font color="#0000BB">$ip</font><font color="#007700">; }
|
||
<br /> </font><font color="#FF8000">// anzahl felder von $ips entspricht anzahl der user online
|
||
<br /> </font><font color="#0000BB">$user_online</font><font color="#007700">=</font><font color="#0000BB">count</font><font color="#007700">(</font><font color="#0000BB">$ips</font><font color="#007700">);
|
||
<br /> </font><font color="#FF8000">// wenn aktuelle zahl besucher groesser als letztes maximum, dann ueberschreiben und neu einlesen
|
||
<br /> </font><font color="#007700">if (</font><font color="#0000BB">$user_online</font><font color="#007700">></font><font color="#0000BB">$counter_max</font><font color="#007700">[</font><font color="#0000BB">1</font><font color="#007700">])
|
||
<br /> {
|
||
<br /> </font><font color="#0000BB">$fh</font><font color="#007700">=</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#0000BB">$p_counter_max</font><font color="#007700">, </font><font color="#DD0000">'w'</font><font color="#007700">);
|
||
<br /> </font><font color="#0000BB">fwrite</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">, </font><font color="#0000BB">time</font><font color="#007700">().</font><font color="#DD0000">'#'</font><font color="#007700">.</font><font color="#0000BB">$user_online</font><font color="#007700">);
|
||
<br /> </font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">);
|
||
<br /> </font><font color="#0000BB">$temp</font><font color="#007700">=</font><font color="#0000BB">file</font><font color="#007700">(</font><font color="#0000BB">$p_counter_max</font><font color="#007700">); </font><font color="#0000BB">$counter_max</font><font color="#007700">=</font><font color="#0000BB">explode</font><font color="#007700">(</font><font color="#DD0000">'#'</font><font color="#007700">, </font><font color="#0000BB">$temp</font><font color="#007700">[</font><font color="#0000BB">0</font><font color="#007700">]);
|
||
<br /> }
|
||
<br /> </font><font color="#FF8000">// die ips speichern
|
||
<br /> </font><font color="#0000BB">$fh</font><font color="#007700">=</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#0000BB">$p_ips_user_online</font><font color="#007700">, </font><font color="#DD0000">'w'</font><font color="#007700">);
|
||
<br /> </font><font color="#0000BB">fwrite</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">, </font><font color="#0000BB">join</font><font color="#007700">(</font><font color="#DD0000">"\n"</font><font color="#007700">, </font><font color="#0000BB">$ips</font><font color="#007700">));
|
||
<br /> </font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">);
|
||
<br />
|
||
<br /> </font><font color="#FF8000">// besucherzaehler - noch gueltige ips raussuchen
|
||
<br /> </font><font color="#0000BB">$i</font><font color="#007700">=</font><font color="#0000BB">0</font><font color="#007700">; </font><font color="#0000BB">$j</font><font color="#007700">=</font><font color="#0000BB">0</font><font color="#007700">; </font><font color="#0000BB">$ip_exists</font><font color="#007700">=</font><font color="#0000BB">0</font><font color="#007700">;
|
||
<br /> while (</font><font color="#0000BB">$i </font><font color="#007700">< </font><font color="#0000BB">count</font><font color="#007700">(</font><font color="#0000BB">$ips_counter</font><font color="#007700">))
|
||
<br /> {
|
||
<br /> </font><font color="#0000BB">$temp</font><font color="#007700">=</font><font color="#0000BB">explode</font><font color="#007700">(</font><font color="#DD0000">'#'</font><font color="#007700">, </font><font color="#0000BB">trim</font><font color="#007700">(</font><font color="#0000BB">$ips_counter</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">]));
|
||
<br /> if (</font><font color="#0000BB">time</font><font color="#007700">() < </font><font color="#0000BB">$temp</font><font color="#007700">[</font><font color="#0000BB">0</font><font color="#007700">]+</font><font color="#0000BB">$t_counter</font><font color="#007700">*</font><font color="#0000BB">60</font><font color="#007700">)
|
||
<br /> {
|
||
<br /> </font><font color="#0000BB">$ips</font><font color="#007700">[</font><font color="#0000BB">$j</font><font color="#007700">]=</font><font color="#0000BB">$ips_counter</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">]; </font><font color="#0000BB">$j</font><font color="#007700">++;
|
||
<br /> </font><font color="#FF8000">// wenn ip des aktuellen besuchers gefunden, dann vermerken
|
||
<br /> </font><font color="#007700">if (</font><font color="#0000BB">$temp</font><font color="#007700">[</font><font color="#0000BB">1</font><font color="#007700">]==</font><font color="#0000BB">$ip</font><font color="#007700">) { </font><font color="#0000BB">$ip_exists</font><font color="#007700">=</font><font color="#0000BB">1</font><font color="#007700">; }
|
||
<br /> }
|
||
<br /> </font><font color="#0000BB">$i</font><font color="#007700">++;
|
||
<br /> }
|
||
<br /> </font><font color="#FF8000">// wenn aktuelle ip nicht gefunden wurde ($ip_exists==0) oder alle entsorgt wurden, dann diese hinzufuegen
|
||
<br /> </font><font color="#007700">if (!isset(</font><font color="#0000BB">$ips</font><font color="#007700">) && </font><font color="#0000BB">$ip_exists</font><font color="#007700">==</font><font color="#0000BB">1 </font><font color="#007700">|| </font><font color="#0000BB">$ip_exists</font><font color="#007700">==</font><font color="#0000BB">0</font><font color="#007700">)
|
||
<br /> {
|
||
<br /> </font><font color="#0000BB">$ips</font><font color="#007700">[</font><font color="#0000BB">$i</font><font color="#007700">]=</font><font color="#0000BB">time</font><font color="#007700">().</font><font color="#DD0000">'#'</font><font color="#007700">.</font><font color="#0000BB">$ip</font><font color="#007700">;
|
||
<br /> </font><font color="#0000BB">$counter</font><font color="#007700">++;
|
||
<br /> </font><font color="#0000BB">$fh</font><font color="#007700">=</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#0000BB">$p_counter</font><font color="#007700">, </font><font color="#DD0000">'w'</font><font color="#007700">);
|
||
<br /> </font><font color="#0000BB">fwrite</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">, </font><font color="#0000BB">$counter</font><font color="#007700">);
|
||
<br /> </font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">);
|
||
<br /> }
|
||
<br /> </font><font color="#FF8000">// die ips speichern
|
||
<br /> </font><font color="#0000BB">$fh</font><font color="#007700">=</font><font color="#0000BB">fopen</font><font color="#007700">(</font><font color="#0000BB">$p_ips_counter</font><font color="#007700">, </font><font color="#DD0000">'w'</font><font color="#007700">);
|
||
<br /> </font><font color="#0000BB">fwrite</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">, </font><font color="#0000BB">join</font><font color="#007700">(</font><font color="#DD0000">"\n"</font><font color="#007700">, </font><font color="#0000BB">$ips</font><font color="#007700">));
|
||
<br /> </font><font color="#0000BB">fclose</font><font color="#007700">(</font><font color="#0000BB">$fh</font><font color="#007700">);
|
||
<br />
|
||
<br /> </font><font color="#FF8000">// ausgabe der besucherdaten
|
||
<br /> </font><font color="#007700">echo </font><font color="#DD0000">'Es sind '</font><font color="#007700">.</font><font color="#0000BB">$user_online</font><font color="#007700">.</font><font color="#DD0000">' Nutzer online.<br>'</font><font color="#007700">;
|
||
<br /> echo </font><font color="#DD0000">'Seit dem 22. Mai 2003 waren '</font><font color="#007700">.</font><font color="#0000BB">$counter</font><font color="#007700">.</font><font color="#DD0000">' Besucher auf dieser Seite.<br>'</font><font color="#007700">;
|
||
<br /> echo </font><font color="#DD0000">'Gr<47><72>te Zahl gleichzeitiger Besucher war am '</font><font color="#007700">.</font><font color="#0000BB">date</font><font color="#007700">(</font><font color="#DD0000">"d.m.Y"</font><font color="#007700">, </font><font color="#0000BB">$counter_max</font><font color="#007700">[</font><font color="#0000BB">0</font><font color="#007700">]).</font><font color="#DD0000">' mit '</font><font color="#007700">.</font><font color="#0000BB">$counter_max</font><font color="#007700">[</font><font color="#0000BB">1</font><font color="#007700">].</font><font color="#DD0000">' Besuchern.'</font><font color="#007700">;
|
||
<br /></font><font color="#0000BB">?></font>
|
||
</font>
|
||
</code></td>
|
||
</tr>
|
||
</table>
|
||
<br /><br />
|
||
<table width="100%" class="doc">
|
||
<tr>
|
||
<td><a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben" /></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten" /></a></td>
|
||
</tr>
|
||
</table>
|
||
<h2 class="Sh2"><a name="beschreibung" class="an">Beschreibung</a></h2>
|
||
<table width="100%" cellpadding="10">
|
||
<tr>
|
||
<td bgcolor="#E4EEFF" class="xmpcode">
|
||
Diese kleine Statistik zählt die Anzahl Besucher. Gleichzeitig wird noch ermittelt, wie viele Leute gerade auf der Seite sind und was das Maximum an gleichzeitigen Besuchern war (samt Datum). Das Ganze funktioniert ohne mySQL oder änlichen Datenbanksystemen. Das Skript benötigt nur Schreibrechte.<br><br>
|
||
In den ersten Zeilen des Skriptes werden diverse Parameter festgelegt, welche angepasst werden können. Dazu gehöhrt zum Beispiel, wie lange ein Besucher als online gilt ($t_user_online) oder wo und unter welchem Namen welche Datei gespeichert werden soll (fangen mit $p_ an) Es erfolgt keine Überprüfung dieser Werte, also heißt es selber darauf zu achten.<br><br>
|
||
Beim ersten Lauf des Skriptes werden die vier Dateien zur Datenspeicherung
|
||
erstellt. Diese Zeilen sollten - wenn Durchlauf erfolgreich - auskommentiert
|
||
werden, da es sonst zu Fehlern der Funktion <a href="../../funktionsreferenz/dateisystem_funktionen/file_exists.html">file_exists()</a>
|
||
kommen kann! Einfach // vor die vier Zeilen schreiben, die mit $p_ (p steht
|
||
für path) anfangen.<br>
|
||
<br>
|
||
Im Anschluss daran werden die bereits gespeicherten Daten ausgelesen.<br>
|
||
Die Aussortierung der nicht mehr gütigen IPs erfolgt durch Kontrolle der gespeicherten Uhrzeit und der aktuellen. Die Speicherung der IPs samt Uhrzeit sieht in den beiden dafür vorgesehenen Datei ($p_ips_counter und $p_ips_user_online) wie folgt aus:<br>
|
||
<font face="courier new">
|
||
1053793433#169.254.244.235<br>
|
||
1053793901#192.168.12.29<br>
|
||
</font>
|
||
Also zu erst der Zeitstempel und dann die IP. Jede noch gütige IP wird in einem neuen Array ($ips) erfasst und die Daten daraus dann in der dafür vorgesehenen Datei ($p_ips_counter und $p_ips_user_online) gespeichert. Nebenbei wird geprüft, ob die IP des aktuellen Besuchers in der Datenbank vorhanden ist. Wenn sie nicht vorhanden ist oder aufgrund von Zeitüberschreitung nicht übernommen wurde, dann wird diese IP noch in das Array hinzugefügt.<br>
|
||
Bei der Auswertung der IPs für die User-Online-Statistik erfolgen noch
|
||
zwei weitere Schritte: Zum einen wird die Anzahl dieser gleichzeitigen Besucher
|
||
aus der Anzahl Felder von $ips ermittelt (Funktion <a href="../../funktionsreferenz/array_funktionen/count.html">count()</a>)
|
||
und in $user_online gespeichert. Des weiteren wird geprüft, ob die
|
||
aktuelle Zahl Besucher größer ist, als die bisherige (in $counter_max
|
||
aus Datei $p_counter_max). Wenn ja, dann wird diese samt Zeitstempel gespeichert.<br>
|
||
<br><br>
|
||
Am Ende befinden sich folgende Daten in diesen Variablen:<br>
|
||
Anzahl Besucher: $counter
|
||
aktuelle Zahl Besucher auf der Seite: $user_online
|
||
Maximum gleichzeitiger Besucher: $counter_max[1]
|
||
Zeitpunkt des Maximums: $counter_max[0]<br><br>
|
||
Zur Formatierung des Zeitstempels empfiehlt sich die Funktion <a href="../../funktionsreferenz/datums_und_zeit_funktionen/date.html">date()</a><br>
|
||
Die hier genutzte Formatierung (<font face="courier new">date("d.m.Y", $counter_max[0])</font>) gibt zum Beispiel <font face="courier new">29.05.2003</font> aus.<br><br>
|
||
Dieses Skript kann unter Beibehaltung des namens mittels <font face="courier new"><?php include('besucherzaehler.php'); ?></font> integriert werden.</td>
|
||
</tr>
|
||
</table>
|
||
<br /><br />
|
||
<table width="100%" class="doc">
|
||
<tr>
|
||
<td><a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben" /></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten" /></a></td>
|
||
</tr>
|
||
</table>
|
||
<h2 class="Sh2"><a name="download" class="an">Download</a></h2>
|
||
<table width="100%" cellpadding="10">
|
||
<tr>
|
||
<td bgcolor="#E4EEFF" class="xmpcode">Der Download beeinhaltet folgende Dateien:<ul>
|
||
<li>besucherzaehler_integrieren_script.php</li>
|
||
<li>besucherzaehler_integrieren_erklaerung.txt</li>
|
||
<li>readme.txt</li>
|
||
</ul><a href="besucherzaehler_integrieren.zip">Download starten</a></td>
|
||
</tr>
|
||
</table>
|
||
<br /><br />
|
||
<table width="100%" border="0" cellspacing="0" cellpadding="4">
|
||
<tr>
|
||
<td colspan="3" class="doc"><a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td width="11%" align="right" class="doc">weiter:<a href="../index.php"><img src="../../src/next.gif" width="10" height="10" border="0" hspace="10" alt="weiter"></a></td>
|
||
|
||
<td colspan="2"><img src="../../src/dok.gif" width="15" height="10" border="0" alt="Seite">
|
||
<a href="../index.html"><b>Tipps & Tricks</b></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td align="right" class="doc">zurück:<a href="index.php"><img src="../../src/prev.gif" width="10" height="10" border="0" hspace="10" alt="zurück"></a></td>
|
||
|
||
<td colspan="2"><img src="../../src/dok.gif" width="15" height="10" border="0" alt="Seite">
|
||
<a href="index.html"><b>Statistiken</b></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="3" class="doc"> </td>
|
||
</tr>
|
||
<tr>
|
||
|
||
<td bgcolor="#FFEEDD" colspan="3" class="nav"><a name="bottom" class="an"><img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"></a>
|
||
<a href="../../index.html"><b>SELFPHP</b></a>/<a href="../../navigation/index.html">Navigationshilfen</a>
|
||
<img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von">
|
||
<a href="../index.html"><b>Tipps & Tricks</b></a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von">
|
||
<a href="index.html"><b>Statistiken</b></a></td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="3"><a name="bottom" class="an"><br>© 2001, 2002, 2003</a> <img src="../../src/mail.gif" width="15" height="10" border="0" alt="E-Mail"> <a href="mailto:mail@selfphp.com">Damir Enseleit, mail@selfphp.com</a> , <a href="http://www.selfphp.info/impressum.php">Impressum</a></td>
|
||
</tr>
|
||
</table>
|
||
</body>
|
||
|
||
</html> |