MTGRandom/ajax/login.php
2026-07-29 19:51:07 -04:00

32 lines
887 B
PHP

<?php
require "../header.php";
define("FAILED", true);
$data = array();
$data["error"] = false;
$data["message"] = "";
function sendResponse($error = false, $message = "") {
global $data;
$data["error"] = $error;
if ( $error ) $data["message"] = $message;
header('Content-Type: application/json');
echo json_encode($data);
exit();
}
if ( $_SESSION["validated"] ) sendResponse(FAILED, "Already Logged In");
if ( !isset($_REQUEST["username"]) || !isset($_REQUEST["password"]) ) sendResponse(FAILED, "Invalid Request");
if ( array_key_exists($_REQUEST["username"], MGMTUSERS) && (MGMTUSERS[$_REQUEST["username"]] == $_REQUEST["password"]) ) {
//if ( ($_REQUEST["username"] == MGMTUSER) && ($_REQUEST["password"] == MGMTPASS) ) {
$_SESSION["validated"] = true;
$data["validated"] = true;
sendResponse();
} else {
sendResponse(FAILED, "Invalid Login");
}