Skip to content

Commit 4e40d8d

Browse files
authored
Add files via upload
1 parent 0daa415 commit 4e40d8d

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed

access.class.php

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
3+
class Access
4+
{
5+
/** List of Browsers */
6+
public $browsers = array(
7+
'/msie/i' => 'Internet Explorer',
8+
'/firefox/i' => 'Firefox',
9+
'/safari/i' => 'Safari',
10+
'/chrome/i' => 'Chrome',
11+
'/edge/i' => 'Edge',
12+
'/opera/i' => 'Opera',
13+
'/netscape/i' => 'Netscape',
14+
'/maxthon/i' => 'Maxthon',
15+
'/konqueror/i' => 'Konqueror',
16+
'/mobile/i' => 'Handheld Browser'
17+
);
18+
19+
/** List of OSs */
20+
public $OS = array(
21+
'/windows nt 10/i' => 'Windows 10',
22+
'/windows nt 6.3/i' => 'Windows 8.1',
23+
'/windows nt 6.2/i' => 'Windows 8',
24+
'/windows nt 6.1/i' => 'Windows 7',
25+
'/windows nt 6.0/i' => 'Windows Vista',
26+
'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
27+
'/windows nt 5.1/i' => 'Windows XP',
28+
'/windows xp/i' => 'Windows XP',
29+
'/windows nt 5.0/i' => 'Windows 2000',
30+
'/windows me/i' => 'Windows ME',
31+
'/win98/i' => 'Windows 98',
32+
'/win95/i' => 'Windows 95',
33+
'/win16/i' => 'Windows 3.11',
34+
'/macintosh|mac os x/i' => 'Mac OS X',
35+
'/mac_powerpc/i' => 'Mac OS 9',
36+
'/linux/i' => 'Linux',
37+
'/ubuntu/i' => 'Ubuntu',
38+
'/iphone/i' => 'iPhone',
39+
'/ipod/i' => 'iPod',
40+
'/ipad/i' => 'iPad',
41+
'/android/i' => 'Android',
42+
'/blackberry/i' => 'BlackBerry',
43+
'/webos/i' => 'Mobile'
44+
);
45+
46+
/** List of Crawlers */
47+
public $crawlers = array(
48+
'/google/i' => 'Google',
49+
'/msnbot/i' => 'MSN',
50+
'/Rambler/i' => 'Rambler',
51+
'/Yahoo/i' => 'Yahoo',
52+
'/AbachoBOT/i' => 'AbachoBOT',
53+
'/Accoona/i' => 'Accoona',
54+
'/AcoiRobot/i' => 'AcoiRobot',
55+
'/ASPSeek/i' => 'ASPSeek',
56+
'/CrocCrawler/i' => 'CrocCrawler',
57+
'/Dumbot/i' => 'Dumbot',
58+
'/FAST-WebCrawler/i' => 'FAST-WebCrawler',
59+
'/GeonaBot/i' => 'GeonaBot',
60+
'/Gigabot/i' => 'Gigabot',
61+
'/Lycos/i' => 'Lycos spider',
62+
'/MSRBOT/i' => 'MSRBOT',
63+
'/Scooter/i' => 'Altavista robot',
64+
'/Altavista/i' => 'AltaVista robot',
65+
'/IDBot/i' => 'ID-Search Bot',
66+
'/eStyle/i' => 'eStyle Bot',
67+
'/Scrubby/i' => 'Scrubby robot'
68+
);
69+
70+
/** Info array */
71+
private $access = array();
72+
73+
public function __construct()
74+
{
75+
$this->access['browser'] = $this->getBrowser();
76+
$this->access['browserVersion'] = $this->getBrowserVersion();
77+
$this->access['OS'] = $this->getOS();
78+
$this->access['robot'] = $this->getRobot();
79+
$this->access['referer'] = $_SERVER['HTTP_REFERER'];
80+
$this->access['time'] = time();
81+
}
82+
83+
private function getBrowser()
84+
{
85+
foreach ($this->browsers as $regex => $name) {
86+
if (preg_match($regex, $_SERVER['HTTP_USER_AGENT'])) {
87+
return $name;
88+
}
89+
}
90+
return "Unknown";
91+
}
92+
93+
private function getBrowserVersion()
94+
{
95+
$data = explode("/", $_SERVER['HTTP_USER_AGENT']);
96+
return $data[count($data) - 1];
97+
}
98+
99+
private function getOS()
100+
{
101+
foreach ($this->OS as $regex => $name) {
102+
if (preg_match($regex, $_SERVER['HTTP_USER_AGENT'])) {
103+
return $name;
104+
}
105+
}
106+
return "Unknown";
107+
}
108+
109+
private function getRobot()
110+
{
111+
foreach ($this->crawlers as $regex => $name) {
112+
if (preg_match($regex, $_SERVER['HTTP_USER_AGENT'])) {
113+
return $name;
114+
}
115+
}
116+
return false;
117+
}
118+
119+
public function getInfo()
120+
{
121+
return $this->access;
122+
}
123+
}

0 commit comments

Comments
 (0)