summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorsijanec <sijanecantonluka@gmail.com>2020-12-01 23:50:20 +0100
committersijanec <sijanecantonluka@gmail.com>2020-12-01 23:50:20 +0100
commit5fdb8d8f43e15b9581e8320153eb2e8c24cedac8 (patch)
tree05f9192f178fd698c0a62c9582b0c5d5592f6d67 /api
parentdodal https predlog - hostname fix (diff)
downloadsijanec.eu-5fdb8d8f43e15b9581e8320153eb2e8c24cedac8.tar
sijanec.eu-5fdb8d8f43e15b9581e8320153eb2e8c24cedac8.tar.gz
sijanec.eu-5fdb8d8f43e15b9581e8320153eb2e8c24cedac8.tar.bz2
sijanec.eu-5fdb8d8f43e15b9581e8320153eb2e8c24cedac8.tar.lz
sijanec.eu-5fdb8d8f43e15b9581e8320153eb2e8c24cedac8.tar.xz
sijanec.eu-5fdb8d8f43e15b9581e8320153eb2e8c24cedac8.tar.zst
sijanec.eu-5fdb8d8f43e15b9581e8320153eb2e8c24cedac8.zip
Diffstat (limited to 'api')
-rw-r--r--api/c/Makefile (renamed from api/Makefile)1
-rwxr-xr-xapi/c/api (renamed from api/api)bin17992 -> 17992 bytes
-rw-r--r--api/c/api.c (renamed from api/api.c)0
-rw-r--r--api/c/urlcode.c (renamed from api/urlcode.c)0
-rw-r--r--api/php/api.php60
5 files changed, 61 insertions, 0 deletions
diff --git a/api/Makefile b/api/c/Makefile
index 7b8ab7d..5f4f70a 100644
--- a/api/Makefile
+++ b/api/c/Makefile
@@ -4,3 +4,4 @@ prepare:
wget http://www.geekhideout.com/downloads/urlcode.c
clean:
rm urlencode.c api
+
diff --git a/api/api b/api/c/api
index cd48526..cd48526 100755
--- a/api/api
+++ b/api/c/api
Binary files differ
diff --git a/api/api.c b/api/c/api.c
index e452617..e452617 100644
--- a/api/api.c
+++ b/api/c/api.c
diff --git a/api/urlcode.c b/api/c/urlcode.c
index ecf34e1..ecf34e1 100644
--- a/api/urlcode.c
+++ b/api/c/urlcode.c
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 @@
+<?php
+ // pisal bom v PHPju, ker se mi res ne da zajebavat s Cjem
+ switch ($_REQUEST["m"]) {
+ case "commentreply":
+ if (empty($_REQUEST['vzdevek'])) {
+ $vzdevek = "anonymous";
+ } else {
+ $vzdevek = $_REQUEST['vzdevek'];
+ }
+ if (empty($_REQUESTT['message'])) {
+ http_response_code(400);
+ header("Content-Type: text/plain");
+ exit("400: Napaka. Niste vnesli sporočila.");
+ }
+ if ($_REQUEST['submit'] != 'Objavi!') {
+ http_response_code(201); // he's obviously automating queries
+ header("Content-Type: text/plain");
+ exit("201: Uspelo! Komentar objavljen."); // lies and deception
+ }
+ if (empty($_REQUEST['parent'])) {
+ http_response_code(400);
+ header("Content-Type: text/plain");
+ exit("400: Napaka. V zahtevi ni določeno, na kaj odgovarjate.");
+ }
+ if (empty($_REQUEST["is-submitter-human"] != "true")) {
+ http_response_code(201); // he's obviously automating queries
+ header("Content-Type: text/plain");
+ exit("201: Uspelo! Komentar objavljen."); // lies and deception
+ }
+ $sporocilo = $_REQUEST['message'];
+ $parent = $_REQUEST['parent'];
+ if (strlen($sporocilo) > 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;
+ }
+?>