Skip to content

Commit

Permalink
PUSH
Browse files Browse the repository at this point in the history
  • Loading branch information
NaysKutzu committed Oct 19, 2023
1 parent ad78108 commit 3e3909a
Show file tree
Hide file tree
Showing 22 changed files with 726 additions and 363 deletions.
1 change: 1 addition & 0 deletions Insomnia_2023-10-19.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"_type":"export","__export_format":4,"__export_date":"2023-10-19T20:42:04.363Z","__export_source":"insomnia.desktop.app:v8.3.0","resources":[{"_id":"req_5c04f332fd5d47e399f1c9beeeb66a65","parentId":"fld_e104fd81a13d448b880f4f8921ac8028","modified":1697746630922,"created":1697744921958,"url":"https://devclient.mythicalsystems.me/api/admin/user/resources/set","name":"Set","description":"This just assigns resources to the user.","method":"POST","body":{"mimeType":"multipart/form-data","params":[{"id":"pair_786fa7c51a9847758381b99be88d5942","name":"email","value":"[email protected]","description":""},{"id":"pair_bd61ca0e3aa6445fb9c84423cbf4af37","name":"coins","value":"150","description":""},{"id":"pair_2f9ef79ce3ff4650b369a4e13c423e2e","name":"ram","value":"1024","description":""},{"id":"pair_c5b179fdfc5147228ea28b9a58c05498","name":"disk","value":"1024","description":""},{"id":"pair_bf996290689e4d01802538fe67f7e7b4","name":"cpu","value":"100","description":""},{"id":"pair_2c86496730e64070b1829a5eec9040f7","name":"server_limit","value":"1","description":""},{"id":"pair_351b69b1fe0747059893ca98e1243d36","name":"ports","value":"1","description":""},{"id":"pair_c9b374c78d75445e851f438a9e6a4338","name":"databases","value":"1","description":""},{"id":"pair_b305b47d376f4a718457757698f17edd","name":"backups","value":"1","description":""}]},"parameters":[],"headers":[{"name":"Content-Type","value":"multipart/form-data"},{"name":"User-Agent","value":"insomnia/8.3.0","id":"pair_d1897202eda04fa58bfa3f24ec3e8107"},{"id":"pair_a40e75d71994400d9675a72c9d4b8673","name":"Authorization","value":"mythicaldash_apikey","description":""}],"authentication":{},"metaSortKey":-1697744875752,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_e104fd81a13d448b880f4f8921ac8028","parentId":"fld_e8ff218397174389bae6a3a5661669c0","modified":1697744844978,"created":1697744840177,"name":"Resources","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1697742197784,"_type":"request_group"},{"_id":"fld_e8ff218397174389bae6a3a5661669c0","parentId":"fld_1e79fba929fc4d72bb47e7eb24ec1737","modified":1697742189325,"created":1697742176368,"name":"User","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1697740779163,"_type":"request_group"},{"_id":"fld_1e79fba929fc4d72bb47e7eb24ec1737","parentId":"wrk_a2ea7d20da784d39a2211928ba8a016f","modified":1697740702126,"created":1697740702126,"name":"Admin","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1697740702126,"_type":"request_group"},{"_id":"wrk_a2ea7d20da784d39a2211928ba8a016f","parentId":null,"modified":1697740507721,"created":1697740507721,"name":"MythicalDash API","description":"","scope":"collection","_type":"workspace"},{"_id":"req_7219bb298f4f487a9fff86d14f7a7c2b","parentId":"fld_e104fd81a13d448b880f4f8921ac8028","modified":1697747863230,"created":1697744848474,"url":"https://devclient.mythicalsystems.me/api/admin/user/resources/add","name":"Add","description":"This just adds resources to the user.","method":"POST","body":{"mimeType":"multipart/form-data","params":[{"id":"pair_61239e6aebf748eaa512e784c5d06aae","name":"email","value":"[email protected]","description":""},{"id":"pair_49bc7f42e8f14355919bc9bcba11c16a","name":"coins","value":"0","description":""},{"id":"pair_6ca9896e89484881ba8e5c221929120b","name":"ram","value":"0","description":""},{"id":"pair_0c7483614a85494f89fe258044b5e5c2","name":"disk","value":"0","description":""},{"id":"pair_4ecd5a6dc69b4bf5b1876f83714ad958","name":"cpu","value":"0","description":""},{"id":"pair_9d1b3fc865c24db499e43fa2b163cf2c","name":"server_limit","value":"0","description":""},{"id":"pair_41c75a5885594d1c9d4189229f935643","name":"ports","value":"0","description":""},{"id":"pair_4f4c82aeab6a46a2bd2fc3428d1007de","name":"databases","value":"0","description":""},{"id":"pair_0cf0342cf5cd4eb5a2d2af363c25c974","name":"backups","value":"0","description":""}]},"parameters":[],"headers":[{"name":"Content-Type","value":"multipart/form-data"},{"name":"User-Agent","value":"insomnia/8.3.0","id":"pair_9537cfb9de5c498f8dd8c3673ef25bd4"},{"id":"pair_28df8e45bc3149f2a1489d7bc76159f9","name":"Authorization","value":"mythicaldash_apikey","description":""}],"authentication":{},"metaSortKey":-1697744875652,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_a99d49ff72144407a8a82f0a62dd5e0b","parentId":"fld_e8ff218397174389bae6a3a5661669c0","modified":1697744734268,"created":1697744162993,"url":"https://devclient.mythicalsystems.me/api/admin/user/unban","name":"UnBan","description":"This just unbans the user","method":"POST","body":{"mimeType":"multipart/form-data","params":[{"id":"pair_c594e08be34c4407823b1b5e47b3e653","name":"email","value":"[email protected]","description":""}]},"parameters":[],"headers":[{"name":"Content-Type","value":"multipart/form-data"},{"name":"User-Agent","value":"insomnia/8.3.0","id":"pair_7de2161e9d1749448b3084018dff7ed5"},{"id":"pair_76dc3d74fad04d8fa5d64476ce41e1ff","name":"Authorization","value":"mythicaldash_apikey","description":""}],"authentication":{},"metaSortKey":-1697742197684,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_da47a5a9e6da4b6fad000de655d92af7","parentId":"fld_e8ff218397174389bae6a3a5661669c0","modified":1697744759828,"created":1697743754282,"url":"https://devclient.mythicalsystems.me/api/admin/user/ban","name":"Ban","description":"This just bans the user","method":"POST","body":{"mimeType":"multipart/form-data","params":[{"id":"pair_eae57274a71e470ba08874f58b9360ac","name":"email","value":"[email protected]","description":""}]},"parameters":[{"id":"pair_1c87f16c519549ee8214c152f67ecee5","name":"email","value":"[email protected]","description":""}],"headers":[{"name":"Content-Type","value":"multipart/form-data"},{"name":"User-Agent","value":"insomnia/8.3.0","id":"pair_11fd718730a54fdc86c132feb9cd95f8"},{"id":"pair_8ffae0e5b0c349a89cb16eb4602543e3","name":"Authorization","value":"mythicaldash_apikey","description":""}],"authentication":{},"metaSortKey":-1697742197584,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_90ae0bacdb83448394c98a758eaeb836","parentId":"fld_e8ff218397174389bae6a3a5661669c0","modified":1697747477606,"created":1697747326361,"url":"https://devclient.mythicalsystems.me/api/admin/user/reset-password","name":"Reset-Password","description":"Created a code for a password reset!","method":"POST","body":{"mimeType":"multipart/form-data","params":[{"id":"pair_39a363f2bb3e4df3a116f4fd68b509b4","name":"email","value":"[email protected]","description":""}]},"parameters":[],"headers":[{"name":"Content-Type","value":"multipart/form-data","id":"pair_f8e17e133adf4338bd923cdb0b5f1fc8"},{"name":"User-Agent","value":"insomnia/8.3.0","id":"pair_fee36d87652942a5a1c194866d8b0c0b"},{"id":"pair_5c8abceb26ea42a28a5a5abb96952c4c","name":"Authorization","value":"mythicaldash_apikey","description":""}],"authentication":{},"metaSortKey":-1697742197534,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_fe1fa766bcec471a8a21d2c11965866e","parentId":"fld_e8ff218397174389bae6a3a5661669c0","modified":1697744605637,"created":1697742998516,"url":"https://devclient.mythicalsystems.me/api/admin/user/{% os 'userInfo', '' %}","name":"Info ","description":"This thing gets info about the user","method":"GET","body":{"mimeType":"application/json","text":""},"parameters":[{"id":"pair_0253fef8faa045e5894fc2766df9e28c","name":"email","value":"[email protected]","description":""}],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_9a33a6992501492eb76edb45c3036efe"},{"name":"User-Agent","value":"insomnia/8.3.0","id":"pair_6fb35dbd784449f796946d1d98d017a3"},{"id":"pair_b1f3c0065c61437b89e8862818c7481e","name":"Authorization","value":"mythicaldash_apikey","description":""}],"authentication":{},"metaSortKey":-1697742197484,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_1e289ae49b444a509e7b91c6c40acee4","parentId":"fld_e8ff218397174389bae6a3a5661669c0","modified":1697742897891,"created":1697742191918,"url":"https://devclient.mythicalsystems.me/api/admin/user/list","name":"List","description":"List all users from the database","method":"GET","body":{"mimeType":"application/json","text":""},"parameters":[{"id":"pair_fbf53b9fc1a34fe293680c85bf157788","name":"page","value":"2","description":""}],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_af99c4dffac040e4b7c9d291c62dd7bf"},{"name":"User-Agent","value":"insomnia/8.3.0","id":"pair_0442a6887683493891e5585b60530e35"},{"id":"pair_7b70e9741eea493692dad339b83269aa","name":"Authorization","value":"mythicaldash_apikey","description":""}],"authentication":{},"metaSortKey":-1697742197384,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_9e23eaa6a5034f35b0aa4483b1bb076c","parentId":"fld_1e79fba929fc4d72bb47e7eb24ec1737","modified":1697741102255,"created":1697740704720,"url":"https://devclient.mythicalsystems.me/api/admin/statistics","name":"Statistics","description":"Get the statistics like total users or servers. ","method":"GET","body":{"mimeType":"application/json","text":""},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_0ad1e4468cf34a96a1ec9365e52123eb"},{"name":"User-Agent","value":"insomnia/8.3.0","id":"pair_b2a11c367ba04277995facb1677e2faa"},{"id":"pair_7de0770235aa41428c3010d6f09d408e","name":"Authorization","value":"mythicaldash_apikey","description":""}],"authentication":{},"metaSortKey":-1697740779063,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_a872852d26284b63b48593ef47a0f8ae","parentId":"wrk_a2ea7d20da784d39a2211928ba8a016f","modified":1697740564415,"created":1697740511067,"url":"https://devclient.mythicalsystems.me/api","name":"Main","description":"This does nothing it is just the main API path.","method":"GET","body":{"mimeType":"application/json","text":""},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/8.3.0"}],"authentication":{},"metaSortKey":-1697740511067,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_75e6215485b10e994d1f4dc9866824c7d9b84a91","parentId":"wrk_a2ea7d20da784d39a2211928ba8a016f","modified":1697740507722,"created":1697740507722,"name":"Base Environment","data":{},"dataPropertyOrder":null,"color":null,"isPrivate":false,"metaSortKey":1697740507722,"_type":"environment"},{"_id":"jar_75e6215485b10e994d1f4dc9866824c7d9b84a91","parentId":"wrk_a2ea7d20da784d39a2211928ba8a016f","modified":1697740523072,"created":1697740507722,"name":"Default Jar","cookies":[{"key":"PHPSESSID","value":"pi2u6pkf2bohb5mn5jb1ariune","domain":"devclient.mythicalsystems.me","path":"/","hostOnly":true,"creation":"2023-10-19T18:35:23.072Z","lastAccessed":"2023-10-19T18:35:23.072Z","id":"29508785360150114"}],"_type":"cookie_jar"}]}
72 changes: 72 additions & 0 deletions api/admin/user/ban.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
include(__DIR__ . "/../base.php");
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
if (isset($_POST['email']) && !$_POST['email'] == "") {
$email = mysqli_real_escape_string($conn, $_POST['email']);
$query = "SELECT * FROM mythicaldash_users WHERE `email` = '$email'";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
$userdb = $conn->query("SELECT * FROM mythicaldash_users WHERE email = '" . $email . "'")->fetch_array();
if ($userdb['banned'] == "") {
if (isset($_POST['reason'])) {
$reason = mysqli_real_escape_string($conn, $_POST['reason']);
} else {
$reason = 'Unknown';
}
$conn->query("UPDATE `mythicaldash_users` SET `banned` = '$reason' WHERE `mythicaldash_users`.`email` = '$email';");
$rsp = array(
"code" => 200,
"error" => null,
"message" => "We banned ".$userdb['username'],
);
http_response_code(200);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
} else {
$rsp = array(
"code" => 403,
"error" => "The server understood the request, but it refuses to authorize it.",
"message" => "User is already banned!"
);
http_response_code(403);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}

} else {
$rsp = array(
"code" => 403,
"error" => "The server understood the request, but it refuses to authorize it.",
"message" => "We can't find this user in our database!"
);
http_response_code(403);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
} else {
$rsp = array(
"code" => 400,
"error" => "Bad request syntax",
"message" => "Email is required, but not provided."
);
http_response_code(400);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}

} catch (Exception $e) {
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
} else {
$rsp = array(
"code" => 405,
"error" => "A request was made of a page using a request method not supported by that page",
"message" => "Please use a post request"
);
http_response_code(405);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
?>
90 changes: 90 additions & 0 deletions api/admin/user/info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
include(__DIR__ . "/../base.php");
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
try {
if (isset($_GET['email']) && !$_GET['email'] == "") {
$email = mysqli_real_escape_string($conn, $_GET['email']);
$query = "SELECT * FROM mythicaldash_users WHERE `email` = '$email'";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
$userdb = $conn->query("SELECT * FROM mythicaldash_users WHERE email = '" . $email . "'")->fetch_array();
$rsp = array(
"code" => 200,
"error" => null,
"info" => array(
"database_id" => $userdb['id'],
"pterodactyl_id" => $userdb["panel_id"],
"username" => $userdb['username'],
"email" => $userdb['email'],
"first_name" => decrypt($userdb['first_name'], $ekey),
"last_name" => decrypt($userdb['last_name'], $ekey),
"role" => $userdb['role'],
"banned" => $userdb['banned'],
"last_ip" => $userdb["last_ip"],
"first_ip" => $userdb["first_ip"],
"registred_at" => $userdb['registred']
),
"resources" => array(
"coins" => $userdb['coins'],
"ram" => $userdb['ram'],
"disk" => $userdb['disk'],
"cpu" => $userdb['cpu'],
"server_limit" => $userdb['server_limit'],
"ports" => $userdb['ports'],
"databases" => $userdb['databases'],
"backups" => $userdb['backups'],
"minutes_afk" => $userdb["minutes_afk"],
),
"discord" => array(
"linked" => $userdb["discord_linked"],
"discord_id" => $userdb["discord_id"],
"discord_username" => $userdb["discord_username"],
"discord_global_username" => $userdb["discord_global_username"],
"discord_email" => $userdb["discord_email"],
),
"profile" => array(
"avatar" => $userdb['avatar'],
"banner" => $userdb['banner'],
),
);
$conn->close();
http_response_code(200);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
} else {
$rsp = array(
"code" => 403,
"error" => "The server understood the request, but it refuses to authorize it.",
"message" => "We can't find this user in our database!"
);
http_response_code(403);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
} else {
$rsp = array(
"code" => 400,
"error" => "Bad request syntax",
"message" => "Email is required, but not provided."
);
http_response_code(400);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}

} catch (Exception $e) {
$rsp = array(
"code" => 500,
"error" => "The server encountered a situation it doesn't know how to handle.",
"message" => "We are sorry, but our server can't handle this request. Please do not try again!"
);
http_response_code(500);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
} else {
$rsp = array(
"code" => 405,
"error" => "A request was made of a page using a request method not supported by that page",
"message" => "Please use a get request"
);
http_response_code(405);
die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
?>
Loading

0 comments on commit 3e3909a

Please sign in to comment.