Passed
Push — dependabot/composer/fortawesom... ( b43113 )
by
unknown
05:17
created
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/CachedRDnsLookupProvider.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -20,40 +20,40 @@
 block discarded – undo
20 20
  */
21 21
 class CachedRDnsLookupProvider implements IRDnsProvider
22 22
 {
23
-    private $database;
23
+	private $database;
24 24
 
25
-    public function __construct(PdoDatabase $database)
26
-    {
27
-        $this->database = $database;
28
-    }
25
+	public function __construct(PdoDatabase $database)
26
+	{
27
+		$this->database = $database;
28
+	}
29 29
 
30
-    public function getReverseDNS($address)
31
-    {
32
-        $address = trim($address);
30
+	public function getReverseDNS($address)
31
+	{
32
+		$address = trim($address);
33 33
 
34
-        // lets look in our cache database first.
35
-        $rDns = RDnsCache::getByAddress($address, $this->database);
34
+		// lets look in our cache database first.
35
+		$rDns = RDnsCache::getByAddress($address, $this->database);
36 36
 
37
-        if ($rDns instanceof RDnsCache) {
38
-            // touch cache timer
39
-            $rDns->save();
37
+		if ($rDns instanceof RDnsCache) {
38
+			// touch cache timer
39
+			$rDns->save();
40 40
 
41
-            return $rDns->getData();
42
-        }
41
+			return $rDns->getData();
42
+		}
43 43
 
44
-        // OK, it's not there, let's do an rDNS lookup.
45
-        $result = @ gethostbyaddr($address);
44
+		// OK, it's not there, let's do an rDNS lookup.
45
+		$result = @ gethostbyaddr($address);
46 46
 
47
-        if ($result !== false) {
48
-            $rDns = new RDnsCache();
49
-            $rDns->setDatabase($this->database);
50
-            $rDns->setAddress($address);
51
-            $rDns->setData($result);
52
-            $rDns->save();
47
+		if ($result !== false) {
48
+			$rDns = new RDnsCache();
49
+			$rDns->setDatabase($this->database);
50
+			$rDns->setAddress($address);
51
+			$rDns->setData($result);
52
+			$rDns->save();
53 53
 
54
-            return $result;
55
-        }
54
+			return $result;
55
+		}
56 56
 
57
-        return null;
58
-    }
57
+		return null;
58
+	}
59 59
 }
Please login to merge, or discard this patch.
includes/Providers/TorExitProvider.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -13,96 +13,96 @@
 block discarded – undo
13 13
 
14 14
 class TorExitProvider
15 15
 {
16
-    /** @var PdoDatabase */
17
-    private $database;
18
-
19
-    /**
20
-     * TorExitProvider constructor.
21
-     *
22
-     * @param PdoDatabase $database
23
-     */
24
-    public function __construct(PdoDatabase $database)
25
-    {
26
-        $this->database = $database;
27
-    }
28
-
29
-    /**
30
-     * Checks whether an IP address is a Tor exit node for one of the pre-cached IP addresses.
31
-     *
32
-     * @param string $ip IP Address
33
-     *
34
-     * @return bool
35
-     */
36
-    public function isTorExit($ip)
37
-    {
38
-        $statement = $this->database->prepare('SELECT COUNT(1) FROM tornodecache WHERE ipaddr = :ip');
39
-
40
-        $statement->execute(array(':ip' => $ip));
41
-
42
-        $count = $statement->fetchColumn();
43
-        $statement->closeCursor();
44
-
45
-        if ($count > 0) {
46
-            return true;
47
-        }
48
-        else {
49
-            return false;
50
-        }
51
-    }
52
-
53
-    public static function regenerate(PdoDatabase $database, HttpHelper $httpHelper, $destinationIps)
54
-    {
55
-        $query = <<<SQL
16
+	/** @var PdoDatabase */
17
+	private $database;
18
+
19
+	/**
20
+	 * TorExitProvider constructor.
21
+	 *
22
+	 * @param PdoDatabase $database
23
+	 */
24
+	public function __construct(PdoDatabase $database)
25
+	{
26
+		$this->database = $database;
27
+	}
28
+
29
+	/**
30
+	 * Checks whether an IP address is a Tor exit node for one of the pre-cached IP addresses.
31
+	 *
32
+	 * @param string $ip IP Address
33
+	 *
34
+	 * @return bool
35
+	 */
36
+	public function isTorExit($ip)
37
+	{
38
+		$statement = $this->database->prepare('SELECT COUNT(1) FROM tornodecache WHERE ipaddr = :ip');
39
+
40
+		$statement->execute(array(':ip' => $ip));
41
+
42
+		$count = $statement->fetchColumn();
43
+		$statement->closeCursor();
44
+
45
+		if ($count > 0) {
46
+			return true;
47
+		}
48
+		else {
49
+			return false;
50
+		}
51
+	}
52
+
53
+	public static function regenerate(PdoDatabase $database, HttpHelper $httpHelper, $destinationIps)
54
+	{
55
+		$query = <<<SQL
56 56
 INSERT INTO tornodecache (ipaddr, exitaddr, exitport)
57 57
 VALUES (:ipaddr, :exitaddr, :exitport)
58 58
 ON DUPLICATE KEY
59 59
 UPDATE touched = CURRENT_TIMESTAMP, updateversion = updateversion + 1
60 60
 SQL;
61 61
 
62
-        $statement = $database->prepare($query);
62
+		$statement = $database->prepare($query);
63 63
 
64
-        foreach ($destinationIps as $ip) {
65
-            echo 'Fetching data for ' . $ip . PHP_EOL;
64
+		foreach ($destinationIps as $ip) {
65
+			echo 'Fetching data for ' . $ip . PHP_EOL;
66 66
 
67
-            $statement->bindValue(':exitaddr', $ip);
67
+			$statement->bindValue(':exitaddr', $ip);
68 68
 
69
-            $http = $httpHelper->get(
70
-                'https://check.torproject.org/cgi-bin/TorBulkExitList.py',
71
-                array(
72
-                    'ip'   => $ip,
73
-                    'port' => 80,
74
-                ));
69
+			$http = $httpHelper->get(
70
+				'https://check.torproject.org/cgi-bin/TorBulkExitList.py',
71
+				array(
72
+					'ip'   => $ip,
73
+					'port' => 80,
74
+				));
75 75
 
76
-            $https = $httpHelper->get(
77
-                'https://check.torproject.org/cgi-bin/TorBulkExitList.py',
78
-                array(
79
-                    'ip'   => $ip,
80
-                    'port' => 443,
81
-                ));
76
+			$https = $httpHelper->get(
77
+				'https://check.torproject.org/cgi-bin/TorBulkExitList.py',
78
+				array(
79
+					'ip'   => $ip,
80
+					'port' => 443,
81
+				));
82 82
 
83
-            foreach (array(80 => $http, 443 => $https) as $port => $response) {
84
-                echo '  Running for port ' . $ip . ':' . $port . PHP_EOL;
83
+			foreach (array(80 => $http, 443 => $https) as $port => $response) {
84
+				echo '  Running for port ' . $ip . ':' . $port . PHP_EOL;
85 85
 
86
-                $statement->bindValue(':exitport', $port);
86
+				$statement->bindValue(':exitport', $port);
87 87
 
88
-                $lines = explode("\n", $response);
88
+				$lines = explode("\n", $response);
89 89
 
90
-                foreach ($lines as $line) {
91
-                    // line contains a comment char, just skip the line.
92
-                    // This is OK as of 2016-04-06  --stw
93
-                    if (strpos($line, '#') !== false) {
94
-                        continue;
95
-                    }
90
+				foreach ($lines as $line) {
91
+					// line contains a comment char, just skip the line.
92
+					// This is OK as of 2016-04-06  --stw
93
+					if (strpos($line, '#') !== false) {
94
+						continue;
95
+					}
96 96
 
97
-                    $statement->bindValue(':ipaddr', $line);
98
-                    $statement->execute();
99
-                }
100
-            }
97
+					$statement->bindValue(':ipaddr', $line);
98
+					$statement->execute();
99
+				}
100
+			}
101 101
 
102
-            echo 'Done for ' . $ip . PHP_EOL;
103
-        }
102
+			echo 'Done for ' . $ip . PHP_EOL;
103
+		}
104 104
 
105
-        // kill old cached entries
106
-        $database->exec('DELETE FROM tornodecache WHERE touched < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 DAY)');
107
-    }
105
+		// kill old cached entries
106
+		$database->exec('DELETE FROM tornodecache WHERE touched < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 DAY)');
107
+	}
108 108
 }
109 109
\ No newline at end of file
Please login to merge, or discard this patch.
includes/Providers/CachedApiAntispoofProvider.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -22,77 +22,77 @@
 block discarded – undo
22 22
  */
23 23
 class CachedApiAntispoofProvider implements IAntiSpoofProvider
24 24
 {
25
-    /**
26
-     * @var PdoDatabase
27
-     */
28
-    private $database;
29
-    /**
30
-     * @var string
31
-     */
32
-    private $mediawikiWebServiceEndpoint;
33
-    /**
34
-     * @var HttpHelper
35
-     */
36
-    private $httpHelper;
25
+	/**
26
+	 * @var PdoDatabase
27
+	 */
28
+	private $database;
29
+	/**
30
+	 * @var string
31
+	 */
32
+	private $mediawikiWebServiceEndpoint;
33
+	/**
34
+	 * @var HttpHelper
35
+	 */
36
+	private $httpHelper;
37 37
 
38
-    public function __construct(PdoDatabase $database, $mediawikiWebServiceEndpoint, HttpHelper $httpHelper)
39
-    {
40
-        $this->database = $database;
41
-        $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint;
42
-        $this->httpHelper = $httpHelper;
43
-    }
38
+	public function __construct(PdoDatabase $database, $mediawikiWebServiceEndpoint, HttpHelper $httpHelper)
39
+	{
40
+		$this->database = $database;
41
+		$this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint;
42
+		$this->httpHelper = $httpHelper;
43
+	}
44 44
 
45
-    public function getSpoofs($username)
46
-    {
47
-        /** @var AntiSpoofCache $cacheResult */
48
-        $cacheResult = AntiSpoofCache::getByUsername($username, $this->database);
49
-        if ($cacheResult == false) {
50
-            // get the data from the API
51
-            $data = $this->httpHelper->get($this->mediawikiWebServiceEndpoint, array(
52
-                'action'   => 'antispoof',
53
-                'format'   => 'php',
54
-                'username' => $username,
55
-            ));
45
+	public function getSpoofs($username)
46
+	{
47
+		/** @var AntiSpoofCache $cacheResult */
48
+		$cacheResult = AntiSpoofCache::getByUsername($username, $this->database);
49
+		if ($cacheResult == false) {
50
+			// get the data from the API
51
+			$data = $this->httpHelper->get($this->mediawikiWebServiceEndpoint, array(
52
+				'action'   => 'antispoof',
53
+				'format'   => 'php',
54
+				'username' => $username,
55
+			));
56 56
 
57
-            $cacheEntry = new AntiSpoofCache();
58
-            $cacheEntry->setDatabase($this->database);
59
-            $cacheEntry->setUsername($username);
60
-            $cacheEntry->setData($data);
61
-            $cacheEntry->save();
57
+			$cacheEntry = new AntiSpoofCache();
58
+			$cacheEntry->setDatabase($this->database);
59
+			$cacheEntry->setUsername($username);
60
+			$cacheEntry->setData($data);
61
+			$cacheEntry->save();
62 62
 
63
-            $cacheResult = $cacheEntry;
64
-        }
65
-        else {
66
-            $data = $cacheResult->getData();
67
-        }
63
+			$cacheResult = $cacheEntry;
64
+		}
65
+		else {
66
+			$data = $cacheResult->getData();
67
+		}
68 68
 
69
-        $result = unserialize($data);
69
+		$result = unserialize($data);
70 70
 
71
-        if (!isset($result['antispoof']) || !isset($result['antispoof']['result'])) {
72
-            $cacheResult->delete();
71
+		if (!isset($result['antispoof']) || !isset($result['antispoof']['result'])) {
72
+			$cacheResult->delete();
73 73
 
74
-            if (isset($result['error']['info'])) {
75
-                throw new Exception("Unrecognised API response to query: " . $result['error']['info']);
76
-            }
74
+			if (isset($result['error']['info'])) {
75
+				throw new Exception("Unrecognised API response to query: " . $result['error']['info']);
76
+			}
77 77
 
78
-            throw new Exception("Unrecognised API response to query.");
79
-        }
78
+			throw new Exception("Unrecognised API response to query.");
79
+		}
80 80
 
81
-        if ($result['antispoof']['result'] == "pass") {
82
-            // All good here!
83
-            return array();
84
-        }
81
+		if ($result['antispoof']['result'] == "pass") {
82
+			// All good here!
83
+			return array();
84
+		}
85 85
 
86
-        if ($result['antispoof']['result'] == "conflict") {
87
-            // we've got conflicts, let's do something with them.
88
-            return $result['antispoof']['users'];
89
-        }
86
+		if ($result['antispoof']['result'] == "conflict") {
87
+			// we've got conflicts, let's do something with them.
88
+			return $result['antispoof']['users'];
89
+		}
90 90
 
91
-        if ($result['antispoof']['result'] == "error") {
92
-            // we've got conflicts, let's do something with them.
93
-            throw new Exception("Encountered error while getting result: " . $result['antispoof']['error']);
94
-        }
91
+		if ($result['antispoof']['result'] == "error") {
92
+			// we've got conflicts, let's do something with them.
93
+			throw new Exception("Encountered error while getting result: " . $result['antispoof']['error']);
94
+		}
95 95
 
96
-        throw new Exception("Unrecognised API response to query.");
97
-    }
96
+		throw new Exception("Unrecognised API response to query.");
97
+	}
98 98
 }
Please login to merge, or discard this patch.
includes/ConsoleTasks/ClearOldDataTask.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -13,25 +13,25 @@
 block discarded – undo
13 13
 
14 14
 class ClearOldDataTask extends ConsoleTaskBase
15 15
 {
16
-    public function execute()
17
-    {
18
-        $dataClearInterval = $this->getSiteConfiguration()->getDataClearInterval();
16
+	public function execute()
17
+	{
18
+		$dataClearInterval = $this->getSiteConfiguration()->getDataClearInterval();
19 19
 
20
-        $query = $this->getDatabase()->prepare(<<<SQL
20
+		$query = $this->getDatabase()->prepare(<<<SQL
21 21
 UPDATE request
22 22
 SET ip = :ip, forwardedip = null, email = :mail, useragent = ''
23 23
 WHERE date < DATE_SUB(curdate(), INTERVAL {$dataClearInterval})
24 24
 AND status = 'Closed';
25 25
 SQL
26
-        );
26
+		);
27 27
 
28
-        $success = $query->execute(array(
29
-            ":ip"   => $this->getSiteConfiguration()->getDataClearIp(),
30
-            ":mail" => $this->getSiteConfiguration()->getDataClearEmail(),
31
-        ));
28
+		$success = $query->execute(array(
29
+			":ip"   => $this->getSiteConfiguration()->getDataClearIp(),
30
+			":mail" => $this->getSiteConfiguration()->getDataClearEmail(),
31
+		));
32 32
 
33
-        if (!$success) {
34
-            throw new Exception("Error in transaction: Could not clear data.");
35
-        }
36
-    }
33
+		if (!$success) {
34
+			throw new Exception("Error in transaction: Could not clear data.");
35
+		}
36
+	}
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
includes/ConsoleTasks/ClearExpiredIdentificationData.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
13 13
 
14 14
 class ClearExpiredIdentificationData extends ConsoleTaskBase
15 15
 {
16
-    /**
17
-     * @return void
18
-     */
19
-    public function execute()
20
-    {
21
-        IdentificationVerifier::clearExpiredCacheEntries($this->getSiteConfiguration(), $this->getDatabase());
22
-    }
16
+	/**
17
+	 * @return void
18
+	 */
19
+	public function execute()
20
+	{
21
+		IdentificationVerifier::clearExpiredCacheEntries($this->getSiteConfiguration(), $this->getDatabase());
22
+	}
23 23
 }
Please login to merge, or discard this patch.