From 90c8ffa3a62fb2f282c0cb291bcd8acac8ca19ad 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: Mon, 29 Oct 2018 11:42:30 +0900 Subject: [PATCH] Add: banned word DB --- src/web/js/lib/account_validator.js | 6 ++++-- src/web/server/maestro/check_id.php | 26 ++++++++++++++++++++++++++ src/web/sql/make_db.sql | 5 +++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/web/js/lib/account_validator.js b/src/web/js/lib/account_validator.js index 842b48e..8f65b53 100644 --- a/src/web/js/lib/account_validator.js +++ b/src/web/js/lib/account_validator.js @@ -19,10 +19,12 @@ AccountValidator.prototype.messageForInvalidMaestroID = function(textID) { return "마에스트로 계정명은 " + AccountValidator.MAESTRO_ID_LENGTH_MINIMUM + "글자 이상이어야 합니다."; else if(textID.length > AccountValidator.MAESTRO_ID_LENGTH_MAXIMUM) return "마에스트로 계정명은 " + AccountValidator.MAESTRO_ID_LENGTH_MAXIMUM + "글자 이하이어야 합니다."; + else if((/\s/.test(textID))) + return "마에스트로 계정명에는 띄어쓰기를 허용하지 않고 있습니다."; else if(!(/^[A-Za-z]/.test(textID))) - return "마에스트로 계정명은 알파벳으로 시작해야 합니다."; + return "마에스트로 계정명은 글자와 숫자로만 적어주세요."; else if((/[^\w]/g).test(textID)) - return "마에스트로 계정명은 알파벳과 숫자로만 적어주세요."; + return "마에스트로 계정명은 글자와 숫자로만 적어주세요."; } diff --git a/src/web/server/maestro/check_id.php b/src/web/server/maestro/check_id.php index e174fcd..1ddba4d 100644 --- a/src/web/server/maestro/check_id.php +++ b/src/web/server/maestro/check_id.php @@ -7,6 +7,13 @@ include "./../setup/connect_db.php"; $maestro_name = $_POST["maestro_name"]; +$banned_word = banned_maestro_name($maestro_name); +if($banned_word !== null) { + set_error_message($maestro_name." : 금칙어로 등록된 이름입니다. 다른 아이디로 입력해주세요."); + send_result_fail(); + exit; +} + $maestro_id = get_maestro_id($maestro_name); if($maestro_id !== null) { set_error_code("registered_name"); @@ -20,6 +27,25 @@ exit; +function banned_maestro_name($maestroName) { + global $db_conn; + + $query = " + SELECT Word + FROM banned_word + WHERE Word = ? + "; + $stmt = $db_conn->prepare($query); + $stmt->bind_param("s", $maestroName); + $stmt->execute(); + $stmt->bind_result($maestroID); + // while($stmt->fetch()) + $stmt->fetch(); + $stmt->close(); + + return $maestroID; +} + function get_maestro_id($maestro_name) { global $db_conn; diff --git a/src/web/sql/make_db.sql b/src/web/sql/make_db.sql index fa56fe9..55d4326 100644 --- a/src/web/sql/make_db.sql +++ b/src/web/sql/make_db.sql @@ -101,3 +101,8 @@ CREATE TABLE ranking ( FOREIGN KEY (AppID) REFERENCES app(AppID), FOREIGN KEY (PlayerID) REFERENCES player(PlayerID) ); + +CREATE TABLE banned_word ( + BannedWordID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + Word CHAR(50) NOT NULL +);