cappa1983 Posted January 12, 2020 Share Posted January 12, 2020 Hi All - I'm trying to see if the below is possible using PHP. is it possible for php to allow a user to check if a port is open/listening on a remote server/PC, from their local machine. I've seen scripts on the web that talk about opening cmd.exe - this won't work as not all of my users will be on windows. Also saw fsock.. but the remote server is not serving http page(s). Also saw telnet, but again, some of my users may not have that windows feature enabled. Desired workflow: 1. user enters the server hostname/IP and a port 2. my php webapp will emulate checking if that hostname and port is open from the local user's computer. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/309833-check-if-port-on-remote-server-is-open-from-client-side/ Share on other sites More sharing options...
gw1500se Posted January 12, 2020 Share Posted January 12, 2020 I think you are confusing what PHP is. It is server side only. PHP does not execute on the client side (user machine). Client side code is javascript. There are some javascript port scan scripts around, just search for javascript port scanner. Quote Link to comment https://forums.phpfreaks.com/topic/309833-check-if-port-on-remote-server-is-open-from-client-side/#findComment-1573406 Share on other sites More sharing options...
cappa1983 Posted January 12, 2020 Author Share Posted January 12, 2020 while continuing my searching...I started to realized that. still fairly new to PHP. Thanks for the info! Quote Link to comment https://forums.phpfreaks.com/topic/309833-check-if-port-on-remote-server-is-open-from-client-side/#findComment-1573407 Share on other sites More sharing options...
elsafraslastra Posted September 1, 2022 Share Posted September 1, 2022 On 1/12/2020 at 3:18 PM, cappa1983 said: Hi All - I'm trying to see if the below is possible using PHP. is it possible for php to allow a user to check if a port is open/listening on a remote server/PC, from their local machine. I've seen scripts on the web that talk about opening cmd.exe - this won't work as not all of my users will be on windows. Also saw fsock.. but the remote server is not serving http page(s). Also saw telnet, but again, some of my users may not have that windows feature enabled. Desired workflow: 1. user enters the server hostname/IP and a port 2. my php webapp will emulate checking if that hostname and port is open from the local user's computer. thanks! With this routine you can check severals hosts and put in a table (must insert an up and down image). <?php $counterx = 0; echo "<table border=2 align=center>"; echo "<th>Servidor Externo</th>"; echo "<th>Est.</th>"; echo "<th>Puerto</th>"; echo '<br>'; echo '<br>'; $hostx[1] = 'www.domain1.com'; $hostx[2] = 'www.domain2.com'; $hostx[3] = 'www.domain3.com'; $port[1] = '80'; $port[2] = '443'; $port[3] = '21'; foreach ($hostx as $value) { $counterx = $counterx + 1; $connection = @fsockopen($hostx[$counterx], $port[$counterx]); if (is_resource($connection)) { echo "<tr><td width=150 style='font-size:80%'>$hostx[$counterx]</td>"; echo "<td width=10><img src='up.png'></td>"; echo "<td width=20 style='font-size:80%'>$port[$counterx]</td>"; fclose($connection); } else { echo "<tr><td width=150 style='font-size:80%'>$hostx[$counterx]</td>"; echo "<td width=10><img src='down.png'></td>"; echo "<td width=20 style='font-size:80%'>$port[$counterx]</td>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/309833-check-if-port-on-remote-server-is-open-from-client-side/#findComment-1599970 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.