@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function report(string $ip = '', string $categories = '', string $message = '', bool $returnArray = false) |
147 | 147 | { |
148 | - // ip must be set |
|
148 | + // ip must be set |
|
149 | 149 | if (empty($ip)){ |
150 | 150 | throw new \InvalidArgumentException('Ip was empty'); |
151 | 151 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | // message must be set |
159 | - if (empty($message)){ |
|
159 | + if (empty($message)){ |
|
160 | 160 | throw new \InvalidArgumentException('report message was empty'); |
161 | 161 | } |
162 | 162 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | |
312 | 312 | // option |
313 | 313 | if ($verbose){ |
314 | - $data['verbose'] = true; |
|
314 | + $data['verbose'] = true; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | $response = $this->apiRequest('check', $data, 'GET', $returnArray) ; |
@@ -457,14 +457,14 @@ discard block |
||
457 | 457 | 'Key: ' . $this->aipdbApiKey, |
458 | 458 | ]); |
459 | 459 | |
460 | - // execute curl call |
|
461 | - $result = curl_exec($ch); |
|
460 | + // execute curl call |
|
461 | + $result = curl_exec($ch); |
|
462 | 462 | |
463 | - // close connection |
|
464 | - curl_close($ch); |
|
463 | + // close connection |
|
464 | + curl_close($ch); |
|
465 | 465 | |
466 | - // return response as JSON data |
|
467 | - return $result; |
|
466 | + // return response as JSON data |
|
467 | + return $result; |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * @access public |
476 | 476 | * @param string $message The original message |
477 | 477 | * |
478 | - * @return string |
|
478 | + * @return string |
|
479 | 479 | */ |
480 | 480 | protected function cleanMessage(string $message) |
481 | 481 | { |
@@ -500,10 +500,10 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @access public |
502 | 502 | * @static |
503 | - * @param string $filePath The file's full path |
|
504 | - * @param bool $trowError Throw error on true or silent process. Default is true |
|
503 | + * @param string $filePath The file's full path |
|
504 | + * @param bool $trowError Throw error on true or silent process. Default is true |
|
505 | 505 | * |
506 | - * @return object|null |
|
506 | + * @return object|null |
|
507 | 507 | * @throws \Exception |
508 | 508 | * @throws \LogicException |
509 | 509 | */ |
@@ -511,10 +511,10 @@ discard block |
||
511 | 511 | { |
512 | 512 | // check file exists |
513 | 513 | if (!file_exists($filePath) || !is_file($filePath)){ |
514 | - if ($throwError) { |
|
514 | + if ($throwError) { |
|
515 | 515 | throw new \Exception('Config file not found'); |
516 | - } |
|
517 | - return null; |
|
516 | + } |
|
517 | + return null; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | // get and parse content |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @access protected |
51 | 51 | * @var array $selfIps |
52 | 52 | */ |
53 | - protected $selfIps = []; |
|
53 | + protected $selfIps = [ ]; |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Constructor |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param array $myIps The Ips/domain name you dont want to display in report messages |
62 | 62 | * |
63 | 63 | */ |
64 | - public function __construct(string $apiKey, string $userId, array $myIps = []) |
|
64 | + public function __construct(string $apiKey, string $userId, array $myIps = [ ]) |
|
65 | 65 | { |
66 | 66 | $this->aipdbApiKey = $apiKey; |
67 | 67 | $this->aipdbUserId = $userId; |
@@ -100,21 +100,21 @@ discard block |
||
100 | 100 | { |
101 | 101 | |
102 | 102 | // check file exists |
103 | - if (!file_exists($configPath) || !is_file($configPath)){ |
|
103 | + if (!file_exists($configPath) || !is_file($configPath)) { |
|
104 | 104 | throw new \InvalidArgumentException('The file [' . $configPath . '] does not exist.'); |
105 | 105 | } |
106 | 106 | |
107 | 107 | // check file is readable |
108 | - if (!is_readable($configPath)){ |
|
108 | + if (!is_readable($configPath)) { |
|
109 | 109 | throw new InvalidPermissionException('The file [' . $configPath . '] is not readable.'); |
110 | 110 | } |
111 | 111 | |
112 | 112 | $keyConfig = self::loadJsonFile($configPath); |
113 | - $selfIps = []; |
|
113 | + $selfIps = [ ]; |
|
114 | 114 | |
115 | 115 | // Look for other optional config files in the same directory |
116 | 116 | $selfIpsConfigPath = pathinfo($configPath, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . 'self_ips.json'; |
117 | - if (file_exists($selfIpsConfigPath)){ |
|
117 | + if (file_exists($selfIpsConfigPath)) { |
|
118 | 118 | $selfIps = self::loadJsonFile($selfIpsConfigPath)->self_ips; |
119 | 119 | } |
120 | 120 | |
@@ -146,17 +146,17 @@ discard block |
||
146 | 146 | public function report(string $ip = '', string $categories = '', string $message = '', bool $returnArray = false) |
147 | 147 | { |
148 | 148 | // ip must be set |
149 | - if (empty($ip)){ |
|
149 | + if (empty($ip)) { |
|
150 | 150 | throw new \InvalidArgumentException('Ip was empty'); |
151 | 151 | } |
152 | 152 | |
153 | 153 | // categories must be set |
154 | - if (empty($categories)){ |
|
154 | + if (empty($categories)) { |
|
155 | 155 | throw new \InvalidArgumentException('categories list was empty'); |
156 | 156 | } |
157 | 157 | |
158 | 158 | // message must be set |
159 | - if (empty($message)){ |
|
159 | + if (empty($message)) { |
|
160 | 160 | throw new \InvalidArgumentException('report message was empty'); |
161 | 161 | } |
162 | 162 | |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | public function checkBlock(string $network = null, int $maxAge = 30, bool $returnArray = false) |
224 | 224 | { |
225 | 225 | // max age must be less or equal to 365 |
226 | - if ($maxAge > 365 || $maxAge < 1){ |
|
226 | + if ($maxAge > 365 || $maxAge < 1) { |
|
227 | 227 | throw new \InvalidArgumentException('maxAge must be at least 1 and less than 365 (' . $maxAge . ' was given)'); |
228 | 228 | } |
229 | 229 | |
230 | 230 | // ip must be set |
231 | - if (empty($network)){ |
|
231 | + if (empty($network)) { |
|
232 | 232 | throw new \InvalidArgumentException('network argument must be set (null given)'); |
233 | 233 | } |
234 | 234 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | 'maxAgeInDays' => $maxAge, |
239 | 239 | ]; |
240 | 240 | |
241 | - $response = $this->apiRequest('check-block', $data, 'GET', $returnArray) ; |
|
241 | + $response = $this->apiRequest('check-block', $data, 'GET', $returnArray); |
|
242 | 242 | |
243 | 243 | return json_decode($response, $returnArray); |
244 | 244 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | public function clear(string $ip = null, bool $returnArray = false) |
266 | 266 | { |
267 | 267 | // ip must be set |
268 | - if (empty($ip)){ |
|
268 | + if (empty($ip)) { |
|
269 | 269 | throw new \InvalidArgumentException('ip argument must be set (null given)'); |
270 | 270 | } |
271 | 271 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | 'ipAddress' => $ip, |
275 | 275 | ]; |
276 | 276 | |
277 | - $response = $this->apiRequest('check', $data, 'DELETE', $returnArray) ; |
|
277 | + $response = $this->apiRequest('check', $data, 'DELETE', $returnArray); |
|
278 | 278 | |
279 | 279 | return json_decode($response, $returnArray); |
280 | 280 | } |
@@ -294,12 +294,12 @@ discard block |
||
294 | 294 | public function check(string $ip = null, int $maxAge = 30, bool $verbose = false, bool $returnArray = false) |
295 | 295 | { |
296 | 296 | // max age must be less or equal to 365 |
297 | - if ($maxAge > 365 || $maxAge < 1){ |
|
297 | + if ($maxAge > 365 || $maxAge < 1) { |
|
298 | 298 | throw new \InvalidArgumentException('maxAge must be at least 1 and less than 365 (' . $maxAge . ' was given)'); |
299 | 299 | } |
300 | 300 | |
301 | 301 | // ip must be set |
302 | - if (empty($ip)){ |
|
302 | + if (empty($ip)) { |
|
303 | 303 | throw new \InvalidArgumentException('ip argument must be set (null given)'); |
304 | 304 | } |
305 | 305 | |
@@ -310,11 +310,11 @@ discard block |
||
310 | 310 | ]; |
311 | 311 | |
312 | 312 | // option |
313 | - if ($verbose){ |
|
314 | - $data['verbose'] = true; |
|
313 | + if ($verbose) { |
|
314 | + $data[ 'verbose' ] = true; |
|
315 | 315 | } |
316 | 316 | |
317 | - $response = $this->apiRequest('check', $data, 'GET', $returnArray) ; |
|
317 | + $response = $this->apiRequest('check', $data, 'GET', $returnArray); |
|
318 | 318 | |
319 | 319 | return json_decode($response, $returnArray); |
320 | 320 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | public function getBlacklist(int $limit = 10000, bool $plainText = false, bool $returnArray = false) |
335 | 335 | { |
336 | 336 | |
337 | - if ($limit < 1){ |
|
337 | + if ($limit < 1) { |
|
338 | 338 | throw new \InvalidArgumentException('limit must be at least 1 (' . $limit . ' was given)'); |
339 | 339 | } |
340 | 340 | |
@@ -346,13 +346,13 @@ discard block |
||
346 | 346 | |
347 | 347 | // plaintext paremeter has no value and must be added only when true |
348 | 348 | // (set plaintext=false won't work) |
349 | - if ($plainText){ |
|
350 | - $data['plaintext'] = $plainText; |
|
349 | + if ($plainText) { |
|
350 | + $data[ 'plaintext' ] = $plainText; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | $response = $this->apiRequest('blacklist', $data, 'GET'); |
354 | 354 | |
355 | - if ($plainText){ |
|
355 | + if ($plainText) { |
|
356 | 356 | return $response; |
357 | 357 | } |
358 | 358 | |
@@ -383,21 +383,21 @@ discard block |
||
383 | 383 | foreach ($cats as $cat) { |
384 | 384 | |
385 | 385 | // get index on our array of categories |
386 | - $catIndex = is_numeric($cat) ? $this->getCategoryIndex($cat, 1) : $this->getCategoryIndex($cat, 0); |
|
386 | + $catIndex = is_numeric($cat) ? $this->getCategoryIndex($cat, 1) : $this->getCategoryIndex($cat, 0); |
|
387 | 387 | |
388 | 388 | // check if found |
389 | - if ($catIndex === false ){ |
|
390 | - throw new \InvalidArgumentException('Invalid report category was given : ['. $cat . ']'); |
|
389 | + if ($catIndex === false) { |
|
390 | + throw new \InvalidArgumentException('Invalid report category was given : [' . $cat . ']'); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | // get Id |
394 | - $catId = $this->aipdbApiCategories[$catIndex][1]; |
|
394 | + $catId = $this->aipdbApiCategories[ $catIndex ][ 1 ]; |
|
395 | 395 | |
396 | 396 | // need another ? |
397 | - if ($needAnother !== false){ |
|
397 | + if ($needAnother !== false) { |
|
398 | 398 | |
399 | 399 | // is a standalone cat ? |
400 | - if ($this->aipdbApiCategories[$catIndex][3] === false) { |
|
400 | + if ($this->aipdbApiCategories[ $catIndex ][ 3 ] === false) { |
|
401 | 401 | $needAnother = true; |
402 | 402 | |
403 | 403 | } else { |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | } |
409 | 409 | |
410 | 410 | // set or add to cats list |
411 | - $catsString = ($catsString === '') ? $catId : $catsString .','.$catId; |
|
411 | + $catsString = ($catsString === '') ? $catId : $catsString . ',' . $catId; |
|
412 | 412 | } |
413 | 413 | |
414 | - if ($needAnother !== false){ |
|
414 | + if ($needAnother !== false) { |
|
415 | 415 | throw new \InvalidArgumentException('Invalid report category paremeter given: some categories can\'t be used alone'); |
416 | 416 | } |
417 | 417 | |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | $message = str_replace('\\', '', $message); |
484 | 484 | |
485 | 485 | // Remove self ips |
486 | - foreach ($this->selfIps as $ip){ |
|
486 | + foreach ($this->selfIps as $ip) { |
|
487 | 487 | $message = str_replace($ip, '*', $message); |
488 | 488 | } |
489 | 489 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | protected static function loadJsonFile(string $filePath, bool $throwError = true) |
511 | 511 | { |
512 | 512 | // check file exists |
513 | - if (!file_exists($filePath) || !is_file($filePath)){ |
|
513 | + if (!file_exists($filePath) || !is_file($filePath)) { |
|
514 | 514 | if ($throwError) { |
515 | 515 | throw new \Exception('Config file not found'); |
516 | 516 | } |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | $json = json_decode(utf8_encode($content)); |
523 | 523 | |
524 | 524 | // check for errors |
525 | - if ($json == null && json_last_error() != JSON_ERROR_NONE){ |
|
525 | + if ($json == null && json_last_error() != JSON_ERROR_NONE) { |
|
526 | 526 | if ($throwError) { |
527 | 527 | throw new \LogicException(sprintf("Failed to parse config file Error: '%s'", json_last_error_msg())); |
528 | 528 | } |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | // Open proxy, open relay, or Tor exit node. |
71 | 71 | ['openproxy' , '9', 'Open Proxy', true], |
72 | 72 | |
73 | - // Comment/forum spam, HTTP referer spam, or other CMS spam. |
|
74 | - ['webspam' , '10', 'Web Spam', true], |
|
73 | + // Comment/forum spam, HTTP referer spam, or other CMS spam. |
|
74 | + ['webspam' , '10', 'Web Spam', true], |
|
75 | 75 | |
76 | 76 | // Spam email content, infected attachments, and phishing emails. Note: Limit comments to only relevent |
77 | 77 | // information (instead of log dumps) and be sure to remove PII if you want to remain anonymous. |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | if ($cat[0] === $categoryName) { |
148 | 148 | return $cat; |
149 | 149 | } |
150 | - } |
|
150 | + } |
|
151 | 151 | |
152 | 152 | // not found |
153 | 153 | return false; |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | public function getCategoryNameById(string $categoryId) |
165 | 165 | { |
166 | 166 | foreach ($this->aipdbApiCategories as $cat){ |
167 | - if ($cat[1] === $categoryId) { |
|
168 | - return $cat; |
|
169 | - } |
|
167 | + if ($cat[1] === $categoryId) { |
|
168 | + return $cat; |
|
169 | + } |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | // not found |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | return $i; |
191 | 191 | } |
192 | 192 | $i++; |
193 | - } |
|
193 | + } |
|
194 | 194 | |
195 | 195 | // not found |
196 | 196 | return false; |
@@ -44,82 +44,82 @@ discard block |
||
44 | 44 | protected $aipdbApiCategories = [ |
45 | 45 | |
46 | 46 | // Altering DNS records resulting in improper redirection. |
47 | - ['dns-c' , '1', 'DNS Compromise', true], |
|
47 | + [ 'dns-c', '1', 'DNS Compromise', true ], |
|
48 | 48 | |
49 | 49 | // Falsifying domain server cache (cache poisoning). |
50 | - ['dns-p' , '2', 'DNS Poisoning', true], |
|
50 | + [ 'dns-p', '2', 'DNS Poisoning', true ], |
|
51 | 51 | |
52 | 52 | // Fraudulent orders. |
53 | - ['fraud-orders' , '3', 'Fraud Orders', true], |
|
53 | + [ 'fraud-orders', '3', 'Fraud Orders', true ], |
|
54 | 54 | |
55 | 55 | // Participating in distributed denial-of-service (usually part of botnet). |
56 | - ['ddos' , '4', 'DDoS Attack', true], |
|
56 | + [ 'ddos', '4', 'DDoS Attack', true ], |
|
57 | 57 | |
58 | 58 | // |
59 | - ['ftp-bf' , '5', 'FTP Brute-Force', true], |
|
59 | + [ 'ftp-bf', '5', 'FTP Brute-Force', true ], |
|
60 | 60 | |
61 | 61 | // Oversized IP packet. |
62 | - ['pingdeath' , '6', 'Ping of Death', true], |
|
62 | + [ 'pingdeath', '6', 'Ping of Death', true ], |
|
63 | 63 | |
64 | 64 | // Phishing websites and/or email. |
65 | - ['phishing' , '7', 'Phishing', true], |
|
65 | + [ 'phishing', '7', 'Phishing', true ], |
|
66 | 66 | |
67 | 67 | // |
68 | - ['fraudvoip' , '8', 'Fraud VoIP', true], |
|
68 | + [ 'fraudvoip', '8', 'Fraud VoIP', true ], |
|
69 | 69 | |
70 | 70 | // Open proxy, open relay, or Tor exit node. |
71 | - ['openproxy' , '9', 'Open Proxy', true], |
|
71 | + [ 'openproxy', '9', 'Open Proxy', true ], |
|
72 | 72 | |
73 | 73 | // Comment/forum spam, HTTP referer spam, or other CMS spam. |
74 | - ['webspam' , '10', 'Web Spam', true], |
|
74 | + [ 'webspam', '10', 'Web Spam', true ], |
|
75 | 75 | |
76 | 76 | // Spam email content, infected attachments, and phishing emails. Note: Limit comments to only relevent |
77 | 77 | // information (instead of log dumps) and be sure to remove PII if you want to remain anonymous. |
78 | - ['emailspam' , '11', 'Email Spam', true], |
|
78 | + [ 'emailspam', '11', 'Email Spam', true ], |
|
79 | 79 | |
80 | 80 | // CMS blog comment spam. |
81 | - ['blogspam' , '12', 'Blog Spam', true], |
|
81 | + [ 'blogspam', '12', 'Blog Spam', true ], |
|
82 | 82 | |
83 | 83 | // Conjunctive category. |
84 | - ['vpnip' , '13', 'VPN IP', false], // to check alone ?? |
|
84 | + [ 'vpnip', '13', 'VPN IP', false ], // to check alone ?? |
|
85 | 85 | |
86 | 86 | // Scanning for open ports and vulnerable services. |
87 | - ['scan' , '14', 'Port Scan', true], |
|
87 | + [ 'scan', '14', 'Port Scan', true ], |
|
88 | 88 | |
89 | 89 | // |
90 | - ['hack' , '15', 'Hacking', true], |
|
90 | + [ 'hack', '15', 'Hacking', true ], |
|
91 | 91 | |
92 | 92 | // Attempts at SQL injection. |
93 | - ['sql' , '16', 'SQL Injection', true], |
|
93 | + [ 'sql', '16', 'SQL Injection', true ], |
|
94 | 94 | |
95 | 95 | // Email sender spoofing. |
96 | - ['spoof' , '17', 'Spoofing', true], |
|
96 | + [ 'spoof', '17', 'Spoofing', true ], |
|
97 | 97 | |
98 | 98 | // Credential brute-force attacks on webpage logins and services like SSH, FTP, SIP, SMTP, RDP, etc. |
99 | 99 | // This category is seperate from DDoS attacks. |
100 | - ['brute' , '18', 'Brute-Force', true], |
|
100 | + [ 'brute', '18', 'Brute-Force', true ], |
|
101 | 101 | |
102 | 102 | // Webpage scraping (for email addresses, content, etc) and crawlers that do not honor robots.txt. |
103 | 103 | // Excessive requests and user agent spoofing can also be reported here. |
104 | - ['badbot' , '19', 'Bad Web Bot', true], |
|
104 | + [ 'badbot', '19', 'Bad Web Bot', true ], |
|
105 | 105 | |
106 | 106 | // Host is likely infected with malware and being used for other attacks or to host malicious content. |
107 | 107 | // The host owner may not be aware of the compromise. This category is often used in combination |
108 | 108 | // with other attack categories. |
109 | - ['explhost' , '20', 'Exploited Host', true], |
|
109 | + [ 'explhost', '20', 'Exploited Host', true ], |
|
110 | 110 | |
111 | 111 | // Attempts to probe for or exploit installed web applications such as a CMS |
112 | 112 | // like WordPress/Drupal, e-commerce solutions, forum software, phpMyAdmin and |
113 | 113 | // various other software plugins/solutions. |
114 | - ['webattack' , '21', 'Web App Attack', true ], |
|
114 | + [ 'webattack', '21', 'Web App Attack', true ], |
|
115 | 115 | |
116 | 116 | // Secure Shell (SSH) abuse. Use this category in combination |
117 | 117 | // with more specific categories. |
118 | - ['ssh' , '22', 'SSH', false], |
|
118 | + [ 'ssh', '22', 'SSH', false ], |
|
119 | 119 | |
120 | 120 | // Abuse was targeted at an "Internet of Things" type device. Include |
121 | 121 | // information about what type of device was targeted in the comments. |
122 | - ['oit' , '23', 'IoT Targeted', true], |
|
122 | + [ 'oit', '23', 'IoT Targeted', true ], |
|
123 | 123 | ]; |
124 | 124 | |
125 | 125 | /** |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function getCategoryIdbyName(string $categoryName) |
145 | 145 | { |
146 | - foreach ($this->aipdbApiCategories as $cat){ |
|
147 | - if ($cat[0] === $categoryName) { |
|
146 | + foreach ($this->aipdbApiCategories as $cat) { |
|
147 | + if ($cat[ 0 ] === $categoryName) { |
|
148 | 148 | return $cat; |
149 | 149 | } |
150 | 150 | } |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function getCategoryNameById(string $categoryId) |
165 | 165 | { |
166 | - foreach ($this->aipdbApiCategories as $cat){ |
|
167 | - if ($cat[1] === $categoryId) { |
|
166 | + foreach ($this->aipdbApiCategories as $cat) { |
|
167 | + if ($cat[ 1 ] === $categoryId) { |
|
168 | 168 | return $cat; |
169 | 169 | } |
170 | 170 | } |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | protected function getCategoryIndex(string $value, int $index) |
186 | 186 | { |
187 | 187 | $i = 0; |
188 | - foreach ($this->aipdbApiCategories as $cat){ |
|
189 | - if ($cat[$index] === $value) { |
|
188 | + foreach ($this->aipdbApiCategories as $cat) { |
|
189 | + if ($cat[ $index ] === $value) { |
|
190 | 190 | return $i; |
191 | 191 | } |
192 | 192 | $i++; |