서버 post를 string으로.
This commit is contained in:
@@ -3,10 +3,10 @@ var serverAdminTemplate = '\
|
||||
<tr class="bg0" data-server_name="<%name%>">\
|
||||
<th style="color:<%color%>;"><%korName%>(<%name%>)</th>\
|
||||
<td><%status%></td>\
|
||||
<td><input class="with_skin obj_fill" type="button" value="폐쇄" onclick="Entrance_AdminPost(this, 0);"></td>\
|
||||
<td><input class="with_skin obj_fill" type="button" value="오픈" onclick="Entrance_AdminPost(this, 2);"></td>\
|
||||
<td><input class="with_skin obj_fill" type="button" value="리셋" onclick="Entrance_AdminPost(this, 1);"></td>\
|
||||
<td><input class="with_skin obj_fill" type="button" value="하드리셋" onclick="Entrance_AdminPost(this, 3);"></td>\
|
||||
<td><input class="with_skin obj_fill" type="button" value="폐쇄" onclick="modifyServerStatus(this, \'close\');"></td>\
|
||||
<td><input class="with_skin obj_fill" type="button" value="오픈" onclick="modifyServerStatus(this, \'open\');"></td>\
|
||||
<td><input class="with_skin obj_fill" type="button" value="리셋" onclick="modifyServerStatus(this, \'reset\');"></td>\
|
||||
<td><input class="with_skin obj_fill" type="button" value="하드리셋" onclick="modifyServerStatus(this, \'reset_full\');"></td>\
|
||||
<td><input class="with_skin obj_fill" type="button" value="폐쇄중 로그인" onclick="Entrance_AdminClosedLogin(this);"></td>\
|
||||
<td><input class="with_skin obj_fill" type="button" value="서버119" onclick="Entrance_AdminOpen119(this);"></td>\
|
||||
</tr>\
|
||||
@@ -79,7 +79,7 @@ function Entrance_AdminChangeNotice() {
|
||||
Popup_Wait(function() {
|
||||
PostJSON(
|
||||
HOME+I+ENTRANCE+W+ADMIN+POST, {
|
||||
action: 0,
|
||||
action: 'notice',
|
||||
notice: notice
|
||||
},
|
||||
function(response, textStatus) {
|
||||
@@ -94,7 +94,7 @@ function Entrance_AdminChangeNotice() {
|
||||
});
|
||||
}
|
||||
|
||||
function Entrance_AdminPost(caller, select) {
|
||||
function modifyServerStatus(caller, action) {
|
||||
var $caller = $(caller);
|
||||
var server = $caller.parents('tr').data('server_name');
|
||||
|
||||
@@ -102,14 +102,13 @@ function Entrance_AdminPost(caller, select) {
|
||||
Popup_Wait(function() {
|
||||
PostJSON(
|
||||
HOME+I+ENTRANCE+W+ADMIN+POST, {
|
||||
action: 1,
|
||||
server: server,
|
||||
select: select
|
||||
action: action
|
||||
},
|
||||
function(response, textStatus) {
|
||||
if(response.result == "SUCCESS") {
|
||||
Popup_WaitHide();
|
||||
if(select == 1) {
|
||||
if(action == 'reset') {
|
||||
ReplaceFrame(response.installURL);
|
||||
} else {
|
||||
Replace(ENTRANCE+PHP);
|
||||
|
||||
+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