서버 post를 string으로.
This commit is contained in:
+13
-20
@@ -6,10 +6,9 @@ require_once(ROOT.'/f_config/SESSION.php');
|
||||
use utilphp\util as util;
|
||||
|
||||
// 외부 파라미터
|
||||
// $_POST['action'] : 0: 공지, 1: 서버
|
||||
// $_POST['action'] : 'notice', 'open', 'close', 'reset', 'reset_full'
|
||||
// $_POST['notice'] : 공지
|
||||
// $_POST['server'] : 서버 인덱스
|
||||
// $_POST['select'] : 0: 폐쇄, 1: 리셋, 2: 오픈
|
||||
|
||||
function escapeIPv4($ip){
|
||||
return str_replace('.', '\\.', $ip);
|
||||
@@ -18,13 +17,12 @@ function escapeIPv4($ip){
|
||||
$action = util::array_get($_POST['action'], '');
|
||||
$notice = util::array_get($_POST['notice'], '');
|
||||
$server = util::array_get($_POST['server'], '');
|
||||
$select = util::array_get($_POST['select'], '');
|
||||
|
||||
$db = getRootDB();
|
||||
|
||||
$member = $db->queryFirstRow('SELECT `GRADE` FROM `MEMBER` WHERE `NO` = %i', $SESSION->NoMember());
|
||||
|
||||
function doServerModeSet($server, $select, &$response){
|
||||
function doServerModeSet($server, $action, &$response){
|
||||
$serverList = getServerConfigList();
|
||||
$settingObj = $serverList[$server][2];
|
||||
|
||||
@@ -32,7 +30,7 @@ function doServerModeSet($server, $select, &$response){
|
||||
$serverPath = $settingObj->getBasePath();
|
||||
$realServerPath = realpath(dirname(__FILE__)).W.$serverPath;
|
||||
|
||||
if($select == 0) { //폐쇄
|
||||
if($action == 'close') { //폐쇄
|
||||
$templates = new League\Plates\Engine('templates');
|
||||
|
||||
//TODO: .htaccess가 서버 오픈에도 사용될 수 있으니 별도의 방법이 필요함
|
||||
@@ -49,21 +47,21 @@ function doServerModeSet($server, $select, &$response){
|
||||
$htaccess = $templates->render('block_htaccess',
|
||||
['allow_ip' => $allow_ip, 'xforward_allow_ip' => $xforward_allow_ip]);
|
||||
file_put_contents($serverPath.'/.htaccess', $htaccess);
|
||||
} elseif($select == 1) {//리셋
|
||||
} elseif($action == 'reset') {//리셋
|
||||
if(file_exists($serverPath.'/d_setting/conf.php')){
|
||||
@unlink($serverPath.'/d_setting/conf.php');
|
||||
}
|
||||
|
||||
$response['installURL'] = $serverDir.W."install.php";
|
||||
} elseif($select == 2) {//오픈
|
||||
if(file_exists($serverPath.'.htaccess')){
|
||||
@unlink($serverPath.'.htaccess');
|
||||
} elseif($action == 'open') {//오픈
|
||||
if(file_exists($serverPath.'/.htaccess')){
|
||||
@unlink($serverPath.'/.htaccess');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function doAdminPost($member, $action, $notice, $server, $select){
|
||||
function doAdminPost($member, $action, $notice, $server){
|
||||
$response['result'] = 'FAIL';
|
||||
if($member['GRADE'] < 6) {
|
||||
$response['result'] = 'FAIL';
|
||||
@@ -71,26 +69,21 @@ function doAdminPost($member, $action, $notice, $server, $select){
|
||||
return $response;
|
||||
}
|
||||
|
||||
if($action == 0) {
|
||||
if($action == 'notice') {
|
||||
getRootDB()->update('SYSTEM', ['NOTICE'=>$notice], 'NO=1');
|
||||
$response['result'] = 'SUCCESS';
|
||||
return $response;
|
||||
}
|
||||
|
||||
if($action == 1) {
|
||||
if(doServerModeSet($server, $select, $response)){
|
||||
$response['result'] = 'SUCCESS';
|
||||
}
|
||||
|
||||
if(doServerModeSet($server, $action, $response)){
|
||||
$response['result'] = 'SUCCESS';
|
||||
return $response;
|
||||
}
|
||||
|
||||
$response['result'] = 'FAIL';
|
||||
$response['msg'] = '알 수 없는 명령입니다.';
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
$response = doAdminPost($member, $action, $notice, $server, $select);
|
||||
$response = doAdminPost($member, $action, $notice, $server);
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
Reference in New Issue
Block a user