-
Notifications
You must be signed in to change notification settings - Fork 7
/
IP-Logger.php
35 lines (32 loc) · 851 Bytes
/
IP-Logger.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
$realip = getRealIpAddr();
$log = 'log.html';
$ip = $_SERVER['REMOTE_ADDR'];
$page = $_SERVER['REQUEST_URI'];
$refer = $_SERVER['HTTP_REFERER'];
$date_time = date("l j F Y g:ia", time() - date("Z")) ;
$agent = $_SERVER['HTTP_USER_AGENT'];
$fp = fopen("log.html", "a");
fputs($fp, "
<b>$date_time</b> <br> <b>IP: </b>$ip<br><b>IP: </b>$realip<br><b>Page: </b>$page<br><b>Refer: </b>$refer<br><b>Useragent:
</b>$agent <br><br>
");
flock($fp, 3);
fclose($fp);
?>