Add: maestro test account, player for experience mode

This commit is contained in:
2018-07-08 22:46:39 +09:00
parent 785575a1e1
commit b34e62c4ea
6 changed files with 337 additions and 8 deletions
+1 -1
View File
@@ -33,7 +33,7 @@
<ul class="header_menu"> <ul class="header_menu">
<li> <li>
<span class="col"> <span class="col">
<a href="#" target="_blank" id="login_player" class="btn btn-rouge">학생 앱<br/>실행</a> <a href="./../client/login.html" target="_blank" id="login_player" class="btn btn-rouge">학생 앱<br/>실행</a>
</span> </span>
</li> </li>
<li> <li>
+54 -4
View File
@@ -14,10 +14,60 @@
<script> <script>
function experienceMaestro() { function loadMaestroTestAccountInfo() {
maestroID = 0; let xhr = new XMLHttpRequest(); //new로 생성.
sessionStorage.setItem("maestroID", maestroID); xhr.open('POST', './../server/maestro/maestro_test_account.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send();
xhr.onload = function() {
if(xhr.readyState === 4 && xhr.status === 200) {
// console.log(xhr.responseText);
// console.log(xhr.responseText.length);
if(xhr.responseText.length === 0 || xhr.responseText === null) {
console.log("no data from server");
return;
}
let replyJSON = JSON.parse(xhr.responseText);
// console.log(replyJSON);
if(replyJSON === null) {
console.log("no data from server");
return;
}
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
console.log(replyJSON["ERROR"]);
return;
}
if(replyJSON["RESULT"] === "fail") {
console.log(replyJSON["RESULT"]);
return;
}
let maestroID = replyJSON["maestroID"];
let playerID = replyJSON["playerID"];
let playerName = replyJSON["playerName"];
console.log("maestroID : " + maestroID);
console.log("playerID : " + playerID);
console.log("playerName : " + playerName);
sessionStorage.setItem("maestroID", maestroID);
sessionStorage.setItem("playerID", playerID);
sessionStorage.setItem("playerName", playerName);
}
}
}
function playFree() {
loadMaestroTestAccountInfo();
window.open("./../client/menu_app.html", "_blank");
}
function experienceMaestro() {
loadMaestroTestAccountInfo();
location.href = "./../maestro/main_menu.html"; location.href = "./../maestro/main_menu.html";
} }
@@ -28,7 +78,7 @@ function experienceMaestro() {
<div class="container"> <div class="container">
<div class="player_free"> <div class="player_free">
<div class="col alignCenter"> <div class="col alignCenter">
<a href="./../client/menu_app.html" target="_blank" id="player_free_play" class="btn btn-rouge width400">학생 연습 앱<br/>무료 체험</a> <a id="player_free_play" class="btn btn-rouge width400" onClick="playFree()" >학생 연습 앱<br/>무료 체험</a>
</div> </div>
<ul id="free_app_list"> <ul id="free_app_list">
+62 -3
View File
@@ -23,8 +23,67 @@
<script type="text/javascript"> <script type="text/javascript">
function runMaestroAccountApp() {
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/maestro/maestro_test_player.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_id=" + maestroID);
xhr.onload = function() {
if(xhr.readyState === 4 && xhr.status === 200) {
// console.log(xhr.responseText);
// console.log(xhr.responseText.length);
if(xhr.responseText.length === 0 || xhr.responseText === null) {
console.log("no data from server");
return;
}
let replyJSON = JSON.parse(xhr.responseText);
// console.log(replyJSON);
if(replyJSON === null) {
console.log("no data from server");
return;
}
if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) {
console.log(replyJSON["ERROR"]);
return;
}
if(replyJSON["RESULT"] === "fail") {
console.log(replyJSON["RESULT"]);
return;
}
let playerID = replyJSON["PlayerID"];
let playerName = replyJSON["PlayerName"];
console.log("playerID : " + playerID);
console.log("playerName : " + playerName);
sessionStorage.setItem("playerID", playerID);
sessionStorage.setItem("playerName", playerName);
}
}
}
function deleteMaestroAllRecords() { function deleteMaestroAllRecords() {
alert("마에스트로 전용 계정의 모든 플레이 기록이 지워집니다.\n예) 게임 기록, 타자 타수, 순위 등"); // alert("마에스트로 전용 계정의 모든 플레이 기록이 지워집니다.\n예) 게임 기록, 타자 타수, 순위 등");
if(confirm("마에스트로 전용 계정의 모든 플레이 기록이 지워집니다.\n예) 게임 기록, 타자 타수, 순위 등")) {
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/maestro/delete_test_player_record.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_id=" + maestroID);
xhr.onload = function() {
if(xhr.readyState === 4 && xhr.status === 200) {
let replyJSON = JSON.parse(xhr.responseText);
// console.log(replyJSON);
}
}
alert("마에스트로 전용 계정의 모든 플레이 기록이 지워졌습니다.");
} else {
}
} }
</script> </script>
@@ -43,12 +102,12 @@ function deleteMaestroAllRecords() {
<ul class="header_menu"> <ul class="header_menu">
<li> <li>
<span class="col"> <span class="col">
<a href="./../client/menu_app.html" target="_blank" id="delete_test_player_history" class="btn btn-rouge">마에스트로 앱<br/>실행</a> <a href="./../client/menu_app.html" target="_blank" class="btn btn-rouge" onClick="runMaestroAccountApp()">마에스트로 앱<br/>실행</a>
</span> </span>
</li> </li>
<li> <li>
<span class="col"> <span class="col">
<a id="enter_test_player" class="btn btn-sea" onClick="deleteMaestroAllRecords()">마에스트로 앱<br/>모든 기록 삭제</a> <a id="enter_test_player" class="btn btn-sea" id="delete_test_player_history" onClick="deleteMaestroAllRecords()">마에스트로 앱<br/>모든 기록 삭제</a>
</span> </span>
</li> </li>
<li> <li>
@@ -0,0 +1,57 @@
<?php
header('Content-Type: application/json');
$maestro_id = $_POST["maestro_id"];
include "./../setup/connect_db.php";
$maestro_test_player_id = get_maestro_test_player_id($maestro_id);
if($maestro_test_player_id === null) {
$replyJSON["ERROR"] = "등록된 마에스트로 테스트 계정이 없습니다";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
exit;
}
delete_maestro_test_player_record($maestro_test_player_id);
$replyJSON["PlayerID"] = $maestro_test_player_id;
$replyJSON["RESULT"] = "ok";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
exit;
function get_maestro_test_player_id($maestro_id) {
global $db_conn;
$query = "SELECT MaestroTestID FROM moty_maestro WHERE MaestroID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('i', $maestro_id);
$stmt->execute();
$stmt->bind_result($maestro_test_player_id);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
return $maestro_test_player_id;
}
function delete_maestro_test_player_record($player_id) {
global $db_conn;
$query = "DELETE FROM moty_best_record WHERE PlayerID=?;";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('i', $player_id);
$stmt->execute();
// $stmt->bind_result($maestro_test_player_id);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
}
?>
@@ -0,0 +1,94 @@
<?php
header('Content-Type: application/json');
/*
if(!is_numeric($enterCode)) {
send_error_code('생년월일이 숫자가 아닙니다. : '.$enterCode);
exit;
} else if(strlen($enterCode) != 6) {
send_error_code('6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : '.$enterCode);
exit;
}
*/
include "./../setup/connect_db.php";
$maestro_test_account_id = get_maestro_test_account_id("test");
if($maestro_test_account_id === null) {
$replyJSON["ERROR"] = "등록된 마에스트로 관리자 계정이 없습니다. (".$maestro_test_account_id.")";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
exit;
}
$maestro_test_player_id = get_maestro_test_player_id($maestro_test_account_id);
if($maestro_test_player_id === null) {
$replyJSON["ERROR"] = "등록된 마에스트로 테스트 계정이 없습니다. (".$maestro_test_player_id.")";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
exit;
}
$maestro_test_player_name = get_maestro_test_player_name($maestro_test_player_id);
$replyJSON["maestroID"] = $maestro_test_account_id;
$replyJSON["playerID"] = $maestro_test_player_id;
$replyJSON["playerName"] = $maestro_test_player_name;
$replyJSON["RESULT"] = "ok";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
exit;
function get_maestro_test_account_id($maestro_name) {
global $db_conn;
$query = "SELECT MaestroID FROM moty_maestro WHERE Name=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('s', $maestro_name);
$stmt->execute();
$stmt->bind_result($maestro_test_account_id);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
return $maestro_test_account_id;
}
function get_maestro_test_player_id($maestro_id) {
global $db_conn;
$query = "SELECT MaestroTestID FROM moty_maestro WHERE MaestroID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('i', $maestro_id);
$stmt->execute();
$stmt->bind_result($maestro_test_player_id);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
return $maestro_test_player_id;
}
function get_maestro_test_player_name($player_id) {
global $db_conn;
$query = "SELECT Name FROM moty_player WHERE PlayerID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('i', $player_id);
$stmt->execute();
$stmt->bind_result($maestro_test_player_name);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
return $maestro_test_player_name;
}
?>
@@ -0,0 +1,69 @@
<?php
header('Content-Type: application/json');
$maestro_id = $_POST["maestro_id"];
/*
if(!is_numeric($enterCode)) {
send_error_code('생년월일이 숫자가 아닙니다. : '.$enterCode);
exit;
} else if(strlen($enterCode) != 6) {
send_error_code('6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : '.$enterCode);
exit;
}
*/
include "./../setup/connect_db.php";
$maestro_test_player_id = get_maestro_test_player_id($maestro_id);
if($maestro_test_player_id === null) {
$replyJSON["ERROR"] = "등록된 마에스트로 테스트 계정이 없습니다";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
exit;
}
$maestro_test_player_name = get_maestro_test_player_name($maestro_test_player_id);
$replyJSON["PlayerID"] = $maestro_test_player_id;
$replyJSON["PlayerName"] = $maestro_test_player_name;
$replyJSON["RESULT"] = "ok";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
exit;
function get_maestro_test_player_id($maestro_id) {
global $db_conn;
$query = "SELECT MaestroTestID FROM moty_maestro WHERE MaestroID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('i', $maestro_id);
$stmt->execute();
$stmt->bind_result($maestro_test_player_id);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
return $maestro_test_player_id;
}
function get_maestro_test_player_name($player_id) {
global $db_conn;
$query = "SELECT Name FROM moty_player WHERE PlayerID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('i', $player_id);
$stmt->execute();
$stmt->bind_result($maestro_test_player_name);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
return $maestro_test_player_name;
}
?>