@@ -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; |
@@ -52,82 +52,82 @@ discard block |
||
| 52 | 52 | protected $aipdbApiCategories = [ |
| 53 | 53 | |
| 54 | 54 | // Altering DNS records resulting in improper redirection. |
| 55 | - ['dns-c' , '1', 'DNS Compromise', true], |
|
| 55 | + [ 'dns-c', '1', 'DNS Compromise', true ], |
|
| 56 | 56 | |
| 57 | 57 | // Falsifying domain server cache (cache poisoning). |
| 58 | - ['dns-p' , '2', 'DNS Poisoning', true], |
|
| 58 | + [ 'dns-p', '2', 'DNS Poisoning', true ], |
|
| 59 | 59 | |
| 60 | 60 | // Fraudulent orders. |
| 61 | - ['fraud-orders' , '3', 'Fraud Orders', true], |
|
| 61 | + [ 'fraud-orders', '3', 'Fraud Orders', true ], |
|
| 62 | 62 | |
| 63 | 63 | // Participating in distributed denial-of-service (usually part of botnet). |
| 64 | - ['ddos' , '4', 'DDoS Attack', true], |
|
| 64 | + [ 'ddos', '4', 'DDoS Attack', true ], |
|
| 65 | 65 | |
| 66 | 66 | // |
| 67 | - ['ftp-bf' , '5', 'FTP Brute-Force', true], |
|
| 67 | + [ 'ftp-bf', '5', 'FTP Brute-Force', true ], |
|
| 68 | 68 | |
| 69 | 69 | // Oversized IP packet. |
| 70 | - ['pingdeath' , '6', 'Ping of Death', true], |
|
| 70 | + [ 'pingdeath', '6', 'Ping of Death', true ], |
|
| 71 | 71 | |
| 72 | 72 | // Phishing websites and/or email. |
| 73 | - ['phishing' , '7', 'Phishing', true], |
|
| 73 | + [ 'phishing', '7', 'Phishing', true ], |
|
| 74 | 74 | |
| 75 | 75 | // |
| 76 | - ['fraudvoip' , '8', 'Fraud VoIP', true], |
|
| 76 | + [ 'fraudvoip', '8', 'Fraud VoIP', true ], |
|
| 77 | 77 | |
| 78 | 78 | // Open proxy, open relay, or Tor exit node. |
| 79 | - ['openproxy' , '9', 'Open Proxy', true], |
|
| 79 | + [ 'openproxy', '9', 'Open Proxy', true ], |
|
| 80 | 80 | |
| 81 | 81 | // Comment/forum spam, HTTP referer spam, or other CMS spam. |
| 82 | - ['webspam' , '10', 'Web Spam', true], |
|
| 82 | + [ 'webspam', '10', 'Web Spam', true ], |
|
| 83 | 83 | |
| 84 | 84 | // Spam email content, infected attachments, and phishing emails. Note: Limit comments to only relevent |
| 85 | 85 | // information (instead of log dumps) and be sure to remove PII if you want to remain anonymous. |
| 86 | - ['emailspam' , '11', 'Email Spam', true], |
|
| 86 | + [ 'emailspam', '11', 'Email Spam', true ], |
|
| 87 | 87 | |
| 88 | 88 | // CMS blog comment spam. |
| 89 | - ['blogspam' , '12', 'Blog Spam', true], |
|
| 89 | + [ 'blogspam', '12', 'Blog Spam', true ], |
|
| 90 | 90 | |
| 91 | 91 | // Conjunctive category. |
| 92 | - ['vpnip' , '13', 'VPN IP', false], // to check alone ?? |
|
| 92 | + [ 'vpnip', '13', 'VPN IP', false ], // to check alone ?? |
|
| 93 | 93 | |
| 94 | 94 | // Scanning for open ports and vulnerable services. |
| 95 | - ['scan' , '14', 'Port Scan', true], |
|
| 95 | + [ 'scan', '14', 'Port Scan', true ], |
|
| 96 | 96 | |
| 97 | 97 | // |
| 98 | - ['hack' , '15', 'Hacking', true], |
|
| 98 | + [ 'hack', '15', 'Hacking', true ], |
|
| 99 | 99 | |
| 100 | 100 | // Attempts at SQL injection. |
| 101 | - ['sql' , '16', 'SQL Injection', true], |
|
| 101 | + [ 'sql', '16', 'SQL Injection', true ], |
|
| 102 | 102 | |
| 103 | 103 | // Email sender spoofing. |
| 104 | - ['spoof' , '17', 'Spoofing', true], |
|
| 104 | + [ 'spoof', '17', 'Spoofing', true ], |
|
| 105 | 105 | |
| 106 | 106 | // Credential brute-force attacks on webpage logins and services like SSH, FTP, SIP, SMTP, RDP, etc. |
| 107 | 107 | // This category is seperate from DDoS attacks. |
| 108 | - ['brute' , '18', 'Brute-Force', true], |
|
| 108 | + [ 'brute', '18', 'Brute-Force', true ], |
|
| 109 | 109 | |
| 110 | 110 | // Webpage scraping (for email addresses, content, etc) and crawlers that do not honor robots.txt. |
| 111 | 111 | // Excessive requests and user agent spoofing can also be reported here. |
| 112 | - ['badbot' , '19', 'Bad Web Bot', true], |
|
| 112 | + [ 'badbot', '19', 'Bad Web Bot', true ], |
|
| 113 | 113 | |
| 114 | 114 | // Host is likely infected with malware and being used for other attacks or to host malicious content. |
| 115 | 115 | // The host owner may not be aware of the compromise. This category is often used in combination |
| 116 | 116 | // with other attack categories. |
| 117 | - ['explhost' , '20', 'Exploited Host', true], |
|
| 117 | + [ 'explhost', '20', 'Exploited Host', true ], |
|
| 118 | 118 | |
| 119 | 119 | // Attempts to probe for or exploit installed web applications such as a CMS |
| 120 | 120 | // like WordPress/Drupal, e-commerce solutions, forum software, phpMyAdmin and |
| 121 | 121 | // various other software plugins/solutions. |
| 122 | - ['webattack' , '21', 'Web App Attack', true ], |
|
| 122 | + [ 'webattack', '21', 'Web App Attack', true ], |
|
| 123 | 123 | |
| 124 | 124 | // Secure Shell (SSH) abuse. Use this category in combination |
| 125 | 125 | // with more specific categories. |
| 126 | - ['ssh' , '22', 'SSH', false], |
|
| 126 | + [ 'ssh', '22', 'SSH', false ], |
|
| 127 | 127 | |
| 128 | 128 | // Abuse was targeted at an "Internet of Things" type device. Include |
| 129 | 129 | // information about what type of device was targeted in the comments. |
| 130 | - ['oit' , '23', 'IoT Targeted', true], |
|
| 130 | + [ 'oit', '23', 'IoT Targeted', true ], |
|
| 131 | 131 | ]; |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function getCategoryIdbyName(string $categoryName) |
| 154 | 154 | { |
| 155 | - foreach ($this->aipdbApiCategories as $cat){ |
|
| 156 | - if ($cat[0] === $categoryName) { |
|
| 155 | + foreach ($this->aipdbApiCategories as $cat) { |
|
| 156 | + if ($cat[ 0 ] === $categoryName) { |
|
| 157 | 157 | return $cat; |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | public function getCategoryNameById(string $categoryId) |
| 174 | 174 | { |
| 175 | - foreach ($this->aipdbApiCategories as $cat){ |
|
| 176 | - if ($cat[1] === $categoryId) { |
|
| 175 | + foreach ($this->aipdbApiCategories as $cat) { |
|
| 176 | + if ($cat[ 1 ] === $categoryId) { |
|
| 177 | 177 | return $cat; |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -194,8 +194,8 @@ discard block |
||
| 194 | 194 | protected function getCategoryIndex(string $value, int $index) |
| 195 | 195 | { |
| 196 | 196 | $i = 0; |
| 197 | - foreach ($this->aipdbApiCategories as $cat){ |
|
| 198 | - if ($cat[$index] === $value) { |
|
| 197 | + foreach ($this->aipdbApiCategories as $cat) { |
|
| 198 | + if ($cat[ $index ] === $value) { |
|
| 199 | 199 | return $i; |
| 200 | 200 | } |
| 201 | 201 | $i++; |
@@ -229,21 +229,21 @@ discard block |
||
| 229 | 229 | foreach ($cats as $cat) { |
| 230 | 230 | |
| 231 | 231 | // get index on our array of categories |
| 232 | - $catIndex = is_numeric($cat) ? $this->getCategoryIndex($cat, 1) : $this->getCategoryIndex($cat, 0); |
|
| 232 | + $catIndex = is_numeric($cat) ? $this->getCategoryIndex($cat, 1) : $this->getCategoryIndex($cat, 0); |
|
| 233 | 233 | |
| 234 | 234 | // check if found |
| 235 | - if ($catIndex === false ){ |
|
| 235 | + if ($catIndex === false) { |
|
| 236 | 236 | throw new \InvalidArgumentException('Invalid report category was given.'); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // get Id |
| 240 | - $catId = $this->aipdbApiCategories[$catIndex][1]; |
|
| 240 | + $catId = $this->aipdbApiCategories[ $catIndex ][ 1 ]; |
|
| 241 | 241 | |
| 242 | 242 | // need another ? |
| 243 | - if ($needAnother !== false){ |
|
| 243 | + if ($needAnother !== false) { |
|
| 244 | 244 | |
| 245 | 245 | // is a standalone cat ? |
| 246 | - if ($this->aipdbApiCategories[$catIndex][3] === false) { |
|
| 246 | + if ($this->aipdbApiCategories[ $catIndex ][ 3 ] === false) { |
|
| 247 | 247 | $needAnother = true; |
| 248 | 248 | |
| 249 | 249 | } else { |
@@ -254,10 +254,10 @@ discard block |
||
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | // set or add to cats list |
| 257 | - $catsString = ($catsString === '') ? $catId : $catsString .','.$catId; |
|
| 257 | + $catsString = ($catsString === '') ? $catId : $catsString . ',' . $catId; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - if ($needAnother !== false){ |
|
| 260 | + if ($needAnother !== false) { |
|
| 261 | 261 | throw new \InvalidArgumentException('Invalid report category parameter given: this category can\'t be used alone.'); |
| 262 | 262 | } |
| 263 | 263 | |
@@ -38,8 +38,8 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | protected function setCurlOption($ch, int $option, $value): void |
| 40 | 40 | { |
| 41 | - if(!curl_setopt($ch,$option,$value)){ |
|
| 42 | - throw new \RuntimeException('curl_setopt failed! '.curl_error($ch)); |
|
| 41 | + if (!curl_setopt($ch, $option, $value)) { |
|
| 42 | + throw new \RuntimeException('curl_setopt failed! ' . curl_error($ch)); |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function report(string $ip, string $categories, string $message): ApiResponse |
| 94 | 94 | { |
| 95 | - // ip must be set |
|
| 95 | + // ip must be set |
|
| 96 | 96 | if (empty($ip)){ |
| 97 | 97 | throw new \InvalidArgumentException('Ip was empty'); |
| 98 | 98 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | // option |
| 233 | 233 | if ($verbose){ |
| 234 | - $data['verbose'] = true; |
|
| 234 | + $data['verbose'] = true; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | return $this->apiRequest('check', $data, 'GET') ; |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | * @access public |
| 404 | 404 | * @param string $message The original message |
| 405 | 405 | * |
| 406 | - * @return string |
|
| 406 | + * @return string |
|
| 407 | 407 | */ |
| 408 | 408 | public function cleanMessage(string $message): string |
| 409 | 409 | { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @access protected |
| 45 | 45 | * @var array |
| 46 | 46 | */ |
| 47 | - protected $selfIps = []; |
|
| 47 | + protected $selfIps = [ ]; |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Constructor |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param array $myIps The Ips/domain name you don't want to display in report messages |
| 55 | 55 | * |
| 56 | 56 | */ |
| 57 | - public function __construct(string $apiKey, array $myIps = []) |
|
| 57 | + public function __construct(string $apiKey, array $myIps = [ ]) |
|
| 58 | 58 | { |
| 59 | 59 | $this->aipdbApiKey = $apiKey; |
| 60 | 60 | $this->selfIps = $myIps; |
@@ -98,17 +98,17 @@ discard block |
||
| 98 | 98 | public function report(string $ip, string $categories, string $message): ApiResponse |
| 99 | 99 | { |
| 100 | 100 | // ip must be set |
| 101 | - if (empty($ip)){ |
|
| 101 | + if (empty($ip)) { |
|
| 102 | 102 | throw new \InvalidArgumentException('Ip was empty'); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // categories must be set |
| 106 | - if (empty($categories)){ |
|
| 106 | + if (empty($categories)) { |
|
| 107 | 107 | throw new \InvalidArgumentException('Categories list was empty'); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | // message must be set |
| 111 | - if (empty($message)){ |
|
| 111 | + if (empty($message)) { |
|
| 112 | 112 | throw new \InvalidArgumentException('Report message was empty'); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -164,16 +164,16 @@ discard block |
||
| 164 | 164 | public function bulkReport(string $filePath): ApiResponse |
| 165 | 165 | { |
| 166 | 166 | // check file exists |
| 167 | - if (!file_exists($filePath) || !is_file($filePath)){ |
|
| 167 | + if (!file_exists($filePath) || !is_file($filePath)) { |
|
| 168 | 168 | throw new \InvalidArgumentException('The file [' . $filePath . '] does not exist.'); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // check file is readable |
| 172 | - if (!is_readable($filePath)){ |
|
| 172 | + if (!is_readable($filePath)) { |
|
| 173 | 173 | throw new InvalidPermissionException('The file [' . $filePath . '] is not readable.'); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - return $this->apiRequest('bulk-report', [], 'POST', $filePath); |
|
| 176 | + return $this->apiRequest('bulk-report', [ ], 'POST', $filePath); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -197,11 +197,11 @@ discard block |
||
| 197 | 197 | public function clearAddress(string $ip): ApiResponse |
| 198 | 198 | { |
| 199 | 199 | // ip must be set |
| 200 | - if (empty($ip)){ |
|
| 200 | + if (empty($ip)) { |
|
| 201 | 201 | throw new \InvalidArgumentException('IP argument must be set.'); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - return $this->apiRequest('clear-address', ['ipAddress' => $ip ], "DELETE") ; |
|
| 204 | + return $this->apiRequest('clear-address', [ 'ipAddress' => $ip ], "DELETE"); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | public function check(string $ip, int $maxAgeInDays = 30, bool $verbose = false): ApiResponse |
| 220 | 220 | { |
| 221 | 221 | // max age must be less or equal to 365 |
| 222 | - if ( $maxAgeInDays > 365 || $maxAgeInDays < 1 ){ |
|
| 222 | + if ($maxAgeInDays > 365 || $maxAgeInDays < 1) { |
|
| 223 | 223 | throw new \InvalidArgumentException('maxAgeInDays must be between 1 and 365.'); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | // ip must be set |
| 227 | - if (empty($ip)){ |
|
| 227 | + if (empty($ip)) { |
|
| 228 | 228 | throw new \InvalidArgumentException('ip argument must be set (empty value given)'); |
| 229 | 229 | } |
| 230 | 230 | |
@@ -235,11 +235,11 @@ discard block |
||
| 235 | 235 | ]; |
| 236 | 236 | |
| 237 | 237 | // option |
| 238 | - if ($verbose){ |
|
| 239 | - $data['verbose'] = true; |
|
| 238 | + if ($verbose) { |
|
| 239 | + $data[ 'verbose' ] = true; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - return $this->apiRequest('check', $data, 'GET') ; |
|
| 242 | + return $this->apiRequest('check', $data, 'GET'); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -288,12 +288,12 @@ discard block |
||
| 288 | 288 | public function checkBlock(string $network, int $maxAgeInDays = 30): ApiResponse |
| 289 | 289 | { |
| 290 | 290 | // max age must be between 1 and 365 |
| 291 | - if ($maxAgeInDays > 365 || $maxAgeInDays < 1){ |
|
| 291 | + if ($maxAgeInDays > 365 || $maxAgeInDays < 1) { |
|
| 292 | 292 | throw new \InvalidArgumentException('maxAgeInDays must be between 1 and 365 (' . $maxAgeInDays . ' was given)'); |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // ip must be set |
| 296 | - if (empty($network)){ |
|
| 296 | + if (empty($network)) { |
|
| 297 | 297 | throw new \InvalidArgumentException('network argument must be set (empty value given)'); |
| 298 | 298 | } |
| 299 | 299 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | public function blacklist(int $limit = 10000, bool $plainText = false, int $confidenceMinimum = 100): ApiResponse |
| 324 | 324 | { |
| 325 | - if ($limit < 1){ |
|
| 325 | + if ($limit < 1) { |
|
| 326 | 326 | throw new \InvalidArgumentException('limit must be at least 1 (' . $limit . ' was given)'); |
| 327 | 327 | } |
| 328 | 328 | |
@@ -334,8 +334,8 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | // plaintext paremeter has no value and must be added only when true |
| 336 | 336 | // (set plaintext=false won't work) |
| 337 | - if ($plainText){ |
|
| 338 | - $data['plaintext'] = $plainText; |
|
| 337 | + if ($plainText) { |
|
| 338 | + $data[ 'plaintext' ] = $plainText; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | return $this->apiRequest('blacklist', $data, 'GET'); |
@@ -370,8 +370,8 @@ discard block |
||
| 370 | 370 | $ch = curl_init(); |
| 371 | 371 | |
| 372 | 372 | // for csv |
| 373 | - if (!empty($csvFilePath)){ |
|
| 374 | - $cfile = new \CurlFile($csvFilePath, 'text/csv', 'csv'); |
|
| 373 | + if (!empty($csvFilePath)) { |
|
| 374 | + $cfile = new \CurlFile($csvFilePath, 'text/csv', 'csv'); |
|
| 375 | 375 | //curl file itself return the realpath with prefix of @ |
| 376 | 376 | $data = array('csv' => $cfile); |
| 377 | 377 | } |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | $message = str_replace('\\', '', $message); |
| 417 | 417 | |
| 418 | 418 | // Remove self ips |
| 419 | - foreach ($this->selfIps as $ip){ |
|
| 419 | + foreach ($this->selfIps as $ip) { |
|
| 420 | 420 | $message = str_replace($ip, '*', $message); |
| 421 | 421 | } |
| 422 | 422 | |
@@ -110,6 +110,6 @@ |
||
| 110 | 110 | */ |
| 111 | 111 | public function errors(): array |
| 112 | 112 | { |
| 113 | - return ($this->decodedResponse && $this->decodedResponse->errors) ? $this->decodedResponse->errors : []; |
|
| 113 | + return ($this->decodedResponse && $this->decodedResponse->errors) ? $this->decodedResponse->errors : [ ]; |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | \ No newline at end of file |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | public function report(string $ip, string $categories, string $message): ApiResponse |
| 65 | 65 | { |
| 66 | 66 | try { |
| 67 | - return parent::report($ip,$categories,$message); |
|
| 67 | + return parent::report($ip, $categories, $message); |
|
| 68 | 68 | } catch (\Exception $e) { |
| 69 | 69 | return $this->getErrorResponse($e->getMessage()); |
| 70 | 70 | } |