getCityFull($ip) ?: ['country' => ['name_ru' => 'undefined'], 'city' => ['name_ru' => 'undefined', 'lat' => 0, 'lon' => 0], 'region' => ['name_ru' => 'undefined']]; } /** * Получение списка стандартных портов * * @return int[] */ function getDefaultPortList(): array { return [ 7, 9, 20, 21, 22, 23, 25, 53, 67, 68, 69, 80, 110, 123, 143, 161, 443, 993, 995, 3389, 8080, 33434, ]; } /** * Получение открытых портов * * @param string|null $ip * @return array */ function getOpenedPorts(?string $ip = null): array { if (empty($ip)) { $ip = getIP(); } $result = []; $scanList = getDefaultPortList(); foreach ($scanList as $port){ $connection = @fsockopen(hostname: $ip, port: $port, timeout: 0.1); // 0.05 if (is_resource($connection)){ $result[] = [ 'port' => $port, 'service' => getservbyport($port, 'tcp') ]; fclose($connection); } } return $result; }