Login   Register  
PHP Classes
elePHPant
Icontem

File: proxycurl.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Martin Fasani  >  HTTP Request class  >  proxycurl.php  >  Download  
File: proxycurl.php
Role: Auxiliary script
Content type: text/plain
Description: Simple CURL proxy
Class: HTTP Request class
Generate Javascript to send HTTP AJAX requests
Author: By
Last change:
Date: 2005-08-23 03:47
Size: 1,011 bytes
 

Contents

Class file image Download
<? 
/*
Author : Martin Fasani [ www.movil.be ]
lastMod: 20050701 [YYYYMMDD]
Simple CURL proxy.
The headers info and request are sent by the other page, so this acts just as a proxy.
*/

$send     $GLOBALS['HTTP_RAW_POST_DATA']; 
$header[] = "MessageType:$_SERVER[HTTP_MESSAGETYPE]"
$header[] = "Content-Type:$_SERVER[CONTENT_TYPE]";   
$ch      curl_init();


/*
API KEY NEEDS TO BE INSERTED HERE
NOTICE that in order to avoid pasting the googleAPI key in public we will replace it here:
                                                 |
*/

$send    ereg_replace("@apikey","googleAPIkey",$send);

curl_setopt($chCURLOPT_URL,      $_GET['url'] );
curl_setopt($chCURLOPT_POST,     1);
curl_setopt($chCURLOPT_POSTFIELDS,    $send);
curl_setopt ($chCURLOPT_HTTPHEADER$header);
if (!
ch) { die ("Cannot initialize a new cURL handle\n"); }
$data curl_exec($ch);
if (
is_int($data)) {
    die (
"cURL error:".curl_error($ch)."\n"); 
}
echo 
$data;
curl_close($ch);
?>