Add: session storage manager - maestroAccountType, playerAccountType

This commit is contained in:
2018-08-10 14:57:58 +09:00
parent ade28a3334
commit d97dbaa20f
9 changed files with 83 additions and 47 deletions
+22 -13
View File
@@ -9,23 +9,31 @@ $name = $_POST["name"];
$enterCode = $_POST["enter_code"];
$maestroID = get_maestro_id($maestroName);
if($maestroID === null) {
$maestroInfo = get_maestro_id($maestroName);
if($maestroInfo === null) {
send_error_message($replyJSON, "입력한 마에스트로 계정이 없습니다");
$db_conn->close();
exit;
}
$playerID = get_login_data($maestroID, $name, $enterCode);
if($playerID === null) {
$maestroID = $maestroInfo["maestroID"];
$maestroAccountType = $maestroInfo["accountType"];
$playerInfo = get_login_data($maestroID, $name, $enterCode);
if($playerInfo === null) {
send_error_message($replyJSON, "입력한 이름/입장번호와 일치하는 계정이 없습니다");
$db_conn->close();
exit;
}
$playerID = $playerInfo["playerID"];
$playerAccountType = $playerInfo["accountType"];
set_data("MaestroID", $maestroID);
set_data("MaestroAccountType", $maestroAccountType);
set_data("PlayerID", $playerID);
set_data("PlayerAccountType", $playerAccountType);
send_result_success();
exit;
@@ -34,43 +42,44 @@ function get_maestro_id($maestroName) {
global $db_conn;
$query = "
SELECT MaestroID
SELECT MaestroID, AccountType
FROM moty_maestro
WHERE Name = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('s', $maestroName);
$stmt->execute();
$stmt->bind_result($maestroID);
$stmt->bind_result($maestroID, $accountType);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
return $maestroID;
$result["maestroID"] = $maestroID;
$result["accountType"] = $accountType;
return $result;
}
function get_login_data($maestroID, $name, $enterCode) {
global $db_conn;
$query = "
SELECT PlayerID
SELECT PlayerID, AccountType
FROM moty_player
WHERE MaestroID = ? AND Name = ? AND EnterCode = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iss', $maestroID, $name, $enterCode);
$stmt->execute();
$stmt->bind_result($playerID);
$stmt->bind_result($playerID, $accountType);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
// $replyJSON["MaestroID"] = $maestroID;
// $replyJSON["PlayerID"] = $playerID;
return $playerID;
$result["playerID"] = $playerID;
$result["accountType"] = $accountType;
return $result;
}
?>