0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-16 15:47:55 +01:00
doodle3d-client/proxy.php
peteruithoven 6df5e255c2 Basic feedback and more control
Display temperature
Only show temperature when connected with printer
Move index.html javascript to main.js
stop button (Still having issues in firmware)
OOP style printer control
Added a proxy.php file to forward cross domain posts and get's. (should
not be necessary)
2013-08-07 20:47:47 +02:00

36 lines
922 B
PHP

<?php
/*$url = $_GET['url'];
if ( !$url ) {
$url = $_POST['url'];
}*/
$target_url = "http://192.168.5.1/cgi-bin/d3dapi/";
$target_api = str_replace("/proxy5.php/","",$_SERVER["REQUEST_URI"]);
$target_url .= $target_api;
//echo "target_url: ".$target_url;
$postdata = file_get_contents("php://input");
$ok = true;
$c = curl_init();
curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type' => 'application/xml'));
curl_setopt($c, CURLOPT_URL, $target_url);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS,$postdata);
$result = curl_exec ($c);
curl_close ($c);
if(!
$result)
{
$ok = false;
$error = "Failed to forward HTTP request to: {$target_url}\r\n" . var_export(error_get_last(),true) . "\r\n{$postdata}";
error_log($error);
error_log($error, 1, "my-email-address@my-test-domain.com");
}
if(!
$ok)
header('HTTP/1.1 500 Internal Server Error');
else
header('HTTP/1.1 200 OK');
?>