PHP IP rögzítés
Üdv!
Az a gondom, hogy nem rögzíti az IP címet ez a kis
prg.Én persze nem értek hozzá, ha v.ki tud , akkor segítsen!
Előre is tanx.
<?
$datafile="adat.txt";
$seperator = chr(14).chr(1);
$lseperator = chr(0).chr(0).chr(0);
chmod($datafile,0666);
if($act == "sign") {
if(filesize($datafile)>0) {
$x=fopen($datafile,"r+");
$data = fread($x,filesize($datafile));
$start=0;
$arr = explode($lseperator,$data);
echo "&total=".(count($arr)+1)."&";
fclose($x);
}
$name = str_replace("<?","PHPCODE-Start",$name);
$name = str_replace("?>","PHPCODE-Start",$name);
$name = str_replace("&","^^",$name);
$email = str_replace("<?","PHPCODE-Start", $email);
$email = str_replace("?>","PHPCODE-Ends", $email);
$email = str_replace("&","^^", $email);
$site = str_replace("<?","PHPCODE-Start", $site);
$site = str_replace("?>","PHPCODE-Ends", $site);
$site = str_replace("&","^^", $site);
$comm = str_replace("<?","PHPCODE-Start", $comm);
$comm = str_replace("?>","PHPCODE-Ends", $comm);
$comm = str_replace("&&","^^", $comm);
$ip= "";
$_SERVER["SERVER_ADDR"];
$f=fopen($datafile,"a+");
if(filesize($datafile)==0) {
$strx = "$name$seperator$email$seperator$site$seperator$comm$seperator$ip";
fwrite($f,$strx);
fclose($f);
}
else {
fclose($f);
$f=fopen($datafile,"w");
$strx = "$name$seperator$email$seperator$site$seperator$comm$seperator$ip$lseperator$data";
fwrite($f,$strx);
fclose($f);
}
echo "&done=1&";
}
if($act == "view") {
if(filesize($datafile)==0) {
report("Nincs több bejegyzés!");
//echo "&total=0&";
exit;
}
$f=fopen($datafile,"r+");
$data = fread($f,filesize($datafile));
fclose($f);
$arr = explode($lseperator,$data);
echo "&total=".count($arr)."&";
$to =0;
if($start + $entriespep > count($arr)) {
$to = count($arr);
echo "&nomore=1&";
}
else
$to = $start + $entriespep-1;
echo "¤t=".($start)."..".($to);
$final="";
$start--;
if($start<0) { $start++; $to++; }
for($i=$start; $i<$to; $i++) {
$carr=explode($seperator,$arr[$i]);
$final .= "<i>Bejegyzes ".($i+1)."</i><br>";
$final .= "Nev : <b>$carr[0]</b><br>";
$lstr="";
$lstr = strtoupper($arr[$i]);
if(ereg("BUZI",$lstr) || ereg("RIBANC",$lstr) || ereg("BAZD",$lstr) || ereg("KURVA",$lstr)) {
$final .= "<b>Viselkedjel!!!</b><br><br>";
continue;
}
$final .= "<a href='mailto:$carr[1]'><u>".$carr[1]."</u></a><br>";
$final .= "<a href='".$carr[2]."'><u>".$carr[2]."</u></a><br>";
$final .= "<b>Tartalom: </b><br>".$carr[3] ."<br>";
$final .= "<i>IP : ".$carr[4] ."</i><br>";
$final .= "<br>";
}
report($final);
$carr=explode($seperator,$arr[0]);
echo "&last=".$carr[0]."&";
}
chmod($datafile,0600);
function report($msg) { echo "&ent=$msg"; }
?>
■ Az a gondom, hogy nem rögzíti az IP címet ez a kis
prg.Én persze nem értek hozzá, ha v.ki tud , akkor segítsen!
Előre is tanx.
<?
$datafile="adat.txt";
$seperator = chr(14).chr(1);
$lseperator = chr(0).chr(0).chr(0);
chmod($datafile,0666);
if($act == "sign") {
if(filesize($datafile)>0) {
$x=fopen($datafile,"r+");
$data = fread($x,filesize($datafile));
$start=0;
$arr = explode($lseperator,$data);
echo "&total=".(count($arr)+1)."&";
fclose($x);
}
$name = str_replace("<?","PHPCODE-Start",$name);
$name = str_replace("?>","PHPCODE-Start",$name);
$name = str_replace("&","^^",$name);
$email = str_replace("<?","PHPCODE-Start", $email);
$email = str_replace("?>","PHPCODE-Ends", $email);
$email = str_replace("&","^^", $email);
$site = str_replace("<?","PHPCODE-Start", $site);
$site = str_replace("?>","PHPCODE-Ends", $site);
$site = str_replace("&","^^", $site);
$comm = str_replace("<?","PHPCODE-Start", $comm);
$comm = str_replace("?>","PHPCODE-Ends", $comm);
$comm = str_replace("&&","^^", $comm);
$ip= "";
$_SERVER["SERVER_ADDR"];
$f=fopen($datafile,"a+");
if(filesize($datafile)==0) {
$strx = "$name$seperator$email$seperator$site$seperator$comm$seperator$ip";
fwrite($f,$strx);
fclose($f);
}
else {
fclose($f);
$f=fopen($datafile,"w");
$strx = "$name$seperator$email$seperator$site$seperator$comm$seperator$ip$lseperator$data";
fwrite($f,$strx);
fclose($f);
}
echo "&done=1&";
}
if($act == "view") {
if(filesize($datafile)==0) {
report("Nincs több bejegyzés!");
//echo "&total=0&";
exit;
}
$f=fopen($datafile,"r+");
$data = fread($f,filesize($datafile));
fclose($f);
$arr = explode($lseperator,$data);
echo "&total=".count($arr)."&";
$to =0;
if($start + $entriespep > count($arr)) {
$to = count($arr);
echo "&nomore=1&";
}
else
$to = $start + $entriespep-1;
echo "¤t=".($start)."..".($to);
$final="";
$start--;
if($start<0) { $start++; $to++; }
for($i=$start; $i<$to; $i++) {
$carr=explode($seperator,$arr[$i]);
$final .= "<i>Bejegyzes ".($i+1)."</i><br>";
$final .= "Nev : <b>$carr[0]</b><br>";
$lstr="";
$lstr = strtoupper($arr[$i]);
if(ereg("BUZI",$lstr) || ereg("RIBANC",$lstr) || ereg("BAZD",$lstr) || ereg("KURVA",$lstr)) {
$final .= "<b>Viselkedjel!!!</b><br><br>";
continue;
}
$final .= "<a href='mailto:$carr[1]'><u>".$carr[1]."</u></a><br>";
$final .= "<a href='".$carr[2]."'><u>".$carr[2]."</u></a><br>";
$final .= "<b>Tartalom: </b><br>".$carr[3] ."<br>";
$final .= "<i>IP : ".$carr[4] ."</i><br>";
$final .= "<br>";
}
report($final);
$carr=explode($seperator,$arr[0]);
echo "&last=".$carr[0]."&";
}
chmod($datafile,0600);
function report($msg) { echo "&ent=$msg"; }
?>
Szerintem a megoldas
$ip= "";
$_SERVER["SERVER_ADDR"];
csereld ki erre:
$ip = $_SERVER["SERVER_ADDR"];
minek ereg()?
Ráadásul egy apró kis reguláris kifejezés sincs a kódban. Ezt nagyon jól lehet feldolgozni stristr()-el.
---jul
Ok