Page 1 of 1

need help with fwrite

Posted: Wed Jan 18, 2006 9:05 pm
by nickman013
ok this is my script

Code: Select all

<?php
$snf = str_replace(" ", "", $sn);
if ("nickman013" == $snf) header('Location:/nvideos/Password.php');
if(gotti1 == $page) include("GottiVideo.php");
if(gotti2 == $page) include("/GottiVideo2.php");
if ($_SERVER['remote_addr']  != '68.195.158.89') {
$date = date("F j, Y, g:i a");
$sn2 = "$snf";
$ip = @$REMOTE_ADDR; 
$filename = 'visit_log.htm'; 
$somecontent = "<tr><td align=center>$sn2</td><td align=center>$page</td><td align=center>$date</td><td align=center>$ip</td></tr>"; 
if (is_writable($filename)) { 
if (!$handle = fopen($filename, 'a')) { 
echo "Cannot open file ($filename)"; 
exit; 
} 
if (fwrite($handle, $somecontent) === FALSE) { 
echo "Cannot write to file ($filename)"; 
exit; 
} 
echo "Success $filename"; 
fclose($handle); 
} else { 
echo "The file $filename is not writable"; 
} 
}
?>


i dont want it to log me in the log..

thank you

Posted: Wed Jan 18, 2006 9:09 pm
by josh
run this code in a seperate file

Code: Select all

if ($_SERVER['remote_addr']  != '68.195.158.89') {
   var_dump($_SERVER['remote_addr']);
} else {
   echo 'detecting ip correctly';
}
what do you get


edit - do'h, remote_addr is case sensitive, change it to REMOTE_ADDR

Posted: Wed Jan 18, 2006 9:52 pm
by nickman013
this is solved, anybody following this thread, the final script is

Code: Select all

<?php 
$snf = str_replace(" ", "", $sn); 
if ("nickman013" == $snf) header('Location:/nvideos/Password.php'); 
if(gotti1 == $page) include("GottiVideo.php"); 
if(gotti2 == $page) include("/GottiVideo2.php"); 
if ($_SERVER['remote_addr']  != '68.195.158.89') { 
$date = date("F j, Y, g:i a"); 
$sn2 = "$snf"; 
$ip = @$REMOTE_ADDR; 
$filename = 'visit_log.htm'; 
$somecontent = "<tr><td align=center>$sn2</td><td align=center>$page</td><td align=center>$date</td><td align=center>$ip</td></tr>"; 
if (is_writable($filename)) { 
if (!$handle = fopen($filename, 'a')) { 
echo "Cannot open file ($filename)"; 
exit; 
} 
if (fwrite($handle, $somecontent) === FALSE) { 
echo "Cannot write to file ($filename)"; 
exit; 
} 
echo "Success $filename"; 
fclose($handle); 
} else { 
echo "The file $filename is not writable"; 
} 
} 
?>
thanks to jshpro2, this problem was solved :)