Last active
December 22, 2015 08:48
-
-
Save micc83/6446989 to your computer and use it in GitHub Desktop.
Proxy check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Controlla che non si tratti di un proxy | |
*/ | |
function ipProxyPortCheck( $ip ){ | |
//timeout you want to use to test | |
$timeout = 5; | |
// ports we're going to check | |
$ports = array(80,3128,8080); | |
// flag to be returned 0 means safe, 1 means open and unsafe | |
$flag = false; | |
// loop through each of the ports we're checking | |
foreach( $ports as $port ){ | |
// this is the code that does the actual checking for the port | |
@$fp = fsockopen($ip,$port,$errno,$errstr,$timeout); | |
// test if something was returned, ie the port is open | |
if( !empty( $fp ) ){ | |
// we know the set the flag | |
$flag = true; | |
// close our connection to the IP | |
fclose($fp); | |
} | |
} | |
// send our flag back to the calling code | |
return $flag; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment