Jump to content

php page that checks if a port is forwarded to a user's computer?


pinacoladaxb

Recommended Posts

I am making an application that can only work if the user has forwarded a couple ports to their computer. I need a php page that will check if those ports are open and unblocked by the user's windows firewall. Here's what I have:

<?php
$ip=$_SERVER['REMOTE_ADDR'];//Gets user's IP address
$port = array(765,6546,6500,6515,7777,13000,13139,27900,3783,6667,28900,29900,29901);//ports that should be forwarded and unblocked
$loopindex=0;
while ($loopindex<count($port)){//loops through the ports and checks if each is open
$checkport = fsockopen($ip, $port[$loopindex], $errnum, $errstr, 2);
if(!$checkport) echo $port[$loopindex].",";//echos a list of ports that are not open
$loopindex++;
}  
?>

But when I run the script it says all of those ports are not responding. I'm no expert here, so I don't know what I did wrong. Help me please. :)

Yes, but take a look at this. All ports are closed except 21761:

Warning: fsockopen() [function.fsockopen]: unable to connect to 173.71.166.97:7777 (Connection timed out) in /home/pauliuko/public_html/atomicriot/portcheck.php on line 6
7777,
Warning: fsockopen() [function.fsockopen]: unable to connect to 173.71.166.97:21761 (Connection timed out) in /home/pauliuko/public_html/atomicriot/portcheck.php on line 6
21761,

Warning: fsockopen() [function.fsockopen]: unable to connect to 173.71.166.97:13000 (Connection timed out) in /home/pauliuko/public_html/atomicriot/portcheck.php on line 6
13000,
Warning: fsockopen() [function.fsockopen]: unable to connect to 173.71.166.97:13139 (Connection timed out) in /home/pauliuko/public_html/atomicriot/portcheck.php on line 6
13139,
Warning: fsockopen() [function.fsockopen]: unable to connect to 173.71.166.97:27900 (Connection timed out) in /home/pauliuko/public_html/atomicriot/portcheck.php on line 6
27900,

Isn't it weird that there's a space after the port that was open? Hmm...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.