From c49dcf81528f0a2963ae40f973d50c3df62aa451 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 5 Mar 2018 00:49:31 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A0=88=EA=B1=B0=EC=8B=9C=20dbConn=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=EB=A5=BC=20=EC=9A=B0=EC=84=A0=20getDB()=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=EC=97=90=20=EA=B8=B0=EB=B0=98=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- twe/commandlist.php | 2 +- twe/func.php | 11 +++++++++++ twe/lib.php | 22 ++++++++++------------ twe/select_npc.php | 2 +- twe/select_npc_post.php | 2 +- twe/selection.php | 2 +- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/twe/commandlist.php b/twe/commandlist.php index f8f01b8b..1d0b40eb 100644 --- a/twe/commandlist.php +++ b/twe/commandlist.php @@ -3,7 +3,7 @@ include "lib.php"; include "func.php"; //로그인 검사 CheckLogin(1); -$connect = dbconn(); +$connect = dbConn(); ?> diff --git a/twe/func.php b/twe/func.php index cd7b91ae..454f74aa 100644 --- a/twe/func.php +++ b/twe/func.php @@ -59,6 +59,17 @@ function getUserID($forceExit=false){ return $userID; } +/** + * 로그인 유저의 전역 grade를 받아옴 + * @return int|null + */ +function getUserGrade($forceExit=false){ + $userID = getUserID($forceExit); + if(!$userID){ + return null; + } + return getRootDB()->queryFirstField('SELECT `GRADE` from `MEMBER` WHERE NO=%i', $userID); +} /** * 로그인한 유저의 장수 id를 받아옴 diff --git a/twe/lib.php b/twe/lib.php index f1c125a1..d22f7d67 100644 --- a/twe/lib.php +++ b/twe/lib.php @@ -95,12 +95,14 @@ if($_SESSION['p_time']+3600 < time()) { $_SESSION['p_time'] = time(); } +/* // DB가 설정이 되었는지를 검사 -if(!file_exists(__DIR__."/d_setting/set.php")&&!preg_match("/install/i",$_SERVER['PHP_SELF'])) { +if(!file_exists(__DIR__."/d_setting/conf.php")&&!preg_match("/install/i",$_SERVER['PHP_SELF'])) { // echo""; -echo $_SERVER['PHP_SELF'].'//'.preg_match("/install/i",$_SERVER['PHP_SELF']); + echo $_SERVER['PHP_SELF'].'//'.preg_match("/install/i",$_SERVER['PHP_SELF']); exit; } +*/ /** * Session에 보관된 장수 정보를 제거함. @@ -115,15 +117,11 @@ function resetSessionGeneralValues(){ } // MySQL 데이타 베이스에 접근 -function dbconn($table = "") { - //TODO:dbconn 사용하는 모든 녀석들을 없애야한다. - global $connect, $HTTP_COOKIE_VARS; - $f = @file("d_setting/set.php") or Error("set.php파일이 없습니다. DB설정을 먼저 하십시요!"); - for($i=1; $i<= 4; $i++) $f[$i] = trim(str_replace("\n","",$f[$i])); - if(!$connect) $connect = @MYDB_connect($f[1],$f[2],$f[3]) or Error("DB 접속시 에러가 발생했습니다"); - if($table != "") { $f[4] = $table; } - @MYDB_select_db($f[4], $connect) or Error("DB Select 에러가 발생했습니다",""); - return $connect; +function dbConn($isRoot=false) { + if($isRoot){ + return getRootDB()->get(); + } + return getDB()->get(); } // 에러 메세지 출력 @@ -159,7 +157,7 @@ function returnJson($value, $noCache = true, $pretty = false, $die = true){ // 게시판의 생성유무 검사 function isTable($connect, $str, $dbname='') { if(!$dbname) { - $f=@file("d_setting/set.php") or Error("set.php파일이 없습니다. DB설정을 먼저 하십시요"); + $f=@file("d_setting/conf.php") or Error("conf.php파일이 없습니다. DB설정을 먼저 하십시요"); for($i=1;$i<=4;$i++) $f[$i]=str_replace("\n","",$f[$i]); $dbname=$f[4]; } diff --git a/twe/select_npc.php b/twe/select_npc.php index 17ccacd5..1ec65de7 100644 --- a/twe/select_npc.php +++ b/twe/select_npc.php @@ -2,7 +2,7 @@ include "lib.php"; include "func.php"; -$connect = dbConn("sammo"); +$connect = dbConn(true); $userID = getUserID(); //회원 테이블에서 정보확인 $query = "select no,name,picture,grade from MEMBER where no='$userID'"; diff --git a/twe/select_npc_post.php b/twe/select_npc_post.php index a3964595..d8daa726 100644 --- a/twe/select_npc_post.php +++ b/twe/select_npc_post.php @@ -5,7 +5,7 @@ include "func.php"; $face = $_POST['face'];//TODO: face를 user_id에서 general.no 값을 이용하도록 변경 $userID = getUserID(); -$connect = dbConn("sammo"); +$connect = dbConn(true); //회원 테이블에서 정보확인 $query = "select no,id,picture,grade,name from MEMBER where no='$userID'"; diff --git a/twe/selection.php b/twe/selection.php index a6061b89..d364636f 100644 --- a/twe/selection.php +++ b/twe/selection.php @@ -6,7 +6,7 @@ include "func.php"; $btn = $_POST['btn']; $userID = getUserID(); -$connect = dbConn("sammo"); +$connect = dbConn(true); //회원 테이블에서 정보확인 $query = "select no,name,picture,grade from MEMBER where no='$userID'";