Autors: BlackHalt
Komentārs: Is TOR? PHP code snipet
<!-- HTML --> <form id="forma" name="forma" method="post" action=""> <input type="text" name="ip" /> <input type="submit" name="Submit" value="Submit" /> </form> <?php /* BlaskHalt Is TOR? PHP code snipet http://blackhalt.wordpress.com/2008/06/05/is-tor/ */ //error_reporting(0); $mans_tor_fails='is_tor.txt'; $svaigums='http://proxy.org/tor_blacklist.txt'; // Nocheko kaut kaadu svaigumu, viena diena: if ((!file_exists($mans_tor_fails)) or (time() - filemtime($mans_tor_fails) > 86400)) { $ctx = stream_context_create(array( 'http' => array( 'timeout' => 10 ) ) ); $atvelk=file_get_contents($svaigums,0,$ctx); if($atvelk==true){ // Tipa iznjemam aaraa lieko // Ar tiem njuulainiem pashi gudrojiet: $atvelk=str_replace( array( "RewriteEngine on \n", "\nRewriteRule ^.* - [F] ", 'RewriteCond %{REMOTE_ADDR} ^', '^', '$', '[OR]', ' ', ), '', $atvelk); $atvelk=str_replace('\.','.',$atvelk); // Ieraksta failaa: $raksta=fopen($mans_tor_fails,'w+'); fputs($raksta,$atvelk); fclose($raksta); } } // $_POST['ip'] viet? vari izmantot IP noteikshanas funkcijas. if(isset($_POST['ip'])){ $ip=$_POST['ip']; // Te var veel visaadus filtrus samudriit: $ip=htmlspecialchars($ip,ENT_QUOTES); $saraksts=array_map('trim',file($mans_tor_fails)); if(in_array($ip,$saraksts)){ echo'<h1>Ir TOR</h1>'; } else{ echo'Nav TOR'; } } ?>
© 2003 – 2010 PHP.lv komanda. Visas tiesības ir paturētas. Izņemot saturu, kurš ir tā autora īpašums, ja nekas nenosaka savādāk.