From 91232a83eb249df5984032bcc526476c2c5e052e Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 31 Mar 2018 00:24:06 +0900 Subject: [PATCH] =?UTF-8?q?sql=20=ED=8C=8C=EC=9D=BC=20=EC=9D=84=20?= =?UTF-8?q?=EB=B6=88=EB=9F=AC=EC=98=A4=EB=8A=94=20=EB=8F=99=EC=9E=91?= =?UTF-8?q?=EC=9D=84=20=EC=9E=98=EB=AA=BB=20=EC=88=98=ED=96=89=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EC=A0=90=20=ED=95=B4=EA=B2=B0=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- f_install/j_setup_db.php | 4 +-- twe/j_install.php | 55 ++++++++++++++++++++++++---------------- twe/j_install_db.php | 6 +---- 3 files changed, 35 insertions(+), 30 deletions(-) diff --git a/f_install/j_setup_db.php b/f_install/j_setup_db.php index bc9b1029..910fd2a3 100644 --- a/f_install/j_setup_db.php +++ b/f_install/j_setup_db.php @@ -124,9 +124,7 @@ $rootDB->error_handler = 'dbSQLFail'; $mysqli_obj = $rootDB->get(); //로그인에 실패할 경우 자동으로 dbConnFail()이 실행됨. if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/common_schema.sql'))){ - do{ - $mysqli_obj->store_result(); - } while($mysqli_obj->next_result()); + while ($mysqli_obj->next_result()) {;} } $rootDB->insert('system', array( diff --git a/twe/j_install.php b/twe/j_install.php index 397e3fba..8d910e94 100644 --- a/twe/j_install.php +++ b/twe/j_install.php @@ -12,23 +12,41 @@ if($session->userGrade < 5){ ]); } -$turnterm = Util::toInt(Util::array_get($_POST['turnterm'])); -$sync = Util::toInt(Util::array_get($_POST['sync'])); -$scenario = Util::toInt(Util::array_get($_POST['scenario'])); -$fiction = Util::toInt(Util::array_get($_POST['fiction'])); -$extend = Util::toInt(Util::array_get($_POST['extend'])); -$npcmode = Util::toInt(Util::array_get($_POST['npcmode'])); -$show_img_level = Util::toInt(Util::array_get($_POST['show_img_level'])); - - - -if($turnterm===null || $sync===null || $scenario===null || $fiction===null || $extend===null || $npcmode===null || $show_img_level===null){ +$v = new Validator($_POST); +$v->rule('required', [ + 'turnterm', + 'sync', + 'scenario', + 'fiction', + 'extend', + 'npcmode', + 'show_img_level' +])->rule('integer', [ + 'turnterm', + 'sync', + 'scenario', + 'fiction', + 'extend', + 'npcmode', + 'show_img_level' +]); +if(!$v->validate()){ + $errors = array_values((array)$v->errors()); + $errors = array_map(function($value){return join(', ', $value);}, $errors); + $errors = join(', ', $errors); Json::die([ 'result'=>false, - 'reason'=>'입력 값이 올바르지 않습니다' + 'reason'=>$errors ]); } +$turnterm = (int)$_POST['turnterm']; +$sync = (int)$_POST['sync']; +$scenario = (int)$_POST['scenario']; +$fiction = (int)$_POST['fiction']; +$extend = (int)$_POST['extend']; +$npcmode = (int)$_POST['npcmode']; +$show_img_level = (int)$_POST['show_img_level']; if(120 % $turnterm != 0){ Json::die([ @@ -39,20 +57,13 @@ if(120 % $turnterm != 0){ $mysqli_obj = DB::db()->get(); + if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/reset.sql'))){ - do{ - if(!$mysqli_obj->store_result()){ - break; - } - } while($mysqli_obj->next_result()); + while ($mysqli_obj->next_result()) {;} } if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/schema.sql'))){ - do{ - if(!$mysqli_obj->store_result()){ - break; - } - } while($mysqli_obj->next_result()); + while ($mysqli_obj->next_result()) {;} } //TODO:script diff --git a/twe/j_install_db.php b/twe/j_install_db.php index 087436c0..93719572 100644 --- a/twe/j_install_db.php +++ b/twe/j_install_db.php @@ -30,11 +30,7 @@ if($fullReset && class_exists('\\sammo\\DB')){ $mysqli_obj = DB::db()->get(); if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/reset.sql'))){ - do{ - if(!$mysqli_obj->store_result()){ - break; - } - } while($mysqli_obj->next_result()); + while ($mysqli_obj->next_result()) {;} } }