Skip to content

Instantly share code, notes, and snippets.

@micc83
Last active December 22, 2015 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micc83/6446989 to your computer and use it in GitHub Desktop.
Save micc83/6446989 to your computer and use it in GitHub Desktop.
Proxy check
<?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