Add: license maestro password, score list
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$maestro_id = $_POST["MaestroID"];
|
||||
// echo $maestro_id;
|
||||
|
||||
include "./../lib/send_reply_json.php";
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
|
||||
$default_password = "1111";
|
||||
|
||||
// get license_time data
|
||||
$password = get_maestro_password($maestro_id);
|
||||
if($password == null) {
|
||||
$password = $default_password;
|
||||
insert_maestro_password($maestro_id, $default_password);
|
||||
}
|
||||
|
||||
// send license_time data back to client
|
||||
set_data("maestroPassword", $password);
|
||||
send_result_success();
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
function get_maestro_password($maestro_id) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT Password
|
||||
FROM license_maestro_password
|
||||
WHERE MaestroID = ?
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("i", $maestro_id);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($password);
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
|
||||
return $password;
|
||||
}
|
||||
|
||||
function insert_maestro_password($maestro_id, $password) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
INSERT INTO license_maestro_password (MaestroID, Password)
|
||||
VALUES (?, ?);
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("ii", $maestro_id, $password);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$maestro_id = $_POST["MaestroID"];
|
||||
$player_id = $_POST["PlayerID"];
|
||||
// echo $maestro_id." / ".$player_id;
|
||||
|
||||
include "./../lib/send_reply_json.php";
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
// get license_time data
|
||||
$score_list = get_score_list($maestro_id, $player_id);
|
||||
|
||||
// send license_time data back to client
|
||||
set_data("scoreList", $score_list);
|
||||
send_result_success();
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
function get_score_list($maestro_id, $player_id) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT SubjectName, Score, ScoreDateTime
|
||||
FROM license_score
|
||||
WHERE MaestroID = ? AND PlayerID = ?
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param("ii", $maestro_id, $player_id);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($subject_name, $score, $score_date_time);
|
||||
|
||||
$score_list = array();
|
||||
while($stmt->fetch()) {
|
||||
$score_data["SubjectName"] = $subject_name;
|
||||
$score_data["Score"] = $score;
|
||||
$score_data["ScoreDateTime"] = $score_date_time;
|
||||
array_push($score_list, $score_data);
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
return $score_list;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$maestro_id = $_POST["MaestroID"];
|
||||
$password = $_POST["Password"];
|
||||
// echo $maestro_id."/".$password;
|
||||
|
||||
include "./../lib/send_reply_json.php";
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
|
||||
|
||||
update_maestro_password($maestro_id, $password);
|
||||
|
||||
send_result_success();
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
function update_maestro_password($maestro_id, $password) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
UPDATE license_maestro_password
|
||||
SET Password = ?
|
||||
WHERE MaestroID = ?
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('ii', $password, $maestro_id);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -20,4 +20,12 @@ CREATE TABLE license_score (
|
||||
|
||||
FOREIGN KEY (MaestroID) REFERENCES maestro(MaestroID),
|
||||
FOREIGN KEY (PlayerID) REFERENCES player(PlayerID)
|
||||
);
|
||||
|
||||
CREATE TABLE license_maestro_password (
|
||||
LicenseMaestroPasswordID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
MaestroID INT UNSIGNED NOT NULL,
|
||||
Password INT UNSIGNED NOT NULL,
|
||||
|
||||
FOREIGN KEY (MaestroID) REFERENCES maestro(MaestroID)
|
||||
);
|
||||
Reference in New Issue
Block a user