forked from devsam/core
getDB(), getRootDB()를 autoload 클래스로 변경
- 각각 DB::db(), RootDB::db()임.
This commit is contained in:
+4
-7
@@ -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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
namespace kakao;
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
class KakaoKey{
|
||||
const REST_KEY = '_tK_REST_API_KEY_';
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
class RootDB{
|
||||
private static $uDB = null;
|
||||
|
||||
private static $host = '_tK_host_';
|
||||
private static $user = '_tK_user_';
|
||||
private static $password = '_tK_password_';
|
||||
private static $dbName = '_tK_dbName_';
|
||||
private static $port = _tK_port_;
|
||||
private static $encoding = 'utf8';
|
||||
|
||||
private static $globalSalt = '_tK_globalSalt_';
|
||||
|
||||
private static $serverWebPath = '_tK_serverBasePath';
|
||||
|
||||
private function __construct(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DB 객체 생성
|
||||
*
|
||||
* @return \MeekroDB
|
||||
*/
|
||||
public static function db(){
|
||||
if(self::$uDB === null){
|
||||
self::$uDB = new \MeekroDB(self::$host,self::$user,self::$password,self::$dbName,self::$port,self::$encoding);
|
||||
self::$uDB->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;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
/**
|
||||
* 비밀번호 해시용 전역 SALT 반환
|
||||
* 비밀번호는 sha512(usersalt|sha512(globalsalt|password|globalsalt)|usersalt); 순임
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getGlobalSalt(){
|
||||
return '_tK_globalSalt_';
|
||||
}
|
||||
|
||||
/**
|
||||
* 서버 주소 반환. 서버의 경로가 하부 디렉토리인 경우에 하부 디렉토리까지 포함
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getServerBasepath(){
|
||||
return '_tK_serverBasePath_';
|
||||
}
|
||||
|
||||
/**
|
||||
* DB 객체 생성
|
||||
*
|
||||
* @return \MeekroDB
|
||||
*/
|
||||
function getRootDB(){
|
||||
$host = '_tK_host_';
|
||||
$user = '_tK_user_';
|
||||
$password = '_tK_password_';
|
||||
$dbName = '_tK_dbName_';
|
||||
$port = _tK_port_;
|
||||
$encoding = 'utf8';
|
||||
|
||||
static $uDB = null;
|
||||
|
||||
if($uDB === null){
|
||||
$uDB = new \MeekroDB($host,$user,$password,$dbName,$port,$encoding);
|
||||
$uDB->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
|
||||
}
|
||||
|
||||
return $uDB;
|
||||
}
|
||||
@@ -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');
|
||||
|
||||
@@ -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()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
?>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)',
|
||||
|
||||
@@ -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()
|
||||
]);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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'] .= '</table>';
|
||||
|
||||
$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']}";
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
require('d_setting/conf_kakao.php');
|
||||
require('_common.php');
|
||||
|
||||
if(!AppConf::getRoot()->isExists()){
|
||||
@@ -142,7 +141,7 @@ function postOAuthResult(result){
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="global_salt" name="global_salt" value="<?=getGlobalSalt()?>">
|
||||
<input type="hidden" id="global_salt" name="global_salt" value="<?=RootDB::getGlobalSalt()?>">
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-4" style="position:relative;"><a href="javascript:doLoginUsingOAuth(true);"><img style="height:46px;margin-top:6px;" src="oauth_kakao/kakao_btn.png"></a></div>
|
||||
<div class="col-sm-8">
|
||||
|
||||
+3
-3
@@ -21,7 +21,7 @@ if(!$username || !$password){
|
||||
]);
|
||||
}
|
||||
|
||||
$canLogin = getRootDB()->queryFirstField('SELECT `LOGIN` FROM `SYSTEM` WHERE `NO` = 1');
|
||||
$canLogin = RootDB::db()->queryFirstField('SELECT `LOGIN` FROM `SYSTEM` WHERE `NO` = 1');
|
||||
if($canLogin != 'Y'){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
@@ -29,7 +29,7 @@ if($canLogin != 'Y'){
|
||||
]);
|
||||
}
|
||||
|
||||
$userInfo = getRootDB()->queryFirstRow(
|
||||
$userInfo = RootDB::db()->queryFirstRow(
|
||||
'SELECT `no`, `id`, `name`, `grade`, `delete_after` '.
|
||||
'from member where id=%s_username AND '.
|
||||
'pw=sha2(concat(salt, %s_password, salt), 512)',[
|
||||
@@ -47,7 +47,7 @@ if(!$userInfo){
|
||||
$nowDate = TimeUtil::DatetimeNow();
|
||||
if($userInfo['delete_after']){
|
||||
if($userInfo['delete_after'] < $nowDate){
|
||||
getRootDB()->delete('member', 'no=%i', $userInfo['no']);
|
||||
RootDB::db()->delete('member', 'no=%i', $userInfo['no']);
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>"기간 만기로 삭제되었습니다. 재 가입을 시도해주세요."
|
||||
|
||||
+3
-3
@@ -26,13 +26,13 @@ function changeInstallMode(){
|
||||
if(result.step == 'conn_fail'){
|
||||
$('#db_form_card').hide();
|
||||
$('#admin_form_card').hide();
|
||||
alert('설치 이후 DB 설정이 변경된 것 같습니다. conf.php 파일의 설정을 확인해주십시오.');
|
||||
alert('설치 이후 DB 설정이 변경된 것 같습니다. RootDB.php 파일의 설정을 확인해주십시오.');
|
||||
return;
|
||||
}
|
||||
if(result.step == 'sql_fail'){
|
||||
$('#db_form_card').hide();
|
||||
$('#admin_form_card').hide();
|
||||
alert('DB가 제대로 설정되지 않았거나, 훼손된 것 같습니다. DB를 복구하거나 conf.php 파일을 삭제 후 재설치를 진행해 주십시오.');
|
||||
alert('DB가 제대로 설정되지 않았거나, 훼손된 것 같습니다. DB를 복구하거나 RootDB.php 파일을 삭제 후 재설치를 진행해 주십시오.');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ $(document).ready( function () {
|
||||
deferred.reject('fail');
|
||||
}
|
||||
else{
|
||||
alert('conf.php가 생성되었습니다. 관리자 계정 생성을 진행합니다.');
|
||||
alert('RootDB.php가 생성되었습니다. 관리자 계정 생성을 진행합니다.');
|
||||
deferred.resolve();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__.'/../d_setting/conf_kakao.php');
|
||||
use \kakao\KakaoKey as KakaoKey;
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__.'/../d_setting/conf_kakao.php');
|
||||
require('_common.php');
|
||||
require(ROOT.'/f_config/DB.php');
|
||||
|
||||
@@ -60,9 +59,9 @@ if($expires < $nowDate){
|
||||
}
|
||||
}
|
||||
|
||||
getRootDB()->query("lock tables member write, member_log write");
|
||||
RootDB::db()->query("lock tables member write, member_log write");
|
||||
|
||||
$isUser = getRootDB()->queryFirstRow(
|
||||
$isUser = RootDB::db()->queryFirstRow(
|
||||
'SELECT count(`no`) from member where no=%i',$userID);
|
||||
if(!$isUser){
|
||||
Json::die([
|
||||
@@ -72,7 +71,7 @@ if(!$isUser){
|
||||
}
|
||||
|
||||
$newPassword = Util::randomStr(6);
|
||||
$tmpPassword = Util::hashPassword(getGlobalSalt(), $newPassword);
|
||||
$tmpPassword = Util::hashPassword(RootDB::getGlobalSalt(), $newPassword);
|
||||
$newSalt = bin2hex(random_bytes(8));
|
||||
$newFinalPassword = Util::hashPassword($newSalt, $tmpPassword);
|
||||
|
||||
@@ -80,8 +79,8 @@ $sendResult = $restAPI->talk_to_me_default([
|
||||
"object_type"=> "text",
|
||||
"text"=> "임시 비밀번호는 $newPassword 입니다. 로그인 후 바로 다른 비밀번호로 변경해주세요.",
|
||||
"link"=> [
|
||||
"web_url"=> getServerBasepath(),
|
||||
"mobile_web_url" => getServerBasepath()
|
||||
"web_url"=> RootDB::getServerBasepath(),
|
||||
"mobile_web_url" => RootDB::getServerBasepath()
|
||||
],
|
||||
"button_title"=> "로그인 페이지 열기"
|
||||
]);
|
||||
@@ -93,12 +92,12 @@ if($sendResult['code'] < 0){
|
||||
]);
|
||||
}
|
||||
|
||||
getRootDB()->update('member', [
|
||||
RootDB::db()->update('member', [
|
||||
'pw'=>$newFinalPassword,
|
||||
'salt'=>$newSalt
|
||||
],'no=%i', $userID);
|
||||
|
||||
getRootDB()->insert('member_log', [
|
||||
RootDB::db()->insert('member_log', [
|
||||
'member_no'=>$userID,
|
||||
'date'=>$nowDate,
|
||||
'action_type'=>'change_pw',
|
||||
@@ -109,7 +108,7 @@ getRootDB()->insert('member_log', [
|
||||
], JSON_UNESCAPED_UNICODE)
|
||||
]);
|
||||
|
||||
getRootDB()->query("unlock tables");
|
||||
RootDB::db()->query("unlock tables");
|
||||
|
||||
|
||||
Json::die([
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__.'/../d_setting/conf_kakao.php');
|
||||
require_once('_common.php');
|
||||
require('lib.join.php');
|
||||
require('kakao.php');
|
||||
@@ -10,7 +9,7 @@ use \kakao\Kakao_REST_API_Helper as Kakao_REST_API_Helper;
|
||||
|
||||
session_start();
|
||||
|
||||
$canJoin = getRootDB()->queryFirstField('SELECT REG FROM `SYSTEM` WHERE `NO` = 1');
|
||||
$canJoin = RootDB::db()->queryFirstField('SELECT REG FROM `SYSTEM` WHERE `NO` = 1');
|
||||
if($canJoin != 'Y'){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
@@ -144,7 +143,7 @@ if($emailChk !== true){
|
||||
}
|
||||
|
||||
//모든 절차 종료. 등록.
|
||||
getRootDB()->insert('member',[
|
||||
RootDB::db()->insert('member',[
|
||||
'oauth_id' => $kakaoID,
|
||||
'oauth_type' => 'KAKAO',
|
||||
'id' => $username,
|
||||
@@ -154,9 +153,9 @@ getRootDB()->insert('member',[
|
||||
'name'=>$nickname,
|
||||
'reg_date'=>$nowDate
|
||||
]);
|
||||
$userID = getRootDB()->insertId();
|
||||
$userID = RootDB::db()->insertId();
|
||||
|
||||
getRootDB()->insert('member_log', [
|
||||
RootDB::db()->insert('member_log', [
|
||||
'member_no'=>$userID,
|
||||
'date'=>$nowDate,
|
||||
'action_type'=>'reg',
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__.'/../d_setting/conf_kakao.php');
|
||||
require('_common.php');
|
||||
require(ROOT.'/f_config/DB.php');
|
||||
require('kakao.php');
|
||||
@@ -13,7 +12,7 @@ if($session->isLoggedIn()){
|
||||
$session->logout();
|
||||
}
|
||||
|
||||
$canLogin = getRootDB()->queryFirstField('SELECT `LOGIN` FROM `SYSTEM` WHERE `NO` = 1');
|
||||
$canLogin = RootDB::db()->queryFirstField('SELECT `LOGIN` FROM `SYSTEM` WHERE `NO` = 1');
|
||||
if($canLogin != 'Y'){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
@@ -92,7 +91,7 @@ if(!$email){
|
||||
}
|
||||
|
||||
|
||||
$userInfo = getRootDB()->queryFirstRow(
|
||||
$userInfo = RootDB::db()->queryFirstRow(
|
||||
'SELECT `no`, `id`, `name`, `grade`, `delete_after` from member where email=%s',$email);
|
||||
|
||||
if(!$userInfo){
|
||||
@@ -108,7 +107,7 @@ if($userInfo['delete_after']){
|
||||
if($userInfo['delete_after'] < $nowDate){
|
||||
$restAPI->unlink();
|
||||
unset($_SESSION['access_token']);
|
||||
getRootDB()->delete('member', 'no=%i', $userInfo['no']);
|
||||
RootDB::db()->delete('member', 'no=%i', $userInfo['no']);
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>"기간 만기로 삭제되었습니다. 재 가입을 시도해주세요."
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
namespace sammo;
|
||||
|
||||
require('_common.php');
|
||||
require_once(__dir__.'/../d_setting/conf.php');
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +12,7 @@ if(!$access_token){
|
||||
header('Location:oauth_fail.html');
|
||||
}
|
||||
|
||||
$canJoin = getRootDB()->queryFirstField('SELECT REG FROM `SYSTEM` WHERE `NO` = 1');
|
||||
$canJoin = RootDB::db()->queryFirstField('SELECT REG FROM `SYSTEM` WHERE `NO` = 1');
|
||||
if($canJoin != 'Y'){
|
||||
die('현재는 가입이 금지되어있습니다!');
|
||||
}
|
||||
@@ -98,7 +97,7 @@ if($canJoin != 'Y'){
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="global_salt" name="global_salt" value="<?=getGlobalSalt()?>">
|
||||
<input type="hidden" id="global_salt" name="global_salt" value="<?=RootDB::getGlobalSalt()?>">
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-3"></div>
|
||||
<div class="col-sm-9">
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__.'/../d_setting/conf_kakao.php');
|
||||
require('_common.php');
|
||||
|
||||
use \kakao\Kakao_REST_API_Helper as Kakao_REST_API_Helper;
|
||||
|
||||
@@ -8,7 +8,7 @@ class Setting {
|
||||
|
||||
public function __construct($basepath = __DIR__.'/../..') {
|
||||
$this->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;
|
||||
|
||||
+23
-23
@@ -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)." 지급!"; }
|
||||
// 상대에게 발송
|
||||
|
||||
@@ -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:새 갠메 시스템으로 변경
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ if($me['skin'] < 1) {
|
||||
</table>
|
||||
<?php
|
||||
|
||||
$nationLevel = getDB()->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;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
class DB{
|
||||
private static $uDB = null;
|
||||
|
||||
private static $host = '_tK_host_';
|
||||
private static $user = '_tK_user_';
|
||||
private static $password = '_tK_password_';
|
||||
private static $dbName = '_tK_dbName_';
|
||||
private static $port = _tK_port_;
|
||||
private static $encoding = 'utf8';
|
||||
|
||||
private static $prefix = '_tK_prefix_';
|
||||
|
||||
private function __construct(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DB 객체 생성
|
||||
*
|
||||
* @return \MeekroDB
|
||||
*/
|
||||
public static function db(){
|
||||
if(self::$uDB === null){
|
||||
self::$uDB = new \MeekroDB(self::$host,self::$user,self::$password,self::$dbName,self::$port,self::$encoding);
|
||||
self::$uDB->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
|
||||
}
|
||||
return self::$uDB;
|
||||
}
|
||||
|
||||
public static function prefix()
|
||||
{
|
||||
return self::$prefix;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
require_once(__dir__.'/../../d_setting/conf.php');
|
||||
|
||||
/**
|
||||
* DB 객체 생성
|
||||
*
|
||||
* @return \MeekroDB
|
||||
*/
|
||||
function getDB(){
|
||||
$host = '_tK_host_';
|
||||
$user = '_tK_user_';
|
||||
$password = '_tK_password_';
|
||||
$dbName = '_tK_dbName_';
|
||||
$port = _tK_port_;
|
||||
$encoding = 'utf8';
|
||||
|
||||
static $uDB = null;
|
||||
|
||||
if($uDB === null){
|
||||
$uDB = new \MeekroDB($host,$user,$password,$dbName,$port,$encoding);
|
||||
$uDB->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
|
||||
}
|
||||
|
||||
return $uDB;
|
||||
}
|
||||
|
||||
function getServPrefix()
|
||||
{
|
||||
return '_tK_prefix_';
|
||||
}
|
||||
+16
-17
@@ -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.'<br>', $me['no']);
|
||||
}
|
||||
|
||||
function addNationHistory($nation, $history) {
|
||||
//FIXME: update 쿼리만으로도 구성 가능해보임.
|
||||
$nation['history'] = "{$nation['history']}{$history}<br>";
|
||||
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.'<br>', $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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
require_once(__dir__.'/d_setting/conf.php');
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
|
||||
@@ -7,7 +6,7 @@ require(__dir__.'/../vendor/autoload.php');
|
||||
function checkScoutAvailable($messageInfo, $general, $srcGeneral, $startyear, $year){
|
||||
$nationID = $messageInfo['src']['nationID'];
|
||||
|
||||
$srcNation = getDB()->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']]);
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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']);
|
||||
|
||||
|
||||
+2
-2
@@ -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']);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
require_once(__dir__.'/d_setting/conf.php');
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
|
||||
@@ -45,7 +44,7 @@ class Message{
|
||||
}
|
||||
|
||||
function getSingleMessage($messageID){
|
||||
$messageInfo = getDB()->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])){
|
||||
|
||||
+5
-5
@@ -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();
|
||||
}
|
||||
|
||||
@@ -775,7 +775,7 @@ function process_55($connect, &$general) {
|
||||
$log[] = "<C>●</>{$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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ $connect = dbConn();
|
||||
increaseRefresh("메인", 2);
|
||||
checkTurn($connect);
|
||||
|
||||
$db = getDB();
|
||||
$db = DB::db();
|
||||
|
||||
//로그인 검사
|
||||
if(!isSigned()){
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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'=>'이미 설정 파일이 존재합니다.'
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -11,12 +11,12 @@ if(Session::getUserGrade(true) < 5){
|
||||
|
||||
|
||||
// 파일로 DB 정보 저장
|
||||
$file=@fopen("d_setting/conf.php","w") or Error("conf.php 파일 생성 실패<br><br>디렉토리의 퍼미션을 707로 주십시요","");
|
||||
//@fwrite($file,"<?php /*\n$hostname\n$user_id\n$password\n$dbname\n */\n") or Error("conf.php 파일 생성 실패<br><br>디렉토리의 퍼미션을 707로 주십시요","");
|
||||
$file=@fopen("d_setting/DB.php","w") or Error("DB.php 파일 생성 실패<br><br>디렉토리의 퍼미션을 707로 주십시요","");
|
||||
//@fwrite($file,"<?php /*\n$hostname\n$user_id\n$password\n$dbname\n */\n") or Error("DB.php 파일 생성 실패<br><br>디렉토리의 퍼미션을 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));
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ if(!isSigned()){
|
||||
}
|
||||
|
||||
|
||||
$db = getDB();
|
||||
$db = DB::db();
|
||||
|
||||
$connect = dbConn();
|
||||
increaseRefresh('서신전달', 1);
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
+1
-1
@@ -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("잘못된 접근입니다!!!");
|
||||
|
||||
+3
-3
@@ -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'");
|
||||
|
||||
+5
-15
@@ -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"<meta http-equiv=refresh content='0;url=../'>";
|
||||
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];
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ if(Session::getUserGrade(true) < 5){
|
||||
die('관리자 아님');
|
||||
}
|
||||
|
||||
if(file_exists("d_setting/conf.php")) error("이미 conf.php가 생성되어 있습니다.<br><br>재설치하려면 해당 파일을 지우세요");
|
||||
if(file_exists("d_setting/DB.php")) error("이미 DB.php가 생성되어 있습니다.<br><br>재설치하려면 해당 파일을 지우세요");
|
||||
|
||||
@chmod(".",0707);
|
||||
?>
|
||||
|
||||
@@ -7,7 +7,7 @@ if(Session::getUserGrade(true) < 5){
|
||||
die('관리자 아님');
|
||||
}
|
||||
|
||||
if(file_exists("d_setting/conf.php")) error("이미 conf.php가 생성되어 있습니다.<br><br>재설치하려면 해당 파일을 지우세요");
|
||||
if(file_exists("d_setting/DB.php")) error("이미 DBD.php가 생성되어 있습니다.<br><br>재설치하려면 해당 파일을 지우세요");
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
@@ -9,7 +9,7 @@ if(Session::getUserGrade(true) < 5){
|
||||
die('관리자 아님');
|
||||
}
|
||||
|
||||
if(file_exists("d_setting/conf.php")) error("이미 conf.php가 생성되어 있습니다.<br><br>재설치하려면 해당 파일을 지우세요");
|
||||
if(file_exists("d_setting/DB.php")) error("이미 DB.php가 생성되어 있습니다.<br><br>재설치하려면 해당 파일을 지우세요");
|
||||
|
||||
|
||||
$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));
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
+4
-4
@@ -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<br>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 파일 생성 실패<br><br>디렉토리의 퍼미션을 707로 주십시요","");
|
||||
@fwrite($file,"<?php /*\n$hostname\n$user_id\n$password\n$dbname\n */\n") or Error("conf.php 파일 생성 실패<br><br>디렉토리의 퍼미션을 707로 주십시요","");
|
||||
$file=@fopen("d_setting/DB.php","w") or Error("DB.php 파일 생성 실패<br><br>디렉토리의 퍼미션을 707로 주십시요","");
|
||||
@fwrite($file,"<?php /*\n$hostname\n$user_id\n$password\n$dbname\n */\n") or Error("DB.php 파일 생성 실패<br><br>디렉토리의 퍼미션을 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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user