[ PHP ] Save Log IP V.2
<?php
$BlockedIPs = Array('Your IP here');
$Unique = 1;
$Time = Date("g:i a") . ' on ' . Date("m/d/Y");
$IP = $_SERVER['REMOTE_ADDR'];
$Port = $_SERVER['REMOTE_PORT'];
$Data = "Received at $Time\nIP Address: $IP\nAccessed through Port $Port\nhttp://www.ip-tracker.org/locator/ip-lookup.php?ip=$IP\n\n";
$Log = 'ip_log.txt';
$Contents = File_Get_Contents($Log);
If($Unique == 1){
If(!strpos($Contents, $IP)){
If(!In_Array($IP, $BlockedIPs)){
$File = FOpen($Log, 'a+');
FWrite($File, $Data);
FClose($File);
}
}
Else{
Die('An unexpected error has occurred.');
}
}
ElseIf($Unique == 0){
$File = FOpen($Log, 'a+');
FWrite($File, $Data);
FClose($File);
}
?>
$BlockedIPs = Array('Your IP here');
$Unique = 1;
$Time = Date("g:i a") . ' on ' . Date("m/d/Y");
$IP = $_SERVER['REMOTE_ADDR'];
$Port = $_SERVER['REMOTE_PORT'];
$Data = "Received at $Time\nIP Address: $IP\nAccessed through Port $Port\nhttp://www.ip-tracker.org/locator/ip-lookup.php?ip=$IP\n\n";
$Log = 'ip_log.txt';
$Contents = File_Get_Contents($Log);
If($Unique == 1){
If(!strpos($Contents, $IP)){
If(!In_Array($IP, $BlockedIPs)){
$File = FOpen($Log, 'a+');
FWrite($File, $Data);
FClose($File);
}
}
Else{
Die('An unexpected error has occurred.');
}
}
ElseIf($Unique == 0){
$File = FOpen($Log, 'a+');
FWrite($File, $Data);
FClose($File);
}
?>
[ PHP ] Save Log IP V.2
Reviewed by Nguyen Nam Hong
on
11:20 PM
Rating: