Search the Community
Showing results for tags 'fsockopen'.
-
Hey guys, I'm trying to show a few ips are online or not, but the return is always as online. The function I'm trying to use is the one below: <?php function ping($host) { $conectado = fsockopen($host, 80, $numeroDoErro, $stringDoErro, 255); if ($conectado) { return true; }else{ return false; fclose($conectado); } } ?> The variable $host receives an ip like this: 172.16.10.50 I'm calling the function like this: $ping = ping($dados[ip]); I need some extra configuration to work properly?
-
Hey I'm running a website where I get quite a few proxy users evading bans. As an attempt to block them, I added this code: if(@fsockopen($_SERVER['REMOTE_ADDR'], 80, $errstr, $errno, 1)) die("Your magical proxy adventure ends here."); if(@fsockopen($_SERVER['REMOTE_ADDR'], 3128, $errstr, $errno, 1)) die("Your magical proxy adventure ends here."); if(@fsockopen($_SERVER['REMOTE_ADDR'], 8080, $errstr, $errno, 1)) die("Your magical proxy adventure ends here."); I know it probably could be a little shorter, but it worked which was the main thing. However, a few of my users run legitimate websites off their home networks, so they ended up being blocked by this. I've attempted something, but I am receiving the error: syntax error, unexpected '{', expecting '(' on the first ELSE IF clause. The full code is: if (in_array($_SERVER['REMOTE_ADDR'], $whitelist)) { // User is whitelisted, so we continue without going to the check. } else if { if (@fsockopen($_SERVER['REMOTE_ADDR'], 80, $errstr, $errno, 1) || (@fsockopen($_SERVER['REMOTE_ADDR'], 8080, $errstr, $errno, 1) || (@fsockopen($_SERVER['REMOTE_ADDR'], 3128, $errstr, $errno, 1) } else { // User isn't whitelisted, but is not a proxy, continue! } Can anyone point me in the right direction?
-
I'm having an issue using fsockopen to connect to smtp.gmail.com in which I always receive the error "Failed to connect to server: Connection timed out". The issue seems very similar to an old bug fixed in late 2010: https://bugs.php.net/bug.php?id=50953 I'm using the following script to test: // connect to the smtp server $smtp_conn = @fsockopen("ssl://smtp.gmail.com", // the host of the server 465, // the port to use: 25, 465, 587 $errno, // error number if any $errstr, // error message if any 5); // give up after ? secs // verify we connected properly if(empty($smtp_conn)) { $error = array("error" => "Failed to connect to server", "errno" => $errno, "errstr" => $errstr); echo "SMTP -> ERROR: " . $error["error"] . ": $errstr ($errno)\n"; } else { fclose($smtp_conn); echo "Connected!\n"; } Replacing the host argument with tsl://smtp.gmail.com or simply smtp.gmail.com and any combination of ports 25, 465, 587 also fails. Yet other smtps connect fine (e.g. smtp.live.com:587, smtp.mail.yahoo.com:465). A firewall or other blocking is not the issue. This is on a VPS with the firewall disabled and, furthermore, I can successfully connect to smtp.gmail.com (and send an email) via openssl s_client. So basic access to the server/port is not the prob. Is there any possibility this old bug (id=50953) is still lingering around in a fairly recent 5.3 version of PHP? Or any suggestions on other possible causes? I am using 5.3.17-1~dotdeb.0 and same code works fine on a different VPS with PHP 5.2.17-1.