-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
97 lines (80 loc) · 2.96 KB
/
api.php
File metadata and controls
97 lines (80 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
# @*************************************************************************@
# @ Software author: JOOJ Team (JOOJ.us) @
# @ Author_url 1: https://jooj.us @
# @ Author_url 2: http://jooj.us/twitter-clone @
# @ Author E-mail: [email protected] @
# @*************************************************************************@
# @ JOOJ Talk - The Ultimate Modern Social Media Sharing Platform @
# @ Copyright (c) 2020 - 2023 JOOJ Talk. All rights reserved. @
# @*************************************************************************@
header('Content-Type: application/json');
$data = array();
$api = ((isset($_GET["api"])) ? $_GET["api"] : "");
$app = ((isset($_GET["app"])) ? $_GET["app"] : "");
if ($api == "native") {
require_once("core/web_req_init.php");
set_error_handler('cl_json_server500_err');
$csrf = false;
$action = ((not_empty($_GET["action"])) ? $_GET["action"] : "");
$app_stat = fetch_or_get($applications[$app], false);
if ($app_stat == true) {
$req_handler = cl_strf("apps/native/ajax/%s/content.php",$app);
$errors = array();
$hash = ((not_empty($_GET["hash"])) ? $_GET["hash"] : "");
if (empty($hash)) {
$hash = ((not_empty($_POST["hash"])) ? $_POST["hash"] : "");
}
if ($csrf) {
if (empty($hash) || empty(cl_verify_csrf_token($hash))) {
$data = array(
"status" => "400",
"err_code" => "invalid_csrf_token",
"message" => "ERROR: Invalid or missing CSRF token"
);
echo json_encode($data, JSON_PRETTY_PRINT);
exit();
}
}
require_once(cl_full_path($req_handler));
echo json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
mysqli_close($mysqli);
unset($cl);
exit();
}
else {
cl_json_server500_err(false, "Error: Handler for request not found");
}
}
else {
require_once("core/api_req_init.php");
set_error_handler('cl_json_server500_err');
$req_handler = cl_strf("apps/native/api/%s/content.php", $app);
$errors = array();
$hash = ((not_empty($_GET["hash"])) ? $_GET["hash"] : "");
if ($cl["config"]["system_api_status"] == "on") {
if (file_exists(cl_full_path($req_handler))) {
require_once(cl_full_path($req_handler));
}
else {
$data = array(
"status" => "400",
"err_code" => "invalid_endpoint",
"message" => "Invalid endpoint error on API call"
);
}
echo json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
mysqli_close($mysqli);
unset($cl);
exit();
}
else{
$data = array(
"status" => "400",
"err_code" => "api_is_disabled",
"message" => cl_strf("Unfortunately, the system API of %s is temporary not available.", $cl["config"]["name"])
);
echo json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
exit();
}
}