|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* m'Manager | Invoices Management System |
|
5
|
|
|
* |
|
6
|
|
|
* This content is released under the Proprietary License (Proprietary) |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright (c) 2017, Eric Claver AKAFFOU - All Rights Reserved |
|
9
|
|
|
* Unauthorized copying of this file, via any medium is strictly prohibited |
|
10
|
|
|
* Proprietary and confidential |
|
11
|
|
|
* |
|
12
|
|
|
* @package m'Manager |
|
13
|
|
|
* @author Eric Claver AKAFFOU |
|
14
|
|
|
* @copyright Copyright (c) 2017, on'Eric Computing, Inc. (https://www.onericcomputing.com/) |
|
15
|
|
|
* @license https://www.mmanager.fr Proprietary License |
|
16
|
|
|
* @link https://codecanyon.net/item/mmanager-invoices-management-system/19866435?s_rank=1 |
|
17
|
|
|
* @since Version 1.0.0 |
|
18
|
|
|
* @filesource |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace Mmanager\Utils; |
|
22
|
|
|
|
|
23
|
|
|
class UserAgent |
|
24
|
|
|
{ |
|
25
|
|
|
protected $UserAgent; |
|
26
|
|
|
protected $UserIP; |
|
27
|
|
|
|
|
28
|
|
|
public function __construct() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->UserAgent = $_SERVER['HTTP_USER_AGENT']; |
|
31
|
|
|
$this->UserIP = $this->__getUserIP(); |
|
32
|
|
|
} |
|
33
|
|
|
/** |
|
34
|
|
|
* @return mixed |
|
35
|
|
|
*/ |
|
36
|
|
|
public function getUserAgent() |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->UserAgent; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param mixed $UserAgent |
|
43
|
|
|
* |
|
44
|
|
|
* @return self |
|
45
|
|
|
*/ |
|
46
|
|
|
public function setUserAgent($UserAgent) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->UserAgent = $UserAgent; |
|
49
|
|
|
|
|
50
|
|
|
return $this; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @return mixed |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getUserIP() |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->UserIP; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param mixed $UserIP |
|
63
|
|
|
* |
|
64
|
|
|
* @return self |
|
65
|
|
|
*/ |
|
66
|
|
|
public function setUserIP($UserIP) |
|
67
|
|
|
{ |
|
68
|
|
|
$this->UserIP = $UserIP; |
|
69
|
|
|
|
|
70
|
|
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
private function __getUserIP() |
|
73
|
|
|
{ |
|
74
|
|
|
// Get real visitor IP behind CloudFlare network |
|
75
|
|
|
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { |
|
76
|
|
|
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; |
|
77
|
|
|
$_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; |
|
78
|
|
|
} |
|
79
|
|
|
$client = @$_SERVER['HTTP_CLIENT_IP']; |
|
80
|
|
|
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; |
|
81
|
|
|
$remote = $_SERVER['REMOTE_ADDR']; |
|
82
|
|
|
|
|
83
|
|
|
if(filter_var($client, FILTER_VALIDATE_IP)) |
|
84
|
|
|
{ |
|
85
|
|
|
$ip = $client; |
|
86
|
|
|
} |
|
87
|
|
|
elseif(filter_var($forward, FILTER_VALIDATE_IP)) |
|
88
|
|
|
{ |
|
89
|
|
|
$ip = $forward; |
|
90
|
|
|
} |
|
91
|
|
|
else |
|
92
|
|
|
{ |
|
93
|
|
|
$ip = $remote; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
return $ip; |
|
97
|
|
|
} |
|
98
|
|
|
} |