View Single Post
Old 28 June, 2009, 17:16 PM   #1 (permalink)
xrvel xrvel is offline
Newbie Net Builder
 
xrvel's Avatar
 
Location: ProxyCoder.com
iTrader: (0)
Blog Entries: 1
Thanked 18 Times in 8 Posts
Posts: 37
$NetBucks: 65
Join Date: Mar 2009
Last Online: 8 January, 2010 15:46 PM
Lightbulb Proxy Checker (for Proxy List)

Here is a code to check some proxies in your proxy list.
It checks dead or not, and the reciprocal status

Edit :
It can be used for all proxy listing script (devduke's or other's).
Because the input is only plain URL.
And the output is a basic array.

But it should be customized and modified further (which i can not write here, because it depends to each proxy list script) including :
- update the proxy status on the database.

PHP Code:
<?php
//
// Proxy list cleaner
//
// Author : Xrvel (xrvel.com)
//
// This cron script check each proxy and :
// - update its status (dead or alive).
// - check backlink
//
// Requirement :
// - PHP CURL
//
// Note that this function only check the URL.
// It does not mark it on database whether it is dead or not,
// So you must add your custom code yourself if you want
// it to automatically mark dead proxies on your database.
//

// Do not modify start
ob_start();
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()-60).' GMT');
header('Cache-Control: private, no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');
header('Pragma: no-cache');
//error_reporting(E_ALL);
ignore_user_abort(true);
set_time_limit(60 5);
session_start();
// Do not modify end

//
// Here is the proxy URL which you want to check
// You can customize it to receive URL from form / database
// Could be a string, or an array of string
//

/*
$proxy_url = array(
    'http://someonesproxy1.com',
    'http://someonesproxy2.com',
    'http://someonesproxy3.com'
);
*/

$proxy_url 'http://example.com';

//
// Reciprocal is marked as "found"
// if this string is found in the proxy's page
// But this script can not detect whether the reciprocal
// is on HTML comment / hidden section or such.
// You must manually check it (human editor)
//
$reciprocal_match 'yourdomain.com';

// Example :
$result check_the_proxy($proxy_url);
echo 
'<pre>'print_r($resulttrue), '</pre>';

//
// No need to modify anything below
//

//
// MAIN FUNCTION START
//
// Return type : array of mixed
//
function check_the_proxy($proxy_url) {
    global 
$reciprocal_match;

    
$proxies = array();// everything will be put here

    
if (is_string($proxy_url)) {
        
$proxy_url = array($proxy_url);
    }

    foreach (
$proxy_url as $u) {
        
$proxies[] = array(
            
'url' => $u,
            
'is_dead' => 0,
            
'http_code' => '',
            
'download_content_length' => '',
            
'reciprocal_found' => 0,
            
'curl_info' => array()
        );
    }
    unset(
$proxy_url);

    
$ch curl_init();
    
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt($chCURLOPT_AUTOREFERERtrue);
    
curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue);
    
curl_setopt($chCURLOPT_MAXREDIRS2);
    
curl_setopt($chCURLOPT_USERAGENT'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6');
    
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
    
curl_setopt($chCURLOPT_TIMEOUT30);

    
$i 0;

    
// loop for each proxy
    
foreach ($proxies as $data) {
        
curl_setopt($chCURLOPT_URL$data['url']);
        
curl_setopt($chCURLOPT_REFERER$data['url']);
        
$res curl_exec($ch);
        
$info curl_getinfo($ch);

        
$proxies[$i]['curl_info'] = $info;
        
$proxies[$i]['http_code'] = $info['http_code'];
        
$proxies[$i]['download_content_length'] = $info['download_content_length'];

        
// Check is dead ?
        
if ($info['http_code'] == '200' || $info['http_code'] == '300' || $info['http_code'] == '301') {
            
$proxies[$i]['is_dead'] = 0;
        } else {
            
$proxies[$i]['is_dead'] = 1;
        }

        
// Check reciprocal
        
if (stristr($res$reciprocal_match)) {
            
$proxies[$i]['reciprocal_found'] = 1;
        } else {
            
$proxies[$i]['reciprocal_found'] = 0;
        }
        
$i++;
    }    
    
curl_close($ch);
    unset(
$ch$res);

    return 
$proxies;
}
// MAIN FUNCTION END
?>
Output example :
Code:
Array
(
    [0] => Array
        (
            [url] => http://example.com
            [is_dead] => 0
            [http_code] => 200
            [download_content_length] => 438
            [reciprocal_found] => 0
            [curl_info] => Array
                (
                    [url] => http://example.com
                    [content_type] => text/html; charset=UTF-8
                    [http_code] => 200
                    [header_size] => 276
                    [request_size] => 183
                    [filetime] => -1
                    [ssl_verify_result] => 0
                    [redirect_count] => 0
                    [total_time] => 7.071
                    [namelookup_time] => 6.339
                    [connect_time] => 6.475
                    [pretransfer_time] => 6.476
                    [size_upload] => 0
                    [size_download] => 438
                    [speed_download] => 61
                    [speed_upload] => 0
                    [download_content_length] => 438
                    [upload_content_length] => 0
                    [starttransfer_time] => 7.071
                    [redirect_time] => 0
                )

        )

)
__________________
. Xrvel . Free Proxy List Script (BETA) .
Anyone want to join open source proxy list project? Let's work with subversion. PM me for details.
Domains for sale : ihidden.com

Last edited by xrvel; 28 June, 2009 at 17:48 PM..
  Reply With Quote