pinacoladaxb Posted March 19, 2009 Share Posted March 19, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/150075-php-page-that-checks-if-a-port-is-forwarded-to-a-users-computer/ Share on other sites More sharing options...
hellonoko Posted March 19, 2009 Share Posted March 19, 2009 Have you set some open and some closed to test it? Quote Link to comment https://forums.phpfreaks.com/topic/150075-php-page-that-checks-if-a-port-is-forwarded-to-a-users-computer/#findComment-788210 Share on other sites More sharing options...
pinacoladaxb Posted March 19, 2009 Author Share Posted March 19, 2009 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... Quote Link to comment https://forums.phpfreaks.com/topic/150075-php-page-that-checks-if-a-port-is-forwarded-to-a-users-computer/#findComment-788227 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.