예제 #1
0
header('Access-Control-Allow-Methods: GET, POST');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
/* 
 * Get the HTTP vars
 */
$svgsources = isset($_REQUEST["svgsources"]) ? $_REQUEST["svgsources"] : null;
$dumpcache = isset($_REQUEST["dumpcache"]) ? $_REQUEST["dumpcache"] : false;
$serverdomain = $_REQUEST["secure"] == 'true' || isset($_SERVER['HTTPS']) ? 'https://bitlabs.nl/svgmagic' : 'http://bitlabs.nl/svgmagic';
$version = !isset($_REQUEST["version"]) ? 2.4 : $_REQUEST["version"];
$origin = isset($_REQUEST["origin"]) ? $_REQUEST["origin"] : "undefined";
/* 
 * Init converter 
 */
$converter = new Converter($origin, $svgsources, $serverdomain, $version);
$result = $converter->start($dumpcache);
/*
 * Set status code if needed
 */
if ($result["error"] == true) {
    http_response_code(206);
}
/*
 * Show results
 * Wrap the $result in a callback if provided
 */
if (isset($_GET['callback'])) {
    echo $_GET['callback'] . '(' . json_encode($result) . ')';
} else {
    echo json_encode($result);
}