fsockopen端口检查脚本

时间:2017-09-12 20:39:34

标签: php html fsockopen

我有一个使用PHP和fsockopen的脚本来检查端口是打开还是关闭。它在某些时候工作但是我的IP地址上有几个端口,我知道它已经打开但是它已经关闭了。有人有什么建议吗?

<?php

  $timeout = "10";

if ( isset($_GET['submit'] ) )
{


        $server  = ($_GET['server']);

        $port   = ($_GET['port']);




      if ($server and $port and $timeout) {
    $verbinding =  @fsockopen("$server", $port,  $timeout);

  }
  if($verbinding) {
    echo "<mark>Port $port is open</mark><br>";
  }
  else {
    echo "<mark>Timed Out: Port $port is closed.</mark><br>";
  }



}
?>

HTML

<form method="get" action="">

Server IP/URL:<input type="text" name="server" id="server"  pattern="((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$"  required><br>

Port Number:<input type="number" name="port" id="port" min="1" max="65535"  required><br>

<input type="submit" name="submit">
</form>

提前致谢!

0 个答案:

没有答案