| Vorheriges Thema anzeigen :: Nächstes Thema anzeigen |
| Autor |
Nachricht |
Geiseltaler Mitglied

|
 |
|
|
@ David,
So weit hab ich das nun begriffen, aber da ist wahrscheinlich mein Problem, weil ich den Onlinezähler noch davor hatte. (das Zählerscript vom Onlinezähler) Hatte also beide Scripte nacheinander vor die Tags <html><head> .... usw geschrieben und die Audgabe-Geschichte dann nacheinander unten am Seitenende angehängt.
Wenn ich den Zähler vom V4hn als erstes schreibe, meckert der Online-Zähler und wenn der vorn steht, mecker der vom V4hn.
Könnte man so nen online Zähler noch mit dort rein basteln? Ohne großen Aufwand, sonst müsste ich den schmerzlich entfernen.
Also Quasi das meine Ausgabe so aussieht:
Besucher Online: 1 Heute: 89 Gestern: zu wenige Gesamt: nie genug
Ich hoffe ich konnte es rüber bringen, was ich meine.
Edit: Oder kann man diese beiden irgrendwie zusammen wurschteln?!??!
Danke für die viele Hilfe bisher auch wenn ich der Fehler im System war.
Gruß
Mario |
_________________
http://www.im-geiseltal.de
oder:
http://www.homepage.familie-pforte.de
Ich frage was ich nicht weiß, auch wenn die Fragen nicht immer bequem sind. Denn es gibt doch keine dummen Fragen ....! |
|
|
| 05 Apr 2006 09:16 |
|
  |
David Administrator

|
 |
|
|
| Ich schlage vor du veröffentlichst die komplette Datei (bitte einen Link auf die txt-Datei setzen). Dann lässt sich auch sagen was man machen muss. |
_________________ MfG David Mirzoian
axinio Internet Marketing - professionelle Suchmaschinenoptimierung |
|
|
| 05 Apr 2006 11:55 |
|
 |
Breezzer Mitglied
|
 |
|
|
wird wohl auch nix bringen;
ich wollts eigentlich schon länger mal vorschlagen, dachte aber dass du den counter bishe rimmer separat aufgerufen hast....daher guckst du hier:
ganz oben in deine index.php (oder wie auch immer deine "grundseite" heissen soll) schreibst du das:
wirklich GANZ oben, davor darf nichtmal ein leerzeichen stehen
| PHP-Code: | 1 2 3
| <?php
ob_start();
?> |
und ganz unten:
| PHP-Code: | 1 2 3
| <?php
ob_end_flush();
?> |
mit ob_start() wird ein schreibpuffer gestartet, d.h. alle ausgaben die mit html oder php erfolgen, werden nicht sofort ausgegeben, sondern erst wenn du den puffer mit ob_end_flush() wieder deaktivierst
deine cookie-asugabe wird ist von dem puffer aber nicht betroffen, ist daher die erste zeile -> header wurde erfolgreich modifiziert
mehr dazu gibts hier:
http://de.php.net/ob_start |
_________________ BS-Media
Kauft bei Amazon indem ihr diesem Link folgt und tut was gutes! Jede Provision die so erlangt wird fliesst einem UNICEF-Projekt zu. |
|
|
| 05 Apr 2006 12:41 |
|
 |
David Administrator

|
 |
|
|
| Das wollte ich auch vorschlagen, aber es gibt manche, die ständig prädigen, dass es keine saubere Methode ist. Stimmt das? |
_________________ MfG David Mirzoian
axinio Internet Marketing - professionelle Suchmaschinenoptimierung |
|
|
| 05 Apr 2006 12:44 |
|
 |
Breezzer Mitglied
|
 |
|
|
ich weiss net, was daran unsauber sein sollte.
klar könnte man es in diesem fall als 'faul' bezeichnen, denn man könnte auch den counter-code an den anfang schreiben, aber des is ja net immer so einfach bei leuten, die sich vielleicht nicht ganz so gut auskennen.
und der puffer ist durchaus gut, sonst gäbs ihn nicht  |
_________________ BS-Media
Kauft bei Amazon indem ihr diesem Link folgt und tut was gutes! Jede Provision die so erlangt wird fliesst einem UNICEF-Projekt zu. |
|
|
| 05 Apr 2006 12:58 |
|
 |
Geiseltaler Mitglied

|
 |
|
|
So, habe nun mal schnell den Code meiner Seite gezogen, den ich bisher aufgerufen habe. Hier ist die Counterdatei über dem Header = der Besucher Online Counter.
Die Counterdatei für die Statistik (Besucher Heute, gestern, gesamt) rufe ich am Ende der Seite über PHP-Include auf Also als externe Datei.
Damit zählt der Counter aber alles und jeden einzelnen Seitenwechsel.
Hier nun der Code:
| Code: |
/* Online Counterscript Anfang /*
<?PHP
//-------------------------------------------------------------
// artmedic useronline 1.0 || http://www.artmedic.de
// Copyright (C) 2002 Ellen Baitinger, artmedic webdesign
// This Software is distributed under the GNU General Public
// License.
//-------------------------------------------------------------
$daten="count.txt";
$time = time();
$ip = getenv("REMOTE_ADDR");
$ablaufzeit = "$time"-"300";
$pruefung = @file($daten);
while (list ($line_num, $line) = @each ($pruefung))
{$zeiten = explode("&&",$line);
if($zeiten[0] <= $ablaufzeit)
{$fp = fopen( "$daten", "r" );
$contents = fread($fp, filesize($daten));
fclose($fp);
$line=quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh=fopen($daten, "w");
@flock($fp,2);
fputs($fh, $replace);
@flock($fp,3);
fclose($fh);}}
$ippruefung = @file($daten);
while (list ($line_num, $line) = @each ($ippruefung))
{$ips = explode("&&",$line);
if($ips[1] == $ip)
{$fp = fopen( "$daten", "r" );
$contents = fread($fp, filesize($daten));
fclose($fp);
$line=quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh=fopen($daten, "w");
@flock($fp,2);
fputs($fh, $replace);
@flock($fp,3);
fclose($fh);}}
$fp = fopen("$daten", "a+");
flock($fp,2);
fputs ($fp, "$time&&$ip&&\n");
flock($fp,3);
fclose ($fp);
$anzahldaten = file($daten);
$anzahl = count($anzahldaten);
?>
/* Online Counterscript ENDE /*
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="de">
<head>
<title>MP-Hobbydesign Internetseiten nach ihren Vorlagen!</title>
<?php include ("meta.txt"); ?>
<script src="script/tooltip.js"></script>
</head>
<body onmousemove="overhere()">
<div id="ToolTip"></div>
<script src="e-mail.js"></script>
<div id="navigation">
<table cellpadding="0" cellspacing="0" width="190px" height="100%">
<tr>
<td width="190" valign="top" background="logomp.png" style="background-repeat: no-repeat;">
<img border="0" width="190" height="170" src="baum.gif">
<?php include ("navigation.txt"); ?>
</td>
</tr>
</table>
</div>
<!-- Inhalt ANFANG -->
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top" background="http://www.familie-pforte.de/inhalt1/logohdg1.png" style="background-repeat: no-repeat; background-position: top center;">
<img src="http://www.familie-pforte.de/img/0.gif" border="0" height="120">
<table cellpadding="0">
<tr>
<?php
$action = $_GET["action"];
if (!isset($action)) { $action = "start"; }
$action = "./inhalt1/".$action.".txt";
include ($action);
?>
</td>
</tr>
<tr bgcolor="gold"><td>
<?php include ("copyright.txt"); ?>
</td>
</tr>
</table>
<div align="right" class="copy">Besucher Online: <?php echo "$anzahl";?>
<?php include ("counter.php"); ?> </div>
</body>
</html>
|
Die Kommentare Anfang Ende usw habe ich eben eingefügt.
Dann habe ich versucht die Counterdatei der Statistik oben mit zu integrieren und habe nach der Online-Counterdatei den Code hinzugefügt.
Am Ende habe ich dann statt der PHP-Include Zeile die Aufrufzeile eingesetzt und bekam dann die Fehlermeldung wie oben (vorheriges Posting) angegeben.
Hier der Code dafür:
| Code: |
/* Online Counterscript Anfang /*
<?PHP
//-------------------------------------------------------------
// artmedic useronline 1.0 || http://www.artmedic.de
// Copyright (C) 2002 Ellen Baitinger, artmedic webdesign
// This Software is distributed under the GNU General Public
// License.
//-------------------------------------------------------------
$daten="count.txt";
$time = time();
$ip = getenv("REMOTE_ADDR");
$ablaufzeit = "$time"-"300";
$pruefung = @file($daten);
while (list ($line_num, $line) = @each ($pruefung))
{$zeiten = explode("&&",$line);
if($zeiten[0] <= $ablaufzeit)
{$fp = fopen( "$daten", "r" );
$contents = fread($fp, filesize($daten));
fclose($fp);
$line=quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh=fopen($daten, "w");
@flock($fp,2);
fputs($fh, $replace);
@flock($fp,3);
fclose($fh);}}
$ippruefung = @file($daten);
while (list ($line_num, $line) = @each ($ippruefung))
{$ips = explode("&&",$line);
if($ips[1] == $ip)
{$fp = fopen( "$daten", "r" );
$contents = fread($fp, filesize($daten));
fclose($fp);
$line=quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh=fopen($daten, "w");
@flock($fp,2);
fputs($fh, $replace);
@flock($fp,3);
fclose($fh);}}
$fp = fopen("$daten", "a+");
flock($fp,2);
fputs ($fp, "$time&&$ip&&\n");
flock($fp,3);
fclose ($fp);
$anzahldaten = file($daten);
$anzahl = count($anzahldaten);
?>
/* Online Counterscript ENDE /*
/* Statistik Counterscript Anfang /*
<?
/*
--------------------------------------------------
______ _____
_/ \_ _/ \__
_/ \_ _/ \_
( ____)-(____ )
\_ (XXx/ \xXX) _/
\__ (XXX/ \XXX) __/
\__(XX/ \XX)__/
by V4hn is watching you
--------------------------------------------------
This is a little file based counter,
wich is able to save the counts for the last days too.
The only conditions are the ability to write files on your webspace and minimum 1 user per day accessing the page.
layout of the database:
data in lines:
1. line: current day of the month
2. line: the total of visitors
3. line: visitors today
n. line: visitors of n-3 days before
*/
$file_name = "counter.txt"; // file to save the counter infos in
$hours2block = 72; //hours to wait until next count for the same ip
$days = 2; //number of days to save a count for
//create countdatabase, if not existing
if(!is_file($file_name)){
$fp = @fopen($file_name, "w+");
$default = date("d")."\n0\n";
for($i=0; $i < $days; $i++) $default .= "0\n";
@fputs($fp, $default);
@fclose($fp);
}
$cookie_ip = !empty($_COOKIE['cookie_ip']) ? $_COOKIE['cookie_ip'] : 1;
$carray = @file($file_name);
//if the next day has come, rewrite the file
if(chop($carray[0]) != date("d")){
$fp = @fopen($file_name, "w+");
@fputs($fp, date("d")."\n".$carray[1]."0\n");
for($i=2; $i <= $days; $i++)
@fputs($fp, $carray[$i]);
@fclose($cp);
$carray = @file($file_name);
}
//update countvalues
if(($cookie_ip == 1) || ($cookie_ip != $_SERVER['REMOTE_ADDR'])){
$carray[1] = (chop($carray[1])+1)."\n";
$carray[2] = (chop($carray[2])+1)."\n";
$fp = @fopen($file_name, "w+");
for($i=0; $i < count($carray); $i++)
@fputs($fp, $carray[$i]."");
fclose($fp);
setcookie('cookie_ip', $_SERVER['REMOTE_ADDR'], time()+($hours2block*3600));
}
//give out a short text
?>
/* Statistik Counterscript ENDE /*
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="de">
<head>
<title>MP-Hobbydesign Internetseiten nach ihren Vorlagen!</title>
<?php include ("meta.txt"); ?>
<script src="script/tooltip.js"></script>
</head>
<body onmousemove="overhere()">
<div id="ToolTip"></div>
<script src="e-mail.js"></script>
<div id="navigation">
<table cellpadding="0" cellspacing="0" width="190px" height="100%">
<tr>
<td width="190" valign="top" background="logomp.png" style="background-repeat: no-repeat;">
<img border="0" width="190" height="170" src="baum.gif">
<?php include ("navigation.txt"); ?>
</td>
</tr>
</table>
</div>
<!-- Inhalt ANFANG -->
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top" background="http://www.familie-pforte.de/inhalt1/logohdg1.png" style="background-repeat: no-repeat; background-position: top center;">
<img src="http://www.familie-pforte.de/img/0.gif" border="0" height="120">
<table cellpadding="0">
<tr>
<?php
$action = $_GET["action"];
if (!isset($action)) { $action = "start"; }
$action = "./inhalt1/".$action.".txt";
include ($action);
?>
</td>
</tr>
<tr bgcolor="gold"><td>
<?php include ("copyright.txt"); ?>
</td>
</tr>
</table>
<div align="right" class="copy">Besucher Online:
<?php echo "$anzahl";?>
<?php "Heute: ".$carray[2]." \nGestern: ".$carray[3]." \nGesamt: ".$carray[1];?> </div>
</body>
</html>
|
Auch ein Wechsel der beiden Scripte über der HTML Datei brachte nur wechselnde Fehlermeldungen der beiden Counter.
Nun hoffe ich das ich etwas Klarheit schaffen konnte.
Mir ist es im Prinzip egal, ob ich den Counter extern Aufrufe oder integrieren muss. Ich hab nur leider nicht so viel Durchblick das ich entscheiden kann ob hier was sauber oder unsauber ist (noch nicht ). Dafür seit ihr die Fachleute. Ich vertraue euch das ihr noch eine gute Lösung findet.
Also dann, auf zur nächsten Runde
Mario
EDIT: @Breezzer:
Ich habe eben noch deinen Vorschlag mit dem Puffer getestet. Sovol einmal mit beiden Dateien als externen Aufruf, als auch mit beiden Dateien im Seitencode. Einmal zählte wieder alles und bei einer Version war die Statistik komplett verschwunden.
Nur noch nebenbei zur Info. |
_________________
http://www.im-geiseltal.de
oder:
http://www.homepage.familie-pforte.de
Ich frage was ich nicht weiß, auch wenn die Fragen nicht immer bequem sind. Denn es gibt doch keine dummen Fragen ....! |
|
|
| 05 Apr 2006 13:47 |
|
 |
V4hn Moderator
|
 |
|
|
| Code: | <?PHP
/* Online Counterscript Anfang */
//-------------------------------------------------------------
// artmedic useronline 1.0 || http://www.artmedic.de
// Copyright (C) 2002 Ellen Baitinger, artmedic webdesign
// This Software is distributed under the GNU General Public
// License.
//-------------------------------------------------------------
$daten="count.txt";
$time = time();
$ip = getenv("REMOTE_ADDR");
$ablaufzeit = "$time"-"300";
$pruefung = @file($daten);
while (list ($line_num, $line) = @each ($pruefung))
{$zeiten = explode("&&",$line);
if($zeiten[0] <= $ablaufzeit)
{$fp = fopen( "$daten", "r" );
$contents = fread($fp, filesize($daten));
fclose($fp);
$line=quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh=fopen($daten, "w");
@flock($fp,2);
fputs($fh, $replace);
@flock($fp,3);
fclose($fh);}}
$ippruefung = @file($daten);
while (list ($line_num, $line) = @each ($ippruefung))
{$ips = explode("&&",$line);
if($ips[1] == $ip)
{$fp = fopen( "$daten", "r" );
$contents = fread($fp, filesize($daten));
fclose($fp);
$line=quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh=fopen($daten, "w");
@flock($fp,2);
fputs($fh, $replace);
@flock($fp,3);
fclose($fh);}}
$fp = fopen("$daten", "a+");
flock($fp,2);
fputs ($fp, "$time&&$ip&&\n");
flock($fp,3);
fclose ($fp);
$anzahldaten = file($daten);
$anzahl = count($anzahldaten);
/* Online Counterscript ENDE */
/* Statistik Counterscript Anfang */
/*
--------------------------------------------------
______ _____
_/ \_ _/ \__
_/ \_ _/ \_
( ____)-(____ )
\_ (XXx/ \xXX) _/
\__ (XXX/ \XXX) __/
\__(XX/ \XX)__/
by V4hn is watching you
--------------------------------------------------
This is a little file based counter,
wich is able to save the counts for the last days too.
The only conditions are the ability to write files on your webspace and minimum 1 user per day accessing the page.
layout of the database:
data in lines:
1. line: current day of the month
2. line: the total of visitors
3. line: visitors today
n. line: visitors of n-3 days before
*/
$file_name = "counter.txt"; // file to save the counter infos in
$hours2block = 72; //hours to wait until next count for the same ip
$days = 2; //number of days to save a count for
//create countdatabase, if not existing
if(!is_file($file_name)){
$fp = @fopen($file_name, "w+");
$default = date("d")."\n0\n";
for($i=0; $i < $days; $i++) $default .= "0\n";
@fputs($fp, $default);
@fclose($fp);
}
$cookie_ip = !empty($_COOKIE['cookie_ip']) ? $_COOKIE['cookie_ip'] : 1;
$carray = @file($file_name);
//if the next day has come, rewrite the file
if(chop($carray[0]) != date("d")){
$fp = @fopen($file_name, "w+");
@fputs($fp, date("d")."\n".$carray[1]."0\n");
for($i=2; $i <= $days; $i++)
@fputs($fp, $carray[$i]);
@fclose($cp);
$carray = @file($file_name);
}
//update countvalues
if(($cookie_ip == 1) || ($cookie_ip != $_SERVER['REMOTE_ADDR'])){
$carray[1] = (chop($carray[1])+1)."\n";
$carray[2] = (chop($carray[2])+1)."\n";
$fp = @fopen($file_name, "w+");
for($i=0; $i < count($carray); $i++)
@fputs($fp, $carray[$i]."");
fclose($fp);
setcookie('cookie_ip', $_SERVER['REMOTE_ADDR'], time()+($hours2block*3600));
}
//text is printed below
/* Statistik Counterscript ENDE */
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="de">
<head>
<title>MP-Hobbydesign Internetseiten nach ihren Vorlagen!</title>
<?php include ("meta.txt"); ?>
<script src="script/tooltip.js"></script>
</head>
<body onmousemove="overhere()">
<div id="ToolTip"></div>
<script src="e-mail.js"></script>
<div id="navigation">
<table cellpadding="0" cellspacing="0" width="190px" height="100%">
<tr>
<td width="190" valign="top" background="logomp.png" style="background-repeat: no-repeat;">
<img border="0" width="190" height="170" src="baum.gif">
<?php include ("navigation.txt"); ?>
</td>
</tr>
</table>
</div>
<!-- Inhalt ANFANG -->
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top" background="http://www.familie-pforte.de/inhalt1/logohdg1.png" style="background-repeat: no-repeat; background-position: top center;">
<img src="http://www.familie-pforte.de/img/0.gif" border="0" height="120">
<table cellpadding="0">
<tr>
<?php
$action = $_GET["action"];
if (!isset($action)) { $action = "start"; }
$action = "./inhalt1/".$action.".txt";
include ($action);
?>
</td>
</tr>
<tr bgcolor="gold"><td>
<?php include ("copyright.txt"); ?>
</td>
</tr>
</table>
<div align="right" class="copy">Besucher Online:
<?php echo "$anzahl";?>
<?php echo "Heute: ".$carray[2]." \nGestern: ".$carray[3]." \nGesamt: ".$carray[1]; ?> </div>
</body>
</html>
|
das sollte jetzt endlich funkzen...
1. Stream comments mit /* */ nicht /* /*
2. wenn du ?> <?php schreibst, dann überträgt er schon 1 Leerzeichen dazwischen Zeichen an den Browser: darf er nicht
3. kommentare außerhalb von <?php ?> werden auch übermittelt und
4. bringt nicht viel, wenn man <?php "string"; ?> schreibt...(siehe außgabe von meinem counter
entweder <?="string"?> (kurzform, die nicht überall unterstützt ist)
oder <?php echo "string"; ?>
... |
_________________
 |
|
|
| 05 Apr 2006 15:27 |
|
 |
Geiseltaler Mitglied

|
|
| 05 Apr 2006 15:53 |
|
 |
V4hn Moderator
|
|
| 05 Apr 2006 16:11 |
|
 |
Breezzer Mitglied
|
 |
|
|
gratuliere
ja, $hours2block (wie cool der vahn variablen abküzt ) gibt die an, wie lange eine ip blockiert ist...wobei doch auch cookies gesetzt werden
denn sinn soll dir der vahn erklären  |
_________________ BS-Media
Kauft bei Amazon indem ihr diesem Link folgt und tut was gutes! Jede Provision die so erlangt wird fliesst einem UNICEF-Projekt zu. |
|
|
| 05 Apr 2006 16:13 |
|
 |
|