Skip to content
This repository was archived by the owner on Apr 9, 2023. It is now read-only.

Commit 7316c32

Browse files
committed
Remove unnecessary code
1 parent e562661 commit 7316c32

File tree

1 file changed

+13
-32
lines changed

1 file changed

+13
-32
lines changed

analytics.php

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111

1212
class b1_analytics {
13-
public $a = array();
1413
public $s = null;
1514
public $h = null;
1615
public $d = null;
@@ -44,8 +43,6 @@ class b1_analytics {
4443
public $r_domain = null;
4544
public $r_accept = null;
4645
public $u_port = null;
47-
public $domain = null;
48-
public $anonymous_ip = null;
4946

5047
function get_row_count($query, $mysql) {
5148
$count = 0;
@@ -124,23 +121,15 @@ function endsWith($haystack, $needle) {
124121

125122
// Checks user agent and hostname to find out whether the visitor is a bot
126123
function getbot() {
127-
$bot = 0;
128-
if(preg_match('/googlebot/i', $this->ua) && ($this->endsWith($this->u_host, ".googlebot.com") || $this->endsWith($this->u_host, ".google.com"))) {
129-
$bot = 1;
130-
} elseif (preg_match('/bingbot/i', $this->ua) && $this->endsWith($this->u_host, ".search.msn.com")) {
131-
$bot = 1;
132-
} elseif ((preg_match('/yandexbot/i', $this->ua) || preg_match('/yandeximages/i', $this->ua)) && $this->endsWith($this->u_host, ".yandex.com")) {
133-
$bot = 1;
134-
} elseif (preg_match('/baiduspider/i', $this->ua) && $this->endsWith($this->u_host, ".crawl.baidu.com")) {
135-
$bot = 1;
136-
} elseif ((preg_match('/duckduckbot/i', $this->ua) || preg_match('/duckduckgo/i', $this->ua)) && $this->startsWith($this->u_host, "72.94.249.")) {
137-
$bot = 1;
138-
} elseif (preg_match('/archive.org_bot/i', $this->ua) && $this->endsWith($this->u_host, ".archive.org")) {
139-
$bot = 1;
124+
if((preg_match('/googlebot/i', $this->ua) && ($this->endsWith($this->u_host, ".googlebot.com") || $this->endsWith($this->u_host, ".google.com"))) ||
125+
(preg_match('/bingbot/i', $this->ua) && $this->endsWith($this->u_host, ".search.msn.com")) ||
126+
(preg_match('/yandexbot/i', $this->ua) || preg_match('/yandeximages/i', $this->ua)) && $this->endsWith($this->u_host, ".yandex.com") ||
127+
(preg_match('/baiduspider/i', $this->ua) && $this->endsWith($this->u_host, ".crawl.baidu.com")) ||
128+
((preg_match('/duckduckbot/i', $this->ua) || preg_match('/duckduckgo/i', $this->ua)) && $this->startsWith($this->u_host, "72.94.249.")) ||
129+
(preg_match('/archive.org_bot/i', $this->ua) && $this->endsWith($this->u_host, ".archive.org"))) {
130+
$this->u_bot = 1;
140131
}
141-
$this->u_bot = $bot;
142-
$bot_array = array(
143-
'/googlebot/i' => 'Google',
132+
$bot_array = array('/googlebot/i' => 'Google',
144133
'/bingbot/i' => 'Bing',
145134
'/twitterbot/i' => 'Twitter',
146135
'/baiduspider/i' => 'Baidu',
@@ -158,7 +147,6 @@ function getbot() {
158147

159148
// Gets the os name and version from the user agent
160149
function getos() {
161-
$os_platform = null;
162150
$os_array = array('/windows nt/i' => 'Windows',
163151
'/windows nt 10/i' => 'Windows 10',
164152
'/windows nt 6.3/i' => 'Windows 8.1',
@@ -201,15 +189,13 @@ function getos() {
201189
);
202190
foreach ($os_array as $regex => $value) {
203191
if (preg_match($regex, $this->ua)) {
204-
$os_platform = $value;
192+
$this->u_os = $value;
205193
}
206194
}
207-
$this->u_os = $os_platform;
208195
}
209196

210197
// Gets the type of device from the user agent
211198
function getdevice() {
212-
$device = null;
213199
$device_array = array('/windows nt/i' => 'PC',
214200
'/windows xp/i' => 'PC',
215201
'/windows me/i' => 'PC',
@@ -241,15 +227,13 @@ function getdevice() {
241227
);
242228
foreach ($device_array as $regex => $value) {
243229
if (preg_match($regex, $this->ua)) {
244-
$device = $value;
230+
$this->u_device = $value;
245231
}
246232
}
247-
$this->u_device = $device;
248233
}
249234

250235
// Gets the browser name from the user agents
251236
function getbrowser() {
252-
$browser = null;
253237
$browser_array = array(
254238
'/mozilla/i' => 'Mozilla Compatible Agent',
255239
'/applewebkit/i' => 'AppleWebKit Agent',
@@ -284,19 +268,16 @@ function getbrowser() {
284268
);
285269
foreach ($browser_array as $regex => $value) {
286270
if (preg_match($regex, $this->ua)) {
287-
$browser = $value;
271+
$this->u_browser = $value;
288272
}
289273
}
290-
$this->user_browser = $browser;
291274
}
292275

293276
// Checks whether the visitor uses a mobile device using the user agent
294277
function getmobile() {
295-
$mobile = null;
296278
if (preg_match('/mobile/i', $this->ua)) {
297-
$mobile = 1;
279+
$this->u_mobile = 1;
298280
}
299-
$this->u_mobile = $mobile;
300281
}
301282

302283
// Gets user language and country from hostname and http header
@@ -537,7 +518,7 @@ function getrequest($mysql) {
537518
if(isset($this->s["REQUEST_URI"])) {
538519
$uri = $this->s["REQUEST_URI"];
539520
if($uri != null && $uri != "" && $uri != "/") {
540-
$this->r_target = $this->s["REQUEST_URI"];
521+
$this->r_target = $uri;
541522
}
542523
}
543524
if(isset($this->s["HTTP_REFERER"])) {

0 commit comments

Comments
 (0)