mqnoy

pinger.php

Mar 11th, 2019
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. <?php
  2. // thx for : https://stackoverflow.com/questions/9841635/how-can-i-ping-a-server-port-with-php
  3. // include "config.php";
  4. $fileloc = "./iplist.ini";
  5. function getList_ip($file_ini){
  6. $data = parse_ini_file($file_ini,true);
  7. // $data = json_encode($rawdata);
  8. return $data;
  9. }
  10. function pinger($list){
  11. // $host_ipaddress = $ip_port['ip'];
  12. // $host_port []= $ip_port['port'];
  13. // $hostname = $host;
  14.  
  15. $wait = 1; // wait Timeout In Seconds
  16. var_dump($list);
  17. echo "-----------------------------\n";
  18. // var_dump($list['hostname_1']['port']);
  19. $x=0;
  20. foreach ($list as $key => $thisHost) {
  21. $array_port =$thisHost['port'];
  22. $pecah_port[$x]= array_map('intval', explode(',', $list[$key]['port']));
  23.  
  24. // echo "ping $thisHost[ip] port : $thisHost[port]";
  25. print_r($pecah_port);
  26. echo "\n";
  27. $x++;
  28. }
  29. # code...
  30. $pecah_port[$thisHost['ip']]= array_map('intval', explode(',', $array_port));
  31. // var_dump($pecah_port);
  32.  
  33.  
  34.  
  35. // return $fp;
  36. // var_dump(pinger($host,$ip,$port));
  37. }
  38.  
  39. $listHost = getList_ip($fileloc);
  40. // print_r($listHost);
  41. $listHost2 = pinger($listHost);
  42.  
  43.  
  44.  
  45.  
  46. $host = 'imzazmi.com';
  47. $ports = [
  48. 'http' => 80,
  49. 'https' => 4434,
  50. 'ftp' => 21,
  51. ];
  52.  
  53. // foreach ($ports as $key => $port) {
  54. // $fp = @fsockopen($host, $port, $errCode, $errStr, $wait);
  55. // echo "Ping $host:$port ($key) ==> ";
  56. // if ($fp) {
  57. // echo 'SUCCESS';
  58. // fclose($fp);
  59. // } else {
  60. // echo "ERROR: $errCode - $errStr";
  61. // }
  62. // }
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment