Einzelnen Beitrag anzeigen

Benutzerbild von vlees91
vlees91

Registriert seit: 19. Apr 2004
843 Beiträge
 
Turbo Delphi für Win32
 
#3

Re: Zugriffszähler für Homepage

  Alt 5. Feb 2006, 14:44
damit geht das nicht
das musst du mit cgi, asp, php o.Ä. machen

hiermit geht das (ist PHP):
Code:
<? function getCounter($counterID)
{
   // each counter value is stored inside a unique file
   // We use $counterID as a part of the file name
   // Example: file name will be "counter1.txt" if $counterID is set to "1"

   $fileName = "counter".$counterID.".txt";

   if( file_exists($fileName) ) {
      list($numVisitors)=file($fileName); // Read contents from the file
   } else {
      $numVisitors=0; // This is the first time the page is accessed
   }

   $numVisitors=$numVisitors+1; // Increase the count

   $fil=fopen($fileName,"w");    // Open the file to replace old value
   fputs($fil,$numVisitors);    // Write the new count to the file
   fclose($fil);            // Close the file
   return $numVisitors;      // Return the new count
}
?>
und dann mit
Code:
<? echo getCounter("1"); ?>
ruft man das ganze auf!
anstatt der 1 kann man auch startseite hinsetzen




PS: Die funktion ist aus dem Spin PHP...
vlees91
  Mit Zitat antworten Zitat