From 5fdb8d8f43e15b9581e8320153eb2e8c24cedac8 Mon Sep 17 00:00:00 2001 From: sijanec Date: Tue, 1 Dec 2020 23:50:20 +0100 Subject: =?UTF-8?q?dodal=20mo=C5=BEnost=20komentiranja?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/php/api.php | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 api/php/api.php (limited to 'api/php') diff --git a/api/php/api.php b/api/php/api.php new file mode 100644 index 0000000..5c5ec82 --- /dev/null +++ b/api/php/api.php @@ -0,0 +1,60 @@ + 1024 || strlen($parent) > 7+1+256+1+19 || strlen($vzdevek) > 256) { + http_response_code(400); + header("Content-Type: text/plain"); + exit("400: Napaka. Preveč besedila - vzdevek je lahko dolg 256, sporočilo pa 1024 znakov."); + } + $datum = date("Y-m-d H:i:s"); + $cm = yaml_emit(array( + "author" => $vzdevek, + "date" => $datum, + "message" => $sporocilo, + "parent" => $parent, + "ip" => $_SERVER['REMOTE_ADDR'], + "addedby" => "PHP API 0.0.0", + "nonce" => hash('sha256', $vzdevek."|".$datum."|".random_bytes(69)) + )); + file_put_contents($commentsfile, $cm, FILE_APPEND); // pri append ni locka + break; + case "commentedit": + http_response_code(400); + header("Content-Type: text/plain"); + exit("400: Napaka. Urejanje komentarjev še ni izdelano. Napišite elektronsko sporočilo na anton+blog@sijanec.eu."); + break; + default: + http_response_code(400); + header("Content-Type: text/plain"); + exit("400: Napaka. Izbrali ste neobstoječo API metodo."); + break; + } +?> -- cgit v1.2.3