Проект ещё жив!
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
<?php // Viewing account data
|
||||
|
||||
// Includes
|
||||
require_once("../_auth.php");
|
||||
require_once("../_utils.php");
|
||||
require_once("../_errorslist.php");
|
||||
require_once("../_types.php");
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +21,7 @@ require_once("../_types.php");
|
||||
* FUNCTION
|
||||
* Check if user with supplied login exists
|
||||
*/
|
||||
function User_LoginExist ($login): bool {
|
||||
function User_LoginExist (string $login): bool {
|
||||
global $db;
|
||||
|
||||
$s = $db->prepare("SELECT * FROM users WHERE login = ?");
|
||||
@@ -28,7 +35,7 @@ function User_LoginExist ($login): bool {
|
||||
* FUNCTION
|
||||
* Check if user with supplied ID exists
|
||||
*/
|
||||
function User_IDExist ($id): bool {
|
||||
function User_IDExist (int $id): bool {
|
||||
global $db;
|
||||
|
||||
$s = $db->prepare("SELECT * FROM users WHERE id = ?");
|
||||
@@ -42,7 +49,7 @@ function User_IDExist ($id): bool {
|
||||
* FUNCTION
|
||||
* Check if user has specified role
|
||||
*/
|
||||
function User_HasRole ($id, $role): ReturnT {
|
||||
function User_HasRole (int $id, string $role): ReturnT {
|
||||
global $db;
|
||||
|
||||
$s = $db->prepare("SELECT * FROM users WHERE id = ?");
|
||||
@@ -60,7 +67,7 @@ function User_HasRole ($id, $role): ReturnT {
|
||||
* FUNCTION
|
||||
* Check if user is moderator (or higher)
|
||||
*/
|
||||
function User_IsMod ($id): ReturnT {
|
||||
function User_IsMod (int $id): ReturnT {
|
||||
global $db;
|
||||
|
||||
$s = $db->prepare("SELECT * FROM users WHERE id = ?");
|
||||
@@ -79,7 +86,7 @@ function User_IsMod ($id): ReturnT {
|
||||
* Get user information from DB
|
||||
*/
|
||||
function User_GetInfoByID (int $id): ReturnT {
|
||||
global $THIS_USER;
|
||||
global $db, $THIS_USER;
|
||||
|
||||
$result = array();
|
||||
|
||||
@@ -97,7 +104,7 @@ function User_GetInfoByID (int $id): ReturnT {
|
||||
$result["avatar_path"] = $d["avatar_path"];
|
||||
$result["role"] = $d["role"];
|
||||
$result["banned"] = $d["banned"];
|
||||
if (($id === $THIS_USER) || User_IsMod($THIS_USER).GetData()) { // User himself and mods can see additional info
|
||||
if (($id === $THIS_USER) || User_IsMod($THIS_USER)->GetData()) { // User himself and mods can see additional info
|
||||
$result["email"] = $d["email"];
|
||||
$result["invite_id"] = $d["invite_id"];
|
||||
}
|
||||
@@ -114,7 +121,7 @@ function User_GetInfoByID (int $id): ReturnT {
|
||||
* Get user information from DB
|
||||
*/
|
||||
function User_GetInfoByID_Method (array $req): ReturnT {
|
||||
global $db, $THIS_USER, $LOGGED_IN;
|
||||
global $THIS_USER, $LOGGED_IN;
|
||||
|
||||
// Input sanity checks
|
||||
|
||||
@@ -127,7 +134,7 @@ function User_GetInfoByID_Method (array $req): ReturnT {
|
||||
if ($LOGGED_IN)
|
||||
$UserID = $THIS_USER;
|
||||
else
|
||||
return new ReturnT(err_code: E_UIN_BADARGS, err_desc: "id must be specified or valid session must be provided");
|
||||
return new ReturnT(err_code: E_UIN_INSUFARGS, err_desc: "id must be specified or valid session must be provided");
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
Reference in New Issue
Block a user