summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-02-14 12:45:39 +0300
committeremkael <emkael@tlen.pl>2019-02-14 12:45:39 +0300
commitaf780009430cf5b1b511cf2b75479fd072d391cd (patch)
treea134aa8b804e6f08ceeac5d46dd17720e5448a4e
parentef4974082b40d59e631174ca694dc3fbd50f8fae (diff)
This is ridiculous.
-rw-r--r--http/api.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/http/api.php b/http/api.php
index a3f155d..29c56ec 100644
--- a/http/api.php
+++ b/http/api.php
@@ -28,6 +28,18 @@ Parametry:
*/
+if (!function_exists('http_response_code')) {
+ function http_response_code($code = NULL) {
+ $codes = array(400 => "Bad Request",
+ 500 => "Internal Server Error");
+ if (!isset($codes[$code])) {
+ return;
+ }
+ $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
+ header($protocol . ' ' . $code . ' ' . $codes[$code]);
+ }
+}
+
class ParametersException extends Exception {};
function safe_ceil($value, $precision = 1e-6) {
@@ -201,12 +213,7 @@ function run($parameters) {
}
}
-/*if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- http_response_code(405);
- die('API only accepts POST requests');
-} else {*/
- header('Content-Type: application/json');
- print(json_encode(run($_REQUEST)));
-//}
+header('Content-Type: application/json');
+print(json_encode(run($_REQUEST)));
?>