<?php
function hexip($ip){
$osa = explode(".", current(explode(",", $ip)));
return substr(sprintf("%02X%02X%02X%02X", $osa[0], $osa[1], $osa[2], $osa[3]), 0, 8);
}
function find_hexip($tiedosto, $hexip){
$find = 0;
$fp = fopen($tiedosto, "rb"); // windowsilla täytyy olla "rb", muilla "r"
while(!feof($fp)){
$data = fread($fp, 4086); // huom, täytyy olla jaollinen 9:llä (4086/9 = 454)
if(strpos($data, $hexip.' ') !== false){
$find = 1;
break;
}
} // IP:n haku tiedostosta by T.M. - www.HC-Codes.net
fclose($fp);
return $find;
}
$ip = $_SERVER['REMOTE_ADDR'];
$hexip = hexip($ip);
$find = find_hexip("tiedosto.txt", $hexip);
if($find){
print"IP löytyi tiedostosta.";
}else{
print"IP ei löytynyt tiedostosta.";
}
?>Aihe on jo aika vanha, joten et voi enää vastata siihen.