ainars Posted September 14, 2004 Report Share Posted September 14, 2004 (edited) Kā izlabot scriptu, lai neņemvērā refreshu??? Citadi refreshojot lapu skaitās cipari uz priekšu..... nevar noteikt patieso apmekletāju skaitu :( <?php class acounter { var $config = array(); function acounter () { /* URL to the digitset */ $this->config['img'] = "http://sitkana.eclub.lv/*/"; /* URL to the animated digitset */ $this->config['animated_img'] = "http://sitkana.eclub.lv/*/"; /* How many digits to show */ $this->config['pad'] = 6; /* digit width and height */ $this->config['width'] = 16; $this->config['height'] = 22; /* ip blocking (true/false) */ $this->config['block_ip'] = false; /* path to ip logfiles */ $this->config['logfile'] = "count/ip.txt"; /* timeout (minutes) */ $this->config['block_time'] = 15; } function is_new_visitor() { $is_new = true; $rows = @file($this->config['logfile']); $this_time = time(); $ip = getenv("REMOTE_ADDR"); $reload_dat = fopen($this->config['logfile'],"wb"); flock($reload_dat, 2); for ($i=0; $i<sizeof($rows); $i++) { list($time_stamp,$ip_addr) = split("\|",$rows[$i]); if ($this_time < ($time_stamp+$this->config['block_time'])) { if (chop($ip_addr) == $ip) { $is_new = false; } else { fwrite($reload_dat,"$time_stamp|$ip_addr"); } } } fwrite($reload_dat,"$this_time|$ip\n"); flock($reload_dat, 3); fclose($reload_dat); return $is_new; } function read_counter_file($page) { $update = false; if (!file_exists("count/pages/$page.txt")) { $count_dat = fopen("count/pages/$page.txt","w+"); $this->counter = 1; fwrite($count_dat,$this->counter); fclose($count_dat); } else { $fp = fopen("count/pages/$page.txt", "r+"); flock($fp, 2); $this->counter = fgets($fp, 4096); flock($fp, 3); fclose($fp); if ($this->config['block_ip']) { if ($this->is_new_visitor()) { $this->counter++; $update = true; } } else { $this->counter++; $update = true; } if ($update) { $fp = fopen("count/pages/$page.txt", "r+"); flock($fp, 2); rewind($fp); fwrite($fp, $this->counter); flock($fp, 3); fclose($fp); } } return $this->counter; } function create_output($page='') { if (empty($page)) { $page = "counter"; } $this->read_counter_file($page); $this->counter = sprintf("%0"."".$this->config['pad'].""."d",$this->counter); $ani_digits = sprintf("%0"."".$this->config['pad'].""."d",$this->counter+1); $html_output = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr align=\"center\">\n"; for ($i=0; $i<strlen($this->counter); $i++) { if (substr("$this->counter",$i,1) == substr("$ani_digits",$i,1)) { $digit_pos = substr("$this->counter",$i,1); $html_output .= "<td><img src=\"".$this->config['img']."$digit_pos.gif\""; } else { $digit_pos = substr("$ani_digits",$i,1); $html_output .= "<td><img src=\"".$this->config['animated_img']."$digit_pos.gif\""; } $html_output .= " width=\"".$this->config['width']."\" height=\"".$this->config['height']."\"></td>\n"; } $html_output .= "</tr></table>\n"; return $html_output; } } ?> Kā to dabūt gatavu???? :unsure: Edited September 14, 2004 by ainars Link to comment Share on other sites More sharing options...
рпр Posted September 14, 2004 Report Share Posted September 14, 2004 kā tev pašam liekas kā var noteikt vai cilvēks taisa refrešu vai ievada urli ar roku? varbuut pasties kautko par kuukijiem vai sesijaam, gan jau dziivee noderees. Link to comment Share on other sites More sharing options...
bubu Posted September 14, 2004 Report Share Posted September 14, 2004 Visi kaunteri tak ņem vērā refreshu, tāpēc jau mēra gan hostus (datoru skaitu, kas apmeklē lapu, pēc IP adreses vai/un citas kombinācijas) un hitus (lapu ielādes skaitu). Link to comment Share on other sites More sharing options...
ainars Posted September 14, 2004 Author Report Share Posted September 14, 2004 kā tev pašam liekas kā var noteikt vai cilvēks taisa refrešu vai ievada urli ar roku? varbuut pasties kautko par kuukijiem vai sesijaam, gan jau dziivee noderees. Jā bet var jau uztaisīt, ja cilvēks no viena IP atrodas lapā un protams jau ir pieskaitīts, tad no šī IP personu neskaita klāt piem 30min[gadījuma, ja lapu refresho]! Vislabakais jau ir uztaisiit, lai visiem IP, kuri ir pieskaitīti netiek par jaunu skaitīti noteiktu laika intervālu.. bet šeit bez papildus IP lista neiztikt!!! Link to comment Share on other sites More sharing options...
рпр Posted September 14, 2004 Report Share Posted September 14, 2004 sagalabaa datus sql tabulaa un peec tam sagrupee peec ip. Link to comment Share on other sites More sharing options...
ainars Posted September 14, 2004 Author Report Share Posted September 14, 2004 sagalabaa datus sql tabulaa un peec tam sagrupee peec ip. Jā ideja laba, tikai http://eclub.lv nav bezmaksas SQL.... vai nevar txt listingu??? Link to comment Share on other sites More sharing options...
рпр Posted September 14, 2004 Report Share Posted September 14, 2004 vispar tajaa klasee, ko tu pirmajaa postaa ieposteeji ir taada funkcija is_new_visitor(), papeeti to. Link to comment Share on other sites More sharing options...
Analgiins Posted September 14, 2004 Report Share Posted September 14, 2004 btw, kaa tev var straadaat fwrite funkcija uz eclub.lv ? Es testeeju, man neatljaava neko tamliidziigu Link to comment Share on other sites More sharing options...
ainars Posted September 14, 2004 Author Report Share Posted September 14, 2004 btw, kaa tev var straadaat fwrite funkcija uz eclub.lv ? Es testeeju, man neatljaava neko tamliidziigu Man viss shansee.... skaties varbut Tev koda klluuda... Link to comment Share on other sites More sharing options...
Analgiins Posted September 14, 2004 Report Share Posted September 14, 2004 sapratu, palasiijos manuaaljos, forumos... - failiem tak jaabuut CHMOD`ed :) Link to comment Share on other sites More sharing options...
Recommended Posts