| Conditions | 3 |
| Paths | 3 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 14 | public function collect(): array |
||
| 15 | { |
||
| 16 | // @todo use already collected ip address |
||
| 17 | $ip = file_get_contents('https://api.ipify.org'); |
||
| 18 | $data = json_decode(file_get_contents("http://ip-api.com/json/" . $ip), true); |
||
| 19 | |||
| 20 | $asnArray = explode(' ', $data['as']); |
||
| 21 | |||
| 22 | $asn = substr($asnArray[0], 2); |
||
| 23 | $as = $data['as']; |
||
| 24 | |||
| 25 | $short = $as; |
||
| 26 | |||
| 27 | if (str_contains(strtolower($short), 'hetzner')) { |
||
| 28 | $short = 'hetzner'; |
||
| 29 | } else if (str_contains(strtolower($short), 'velia')) { |
||
| 30 | $short = 'velia'; |
||
| 31 | } |
||
| 32 | |||
| 33 | return [ |
||
| 34 | 'as' => $as, |
||
| 35 | 'asn' => $asn, |
||
| 36 | 'short' => $short |
||
| 37 | ]; |
||
| 40 |