By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,807 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,807 IT Pros & Developers. It's quick & easy.

I need a litle help about fsockopen function

P: 1
I need a little help with the fsockopen function.

I have this PHP code

Expand|Select|Wrap|Line Numbers
  1.    if (    in_array($_SERVER['REMOTE_PORT'], array(8080,80,6588,8000,3128,553,554,47830,50070))
  2.     || @fsockopen($_SERVER['REMOTE_ADDR'], 80, $errno, $errstr, 1))
I need to make @fsockopen check IPs by port 80 if it doesn't request authentication.

I think I should use isset($_SERVER['PHP_AUTH_USER']) in there somewhere, but I can't do it by myself. Can anyone help?

Thank you very much
Nov 24 '11 #1
Share this Question
Share on Google+
1 Reply


P: 13
$_SERVER['REMOTE_PORT'] is a random port of the visiting user.
$_SERVER['REMOTE_ADDR'] is the IP of the visiting User.

Why are you checking a random non standardport against a fixed list of standard ports?.

If you want to check if the visitor is using Port 80, check $_SERVER["SERVER_PORT"] as this is the port the user is connected by the protocol he is using.

2nd question is, where do you want to connect to? To the visitors PC, 99% chance he is behind a Firewall and has no local http server running.
Nov 26 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.