From 542afc69d90f75fa2660117a65226ad8607f2525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Tue, 30 Oct 2018 12:27:55 +0900 Subject: [PATCH] Add: maestro log DB --- src/web/server/admin/register_maestro.php | 2 + src/web/server/admin/upgrade_maestro.php | 2 + src/web/server/lib/maestro_log.php | 72 +++++++++++++++++++ src/web/server/maestro/add_maestro.php | 2 + .../server/maestro/update_maestro_info.php | 12 +++- src/web/sql/make_db.sql | 8 +++ 6 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 src/web/server/lib/maestro_log.php diff --git a/src/web/server/admin/register_maestro.php b/src/web/server/admin/register_maestro.php index 9f1d191..f85440a 100644 --- a/src/web/server/admin/register_maestro.php +++ b/src/web/server/admin/register_maestro.php @@ -5,6 +5,7 @@ include "./../lib/send_reply_json.php"; include "./../setup/connect_db.php"; include "./../lib/maestro_account_info.php"; include "./../lib/db_maestro.php"; +include "./../lib/maestro_log.php"; include "./../mail/mail_setting.php"; include "./../mail/send_mail.php"; @@ -41,6 +42,7 @@ update_count_registered_player($maestroID, $count); $maestro_data = get_maestro_data($maestroID); sendMailRegisterDone($maestro_data["name"], $maestro_data["email"]); +insertMaestroLog("register_maestro", $maestroID, $maestro_data["name"]." / ".$maestro_data["email"]); send_result_success(); exit; diff --git a/src/web/server/admin/upgrade_maestro.php b/src/web/server/admin/upgrade_maestro.php index c2e32f2..1939ede 100644 --- a/src/web/server/admin/upgrade_maestro.php +++ b/src/web/server/admin/upgrade_maestro.php @@ -4,6 +4,7 @@ header("Content-Type: application/json"); include "./../setup/connect_db.php"; include "./../lib/send_reply_json.php"; include "./../lib/db_maestro.php"; +include "./../lib/maestro_log.php"; include "./../lib/maestro_account_info.php"; include "./../mail/mail_setting.php"; include "./../mail/send_mail.php"; @@ -20,6 +21,7 @@ change_upgrade_request_status_to_applied($maestro_upgrade_id); $maestro_data = get_maestro_data($maestro_id); sendMailUpgradeDone($maestro_data["name"], $maestro_data["email"], $registered_account_type, $upgrade_account_type); +insertMaestroLog("upgrade_maestro", $maestro_id, $registered_account_type." -> ".$upgrade_account_type); // set_data("maestro_upgrade_id", $maestro_upgrade_id); // set_data("maestro_id", $maestro_id); diff --git a/src/web/server/lib/maestro_log.php b/src/web/server/lib/maestro_log.php new file mode 100644 index 0000000..7bed7bd --- /dev/null +++ b/src/web/server/lib/maestro_log.php @@ -0,0 +1,72 @@ +prepare($query); + $stmt->bind_param('sis', $type, $maestro_id, $remark); + $stmt->execute(); + + // echo "\ninsertMaestroLog"; +} + + +/* +function get_app_highest_record($maestro_id, $app_id, $player_id) { + global $db_conn; + + $query = " + SELECT HighestRecord + FROM app_highest_record + WHERE MaestroID = ? AND AppID = ? AND PlayerID = ?; + "; + $stmt = $db_conn->prepare($query); + $stmt->bind_param("iii", $maestro_id, $app_id, $player_id); + $stmt->execute(); + $stmt->bind_result($app_highest_record); + $stmt->fetch(); + $stmt->close(); + + return $app_highest_record; + + // echo "\nget_app_highest_record : $app_highest_record"; +} + + +function remove_app_highest_record($maestro_id, $app_id, $player_id) { + global $db_conn; + + $query = " + DELETE FROM app_highest_record + WHERE MaestroID = ? AND AppID = ? AND PlayerID = ?; + "; + $stmt = $db_conn->prepare($query); + $stmt->bind_param("iii", $maestro_id, $app_id, $player_id); + $stmt->execute(); + + // echo "\ndelete_app_highest_record"; +} + +function insert_app_highest_record($maestro_id, $app_id, $player_id, $app_highest_record) { + global $db_conn; + + $query = " + INSERT INTO app_highest_record (MaestroID, PlayerID, AppID, HighestRecord, RecordDateTime) + VALUES (?, ?, ?, ?, NOW()); + "; + $stmt = $db_conn->prepare($query); + $stmt->bind_param('iiid', $maestro_id, $player_id, $app_id, $app_highest_record); + $stmt->execute(); + + // echo "\ninsert_app_highest_record"; +} +*/ + +?> \ No newline at end of file diff --git a/src/web/server/maestro/add_maestro.php b/src/web/server/maestro/add_maestro.php index 514bdbd..5d00536 100644 --- a/src/web/server/maestro/add_maestro.php +++ b/src/web/server/maestro/add_maestro.php @@ -5,6 +5,7 @@ include "./../setup/connect_db.php"; include "./../lib/send_reply_json.php"; include "./../lib/maestro_account_info.php"; include "./../lib/db_maestro.php"; +include "./../lib/maestro_log.php"; include "./../mail/mail_setting.php"; include "./../mail/send_mail.php"; @@ -32,6 +33,7 @@ if($maestroID === null) { } sendMailRegisterBankInfo($maestro_name, $email, $account_type); +insertMaestroLog("add_maestro", $maestroID, $maestro_name." / ".$email." / ".$account_type); send_result_success(); exit; diff --git a/src/web/server/maestro/update_maestro_info.php b/src/web/server/maestro/update_maestro_info.php index a81d641..b102622 100644 --- a/src/web/server/maestro/update_maestro_info.php +++ b/src/web/server/maestro/update_maestro_info.php @@ -5,6 +5,7 @@ include "./../lib/send_reply_json.php"; include "./../setup/connect_db.php"; include "./../lib/maestro_account_info.php"; include "./../lib/db_maestro.php"; +include "./../lib/maestro_log.php"; include "./../mail/mail_setting.php"; include "./../mail/send_mail.php"; @@ -25,11 +26,16 @@ $email_prev = $info["email"]; update_maestro_info($maestroID, $maestroName, $email); -if($maestroName != $maestro_name_prev) - sendMailUpdateMaestroName($maestroName, $maestro_name_prev, $email); -if($email != $email_prev) +if($maestroName != $maestro_name_prev) { + sendMailUpdateMaestroName($maestroName, $maestro_name_prev, $email); + insertMaestroLog("update_maestro_name", $maestroID, $maestro_name_prev." -> ".$maestroName); +} + +if($email != $email_prev) { sendMailUpdateMaestroEmail($maestroName, $email, $email_prev); + insertMaestroLog("update_maestro_email", $maestroID, $email_prev." -> ".$email); +} send_result_success(); exit; diff --git a/src/web/sql/make_db.sql b/src/web/sql/make_db.sql index 55d4326..2e19f56 100644 --- a/src/web/sql/make_db.sql +++ b/src/web/sql/make_db.sql @@ -106,3 +106,11 @@ CREATE TABLE banned_word ( BannedWordID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, Word CHAR(50) NOT NULL ); + +CREATE TABLE maestro_log ( + MaestroLogID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + Type CHAR(50) NOT NULL, + LogDateTime DATETIME NOT NULL, + MaestroID INT UNSIGNED NOT NULL, + Remark CHAR(100) NOT NULL +);