From 9a4658f3ea7cb59241f5be90e891b8e264239d02 Mon Sep 17 00:00:00 2001 From: shr3dd3r Date: Wed, 6 Sep 2023 05:38:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=20=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B0=D1=82=D1=8C=20API=20=D0=B4=D0=BB=D1=8F=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ TODO.md | 1 + api/post/create.php | 36 ++++++++++++++++++++++++++++++++++++ api/post/index.php | 17 ++++++++++++++++- api/user/delete.php | 1 + config.json | 12 ++++++++++++ docs/DB.md | 3 +++ 7 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 api/post/create.php diff --git a/README.md b/README.md index 0afbaee..9cef2b2 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,6 @@ The newest generation imageboard. - `sudo rm -r /usr/share/nginx/html/testing/E949 && sudo cp -R . /usr/share/nginx/html/testing/E949/ && sudo chown -R http:http /usr/share/nginx/html/testing` +- `mysql -u e949 -p` + - `#049e59` -> `#094e59` \ No newline at end of file diff --git a/TODO.md b/TODO.md index 742785b..ca0f828 100644 --- a/TODO.md +++ b/TODO.md @@ -39,6 +39,7 @@ - Может банить кого угодно - Может удалять чьи угодно аккаунты - Может редактировать чужие посты + - Может управлять одобренными тегами - Аватарки - Бан - Полное удаление diff --git a/api/post/create.php b/api/post/create.php new file mode 100644 index 0000000..dfbb1b9 --- /dev/null +++ b/api/post/create.php @@ -0,0 +1,36 @@ +prepare("INSERT ..."); + // $s->bind_param("s", $author); + // $s->execute(); + // $d = $s->get_result()->fetch_assoc(); + // + // if (!(bool)$d) { + // return null; + // } + + return $result; +} + + + +if (ThisFileIsRequested(__FILE__)) { + require_once("../_json.php"); + + // Check if there are necessary input + if (!(isset($_POST["tags"]) && isset($_FILES["pic"]))) + ReturnJSONError($Err_RDP_InvalidArgs, "not enough arguments"); + + // TODO +} + +?> \ No newline at end of file diff --git a/api/post/index.php b/api/post/index.php index e882142..22cfde8 100644 --- a/api/post/index.php +++ b/api/post/index.php @@ -5,6 +5,21 @@ require_once("../_utils.php"); +// Increment number of views for post +function Post_AddView ($id) { + global $db; + + $s = $db->prepare("UPDATE posts SET views = views + 1 WHERE id = ?"); + $s->bind_param("s", $id); + $s->execute(); + $d = $s->get_result()->fetch_assoc(); + + if (!(bool)$d) { + require_once("../_json.php"); + ReturnJSONError($Err_Int_Unexpected, "failed to increment number of views"); + } +} + // Get single publication by ID function Post_GetByID ($id) { global $db; @@ -34,7 +49,7 @@ function Post_GetByID ($id) { $result["preview_path"] = $d["preview_path"]; $result["edit_lock"] = $d["edit_lock"]; - // TODO: increment views of post + Post_AddView($id); return $result; } diff --git a/api/user/delete.php b/api/user/delete.php index 105dd61..d57d84c 100644 --- a/api/user/delete.php +++ b/api/user/delete.php @@ -1,4 +1,5 @@