Move files
This commit is contained in:
1 parent
30dd940c0e
commit
a58ecbb597
43 files changed
+7
-7
No files matched your search
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
require '../config/config.php';
|
||||
require '../incl/main.php';
|
||||
|
||||
$old_displayname = isset($_POST['olddisplayname']) ? $_POST['olddisplayname'] : '';
|
||||
$new_displayname = isset($_POST['newdisplayname']) ? $_POST['newdisplayname'] : '';
|
||||
$username = isset($_POST['username']) ? $_POST['username'] : '';
|
||||
$password = isset($_POST['password']) ? $_POST['password'] : '';
|
||||
|
||||
if (empty($username) || empty($old_displayname) || empty($new_displayname) || empty($password)) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'response' => 'Missing Username, Old Display Name, New Display Name, or Password']));
|
||||
}
|
||||
|
||||
if (strlen($new_displayname) < 3 || strlen($new_displayname) > 32) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'responsae' => 'New Display Name must be between 3 and 32 characters']));
|
||||
exit;
|
||||
}
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'response' => 'Unable to access database']));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT password FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$user = $result->fetch_assoc();
|
||||
|
||||
if (!password_verify($password, $user['password'])) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'response' => 'Password is incorrect']));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET display_name = ? WHERE username = ?");
|
||||
$stmt->bind_param("ss", $new_displayname, $username);
|
||||
$stmt->execute();
|
||||
|
||||
http_response_code(200);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(['success' => 'true', 'response' => 'Display Name changed successfully']);
|
||||
} else {
|
||||
http_response_code(404);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'response' => 'User not found']));
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
require '../config/config.php';
|
||||
require '../incl/main.php';
|
||||
|
||||
$username = isset($_POST['username']) ? $_POST['username'] : '';
|
||||
$old_password = isset($_POST['oldpassword']) ? $_POST['oldpassword'] : '';
|
||||
$new_password = isset($_POST['newpassword']) ? $_POST['newpassword'] : '';
|
||||
|
||||
if (empty($username) || empty($old_password) || empty($new_password)) {
|
||||
http_response_code(400);
|
||||
die(json_encode(['success' => 'false', 'response' => 'Missing Username, Old Password, or New Password']));
|
||||
}
|
||||
|
||||
if (isset($_POST['confirmpassword']) && $_POST['confirmpassword'] != $new_password) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'response' => 'Passwords do not match']));
|
||||
}
|
||||
|
||||
if (strlen($new_password) < 8 || !preg_match("/[A-Za-z]/", $new_password) || !preg_match("/[0-9]/", $new_password)) {
|
||||
http_response_code(400);
|
||||
die(json_encode(['success' => 'false', 'response' => 'New password must be at least 8 characters long and contain at least one letter and one number']));
|
||||
}
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
http_response_code(500);
|
||||
die(json_encode(['success' => 'false', 'response' => 'Unable to access database']));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT password FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $username);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$user = $result->fetch_assoc();
|
||||
|
||||
if (!password_verify($old_password, $user['password'])) {
|
||||
http_response_code(400);
|
||||
die(json_encode(['success' => 'false', 'response' => 'Old password is incorrect']));
|
||||
}
|
||||
|
||||
$hashed_password = password_hash($new_password, PASSWORD_DEFAULT);
|
||||
$empty = null;
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET password = ?, session = ?, session_expire = ? WHERE username = ?");
|
||||
$stmt->bind_param("ssss", $hashed_password, $empty, $empty, $username);
|
||||
$stmt->execute();
|
||||
|
||||
http_response_code(200);
|
||||
echo json_encode(['success' => 'true', 'response' => 'Password changed successfully']);
|
||||
} else {
|
||||
http_response_code(404);
|
||||
die(json_encode(['success' => 'false', 'response' => 'User not found']));
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
require '../config/config.php';
|
||||
require '../incl/main.php';
|
||||
|
||||
$old_username = isset($_POST['oldusername']) ? $_POST['oldusername'] : '';
|
||||
$new_username = isset($_POST['newusername']) ? $_POST['newusername'] : '';
|
||||
$password = isset($_POST['password']) ? $_POST['password'] : '';
|
||||
|
||||
if (empty($old_username) || empty($new_username) || empty($password)) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'response' => 'Missing Old Username, New Username, or Password']));
|
||||
}
|
||||
|
||||
if (strlen($new_username) < 3 || strlen($new_username) > 32) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'response' => 'New Username must be between 3 and 32 characters']));
|
||||
}
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'response' => 'Unable to access database']));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT password FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $old_username);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$user = $result->fetch_assoc();
|
||||
|
||||
if (!password_verify($password, $user['password'])) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'response' => 'Password is incorrect']));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET username = ? WHERE username = ?");
|
||||
$stmt->bind_param("ss", $new_username, $old_username);
|
||||
$stmt->execute();
|
||||
|
||||
http_response_code(200);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(['success' => 'true', 'response' => 'Username changed successfully']);
|
||||
} else {
|
||||
http_response_code(404);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'response' => 'User not found']));
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
require '../config/config.php';
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$apikey = isset($_SERVER['HTTP_KEY']) ? $_SERVER['HTTP_KEY'] : '';
|
||||
|
||||
if (isset($apikey) && empty($apikey)) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'API Key not provided',
|
||||
];
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT api_key FROM users WHERE api_key = ?");
|
||||
$stmt->bind_param("s", $apikey);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'response' => 'API Key is valid',
|
||||
];
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'API Key is invalid',
|
||||
];
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
include '../../config/config.php';
|
||||
|
||||
if (isset($_GET['code']) && !empty($_GET['code']) && isset($_COOKIE['session']) && !empty($_COOKIE['session'])){
|
||||
$code = $_GET['code'];
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://discord.com/api/v8/oauth2/token');
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
|
||||
'client_id' => $discordClientId,
|
||||
'client_secret' => $discordClientSecret,
|
||||
'grant_type' => 'authorization_code',
|
||||
'code' => $code,
|
||||
'redirect_uri' => $discordRedirectUri,
|
||||
'scope' => 'identify guilds.join, email, identify'
|
||||
]));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($ch);
|
||||
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($status_code != 200) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'message' => 'Invalid code provided.',
|
||||
];
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
$data = json_decode($response, true);
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://discord.com/api/v8/users/@me');
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Authorization: Bearer ' . $data['access_token']
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_POST, 0);
|
||||
$response = curl_exec($ch);
|
||||
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($status_code != 200) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'message' => 'Unable to fetch user data.',
|
||||
];
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
$userData = json_decode($response, true);
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, "https://discord.com/api/v8/guilds/{$discordGuildId}/members/{$userData['id']}");
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Authorization: Bot ' . $discordBotToken,
|
||||
'Content-Type: application/json'
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
|
||||
'access_token' => $data['access_token'],
|
||||
'roles' => [],
|
||||
'mute' => false,
|
||||
'deaf' => false
|
||||
]));
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'message' => 'Unable to connect to the database.',
|
||||
];
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE session = ?");
|
||||
$stmt->bind_param("s", $_COOKIE['session']);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$sqlData = $result->fetch_assoc();
|
||||
|
||||
if ($result->num_rows == 0) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'message' => 'Invalid session.',
|
||||
];
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$avatar = "https://cdn.discordapp.com/avatars/" . $userData['id'] . "/" . $userData['avatar'];
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET discord_id = ?, discord_access_token = ?, discord_refresh_token = ?, discord_expires_in = ?, discord_avatar = ?, discord_email = ? WHERE email = ?");
|
||||
$stmt->bind_param("sssssss", $userData['id'], $data['access_token'], $data['refresh_token'], $data['expires_in'], $avatar, $userData['email'], $sqlData['email']);
|
||||
$stmt->execute();
|
||||
|
||||
if (isset($_COOKIE['redirect_link']) && !empty($_COOKIE['redirect_link']) && strpos($_COOKIE['redirect_link'], 'https://upload.xytriza.com/dashboard') === 0) {
|
||||
setcookie('redirect_link', '', time() - 3600, '/', '', true, true);
|
||||
// deepcode ignore OR: already validated in the if condition
|
||||
header('Location: ' . $_COOKIE['redirect_link']);
|
||||
die();
|
||||
}
|
||||
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'message' => 'Successfully saved to database'
|
||||
];
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'message' => 'Invalid request.',
|
||||
];
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
require '../../config/config.php';
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
function generateRandomString($length) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[random_int(0, strlen($characters) - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
$session = isset($_COOKIE['session']) ? $_COOKIE['session'] : '';
|
||||
|
||||
if (isset($session) && empty($session)) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid session',
|
||||
];
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE session = ?");
|
||||
$stmt->bind_param("s", $session);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$user = $result->fetch_assoc();
|
||||
$api_key = generateRandomString(32);
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET api_key = ? WHERE session = ?");
|
||||
$stmt->bind_param("ss", $api_key, $session);
|
||||
$stmt->execute();
|
||||
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'response' => 'API key generated',
|
||||
'api_key' => $api_key,
|
||||
];
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid session',
|
||||
];
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
require '../../config/config.php';
|
||||
require '../../incl/main.php';
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$session = isset($_COOKIE['session']) ? $_COOKIE['session'] : '';
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE session = ?");
|
||||
$stmt->bind_param("s", $session);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
$key = $row['api_key'];
|
||||
|
||||
if ($result->num_rows == 0) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid session',
|
||||
];
|
||||
|
||||
http_response_code(403);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$config = '{
|
||||
"Name": "Xytriza\'s Uploading Service",
|
||||
"DestinationType": "ImageUploader, FileUploader",
|
||||
"RequestType": "POST",
|
||||
"RequestURL": "https://upload.xytriza.com/api/uploadFile.php",
|
||||
"FileFormName": "file",
|
||||
"Body": "MultipartFormData",
|
||||
"Headers": {
|
||||
"key": "' . $key . '"
|
||||
},
|
||||
"URL": "$json:fileUrl$",
|
||||
"DeletionURL": "$json:deletionUrl$",
|
||||
"ErrorMessage": "$json:error$"
|
||||
}';
|
||||
header('Content-Type: application/json');
|
||||
header('Content-Disposition: attachment; filename="xytrizas-uploading-service.sxcu"');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . strlen($config));
|
||||
echo $config;
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
require '../../config/config.php';
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$session = isset($_COOKIE['session']) ? $_COOKIE['session'] : '';
|
||||
|
||||
if (isset($session) && empty($session)) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid session',
|
||||
];
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT api_key FROM users WHERE session = ?");
|
||||
$stmt->bind_param("s", $session);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$user = $result->fetch_assoc();
|
||||
$api_key = $user['api_key'];
|
||||
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'response' => 'Success',
|
||||
'api_key' => $api_key,
|
||||
];
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid session',
|
||||
];
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
require '../../config/config.php';
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$session = isset($_COOKIE['session']) ? $_COOKIE['session'] : '';
|
||||
|
||||
if (isset($session) && empty($session)) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid session',
|
||||
];
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$sql = "SELECT value FROM settings WHERE id = 1";
|
||||
$result = $conn->query($sql);
|
||||
$row = $result->fetch_assoc();
|
||||
$news = base64_decode($row['value']);
|
||||
|
||||
$sql = "SELECT value FROM settings WHERE id = 2";
|
||||
$result = $conn->query($sql);
|
||||
$row = $result->fetch_assoc();
|
||||
$motd = base64_decode($row['value']);
|
||||
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'response' => 'Here is the announcements',
|
||||
'news' => $news,
|
||||
'motd' => $motd,
|
||||
];
|
||||
|
||||
http_response_code(200);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($response);
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
require '../../config/config.php';
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$key = isset($_SERVER['HTTP_KEY']) ? $_SERVER['HTTP_KEY'] : '';
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE api_key = ?");
|
||||
$stmt->bind_param("s", $key);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows == 0) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid API Key',
|
||||
];
|
||||
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$sql = "SELECT value FROM settings WHERE id = 1";
|
||||
$result = $conn->query($sql);
|
||||
$row = $result->fetch_assoc();
|
||||
$news = base64_decode($row['value']);
|
||||
|
||||
$sql = "SELECT value FROM settings WHERE id = 2";
|
||||
$result = $conn->query($sql);
|
||||
$row = $result->fetch_assoc();
|
||||
$motd = base64_decode($row['value']);
|
||||
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'response' => 'Here is the announcements',
|
||||
'news' => $news,
|
||||
'motd' => $motd,
|
||||
];
|
||||
|
||||
http_response_code(200);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($response);
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
require '../../config/config.php';
|
||||
require '../../incl/main.php';
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$apiKey = isset($_POST['key']) ? $_POST['key'] : null;
|
||||
$session = isset($_COOKIE['session']) ? $_COOKIE['session'] : null;
|
||||
$country = isset($_POST['country']) ? $_POST['country'] : null;
|
||||
$timezone = isset($_POST['timezone']) ? $_POST['timezone'] : null;
|
||||
$dateformat = isset($_POST['dateformat']) ? $_POST['dateformat'] : null;
|
||||
$timeformat = isset($_POST['timeformat']) ? $_POST['timeformat'] : null;
|
||||
|
||||
$query = "UPDATE users SET ";
|
||||
$params = [];
|
||||
$paramTypes = "";
|
||||
|
||||
if ($country !== null) {
|
||||
$countries = ["Andorra", "French Southern and Antarctic Lands", "Laos", "Canada", "Nigeria", "Vanuatu", "Czechia", "Malawi", "Mali", "Iceland", "Norway", "Saint Vincent and the Grenadines", "Guadeloupe", "Chile", "Bermuda", "Kuwait", "Dominica", "Montenegro", "United States Virgin Islands", "Cameroon", "Sri Lanka", "China", "Bangladesh", "Sweden", "Grenada", "Turkey", "Guinea", "Tanzania", "Rwanda", "Singapore", "Morocco", "Saint Barthélemy", "Iraq", "Brunei", "Isle of Man", "North Korea", "Iran", "Curaçao", "Paraguay", "Albania", "Tajikistan", "Bolivia", "Austria", "Saint Kitts and Nevis", "United States Minor Outlying Islands", "Colombia", "Kosovo", "Belize", "Guinea-Bissau", "Marshall Islands", "Myanmar", "French Polynesia", "Brazil", "Croatia", "Somalia", "Afghanistan", "Anguilla", "Cook Islands", "Western Sahara", "New Zealand", "Eritrea", "Cambodia", "Bahamas", "Belarus", "Norfolk Island", "Tuvalu", "South Georgia", "Mauritania", "New Caledonia", "Bulgaria", "Mozambique", "Niue", "Estonia", "Italy", "Malta", "Slovenia", "India", "Peru", "Burundi", "Lithuania", "United States", "Honduras", "Tonga", "Saudi Arabia", "Suriname", "Qatar", "Saint Helena, Ascension and Tristan da Cunha", "Gibraltar", "Northern Mariana Islands", "Mauritius", "Barbados", "Réunion", "British Indian Ocean Territory", "Syria", "Egypt", "São Tomé and Príncipe", "Kiribati", "Timor-Leste", "Lesotho", "Solomon Islands", "Libya", "South Korea", "Liechtenstein", "Nicaragua", "Ecuador", "Maldives", "Algeria", "Kyrgyzstan", "Finland", "Antarctica", "Kenya", "Cuba", "Montserrat", "Poland", "Åland Islands", "Ethiopia", "Togo", "Bosnia and Herzegovina", "Uruguay", "Guam", "Cape Verde", "Chad", "Vatican City", "Palau", "Haiti", "Yemen", "Eswatini", "Zimbabwe", "Greece", "Israel", "Saint Martin", "Antigua and Barbuda", "Cyprus", "Sint Maarten", "Monaco", "Fiji", "Ukraine", "Martinique", "Hong Kong", "Portugal", "Bhutan", "Nepal", "France", "Ireland", "United Arab Emirates", "Guernsey", "Saint Lucia", "Dominican Republic", "Serbia", "Botswana", "Ivory Coast", "Ghana", "Comoros", "Azerbaijan", "United Kingdom", "Central African Republic", "Palestine", "Caribbean Netherlands", "Taiwan", "Pitcairn Islands", "San Marino", "Svalbard and Jan Mayen", "Djibouti", "Wallis and Futuna", "Denmark", "Papua New Guinea", "Madagascar", "Bouvet Island", "Hungary", "Tokelau", "Trinidad and Tobago", "Gambia", "Luxembourg", "Cocos (Keeling) Islands", "Republic of the Congo", "Argentina", "DR Congo", "Greenland", "Jordan", "Belgium", "Switzerland", "Indonesia", "Lebanon", "Malaysia", "Cayman Islands", "Slovakia", "Armenia", "Christmas Island", "Mongolia", "Saint Pierre and Miquelon", "Japan", "South Africa", "Philippines", "Micronesia", "Germany", "Latvia", "Jamaica", "Macau", "Nauru", "Faroe Islands", "Guyana", "Burkina Faso", "Sudan", "Russia", "Mayotte", "Australia", "Liberia", "Mexico", "Tunisia", "Aruba", "Kazakhstan", "Oman", "French Guiana", "Niger", "Turkmenistan", "Sierra Leone", "Samoa", "Senegal", "Georgia", "Namibia", "South Sudan", "Thailand", "Bahrain", "Heard Island and McDonald Islands", "Falkland Islands", "Jersey", "Vietnam", "Guatemala", "Moldova", "North Macedonia", "Uzbekistan", "Romania", "Uganda", "El Salvador", "Zambia", "Gabon", "Equatorial Guinea", "Spain", "Netherlands", "British Virgin Islands", "Benin", "Pakistan", "Panama", "Turks and Caicos Islands", "Angola", "American Samoa", "Venezuela", "Costa Rica", "Puerto Rico", "Seychelles"];
|
||||
if (!in_array($country, $countries)) {
|
||||
$country = null;
|
||||
die('{"success": false, "response": "Invalid country" }');
|
||||
return;
|
||||
}
|
||||
|
||||
$query .= "country = ?, ";
|
||||
array_push($params, $country);
|
||||
$paramTypes .= "s";
|
||||
}
|
||||
|
||||
if ($timezone !== null) {
|
||||
$timezones = ['Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_Ababa', 'Africa/Algiers', 'Africa/Asmara', 'Africa/Asmera', 'Africa/Bamako', 'Africa/Bangui', 'Africa/Banjul', 'Africa/Bissau', 'Africa/Blantyre', 'Africa/Brazzaville', 'Africa/Bujumbura', 'Africa/Cairo', 'Africa/Casablanca', 'Africa/Ceuta', 'Africa/Conakry', 'Africa/Dakar', 'Africa/Dar_es_Salaam', 'Africa/Djibouti', 'Africa/Douala', 'Africa/El_Aaiun', 'Africa/Freetown', 'Africa/Gaborone', 'Africa/Harare', 'Africa/Johannesburg', 'Africa/Juba', 'Africa/Kampala', 'Africa/Khartoum', 'Africa/Kigali', 'Africa/Kinshasa', 'Africa/Lagos', 'Africa/Libreville', 'Africa/Lome', 'Africa/Luanda', 'Africa/Lubumbashi', 'Africa/Lusaka', 'Africa/Malabo', 'Africa/Maputo', 'Africa/Maseru', 'Africa/Mbabane', 'Africa/Mogadishu', 'Africa/Monrovia', 'Africa/Nairobi', 'Africa/Ndjamena', 'Africa/Niamey', 'Africa/Nouakchott', 'Africa/Ouagadougou', 'Africa/Porto-Novo', 'Africa/Sao_Tome', 'Africa/Timbuktu', 'Africa/Tripoli', 'Africa/Tunis', 'Africa/Windhoek', 'America/Adak', 'America/Anchorage', 'America/Anguilla', 'America/Antigua', 'America/Araguaina', 'America/Argentina/Buenos_Aires', 'America/Argentina/Catamarca', 'America/Argentina/ComodRivadavia', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/La_Rioja', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Salta', 'America/Argentina/San_Juan', 'America/Argentina/San_Luis', 'America/Argentina/Tucuman', 'America/Argentina/Ushuaia', 'America/Aruba', 'America/Asuncion', 'America/Atikokan', 'America/Atka', 'America/Bahia', 'America/Bahia_Banderas', 'America/Barbados', 'America/Belem', 'America/Belize', 'America/Blanc-Sablon', 'America/Boa_Vista', 'America/Bogota', 'America/Boise', 'America/Buenos_Aires', 'America/Cambridge_Bay', 'America/Campo_Grande', 'America/Cancun', 'America/Caracas', 'America/Catamarca', 'America/Cayenne', 'America/Cayman', 'America/Chicago', 'America/Chihuahua', 'America/Ciudad_Juarez', 'America/Coral_Harbour', 'America/Cordoba', 'America/Costa_Rica', 'America/Creston', 'America/Cuiaba', 'America/Curacao', 'America/Danmarkshavn', 'America/Dawson', 'America/Dawson_Creek', 'America/Denver', 'America/Detroit', 'America/Dominica', 'America/Edmonton', 'America/Eirunepe', 'America/El_Salvador', 'America/Ensenada', 'America/Fort_Nelson', 'America/Fort_Wayne', 'America/Fortaleza', 'America/Glace_Bay', 'America/Godthab', 'America/Goose_Bay', 'America/Grand_Turk', 'America/Grenada', 'America/Guadeloupe', 'America/Guatemala', 'America/Guayaquil', 'America/Guyana', 'America/Halifax', 'America/Havana', 'America/Hermosillo', 'America/Indiana/Indianapolis', 'America/Indiana/Knox', 'America/Indiana/Marengo', 'America/Indiana/Petersburg', 'America/Indiana/Tell_City', 'America/Indiana/Vevay', 'America/Indiana/Vincennes', 'America/Indiana/Winamac', 'America/Indianapolis', 'America/Inuvik', 'America/Iqaluit', 'America/Jamaica', 'America/Jujuy', 'America/Juneau', 'America/Kentucky/Louisville', 'America/Kentucky/Monticello', 'America/Knox_IN', 'America/Kralendijk', 'America/La_Paz', 'America/Lima', 'America/Los_Angeles', 'America/Louisville', 'America/Lower_Princes', 'America/Maceio', 'America/Managua', 'America/Manaus', 'America/Marigot', 'America/Martinique', 'America/Matamoros', 'America/Mazatlan', 'America/Mendoza', 'America/Menominee', 'America/Merida', 'America/Metlakatla', 'America/Mexico_City', 'America/Miquelon', 'America/Moncton', 'America/Monterrey', 'America/Montevideo', 'America/Montreal', 'America/Montserrat', 'America/Nassau', 'America/New_York', 'America/Nipigon', 'America/Nome', 'America/Noronha', 'America/North_Dakota/Beulah', 'America/North_Dakota/Center', 'America/North_Dakota/New_Salem', 'America/Nuuk', 'America/Ojinaga', 'America/Panama', 'America/Pangnirtung', 'America/Paramaribo', 'America/Phoenix', 'America/Port-au-Prince', 'America/Port_of_Spain', 'America/Porto_Acre', 'America/Porto_Velho', 'America/Puerto_Rico', 'America/Punta_Arenas', 'America/Rainy_River', 'America/Rankin_Inlet', 'America/Recife', 'America/Regina', 'America/Resolute', 'America/Rio_Branco', 'America/Rosario', 'America/Santa_Isabel', 'America/Santarem', 'America/Santiago', 'America/Santo_Domingo', 'America/Sao_Paulo', 'America/Scoresbysund', 'America/Shiprock', 'America/Sitka', 'America/St_Barthelemy', 'America/St_Johns', 'America/St_Kitts', 'America/St_Lucia', 'America/St_Thomas', 'America/St_Vincent', 'America/Swift_Current', 'America/Tegucigalpa', 'America/Thule', 'America/Thunder_Bay', 'America/Tijuana', 'America/Toronto', 'America/Tortola', 'America/Vancouver', 'America/Virgin', 'America/Whitehorse', 'America/Winnipeg', 'America/Yakutat', 'America/Yellowknife', 'Antarctica/Casey', 'Antarctica/Davis', 'Antarctica/DumontDUrville', 'Antarctica/Macquarie', 'Antarctica/Mawson', 'Antarctica/McMurdo', 'Antarctica/Palmer', 'Antarctica/Rothera', 'Antarctica/South_Pole', 'Antarctica/Syowa', 'Antarctica/Troll', 'Antarctica/Vostok', 'Arctic/Longyearbyen', 'Asia/Aden', 'Asia/Line truncated
|
||||
if (!in_array($timezone, $timezones)) {
|
||||
$timezone = null;
|
||||
return;
|
||||
}
|
||||
|
||||
$query .= "timezone = ?, ";
|
||||
array_push($params, $timezone);
|
||||
$paramTypes .= "s";
|
||||
}
|
||||
|
||||
if ($dateformat !== null) {
|
||||
if ($dateformat !== "mmddyyyy" && $dateformat !== "ddmmyyyy") {
|
||||
$dateformat = null;
|
||||
return;
|
||||
}
|
||||
|
||||
$query .= "dateformat = ?, ";
|
||||
array_push($params, $dateformat);
|
||||
$paramTypes .= "s";
|
||||
}
|
||||
|
||||
if ($timeformat !== null) {
|
||||
if ($timeformat !== "12hour" && $timeformat !== "24hour") {
|
||||
$timeformat = null;
|
||||
return;
|
||||
}
|
||||
|
||||
$query .= "timeformat = ?, ";
|
||||
array_push($params, str_replace('hour', '', $timeformat));
|
||||
$paramTypes .= "s";
|
||||
}
|
||||
|
||||
if ($country !== null || $timezone !== null || $dateformat !== null || $timeformat !== null) {
|
||||
$query = rtrim($query, ", ");
|
||||
if ($apiKey) {
|
||||
$stmt = $conn->prepare("SELECT COUNT(*) FROM users WHERE api_key = ?");
|
||||
$stmt->bind_param("s", $apiKey);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$count = $result->fetch_array(MYSQLI_NUM)[0];
|
||||
|
||||
if ($count == 0) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid API Key',
|
||||
];
|
||||
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
$query .= " WHERE api_key = ?";
|
||||
array_push($params, $apiKey);
|
||||
} else if ($_COOKIE['session']) {
|
||||
$query .= " WHERE session = ?";
|
||||
array_push($params, $_COOKIE['session']);
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid API Key',
|
||||
];
|
||||
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
$paramTypes .= "s";
|
||||
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param($paramTypes, ...$params);
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'No data provided',
|
||||
];
|
||||
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'response' => 'Saved preferences',
|
||||
];
|
||||
|
||||
http_response_code(200);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Error updating database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
require '../../libs/vendor/autoload.php';
|
||||
require '../config/config.php';
|
||||
require '../incl/main.php';
|
||||
|
||||
use Google\Cloud\Storage\StorageClient;
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$key = isset($_SERVER['HTTP_KEY']) ? $_SERVER['HTTP_KEY'] : '';
|
||||
$session = isset($_COOKIE['session']) ? $_COOKIE['session'] : '';
|
||||
|
||||
if (!empty($key)) {
|
||||
$sql = "SELECT uid FROM users WHERE api_key = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $apiKey);
|
||||
$stmt->execute();
|
||||
} else if (!empty($session)) {
|
||||
$sql = "SELECT uid FROM users WHERE session = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $session);
|
||||
$stmt->execute();
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid API key',
|
||||
];
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
$uid = $row["uid"];
|
||||
|
||||
$storage = new StorageClient([
|
||||
'projectId' => $googleProjectId,
|
||||
'keyFilePath' => $googleKeyFilePath,
|
||||
]);
|
||||
|
||||
$bucket = $storage->bucket($googleBucketName);
|
||||
|
||||
$sql = "SELECT id FROM uploads WHERE uid = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $uid);
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$id = $row["id"];
|
||||
$object = $bucket->object($id);
|
||||
$object->delete();
|
||||
|
||||
$sql = "DELETE FROM uploads WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $id);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'response' => 'All files deleted successfully',
|
||||
];
|
||||
|
||||
http_response_code(200);
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid API key',
|
||||
];
|
||||
http_response_code(401);
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($response);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
require '../../libs/vendor/autoload.php';
|
||||
require '../config/config.php';
|
||||
require '../incl/main.php';
|
||||
|
||||
use Google\Cloud\Storage\StorageClient;
|
||||
|
||||
if (isset($_GET['deletionkey']) && $_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$deleteKey = str_replace('/delete/', '', $_GET['deletionkey']); // used for /delete/ endpoint (nginx stuff blah blah)
|
||||
} else if (isset($_SERVER['HTTP_DELETIONKEY'])) {
|
||||
$deleteKey = $_SERVER['HTTP_DELETIONKEY'];
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'No deletion key provided',
|
||||
];
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$sql = "SELECT id FROM uploads WHERE delete_key = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $deleteKey);
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
$id = $row["id"];
|
||||
|
||||
$storage = new StorageClient([
|
||||
'projectId' => $googleProjectId,
|
||||
'keyFilePath' => $googleKeyFilePath,
|
||||
]);
|
||||
|
||||
$bucket = $storage->bucket($googleBucketName);
|
||||
$object = $bucket->object($id);
|
||||
$object->delete();
|
||||
|
||||
$sql = "DELETE FROM uploads WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $id);
|
||||
$stmt->execute();
|
||||
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'response' => 'File deleted successfully',
|
||||
];
|
||||
|
||||
http_response_code(200);
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid deletion key',
|
||||
];
|
||||
http_response_code(401);
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($response);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
require "../config/config.php";
|
||||
require '../../libs/vendor/autoload.php';
|
||||
include '../incl/main.php';
|
||||
|
||||
use Google\Cloud\Storage\StorageClient;
|
||||
|
||||
if (extension_loaded("zlib")) {
|
||||
ob_start("ob_gzhandler");
|
||||
}
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
"success" => "false",
|
||||
"response" => "Unable to access the database",
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header("Content-Type: application/json");
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$file = rtrim(str_replace("/files/", "", htmlspecialchars($_GET["url"])), "/");
|
||||
|
||||
$storage = new StorageClient([
|
||||
'projectId' => $googleProjectId,
|
||||
'keyFilePath' => $googleKeyFilePath,
|
||||
]);
|
||||
$bucket = $storage->bucket($googleBucketName);
|
||||
|
||||
$stmt = $conn->prepare("SELECT id, uid, uploaded, original_name, filetype FROM uploads WHERE id = ?");
|
||||
$stmt->bind_param("s", $file);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($id, $uid, $uploaded, $original_filename, $fileType);
|
||||
|
||||
if (!$stmt->fetch()) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Xytriza's Uploading Service - File not found</title>
|
||||
<link rel="icon" href="https://upload.xytriza.com/assets/logo.png" type="image/png">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
|
||||
<link rel="stylesheet" href="https://upload.xytriza.com/dashboard/assets/main.css?v=<?php echo filemtime('/home/xytriza-upload/htdocs/upload.xytriza.com/dashboard/assets/main.css'); ?>">
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="https://upload.xytriza.com/dashboard/assets/main.js?v=<?php echo filemtime('/home/xytriza-upload/htdocs/upload.xytriza.com/dashboard/assets/main.js'); ?>"></script>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
if (checkUserSession($conn)) {
|
||||
$stmt = $conn->prepare("SELECT role FROM users WHERE session = ?");
|
||||
$stmt->bind_param("s", $_COOKIE["session"]);
|
||||
$stmt->execute();
|
||||
|
||||
$role = $stmt->get_result()->fetch_assoc()["role"];
|
||||
?>
|
||||
<div id="sidebar">
|
||||
<a href="/" class="logo"><img class="sidebar-item" src="https://upload.xytriza.com/assets/logo.png" alt="Xytriza's Uploading Service" height="40vw" width="40vw"></a>
|
||||
<a href="/dashboard/"><i class="fas fa-home sidebar-item"></i></a>
|
||||
<a href="/dashboard/gallery.php"><i class="fas fa-file-alt sidebar-item" style="margin-left: 20%;"></i></a>
|
||||
<a href="/dashboard/upload.php"><i class="fas fa-upload sidebar-item"></i></a>
|
||||
<a href="/dashboard/settings.php"><i class="fas fa-cog sidebar-item"></i></a>
|
||||
<?php
|
||||
if ($role === 1 || $role === 2) {
|
||||
echo '<a href="/dashboard/admin" class="sidebar-item"><i class="fas fa-user-shield"></i></a>
|
||||
<a href="/dashboard/admin/users.php" class="sidebar-item"><i class="fas fa-user-edit"></i></a>';
|
||||
}
|
||||
?>
|
||||
<a href="/dashboard/account.php" style="margin-top: auto;"><i class="fas fa-user-cog sidebar-item"></i></a>
|
||||
<a href="javascript:logout()"><i class="fas fa-sign-out-alt sidebar-item"></i></a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="notification-container"></div>
|
||||
|
||||
<div id="container">
|
||||
<div id="discord-link">
|
||||
<h1>File not found</h1>
|
||||
<p>We searched everywhere, but we couldn't find that file.</p>
|
||||
<button onclick="window.history.back()">Back</button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
http_response_code(404);
|
||||
die();
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
|
||||
$fileUrl = "https://files.upload.xytriza.com/{$file}";
|
||||
|
||||
$stmt = $conn->prepare("SELECT display_name, timezone FROM users WHERE uid = ?");
|
||||
$stmt->bind_param("s", $uid);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($username, $timezone);
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
|
||||
$username = htmlspecialchars($username, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
if (!isset($timezone) || empty($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers(DateTimeZone::ALL))) {
|
||||
$timezone = "America/Los_Angeles";
|
||||
}
|
||||
|
||||
$date = new DateTime("@{$uploaded}");
|
||||
$date->setTimezone(new DateTimeZone($timezone));
|
||||
|
||||
$utcOffset = $date->getOffset() / 3600;
|
||||
$utcOffsetFormatted = $utcOffset > 0 ? "+{$utcOffset}" : $utcOffset;
|
||||
|
||||
$formattedDate = $date->format("m/d/Y, g:i:s A") . " UTC{$utcOffsetFormatted}";
|
||||
|
||||
$now = new DateTime();
|
||||
$uploadedDate = DateTime::createFromFormat("U", $uploaded);
|
||||
$interval = $now->diff($uploadedDate);
|
||||
|
||||
$timeDiff = "Uploaded by {$username} ";
|
||||
|
||||
$timeUnits = ['year', 'month', 'day', 'hour', 'minute', 'second'];
|
||||
$timeValues = [$interval->y, $interval->m, $interval->d, $interval->h, $interval->i, $interval->s];
|
||||
|
||||
for ($i = 0; $i < count($timeUnits); $i++) {
|
||||
if ($timeValues[$i] > 0) {
|
||||
$timeDiff .= $timeValues[$i] . " " . $timeUnits[$i] . ($timeValues[$i] > 1 ? 's' : '') . ' ago';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$object = $bucket->object($id);
|
||||
$objectData = $object->downloadAsString();
|
||||
} catch (Exception $e) {
|
||||
die("Error searching for file.");
|
||||
}
|
||||
|
||||
if (in_array($fileType, ["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"])) {
|
||||
$objectInfo = getimagesizefromstring($objectData);
|
||||
|
||||
$width = $objectInfo[0];
|
||||
$height = $objectInfo[1];
|
||||
}
|
||||
|
||||
$original_filename = base64_decode($original_filename);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-SH08WXZBBG"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-SH08WXZBBG');
|
||||
</script>
|
||||
<meta name="robots" content="noindex">
|
||||
<title><?php echo $original_filename . ' - ' . $username;?></title>
|
||||
<link rel="icon" href="https://upload.xytriza.com/assets/logo.png" type="image/png">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="<?php echo 'Uploaded ' . $formattedDate . ' by ' . $username;?>">
|
||||
<meta property="og:title" content="<?php echo $original_filename?>">
|
||||
<meta property="og:description" content="<?php echo 'Uploaded ' . $formattedDate . ' by ' . $username;?>">
|
||||
<meta property="og:site_name" content="Xytriza's Uploading Service">
|
||||
<?
|
||||
if (in_array($fileType, ["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"])) {
|
||||
echo '<meta property="og:image" content="' . $fileUrl . '">
|
||||
<meta property="og:image:alt" content="' . $original_filename . '">
|
||||
<meta property="og:image:width" content="' . $width . '">
|
||||
<meta property="og:image:height" content="' . $height . '">';
|
||||
}
|
||||
?>
|
||||
<meta property="theme-color" content="#3c076e">
|
||||
<meta property="twitter:card" content="summary_large_image">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
|
||||
<link rel="stylesheet" href="https://upload.xytriza.com/dashboard/assets/main.css?v=<?php echo filemtime('/home/xytriza-upload/htdocs/upload.xytriza.com/dashboard/assets/main.css'); ?>">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="https://upload.xytriza.com/dashboard/assets/main.js?v=<?php echo filemtime('/home/xytriza-upload/htdocs/upload.xytriza.com/dashboard/assets/main.js'); ?>"></script>
|
||||
<style>
|
||||
img {
|
||||
max-width: 50vw;
|
||||
max-height: 50vh;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
if (checkUserSession($conn)) {
|
||||
$stmt = $conn->prepare("SELECT role FROM users WHERE session = ?");
|
||||
$stmt->bind_param("s", $_COOKIE["session"]);
|
||||
$stmt->execute();
|
||||
|
||||
$role = $stmt->get_result()->fetch_assoc()["role"];
|
||||
?>
|
||||
<div id="sidebar">
|
||||
<a href="/" class="logo"><img class="sidebar-item" src="https://upload.xytriza.com/assets/logo.png" alt="Xytriza's Uploading Service" height="40vw" width="40vw"></a>
|
||||
<a href="/dashboard/"><i class="fas fa-home sidebar-item"></i></a>
|
||||
<a href="/dashboard/gallery.php"><i class="fas fa-file-alt sidebar-item" style="margin-left: 20%;"></i></a>
|
||||
<a href="/dashboard/upload.php"><i class="fas fa-upload sidebar-item"></i></a>
|
||||
<a href="/dashboard/settings.php"><i class="fas fa-cog sidebar-item"></i></a>
|
||||
<a href="/dashboard/account.php" style="margin-top: auto;"><i class="fas fa-user-cog sidebar-item"></i></a>
|
||||
<?php
|
||||
if ($role === 1 || $role === 2) {
|
||||
echo '<a href="/dashboard/admin" class="sidebar-item"><i class="fas fa-user-shield"></i></a>
|
||||
<a href="/dashboard/admin/users.php" class="sidebar-item"><i class="fas fa-user-edit"></i></a>';
|
||||
}
|
||||
?>
|
||||
<a href="javascript:logout()"><i class="fas fa-sign-out-alt sidebar-item"></i></a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="notification-container"></div>
|
||||
|
||||
<div id="container">
|
||||
<div id="content">
|
||||
<div id="file-container">
|
||||
<h1><? echo "{$original_filename} • {$timeDiff}"; ?></h1>
|
||||
<?php
|
||||
if (in_array($fileType, ["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"])) {
|
||||
echo '<img src="' . $fileUrl . '" alt="' . htmlspecialchars($file, ENT_QUOTES, 'UTF-8') . '">';
|
||||
} elseif (in_array($fileType, ["video/mp4", "video/webm", "video/ogg"])) {
|
||||
echo '<video width="100%" height="auto" controls><source src="' . $fileUrl . '" type="' . htmlspecialchars($fileType, ENT_QUOTES, 'UTF-8') . '">Your browser does not support the video tag.</video>';
|
||||
} elseif (in_array($fileType, ["audio/mpeg", "audio/wav", "audio/ogg"])) {
|
||||
echo '<audio controls><source src="' . $fileUrl . '" type="' . $fileType . '">Your browser does not support the audio element.</audio>';
|
||||
} elseif (in_array($fileType, ["text/plain"])) {
|
||||
$fileContent = $object['Body']->getContents();
|
||||
if (strlen($fileContent) > 100000) {
|
||||
$fileContent = substr($fileContent, 0, 100000) . "... Preview too long. Download the file to view the full content.";
|
||||
}
|
||||
echo '<textarea readonly class="file-textbox">' . htmlspecialchars($fileContent, ENT_QUOTES, 'UTF-8') . '</textarea>';
|
||||
} else {
|
||||
echo '<p>Unable to display file "' . $fileType . '". Suggest support for this type in our Discord.</p>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<button class="button" onclick="downloadFile('<?php echo $fileUrl; ?>', '<?php echo $original_filename; ?>', '<?php echo $fileType; ?>')">Download</button>
|
||||
<button class="button" onclick="copyToClipboard('<?php echo $fileUrl; ?>', 'File URL copied to clipboard', 0)">Copy link</button>
|
||||
<?php
|
||||
if (in_array($fileType, ["text/plain"])) {
|
||||
echo '<button class="button" onclick="copyToClipboard(\'' . $fileContent . '\', \'File content copied to clipboard\', 0)">Copy</button>';
|
||||
}
|
||||
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], "https://upload.xytriza.com/dashboard/gallery.php") !== false) {
|
||||
echo '<button class="button" onclick="window.history.back()">Back</button>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (window.location.search.includes("download=1")) {
|
||||
downloadFile("<?php echo $fileUrl; ?>", "<?php echo $original_filename; ?>", "<?php echo $fileType; ?>");
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
require '../config/config.php';
|
||||
require '../incl/main.php';
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$apiKey = isset($_POST['key']) ? $_POST['key'] : null;
|
||||
$session = isset($_COOKIE['session']) ? $_COOKIE['session'] : null;
|
||||
$password = null;//isset($_POST['password']) ? $_POST['password'] : null;
|
||||
$spoiler = isset($_POST['spoiler']) ? $_POST['spoiler'] : null;
|
||||
$filename = isset($_POST['filename']) ? $_POST['filename'] : null;
|
||||
$fileId = isset($_POST['fileId']) ? $_POST['fileId'] : null;
|
||||
|
||||
$query = "UPDATE uploads SET ";
|
||||
$params = [];
|
||||
$paramTypes = "";
|
||||
|
||||
if ($password !== null) {
|
||||
if (strlen($password) > 6) {
|
||||
$password = null;
|
||||
} else {
|
||||
$query .= "password = ?, ";
|
||||
array_push($params, $password);
|
||||
$paramTypes .= "s";
|
||||
}
|
||||
}
|
||||
|
||||
if ($filename !== null) {
|
||||
if (strlen($filename) > 255) {
|
||||
$filename = null;
|
||||
} else {
|
||||
$query .= "original_name = ?, ";
|
||||
array_push($params, base64_encode($filename));
|
||||
$paramTypes .= "s";
|
||||
}
|
||||
}
|
||||
|
||||
if ($password !== null || $filename !== null) {
|
||||
$query = substr($query, 0, -2);
|
||||
if ($apiKey !== null) {
|
||||
$query .= " WHERE id = ? AND uid = (SELECT uid FROM users WHERE api_key = ?)";
|
||||
array_push($params, $fileId, $apiKey);
|
||||
$paramTypes .= "ss";
|
||||
} elseif ($session !== null) {
|
||||
$query .= " WHERE id = ? AND uid = (SELECT uid FROM users WHERE session = ?)";
|
||||
array_push($params, $fileId, $session);
|
||||
$paramTypes .= "ss";
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param($paramTypes, ...$params);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->affected_rows > 0) {
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'response' => 'File preferences updated',
|
||||
];
|
||||
http_response_code(200);
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'No update was made',
|
||||
];
|
||||
http_response_code(400);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid parameters',
|
||||
];
|
||||
http_response_code(400);
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
require '../config/config.php';
|
||||
include '../incl/main.php';
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$apikey = isset($_SERVER['HTTP_KEY']) ? $_SERVER['HTTP_KEY'] : '';
|
||||
$fileid = isset($_SERVER['HTTP_FILEID']) ? $_SERVER['HTTP_FILEID'] : '';
|
||||
|
||||
if (empty($apikey) || empty($fileid)) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid request',
|
||||
];
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT uid FROM users WHERE api_key = ?");
|
||||
$stmt->bind_param("s", $apikey);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$user = $result->fetch_assoc();
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM uploads WHERE id = ?");
|
||||
$stmt->bind_param("s", $fileid);
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows == 0) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'File not found',
|
||||
];
|
||||
http_response_code(404);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$fileInfo = $result->fetch_assoc();
|
||||
|
||||
$info = [
|
||||
'id' => $fileid,
|
||||
'uploaderUid' => $fileInfo['uid'],
|
||||
'size' => $fileInfo['size'],
|
||||
'sizeFormatted' => formatUnitSize($fileInfo['size']),
|
||||
'uploadedAt' => $fileInfo['uploaded'],
|
||||
'fileName' => base64_decode($fileInfo['original_name']),
|
||||
'fileType' => $fileInfo['filetype'],
|
||||
];
|
||||
|
||||
$response = [
|
||||
'success' => true,
|
||||
'response' => 'Information for file "' . $fileid . '"',
|
||||
'fileinfo' => $info,
|
||||
];
|
||||
|
||||
http_response_code(200);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid API key',
|
||||
];
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
require '../config/config.php';
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$apikey = isset($_SERVER['HTTP_KEY']) ? $_SERVER['HTTP_KEY'] : '';
|
||||
|
||||
$stmt = $conn->prepare("SELECT uid FROM users WHERE api_key = ?");
|
||||
$stmt->bind_param("s", $apikey);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$user = $result->fetch_assoc();
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM uploads WHERE uid = ?");
|
||||
$stmt->bind_param("s", $user['uid']);
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
$uploads = [];
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$uploads[] = [
|
||||
'id' => $row['id'],
|
||||
'size' => $row['size'],
|
||||
'uploaded' => $row['uploaded'],
|
||||
'filename' => base64_decode($row['original_name']),
|
||||
'filetype' => $row['filetype'],
|
||||
'deletionkey' => $row['delete_key'],
|
||||
];
|
||||
}
|
||||
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'response' => 'Here are your uploads',
|
||||
'uploads' => $uploads,
|
||||
];
|
||||
|
||||
http_response_code(200);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid API key',
|
||||
];
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
require '../config/config.php';
|
||||
include '../incl/main.php';
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$apikey = isset($_SERVER['HTTP_KEY']) ? $_SERVER['HTTP_KEY'] : '';
|
||||
$uid = isset($_SERVER['HTTP_UID']) ? $_SERVER['HTTP_UID'] : '';
|
||||
|
||||
if (empty($apikey)) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid request',
|
||||
];
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE api_key = ?");
|
||||
$stmt->bind_param("s", $apikey);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$user = $result->fetch_assoc();
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE uid = ?");
|
||||
$stmt->bind_param("i", $uid);
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows == 0) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'User not found',
|
||||
];
|
||||
http_response_code(404);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$userInfo = $result->fetch_assoc();
|
||||
$role = $userInfo['role'] == 1 ? "Owner" : ($userInfo['role'] == 2 ? "Manager" : ($userInfo['role'] == 0 ? "User" : "Unknown"));
|
||||
if ($userInfo['discord_id'] == null || $userInfo['discord_id'] == "") {
|
||||
$userInfo['discord_id'] = "N/A";
|
||||
}
|
||||
if ($userInfo['discord_avatar'] == null || $userInfo['discord_avatar'] == "") {
|
||||
$userInfo['discord_avatar'] = "N/A";
|
||||
}
|
||||
|
||||
$info = [
|
||||
'uid' => $userInfo['uid'],
|
||||
'username' => $userInfo['username'],
|
||||
'displayName' => $userInfo['display_name'],
|
||||
'discordId' => $userInfo['discord_id'],
|
||||
'role' => $role,
|
||||
'registerTime' => $userInfo['register_time'],
|
||||
'avatar' => $userInfo['discord_avatar'],
|
||||
];
|
||||
|
||||
$response = [
|
||||
'success' => true,
|
||||
'response' => 'Information for user "' . $userInfo['display_name'] . '"',
|
||||
'userinfo' => $info,
|
||||
];
|
||||
|
||||
http_response_code(200);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid API key',
|
||||
];
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
require '../config/config.php';
|
||||
require '../incl/main.php';
|
||||
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$token = isset($_POST['captcha_token']) ? $_POST['captcha_token'] : '';
|
||||
|
||||
$url = 'https://challenges.cloudflare.com/turnstile/v0/siteverify';
|
||||
|
||||
$data = [
|
||||
'secret' => '0x4AAAAAAARIYYLl4IlaAeS9Q40g-Y6QZ9M',
|
||||
'response' => $token,
|
||||
'remoteip' => $ip,
|
||||
];
|
||||
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'method' => 'POST',
|
||||
'content' => http_build_query($data),
|
||||
],
|
||||
];
|
||||
|
||||
$context = stream_context_create($options);
|
||||
$result = file_get_contents($url, false, $context);
|
||||
|
||||
if ($result !== false) {
|
||||
$outcome = json_decode($result, true);
|
||||
|
||||
if (!isset($outcome['success']) || !$outcome['success']) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid captcha',
|
||||
];
|
||||
|
||||
http_response_code(403);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to validate captcha',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
function generateRandomString($length) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[random_int(0, strlen($characters) - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
$request_username = $_POST['username'];
|
||||
$request_password = $_POST['password'];
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
|
||||
$stmt->bind_param("s", $request_username);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
if (password_verify($request_password, $row["password"])) {
|
||||
$login_ip = $_SERVER['REMOTE_ADDR'];
|
||||
$login_time = time();
|
||||
$session_token = generateRandomString(255);
|
||||
$session_expires = $login_time + (7 * 24 * 60 * 60);
|
||||
$uid = $row['uid'];
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET session = ?, session_expire = ?, latest_ip = ? WHERE uid = ?");
|
||||
$stmt->bind_param("sssi", $session_token, $session_expires, $login_ip, $uid);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO logins (uid, session_token, session_expire, login_ip, login_time) VALUES (?, ?, ?, ?, ?)");
|
||||
$stmt->bind_param("isssi", $uid, $session_token, $session_expires, $login_ip, $login_time);
|
||||
$stmt->execute();
|
||||
|
||||
$row['session_token'] = $session_token;
|
||||
$row['session_expires'] = $session_expires;
|
||||
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'session' => $session_token,
|
||||
'session_expires' => $session_expires,
|
||||
];
|
||||
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Incorrect username or password',
|
||||
];
|
||||
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Incorrect username or password',
|
||||
];
|
||||
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
require '../config/config.php';
|
||||
require '../incl/main.php';
|
||||
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$token = isset($_POST['captcha_token']) ? $_POST['captcha_token'] : '';
|
||||
|
||||
$url = 'https://challenges.cloudflare.com/turnstile/v0/siteverify';
|
||||
|
||||
$data = [
|
||||
'secret' => '0x4AAAAAAARIYYLl4IlaAeS9Q40g-Y6QZ9M',
|
||||
'response' => $token,
|
||||
'remoteip' => $ip,
|
||||
];
|
||||
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'method' => 'POST',
|
||||
'content' => http_build_query($data),
|
||||
],
|
||||
];
|
||||
|
||||
$context = stream_context_create($options);
|
||||
$result = file_get_contents($url, false, $context);
|
||||
|
||||
if ($result !== false) {
|
||||
$outcome = json_decode($result, true);
|
||||
|
||||
if (!isset($outcome['success']) || !$outcome['success']) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid captcha',
|
||||
];
|
||||
|
||||
http_response_code(403);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
} else {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to validate captcha',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$request_username = isset($_POST['username']) ? $_POST['username'] : '';
|
||||
$request_displayname = (isset($_POST['displayname']) && !empty($_POST['displayname'])) ? $_POST['displayname'] : $request_username;
|
||||
$request_password = isset($_POST['password']) ? $_POST['password'] : '';
|
||||
$request_email = isset($_POST['email']) ? $_POST['email'] : '';
|
||||
|
||||
if (empty($request_username) || empty($request_password) || empty($request_email)) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Missing username, password or email',
|
||||
];
|
||||
|
||||
http_response_code(400);
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
if (!ctype_alnum($request_username)) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Username must be alphanumeric',
|
||||
];
|
||||
|
||||
http_response_code(400);
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
if (!filter_var($request_email, FILTER_VALIDATE_EMAIL)) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Invalid email',
|
||||
];
|
||||
|
||||
http_response_code(400);
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
if (strlen($request_password) < 8 || !preg_match("/[A-Za-z]/", $request_password) || !preg_match("/[0-9]/", $request_password)) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Password must be at least 8 characters long and contain at least one letter and one number',
|
||||
];
|
||||
|
||||
http_response_code(400);
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
if (strlen($request_username) < 3 || strlen($request_username) > 32) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'response' => 'Userame must be between 3 and 32 characters']));
|
||||
exit;
|
||||
}
|
||||
|
||||
if (strlen($request_displayname) < 3 || strlen($request_displayname) > 32) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode(['success' => 'false', 'response' => 'Display Name must be between 3 and 32 characters']));
|
||||
exit;
|
||||
}
|
||||
|
||||
function generateRandomString($length) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[random_int(0, strlen($characters) - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
$hashed_password = password_hash($request_password, PASSWORD_DEFAULT);
|
||||
|
||||
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ? OR email = ?");
|
||||
$stmt->bind_param("ss", $request_username, $request_email);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Username or email already exists',
|
||||
];
|
||||
|
||||
http_response_code(400);
|
||||
die(json_encode($response));
|
||||
} else {
|
||||
$api_key = generateRandomString(32);
|
||||
$emailconfirm = generateRandomString(255);
|
||||
$emailcontent = '<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Email Confirmation</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: "Arial", sans-serif;
|
||||
background-color: #1f1f1f;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.container {
|
||||
background-color: #222;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
margin: 20px auto;
|
||||
padding: 20px;
|
||||
max-width: 600px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
p {
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
a {
|
||||
display: inline-block;
|
||||
padding: 12px 24px;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
color: #fff !important;
|
||||
background-color: #3c076e;
|
||||
border-radius: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Email Confirmation</h1>
|
||||
<p>Thank you for signing up with Xytriza\'s Uploading Service! We\'re excited to have you on board.</p>
|
||||
<p>To complete the registration process, please click on the link below to confirm your email address:</p>
|
||||
|
||||
<a href="https://upload.xytriza.com/confirm-email/' . $emailconfirm . '">Confirm Your Email</a>
|
||||
|
||||
<p>If you did not sign up for Xytriza\'s Uploading Service, please disregard this email and the account will be unregistered within 2 hours.</p>
|
||||
|
||||
<p>Thank you,<br>Xytriza\'s Uploading Service Team</br></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
$emailresult = true;//sendEmail($noreply_email_address, $noreply_email_password, $noreply_email_address, $request_email, $request_username, "Action Required: Confirm Your Email Address with Xytriza\'s Uploading Service", $emailcontent, true, 'smtp.ionos.com');
|
||||
// will do soon (real)
|
||||
|
||||
if (!$emailresult) {
|
||||
$response = [
|
||||
'success' => 'false',
|
||||
'response' => 'Error sending conformation email, please try again later'
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO users (username, display_name, password, email, api_key, emailconfirm, register_time) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->bind_param("ssssssi", $request_username, $request_displayname, $hashed_password, $request_email, $api_key, $emailconfirm, time());
|
||||
$stmt->execute();
|
||||
|
||||
$response = [
|
||||
'success' => 'true',
|
||||
'response' => 'Account created successfully'
|
||||
];
|
||||
|
||||
http_response_code(200);
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
require '../../libs/vendor/autoload.php';
|
||||
require '../config/config.php';
|
||||
require '../incl/main.php';
|
||||
|
||||
use Google\Cloud\Storage\StorageClient;
|
||||
|
||||
function generateRandomString($length) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[random_int(0, strlen($characters) - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
$response = [
|
||||
'success' => false,
|
||||
'response' => 'Unable to access database',
|
||||
];
|
||||
|
||||
http_response_code(500);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$key = isset($_SERVER['HTTP_KEY']) ? $_SERVER['HTTP_KEY'] : '';
|
||||
|
||||
if ($_COOKIE['session']) {
|
||||
$sql = "SELECT uid FROM users WHERE session = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $_COOKIE['session']);
|
||||
} else {
|
||||
$sql = "SELECT uid, role FROM users WHERE api_key = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $key);
|
||||
}
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
$row = $result->fetch_assoc();
|
||||
$uid = $row["uid"];
|
||||
} else {
|
||||
$response = [
|
||||
'success' => false,
|
||||
'response' => 'Invalid API Key',
|
||||
];
|
||||
|
||||
http_response_code(401);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$sql = "SELECT SUM(size) as totalSize FROM uploads WHERE uid = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("i", $uid);
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->get_result();
|
||||
$row = $result->fetch_assoc();
|
||||
$totalSize = $row['totalSize'];
|
||||
|
||||
//role1 is owner (150gb)
|
||||
//role2 is admin (25gb)
|
||||
//else (5gb)
|
||||
|
||||
if ($row['role'] === 1 && $totalSize > 161061273600) {
|
||||
$response = [
|
||||
'success' => false,
|
||||
'response' => 'You cannot use more than 150GB of storage',
|
||||
];
|
||||
|
||||
http_response_code(403);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
} elseif ($row['role'] === 2 && $totalSize > 26843545600) {
|
||||
$response = [
|
||||
'success' => false,
|
||||
'response' => 'You cannot use more than 25GB of storage',
|
||||
];
|
||||
|
||||
http_response_code(403);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
} else if ($totalSize > 5368709120) {
|
||||
$response = [
|
||||
'success' => false,
|
||||
'response' => 'You cannot use more than 5GB of storage',
|
||||
];
|
||||
|
||||
http_response_code(403);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
if ($_FILES['file']['error'] === UPLOAD_ERR_OK) {
|
||||
do {
|
||||
$randomString = generateRandomString(8);
|
||||
$sql = "SELECT id FROM uploads WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $randomString);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
} while ($result->num_rows > 0);
|
||||
|
||||
do {
|
||||
$deleteKey = generateRandomString(24);
|
||||
$sql = "SELECT id FROM uploads WHERE delete_key = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("s", $deleteKey);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
} while ($result->num_rows > 0);
|
||||
|
||||
$storage = new StorageClient([
|
||||
'projectId' => $googleProjectId,
|
||||
'keyFilePath' => $googleKeyFilePath,
|
||||
]);
|
||||
|
||||
$bucket = $storage->bucket($googleBucketName);
|
||||
|
||||
$filePath = $_FILES['file']['tmp_name'];
|
||||
$fileName = base64_encode(htmlspecialchars($_FILES['file']['name']));
|
||||
$fileType = (new finfo(FILEINFO_MIME_TYPE))->buffer(file_get_contents($filePath));
|
||||
|
||||
$options = [
|
||||
'name' => $randomString,
|
||||
'metadata' => [
|
||||
'cacheControl' => 'no-cache, no-store, must-revalidate',
|
||||
'contentType' => $fileType,
|
||||
],
|
||||
];
|
||||
|
||||
$bucket->upload(
|
||||
fopen($filePath, 'r'),
|
||||
$options
|
||||
);
|
||||
|
||||
$size = filesize($filePath);
|
||||
|
||||
$sql = "INSERT INTO uploads (id, uid, uploaded, delete_key, size, original_name, filetype) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$currentTime = time();
|
||||
$stmt->bind_param("siisiss", $randomString, $uid, $currentTime, $deleteKey, $size, $fileName, $fileType);
|
||||
$stmt->execute();
|
||||
|
||||
$response = [
|
||||
'success' => true,
|
||||
'response' => 'File uploaded successfully',
|
||||
'fileUrl' => 'https://upload.xytriza.com/files/'.$randomString,
|
||||
'deletionUrl' => 'https://upload.xytriza.com/delete/'.$deleteKey,
|
||||
'deletionKey' => $deleteKey,
|
||||
];
|
||||
|
||||
http_response_code(200);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
} else {
|
||||
$response = [
|
||||
'success' => false,
|
||||
'response' => 'Invalid file upload'
|
||||
];
|
||||
|
||||
http_response_code(400);
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode($response));
|
||||
}
|
||||
?>
|
||||
Reference in new issue
Block a user