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. :)

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.