From 0c0c4fa5478134b3679320363ae932a916879d3b Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 28 Jan 2018 04:17:13 +0900 Subject: [PATCH] =?UTF-8?q?newDB=20=ED=95=A8=EC=88=98=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=8B=9C=20static=20=EB=B3=80=EC=88=98=EB=A1=9C=20DB=20Object?= =?UTF-8?q?=EB=A5=BC=20=EB=B3=B4=EA=B4=80=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95.=20=20=EB=AA=A8=EB=93=A0=20update=20?= =?UTF-8?q?=EB=AA=85=EB=A0=B9=EC=9D=80=20global=20lock=20=ED=95=98?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=ED=86=B5=EC=A0=9C=EB=90=98=EB=AF=80?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=20=EB=B0=A9=EC=8B=9D=EC=9D=84=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=A0=20=EC=88=98=20=EC=9E=88=EC=9D=8C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- d_setting/conf.orig.php | 8 +++++++- twe/d_setting/conf.orig.php | 8 +++++++- twe/func_message.php | 26 ++++++++++++++++++++++---- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/d_setting/conf.orig.php b/d_setting/conf.orig.php index 9e45ba67..e566e043 100644 --- a/d_setting/conf.orig.php +++ b/d_setting/conf.orig.php @@ -17,7 +17,13 @@ function newRootDB(){ $port = _port_; $encoding = 'utf8'; - return new MeekroDB($host,$user,$password,$dbName,$port,$encoding); + static $uDB = NULL; + + if($uDB === NULL){ + $uDB = new MeekroDB($host,$user,$password,$dbName,$port,$encoding); + } + + return $uDB; } function newMailObj(){ diff --git a/twe/d_setting/conf.orig.php b/twe/d_setting/conf.orig.php index 03fb571c..6d58362d 100644 --- a/twe/d_setting/conf.orig.php +++ b/twe/d_setting/conf.orig.php @@ -14,5 +14,11 @@ function newDB(){ $port = _port_; $encoding = 'utf8'; - return new MeekroDB($host,$user,$password,$dbName,$port,$encoding); + static $uDB = NULL; + + if($uDB === NULL){ + $uDB = new MeekroDB($host,$user,$password,$dbName,$port,$encoding); + } + + return $uDB; } \ No newline at end of file diff --git a/twe/func_message.php b/twe/func_message.php index 8a12ce21..c593bc46 100644 --- a/twe/func_message.php +++ b/twe/func_message.php @@ -66,11 +66,11 @@ function getRawMessage($mailbox, $limit=30, $fromTime=NULL){ $db = newDB(); //TODO: table 네임의 prefix를 처리할 수 있도록 개선 - $result = $db->query($sql, array( + $result = $db->query($sql, [ 'mailbox' => $mailbox, 'limit' => $limit, 'time' => $fromTime - )); + ]); return array_map(function ($row){ @@ -78,7 +78,25 @@ function getRawMessage($mailbox, $limit=30, $fromTime=NULL){ }, $result); } -function getMessage(){ +function getMessage($msgType, $limit=30, $fromTime=NULL){ + $genID = util::array_get($_SESSION['p_id'], NULL); + if($genID === NULL){ + return []; + } + + if($msgType === 'public'){ + return getRawMessage(9999, $limit, $fromTime); + } + else if($msgType === 'private'){ + return getRawMessage($genID, $limit, $fromTime); + } + else if($msgType === 'national'){ + + } + else{ + return []; + } + } @@ -87,7 +105,7 @@ function genList($connect) { $query = "select no,nation,level,msgindex,userlevel from general where user_id='{$_SESSION['p_id']}'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); $me = MYDB_fetch_array($result); - $you = array(); + $you = []; $query = "select msg{$me['msgindex']}_who as reply,msg{$me['msgindex']}_type as type from general where user_id='{$_SESSION['p_id']}'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");