From af780009430cf5b1b511cf2b75479fd072d391cd Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 14 Feb 2019 12:45:39 +0300 Subject: This is ridiculous. --- http/api.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'http') 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))); ?> -- cgit v1.2.3