Added php proxy.

This commit is contained in:
FrozenCow 2011-04-03 17:15:19 +02:00
parent 0dca8d9cfe
commit 445f37475a
2 changed files with 33 additions and 0 deletions

View File

@ -1,6 +1,7 @@
var config = { var config = {
tileUrl: 'tiles/', tileUrl: 'tiles/',
updateUrl: 'up/', // For Apache and lighttpd updateUrl: 'up/', // For Apache and lighttpd
// updateUrl: 'up.php?path=', // For Apache and lighttpd without ability to natively proxy
// updateUrl: 'up.aspx?path=', // For IIS // updateUrl: 'up.aspx?path=', // For IIS
tileWidth: 128, tileWidth: 128,
tileHeight: 128 tileHeight: 128

32
web/up.php Normal file
View File

@ -0,0 +1,32 @@
<?php
define ('HOSTNAME', 'http://localhost:8123/up/');
$path = $_GET['path'];
$url = HOSTNAME.$path;
// Open the Curl session
$session = curl_init($url);
// If it's a POST, put the POST data in the body
if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) {
// Read the input from stdin
$postText = trim(file_get_contents('php://input'));
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $postText);
}
// Don't return HTTP headers. Do return the contents of the call
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// Make the call
$body = curl_exec($session);
header("Content-Type: ".curl_getinfo($session, CURLINFO_CONTENT_TYPE);
echo $body;
curl_close($session);
?>