mmattax, - script.
script , urlencoded proxy_url.
url_proxy.php
$url = ($_POST['proxy_url']) ? $_POST['proxy_url'] : $_GET['proxy_url'];
$session = curl_init($url);
if ($_POST['proxy_url']) {
$postvars = '';
while ($element = current($_POST)) {
if (key($_POST) != 'proxy_url') {
$postvars .= key($_POST).'='.$element.'&';
}
next($_POST);
}
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars);
}
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
if (curl_errno($session)) {
$error_message = curl_error($session);
echo 'Error: '.$error_message;
} else {
echo $response;
}
curl_close($session);
?>
, xml, .
webroot javascript - :
function showMapLegend(baseURL, layer) {
var url = 'http://our-map-server/get-a-legend.php?layer='+layer;
var dt = new Date();
var proxy = baseURL + '/url_proxy.php?currDate='+dt.getTime()+'&proxy_url=';
url = proxy + encodeURIComponent(url);
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport) {
$('map-legend-img').src = transport.responseText;
new Effect.Appear('map-legend', {duration: 0.5});
}
});
}
The javascript function example above is used to get a simple URL string back from our map server, we don’t care if it doesn’t work, therefore there is no onFailure, etc., and basically it is Prototype, but I'm sure you got an idea of how this uses a proxy script.
The baseURL variable is passed inside, it should contain the base http: // server / theappname ", as the url for your application.
source
share