2013-12-12 15:13:57 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$verb = strtolower($_SERVER['REQUEST_METHOD']);
|
|
|
|
|
|
|
|
// Send request method if nothing else is specified
|
2014-09-17 09:31:12 -04:00
|
|
|
if (empty($_GET))
|
2013-12-12 15:13:57 -05:00
|
|
|
{
|
|
|
|
echo $verb;
|
|
|
|
}
|
|
|
|
else if (isset($_GET['data']))
|
|
|
|
{
|
|
|
|
switch($verb)
|
|
|
|
{
|
|
|
|
case "get":
|
|
|
|
$var =& $_GET;
|
|
|
|
break;
|
2014-09-17 09:31:12 -04:00
|
|
|
|
2013-12-12 15:13:57 -05:00
|
|
|
case "post":
|
|
|
|
$var =& $_POST;
|
|
|
|
break;
|
2014-09-17 09:31:12 -04:00
|
|
|
|
|
|
|
default:
|
|
|
|
parse_str(file_get_contents('php://input'), $var);
|
|
|
|
break;
|
2013-12-12 15:13:57 -05:00
|
|
|
}
|
2014-09-17 09:31:12 -04:00
|
|
|
|
2013-12-12 15:13:57 -05:00
|
|
|
header('Content-type: application/json');
|
|
|
|
echo json_encode($var);
|
|
|
|
}
|
|
|
|
else if (isset($_GET['bad']))
|
|
|
|
{
|
|
|
|
http_response_code('401');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|