Проект ещё жив!
This commit is contained in:
@@ -88,6 +88,8 @@ function Post_Create (
|
||||
bool $comms_enabled = false,
|
||||
bool $edit_lock = false
|
||||
): ReturnT {
|
||||
global $db;
|
||||
|
||||
$result = null;
|
||||
|
||||
// Author ID should exist
|
||||
@@ -113,7 +115,7 @@ function Post_Create (
|
||||
* Create single publication
|
||||
*/
|
||||
function Post_Create_Method (array $req, array $files): ReturnT {
|
||||
global $db, $Config, $LOGGED_IN, $THIS_USER;
|
||||
global $Config, $LOGGED_IN, $THIS_USER;
|
||||
|
||||
$author_id = $THIS_USER;
|
||||
$tags = null;
|
||||
@@ -168,7 +170,7 @@ function Post_Create_Method (array $req, array $files): ReturnT {
|
||||
|
||||
|
||||
|
||||
if (ThisFileIsRequested(__FILE__)) {
|
||||
if (Utils_ThisFileIsRequested(__FILE__)) {
|
||||
require_once("../_json.php");
|
||||
|
||||
// TODO: cleanup if bad result
|
||||
|
||||
@@ -1,14 +1,39 @@
|
||||
<?php // Get single post by ID
|
||||
|
||||
require_once("../_auth.php");
|
||||
require_once("../_utils.php");
|
||||
require_once("../_errorslist.php");
|
||||
require_once("../_types.php");
|
||||
// Includes
|
||||
if ($IS_FRONTEND) {
|
||||
require_once("api/_auth.php");
|
||||
require_once("api/_utils.php");
|
||||
require_once("api/_errorslist.php");
|
||||
require_once("api/_types.php");
|
||||
} else {
|
||||
require_once("../_auth.php");
|
||||
require_once("../_utils.php");
|
||||
require_once("../_errorslist.php");
|
||||
require_once("../_types.php");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
/*
|
||||
* FUNCTION
|
||||
* Get total amount of posts
|
||||
*/
|
||||
function Post_GetPostsAmount (): int {
|
||||
global $db;
|
||||
|
||||
$s = $db->prepare("SELECT id FROM posts"); // NOTICE: very naive and will impact performance when many posts are exist
|
||||
$s->execute();
|
||||
$d = $s->get_result()->fetch_assoc();
|
||||
|
||||
if ($d)
|
||||
return count($d);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* FUNCTION
|
||||
* Increment number of views for post
|
||||
@@ -79,10 +104,10 @@ function Post_GetByID_Method (array $req) {
|
||||
$PostID = null;
|
||||
if (isset($req["id"])) {
|
||||
if (!ctype_digit($req["id"]))
|
||||
return new ReturnT(err_code: E_UIN_BADARGS, "id must be numeric");
|
||||
return new ReturnT(err_code: E_UIN_BADARGS, err_desc: "id must be numeric");
|
||||
$PostID = intval($req["id"]);
|
||||
} else {
|
||||
return new ReturnT(err_code: E_UIN_INSUFARGS, "id must be specified");
|
||||
return new ReturnT(err_code: E_UIN_INSUFARGS, err_desc: "id must be specified");
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
||||
Reference in New Issue
Block a user