che, che_close, che_rest 방식을 통합 디렉토리를 이용하도록 변경

This commit is contained in:
2018-01-15 01:08:32 +09:00
parent 922af0d2a1
commit 8fae0c2b5a
178 changed files with 227 additions and 33198 deletions
+32 -11
View File
@@ -27,24 +27,45 @@ $member = $DB->Get($rs);
function doServerModeSet($server, $select, &$reason){
global $_serverDirs;
$reason = '';
$serverDir = $_serverDirs[$server];
$serverPath = ROOT.W.$serverDir;
$realServerPath = realpath(dirname(__FILE__)).W.$serverPath;
if($select == 0) {
rename(realpath(dirname(__FILE__)).W.ROOT.W.$serverDir, realpath(dirname(__FILE__)).W.ROOT.W.$serverDir.'_close');
rename(realpath(dirname(__FILE__)).W.ROOT.W.$serverDir.'_rest', realpath(dirname(__FILE__)).W.ROOT.W.$serverDir);
if($select == 0) { //폐쇄
$templates = new Plates('templates');
//TODO: .htaccess가 서버 오픈에도 사용될 수 있으니 별도의 방법이 필요함
$allow_ip = util::get_client_ip(false);
if(util::starts_with($allow_ip, '192.168.') ||
util::starts_with($allow_ip, '10.'))
{
//172.16~172.31은 코딩하기 귀찮으니까 안할거다
$allow_ip = util::get_client_ip(true);
}
$xforward_allow_ip = escapeIPv4($allow_ip);
$htaccess = $templates->render('block_htaccess',
['allow_ip' => $allow_ip, 'xforward_allow_ip' => $xforward_allow_ip]);
file_put_contents($realServerPath.'/.htaccess', $htaccess);
$response['result'] = 'SUCCESS';
} elseif($select == 1) {
if(file_exists(realpath(dirname(__FILE__)).W.ROOT.W.$serverDir.'_close'.W.D_SETTING.W.SET.PHP)){
@unlink(realpath(dirname(__FILE__)).W.ROOT.W.$serverDir.'_close'.W.D_SETTING.W.SET.PHP);
} elseif($select == 1) {//리셋
if(file_exists($realServerPath.W.D_SETTING.W.SET.PHP)){
@unlink($realServerPath.W.D_SETTING.W.SET.PHP);
}
$response['installURL'] = ROOT.W."{$serverDir}_close/install.php";
$response['installURL'] = $serverPath.W."install.php";
$response['result'] = 'SUCCESS';
} elseif($select == 2) {
rename(realpath(dirname(__FILE__)).W.ROOT.W.$serverDir, realpath(dirname(__FILE__)).W.ROOT.W.$serverDir."_rest");
rename(realpath(dirname(__FILE__)).W.ROOT.W.$serverDir."_close", realpath(dirname(__FILE__)).W.ROOT.W.$serverDir);
} elseif($select == 2) {//오픈
if(file_exists($realServerPath.'.htaccess')){
@unlink($realServerPath.'.htaccess');
}
$response['result'] = 'SUCCESS';
}
return true;
}
function doAdminPost($member, $action, $notice, $server, $select){
@@ -63,7 +84,7 @@ function doAdminPost($member, $action, $notice, $server, $select){
if($action == 1) {
$reason = '';
if(doServerModeSet($server, $select)){
if(doServerModeSet($server, $select, $reason)){
$response['result'] = 'SUCCESS';
}
else{