strong-storm Posted December 26, 2003 Report Share Posted December 26, 2003 Ja pieņem ,ka failā bans.txt ir ip adreses tā : 127.0.0.7| banots par neko 127.0.7.1|ir nezināms 127.0.0.1|Ļaundaris un php izlasa un visam txt failiņam piešķir $saturs Tad man vajaga funkciju, kas izlasītu visas ip tikkai līdz | un salīdzina ar manu ip!!! $fails = "bans.txt"; $atvert = fopen ("$fails", "r"); $saturs = fread($atvert, filesize($fails)); fclose($atvert); $separat = "|"; $saturs = substr($saturs, 0, strpos($saturs,$separat)); if ($ip == $saturs) {echo "bans";} else {echo "viss ok";} A tas stradas tikkai tad, ja virseja ip ir vienada ar 127.0.0.1, bet ja virseja ir 128.0.0.1, tad neka!!! Vajaga, lai cheko visas ip!!!! nu es nezinu ar kādu fišku, lai tā izlasa! Link to comment Share on other sites More sharing options...
Aleksejs Posted December 26, 2003 Report Share Posted December 26, 2003 Tev ir tikai paarbaude uz pirmo adresi, bet vajag izmantot ciklu, lai izietu cauri... Link to comment Share on other sites More sharing options...
Fatalis Posted December 26, 2003 Report Share Posted December 26, 2003 while "|" is in data do blah blah - like this ;) Link to comment Share on other sites More sharing options...
lame Posted December 26, 2003 Report Share Posted December 26, 2003 <?php function is_baned($ip) { $fails =file("bans.txt"); $cik=count($fails); $separat = "|"; for($i=0; $i<$cik; $i++) { $saturs = substr($fails[$i], 0, strpos($fails[$i],$separat)); if($ip == $saturs)return true; } return false; } if (getenv('HTTP_X_FORWARDED_FOR'))$ip = getenv('HTTP_X_FORWARDED_FOR'); else $ip = getenv('REMOTE_ADDR'); if(is_baned($ip))echo "Bans"; else echo "Ok"; ?> Link to comment Share on other sites More sharing options...
Recommended Posts