Support Forums

Full Version: [Function] Test HTTP/Socks 4/Socks 5 Proxy
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
A quick function using cURL to identify if a certain proxy server is currently working/accepting connections, returns true if it is.

PHP Code:
<?php
// Live Demo: http://x32.bz/tools/proxychecker/
// Example Usage: checkproxy("222.124.223.42","3128","SOCKS 5");
function checkproxy($ip,$port,$type){
$ch curl_init("127.0.0.1");
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_HEADER0);
curl_setopt($chCURLOPT_CONNECTTIMEOUT10);
curl_setopt($chCURLOPT_TIMEOUT10);
curl_setopt($chCURLOPT_PROXY$ip ":" $port);
if(
$type == "SOCKS 4"curl_setopt($chCURLOPT_PROXYTYPECURLPROXY_SOCKS4);
else if(
$type == "SOCKS 5"curl_setopt($chCURLOPT_PROXYTYPECURLPROXY_SOCKS5);
$html curl_exec($ch);
$info curl_getinfo($ch);
if(
curl_errno($ch) || $html == "") {
return 
FALSE;
}else{
return 
TRUE;
}
curl_close($ch);