diff --git a/.gitignore b/.gitignore
index 80a8b697..cee08a6d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -113,16 +113,9 @@ venv.bak/
# 체섭 ignore
logs/*.txt
d_log/*.txt
-d_setting/set.php
-set.php
-config.php
sess_*
*/logs/*.txt
-d_setting/set.php
-conf.php
-d_setting/conf*.php
err.txt
-!*/*.orig.php
che/.htaccess
kwe/.htaccess
pwe/.htaccess
@@ -130,5 +123,9 @@ twe/.htaccess
hwe/.htaccess
d_pic/*.jpg
+d_pic/*.gif
+d_pic/*.png
+
d_setting/KakaoKey.php
d_setting/RootDB.php
+*/d_setting/DB.php
diff --git a/d_setting/conf_kakao.orig.php b/d_setting/KakaoKey.orig.php
similarity index 79%
rename from d_setting/conf_kakao.orig.php
rename to d_setting/KakaoKey.orig.php
index 0a48e25e..d50c281a 100644
--- a/d_setting/conf_kakao.orig.php
+++ b/d_setting/KakaoKey.orig.php
@@ -1,6 +1,5 @@
connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
+ }
+ return self::$uDB;
+ }
+
+ /**
+ * 비밀번호 해시용 전역 SALT 반환
+ * 비밀번호는 sha512(usersalt|sha512(globalsalt|password|globalsalt)|usersalt); 순임
+ *
+ * @return string
+ */
+ public static function getGlobalSalt(){
+ return self::$globalSalt;
+ }
+
+ /**
+ * 서버 주소 반환. 서버의 경로가 하부 디렉토리인 경우에 하부 디렉토리까지 포함
+ *
+ * @return string
+ */
+ public static function getServerBasepath(){
+ //FIXME: 더 좋은 위치가 있을 것.
+ return self::$globalSalt;
+ }
+}
\ No newline at end of file
diff --git a/d_setting/conf.orig.php b/d_setting/conf.orig.php
deleted file mode 100644
index 5b047876..00000000
--- a/d_setting/conf.orig.php
+++ /dev/null
@@ -1,46 +0,0 @@
-connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
- }
-
- return $uDB;
-}
diff --git a/f_install/j_create_admin.php b/f_install/j_create_admin.php
index b923d3db..2a2d36c0 100644
--- a/f_install/j_create_admin.php
+++ b/f_install/j_create_admin.php
@@ -33,7 +33,7 @@ if(!AppConf::getRoot()->isExists()){
}
require(__DIR__.'/../f_config/DB.php');
-$rootDB = getRootDB();
+$rootDB = RootDB::db();
//초기 관리자 계정은 딱 하나만 있어야하므로, 중요함.
$rootDB->query('LOCK TABLES member WRITE, member_log WRITE');
diff --git a/f_install/j_install_status.php b/f_install/j_install_status.php
index 3925b1df..e3d91703 100644
--- a/f_install/j_install_status.php
+++ b/f_install/j_install_status.php
@@ -23,7 +23,7 @@ if(!AppConf::getRoot()->isExists()){
}
require(__DIR__.'/../f_config/DB.php');
-$rootDB = getRootDB();
+$rootDB = RootDB::db();
$rootDB->throw_exception_on_nonsql_error = false;
$rootDB->nonsql_error_handler = 'dbConnFail';
@@ -33,7 +33,7 @@ $memberCnt = $rootDB->queryFirstField('SELECT count(`NO`) from MEMBER');
if($memberCnt === 0){
Json::die([
'step'=>'admin',
- 'globalSalt'=>getGlobalSalt()
+ 'globalSalt'=>RootDB::getGlobalSalt()
]);
}
diff --git a/f_install/j_setup_db.php b/f_install/j_setup_db.php
index 0549fca8..9d3afffd 100644
--- a/f_install/j_setup_db.php
+++ b/f_install/j_setup_db.php
@@ -38,17 +38,17 @@ if(!filter_var($servHost, FILTER_VALIDATE_URL)){
]);
}
-if(file_exists(ROOT.'/d_setting/conf.php') && is_dir(ROOT.'/d_setting/conf.php')){
+if(file_exists(ROOT.'/d_setting/RootDB.php') && is_dir(ROOT.'/d_setting/RootDB.php')){
Json::die([
'result'=>false,
- 'reason'=>'d_setting/conf.php 가 디렉토리입니다'
+ 'reason'=>'d_setting/RootDB.php 가 디렉토리입니다'
]);
}
if(AppConf::getRoot()->isExists()){
Json::die([
'result'=>false,
- 'reason'=>'이미 conf.php 파일이 있습니다'
+ 'reason'=>'이미 RootDB.php 파일이 있습니다'
]);
}
@@ -139,8 +139,8 @@ $rootDB->insert('system', array(
$globalSalt = bin2hex(random_bytes(16));
$result = Util::generateFileUsingSimpleTemplate(
- ROOT.'/d_setting/conf.orig.php',
- ROOT.'/d_setting/conf.php',[
+ ROOT.'/d_setting/RootDB.orig.php',
+ ROOT.'/d_setting/RootDB.php',[
'host'=>$host,
'user'=>$username,
'password'=>$password,
diff --git a/i_entrance/admin_userlist.php b/i_entrance/admin_userlist.php
index fecf45e4..a8462738 100644
--- a/i_entrance/admin_userlist.php
+++ b/i_entrance/admin_userlist.php
@@ -5,7 +5,7 @@ require_once('_common.php');
require_once(ROOT.'/f_config/DB.php');
$session = Session::requireLogin();
-$db = getRootDB();
+$db = RootDB::db();
$userGrade = $session->userGrade;
$session->setReadOnly();
diff --git a/i_entrance/entrance.php b/i_entrance/entrance.php
index 82e99dc1..75c4a988 100644
--- a/i_entrance/entrance.php
+++ b/i_entrance/entrance.php
@@ -7,7 +7,7 @@ $session = Session::requireLogin();
$templates = new \League\Plates\Engine('templates');
-$db = getRootDB();
+$db = RootDB::db();
$notice = $db->queryFirstField('SELECT `NOTICE` FROM `SYSTEM` WHERE `NO`=1');
$userGrade = $session->userGrade;
?>
diff --git a/i_entrance/j_change_password.php b/i_entrance/j_change_password.php
index 82eb9167..a00b3f29 100644
--- a/i_entrance/j_change_password.php
+++ b/i_entrance/j_change_password.php
@@ -23,7 +23,7 @@ $newPw = $_POST['new_pw'];
$response['result'] = false;
-$db = getRootDB();
+$db = RootDB::db();
$userInfo = $db->update('member',[
'pw'=>$db->sqleval('sha2(concat(salt, %s, salt), 512)', $newPw)
diff --git a/i_entrance/j_delete_me.php b/i_entrance/j_delete_me.php
index 14e49996..cbf7d165 100644
--- a/i_entrance/j_delete_me.php
+++ b/i_entrance/j_delete_me.php
@@ -25,7 +25,7 @@ if(!$pw){
}
//TODO: 탈퇴 처리하되 한달간 유지.
-$db = getRootDB();
+$db = RootDB::db();
$userInfo = $db->queryFirstRow('SELECT oauth_id, oauth_type, email, delete_after FROM MEMBER '.
'WHERE `no`=%i and pw=sha2(concat(salt, %s, salt), 512)',
diff --git a/i_entrance/j_get_user_info.php b/i_entrance/j_get_user_info.php
index f6da4e0b..1b1f5b72 100644
--- a/i_entrance/j_get_user_info.php
+++ b/i_entrance/j_get_user_info.php
@@ -15,7 +15,7 @@ if(!$session->isLoggedIn()) {
// 외부 파라미터
-$db = getRootDB();
+$db = RootDB::db();
$member = $db->queryFirstRow('SELECT `id`, `name`, `grade`, `picture` FROM `MEMBER` WHERE `NO` = %i', $session->userID);
if(!$member['picture']){
@@ -51,5 +51,5 @@ Json::die([
'name'=>$member['name'],
'grade'=>$grade,
'picture'=>$picture,
- 'global_salt'=>getGlobalSalt()
+ 'global_salt'=>RootDB::getGlobalSalt()
]);
diff --git a/i_entrance/j_icon_change.php b/i_entrance/j_icon_change.php
index 322a53c4..45f93cc1 100644
--- a/i_entrance/j_icon_change.php
+++ b/i_entrance/j_icon_change.php
@@ -28,7 +28,7 @@ $imageType = $size[2];
$availableImageType = array('.jpg'=>IMAGETYPE_JPEG, '.png'=>IMAGETYPE_PNG, '.gif'=>IMAGETYPE_GIF);
-$db = getRootDB();
+$db = RootDB::db();
$member = $db->queryFirstRow('SELECT `ID`, `PICTURE` FROM `MEMBER` WHERE `NO` = %i', $session->userID);
@@ -84,7 +84,7 @@ if(!is_uploaded_file($image['tmp_name'])) {
$response['result'] = false;
} else {
$pic = "{$newPicName}?={$rf}";
- getRootDB()->update('MEMBER',[
+ RootDB::db()->update('MEMBER',[
'PICTURE' => $pic,
'IMGSVR' => 1
], 'NO=%i', $session->userID);
diff --git a/i_entrance/j_icon_delete.php b/i_entrance/j_icon_delete.php
index 04d27524..80ea67ae 100644
--- a/i_entrance/j_icon_delete.php
+++ b/i_entrance/j_icon_delete.php
@@ -16,7 +16,7 @@ if(!$session->isLoggedIn()) {
// 외부 파라미터
$respone = [];
-$db = getRootDB();
+$db = RootDB::db();
$picName = $db->queryFirstField('SELECT picture FROM `MEMBER` WHERE `NO` = %i', $session->userID);
if($picName && strlen($picName) > 11){
diff --git a/i_entrance/j_server_change_status.php b/i_entrance/j_server_change_status.php
index 12c3fb1c..c73d63ae 100644
--- a/i_entrance/j_server_change_status.php
+++ b/i_entrance/j_server_change_status.php
@@ -20,7 +20,7 @@ $action = Util::array_get($_POST['action'], '');
$notice = Util::array_get($_POST['notice'], '');
$server = Util::array_get($_POST['server'], '');
-$db = getRootDB();
+$db = RootDB::db();
$userGrade = $session->userGrade;
session_write_close();
@@ -58,8 +58,8 @@ function doServerModeSet($server, $action, &$response){
file_put_contents($serverPath.'/.htaccess', $htaccess);
} elseif($action == 'reset') {//리셋
//FIXME: reset, reset_full 구현
- if(file_exists($serverPath.'/d_setting/conf.php')){
- @unlink($serverPath.'/d_setting/conf.php');
+ if(file_exists($serverPath.'/d_setting/DB.php')){
+ @unlink($serverPath.'/d_setting/DB.php');
}
$response['installURL'] = $serverDir."/install.php";
@@ -77,7 +77,7 @@ function doAdminPost($action, $notice, $server){
$response['result'] = 'FAIL';
if($action == 'notice') {
- getRootDB()->update('SYSTEM', ['NOTICE'=>$notice], 'NO=1');
+ RootDB::db()->update('SYSTEM', ['NOTICE'=>$notice], 'NO=1');
$response['result'] = 'SUCCESS';
return $response;
}
diff --git a/i_entrance/member/Get.php b/i_entrance/member/Get.php
index 6beaa7a5..430d0215 100644
--- a/i_entrance/member/Get.php
+++ b/i_entrance/member/Get.php
@@ -11,7 +11,7 @@ $session = Session::requireLogin();
// $_GET['select'] : 정렬선택
$select = $_GET['select'];
-$db = getRootDB();
+$db = RootDB::db();
$userGrade = $session->userGrade;
if($userGrade < 6) {
Json::die([
@@ -70,7 +70,7 @@ $response['members'] .= '';
$response['count'] = "(0000/{$count})";
-$system = getRootDB()->queryFirstRow('SELECT `REG`, `LOGIN` FROM `SYSTEM` WHERE `NO`=1');
+$system = RootDB::db()->queryFirstRow('SELECT `REG`, `LOGIN` FROM `SYSTEM` WHERE `NO`=1');
$response['state'] = "가입: {$system['REG']}, 로그인: {$system['LOGIN']}";
diff --git a/i_entrance/member/Post.php b/i_entrance/member/Post.php
index 09df36dd..d0386fb2 100644
--- a/i_entrance/member/Post.php
+++ b/i_entrance/member/Post.php
@@ -11,7 +11,7 @@ $session = Session::requireLogin();
$select = $_POST['select'];
$no = $_POST['no'];
-$db = getRootDB();
+$db = RootDB::db();
$member = $db->queryFirstRow('SELECT `GRADE` FROM `MEMBER` WHERE `NO` = %i', $session->userID);
if($member['GRADE'] < 6) {
diff --git a/index.php b/index.php
index c2d41615..e6845d7a 100644
--- a/index.php
+++ b/index.php
@@ -1,7 +1,6 @@
isExists()){
@@ -142,7 +141,7 @@ function postOAuthResult(result){
-
+
diff --git a/oauth_kakao/lib.join.php b/oauth_kakao/lib.join.php
index f6f7e245..e464e762 100644
--- a/oauth_kakao/lib.join.php
+++ b/oauth_kakao/lib.join.php
@@ -2,7 +2,6 @@
namespace sammo;
require_once('_common.php');
-require_once(__dir__.'/../d_setting/conf.php');
function checkUsernameDup($username){
if(!$username){
@@ -15,7 +14,7 @@ function checkUsernameDup($username){
return '적절하지 않은 길이입니다.';
}
- $cnt = getRootDB()->queryFirstField('SELECT count(no) FROM member WHERE `id` = %s LIMIT 1', $username);
+ $cnt = RootDB::db()->queryFirstField('SELECT count(no) FROM member WHERE `id` = %s LIMIT 1', $username);
if($cnt != 0){
return '이미 사용중인 계정명입니다';
}
@@ -32,7 +31,7 @@ function checkNicknameDup($nickname){
return '적절하지 않은 길이입니다.';
}
- $cnt = getRootDB()->queryFirstField('SELECT count(no) FROM member WHERE `name` = %s LIMIT 1', $nickname);
+ $cnt = RootDB::db()->queryFirstField('SELECT count(no) FROM member WHERE `name` = %s LIMIT 1', $nickname);
if($cnt != 0){
return '이미 사용중인 닉네임입니다';
}
@@ -50,7 +49,7 @@ function checkEmailDup($email){
return '적절하지 않은 길이입니다.';
}
- $userInfo = getRootDB()->queryFirstField('SELECT `no`, `delete_after` FROM member WHERE `email` = %s LIMIT 1', $email);
+ $userInfo = RootDB::db()->queryFirstField('SELECT `no`, `delete_after` FROM member WHERE `email` = %s LIMIT 1', $email);
if($userInfo){
$nowDate = TimeUtil::DatetimeNow();
if (!$userInfo['delete_after']) {
@@ -62,7 +61,7 @@ function checkEmailDup($email){
}
//$userInfo['delete_after'] < $userInfo
- getRootDB()->delete('member', 'no=%i', $userInfo['no']);
+ RootDB::db()->delete('member', 'no=%i', $userInfo['no']);
}
return true;
}
\ No newline at end of file
diff --git a/oauth_kakao/oauth.php b/oauth_kakao/oauth.php
index f3e31e5c..a01c49a5 100644
--- a/oauth_kakao/oauth.php
+++ b/oauth_kakao/oauth.php
@@ -1,7 +1,6 @@
basepath = $basepath;
- $this->settingFile = realpath($basepath.'/d_setting/conf.php');
+ $this->settingFile = realpath($basepath.'/d_setting/DB.php');
if(file_exists($this->settingFile)) {
$this->exist = true;
diff --git a/twe/_admin2_submit.php b/twe/_admin2_submit.php
index da9ca470..7ec156a8 100644
--- a/twe/_admin2_submit.php
+++ b/twe/_admin2_submit.php
@@ -28,42 +28,42 @@ switch($btn) {
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
break;
case "블럭 해제":
- getDB()->query('update general set block=0 where no IN %li', $genlist);
+ DB::db()->query('update general set block=0 where no IN %li', $genlist);
break;
case "1단계 블럭":
$date = date('Y-m-d H:i:s');
- $db = getDB();
+ $db = DB::db();
$db->query('update general set block=1,killturn=24 where no IN %li',$genlist);
//FIXME: subquery로 하는게 더 빠를 듯.
$uid = $db->queryFirstColumn('select owner from general where no IN %li', $genlist);
- getRootDB()->query('update MEMBER set block_num=block_num+1,block_date=%s where no IN %ls', $date, $uid);
+ RootDB::db()->query('update MEMBER set block_num=block_num+1,block_date=%s where no IN %ls', $date, $uid);
break;
case "2단계 블럭":
$date = date('Y-m-d H:i:s');
- $db = getDB();
+ $db = DB::db();
$db->query('update general set gold=0,rice=0,block=2,killturn=24 where no IN %li',$genlist);
$uid = $db->queryFirstColumn('select owner from general where no IN %li', $genlist);
- getRootDB()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
+ RootDB::db()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
break;
case "3단계 블럭":
$date = date('Y-m-d H:i:s');
- $db = getDB();
+ $db = DB::db();
$db->query('update general set gold=0,rice=0,block=3,killturn=24 where no IN %li',$genlist);
$uid = $db->queryFirstColumn('select owner from general where no IN %li', $genlist);
- getRootDB()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
+ RootDB::db()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
break;
case "무한삭턴":
- getDB()->query('update general set killturn=8000 where no IN %li',$genlist);
+ DB::db()->query('update general set killturn=8000 where no IN %li',$genlist);
break;
case "강제 사망":
$date = date('Y-m-d H:i:s');
- getDB()->query('update general set turn0=0,killturn=0,turntime=%s where no IN %li',$date, $genlist);
+ DB::db()->query('update general set turn0=0,killturn=0,turntime=%s where no IN %li',$date, $genlist);
break;
case "특기 부여":
- $admin = getDB()->queryFirstRow('select `year`, `month` from `game` where `no`=1');
+ $admin = DB::db()->queryFirstRow('select `year`, `month` from `game` where `no`=1');
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
$msg = "특기 부여!";
sendMessage('private', ['id'=>$generalID, 'nation_id'=>0], ['id'=>$you['no'], 'nation_id'=>$you['nation']], $msg);
}
@@ -84,7 +84,7 @@ switch($btn) {
break;
case "경험치1000":
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
$msg = $btn." 지급!";
sendMessage('private', ['id'=>$generalID, 'nation_id'=>0], ['id'=>$you['no'], 'nation_id'=>$you['nation']], $msg);
}
@@ -95,7 +95,7 @@ switch($btn) {
break;
case "공헌치1000":
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
$msg = $btn." 지급!";
sendMessage('private', ['id'=>$generalID, 'nation_id'=>0], ['id'=>$you['no'], 'nation_id'=>$you['nation']], $msg);
}
@@ -106,7 +106,7 @@ switch($btn) {
break;
case "보숙10000":
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
$msg = "보병숙련도+10000 지급!";
sendMessage('private', ['id'=>$generalID, 'nation_id'=>0], ['id'=>$you['no'], 'nation_id'=>$you['nation']], $msg);
}
@@ -117,7 +117,7 @@ switch($btn) {
break;
case "궁숙10000":
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
$msg = "궁병숙련도+10000 지급!";
sendMessage('private', ['id'=>$generalID, 'nation_id'=>0], ['id'=>$you['no'], 'nation_id'=>$you['nation']], $msg);
}
@@ -128,7 +128,7 @@ switch($btn) {
break;
case "기숙10000":
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
$msg = "기병숙련도+10000 지급!";
sendMessage('private', ['id'=>$generalID, 'nation_id'=>0], ['id'=>$you['no'], 'nation_id'=>$you['nation']], $msg);
}
@@ -139,7 +139,7 @@ switch($btn) {
break;
case "귀숙10000":
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
$msg = "귀병숙련도+10000 지급!";
sendMessage('private', ['id'=>$generalID, 'nation_id'=>0], ['id'=>$you['no'], 'nation_id'=>$you['nation']], $msg);
}
@@ -150,7 +150,7 @@ switch($btn) {
break;
case "차숙10000":
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
$msg = "차병숙련도+10000 지급!";
sendMessage('private', ['id'=>$generalID, 'nation_id'=>0], ['id'=>$you['no'], 'nation_id'=>$you['nation']], $msg);
}
@@ -175,14 +175,14 @@ switch($btn) {
//TODO:새 갠메 시스템으로 변경
$date = date('Y-m-d H:i:s');
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
sendMessage('private', ['id'=>$generalID, 'nation_id'=>0], ['id'=>$you['no'], 'nation_id'=>$you['nation']], $msg);
}
break;
case "무기지급":
$date = date('Y-m-d H:i:s');
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
if($weap == 0) { $msg = "무기 회수!"; }
else { $msg = getWeapName($weap)." 지급!"; }
sendMessage('private', ['id'=>$generalID, 'nation_id'=>0], ['id'=>$you['no'], 'nation_id'=>$you['nation']], $msg);
@@ -199,7 +199,7 @@ switch($btn) {
case "책지급":
$date = date('Y-m-d H:i:s');
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
if($weap == 0) { $msg = "서적 회수!"; }
else { $msg = getBookName($weap)." 지급!"; }
// 상대에게 발송
@@ -217,7 +217,7 @@ switch($btn) {
case "말지급":
$date = date('Y-m-d H:i:s');
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
if($weap == 0) { $msg = "말 회수!"; }
else { $msg = getHorseName($weap)." 지급!"; }
// 상대에게 발송
@@ -235,7 +235,7 @@ switch($btn) {
case "도구지급":
$date = date('Y-m-d H:i:s');
for($i=0; $i < sizeof($genlist); $i++) {
- $you = getDB()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
+ $you = DB::db()->queryFirstRow('select `no`, `nation` from `general` where `no` = %i', $genlist[$i]);
if($weap == 0) { $msg = "특수도구 회수!"; }
else { $msg = getItemName($weap)." 지급!"; }
// 상대에게 발송
diff --git a/twe/_admin4_submit.php b/twe/_admin4_submit.php
index 78b1ffd8..c1b1b85e 100644
--- a/twe/_admin4_submit.php
+++ b/twe/_admin4_submit.php
@@ -16,36 +16,36 @@ if(Session::getUserGrade() < 5) {
//NOTE: 왜 블럭 시 admin4에선 금쌀을 없애지 않는가?
switch($btn) {
case "블럭 해제":
- getDB()->query('update general set block=0 where no IN %li', $genlist);
+ DB::db()->query('update general set block=0 where no IN %li', $genlist);
break;
case "1단계 블럭":
$date = date('Y-m-d H:i:s');
- $db = getDB();
+ $db = DB::db();
$db->query('update general set block=1,killturn=24 where no IN %li',$genlist);
//FIXME: subquery로 하는게 더 빠를 듯.
$uid = $db->queryFirstColumn('select owner from general where no IN %li', $genlist);
- getRootDB()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
+ RootDB::db()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
break;
case "2단계 블럭":
$date = date('Y-m-d H:i:s');
- $db = getDB();
+ $db = DB::db();
$db->query('update general set block=2,killturn=24 where no IN %li',$genlist);
$uid = $db->queryFirstColumn('select owner from general where no IN %li', $genlist);
- getRootDB()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
+ RootDB::db()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
break;
case "3단계 블럭":
$date = date('Y-m-d H:i:s');
- $db = getDB();
+ $db = DB::db();
$db->query('update general set block=3,killturn=24 where no IN %li',$genlist);
$uid = $db->queryFirstColumn('select owner from general where no IN %li', $genlist);
- getRootDB()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
+ RootDB::db()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
break;
case "무한삭턴":
- getDB()->query('update general set killturn=8000 where no IN %li',$genlist);
+ DB::db()->query('update general set killturn=8000 where no IN %li',$genlist);
break;
case "강제 사망":
$date = date('Y-m-d H:i:s');
- getDB()->query('update general set turn0=0,killturn=0,turntime=%s where no IN %li',$date, $genlist);
+ DB::db()->query('update general set turn0=0,killturn=0,turntime=%s where no IN %li',$date, $genlist);
break;
case "메세지 전달":
//TODO:새 갠메 시스템으로 변경
diff --git a/twe/b_myGenInfo.php b/twe/b_myGenInfo.php
index 4df232ee..9b389cba 100644
--- a/twe/b_myGenInfo.php
+++ b/twe/b_myGenInfo.php
@@ -64,7 +64,7 @@ if($me['skin'] < 1) {
queryFirstField('select level from nation where nation = %i', $me['nation']);
+$nationLevel = DB::db()->queryFirstField('select level from nation where nation = %i', $me['nation']);
switch($type) {
case 1: $query = "select npc,special,special2,personal,picture,imgsvr,name,level,dedication,experience,injury,leader,power,intel,gold,rice,belong,connect,killturn from general where nation='{$me['nation']}' order by level desc"; break;
case 2: $query = "select npc,special,special2,personal,picture,imgsvr,name,level,dedication,experience,injury,leader,power,intel,gold,rice,belong,connect,killturn from general where nation='{$me['nation']}' order by dedication desc"; break;
diff --git a/twe/d_setting/DB.orig.php b/twe/d_setting/DB.orig.php
new file mode 100644
index 00000000..c9a5f066
--- /dev/null
+++ b/twe/d_setting/DB.orig.php
@@ -0,0 +1,37 @@
+connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
+ }
+ return self::$uDB;
+ }
+
+ public static function prefix()
+ {
+ return self::$prefix;
+ }
+}
\ No newline at end of file
diff --git a/twe/d_setting/conf.orig.php b/twe/d_setting/conf.orig.php
deleted file mode 100644
index 2998ac7c..00000000
--- a/twe/d_setting/conf.orig.php
+++ /dev/null
@@ -1,30 +0,0 @@
-connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
- }
-
- return $uDB;
-}
-
-function getServPrefix()
-{
- return '_tK_prefix_';
-}
\ No newline at end of file
diff --git a/twe/func.php b/twe/func.php
index fd06c0a8..064c1888 100644
--- a/twe/func.php
+++ b/twe/func.php
@@ -2,7 +2,6 @@
namespace sammo;
require(__dir__.'/../vendor/autoload.php');
-require_once(__dir__.'/d_setting/conf.php');
require_once 'process_war.php';
require_once 'func_gamerule.php';
require_once 'func_process.php';
@@ -52,14 +51,14 @@ function getGeneralID($forceExit=false, $countLogin=true){
return null;
}
- $idKey = getServPrefix().'p_no';
+ $idKey = DB::prefix().'p_no';
$generalID = Util::array_get($_SESSION[$idKey], null);
if($generalID){
return $generalID;
}
- $db = getDB();
+ $db = DB::db();
//흠?
$generalID = $db->queryFirstField('select no from general where owner = %i', $userID);
if(!$generalID && $forceExit){
@@ -100,7 +99,7 @@ function getGeneralName($forceExit=false)
return null;
}
- $nameKey = getServPrefix().'p_name';
+ $nameKey = DB::prefix().'p_name';
$generalName = Util::array_get($_SESSION[$nameKey], null);
if($generalName){
@@ -108,7 +107,7 @@ function getGeneralName($forceExit=false)
}
//흠?
- $generalName = getDB()->queryFirstField('select name from general where no = %i', $generalID);
+ $generalName = DB::db()->queryFirstField('select name from general where no = %i', $generalID);
if(!$generalName){
//이게 말이 돼?
resetSessionGeneralValues();
@@ -146,7 +145,7 @@ function getNationStaticInfo($nationID, $forceRefresh=false)
}
if($nationList === null){
- $nationAll = getDB()->query("select nation, name, color, type, level, capital from nation");
+ $nationAll = DB::db()->query("select nation, name, color, type, level, capital from nation");
$nationList = Util::convertArrayToDict($nationAll, "nation");
$nationList[-1] = $nationAll;
}
@@ -215,7 +214,7 @@ function checkLimit($con, $conlimit) {
}
function getBlockLevel() {
- return getDB()->queryFirstField('select block from general where no = %i', getGeneralID());
+ return DB::db()->queryFirstField('select block from general where no = %i', getGeneralID());
}
function getRandGenName() {
@@ -1412,14 +1411,14 @@ function MyHistory($connect, $no, $skin) {
}
function addHistory($me, $history) {
- getDB()->query("update general set history=concat(%s, history) where no=%i",
+ DB::db()->query("update general set history=concat(%s, history) where no=%i",
$history.'
', $me['no']);
}
function addNationHistory($nation, $history) {
//FIXME: update 쿼리만으로도 구성 가능해보임.
$nation['history'] = "{$nation['history']}{$history}
";
- getDB()->query("update nation set history=concat(%s, history) where nation=%i",
+ DB::db()->query("update nation set history=concat(%s, history) where nation=%i",
$history.'
', $nation['nation']);
}
@@ -1433,13 +1432,13 @@ function adminMsg($connect, $skin=1) {
}
function getOnlineNum() {
- return getDB()->queryFirstField('select `online` from `game` where `no`=1');
+ return DB::db()->queryFirstField('select `online` from `game` where `no`=1');
}
function onlinegen($connect) {
$onlinegen = "";
$generalID = getGeneralID();
- $nationID = getDB()->queryFirstField('select `nation` from `general` where `no` = %i', $generalID);
+ $nationID = DB::db()->queryFirstField('select `nation` from `general` where `no` = %i', $generalID);
if($nationID !== null || Util::toInt($nationID) === 0) {
$query = "select onlinegen from game where no='1'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1772,10 +1771,10 @@ function CutDay($date) {
function increaseRefresh($type="", $cnt=1) {
$date = date('Y-m-d H:i:s');
- getDB()->query('UPDATE game set refresh=refresh+%i where `no`=1', $cnt);
+ DB::db()->query('UPDATE game set refresh=refresh+%i where `no`=1', $cnt);
if(!Util::array_get($_SESSION['userID'], null)) {
- getDB()->query('UPDATE general set `lastrefresh`=%s_date, `con`=`con`+%i_cnt, `connect`=`connect`+%i_cnt, refcnt=refcnt+%i_cnt, refresh=refresh+%i_cnt where `no`=%i_no',[
+ DB::db()->query('UPDATE general set `lastrefresh`=%s_date, `con`=`con`+%i_cnt, `connect`=`connect`+%i_cnt, refcnt=refcnt+%i_cnt, refresh=refresh+%i_cnt where `no`=%i_no',[
'date'=>$date,
'cnt'=>$cnt,
'owner'->getGeneralID()
@@ -1821,7 +1820,7 @@ function increaseRefresh($type="", $cnt=1) {
function updateTraffic() {
$online = getOnlineNum();
- $db = getDB();
+ $db = DB::db();
$game = $db->queryFirstRow('SELECT year,month,refresh,maxonline,maxrefresh from game where no=1');
//최다갱신자
@@ -1893,12 +1892,12 @@ function CheckOverhead($connect) {
}
function isLock() {
- return getDB()->queryFirstField("select plock from plock where no=1") != 0;
+ return DB::db()->queryFirstField("select plock from plock where no=1") != 0;
}
function tryLock() {
//NOTE: 게임 로직과 관련한 모든 insert, update 함수들은 lock을 거칠것을 권장함.
- $db = getDB();
+ $db = DB::db();
//테이블 락
$db->query("lock tables plock write");
// 잠금
@@ -1916,7 +1915,7 @@ function tryLock() {
function unlock() {
// 풀림
//NOTE: unlock에는 table lock이 필요없는가?
- getDB()->query("update plock set plock=0 where no=1");
+ DB::db()->query("update plock set plock=0 where no=1");
}
function timeover($connect) {
diff --git a/twe/func_converter.php b/twe/func_converter.php
index 4747a179..b085cda5 100644
--- a/twe/func_converter.php
+++ b/twe/func_converter.php
@@ -8,7 +8,7 @@
function getScenario() {
//FIXME: 정말로 side effect가 없으려면 query는 밖으로 이동해야함.
- $scenario = getDB()->queryFirstColumn('select `scenario` from `game` where no=1');
+ $scenario = DB::db()->queryFirstColumn('select `scenario` from `game` where no=1');
switch($scenario) {
case 0: $str = '공백지모드'; break;
@@ -626,7 +626,7 @@ function getBill($dedication) {
function getCost($armtype) {
//FIXME: 정말로 side effect가 없으려면 query는 밖으로 이동해야함.
//TODO: 병종 값이 column으로 들어있는건 전혀 옳지 않음. key->value 형태로 바꿔야함
- return getDB()->queryFirstColumn('select %b from game where no=1', sprintf('cst%d', $armtype));
+ return DB::db()->queryFirstColumn('select %b from game where no=1', sprintf('cst%d', $armtype));
}
function TechLimit($startyear, $year, $tech) {
diff --git a/twe/func_diplomacy.php b/twe/func_diplomacy.php
index 71b2d110..8e2c3d55 100644
--- a/twe/func_diplomacy.php
+++ b/twe/func_diplomacy.php
@@ -1,5 +1,4 @@
queryFirstRow('SELECT `level`, `scout` FROM `nation` WHERE `nation` = %i', $nationID);
+ $srcNation = DB::db()->queryFirstRow('SELECT `level`, `scout` FROM `nation` WHERE `nation` = %i', $nationID);
$realNationID = $srcGeneral['nation'];
@@ -38,9 +37,9 @@ function checkScoutAvailable($messageInfo, $general, $srcGeneral, $startyear, $y
function acceptScout($messageInfo, $general, $msgResponse){
$me = $general;
- $you = getDB()->queryFirstRow('SELECT `no`, `name`, `nation` FROM `general` WHERE `no` = %i', $messageInfo['src']['id']);
+ $you = DB::db()->queryFirstRow('SELECT `no`, `name`, `nation` FROM `general` WHERE `no` = %i', $messageInfo['src']['id']);
- list($startyear, $year, $month, $killturn) = Util::convertDictToArray(getDB()->queryFirstRow('SELECT `startyear`, `year`, `month`, `killturn` FROM `game` LIMIT 1'), ['startyear', 'year', 'month', `killturn`]);
+ list($startyear, $year, $month, $killturn) = Util::convertDictToArray(DB::db()->queryFirstRow('SELECT `startyear`, `year`, `month`, `killturn` FROM `game` LIMIT 1'), ['startyear', 'year', 'month', `killturn`]);
list($avaliableScout, $reason) = checkScoutAvailable($messageInfo, $general, $you, $startyear, $year);
@@ -77,7 +76,7 @@ function acceptScout($messageInfo, $general, $msgResponse){
//처리가 조금 다름.
- $db = getDB();
+ $db = DB::db();
if($me['level'] > 0){
@@ -167,7 +166,7 @@ function declineScout($messageInfo, $reason=null){
$msg = "{$nationName}(으)로 등용 제의 거부";
}
- $db = getDB();
+ $db = DB::db();
$db->query('UPDATE `message` SET `valid_until`=\'1234-11-22 11:22:33\' WHERE `id` = %i', $messageInfo['id']);
sendRawMessage('private', false, $general['no'], $messageInfo['src'], $messageInfo['dest'], $msg, null, null, ['parent'=>$messageInfo['id']]);
diff --git a/twe/func_gamerule.php b/twe/func_gamerule.php
index 235c9780..264cf714 100644
--- a/twe/func_gamerule.php
+++ b/twe/func_gamerule.php
@@ -1265,7 +1265,7 @@ function checkEmperior($connect) {
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$statGeneral = MYDB_fetch_array($result);
- $nationHistory = getDB()->queryFirstField('SELECT `history` FROM `nation` WHERE `nation` = %i', $nation['nation']);
+ $nationHistory = DB::db()->queryFirstField('SELECT `history` FROM `nation` WHERE `nation` = %i', $nation['nation']);
$query = "
insert into emperior (
diff --git a/twe/func_history.php b/twe/func_history.php
index 220985ca..abc53e2f 100644
--- a/twe/func_history.php
+++ b/twe/func_history.php
@@ -93,7 +93,7 @@ function LogHistory($isFirst=0) {
$genStr = "";
$cityStr = "";
- $db = getDB();
+ $db = DB::db();
foreach($db->query('select nation,color,name,power,gennum from nation where level>0 order by power desc') as $nation){
$cityCount = $db->queryFirstField('select count(*) from city where nation = %i',$nation['nation']);
diff --git a/twe/func_map.php b/twe/func_map.php
index ad1caaae..19b64663 100644
--- a/twe/func_map.php
+++ b/twe/func_map.php
@@ -26,7 +26,7 @@ function getHistoryMap($year, $month){
return ['result'=>false, 'reason'=>'연 월이 지정되지 않음'];
}
- $map = getDB()->queryFirstField('select map from history where year=%i and month=%i',
+ $map = DB::db()->queryFirstField('select map from history where year=%i and month=%i',
$year,
$month);
@@ -52,7 +52,7 @@ function getWorldMap($req){
$generalID = getGeneralID(false);
- $db = getDB();
+ $db = DB::db();
$game = $db->queryFirstRow('select `startyear`, `year`, `month` from `game` where `no` = 1');
$startYear = Util::toInt($game['startyear']);
diff --git a/twe/func_message.php b/twe/func_message.php
index 2cf6ab64..8b904a7e 100644
--- a/twe/func_message.php
+++ b/twe/func_message.php
@@ -1,5 +1,4 @@
queryFirstRow('select * from `message` where `id` = %i', $messageID);
+ $messageInfo = DB::db()->queryFirstRow('select * from `message` where `id` = %i', $messageID);
if (!$messageInfo) {
return [false, '존재하지 않는 메시지'];
@@ -67,7 +66,7 @@ function getRawMessage($mailbox, $msgType, $limit=30, $fromSeq=null){
}
//TODO: table 네임의 prefix를 처리할 수 있도록 개선
- $result = getDB()->query($sql, [
+ $result = DB::db()->query($sql, [
'mailbox' => $mailbox,
'type' => $msgType,
'limit' => $limit,
@@ -124,7 +123,7 @@ function sendRawMessage($msgType, $isSender, $mailbox, $src, $dest, $msg, $date,
if(!$isSender && $mailBox < 9000 && Util::array_get($msgOption['alert'], false)){
//TODO:newmsg보단 lastmsg로 datetime을 넣는게 더 나아보임
- getDB()->update('general', array(
+ DB::db()->update('general', array(
'newmsg' => true
), 'no=%i', $dest['id']);
}
@@ -133,7 +132,7 @@ function sendRawMessage($msgType, $isSender, $mailbox, $src, $dest, $msg, $date,
unset($msgOption['alert']);
}
- getDB()->insert('message', array(
+ DB::db()->insert('message', array(
'address' => $dest,
'type' => $msgType,
'is_sender' => $isSender,
@@ -231,7 +230,7 @@ function getMailboxList(){
$generalNations = [];
- foreach(getDB()->query('select `no`, `name`, `nation`, `level`, `npc` from `general` where `npc` < 2') as $general)
+ foreach(DB::db()->query('select `no`, `name`, `nation`, `level`, `npc` from `general` where `npc` < 2') as $general)
{
list($generalID, $generalName, $nationID, $level, $npc) = $general;
if(!isset($generalNations[$nationID])){
diff --git a/twe/func_npc.php b/twe/func_npc.php
index 4dadb0fa..7186befa 100644
--- a/twe/func_npc.php
+++ b/twe/func_npc.php
@@ -64,7 +64,7 @@ function RegGeneral($init,$life,$fiction,$turnterm,$startyear,$year,$gencount,$n
if($nation != 0 && $level == 0) $level = 1;
} elseif($year == $bornyear+14 && $year < $deadyear) {
- $count = getDB()->queryFirstField('SELECT count(`no`) from `general` where `name` = %s' , $name);
+ $count = DB::db()->queryFirstField('SELECT count(`no`) from `general` where `name` = %s' , $name);
if ($count == 0) {
$turntime = getRandTurn($turnterm);
if ($personal != "-") {
@@ -110,7 +110,7 @@ function RegGeneral($init,$life,$fiction,$turnterm,$startyear,$year,$gencount,$n
}
//장수
- getDB()->insert('general',[
+ DB::db()->insert('general',[
'npcid'=>$gencount,
'npc'=>$npc,
'npc_org'=>$npc,
@@ -1072,7 +1072,7 @@ function RegNation($name, $color, $gold, $rice, $scoutmsg, $tech, $gencount, $ty
$type = NationCharCall($type);
$totaltech = $tech * $gencount;
- getDB()->insert('nation', [
+ DB::db()->insert('nation', [
'name'=>$name,
'color'=>$color,
'gold'=>$gold,
@@ -1094,13 +1094,13 @@ function RegNation($name, $color, $gold, $rice, $scoutmsg, $tech, $gencount, $ty
function RegCity($nation, $name, $cap=0) {
$city = CityCall($name);
- getDB()->update('city', [
+ DB::db()->update('city', [
'nation'=>$nation,
'city'=>$city
]);
if($cap > 0){
- getDB()->update('nation', ['capital'=>city], 'nation = %i', $nation);
+ DB::db()->update('nation', ['capital'=>city], 'nation = %i', $nation);
}
refreshNationStaticInfo();
}
diff --git a/twe/func_process_personnel.php b/twe/func_process_personnel.php
index 4a3a218e..7a5bbf0f 100644
--- a/twe/func_process_personnel.php
+++ b/twe/func_process_personnel.php
@@ -775,7 +775,7 @@ function process_55($connect, &$general) {
$log[] = "●>{$admin['month']}월:재야가 된지 12시간이 지나야 합니다. 거병 실패. <1>$date>";
} else {
- getDB()->insert('nation', [
+ DB::db()->insert('nation', [
'name'=>$makename,
'color'=>'#330000',
'gold'=>0,
@@ -787,7 +787,7 @@ function process_55($connect, &$general) {
'type'=>0,
'gennum'=>1
]);
- $nationID = getDB()->insertId();
+ $nationID = DB::db()->insertId();
refreshNationStaticInfo();
$nation = getNationStaticInfo($nationID);
diff --git a/twe/func_template.php b/twe/func_template.php
index 907c56f3..a72b7eaa 100644
--- a/twe/func_template.php
+++ b/twe/func_template.php
@@ -68,7 +68,7 @@ function CoreTurnTable() {
function allButton() {
global $_basecolor2;
- $npcmode = getDB()->queryFirstField("select npcmode from game where no='1'");
+ $npcmode = DB::db()->queryFirstField("select npcmode from game where no='1'");
if($npcmode == 1) {
$site = "a_npcList.php";
$call = "빙의일람";
@@ -94,7 +94,7 @@ function commandButton() {
if($generalID === null){
return '';
}
- $db = getDB();
+ $db = DB::db();
$me = $db->queryFirstRow("select skin,no,nation,level,belong from general where no=%i", $generalID);
diff --git a/twe/index.php b/twe/index.php
index aef60c22..0fcb546c 100644
--- a/twe/index.php
+++ b/twe/index.php
@@ -9,7 +9,7 @@ $connect = dbConn();
increaseRefresh("메인", 2);
checkTurn($connect);
-$db = getDB();
+$db = DB::db();
//로그인 검사
if(!isSigned()){
diff --git a/twe/j_adjust_icon.php b/twe/j_adjust_icon.php
index 1b4c342e..a6adb548 100644
--- a/twe/j_adjust_icon.php
+++ b/twe/j_adjust_icon.php
@@ -22,8 +22,8 @@ if(!$generalID){
]);
}
-$rootDB = getRootDB();
-$db = getDB();
+$rootDB = RootDB::db();
+$db = DB::db();
$image = $rootDB->queryFirstRow('SELECT picture, imgsvr FROM `MEMBER` WHERE no = %i', $userID);
diff --git a/twe/j_basic_info.php b/twe/j_basic_info.php
index aeebd8f0..c9a7e4c2 100644
--- a/twe/j_basic_info.php
+++ b/twe/j_basic_info.php
@@ -17,7 +17,7 @@ if(!$generalID){
Json::die($result);
}
-$generalInfo = getDB()->queryFirstRow('SELECT `nation`, `level` from `general` where `id`=%i', $generalID);
+$generalInfo = DB::db()->queryFirstRow('SELECT `nation`, `level` from `general` where `id`=%i', $generalID);
if(!$generalInfo){
Json::die($result);
}
diff --git a/twe/j_build_conf.php b/twe/j_build_conf.php
index 4beb722a..6a7751f7 100644
--- a/twe/j_build_conf.php
+++ b/twe/j_build_conf.php
@@ -2,16 +2,15 @@
namespace sammo;
require(__dir__.'/../vendor/autoload.php');
-require(__dir__.'/../d_setting/conf.php');
/**
- * conf.php 파일 생성용 코드
+ * DB.php 파일 생성용 코드
*
* 이 파일만 예외적으로 lib.php, func.php를 참조하지 않고 독자적으로 동작함.
*/
-if(file_exist(__dir__.'/d_setting/conf.php')){
+if(file_exist(__dir__.'/d_setting/DB.php')){
Json::die([
'result'=>false,
'reason'=>'이미 설정 파일이 존재합니다.'
diff --git a/twe/j_drop_settings.php b/twe/j_drop_settings.php
index b26a3666..d71c131c 100644
--- a/twe/j_drop_settings.php
+++ b/twe/j_drop_settings.php
@@ -10,7 +10,7 @@ if(Session::getUserGrade(true) < 5){
-$db = getDB();
+$db = DB::db();
// 관리자 테이블 삭제
$db->query("DROP TABLE IF EXISTS game");
@@ -34,7 +34,7 @@ $db->query("DROP TABLE IF EXISTS statistic");
$db->query("DROP TABLE IF EXISTS history");
// 삭제
-unlink(__DIR__."/d_setting/conf.php");
+unlink(__DIR__."/d_setting/DB.php");
FileUtil::delInDir("logs");
FileUtil::delInDir("data/session");
diff --git a/twe/j_get_new_msg.php b/twe/j_get_new_msg.php
index 4989b6a0..9d95a543 100644
--- a/twe/j_get_new_msg.php
+++ b/twe/j_get_new_msg.php
@@ -15,7 +15,7 @@ $jsonPost = WebUtil::parseJsonPost();
$reqSequence = Util::toInt(Util::array_get($jsonPost['sequence'], 0));
-$nationID = getDB()->queryFirstField(
+$nationID = DB::db()->queryFirstField(
'select `nation` from `general` where no = %i',
$generalID
);
diff --git a/twe/j_init_settings.php b/twe/j_init_settings.php
index 7e292383..f1249c8e 100644
--- a/twe/j_init_settings.php
+++ b/twe/j_init_settings.php
@@ -11,12 +11,12 @@ if(Session::getUserGrade(true) < 5){
// 파일로 DB 정보 저장
-$file=@fopen("d_setting/conf.php","w") or Error("conf.php 파일 생성 실패
디렉토리의 퍼미션을 707로 주십시요","");
-//@fwrite($file,"
디렉토리의 퍼미션을 707로 주십시요","");
+$file=@fopen("d_setting/DB.php","w") or Error("DB.php 파일 생성 실패
디렉토리의 퍼미션을 707로 주십시요","");
+//@fwrite($file,"
디렉토리의 퍼미션을 707로 주십시요","");
@fclose($file);
@mkdir("data",0707);
@chmod("data",0707);
-//@chmod("d_setting/conf.php",0707);
+//@chmod("d_setting/DB.php",0707);
$temp=MYDB_fetch_array(MYDB_query("select count(*) from general where level = '1'", $connect));
diff --git a/twe/j_msg_decide_opt.php b/twe/j_msg_decide_opt.php
index 69fa8566..3d9ef856 100644
--- a/twe/j_msg_decide_opt.php
+++ b/twe/j_msg_decide_opt.php
@@ -32,7 +32,7 @@ if ($msgID === null || !is_bool($msgResponse)) {
}
-$general = getDB()->queryFirstRow('select `no`, `name`, `nation`, `nations`, `level`, `npc`, `gold`, `rice`, `troop` from `general` where `no` = %i', $generalID);
+$general = DB::db()->queryFirstRow('select `no`, `name`, `nation`, `nations`, `level`, `npc`, `gold`, `rice`, `troop` from `general` where `no` = %i', $generalID);
if(!$general){
Json::die([
'result'=>false,
diff --git a/twe/j_msgsubmit.php b/twe/j_msgsubmit.php
index cea2ea66..e9e5dd3c 100644
--- a/twe/j_msgsubmit.php
+++ b/twe/j_msgsubmit.php
@@ -41,7 +41,7 @@ if(!isSigned()){
}
-$db = getDB();
+$db = DB::db();
$connect = dbConn();
increaseRefresh('서신전달', 1);
diff --git a/twe/j_server_basic_info.php b/twe/j_server_basic_info.php
index ea2cfb3a..2f20fed5 100644
--- a/twe/j_server_basic_info.php
+++ b/twe/j_server_basic_info.php
@@ -57,7 +57,7 @@ function getTurnTerm($term) {
return $str;
}
-$db = getDB();
+$db = DB::db();
$game = $db->queryFirstRow('SELECT isUnited, npcMode, year, month, scenario, maxgeneral as maxUserCnt, turnTerm from game where `no`=1');
diff --git a/twe/join.php b/twe/join.php
index 7faca357..7b411def 100644
--- a/twe/join.php
+++ b/twe/join.php
@@ -14,7 +14,7 @@ if(!$userID) {
}
//회원 테이블에서 정보확인
-$member = getRootDB()->queryFirstRow("select no,name,picture,imgsvr,grade from MEMBER where no= %i", $userID);
+$member = RootDB::db()->queryFirstRow("select no,name,picture,imgsvr,grade from MEMBER where no= %i", $userID);
if(!$member) {
MessageBox("잘못된 접근입니다!!!");
diff --git a/twe/join_post.php b/twe/join_post.php
index ae8aed48..2511b1f0 100644
--- a/twe/join_post.php
+++ b/twe/join_post.php
@@ -27,7 +27,7 @@ if(!$userID) {
//회원 테이블에서 정보확인
-$member = getRootDB()->queryFirstRow("select no,id,picture,imgsvr,grade from MEMBER where no = %i", $userID);
+$member = RootDB::db()->queryFirstRow("select no,id,picture,imgsvr,grade from MEMBER where no = %i", $userID);
if(!$member) {
MessageBox("잘못된 접근입니다!!!");
@@ -37,10 +37,10 @@ if(!$member) {
$date = date('Y-m-d H:i:s');
//등록정보
-getRootDB()->query("update MEMBER set reg_num=reg_num+1,reg_date=%s where no=%i", $date, $userID);
+RootDB::db()->query("update MEMBER set reg_num=reg_num+1,reg_date=%s where no=%i", $date, $userID);
$connect = dbConn();
-$db = getDB();
+$db = DB::db();
########## 동일 정보 존재여부 확인. ##########
$admin = $db->queryFirstRow("select year,month,scenario,maxgeneral,turnterm,genius,img from game where no='1'");
diff --git a/twe/lib.php b/twe/lib.php
index 5e0f3021..785c4588 100644
--- a/twe/lib.php
+++ b/twe/lib.php
@@ -39,7 +39,6 @@ ini_set("session.cache_expire", 10080); // minutes
ob_start();
include "MYDB.php";
-require_once(__dir__.'/d_setting/conf.php');
// 각종 변수
define('STEP_LOG', true);
@@ -116,22 +115,13 @@ if($_SESSION['p_time']+3600 < time()) {
$_SESSION['p_time'] = time();
}
-/*
-// DB가 설정이 되었는지를 검사
-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']);
- exit;
-}
-*/
-
/**
* Session에 보관된 장수 정보를 제거함.
* _prefix_p_no, _prefix_p_name 두 값임
*/
function resetSessionGeneralValues(){
- $idKey = getServPrefix().'p_no';
- $nameKey = getServPrefix().'p_name';
+ $idKey = DB::prefix().'p_no';
+ $nameKey = DB::prefix().'p_name';
unset($_SESSION[$idKey]);
unset($_SESSION[$nameKey]);
@@ -140,9 +130,9 @@ function resetSessionGeneralValues(){
// MySQL 데이타 베이스에 접근
function dbConn($isRoot=false) {
if($isRoot){
- return getRootDB()->get();
+ return RootDB::db()->get();
}
- return getDB()->get();
+ return DB::db()->get();
}
// 에러 메세지 출력
@@ -156,7 +146,7 @@ function Error($message, $url="") {
// 게시판의 생성유무 검사
function isTable($connect, $str, $dbname='') {
if(!$dbname) {
- $f=@file("d_setting/conf.php") or Error("conf.php파일이 없습니다. DB설정을 먼저 하십시요");
+ $f=@file("d_setting/DB.php") or Error("DB.php파일이 없습니다. DB설정을 먼저 하십시요");
for($i=1;$i<=4;$i++) $f[$i]=str_replace("\n","",$f[$i]);
$dbname=$f[4];
}
diff --git a/twe/login_process.php b/twe/login_process.php
index baa0471b..fc400605 100644
--- a/twe/login_process.php
+++ b/twe/login_process.php
@@ -8,7 +8,7 @@ include "func.php";
-$db = getDB();
+$db = DB::db();
$userID = Session::getUserID();
@@ -37,8 +37,8 @@ case 3:
MessageBox("절대 1계정만 사용하십시오! {$me['killturn']}시간 후 재등록 가능합니다."); break;
}
-$_SESSION[getServPrefix().'p_no'] = Util::toInt($me['no']);
-$_SESSION[getServPrefix().'p_name'] = $me['name'];
+$_SESSION[DB::prefix().'p_no'] = Util::toInt($me['no']);
+$_SESSION[DB::prefix().'p_name'] = $me['name'];
$_SESSION['p_time'] = time();
$date = date('Y-m-d H:i:s');
diff --git a/twe/old/install.php b/twe/old/install.php
index 6019c113..3b0fb433 100644
--- a/twe/old/install.php
+++ b/twe/old/install.php
@@ -7,7 +7,7 @@ if(Session::getUserGrade(true) < 5){
die('관리자 아님');
}
-if(file_exists("d_setting/conf.php")) error("이미 conf.php가 생성되어 있습니다.
재설치하려면 해당 파일을 지우세요");
+if(file_exists("d_setting/DB.php")) error("이미 DB.php가 생성되어 있습니다.
재설치하려면 해당 파일을 지우세요");
@chmod(".",0707);
?>
diff --git a/twe/old/install1.php b/twe/old/install1.php
index 4b6d4cc3..59df4a06 100644
--- a/twe/old/install1.php
+++ b/twe/old/install1.php
@@ -7,7 +7,7 @@ if(Session::getUserGrade(true) < 5){
die('관리자 아님');
}
-if(file_exists("d_setting/conf.php")) error("이미 conf.php가 생성되어 있습니다.
재설치하려면 해당 파일을 지우세요");
+if(file_exists("d_setting/DB.php")) error("이미 DBD.php가 생성되어 있습니다.
재설치하려면 해당 파일을 지우세요");
?>
diff --git a/twe/old/j_old_install.php b/twe/old/j_old_install.php
index 4cd2a5b2..243aa66f 100644
--- a/twe/old/j_old_install.php
+++ b/twe/old/j_old_install.php
@@ -9,7 +9,7 @@ if(Session::getUserGrade(true) < 5){
die('관리자 아님');
}
-if(file_exists("d_setting/conf.php")) error("이미 conf.php가 생성되어 있습니다.
재설치하려면 해당 파일을 지우세요");
+if(file_exists("d_setting/DB.php")) error("이미 DB.php가 생성되어 있습니다.
재설치하려면 해당 파일을 지우세요");
$hostname = Util::array_get($_POST['hostname'], '');
@@ -103,7 +103,7 @@ if(!isTable($connect, "history",$dbname)) @MYDB_query($history_schema, $connect)
@mkdir("data",0707);
@chmod("data",0707);
-@chmod("d_setting/conf.php",0707);
+@chmod("d_setting/DB.php",0707);
$temp=MYDB_fetch_array(MYDB_query("select count(*) from general where level = '1'", $connect));
diff --git a/twe/old/j_old_install2.php b/twe/old/j_old_install2.php
index 8df3d9b0..0398b3c6 100644
--- a/twe/old/j_old_install2.php
+++ b/twe/old/j_old_install2.php
@@ -374,7 +374,7 @@ function insertCity($name, $level, $pop2, $agri2, $comm2, $secu2, $def2, $wall2,
case 8: $pop = 150000; $agri = 1000; $comm = 1000; $secu = 1000; $def = 5000; $wall = 5000; break;
}
- getDB()->insert('city',[
+ DB::db()->insert('city',[
'name'=>$name,
'level'=>$level,
'path'=>$path,
diff --git a/twe/reset.php b/twe/reset.php
index 241a71d3..88352a78 100644
--- a/twe/reset.php
+++ b/twe/reset.php
@@ -16,7 +16,7 @@ $connect = dbConn();
// 삭제
-unlink("d_setting/conf.php");
+unlink("d_setting/DB.php");
// DB에 커넥트 하고 DB NAME으로 select DB
$connect = @MYDB_connect($hostname,$user_id,$password) or Error("MySQL-DB Connect
Error!!!","");
@@ -77,12 +77,12 @@ if(!isTable($connect, "statistic",$dbname)) @MYDB_query($statistic_schema, $conn
if(!isTable($connect, "history",$dbname)) @MYDB_query($history_schema, $connect) or Error("create history ".MYDB_error($connect),"");
// 파일로 DB 정보 저장
-$file=@fopen("d_setting/conf.php","w") or Error("conf.php 파일 생성 실패
디렉토리의 퍼미션을 707로 주십시요","");
-@fwrite($file,"
디렉토리의 퍼미션을 707로 주십시요","");
+$file=@fopen("d_setting/DB.php","w") or Error("DB.php 파일 생성 실패
디렉토리의 퍼미션을 707로 주십시요","");
+@fwrite($file,"
디렉토리의 퍼미션을 707로 주십시요","");
@fclose($file);
@mkdir("data",0707);
@chmod("data",0707);
-@chmod("d_setting/conf.php",0707);
+@chmod("d_setting/DB.php",0707);
$temp=MYDB_fetch_array(MYDB_query("select count(*) from general where level = '1'", $connect));