-
Notifications
You must be signed in to change notification settings - Fork 1
/
counter.php
132 lines (98 loc) · 4.4 KB
/
counter.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/**
* Allomani E-Store v1.0
*
* @package Allomani.E-Store
* @version 1.0
* @copyright (c) 2006-2018 Allomani , All rights reserved.
* @author Ali Allomani <info@allomani.com>
* @link http://allomani.com
* @license GNU General Public License version 3.0 (GPLv3)
*
*/
$http_agent = getenv("HTTP_USER_AGENT") ;
if($settings['count_visitors_info']){
//------------------- Get Browser info ------------
if(stristr( $http_agent,"MSIE")) $browser = "MSIE";
elseif(stristr( $http_agent,"Chrome")) $browser = "Chrome";
elseif(stristr( $http_agent,"Firefox")) $browser = "Firefox";
elseif(stristr( $http_agent,"Nokia")) $browser = "Nokia";
elseif(stristr( $http_agent,"BlackBerry")) $browser = "BlackBerry";
elseif(stristr( $http_agent,"iPhone")) $browser = "iPhone";
elseif(stristr( $http_agent,"iPod")) $browser = "iPod";
elseif(stristr( $http_agent,"Android")) $browser = "Android";
elseif(stristr( $http_agent,"Lynx")) $browser = "Lynx";
elseif(stristr( $http_agent,"Opera")) $browser = "Opera";
elseif(stristr( $http_agent,"WebTV")) $browser = "WebTV";
elseif(stristr( $http_agent,"Konqueror")) $browser = "Konqueror";
elseif((stristr( $http_agent,"Nav")) || (stristr( $http_agent,"Gold")) || (stristr( $http_agent,"X11")) || (stristr( $http_agent,"Mozilla")) || (stristr( $http_agent,"Netscape")) AND (!stristr( $http_agent,"MSIE") AND (!stristr( $http_agent,"Konqueror")))) $browser = "Netscape";
elseif((stristr( $http_agent,"bot")) || (stristr( $http_agent,"Google")) || (stristr( $http_agent,"Slurp")) || (stristr( $http_agent,"Scooter")) || (stristr( $http_agent,"Spider")) || (stristr( $http_agent,"Infoseek"))) $browser = "Bot";
else $browser = "Other";
//--------- Get Os info -------------------
if(stristr( $http_agent,"Win")) $os = "Windows";
elseif((stristr($http_agent,"Mac")) || (stristr( $http_agent,"PPC"))) $os = "Mac";
elseif(stristr( $http_agent,"Linux")) $os = "Linux";
elseif(stristr( $http_agent,"FreeBSD")) $os = "FreeBSD";
elseif(stristr( $http_agent,"SunOS")) $os = "SunOS";
elseif(stristr( $http_agent,"IRIX")) $os = "IRIX";
elseif(stristr( $http_agent,"BeOS")) $os = "BeOS";
elseif(stristr( $http_agent,"OS/2")) $os = "OS/2";
elseif(stristr( $http_agent,"AIX")) $os = "AIX";
elseif(stristr( $http_agent,"Symbian")) $os = "Symbian";
elseif(stristr( $http_agent,"BlackBerry")) $os = "BlackBerry";
else $os = "Other";
//-------- OS and Browser Info ------------
db_query("update info_browser set count=count+1 where name='$browser'");
db_query("update info_os set count=count+1 where name='$os'");
}
if($settings['count_visitors_hits']){
//------ Visitors Count ----------------
$dot = date("d-m-Y");
$result=db_query("select hits from info_hits where date='$dot'");
if (db_num($result)){
db_query("update info_hits set hits=hits+1 where date='$dot'");
}else{
db_query("insert into info_hits (date,hits) values ('$dot','1')");
}
}
if($settings['count_online_visitors']){
// ---- visitor timeout ----------------
if($online_visitor_timeout){
$timeoutseconds = intval($online_visitor_timeout);
}else{
$timeoutseconds=800;
}
$ip = getenv("REMOTE_ADDR");
// $ip = "213.25.52.40";
$time=time();
$timeout=$time-$timeoutseconds;
//$file=$_SERVER['PHP_SELF'];
db_query("DELETE FROM info_online WHERE time<$timeout");
//$sm=split("/",str_replace(".","/",$ip));
//$ip_max = trim("$sm[0].$sm[1].$sm[2]");
$ip_max = $ip ;
$result = db_query("SELECT * FROM info_online WHERE ip like '$ip_max%'");
if (db_num($result)) {
db_query("UPDATE info_online SET time='$time', ip='$ip' WHERE ip like '$ip_max%'");
} else {
db_query("INSERT INTO info_online (time,ip) VALUES ('$time', '$ip')");
}
//---------- Now Online Visitors ------------
$result=db_query("SELECT DISTINCT ip FROM info_online ");
$users=db_num($result);
//=========Best Visitors Record ==============================================
$now_dt = date("d-M-Y")." $phrases[the_hour] : " .date("H:i");
$data=db_qr_fetch("select v_count from info_best_visitors");
if ($users > $data['v_count']){
$counter['best_visit'] = $users ;
$counter['best_visit_time'] = $now_dt ;
db_query("update info_best_visitors set v_count='$users',time='$now_dt'");
}else{
$best=db_qr_fetch("select * from info_best_visitors");
$counter['best_visit'] = $best['v_count'] ;
$counter['best_visit_time'] = $best['time'];
}
//==========================================================================
$counter['online_users'] = $users ;
}
?>