Passed
Push — dependabot/composer/newinterna... ( 13eb18 )
by
unknown
04:37
created
includes/Providers/FakeLocationProvider.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@
 block discarded – undo
15 15
  */
16 16
 class FakeLocationProvider implements ILocationProvider
17 17
 {
18
-    public function getIpLocation($address)
19
-    {
20
-        return null;
21
-    }
18
+	public function getIpLocation($address)
19
+	{
20
+		return null;
21
+	}
22 22
 }
Please login to merge, or discard this patch.
includes/Providers/GlobalState/FakeGlobalStateProvider.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -18,28 +18,28 @@
 block discarded – undo
18 18
  */
19 19
 class FakeGlobalStateProvider extends GlobalStateProvider implements IGlobalStateProvider
20 20
 {
21
-    var $server = array();
22
-    var $get = array();
23
-    var $post = array();
24
-    var $session = array();
21
+	var $server = array();
22
+	var $get = array();
23
+	var $post = array();
24
+	var $session = array();
25 25
 
26
-    public function &getServerSuperGlobal()
27
-    {
28
-        return $this->server;
29
-    }
26
+	public function &getServerSuperGlobal()
27
+	{
28
+		return $this->server;
29
+	}
30 30
 
31
-    public function &getGetSuperGlobal()
32
-    {
33
-        return $this->get;
34
-    }
31
+	public function &getGetSuperGlobal()
32
+	{
33
+		return $this->get;
34
+	}
35 35
 
36
-    public function &getPostSuperGlobal()
37
-    {
38
-        return $this->post;
39
-    }
36
+	public function &getPostSuperGlobal()
37
+	{
38
+		return $this->post;
39
+	}
40 40
 
41
-    public function &getSessionSuperGlobal()
42
-    {
43
-        return $this->session;
44
-    }
41
+	public function &getSessionSuperGlobal()
42
+	{
43
+		return $this->session;
44
+	}
45 45
 }
46 46
\ No newline at end of file
Please login to merge, or discard this patch.
includes/Providers/GlobalState/IGlobalStateProvider.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -14,23 +14,23 @@
 block discarded – undo
14 14
  */
15 15
 interface IGlobalStateProvider
16 16
 {
17
-    /**
18
-     * @return array
19
-     */
20
-    public function getServerSuperGlobal();
17
+	/**
18
+	 * @return array
19
+	 */
20
+	public function getServerSuperGlobal();
21 21
 
22
-    /**
23
-     * @return array
24
-     */
25
-    public function getGetSuperGlobal();
22
+	/**
23
+	 * @return array
24
+	 */
25
+	public function getGetSuperGlobal();
26 26
 
27
-    /**
28
-     * @return array
29
-     */
30
-    public function getPostSuperGlobal();
27
+	/**
28
+	 * @return array
29
+	 */
30
+	public function getPostSuperGlobal();
31 31
 
32
-    /**
33
-     * @return array
34
-     */
35
-    public function getSessionSuperGlobal();
32
+	/**
33
+	 * @return array
34
+	 */
35
+	public function getSessionSuperGlobal();
36 36
 }
37 37
\ No newline at end of file
Please login to merge, or discard this patch.
includes/Providers/GlobalState/GlobalStateProvider.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -18,35 +18,35 @@
 block discarded – undo
18 18
  */
19 19
 class GlobalStateProvider implements IGlobalStateProvider
20 20
 {
21
-    /**
22
-     * @return array
23
-     */
24
-    public function &getServerSuperGlobal()
25
-    {
26
-        return $_SERVER;
27
-    }
21
+	/**
22
+	 * @return array
23
+	 */
24
+	public function &getServerSuperGlobal()
25
+	{
26
+		return $_SERVER;
27
+	}
28 28
 
29
-    /**
30
-     * @return array
31
-     */
32
-    public function &getGetSuperGlobal()
33
-    {
34
-        return $_GET;
35
-    }
29
+	/**
30
+	 * @return array
31
+	 */
32
+	public function &getGetSuperGlobal()
33
+	{
34
+		return $_GET;
35
+	}
36 36
 
37
-    /**
38
-     * @return array
39
-     */
40
-    public function &getPostSuperGlobal()
41
-    {
42
-        return $_POST;
43
-    }
37
+	/**
38
+	 * @return array
39
+	 */
40
+	public function &getPostSuperGlobal()
41
+	{
42
+		return $_POST;
43
+	}
44 44
 
45
-    /**
46
-     * @return array
47
-     */
48
-    public function &getSessionSuperGlobal()
49
-    {
50
-        return $_SESSION;
51
-    }
45
+	/**
46
+	 * @return array
47
+	 */
48
+	public function &getSessionSuperGlobal()
49
+	{
50
+		return $_SESSION;
51
+	}
52 52
 }
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
includes/Providers/Interfaces/ILocationProvider.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@
 block discarded – undo
13 13
  */
14 14
 interface ILocationProvider
15 15
 {
16
-    /**
17
-     * @param string $address IP address
18
-     *
19
-     * @return array
20
-     */
21
-    public function getIpLocation($address);
16
+	/**
17
+	 * @param string $address IP address
18
+	 *
19
+	 * @return array
20
+	 */
21
+	public function getIpLocation($address);
22 22
 }
Please login to merge, or discard this patch.
includes/Providers/Interfaces/IXffTrustProvider.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -19,41 +19,41 @@
 block discarded – undo
19 19
  */
20 20
 interface IXffTrustProvider
21 21
 {
22
-    /**
23
-     * Returns a value if the IP address is a trusted proxy
24
-     *
25
-     * @param string $ip
26
-     *
27
-     * @return bool
28
-     */
29
-    public function isTrusted($ip);
22
+	/**
23
+	 * Returns a value if the IP address is a trusted proxy
24
+	 *
25
+	 * @param string $ip
26
+	 *
27
+	 * @return bool
28
+	 */
29
+	public function isTrusted($ip);
30 30
 
31
-    /**
32
-     * Gets the last trusted IP in the proxy chain.
33
-     *
34
-     * @param string $ip      The IP address from REMOTE_ADDR
35
-     * @param string $proxyIp The contents of the XFF header.
36
-     *
37
-     * @return string Trusted source IP address
38
-     */
39
-    public function getTrustedClientIp($ip, $proxyIp);
31
+	/**
32
+	 * Gets the last trusted IP in the proxy chain.
33
+	 *
34
+	 * @param string $ip      The IP address from REMOTE_ADDR
35
+	 * @param string $proxyIp The contents of the XFF header.
36
+	 *
37
+	 * @return string Trusted source IP address
38
+	 */
39
+	public function getTrustedClientIp($ip, $proxyIp);
40 40
 
41
-    /**
42
-     * Takes an array( "low" => "high" ) values, and returns true if $needle is in at least one of them.
43
-     *
44
-     * @param array  $haystack
45
-     * @param string $ip
46
-     *
47
-     * @return bool
48
-     */
49
-    public function ipInRange($haystack, $ip);
41
+	/**
42
+	 * Takes an array( "low" => "high" ) values, and returns true if $needle is in at least one of them.
43
+	 *
44
+	 * @param array  $haystack
45
+	 * @param string $ip
46
+	 *
47
+	 * @return bool
48
+	 */
49
+	public function ipInRange($haystack, $ip);
50 50
 
51
-    /**
52
-     * Explodes a CIDR range into an array of addresses
53
-     *
54
-     * @param string $range A CIDR-format range
55
-     *
56
-     * @return array An array containing every IP address in the range
57
-     */
58
-    public function explodeCidr($range);
51
+	/**
52
+	 * Explodes a CIDR range into an array of addresses
53
+	 *
54
+	 * @param string $range A CIDR-format range
55
+	 *
56
+	 * @return array An array containing every IP address in the range
57
+	 */
58
+	public function explodeCidr($range);
59 59
 }
Please login to merge, or discard this patch.
includes/Providers/Interfaces/IRDnsProvider.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,12 +13,12 @@
 block discarded – undo
13 13
  */
14 14
 interface IRDnsProvider
15 15
 {
16
-    /**
17
-     * Gets the reverse DNS address for an IP
18
-     *
19
-     * @param string $address
20
-     *
21
-     * @return string
22
-     */
23
-    public function getReverseDNS($address);
16
+	/**
17
+	 * Gets the reverse DNS address for an IP
18
+	 *
19
+	 * @param string $address
20
+	 *
21
+	 * @return string
22
+	 */
23
+	public function getReverseDNS($address);
24 24
 }
Please login to merge, or discard this patch.
includes/Providers/Interfaces/IAntiSpoofProvider.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@
 block discarded – undo
13 13
  */
14 14
 interface IAntiSpoofProvider
15 15
 {
16
-    /**
17
-     * @param string $username
18
-     *
19
-     * @return array
20
-     */
21
-    public function getSpoofs($username);
16
+	/**
17
+	 * @param string $username
18
+	 *
19
+	 * @return array
20
+	 */
21
+	public function getSpoofs($username);
22 22
 }
Please login to merge, or discard this patch.
includes/Providers/XffTrustProvider.php 1 patch
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -22,156 +22,156 @@
 block discarded – undo
22 22
  */
23 23
 class XffTrustProvider implements IXffTrustProvider
24 24
 {
25
-    /**
26
-     * Array of IP addresses which are TRUSTED proxies
27
-     * @var string[]
28
-     */
29
-    private $trustedCache = array();
30
-    /**
31
-     * Array of IP addresses which are UNTRUSTED proxies
32
-     * @var string[]
33
-     */
34
-    private $untrustedCache = array();
35
-    /** @var PDOStatement */
36
-    private $trustedQuery;
37
-    /**
38
-     * @var PdoDatabase
39
-     */
40
-    private $database;
41
-
42
-    /**
43
-     * Creates a new instance of the trust provider
44
-     *
45
-     * @param string[]    $squidIpList List of IP addresses to pre-approve
46
-     * @param PdoDatabase $database
47
-     */
48
-    public function __construct($squidIpList, PdoDatabase $database)
49
-    {
50
-        $this->trustedCache = $squidIpList;
51
-        $this->database = $database;
52
-    }
53
-
54
-    /**
55
-     * Returns a value if the IP address is a trusted proxy
56
-     *
57
-     * @param string $ip
58
-     *
59
-     * @return bool
60
-     */
61
-    public function isTrusted($ip)
62
-    {
63
-        if (in_array($ip, $this->trustedCache)) {
64
-            return true;
65
-        }
66
-
67
-        if (in_array($ip, $this->untrustedCache)) {
68
-            return false;
69
-        }
70
-
71
-        if ($this->trustedQuery === null) {
72
-            $query = "SELECT COUNT(id) FROM xfftrustcache WHERE ip = :ip;";
73
-            $this->trustedQuery = $this->database->prepare($query);
74
-        }
75
-
76
-        $this->trustedQuery->execute(array(":ip" => $ip));
77
-        $result = $this->trustedQuery->fetchColumn();
78
-        $this->trustedQuery->closeCursor();
79
-
80
-        if ($result == 0) {
81
-            $this->untrustedCache[] = $ip;
82
-
83
-            return false;
84
-        }
85
-
86
-        if ($result >= 1) {
87
-            $this->trustedCache[] = $ip;
88
-
89
-            return true;
90
-        }
91
-
92
-        // something weird has happened if we've got here.
93
-        // default to untrusted.
94
-        return false;
95
-    }
96
-
97
-    /**
98
-     * Gets the last trusted IP in the proxy chain.
99
-     *
100
-     * @param string $ip      The IP address from REMOTE_ADDR
101
-     * @param string $proxyIp The contents of the XFF header.
102
-     *
103
-     * @return string Trusted source IP address
104
-     */
105
-    public function getTrustedClientIp($ip, $proxyIp)
106
-    {
107
-        $clientIpAddress = $ip;
108
-        if ($proxyIp) {
109
-            $ipList = explode(",", $proxyIp);
110
-            $ipList[] = $clientIpAddress;
111
-            $ipList = array_reverse($ipList);
112
-
113
-            foreach ($ipList as $ipNumber => $ipAddress) {
114
-                if ($this->isTrusted(trim($ipAddress)) && $ipNumber < (count($ipList) - 1)) {
115
-                    continue;
116
-                }
117
-
118
-                $clientIpAddress = $ipAddress;
119
-                break;
120
-            }
121
-        }
122
-
123
-        return $clientIpAddress;
124
-    }
125
-
126
-    /**
127
-     * Takes an array( "low" => "high" ) values, and returns true if $needle is in at least one of them.
128
-     *
129
-     * @param array  $haystack
130
-     * @param string $ip
131
-     *
132
-     * @return bool
133
-     */
134
-    public function ipInRange($haystack, $ip)
135
-    {
136
-        $needle = ip2long($ip);
137
-
138
-        foreach ($haystack as $low => $high) {
139
-            if (ip2long($low) <= $needle && ip2long($high) >= $needle) {
140
-                return true;
141
-            }
142
-        }
143
-
144
-        return false;
145
-    }
146
-
147
-    /**
148
-     * Explodes a CIDR range into an array of addresses
149
-     *
150
-     * @param string $range A CIDR-format range
151
-     *
152
-     * @return array An array containing every IP address in the range
153
-     */
154
-    public function explodeCidr($range)
155
-    {
156
-        $cidrData = explode('/', $range);
157
-
158
-        if (!isset($cidrData[1])) {
159
-            return array($range);
160
-        }
161
-
162
-        $blow = (
163
-            str_pad(decbin(ip2long($cidrData[0])), 32, "0", STR_PAD_LEFT) &
164
-            str_pad(str_pad("", $cidrData[1], "1"), 32, "0")
165
-        );
166
-        $bhigh = ($blow | str_pad(str_pad("", $cidrData[1], "0"), 32, "1"));
167
-
168
-        $list = array();
169
-
170
-        $bindecBHigh = bindec($bhigh);
171
-        for ($x = bindec($blow); $x <= $bindecBHigh; $x++) {
172
-            $list[] = long2ip($x);
173
-        }
174
-
175
-        return $list;
176
-    }
25
+	/**
26
+	 * Array of IP addresses which are TRUSTED proxies
27
+	 * @var string[]
28
+	 */
29
+	private $trustedCache = array();
30
+	/**
31
+	 * Array of IP addresses which are UNTRUSTED proxies
32
+	 * @var string[]
33
+	 */
34
+	private $untrustedCache = array();
35
+	/** @var PDOStatement */
36
+	private $trustedQuery;
37
+	/**
38
+	 * @var PdoDatabase
39
+	 */
40
+	private $database;
41
+
42
+	/**
43
+	 * Creates a new instance of the trust provider
44
+	 *
45
+	 * @param string[]    $squidIpList List of IP addresses to pre-approve
46
+	 * @param PdoDatabase $database
47
+	 */
48
+	public function __construct($squidIpList, PdoDatabase $database)
49
+	{
50
+		$this->trustedCache = $squidIpList;
51
+		$this->database = $database;
52
+	}
53
+
54
+	/**
55
+	 * Returns a value if the IP address is a trusted proxy
56
+	 *
57
+	 * @param string $ip
58
+	 *
59
+	 * @return bool
60
+	 */
61
+	public function isTrusted($ip)
62
+	{
63
+		if (in_array($ip, $this->trustedCache)) {
64
+			return true;
65
+		}
66
+
67
+		if (in_array($ip, $this->untrustedCache)) {
68
+			return false;
69
+		}
70
+
71
+		if ($this->trustedQuery === null) {
72
+			$query = "SELECT COUNT(id) FROM xfftrustcache WHERE ip = :ip;";
73
+			$this->trustedQuery = $this->database->prepare($query);
74
+		}
75
+
76
+		$this->trustedQuery->execute(array(":ip" => $ip));
77
+		$result = $this->trustedQuery->fetchColumn();
78
+		$this->trustedQuery->closeCursor();
79
+
80
+		if ($result == 0) {
81
+			$this->untrustedCache[] = $ip;
82
+
83
+			return false;
84
+		}
85
+
86
+		if ($result >= 1) {
87
+			$this->trustedCache[] = $ip;
88
+
89
+			return true;
90
+		}
91
+
92
+		// something weird has happened if we've got here.
93
+		// default to untrusted.
94
+		return false;
95
+	}
96
+
97
+	/**
98
+	 * Gets the last trusted IP in the proxy chain.
99
+	 *
100
+	 * @param string $ip      The IP address from REMOTE_ADDR
101
+	 * @param string $proxyIp The contents of the XFF header.
102
+	 *
103
+	 * @return string Trusted source IP address
104
+	 */
105
+	public function getTrustedClientIp($ip, $proxyIp)
106
+	{
107
+		$clientIpAddress = $ip;
108
+		if ($proxyIp) {
109
+			$ipList = explode(",", $proxyIp);
110
+			$ipList[] = $clientIpAddress;
111
+			$ipList = array_reverse($ipList);
112
+
113
+			foreach ($ipList as $ipNumber => $ipAddress) {
114
+				if ($this->isTrusted(trim($ipAddress)) && $ipNumber < (count($ipList) - 1)) {
115
+					continue;
116
+				}
117
+
118
+				$clientIpAddress = $ipAddress;
119
+				break;
120
+			}
121
+		}
122
+
123
+		return $clientIpAddress;
124
+	}
125
+
126
+	/**
127
+	 * Takes an array( "low" => "high" ) values, and returns true if $needle is in at least one of them.
128
+	 *
129
+	 * @param array  $haystack
130
+	 * @param string $ip
131
+	 *
132
+	 * @return bool
133
+	 */
134
+	public function ipInRange($haystack, $ip)
135
+	{
136
+		$needle = ip2long($ip);
137
+
138
+		foreach ($haystack as $low => $high) {
139
+			if (ip2long($low) <= $needle && ip2long($high) >= $needle) {
140
+				return true;
141
+			}
142
+		}
143
+
144
+		return false;
145
+	}
146
+
147
+	/**
148
+	 * Explodes a CIDR range into an array of addresses
149
+	 *
150
+	 * @param string $range A CIDR-format range
151
+	 *
152
+	 * @return array An array containing every IP address in the range
153
+	 */
154
+	public function explodeCidr($range)
155
+	{
156
+		$cidrData = explode('/', $range);
157
+
158
+		if (!isset($cidrData[1])) {
159
+			return array($range);
160
+		}
161
+
162
+		$blow = (
163
+			str_pad(decbin(ip2long($cidrData[0])), 32, "0", STR_PAD_LEFT) &
164
+			str_pad(str_pad("", $cidrData[1], "1"), 32, "0")
165
+		);
166
+		$bhigh = ($blow | str_pad(str_pad("", $cidrData[1], "0"), 32, "1"));
167
+
168
+		$list = array();
169
+
170
+		$bindecBHigh = bindec($bhigh);
171
+		for ($x = bindec($blow); $x <= $bindecBHigh; $x++) {
172
+			$list[] = long2ip($x);
173
+		}
174
+
175
+		return $list;
176
+	}
177 177
 }
Please login to merge, or discard this patch.