-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd_ipaddress.php
36 lines (28 loc) · 940 Bytes
/
add_ipaddress.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
36
<?php
function get_visitor_ip()
{
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}
return $ip;
}
$visitor_ipaddress = mysql_real_escape_string(get_visitor_ip());
$page_url= mysql_real_escape_string($_SERVER['REQUEST_URI']);
$query= "INSERT INTO `db_coding_solutions`.`visitor_ipaddress` (`sno`, `ipaddress`, `timestamp`, `url`) VALUES (NULL, '".$visitor_ipaddress."', CURRENT_TIMESTAMP, '".$page_url."')";
if(!(@$query_run= mysql_query($query)) )
{
die('Please Try Later!');
}
?>