루트DB를 관리하는 방식을 통째로 변경

- DB 불러오는 방식을 기존의 set.php에서 conf.php의 getRootDB()를 이용하도록 변경
- ADODB 에 기반한 _DB 클래스 폐기
- DBS.php 폐기
- _Setting 클래스 용도 변경
- 서버 목록 정의 방식을 하나로 모음
- 로그인시 세션에 사용자 등급을 추가
- "참여"(donation) 관련 코드 전면 제거
- 서버 리셋시 부운영자 비밀번호 문제 수정
- 서버 오픈,닫힘 여부를 새 서버 목록 정의 방식에 따르도록 수정
- DBS.php가 폐기 되었으므로 서버 오픈시 기본 정보를 json으로 받아오도록 하기 위하여 기본 준비
-  기존에 남아있던 세부 서버 로그인 처리 파일을 제거(enterPost.php)
- DBS.php 삭제로 전콘 변경시에도 각 서버로 json 호출을 하도록 하는 방식으로 준비
- 전콘을 수동으로 서버에 올린뒤 처리할 수 있도록 하던 legacy 코드 제거
- general 테이블에서 userlevel 컬럼을 삭제하고, 세션에 기록된 userGrade를 이용하도록 변경
- 벌점 제한을 모든 유저 공통으로 하도록 수정
- 세부 서버 리셋을 json ajax로 처리하도록 준비
This commit is contained in:
2018-03-07 00:59:31 +09:00
parent e8a9f73611
commit 0c9be5c53f
115 changed files with 1169 additions and 2217 deletions
-1
View File
@@ -1,6 +1,5 @@
<?php
require_once('_common.php');
require_once(ROOT.W.F_FUNC.W.'class._DB.php');
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
class _Chat {
-144
View File
@@ -1,144 +0,0 @@
<?php
require_once('_common.php');
class _DB {
private $objDB;
private $setting = 'none';
public function __construct($host, $id, $pw, $db) {
$this->objDB = ADONewConnection('mysqli'); // 예 'mysql' 또는 'postgres'
// $this->objDB->debug = true;
$this->objDB->debug = false;
$this->objDB->Connect($host, $id, $pw, $db) or Error('DB Connect() error: '.$db);
// 성능을 고려해 PConnect 조사
$this->objDB->SetFetchMode(ADODB_FETCH_ASSOC);
$this->objDB->Execute('set names utf8');
$this->setting = "{$host}//{$id}//{$db}";
}
public function GetSetting() {
return $this->setting;
}
public function QueryNoError($strQuery) {
return $this->objDB->Execute($strQuery);
}
public function Query($strQuery) {
$rs = $this->objDB->Execute($strQuery) or Error($strQuery);
return $rs;
}
public function Count($rs) {
if($rs == null) {
return 0;
}
return $rs->RecordCount();
}
public function HasNext($rs) {
return !$rs->EOF;
}
public function GetAll($rs) {
return $rs->GetRows();
}
public function Get($rs) {
return $rs->fields;
}
public function MoveNext($rs) {
$rs->MoveNext();
}
public function Next($rs) {
$obj = $rs->fields;
$rs->MoveNext();
return $obj;
}
public function Select($strFields, $strTable, $strCondition=NULL, $strGroupByField=NULL, $strHavingCondition=NULL) {
$strQuery = "SELECT {$strFields} FROM {$strTable}";
if($strCondition != NULL) {
$strQuery .= " WHERE {$strCondition}";
if($strGroupByField != NULL) {
$strQuery .= " GROUP BY {$strGroupByField}";
if($strHavingCondition != NULL) {
$strQuery .= " HAVING {$strHavingCondition}";
}
}
}
return $this->objDB->Execute($strQuery);
}
public function Insert($strTable, $strFields, $strValues) {
$strQuery = "INSERT INTO {$strTable} ({$strFields}) VALUES ({$strValues})";
$this->objDB->Execute($strQuery);
}
public function InsertArray($strTable, $arrVals) {
$arrFields = array();
$arrValues = array();
foreach($arrVals as $strKey => $strVal) {
$arrFields[] = $strKey;
$arrValues[] = $strVal;
}
$strFields = implode(',', $arrFields);
$strValues = implode("','", $arrValues);
$strValues = "'".$strValues."'";
$strQuery = "INSERT INTO {$strTable} ({$strFields}) VALUES ({$strValues})";
$this->objDB->Execute($strQuery);
}
public function Update($strTable, $strSetting, $strCondition=NULL) {
$strQuery = "UPDATE {$strTable} SET {$strSetting}";
if($strCondition != NULL) {
$strQuery .= " WHERE {$strCondition}";
}
$this->objDB->Execute($strQuery);
}
public function UpdateArray($strTable, $arrVals, $strCondition=NULL) {
$arrSetting = array();
foreach($arrVals as $strKey => $strVal) {
$arrSetting[] = "{$strKey}='{$strVal}'";
}
$strSetting = implode(',', $arrSetting);
$strQuery = "UPDATE {$strTable} SET {$strSetting}";
if($strCondition != NULL) {
$strQuery .= " WHERE {$strCondition}";
}
$this->objDB->Execute($strQuery);
}
public function Delete($strTable, $strCondition=NULL) {
$strQuery = "DELETE FROM {$strTable}";
if($strCondition != NULL) {
$strQuery .= " WHERE {$strCondition}";
}
$this->objDB->Execute($strQuery);
}
public function __destruct() {
$this->objDB->Close();
}
public function Qstr($str) {
return $this->objDB->qstr($str);
}
}
-2
View File
@@ -1,7 +1,5 @@
<?php
require_once('_common.php');
require_once(ROOT.W.F_FUNC.W.'class._DB.php');
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
class _Log {
+3 -3
View File
@@ -5,7 +5,7 @@ require_once(ROOT.W.F_FUNC.W.'class._Lock.php');
class _Process {
private static $mutexLog = false;
public static function ProcessingMutex($DB) {
public static function ProcessingMutex($db) {
// 어디선가 처리중이면 탈출
if(_Lock::Busy() == true) return false;
// 1명 외 접근 금지
@@ -14,7 +14,7 @@ class _Process {
_Process::MutexLog('뮤텍스 진입');
// 처리
_Process::Processing($DB);
_Process::Processing($db);
_Process::MutexLog('뮤텍스 탈출');
@@ -24,7 +24,7 @@ class _Process {
return true;
}
private static function Processing($DB) {
private static function Processing($db) {
}
private static function MutexLog($log) {
+2 -1
View File
@@ -24,11 +24,12 @@ class _Session {
return $_SESSION[$key];
}
public function Login($noMember, $idMember) {
public function Login($noMember, $idMember, $grade) {
$_SESSION['noMember'] = $noMember;
$_SESSION['p_id'] = $idMember;
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['time'] = time();
$_SESSION['userGrade'] = $grade;
}
public function Logout() {
+15 -60
View File
@@ -2,78 +2,33 @@
require_once('_common.php');
class _Setting {
private $basepath;
private $settingFile;
private $isExist = 0;
private $dbHost;
private $dbId;
private $dbPw;
private $dbName;
private $mailHost;
private $mailPort;
private $mailId;
private $mailPw;
private $mailAddr;
private $exist = 0;
public function __construct($filename) {
$this->settingFile = $filename;
public function __construct($basepath) {
$this->basepath = realpath($basepath);
$this->settingFile = realpath($basepath.D_SETTING.W.'conf.php');
if(file_exists($filename)) {
$this->isExist = 1;
$f = @file($filename);
$this->dbHost = trim(str_replace("\n", "", $f[1]));
$this->dbId = trim(str_replace("\n", "", $f[2]));
$this->dbPw = trim(str_replace("\n", "", $f[3]));
$this->dbName = trim(str_replace("\n", "", $f[4]));
if(count($f) > 10){
$this->mailHost = trim(str_replace("\n", "", $f[5]));
$this->mailPort = trim(str_replace("\n", "", $f[6]));
$this->mailId = trim(str_replace("\n", "", $f[7]));
$this->mailPw = trim(str_replace("\n", "", $f[8]));
$this->mailAddr = trim(str_replace("\n", "", $f[9]));
}
if(file_exists($this->settingFile)) {
$this->exist = 1;
}
}
public function IsExist() {
return $this->isExist;
public function isExist() {
return $this->exist;
}
public function DBHost() {
return $this->dbHost;
public function getShortName(){
return basename($this->basepath);
}
public function DBId() {
return $this->dbId;
public function getBasePath(){
return $this->basepath;
}
public function DBPw() {
return $this->dbPw;
}
public function DBName() {
return $this->dbName;
}
public function MailHost() {
return $this->mailHost;
}
public function MailPort() {
return $this->mailPort;
}
public function MailId() {
return $this->mailId;
}
public function MailPw() {
return $this->mailPw;
}
public function MailAddr() {
return $this->mailAddr;
public function getSettingFile() {
return $this->settingFile;
}
}