1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the alphaz Framework. |
5
|
|
|
* |
6
|
|
|
* @author Muhammad Umer Farooq (Malik) <[email protected]> |
7
|
|
|
* |
8
|
|
|
* @link https://github.com/alphazframework/framework |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
* @since 1.0.0 |
13
|
|
|
* |
14
|
|
|
* @license MIT |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace alphaz\UserInfo; |
18
|
|
|
|
19
|
|
|
class UserInfo |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Get user agente. |
23
|
|
|
* |
24
|
|
|
* @since 1.0.0 |
25
|
|
|
* |
26
|
|
|
* @return agent |
|
|
|
|
27
|
|
|
*/ |
28
|
|
|
public static function agent() |
29
|
|
|
{ |
30
|
|
|
return $_SERVER['HTTP_USER_AGENT']; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get OperatingSystem name. |
35
|
|
|
* |
36
|
|
|
* @since 1.0.0 |
37
|
|
|
* |
38
|
|
|
* @return void |
39
|
|
|
*/ |
40
|
|
|
public function operatingSystem() |
41
|
|
|
{ |
42
|
|
|
$UserAgent = self::agent(); |
43
|
|
|
if (preg_match_all('/windows/i', $UserAgent)) { |
44
|
|
|
$PlatForm = 'Windows'; |
45
|
|
|
} elseif (preg_match_all('/linux/i', $UserAgent)) { |
46
|
|
|
$PlatForm = 'Linux'; |
47
|
|
|
} elseif (preg_match('/macintosh|mac os x/i', $UserAgent)) { |
48
|
|
|
$PlatForm = 'Macintosh'; |
49
|
|
|
} elseif (preg_match_all('/Android/i', $UserAgent)) { |
50
|
|
|
$PlatForm = 'Android'; |
51
|
|
|
} elseif (preg_match_all('/iPhone/i', $UserAgent)) { |
52
|
|
|
$PlatForm = 'IOS'; |
53
|
|
|
} elseif (preg_match_all('/ubuntu/i', $UserAgent)) { |
54
|
|
|
$PlatForm = 'Ubuntu'; |
55
|
|
|
} else { |
56
|
|
|
$PlatForm = 'unknown'; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
return $PlatForm; |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Get Browser Name. |
64
|
|
|
* |
65
|
|
|
* @since 1.0.0 |
66
|
|
|
* |
67
|
|
|
* @return void |
68
|
|
|
*/ |
69
|
|
|
public function browser() |
70
|
|
|
{ |
71
|
|
|
$UserAgent = self::agent(); |
72
|
|
|
if (preg_match_all('/Edge/i', $UserAgent)) { |
73
|
|
|
$Browser = 'Microsoft Edge'; |
74
|
|
|
$B_Agent = 'Edge'; |
75
|
|
|
} elseif (preg_match_all('/MSIE/i', $UserAgent)) { |
76
|
|
|
$Browser = 'Mozilla Firefox'; |
77
|
|
|
$B_Agent = 'Firefox'; |
78
|
|
|
} elseif (preg_match_all('/OPR/i', $UserAgent)) { |
79
|
|
|
$Browser = 'Opera'; |
80
|
|
|
$B_Agent = 'Opera'; |
81
|
|
|
} elseif (preg_match_all('/Opera/i', $UserAgent)) { |
82
|
|
|
$Browser = 'Opera'; |
83
|
|
|
$B_Agent = 'Opera'; |
84
|
|
|
} elseif (preg_match_all('/Chrome/i', $UserAgent)) { |
85
|
|
|
$Browser = 'Google Chrome'; |
86
|
|
|
$B_Agent = 'Chrome'; |
87
|
|
|
} elseif (preg_match_all('/Safari/i', $UserAgent)) { |
88
|
|
|
$Browser = 'Apple Safari'; |
89
|
|
|
$B_Agent = 'Safari'; |
90
|
|
|
} elseif (preg_match_all('/firefox/i', $UserAgent)) { |
91
|
|
|
$Browser = 'Mozilla Firefox'; |
92
|
|
|
$B_Agent = 'Firefox'; |
93
|
|
|
} else { |
94
|
|
|
$Browser = null; |
95
|
|
|
$B_Agent = null; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
return [ |
|
|
|
|
99
|
|
|
'browser' => $Browser, |
100
|
|
|
'agent' => $B_Agent, |
101
|
|
|
]; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Get Os version. |
106
|
|
|
* |
107
|
|
|
* @since 1.0.0 |
108
|
|
|
* |
109
|
|
|
* @return void |
110
|
|
|
*/ |
111
|
|
|
public function oSVersion() |
112
|
|
|
{ |
113
|
|
|
$UserAgent = self::agent(); |
114
|
|
|
if (preg_match_all('/windows nt 10/i', $UserAgent)) { |
115
|
|
|
$OsVersion = 'Windows 10'; |
116
|
|
|
} elseif (preg_match_all('/windows nt 6.3/i', $UserAgent)) { |
117
|
|
|
$OsVersion = 'Windows 8.1'; |
118
|
|
|
} elseif (preg_match_all('/windows nt 6.2/i', $UserAgent)) { |
119
|
|
|
$OsVersion = 'Windows 8'; |
120
|
|
|
} elseif (preg_match_all('/windows nt 6.1/i', $UserAgent)) { |
121
|
|
|
$OsVersion = 'Windows 7'; |
122
|
|
|
} elseif (preg_match_all('/windows nt 6.0/i', $UserAgent)) { |
123
|
|
|
$OsVersion = 'Windows Vista'; |
124
|
|
|
} elseif (preg_match_all('/windows nt 5.1/i', $UserAgent)) { |
125
|
|
|
$OsVersion = 'Windows Xp'; |
126
|
|
|
} elseif (preg_match_all('/windows xp/i', $UserAgent)) { |
127
|
|
|
$OsVersion = 'Windows Xp'; |
128
|
|
|
} elseif (preg_match_all('/windows me/i', $UserAgent)) { |
129
|
|
|
$OsVersion = 'Windows Me'; |
130
|
|
|
} elseif (preg_match_all('/win98/i', $UserAgent)) { |
131
|
|
|
$OsVersion = 'Windows 98'; |
132
|
|
|
} elseif (preg_match_all('/win95/i', $UserAgent)) { |
133
|
|
|
$OsVersion = 'Windows 95'; |
134
|
|
|
} elseif (preg_match_all('/Windows Phone +[0-9]/i', $UserAgent, $match)) { |
135
|
|
|
$OsVersion = $match; |
136
|
|
|
} elseif (preg_match_all('/Android +[0-9]/i', $UserAgent, $match)) { |
137
|
|
|
$OsVersion = $match; |
138
|
|
|
} elseif (preg_match_all('/Linux +x[0-9]+/i', $UserAgent, $match)) { |
139
|
|
|
$OsVersion = $match; |
140
|
|
|
} elseif (preg_match_all('/mac os x [0-9]+/i', $UserAgent, $match)) { |
141
|
|
|
$OsVersion = $match; |
142
|
|
|
} elseif (preg_match_all('/os [0-9]+/i', $UserAgent, $match)) { |
143
|
|
|
$OsVersion = $match; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
return isset($OsVersion) ? $OsVersion : false; |
|
|
|
|
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Get Browser version. |
151
|
|
|
* |
152
|
|
|
* @since 1.0.0 |
153
|
|
|
* |
154
|
|
|
* @return void |
155
|
|
|
*/ |
156
|
|
|
public function browserVersion() |
157
|
|
|
{ |
158
|
|
|
$UserAgent = self::agent(); |
159
|
|
|
$B_Agent = self::Browser()['agent']; |
|
|
|
|
160
|
|
|
if ($B_Agent !== null) { |
161
|
|
|
$known = ['Version', $B_Agent, 'other']; |
162
|
|
|
$pattern = '#(?<browser>'.implode('|', $known). |
163
|
|
|
')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#'; |
164
|
|
|
if (!preg_match_all($pattern, $UserAgent, $matches)) { |
165
|
|
|
} |
166
|
|
|
$i = count($matches['browser']); |
167
|
|
|
if ($i != 1) { |
168
|
|
|
if (strripos($UserAgent, 'Version') < strripos($UserAgent, $B_Agent)) { |
169
|
|
|
$Version = $matches['version'][0]; |
170
|
|
|
} else { |
171
|
|
|
$Version = $matches['version'][0]; |
172
|
|
|
} |
173
|
|
|
} else { |
174
|
|
|
$Version = $matches['version'][0]; |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
return $Version; |
|
|
|
|
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Get The user ip. |
183
|
|
|
* |
184
|
|
|
* @since 1.0.0 |
185
|
|
|
* |
186
|
|
|
* @return void |
187
|
|
|
*/ |
188
|
|
|
public function ip() |
189
|
|
|
{ |
190
|
|
|
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
191
|
|
|
$ip_add = $_SERVER['HTTP_CLIENT_IP']; |
192
|
|
|
} elseif (!empty($_SERVER['HTTP_X_FORWADED_FOR'])) { |
193
|
|
|
$ip_add = $_SERVER['HTTP_X_FORWADED_FOR']; |
194
|
|
|
} else { |
195
|
|
|
$ip_add = $_SERVER['REMOTE_ADDR']; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
return $ip_add; |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths