0

Hi,

This is a basic cURL web proxy script.
Why is it showing weird array pattern looking errors ?

<?php

function CURLGetURL($url){

// use CURL to make request

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url); // the url to retrieve
curl_setopt($ch, CURLOPT_HEADER, 1); // return the header along with body
curl_setopt($ch, CURLOPT_MAXREDIRS, 3); // follow this amount of redirects
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,5); // follow redirects - change or paramterize
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return output as string
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //ignore issues with SSL certificates
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); // connection timeout in seconds
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4"); // the useragent to connect with

// get response and set array up

$urlinfo["html"] = curl_exec($ch);
$urlinfo["status"] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$urlinfo["error"] = curl_error($ch);
$urlinfo["headers"] = curl_getinfo($ch);

curl_close($ch);

// return hash table of response
return $urlinfo;
}

// example
$http = CURLGetURL("http://www.ebay.com");

if($http){

if($http["status"] == 200){

// we got a valid 200 OK response - output html
echo $http["html"];

}else{

// show error
echo "returned a " . $http["status"] . " status error";

// output error details
print_r( $http["error"] );

// output all header info
print_r( $http["headers"] );

}
}
?> 

I get this error:

returned a 403 status errorArray ( [url] => http://www.ebay.com/ [content_type] => text/html [http_code] => 403 [header_size] => 208 [request_size] => 181 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.672 [namelookup_time] => 0.266 [connect_time] => 0.453 [pretransfer_time] => 0.453 [size_upload] => 0 [size_download] => 261 [speed_download] => 388 [speed_upload] => 0 [download_content_length] => 261 [upload_content_length] => -1 [starttransfer_time] => 0.672 [redirect_time] => 0 [redirect_url] => [primary_ip] => 23.42.49.103 [certinfo] => Array ( ) [primary_port] => 80 [local_ip] => 10.2.3.100 [local_port] => 51660 )

1
Contributor
1
Reply
17
Views
4 Months
Discussion Span
Last Post by UI
0

Quite frankly, I've had enough of this web proxy script. I'm moving onto others. Do you guys know of any good stable web proxy php scripts ?
I'm going to add my link tracker code so the proxified links get click-tracked. That's all. Tried MiniProxy and managed to add the tracker but it tracks not only the page the user is in but any links present on the page the user is at and tracking those extra links is not what I want and so I was looking into this proxy script instead which is now becoming more bothersome than the first.
Not interested in Glype. Looking into Php-Proxy now and a few others.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.