Начал делать API для постов
This commit is contained in:
parent
983a5d0353
commit
9a4658f3ea
@ -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`
|
1
TODO.md
1
TODO.md
@ -39,6 +39,7 @@
|
||||
- Может банить кого угодно
|
||||
- Может удалять чьи угодно аккаунты
|
||||
- Может редактировать чужие посты
|
||||
- Может управлять одобренными тегами
|
||||
- Аватарки
|
||||
- Бан
|
||||
- Полное удаление
|
||||
|
36
api/post/create.php
Normal file
36
api/post/create.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php // Create new post
|
||||
|
||||
require_once("../_auth.php");
|
||||
require_once("../_utils.php");
|
||||
|
||||
|
||||
|
||||
// Create single publication
|
||||
function Post_Create ($author, $tags, $pic_path, $title = null, $prev_path = null, $comms_enabled = false, $edit_lock = false) {
|
||||
global $db;
|
||||
|
||||
// $s = $db->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
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php // Deleting existing account
|
||||
|
||||
require_once("../_auth.php");
|
||||
require_once("../_utils.php");
|
||||
require_once("./index.php");
|
||||
|
12
config.json
12
config.json
@ -14,5 +14,17 @@
|
||||
},
|
||||
"accounts": {
|
||||
"external_avatars": false
|
||||
},
|
||||
"media": {
|
||||
"max_pic_size": 56623104,
|
||||
"allowed_exts": [
|
||||
"jpg",
|
||||
"jpeg",
|
||||
"png"
|
||||
],
|
||||
"allowed_mimetypes": [
|
||||
"image/jpeg",
|
||||
"image/png"
|
||||
]
|
||||
}
|
||||
}
|
@ -69,4 +69,7 @@ CREATE TABLE invites (
|
||||
author_id INT UNSIGNED NULL COMMENT 'ID of user, who created invite',
|
||||
uses_last SMALLINT UNSIGNED NOT NULL COMMENT 'Remaining uses of invite'
|
||||
);
|
||||
CREATE TABLE approved_tags (
|
||||
value VARCHAR(255) NOT NULL COMMENT 'The tag itself'
|
||||
);
|
||||
```
|
Loading…
Reference in New Issue
Block a user