Joined: Jul 30, 2003 Posts: 551 Location: Neurotic, State, USA
Posted:
Sun Dec 14, 2003 1:27 am
Ok, I have created a page that a ban user is redirected to when they try to access the site. Now, what I want to do is log their ip from this page by writing to a .txt .
This is what I have so far and it works as far as telling them the IP has been log as well as showing the IP, but I can't get the script to write to the .txt.
Code:
$log_file = "ip.txt";
$ip = getenv('REMOTE_ADDR');
$fp = fopen("$log_file", "a");
fputs($fp, "$iprn");
flock($fp, 3);
fclose($fp);
PRINT("Your Ip was logged.....$ip");
Joined: Jul 30, 2003 Posts: 551 Location: Neurotic, State, USA
Posted:
Sun Dec 14, 2003 1:58 pm
Quote:
What is $iprn?
LOL! You know what that was? It was the reason the script would not write to the text file! LOL! I used this code for something else and I forgot to change it . It should have been just $ip
But I think I may use your spruced up version anyway!
Joined: Jul 30, 2003 Posts: 551 Location: Neurotic, State, USA
Posted:
Sun Dec 14, 2003 11:07 pm
Well I had to change a few things in your code, but I have it working nicely now. I'm not a script writer, so if you see anything wrong with the way I have change it please tell me.
Working functions are:
Tells the visitor their ip has been logged & shows it to them.
Writes to the .txt or .csv file.
Sends email with the IP within the message.
Code:
$to = 'YOUR_EMAIL_ADDRESS';
$subject = 'Logging Failure Notice';
$msg = 'System was unable to write to the banned log file';
$log_file = "ip.txt";
$ip = getenv('REMOTE_ADDR');
$fp = @fopen("$log_file", "a");
if (!$fp) @mail($to, $subject, "$msg, $ip","From: $admin_email_address");
@flock($fp,2);
if(@fwrite($fp, "$ip, "));
PRINT("<b>Your IP has been logged.....$ip</b>");
@mail($to, $subject, "$msg, $ip","From: $admin_email_address");
@flock($fp, 3);
@fclose($fp);
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum