All pastes #450517 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-20 22:18 UTC
rendered paste body
<?php

require_once('db_in.php');

set_time_limit(900);

$url = 'https://post.craigslist.org/aus/';

$q1 = "select ID, PROXY from proxies where UNIX_TIMESTAMP()-UNIX_TIMESTAMP(LAST_CHECKED)>600 and NUM<1 and LOCKED=0 limit 30";
$r1 = mysql_query($q1);

$a = $b = 0;

while($row1 = mysql_fetch_object($r1)) {
	$a++;
	$data = getURL($url,$row1->PROXY);
	$find = 'create&nbsp;posting';
	$p = strpos($data, $find);
	echo $data."<br><br><br>";
	if($p !== false) {
		$b++;
		$q2 = "update proxies set CHECKED=1, LAST_CHECKED=now(), GOOD=1, NUM=0 where ID=".$row1->ID;
	}
	else {
		$q2 = "update proxies set NUM=NUM+1, GOOD=0 where ID=".$row1->ID;
		echo $row1->PROXY." - BAD2<br>";
	}
	$r2 = mysql_query($q2);
}

echo $b . "/" . $a . " good proxies";


function getURL($url,$proxy,$post='') {

	$data = '';
	//$cookie = 'C:\Program Files\xampp\htdocs\cl\cookies\cookies\cookies.txt';
	$ch = curl_init() or die(curl_error());
	curl_setopt($ch, CURLOPT_URL,$url);
	//curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
	curl_setopt($ch, CURLOPT_HTTPHEADER, array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2","Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5","Accept-Language: en-us,en;q=0.5","Accept-Encoding: *","Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7","Keep-Alive: 300","Connection: keep-alive","Expect: "));
	//curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
	//curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
	//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt ($ch, CURLOPT_TIMEOUT, 10);
	curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
	curl_setopt ($ch, CURLOPT_PROXY, $proxy);
	if($post!='') {
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
	}
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$data = curl_exec($ch);// or die(curl_error($ch));
	curl_close($ch);
	return $data;

}
?>