Fix: register maestro test player
This commit is contained in:
@@ -89,11 +89,6 @@
|
||||
function register(inputButton) {
|
||||
let id = $(inputButton).siblings(".maestro_id");
|
||||
let maestroID = id.text();
|
||||
// console.log(maestroID);
|
||||
|
||||
// let name = $(inputButton).siblings(".maestro_name");
|
||||
// let maestroName = name.val();
|
||||
// console.log(maestroName);
|
||||
|
||||
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
|
||||
"./../server/admin/register_maestro.php",
|
||||
|
||||
@@ -4,25 +4,94 @@ header("Content-Type: application/json");
|
||||
include "./../lib/send_reply_json.php";
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
$maestro_id = $_POST["maestro_id"];
|
||||
$maestroID = $_POST["maestro_id"];
|
||||
|
||||
|
||||
$query = "
|
||||
UPDATE moty_maestro
|
||||
SET ActivateStatus = 1, AvailableActivateDateTime = DATE_ADD(NOW(), INTERVAL 1 YEAR)
|
||||
WHERE MaestroID = ?
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("i", $maestro_id);
|
||||
$stmt->execute();
|
||||
|
||||
if($stmt->affected_rows <= 0) {
|
||||
$result = register_maestro($maestroID);
|
||||
if($result <= 0) {
|
||||
set_error_message("마에스트로 계정 활성화 실패");
|
||||
send_result_fail();
|
||||
exit;
|
||||
}
|
||||
|
||||
add_maestro_test_player($maestroID);
|
||||
|
||||
$playerID = get_maestro_test_player($maestroID);
|
||||
if($playerID === null) {
|
||||
set_error_message("마에스트로 테스트 플레이어 생성 실패");
|
||||
send_result_fail();
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = set_maestro_test_player($maestroID, $playerID);
|
||||
if($result === null || $result === 0) {
|
||||
set_error_message("마에스트로 테스트 플레이어 등록 실패");
|
||||
send_result_fail();
|
||||
exit;
|
||||
}
|
||||
|
||||
send_result_success();
|
||||
exit;
|
||||
|
||||
|
||||
function register_maestro($maestroID) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
UPDATE moty_maestro
|
||||
SET ActivateStatus = 1, AvailableActivateDateTime = DATE_ADD(NOW(), INTERVAL 1 YEAR)
|
||||
WHERE MaestroID = ?
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("i", $maestroID);
|
||||
$stmt->execute();
|
||||
|
||||
return $stmt->affected_rows;
|
||||
}
|
||||
|
||||
function add_maestro_test_player($maestroID) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
INSERT INTO moty_player (MaestroID, Name, EnterCode, AccountType)
|
||||
VALUES (?, 'Test', '', 1)
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("i", $maestroID);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
function get_maestro_test_player($maestroID) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT PlayerID
|
||||
FROM moty_player
|
||||
WHERE MaestroID = ? AND AccountType = 1
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("i", $maestroID);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($playerID);
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
|
||||
return $playerID;
|
||||
}
|
||||
|
||||
function set_maestro_test_player($maestroID, $playerID) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
UPDATE moty_maestro
|
||||
SET MaestroTestID = ?
|
||||
WHERE MaestroID = ?
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("ii", $playerID, $maestroID);
|
||||
$stmt->execute();
|
||||
|
||||
return $stmt->affected_rows;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -64,7 +64,7 @@ function addMaestro($maestro_name, $password, $email, $account_type) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
INSERT INTO moty_Maestro (Name, Password, Email, AccountType, ActivateStatus, UserCount, AcceptClausesDateTime, MaestroTestID)
|
||||
INSERT INTO moty_maestro (Name, Password, Email, AccountType, ActivateStatus, UserCount, AcceptClausesDateTime, MaestroTestID)
|
||||
VALUES (?, PASSWORD(?), ?, ?, 0, 0, NOW(), -1)";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("sssi", $maestro_name, $password, $email, $account_type);
|
||||
|
||||
Reference in New Issue
Block a user