-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhit_count.php
54 lines (49 loc) · 910 Bytes
/
hit_count.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
require "coonectmysql.php";
$user_ip=$_SERVER['REMOTE_ADDR'];
function ip_exist($ip)
{
global $user_ip;
$query="select * from `hit_ips` where `ips`='$ip'";
if(@$query_run=mysql_query($query))
{
if(mysql_num_rows($query_run)==0)
return 1;
}
else if (mysql_num_rows($query_run)>=1) {
# code...
return 0;
}
else
{
echo mysql_error();
}
}
function update_ips($user_ip)
{
$query="insert into `hit_ips` values('$user_ip')";
if(@$query_run=mysql_query($query))
{
echo "ok";
}
}
function update_count()
{
$query="SELECT `Hit_Count` FROM `hit_counts` WHERE 1";
if($query_run=mysql_query($query))
{
$result=mysql_result($query_run,0,'Hit_Count');
$result_inc=$result+1;
echo $result_inc;
if(@$query_run=mysql_run("update `hit_counts` set `Hit_Count`='$result'"))
{
echo "count updated";
}
}
}
if(ip_exist($user_ip))
{
update_ips($user_ip);
update_count();
}
?>