Willkommen Gast. Bitte Einloggen oder Registrieren
 
Sprache wählen:
 
 
Statistik Version 20 online.

  ÜbersichtHilfeSuchenEinloggenRegistrieren  
 
Seitenindex umschalten Seiten: 1
Thema versenden Drucken
Counter-Cache (Gelesen: 6592 mal)
hr3
Global Moderator
*****
Offline


Es gibt nichts Gutes/
außer: Man tut es. E.Kästner

Beiträge: 1126
Germany
Geschlecht: male
Counter-Cache
02.05.11 um 10:14:46
 
Mit Version 4.4.00 wurde der Counter-Cache umgestellt. Seit dem sind die Dateien log/cache_visitors.php und log/cache_visitors_counter.php identisch. Das macht wenig Sinn und kann gerade bei Installationen mit Counter-Anzeige, vielen Seitenbesuchen, langem Einsatz und besonders wenn Detaillierte Referer-Informationen anzeigen? nicht ausgeschaltet ist zu riesigen Dateien und unnötigen Verzögerungen bei der Counter-Anzeige führen.

Es könnte entweder komplett auf die zweite Datei verzichtet oder diese auf die notwendigen Informationen reduziert werden. Dafür diese Korrektur, die sowohl mit Text-Datei- als auch Datenbank-Installationen läuft.

Die Datei könnte noch weiter optimiert werden. Habe derzeit davon abgesehen, da dieses auch Anpassungen von counter.php nachziehen würde und damit der Aufwand den Nutzen für eine Lösung außerhalb des Standards nicht rechtfertigt.

Cache neu erstellen ist nicht erforderlich. Die reduzierte Datei wird automatisch bei der nächsten Aktualisierung erstellt.

Durch Aktivieren des Original-Programms wird der Standard wieder hergestellt.

stat/cache_creator.php Code:
...
if ( $visitor_hour )
{
 $temp_file_counter = 1;
 fwrite ( $cache_visitors_file , "\$visitor_hour = array ( \n" ); // array header
 $count_array = count ( $visitor_hour );
 foreach ( $visitor_hour as $key => $value )
  {
   if ( $temp_file_counter == $count_array )
    {
     fwrite ( $cache_visitors_file , "\"".$key."\" => \"".$value."\"\n" ); // array values without ","
    }
   else
    {
     fwrite ( $cache_visitors_file , "\"".$key."\" => \"".$value."\" ,\n " ); // array values with "," at the end
    }
   $temp_file_counter++;
  }
 fwrite ( $cache_visitors_file , "\n);\n\n" ); // array footer
}
//----------------
#bisherige Anweisungen löschen
visitor_day();
//----------------
if ( $visitor_weekday )
{
 $temp_file_counter = 1;
 fwrite ( $cache_visitors_file , "\$visitor_weekday = array ( \n" ); // array header
 $count_array = count ( $visitor_weekday );
 foreach ( $visitor_weekday as $key => $value )
  {
   if ( $temp_file_counter == $count_array )
    {
     fwrite ( $cache_visitors_file , "\"".$key."\" => \"".$value."\"\n" ); // array values without ","
    }
   else
    {
     fwrite ( $cache_visitors_file , "\"".$key."\" => \"".$value."\" ,\n " ); // array values with "," at the end
    }
   $temp_file_counter++;
  }
 fwrite ( $cache_visitors_file , "\n);\n\n" ); // array footer
}
//----------------
#bisherige Anweisungen löschen
visitor_month();
visitor_year();
//----------------
if ( $browser )
...

...
// copy the updated stat cache into the counter cache file
#@copy ( "log/cache_visitors.php" , "log/cache_visitors_counter.php" );
if ((!$_GET["archive"])&&($write_cache==1)) {
 $cache_visitors_file = fopen ( "log/cache_visitors_counter.php" , "w+" );
 flock  ( $cache_visitors_file , 2 );
 fwrite ( $cache_visitors_file , "<?php\n" ); // php header
 visitor_day();
 visitor_month();
 visitor_year();
 fwrite ( $cache_visitors_file , "\n?>" ); // php footer
 flock  ( $cache_visitors_file , 3 );
 fclose ( $cache_visitors_file );
 unset  ( $cache_visitors_file );
}

function visitor_day() {
 global $visitor_day,$cache_visitors_file;
 if ( $visitor_day ) {
  $temp_file_counter = 1;
  fwrite ( $cache_visitors_file , "\$visitor_day = array ( \n" ); // array header
  $count_array = count ( $visitor_day );
  foreach ( $visitor_day as $key => $value )
   {
    if ( $temp_file_counter == $count_array )
     {
      fwrite ( $cache_visitors_file , "\"".$key."\" => \"".$value."\"\n" ); // array values without ","
     }
    else
     {
      fwrite ( $cache_visitors_file , "\"".$key."\" => \"".$value."\" ,\n " ); // array values with "," at the end
     }
    $temp_file_counter++;
   }
  fwrite ( $cache_visitors_file , "\n);\n\n" ); // array footer
 }
}

function visitor_month() {
 global $visitor_month,$cache_visitors_file;
 if ( $visitor_month ) {
  $temp_file_counter = 1;
  fwrite ( $cache_visitors_file , "\$visitor_month = array ( \n" ); // array header
  $count_array = count ( $visitor_month );
  foreach ( $visitor_month as $key => $value )
   {
    if ( $temp_file_counter == $count_array )
     {
      fwrite ( $cache_visitors_file , "\"".$key."\" => \"".$value."\"\n" ); // array values without ","
     }
    else
     {
      fwrite ( $cache_visitors_file , "\"".$key."\" => \"".$value."\" ,\n " ); // array values with "," at the end
     }
    $temp_file_counter++;
   }
  fwrite ( $cache_visitors_file , "\n);\n\n" );  // array footer
 }
}

function visitor_year() {
 global $visitor_year,$cache_visitors_file;
 if ( $visitor_year ) {
  $temp_file_counter = 1;
  fwrite ( $cache_visitors_file , "\$visitor_year = array ( \n" ); // array header
  $count_array = count ( $visitor_year );
  foreach ( $visitor_year as $key => $value )
   {
    if ( $temp_file_counter == $count_array )
     {
      fwrite ( $cache_visitors_file , "\"".$key."\" => \"".$value."\"\n" ); // array values without ","
     }
    else
     {
      fwrite ( $cache_visitors_file , "\"".$key."\" => \"".$value."\" ,\n " ); // array values with "," at the end
     }
    $temp_file_counter++;
   }
  fwrite ( $cache_visitors_file , "\n);\n\n" ); // array footer
 }
}

################################################################################
### kill all vars ###
... 


neue und geänderte Zeilen
Zum Seitenanfang
« Zuletzt geändert: 03.05.11 um 09:50:54 von hr3 »  
 
IP gespeichert
 
Reimar
Administrator
*****
Offline



Beiträge: 1982
Geschlecht: male
Re: Counter-Cache
Antwort #1 - 25.06.11 um 15:37:42
 
Gute Idee, übernehmen wir so.
Zum Seitenanfang
 
 
IP gespeichert
 
Seitenindex umschalten Seiten: 1
Thema versenden Drucken