Add: sql - login, history_record
This commit is contained in:
@@ -22,13 +22,13 @@ const GAME_SCREEN_SIZE = { x: 1024, y: 768 }
|
||||
|
||||
let sessionStorageManager = new SessionStorageManager();
|
||||
{
|
||||
// if(isDebugMode()) {
|
||||
// sessionStorageManager.playerName = "박지상";
|
||||
// sessionStorageManager.playerUserID = 1;
|
||||
// sessionStorageManager.playingAppName = "space_invaders";
|
||||
// sessionStorageManager.score = 1000;
|
||||
// sessionStorageManager.highScore = 2000;
|
||||
// }
|
||||
if(isDebugMode()) {
|
||||
sessionStorageManager.playerName = "박지상";
|
||||
sessionStorageManager.playerUserID = 24;
|
||||
sessionStorageManager.playingAppName = "space_invaders";
|
||||
sessionStorageManager.score = 1000;
|
||||
sessionStorageManager.highScore = 2000;
|
||||
}
|
||||
|
||||
console.log("maestroID : " + sessionStorageManager.maestroID);
|
||||
console.log("playerName : " + sessionStorageManager.playerName);
|
||||
|
||||
@@ -18,30 +18,127 @@ class DBConnectManager {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
requestCheckUserLogin(userName, enterCode, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "../../web/server/user/login.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let jsonData = JSON.parse(xhr.responseText);
|
||||
|
||||
if(jsonData != null && jsonData["UserID"] != null)
|
||||
onSucceededListener(jsonData);
|
||||
else
|
||||
onFailedListener(jsonData);
|
||||
}
|
||||
};
|
||||
xhr.send("name=" + sessionStorageManager.playerName + "&enter_code=" + enterCode);
|
||||
}
|
||||
|
||||
requestPlayerHistory(listener) {
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
if(isDebugMode())
|
||||
/*
|
||||
if(isDebugMode()) {
|
||||
this.loadTempPlayerHistory(historyRecordManager);
|
||||
|
||||
if(listener === null)
|
||||
return;
|
||||
if(listener !== null)
|
||||
listener(historyRecordManager);
|
||||
|
||||
listener(historyRecordManager);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
let self = this;
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "../../web/server/record/history_record.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let jsonData = JSON.parse(xhr.responseText);
|
||||
|
||||
if(jsonData != null) {
|
||||
listener(self.parseJSONtoHistoryRecord(jsonData));
|
||||
}
|
||||
else
|
||||
onFailedListener(jsonData);
|
||||
}
|
||||
};
|
||||
xhr.send("UserID=" + sessionStorageManager.playerUserID + "&AppName=" + sessionStorageManager.playingAppName);
|
||||
}
|
||||
|
||||
parseJSONtoHistoryRecord(json) {
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
let count = json.history.length;
|
||||
for(let i = 0; i < count; i++) {
|
||||
let record = new HistoryRecord(
|
||||
json.history[i]["Date"],
|
||||
json.history[i]["AppName"],
|
||||
json.history[i]["HighScore"]
|
||||
);
|
||||
historyRecordManager.push(record);
|
||||
}
|
||||
|
||||
return historyRecordManager;
|
||||
|
||||
/*
|
||||
var startIndex = 0;
|
||||
var endIndex = jsonRankingList.length;
|
||||
|
||||
var recordArray = [];
|
||||
for(var i = startIndex; i < endIndex; i++) {
|
||||
var bestRecordRow = [];
|
||||
var strDate = jsonRankingList[i]['Date'];
|
||||
var dateArray = strDate.split("-");
|
||||
var recordDate = new Date(dateArray[0], dateArray[1], dateArray[2]);
|
||||
bestRecordRow[0] = recordDate.getMonth() + "월 " + recordDate.getDate() + "일";
|
||||
bestRecordRow[1] = Math.floor(jsonRankingList[i]['BestRecord']);
|
||||
bestRecordRow[2] = getStageNameForKorean(jsonRankingList[i]['StageName']);
|
||||
// console.log("$BestRecordRow : " + bestRecordRow[0] + ", " + bestRecordRow[1] + ", " + bestRecordRow[2]);
|
||||
|
||||
recordArray.push(bestRecordRow);
|
||||
}
|
||||
|
||||
return recordArray;
|
||||
*/
|
||||
}
|
||||
|
||||
requestRanking(type, listener) {
|
||||
let rankingRecordManager = new RankingRecordManager();
|
||||
|
||||
if(isDebugMode())
|
||||
this.loadTempRanking(rankingRecordManager);
|
||||
if(isDebugMode()) {
|
||||
this.loadTempPlayerHistory(historyRecordManager);
|
||||
|
||||
if(listener !== null)
|
||||
listener(historyRecordManager);
|
||||
|
||||
if(listener === null)
|
||||
return;
|
||||
|
||||
listener(rankingRecordManager);
|
||||
}
|
||||
}
|
||||
|
||||
onFailed(errorMessage) {
|
||||
console.log("failed : " + errorMessage);
|
||||
}
|
||||
|
||||
|
||||
makeXHRWithParam(url, param, onSucceededListener, onFailedListener) {
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let jsonData = JSON.parse(xhr.responseText);
|
||||
|
||||
if(jsonData != null && jsonData["UserID"] != null)
|
||||
onSucceededListener(jsonData);
|
||||
else
|
||||
onFailedListener(jsonData);
|
||||
}
|
||||
}
|
||||
|
||||
return xhr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
loadTempPlayerHistory(historyRecordManager) {
|
||||
historyRecordManager.push(new HistoryRecord("05/14", "space_invaders", 14460));
|
||||
|
||||
+14
-49
@@ -54,20 +54,20 @@ class Login {
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.boundsAlignH = 'right';
|
||||
|
||||
this.inputTextBirthday = new InputTypeText(inputX, birthdayTextY);
|
||||
this.inputTextBirthday.anchor.set(0.5);
|
||||
this.inputTextBirthday.canvasInput.value('');
|
||||
this.inputTextEnterCode = new InputTypeText(inputX, birthdayTextY);
|
||||
this.inputTextEnterCode.anchor.set(0.5);
|
||||
this.inputTextEnterCode.canvasInput.value('');
|
||||
if(isDebugMode()) {
|
||||
this.inputTextBirthday.canvasInput.value('760621');
|
||||
this.inputTextEnterCode.canvasInput.value('760621');
|
||||
}
|
||||
this.inputTextBirthday.canvasInput._onkeyup = function() {
|
||||
this.inputTextEnterCode.canvasInput._onkeyup = function() {
|
||||
if(event.keyCode == Phaser.Keyboard.ENTER) {
|
||||
self.startMenu();
|
||||
}
|
||||
}
|
||||
|
||||
this.inputTextName.canvasInput.focus();
|
||||
// this.inputTextBirthday.canvasInput.focus();
|
||||
// this.inputTextEnterCode.canvasInput.focus();
|
||||
}
|
||||
|
||||
makeButton() {
|
||||
@@ -80,50 +80,15 @@ class Login {
|
||||
|
||||
startMenu() {
|
||||
sessionStorageManager.playerName = self.inputTextName.canvasInput._value;
|
||||
let birthday = self.inputTextBirthday.canvasInput._value;
|
||||
let enterCode = self.inputTextEnterCode.canvasInput._value;
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function() {
|
||||
// console.log("onreadystatechange : " + xhr);
|
||||
// console.log("xhr.readyState : " + xhr.readyState);
|
||||
// console.log("xhr.status : " + xhr.status);
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
// console.log(xhr.responseText);
|
||||
let jsonData = JSON.parse(xhr.responseText);
|
||||
// console.log(JSON.stringify(jsonData));
|
||||
|
||||
// console.log(jsonData);
|
||||
if(jsonData != null && jsonData["UserID"] != null) {
|
||||
// login successed
|
||||
|
||||
self.loginSucceeded(jsonData);
|
||||
} else {
|
||||
// login failed
|
||||
self.loginFailed(jsonData);
|
||||
}
|
||||
}
|
||||
}
|
||||
xhr.open('POST', '../../web/client/php/check_user.php', true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
let param = 'name=' + sessionStorageManager.playerName + '&birthday=' + birthday;
|
||||
// console.log(param);
|
||||
xhr.send(param);
|
||||
|
||||
/*
|
||||
let params = {
|
||||
'name': this.inputTextName.canvasInput._value,
|
||||
'birthday': this.inputTextBirthday.canvasInput._value
|
||||
};
|
||||
console.log(params);
|
||||
console.log(JSON.stringify(params));
|
||||
|
||||
xhr.setRequestHeader("Content-type", "application/json");
|
||||
// let data = JSON.stringify({"name":"박지상","birthday":"760621","test":101});
|
||||
xhr.send(data);
|
||||
xhr.send(JSON.stringify(params));
|
||||
|
||||
// xhr.send(null);
|
||||
*/
|
||||
let dbConnectManager = new DBConnectManager();
|
||||
dbConnectManager.requestCheckUserLogin(
|
||||
sessionStorageManager.playerName,
|
||||
enterCode,
|
||||
self.loginSucceeded,
|
||||
self.loginFailed
|
||||
);
|
||||
}
|
||||
|
||||
loginSucceeded(jsonData) {
|
||||
|
||||
@@ -25,11 +25,11 @@ class Start {
|
||||
// contents
|
||||
this.printHowToPlay(appInfoManager.getHowToPlayText(sessionStorageManager.playingAppName));
|
||||
this.makeStartButton();
|
||||
this.printChartBaseLine();
|
||||
this.dbConnectManager.requestPlayerHistory( historyRecordManager => {
|
||||
this.printChartBaseLine();
|
||||
|
||||
let underValue = historyRecordManager.underValueForGraph();
|
||||
let upperValue = historyRecordManager.upperValueForGraph();
|
||||
|
||||
for(let i = 0; i < historyRecordManager.count; i++) {
|
||||
if(i > 6)
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>hello phaser!</title>
|
||||
<script src="//cdn.jsdelivr.net/phaser/2.5.0/phaser.min.js"></script>
|
||||
<script type="text/javascript" src="./../../../jquery/jquery-3.2.1.min.js"></script>
|
||||
|
||||
<script type="text/javascript" language="JavaScript">
|
||||
|
||||
function checkAll() {
|
||||
var chk = document.getElementsByName("active_stage[]");
|
||||
var cnt = chk.length;
|
||||
for(var i = 0; i < cnt; i++) {
|
||||
chk[i].checked = document.frm.chkAll.checked;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form name="frm" action="activate_stage.php" method="post">
|
||||
<input type="checkbox" name="chkAll" onClick="javascript:checkAll();" />전체 선택<br />
|
||||
|
||||
<br/><br/>
|
||||
<label type="label">한글</label><br/>
|
||||
<input type="checkbox" name="active_stage[]" value="korean_basic" />기본자리<br />
|
||||
<input type="checkbox" name="active_stage[]" value="korean_left_upper" />왼손 윗글쇠<br />
|
||||
<input type="checkbox" name="active_stage[]" value="korean_second_finger" />검지 글쇠<br />
|
||||
<input type="checkbox" name="active_stage[]" value="korean_right_upper" />오른손 윗글쇠<br />
|
||||
<input type="checkbox" name="active_stage[]" value="korean_left_lower" />왼손 밑글쇠<br />
|
||||
<input type="checkbox" name="active_stage[]" value="korean_right_lower" />오른손 밑글쇠<br />
|
||||
<input type="checkbox" name="active_stage[]" value="korean_left_upper_double" />쌍자음<br />
|
||||
<input type="checkbox" name="active_stage[]" value="korean_right_upper_double" />쌍모음<br />
|
||||
<input type="checkbox" name="active_stage[]" value="korean_word" />짧은 글<br />
|
||||
<input type="checkbox" name="active_stage[]" value="korean_sentence" />긴 글<br />
|
||||
|
||||
<br/><br/>
|
||||
<label type="label">영문</label><br/>
|
||||
<input type="checkbox" name="active_stage[]" value="english_basic" />기본자리<br />
|
||||
<input type="checkbox" name="active_stage[]" value="english_left_upper" />왼손 윗글쇠<br />
|
||||
<input type="checkbox" name="active_stage[]" value="english_second_finger" />검지 글쇠<br />
|
||||
<input type="checkbox" name="active_stage[]" value="english_right_upper" />오른손 윗글쇠<br />
|
||||
<input type="checkbox" name="active_stage[]" value="english_left_lower" />왼손 밑글쇠<br />
|
||||
<input type="checkbox" name="active_stage[]" value="english_right_lower" />오른손 밑글쇠<br />
|
||||
<input type="checkbox" name="active_stage[]" value="english_word" />짧은 글<br />
|
||||
<input type="checkbox" name="active_stage[]" value="english_sentence" />긴 글<br />
|
||||
|
||||
<br/><br/>
|
||||
<input type="button" value="업데이트" onClick="document.frm.submit();" />
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// header('Content-Type: application/json');
|
||||
|
||||
include "send_error_code.php";
|
||||
|
||||
$active_stage_list = $_POST['active_stage'];
|
||||
$cnt = count($active_stage_list);
|
||||
|
||||
include "./connect_db.php";
|
||||
|
||||
$query = "UPDATE afterschool_activated_stage SET Activated = 0";
|
||||
$result = $db_conn->query($query);
|
||||
|
||||
for($i = 0; $i < $cnt; $i++) {
|
||||
$array_item = $active_stage_list[$i];
|
||||
|
||||
$query = "UPDATE afterschool_activated_stage SET Activated = 1 WHERE StageName = ?";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('s', $array_item);
|
||||
$stmt->execute();
|
||||
|
||||
if($stmt->affected_rows > 0) {
|
||||
echo($array_item." : activated<br/>");
|
||||
} else {
|
||||
echo $array_item." : db error<br/>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,23 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>hello phaser!</title>
|
||||
<script src="//cdn.jsdelivr.net/phaser/2.5.0/phaser.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form name="add_user" method="post" action="add_user.php">
|
||||
이름 : <input type="text" name="name" /><br />
|
||||
생년월일 : <input type="text" name="birthday" /><br />
|
||||
<input type="submit" value="추가">
|
||||
</form>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<form name="delete_test_user_data" method="get" action="delete_test_user_data.php">
|
||||
<input type="submit" value="test 유저 데이터 삭제">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
// header('Content-Type: application/json');
|
||||
|
||||
$name = $_POST["name"];
|
||||
|
||||
$birthday = $_POST["birthday"];
|
||||
if(!is_numeric($birthday)) {
|
||||
echo '생년월일이 숫자가 아닙니다.';
|
||||
return;
|
||||
} else if(strlen($birthday) != 6) {
|
||||
echo '6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131)';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
include "./connect_db.php";
|
||||
|
||||
$query = "INSERT INTO afterschool_user(UserID, Name, Birthday) values (null,?,?)";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('ss', $name, $birthday);
|
||||
$stmt->execute();
|
||||
|
||||
if($stmt->affected_rows > 0) {
|
||||
echo("succeed");
|
||||
} else {
|
||||
echo "fail";
|
||||
}
|
||||
|
||||
$db_conn->close();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
// header('Content-Type: application/json');
|
||||
|
||||
include "./connect_db.php";
|
||||
|
||||
$query = "DELETE FROM afterschool_record WHERE UserID=31;";
|
||||
$result = $db_conn->query($query);
|
||||
|
||||
$db_conn->close();
|
||||
|
||||
?>
|
||||
@@ -18,6 +18,7 @@
|
||||
<script src="../../game/lib/input_type_text.js"></script>
|
||||
<script src="../../game/lib/round_rect_button.js"></script>
|
||||
<script src="../../game/lib/fullscreen_button.js"></script>
|
||||
<script src="../../game/lib/db_connect_manager.js"></script>
|
||||
|
||||
<!-- source files -->
|
||||
<script src="../../game/login/login.js"></script>
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
$db_host = "localhost";
|
||||
$db_user = "afterschool";
|
||||
$db_passwd = "sEobMPuJ2A8KTfwU";
|
||||
$db_name = "jisangs";
|
||||
|
||||
$db_conn = new mysqli($db_host, $db_user, $db_passwd, $db_name);
|
||||
|
||||
if ($db_conn->connect_error) {
|
||||
send_error_code("Connection failed: ".$db_conn->connect_error);
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$db_host = "localhost";
|
||||
$db_user = "jisangs";
|
||||
$db_passwd = "Fr12nds95";
|
||||
$db_name = "jisangs";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "send_error_code.php";
|
||||
|
||||
include "connect_db.php";
|
||||
|
||||
$return_array = array();
|
||||
|
||||
$query = "SELECT * FROM afterschool_activated_stage";
|
||||
$result = mysqli_query($db_conn, $query);
|
||||
|
||||
$return_array = array();
|
||||
|
||||
if ( $result ) {
|
||||
// echo "조회된 행의 수 : ".mysqli_num_rows($result)."<br />";
|
||||
|
||||
if($result) {
|
||||
$rows = array();
|
||||
while($row = mysqli_fetch_assoc($result)) {
|
||||
// $row_array['Language'] = $row['Language'];
|
||||
$row_array['StageName'] = $row['StageName'];
|
||||
$row_array['Activated'] = $row['Activated'];
|
||||
array_push($return_array, $row_array);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
send_error_code("Error : ".mysqli_error($db_conn));
|
||||
}
|
||||
|
||||
echo json_encode($return_array, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
// 결과 해제
|
||||
mysqli_free_result($result);
|
||||
|
||||
$db_conn->close();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "./../send_error_code.php";
|
||||
|
||||
$user_id = $_POST["UserID"];
|
||||
$app_name = $_POST["AppName"];
|
||||
|
||||
include "./../connect_db.php";
|
||||
|
||||
|
||||
// my ranking
|
||||
$query = "
|
||||
SELECT DATE(DateTime) AS Date, MAX(Score) AS HighScore, AppName AS AppName
|
||||
FROM moty_record D
|
||||
WHERE UserID = ?
|
||||
GROUP BY DATE(DateTime)
|
||||
ORDER BY DateTime ASC
|
||||
LIMIT 7;
|
||||
";
|
||||
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('s', $user_id);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt->bind_result($date, $score, $app_name);
|
||||
|
||||
$bestRecordArray = array();
|
||||
while($stmt->fetch()) {
|
||||
$best_record['Date'] = $date;
|
||||
$best_record['HighScore'] = $score;
|
||||
$best_record['AppName'] = $app_name;
|
||||
array_push($bestRecordArray, $best_record);
|
||||
array_push($return_array, $best_record);
|
||||
}
|
||||
$return_array['history'] = $bestRecordArray;
|
||||
|
||||
echo json_encode($return_array, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$db_conn->close();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "send_error_code.php";
|
||||
|
||||
$user_id = $_POST["UserID"];
|
||||
$language = $_POST["language"];
|
||||
$stageName = $_POST["stageName"];
|
||||
$record = $_POST["Record"];
|
||||
$stage_name = $language."_".$stageName;
|
||||
// $user_id = $_GET["UserID"];
|
||||
// $language = $_GET["language"];
|
||||
// $stageName = $_GET["stageName"];
|
||||
// $best_record = $_GET["BestRecord"];
|
||||
// $typing_stage = $language."_".$stageName;
|
||||
|
||||
// echo $user_id."\n";
|
||||
// echo $typingStage."\n";
|
||||
|
||||
include "connect_db.php";
|
||||
|
||||
$query = "
|
||||
INSERT INTO afterschool_record (UserID, Record, RecordDateTime, StageName)
|
||||
VALUES (?, ?, NOW(), ?);
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('ids', $user_id, $record, $stage_name);
|
||||
$stmt->execute();
|
||||
|
||||
$db_conn->close();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "send_error_code.php";
|
||||
|
||||
$user_id = $_POST["UserID"];
|
||||
$language = $_POST["language"];
|
||||
$stageNameDetail = $_POST["stageName"];
|
||||
$stageName = $language."_".$stageNameDetail;
|
||||
|
||||
include "connect_db.php";
|
||||
|
||||
|
||||
// my ranking
|
||||
$query = "
|
||||
SELECT DATE(RecordDateTime) AS Date, MAX(Record) AS BestRecord, StageName AS StageName
|
||||
FROM afterschool_record D
|
||||
WHERE UserID = ?
|
||||
GROUP BY DATE(RecordDateTime)
|
||||
ORDER BY RecordDateTime DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('s', $user_id);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt->bind_result($date, $record, $stage_name);
|
||||
|
||||
$bestRecordArray = array();
|
||||
while($stmt->fetch()) {
|
||||
$best_record['Date'] = $date;
|
||||
$best_record['BestRecord'] = $record;
|
||||
$best_record['StageName'] = $stage_name;
|
||||
array_push($bestRecordArray, $best_record);
|
||||
array_push($return_array, $best_record);
|
||||
}
|
||||
$return_array['myRanking'] = $bestRecordArray;
|
||||
|
||||
|
||||
// ranking hour
|
||||
$query = "
|
||||
SELECT D.userID As UserID, U.Name AS Name, MAX(D.record) AS BestRecord
|
||||
FROM afterschool_record D, afterschool_user U
|
||||
WHERE D.userID = U.userID AND DATE(D.RecordDateTime) = DATE(NOW()) AND HOUR(D.RecordDateTime) = HOUR(NOW()) AND StageName = ?
|
||||
GROUP BY D.userID
|
||||
ORDER BY max(D.Record) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('s', $stageName);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt->bind_result($userID, $name, $record);
|
||||
|
||||
$bestRecordArray = array();
|
||||
while($stmt->fetch()) {
|
||||
$best_record['UserID'] = $userID;
|
||||
$best_record['Name'] = $name;
|
||||
$best_record['BestRecord'] = $record;
|
||||
array_push($bestRecordArray, $best_record);
|
||||
// array_push($return_array, $best_record);
|
||||
}
|
||||
$return_array['rankingHour'] = $bestRecordArray;
|
||||
|
||||
|
||||
// ranking day
|
||||
$query = "
|
||||
SELECT D.userID As UserID, U.Name AS Name, MAX(D.record) AS BestRecord
|
||||
FROM afterschool_record D, afterschool_user U
|
||||
WHERE D.userID = U.userID AND DATE(D.RecordDateTime) = DATE(NOW()) AND StageName = ?
|
||||
GROUP BY D.userID
|
||||
ORDER BY max(D.Record) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('s', $stageName);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt->bind_result($userID, $name, $record);
|
||||
|
||||
$bestRecordArray = array();
|
||||
while($stmt->fetch()) {
|
||||
$best_record['UserID'] = $userID;
|
||||
$best_record['Name'] = $name;
|
||||
$best_record['BestRecord'] = $record;
|
||||
array_push($bestRecordArray, $best_record);
|
||||
// array_push($return_array, $best_record);
|
||||
}
|
||||
$return_array['rankingDay'] = $bestRecordArray;
|
||||
|
||||
|
||||
// ranking month
|
||||
$query = "
|
||||
SELECT D.userID As UserID, U.Name AS Name, MAX(D.record) AS BestRecord
|
||||
FROM afterschool_record D, afterschool_user U
|
||||
WHERE D.userID = U.userID AND MONTH(D.RecordDateTime) = MONTH(NOW()) AND StageName = ?
|
||||
GROUP BY D.userID
|
||||
ORDER BY max(D.Record) DESC;
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('s', $stageName);
|
||||
$stmt->execute();
|
||||
|
||||
$stmt->bind_result($userID, $name, $record);
|
||||
|
||||
$bestRecordArray = array();
|
||||
while($stmt->fetch()) {
|
||||
$best_record['UserID'] = $userID;
|
||||
$best_record['Name'] = $name;
|
||||
$best_record['BestRecord'] = $record;
|
||||
array_push($bestRecordArray, $best_record);
|
||||
// array_push($return_array, $best_record);
|
||||
}
|
||||
$return_array['rankingMonth'] = $bestRecordArray;
|
||||
|
||||
echo json_encode($return_array, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
|
||||
$db_conn->close();
|
||||
|
||||
?>
|
||||
@@ -1,25 +1,27 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include "send_error_code.php";
|
||||
include "./../send_error_code.php";
|
||||
|
||||
$name = $_POST["name"];
|
||||
$birthday = $_POST["birthday"];
|
||||
if(!is_numeric($birthday)) {
|
||||
send_error_code('생년월일이 숫자가 아닙니다. : '.$birthday);
|
||||
$enterCode = $_POST["enter_code"];
|
||||
/*
|
||||
if(!is_numeric($enterCode)) {
|
||||
send_error_code('생년월일이 숫자가 아닙니다. : '.$enterCode);
|
||||
exit;
|
||||
} else if(strlen($birthday) != 6) {
|
||||
send_error_code('6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : '.$birthday);
|
||||
} else if(strlen($enterCode) != 6) {
|
||||
send_error_code('6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : '.$enterCode);
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
|
||||
include "connect_db.php";
|
||||
include "./../connect_db.php";
|
||||
|
||||
$return_array = array();
|
||||
|
||||
$query = "SELECT UserID FROM afterschool_user WHERE Name=? AND Birthday=?";
|
||||
$query = "SELECT UserID FROM moty_user WHERE Name=? AND enterCode=?";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('ss', $name, $birthday);
|
||||
$stmt->bind_param('ss', $name, $enterCode);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($user_id);
|
||||
// while($stmt->fetch())
|
||||
Reference in New Issue
Block a user