Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl


zlotybazant
Napisane: 5.10.2005, 09:51:11





Grupa: Zarejestrowani
Postów: 1
Dołączył: 4.10.2005

Ostrzeżenie: (0%)
-----

jak zrobic zeby licznik blokowal ip tylko na 1 lub 2 godz ... mam licznik ale blokuje mi ip na stale ... wpisze ze bez blokody to zlicza mi wszystkie wiejscia i odswieżania stron.
kod licznika :
  1. <?
  2.  
  3.   function hol_StringToObject($s) {
  4.     $L_1 = explode('||', $s);
  5.     $result['name'] = $L_1[0];
  6.     for ($q = 1; $q < count($L_1) -1; $q++) {
  7.       $L_2 = explode('=', $L_1[$q]);
  8.       $name = $L_2[0];
  9.       $result[$name] = $L_2[1];
  10.       $result[$name] = str_replace('&q;', '=', $result[$name]);
  11.       $result[$name] = str_replace('&w;', '|', $result[$name]);
  12.     }
  13.     return $result;
  14.   }
  15.   
  16.   function hol_ObjectToString($o) {
  17.     $result = $o['name'] . '||';
  18.     foreach($o as $key => $value) {
  19.       if ($key !== 'name') {
  20.         $value = str_replace('|', '&w;', $value);  
  21.         $value = str_replace('=', '&q;', $value);
  22.         $result = $result . $key . '=' . $value . '||';
  23.       }
  24.     }
  25.     return $result . ';';
  26.   }
  27.  
  28.   function file_InsertLine ($filename, $line) {
  29.     $fp = fopen ($filename, "a");
  30.     flock($fp, LOCK_EX);
  31.     fputs ($fp, $line . "rn");
  32.     flock($fp, LOCK_UN);
  33.     fclose ($fp);
  34.   }
  35.   
  36.   function IsOnList ($filename) {
  37.     $guests = file($filename);
  38.     for ($q = 0; $q < count($guests); $q ++) {
  39.       $guest = hol_StringToObject($guests[$q]);
  40.       if ($guest['ip'] == $_SERVER['REMOTE_ADDR']) {
  41.         return true;    //Blokowanie ip ( true=tak false=nie)
  42.       }
  43.     }
  44.     return false;
  45.   }
  46.   
  47.   function AddToList ($filename) {
  48.     $guest['name'] = 'guest';
  49.     $guest['ip'] = $_SERVER['REMOTE_ADDR'];
  50.     $guest['date'] = time();
  51.     file_InsertLine($filename, hol_ObjectToString($guest));
  52.   }
  53.   
  54.   $guests = file('today.txt');
  55.   $fileHeader = hol_StringToObject($guests[0]);
  56.   if (date('Y_z', $fileHeader['date']) !== date('Y_z')) {
  57.     $fp = fopen ('today.txt', 'w');
  58.     fclose($fp);
  59.     $fileHeader['name'] = 'header';
  60.     $fileHeader['date'] = time();
  61.     file_InsertLine('today.txt', hol_ObjectToString($fileHeader));
  62.   }
  63.   if (!IsOnList('today.txt')) {
  64.     AddToList('today.txt');
  65.   }
  66.   if (!IsOnList('total.txt')) {
  67.     AddToList('total.txt');
  68.   }
  69.   
  70.   $guests = file('today.txt');
  71.   $total = file('total.txt');
  72.   $stats['today'] = count($guests) -1;
  73.   $stats['total'] = count($total);
  74. ?>

zalezy mi zeby to byl ten licznik ....gdzie zrobic jakies prawki? pomozcie exclamation.gif sad.gif
  Forum: Przedszkole · Podgląd postu: #204560 · Odpowiedzi: 1 · Wyświetleń: 539


New Posts  Nowe odpowiedzi
No New Posts  Brak nowych odpowiedzi
Hot topic  Popularny temat (Nowe)
No new  Popularny temat (Brak nowych)
Poll  Sonda (Nowe)
No new votes  Sonda (Brak nowych)
Closed  Zamknięty temat
Moved  Przeniesiony temat
 

RSS Wersja Lo-Fi Aktualny czas: 8.05.2024 - 00:25