-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.php
30 lines (23 loc) · 961 Bytes
/
log.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
<?php
function GetIP(){
if(!empty($_SERVER["REMOTE_ADDR"])){
$ip = $_SERVER["REMOTE_ADDR"];
}
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ips = explode (",", $_SERVER['HTTP_X_FORWARDED_FOR']);
if ($ip) { array_unshift($ips, $ip); $ip=FALSE; }
for ($i=0; $i < count($ips); $i++) {
if (!eregi ("^(10|172.16|192.168).", $ips[$i])) {
$ip=$ips[$i];
break;
}
}
}
return $ip;
}
function LogBook($page, $text){
$now = date("Y-m-d H:i:s", time());
$IP = GetIP();
mysql_query("INSERT INTO `log` (`logTime`, `page`, `message`, `IP`) VALUES('{$now}', '{$page}', '{$text}', '{$IP}');");
}
?>