20. september 2005 - 14:41Der er
5 kommentarer og 1 løsning
Tæl ikke hvis IP'en er min
Hej.
Har et script, som tæller antal klik på et link. Det virker fint, men jeg kunne godt tænke mig, at den ikke talte når det kommer fra min IP-adresse. Hvordan gøres det?
if($file) { if(strpos($file,'..')!==false || strpos($file,'/')!==false) error('Access Denied ('.$file.')'); if(!in_array(substr(strrchr($file,'.'),1),$config['allowed_files'])) error('You do not have access to this type of file! ('.$file.')'); if(!is_file($config['file_path'].'/'.$file)) error('File "'.$file.'" is not avaliable!'); $result=mysql_query("SELECT * FROM `downloads` WHERE name='$file'",$conn) OR error('MySQL Query Failed: '.mysql_error()); $query=(mysql_num_rows($result) === 0) ? "INSERT INTO downloads (ID, name, downloads, date) Values ('', '$file', '1', '".date("Y-m-d H:i")."')" : "UPDATE downloads SET downloads = downloads+1 WHERE name='$file'"; mysql_query($query,$conn); download($config['file_path'],$file); mysql_close($conn); }
if($file) { if(strpos($file,'..')!==false || strpos($file,'/')!==false) error('Access Denied ('.$file.')'); if(!in_array(substr(strrchr($file,'.'),1),$config['allowed_files'])) error('You do not have access to this type of file! ('.$file.')'); if(!is_file($config['file_path'].'/'.$file)) error('File "'.$file.'" is not avaliable!'); $result=mysql_query("SELECT * FROM `downloads` WHERE name='$file'",$conn) OR error('MySQL Query Failed: '.mysql_error()); if ($_SERVER['REMOTE_ADDR'] != "83.72.34.xxx") { $query=(mysql_num_rows($result) === 0) ? "INSERT INTO downloads (ID, name, downloads, date) Values ('', '$file', '1', '".date("Y-m-d H:i")."')" : "UPDATE downloads SET downloads = downloads+1 WHERE name='$file'"; mysql_query($query,$conn); download($config['file_path'],$file); mysql_close($conn); } }
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.