Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // thx for : https://stackoverflow.com/questions/9841635/how-can-i-ping-a-server-port-with-php
- // include "config.php";
- $fileloc = "./iplist.ini";
- function getList_ip($file_ini){
- $data = parse_ini_file($file_ini,true);
- // $data = json_encode($rawdata);
- return $data;
- }
- function pinger($list){
- // $host_ipaddress = $ip_port['ip'];
- // $host_port []= $ip_port['port'];
- // $hostname = $host;
- $wait = 1; // wait Timeout In Seconds
- var_dump($list);
- echo "-----------------------------\n";
- // var_dump($list['hostname_1']['port']);
- $x=0;
- foreach ($list as $key => $thisHost) {
- $array_port =$thisHost['port'];
- $pecah_port[$x]= array_map('intval', explode(',', $list[$key]['port']));
- // echo "ping $thisHost[ip] port : $thisHost[port]";
- print_r($pecah_port);
- echo "\n";
- $x++;
- }
- # code...
- $pecah_port[$thisHost['ip']]= array_map('intval', explode(',', $array_port));
- // var_dump($pecah_port);
- // return $fp;
- // var_dump(pinger($host,$ip,$port));
- }
- $listHost = getList_ip($fileloc);
- // print_r($listHost);
- $listHost2 = pinger($listHost);
- $host = 'imzazmi.com';
- $ports = [
- 'http' => 80,
- 'https' => 4434,
- 'ftp' => 21,
- ];
- // foreach ($ports as $key => $port) {
- // $fp = @fsockopen($host, $port, $errCode, $errStr, $wait);
- // echo "Ping $host:$port ($key) ==> ";
- // if ($fp) {
- // echo 'SUCCESS';
- // fclose($fp);
- // } else {
- // echo "ERROR: $errCode - $errStr";
- // }
- // }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment