js2ts: entrance, webpack(entrance/dist_js)

This commit is contained in:
2021-08-26 01:25:58 +09:00
parent 5b2b01328a
commit 3b9884160b
21 changed files with 474 additions and 446 deletions
+2
View File
@@ -35,6 +35,8 @@ d_pic/uploaded_image
*/dist_js/*
*/dist_css/*
/dist_js/*
/dist_css/*
d_setting/*.php
*/d_setting/*.php
+21 -21
View File
@@ -12,8 +12,8 @@ require(__DIR__.'/../vendor/autoload.php');
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>설치</title>
<?=WebUtil::printJS('../d_shared/common_path.js') ?>
<?=WebUtil::printJS('../js/vendors.js') ?>
<?=WebUtil::printJS('../js/common.js') ?>
<?=WebUtil::printJS('../dist_js/vendors.js') ?>
<?=WebUtil::printJS('../dist_js/common.js') ?>
<?=WebUtil::printJS('../e_lib/jquery.validate.min.js')?>
<?=WebUtil::printJS('../e_lib/sha512.min.js')?>
<?=WebUtil::printJS('../js/install.js')?>
@@ -29,13 +29,13 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="card" id="db_form_card" style="display:none">
<h3 class="card-header">
설치(DB 설정)
</h3>
</h3>
<div class="card-body">
<form id="db_form" method="post" action="#">
<div class="form-group row">
<label for="db_host" class="col-sm-4 col-form-label">DB호스트</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="db_host" id="db_host"
<input type="text" class="form-control" name="db_host" id="db_host"
placeholder="호스트" value="localhost" />
</div>
</div>
@@ -43,11 +43,11 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="form-group row">
<label for="db_port" class="col-sm-4 col-form-label">DB포트</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="db_port" id="db_port"
<input type="text" class="form-control" name="db_port" id="db_port"
placeholder="접속 포트" value="3306" />
</div>
</div>
<div class="form-group row">
<label for="db_id" class="col-sm-4 col-form-label">DB계정명</label>
<div class="col-sm-8">
@@ -55,11 +55,11 @@ require(__DIR__.'/../vendor/autoload.php');
</div>
</div>
<div class="form-group row">
<label for="db_pw" class="col-sm-4 col-form-label">DB비밀번호</label>
<div class="col-sm-8">
<input type="password" class="form-control" name="db_pw" id="db_pw"
<input type="password" class="form-control" name="db_pw" id="db_pw"
placeholder="DB비밀번호"/>
</div>
</div>
@@ -67,7 +67,7 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="form-group row">
<label for="db_name" class="col-sm-4 col-form-label">DB명</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="db_name" id="db_name"
<input type="text" class="form-control" name="db_name" id="db_name"
placeholder="DB명(예:sammo)"/>
</div>
</div>
@@ -75,7 +75,7 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="form-group row">
<label for="serv_host" class="col-sm-4 col-form-label">접속 경로</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="serv_host" id="serv_host"
<input type="text" class="form-control" name="serv_host" id="serv_host"
placeholder="접속경로(예:http://www.example.com)"/>
</div>
</div>
@@ -83,7 +83,7 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="form-group row">
<label for="shared_icon_path" class="col-sm-4 col-form-label">공용 아이콘 주소</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="shared_icon_path" id="shared_icon_path"
<input type="text" class="form-control" name="shared_icon_path" id="shared_icon_path"
placeholder="공용 아이콘 주소(웹 주소, 또는 접속 경로에 따른 상대 주소)"
value="../image/icons" />
</div>
@@ -92,7 +92,7 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="form-group row">
<label for="game_image_path" class="col-sm-4 col-form-label">게임 이미지 주소</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="game_image_path" id="game_image_path"
<input type="text" class="form-control" name="game_image_path" id="game_image_path"
placeholder="게임 이미지 주소(웹 주소, 또는 접속 경로에 따른 상대 주소)"
value="../image/game" />
</div>
@@ -101,7 +101,7 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="form-group row">
<label for="image_request_key" class="col-sm-4 col-form-label">이미지 갱신 키</label>
<div class="input-group col-sm-8">
<input type="text" class="form-control" name="image_request_key" id="image_request_key"
<input type="text" class="form-control" name="image_request_key" id="image_request_key"
placeholder="이미지 서버의 hook/HashKey.php의 값과 동일하게"
value="" />
<div class="input-group-append">
@@ -115,7 +115,7 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="form-group row">
<label for="kakao_rest_key" class="col-sm-4 col-form-label">카카오 API Rest Key</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="kakao_rest_key" id="kakao_rest_key"
<input type="text" class="form-control" name="kakao_rest_key" id="kakao_rest_key"
placeholder="카카오톡 API의 Rest Key"
value="" />
</div>
@@ -124,7 +124,7 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="form-group row">
<label for="kakao_admin_key" class="col-sm-4 col-form-label">카카오 API Admin Key</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="kakao_admin_key" id="kakao_admin_key"
<input type="text" class="form-control" name="kakao_admin_key" id="kakao_admin_key"
placeholder="카카오톡 API의 Admin Key"
value="" />
</div>
@@ -133,7 +133,7 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="form-group row">
<div class="col-sm-4"></div>
<div class="col-sm-8">
<button type="submit"
<button type="submit"
class="btn btn-primary btn-lg btn-block login-button">설정 파일 생성</button>
</div>
</div>
@@ -144,7 +144,7 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="card" id="admin_form_card" style="display:none">
<h3 class="card-header">
설치(관리자 생성)
</h3>
</h3>
<div class="card-body">
<form id="admin_form" method="post" action="#">
<div class="form-group row">
@@ -155,11 +155,11 @@ require(__DIR__.'/../vendor/autoload.php');
</div>
</div>
<div class="form-group row">
<label for="password" class="col-sm-3 col-form-label">비밀번호</label>
<div class="col-sm-9">
<input type="password" class="form-control" name="password" id="password"
<input type="password" class="form-control" name="password" id="password"
placeholder="비밀번호"/>
</div>
</div>
@@ -167,7 +167,7 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="form-group row">
<label for="confirm_password" class="col-sm-3 col-form-label">비밀번호 확인</label>
<div class="col-sm-9">
<input type="password" class="form-control" name="confirm_password" id="confirm_password"
<input type="password" class="form-control" name="confirm_password" id="confirm_password"
placeholder="비밀번호 확인"/>
</div>
</div>
@@ -175,7 +175,7 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="form-group row">
<label for="nickname" class="col-sm-3 col-form-label">닉네임</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="nickname" id="nickname"
<input type="text" class="form-control" name="nickname" id="nickname"
placeholder="닉네임" value="운영자"/>
</div>
</div>
+2 -4
View File
@@ -1,6 +1,6 @@
import { unwrap } from "./util/unwrap";
import jQuery from "jquery";
import $ from "jquery";
import 'bootstrap';
import axios from "axios";
@@ -308,10 +308,8 @@ export function errUnknown(): void {
alert('작업을 실패했습니다.');
}
export function errUnknownToast(): void {
jQuery.toast({
$.toast({
title: '에러!',
content: '작업을 실패했습니다.',
type: 'danger',
+3 -3
View File
@@ -17,8 +17,8 @@ require(__DIR__.'/../vendor/autoload.php');
<?=WebUtil::printCSS('../css/admin_member.css')?>
<?=WebUtil::printJS('../d_shared/common_path.js') ?>
<?=WebUtil::printJS('../js/vendors.js') ?>
<?=WebUtil::printJS('../js/common.js') ?>
<?=WebUtil::printJS('../dist_js/vendors.js') ?>
<?=WebUtil::printJS('../dist_js/common.js') ?>
<?=WebUtil::printJS('../js/admin_member.js')?>
</head>
<body>
@@ -27,7 +27,7 @@ require(__DIR__.'/../vendor/autoload.php');
<div class="card-header">
<a href="entrance.php"><button type="button" class="btn btn-primary" style="float:right;">돌아가기</button></a>
<h3>회원 관리</h3>
</div>
<div class="card-body">
가입 허용&nbsp;
+6 -9
View File
@@ -28,18 +28,15 @@ $acl = $session->acl;
<?=WebUtil::printCSS('../d_shared/common.css')?>
<?=WebUtil::printCSS('../css/config.css')?>
<?=WebUtil::printCSS('../css/entrance.css')?>
<?=WebUtil::printCSS('../css/admin_server.css')?>
<!-- 액션 -->
<script>
var isAdmin = <?=($userGrade >= 5 || $acl)?'true':'false'?>;
</script>
<?=WebUtil::printJS('../d_shared/common_path.js') ?>
<?=WebUtil::printJS('../js/vendors.js') ?>
<?=WebUtil::printJS('../js/common.js') ?>
<?=WebUtil::printJS('../js/entrance.js')?>
<?php if ($userGrade >= 5 || $acl): ?>
<!-- 운영자 -->
<?=WebUtil::printCSS('../css/admin_server.css')?>
<?=WebUtil::printJS('../js/admin_server.js')?>
<?php endif; ?>
<?=WebUtil::printJS('../dist_js/vendors.js') ?>
<?=WebUtil::printJS('../dist_js/entrance.js')?>
</head>
<body>
+86 -53
View File
@@ -1,7 +1,8 @@
<?php
namespace sammo;
require(__DIR__.'/../vendor/autoload.php');
require(__DIR__ . '/../vendor/autoload.php');
WebUtil::requireAJAX();
@@ -23,93 +24,125 @@ $userGrade = $session->userGrade;
$acl = $session->acl;
$session->setReadOnly();
if($userGrade < 5 && !$acl) {
if ($userGrade < 5 && !$acl) {
Json::die([
'result'=>'FAIL',
'msg'=>'운영자 권한이 없습니다.'
'result' => false,
'reason' => '운영자 권한이 없습니다.'
]);
}
function doServerModeSet($server, $action, &$response, $session){
function doServerModeSet($server, $action, Session $session): array
{
$serverList = ServConfig::getServerList();
$settingObj = $serverList[$server];
$serverAcl = $session->acl[$server]??[];
$serverAcl = $session->acl[$server] ?? [];
$userGrade = $session->userGrade;
$serverDir = $settingObj->getShortName();
$serverPath = $settingObj->getBasePath();
$realServerPath = realpath(dirname(__FILE__)).'/'.$serverPath;
$realServerPath = realpath(dirname(__FILE__)) . '/' . $serverPath;
if($action == 'close') { //폐쇄
if ($action == 'close') { //폐쇄
$doClose = false;
if($userGrade >= 5){
if ($userGrade >= 5) {
$doClose = true;
}
else if(in_array('openClose', $serverAcl)){
} else if (in_array('openClose', $serverAcl)) {
$doClose = true;
}
if(!$doClose && in_array('reset', $serverAcl) && file_exists($serverPath.'/d_setting/DB.php')){
require($serverPath.'/lib.php');
if (!$doClose && in_array('reset', $serverAcl) && file_exists($serverPath . '/d_setting/DB.php')) {
require($serverPath . '/lib.php');
$localGameStorage = KVStorage::getStorage(DB::db(), 'game_env');
//천통 이후, 오픈 직후는 닫을 수 있음
$localGameStorage->cacheValues(['isunited', 'startyear', 'year']);
if($localGameStorage->isunited){
if ($localGameStorage->isunited) {
$doClose = true;
}
else if($localGameStorage->year < $localGameStorage->startyear + 2){
} else if ($localGameStorage->year < $localGameStorage->startyear + 2) {
$doClose = true;
} else{
return [
'result' => false,
'reason' => '서버 시작 직후, 또는 천하통일 이후에만 닫을 수 있습니다.'
];
}
}
if(!$doClose){
if(in_array('reset', $serverAcl)){
$response['msg'] = '서버 시작 직후, 또는 천하통일 이후에만 닫을 수 있습니다.';
}
else{
$response['msg'] = '서버 닫기 권한이 부족합니다.';
}
return false;
if (!$doClose) {
return [
'result' => false,
'reason' => '서버 닫기 권한이 부족합니다.'
];
}
return $settingObj->closeServer();
} elseif($action == 'reset' && $userGrade >= 6) {//리셋
//FIXME: reset, reset_full 구현
if(file_exists($serverPath.'/d_setting/DB.php')){
@unlink($serverPath.'/d_setting/DB.php');
if (!$settingObj->closeServer()) {
return [
'result' => false,
'reason' => '닫기 실패'
];
}
$response['installURL'] = $serverDir."/install.php";
} elseif($action == 'open' && ($userGrade >= 5 || in_array('openClose', $serverAcl))) {//오픈
return $settingObj->openServer();
} else{
$response['msg'] = '올바르지 않은 요청입니다';
return false;
return [
'result' => true,
'reason' => 'success'
];
}
return true;
if ($action == 'reset' && $userGrade >= 6) { //리셋
//FIXME: reset, reset_full 구현
if (file_exists($serverPath . '/d_setting/DB.php')) {
@unlink($serverPath . '/d_setting/DB.php');
}
return [
'result' => true,
'reason' => 'success',
'installURL' => $serverDir . "/install.php"
];
}
if ($action == 'open') { //오픈
if($userGrade < 5 && !in_array('openClose', $serverAcl)){
return [
'result' => false,
'reason' => '서버 열기 권한이 부족합니다.'
];
}
if (!$settingObj->openServer()) {
return [
'result' => false,
'reason' => '오픈 실패'
];
}
return [
'result' => true,
'reason' => 'success'
];
}
return [
'result' => false,
'reason' => '올바르지 않은 요청입니다'
];
}
function doAdminPost($action, $notice, $server, $session){
$response = ['result' => 'FAIL'];
function doAdminPost($action, $notice, $server, Session $session): array
{
$response = ['result' => false];
$globalAcl = $session->acl['global']??[];
$globalAcl = $session->acl['global'] ?? [];
$userGrade = $session->userGrade;
if($action == 'notice' && ($userGrade >= 5 || in_array('notice', $globalAcl))) {
RootDB::db()->update('system', ['NOTICE'=>$notice], true);
$response['result'] = 'SUCCESS';
return $response;
}
if(doServerModeSet($server, $action, $response, $session)){
$response['result'] = 'SUCCESS';
return $response;
if ($action == 'notice' && ($userGrade >= 5 || in_array('notice', $globalAcl))) {
RootDB::db()->update('system', ['NOTICE' => $notice], true);
return [
'result' => true,
'reason' => 'success',
];
}
return $response;
return doServerModeSet($server, $action, $session);
}
$response = doAdminPost($action, $notice, $server, $session);
+5 -5
View File
@@ -19,8 +19,8 @@ require(__DIR__.'/../vendor/autoload.php');
<!-- 액션 -->
<?=WebUtil::printJS('../d_shared/common_path.js') ?>
<?=WebUtil::printJS('../js/vendors.js') ?>
<?=WebUtil::printJS('../js/user_info.js')?>
<?=WebUtil::printJS('../dist_js/vendors.js') ?>
<?=WebUtil::printJS('../dist_js/user_info.js')?>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
@@ -141,8 +141,8 @@ require(__DIR__.'/../vendor/autoload.php');
<input type="file" id="image_upload" name="image_upload" accept=".jpg,.jpeg,.png,.gif"><br>
<input class="with_skin" id="btn_image_submit" type="submit" value="아이콘 변경"> <button id="btn_remove_icon" class="with_skin">아이콘 제거</button>
</form>
</td>
</tr>
</tbody>
@@ -170,7 +170,7 @@ require(__DIR__.'/../vendor/autoload.php');
</button>
</div>
<div class="modal-body">
<form id="chooseServerForm">
</form>
+2 -2
View File
@@ -48,8 +48,8 @@ foreach(ServConfig::getServerList() as $setting){
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>삼국지 모의전투 HiDCHe</title>
<?= WebUtil::printJS('d_shared/common_path.js') ?>
<?= WebUtil::printJS('js/vendors.js') ?>
<?= WebUtil::printJS('js/common.js') ?>
<?= WebUtil::printJS('dist_js/vendors.js') ?>
<?= WebUtil::printJS('dist_js/common.js') ?>
<?= WebUtil::printCSS('d_shared/common.css') ?>
<?= WebUtil::printCSS('e_lib/bootstrap.min.css') ?>
-263
View File
@@ -1,263 +0,0 @@
var serverAdminTemplate = '\
<tr class="bg0 server_admin_<%name%>" data-server_name="<%name%>" data-is_root="<%isRoot%>" data-git-path="<%lastGitPath%>">\
<th style="color:<%color%>;"><%korName%>(<%name%>)</th>\
<td><%status%></td>\
<td><%version%></td>\
<td><button type="button" class="serv_act_close with_skin valid_if_set with_border obj_fill" onclick="modifyServerStatus(this, \'close\');">폐쇄</button></td>\
<td><button type="button" class="serv_act_open with_skin valid_if_set with_border obj_fill" onclick="modifyServerStatus(this, \'open\');">오픈</button></td>\
<td><a class="just_link" href="../<%name%>/install.php"><button type="button" class="serv_act_reset with_skin valid_if_set with_border obj_fill">리셋</button></a></td>\
<td><a class="just_link" href="../<%name%>/install_db.php"><button type="button" class="serv_act_hard_reset with_skin valid_if_installed only_admin with_border obj_fill">하드리셋</button></a></td>\
<td><button type="button" class="serv_act_login_close with_skin valid_if_set with_border obj_fill" onclick="Entrance_AdminClosedLogin(this);">폐쇄중 로그인</button></td>\
<td><button type="button" class="serv_act_119 with_skin valid_if_set with_border obj_fill" onclick="Entrance_AdminOpen119(this);">서버119</button></td>\
<td><button type="button" class="serv_act_update with_skin with_border obj_fill" onclick="serverUpdate(this);">업데이트</button></td>\
</tr>\
';
function serverUpdate(caller){
var $caller = $(caller);
var $tr = $caller.parents('tr');
var server = $tr.data('server_name');
var isRoot = $tr.data('is_root');
var target = $tr.data('gitPath');
if(typeof isRoot !== 'boolean'){
isRoot = (isRoot != 'false');
};
var allowFullUpdate = (server in window.aclList && window.aclList[server].indexOf('fullUpdate')>=0);
allowFullUpdate |= window.adminGrade > 5;
var allowUpdate = (server in window.aclList && window.aclList[server].indexOf('update')>=0);
allowUpdate |= window.adminGrade >= 5;
allowUpdate |= allowFullUpdate;
if(!allowUpdate){
alert('권한이 없습니다!');
return;
}
if(allowFullUpdate){
target = prompt('가져올 git tree-ish 명을 입력해주세요.', target)
if(!target){
return;
}
}
else if(isRoot){
if(!confirm('서버 라이브러리, 루트 서버에 대해 git pull을 실행합니다.')){
return;
}
}
else if (!confirm('다음 git tree-ish 주소로 업데이트를 시도합니다 : ' + target)) {
return;
}
$.ajax({
type:'post',
url:'../j_updateServer.php',
dataType:'json',
data:{
server: server,
target: target
}
}).then(function(response) {
if(response.result) {
var aux = '';
if(isRoot){
aux = ' (이미지 서버 갱신:{0}, {1})'.format(response.imgResult, response.imgDetail);
}
alert('{0} 서버가 {1} 버전으로 업데이트 되었습니다.{2}'.format(response.server, response.version, aux));
location.reload();
} else {
alert(response.reason);
}
}
);
}
function drawServerAdminList(serverList){
var $table = $('#server_admin_list');
var $showErrorLog = $('#showErrorLog');
if(serverList.grade >= 5){
$showErrorLog.show();
}
$.each(serverList.server, function(idx, server){
console.log(server);
var status = '';
if(!server.valid){
status = '에러, {0}'.format(server.reason);
}
else if(!server.run){
status = '폐쇄됨';
}
else{
status = '운영 중';
}
server.status = status;
var $tr = $(TemplateEngine(serverAdminTemplate, server));
$table.append($tr);
if(serverList.grade < 4){
$tr.find('button').prop('disabled', true);
}
if(!server.valid){
$tr.find('.valid_if_set').prop('disabled', true);
}
if(!server.installed){
$tr.find('.valid_if_installed').prop('disabled', true);
}
var aclByServer = serverList.acl[server.name];
$.each(aclByServer, function(idx, action){
console.log(action);
if(action == 'update' || action == 'fullUpdate'){
if(!server.installed){
return true;
}
$tr.find('.serv_act_update').prop('disabled', false);
$showErrorLog.show();
}
else if(action == 'openClose'){
if(!server.valid){
return true;
}
$tr.find('.serv_act_open, .serv_act_close').prop('disabled', false);
}
else if(action == 'reset'){
if(!server.installed){
return true;
}
$tr.find('.serv_act_reset, .serv_act_close').prop('disabled', false);
}
});
});
window.adminGrade = serverList.grade;
window.aclList = serverList.acl;
if(serverList.grade <= 5){
$table.find('.only_admin').prop('disabled', true);
}
}
$(function(){
Entrance_AdminImport();
Entrance_AdminInit();
Entrance_AdminUpdate();
$.ajax({
cache:false,
type:'post',
url:'j_server_get_admin_status.php',
dataType:'json'
}).then(drawServerAdminList);
});
function Entrance_AdminImport() {
}
function Entrance_AdminInit() {
console.log('adminInit');
$("#Entrance_000201").click(Entrance_Donation);
$("#Entrance_000202").click(Entrance_Member);
$("#notice_change_btn").click(Entrance_AdminChangeNotice);
}
function Entrance_AdminUpdate() {
}
function Entrance_Donation() {
$("#Entrance_00").hide();
$("#EntranceDonation_00").show();
EntranceDonation_Update();
}
function Entrance_Member() {
$("#Entrance_00").hide();
$("#EntranceMember_00").show();
EntranceMember_Update();
}
function Entrance_AdminChangeNotice() {
var notice = $("#notice_edit").val();
if(!confirm('정말 실행하시겠습니까?')){
return;
}
$.ajax({
type:'post',
url:'j_server_change_status.php',
dataType:'json',
data:{
action: 'notice',
notice: notice
}
}).then(function(response){
if(response.result == "SUCCESS") {
location.reload();
} else {
alert(response.msg);
}
});
}
function modifyServerStatus(caller, action) {
var $caller = $(caller);
var server = $caller.parents('tr').data('server_name');
if(!confirm('정말 실행하시겠습니까?')){
return;
}
$.ajax({
type:'post',
url:'j_server_change_status.php',
dataType:'json',
data:{
server: server,
action: action
}
}).then(function(response) {
if(response.result == "SUCCESS") {
if(action == 'reset') {
location.href = response.installURL;
} else {
location.reload();
}
} else {
alert(response.msg);
}
}
);
}
function Entrance_AdminNPCLogin(caller) {
var $caller = $(caller);
var serverDir = $caller.parents('tr').data('server_name');
location.href = serverDir+"/npc_login.php";
}
function Entrance_AdminNPCCreate(caller) {
var $caller = $(caller);
var serverDir = $caller.parents('tr').data('server_name');
location.href = serverDir+"/npc_join.php";
}
function Entrance_AdminClosedLogin(caller) {
var $caller = $(caller);
var serverDir = $caller.parents('tr').data('server_name');
location.href = serverDir+"/npc_login.php";
}
function Entrance_AdminOpen119(caller) {
var $caller = $(caller);
var serverDir = $caller.parents('tr').data('server_name');
location.href = serverDir+"/_119.php";
}
function tryServerUpdateAndUpgrade(caller){
var $caller = $(caller);
}
-2
View File
File diff suppressed because one or more lines are too long
-1
View File
File diff suppressed because one or more lines are too long
-2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-3
View File
File diff suppressed because one or more lines are too long
-64
View File
@@ -1,64 +0,0 @@
/*
* [js-sha512]{@link https://github.com/emn178/js-sha512}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2018
* @license MIT
*/
/*!
* Bootstrap v4.6.0 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
/*!
* Sizzle CSS Selector Engine v2.3.6
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
*
* Date: 2021-02-16
*/
/*!
* jQuery JavaScript Library v3.6.0
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2021-03-02T17:08Z
*/
/**!
* @fileOverview Kickass library to create and place poppers near their reference elements.
* @version 1.16.1
* @license
* Copyright (c) 2016 Federico Zivolo and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
File diff suppressed because one or more lines are too long
+332
View File
@@ -0,0 +1,332 @@
import $ from 'jquery';
import axios from 'axios';
import { setAxiosXMLHttpRequest } from '../hwe/ts/util/setAxiosXMLHttpRequest';
import { InvalidResponse } from '../hwe/ts/defs';
import { convertFormData } from '../hwe/ts/util/convertFormData';
import { TemplateEngine } from '../hwe/ts/common_legacy';
import { unwrap_any } from '../hwe/ts/util/unwrap_any';
import { unwrap } from '../hwe/ts/util/unwrap';
type ServerUpdateResponse = {
result: true,
version: string,
server: string,
imgResult: false,
}
type ServerRootUpdateResponse = {
result: true,
version: string,
server: string,
imgResult: true,
imgDetail: string,
}
type ServerStateItem = {
name: string,
korName: string,
color: string,
isRoot: boolean,
lastGitPath: string,
valid: boolean,
run: boolean,
installed: boolean,
version: string,
reason: string,
status?: string,
}
type ServerStateResponse = {
acl: Record<string, string[]>,
server: ServerStateItem[],
grade: number,
}
type ServerChangeResponse = {
result: true,
installURL?: string,
}
const serverAdminTemplate = '\
<tr class="bg0 server_admin_<%name%>" data-server_name="<%name%>" data-is_root="<%isRoot%>" data-git-path="<%lastGitPath%>">\
<th style="color:<%color%>;"><%korName%>(<%name%>)</th>\
<td><%status%></td>\
<td><%version%></td>\
<td><button type="button" class="serv_act_close with_skin valid_if_set with_border obj_fill" onclick="modifyServerStatus(this, \'close\');">폐쇄</button></td>\
<td><button type="button" class="serv_act_open with_skin valid_if_set with_border obj_fill" onclick="modifyServerStatus(this, \'open\');">오픈</button></td>\
<td><a class="just_link" href="../<%name%>/install.php"><button type="button" class="serv_act_reset with_skin valid_if_set with_border obj_fill">리셋</button></a></td>\
<td><a class="just_link" href="../<%name%>/install_db.php"><button type="button" class="serv_act_hard_reset with_skin valid_if_installed only_admin with_border obj_fill">하드리셋</button></a></td>\
<td><button type="button" class="serv_act_login_close with_skin valid_if_set with_border obj_fill" onclick="Entrance_AdminClosedLogin(this);">폐쇄중 로그인</button></td>\
<td><button type="button" class="serv_act_119 with_skin valid_if_set with_border obj_fill" onclick="Entrance_AdminOpen119(this);">서버119</button></td>\
<td><button type="button" class="serv_act_update with_skin with_border obj_fill" onclick="serverUpdate(this);">업데이트</button></td>\
</tr>\
';//TODO: npm install 관련 기능 추가, js/css output 경로 변경
declare global {
interface Window {
modifyServerStatus: (caller: HTMLElement, action: string) => void;
Entrance_AdminClosedLogin: (caller: HTMLElement) => void;
Entrance_AdminOpen119: (caller: HTMLElement) => void;
serverUpdate: (caller: HTMLElement) => void;
adminGrade: number;
aclList: Record<string, string[]>;
}
}
async function serverUpdate(caller: HTMLElement) {
const $caller = $(caller);
const $tr = $caller.parents('tr');
const server = unwrap_any<string>($tr.data('server_name'));
let isRoot: string | boolean = unwrap_any<string>($tr.data('is_root'));
let target = $tr.data('gitPath');
if (typeof isRoot !== 'boolean') {
isRoot = (isRoot != 'false');
}
let allowFullUpdate = (server in window.aclList && window.aclList[server].indexOf('fullUpdate') >= 0);
allowFullUpdate = allowFullUpdate || window.adminGrade > 5;
let allowUpdate = (server in window.aclList && window.aclList[server].indexOf('update') >= 0);
allowUpdate = allowUpdate || window.adminGrade >= 5;
allowUpdate = allowUpdate || allowFullUpdate;
if (!allowUpdate) {
alert('권한이 없습니다!');
return;
}
if (allowFullUpdate) {
target = prompt('가져올 git tree-ish 명을 입력해주세요.', target)
if (!target) {
return;
}
}
else if (isRoot) {
if (!confirm('서버 라이브러리, 루트 서버에 대해 git pull을 실행합니다.')) {
return;
}
}
else if (!confirm('다음 git tree-ish 주소로 업데이트를 시도합니다 : ' + target)) {
return;
}
let result: InvalidResponse | ServerUpdateResponse | ServerRootUpdateResponse;
try {
const response = await axios({
url: '../j_updateServer.php',
responseType: 'json',
method: 'post',
data: convertFormData({
server: server,
target: target
})
});
result = response.data;
} catch (e) {
console.error(e);
alert(`에러: ${e}`);
location.reload();
return;
}
if (!result.result) {
alert(`실패했습니다: ${result.reason}`);
return;
}
let aux = '';
if (result.imgResult) {
aux = ` (이미지 서버 갱신:${result.imgResult}, ${result.imgDetail})`;
}
alert(`${result.server} 서버가 ${result.version} 버전으로 업데이트 되었습니다.${aux}`);
}
function drawServerAdminList(serverList: ServerStateResponse) {
const $table = $('#server_admin_list');
const $showErrorLog = $('#showErrorLog');
if (serverList.grade >= 5) {
$showErrorLog.show();
}
$.each(serverList.server, function (idx, server) {
console.log(server);
let status: string;
if (!server.valid) {
status = '에러, {0}'.format(server.reason);
}
else if (!server.run) {
status = '폐쇄됨';
}
else {
status = '운영 중';
}
server.status = status;
const $tr = $(TemplateEngine(serverAdminTemplate, server));
$table.append($tr);
if (serverList.grade < 4) {
$tr.find('button').prop('disabled', true);
}
if (!server.valid) {
$tr.find('.valid_if_set').prop('disabled', true);
}
if (!server.installed) {
$tr.find('.valid_if_installed').prop('disabled', true);
}
const aclByServer = serverList.acl[server.name];
$.each(aclByServer, function (idx, action) {
console.log(action);
if (action == 'update' || action == 'fullUpdate') {
if (!server.installed) {
return true;
}
$tr.find('.serv_act_update').prop('disabled', false);
$showErrorLog.show();
}
else if (action == 'openClose') {
if (!server.valid) {
return true;
}
$tr.find('.serv_act_open, .serv_act_close').prop('disabled', false);
}
else if (action == 'reset') {
if (!server.installed) {
return true;
}
$tr.find('.serv_act_reset, .serv_act_close').prop('disabled', false);
}
});
});
window.adminGrade = serverList.grade;
window.aclList = serverList.acl;
if (serverList.grade <= 5) {
$table.find('.only_admin').prop('disabled', true);
}
}
export async function loadPlugin(): Promise<void> {
setAxiosXMLHttpRequest();
Entrance_AdminInit();
window.modifyServerStatus = modifyServerStatus;
window.Entrance_AdminClosedLogin = Entrance_AdminClosedLogin;
window.Entrance_AdminOpen119 = Entrance_AdminOpen119;
window.serverUpdate = serverUpdate;
const response = await axios({
url: 'j_server_get_admin_status.php',
method: 'post',
responseType: 'json'
});
drawServerAdminList(response.data);
}
function Entrance_AdminInit() {
console.log('adminInit');
$("#Entrance_000202").on('click', Entrance_Member);
$("#notice_change_btn").on('click', Entrance_AdminChangeNotice);
}
function Entrance_Member(e: JQuery.Event) {
e.preventDefault();
$("#Entrance_00").hide();
$("#EntranceMember_00").show();
}
async function Entrance_AdminChangeNotice(e: JQuery.Event) {
e.preventDefault();
const notice = unwrap_any<string>($("#notice_edit").val());
if (!confirm('정말 실행하시겠습니까?')) {
return;
}
let result: InvalidResponse | ServerChangeResponse;
try {
const response = await axios({
url: 'j_server_change_status.php',
method: 'post',
responseType: 'json',
data: convertFormData({
action: 'notice',
notice: notice
})
});
result = response.data;
}
catch (e) {
console.error(e);
alert(`실패했습니다: ${e}`);
return;
}
if (!result.result) {
alert(`실패했습니다: ${result.reason}`);
return;
}
location.reload();
}
async function modifyServerStatus(caller: HTMLElement, action: string) {
const $caller = $(caller);
const server = unwrap_any<string>($caller.parents('tr').data('server_name'));
if (!confirm('정말 실행하시겠습니까?')) {
return;
}
let result: InvalidResponse | ServerChangeResponse;
try {
const response = await axios({
url: 'j_server_change_status.php',
method: 'post',
responseType: 'json',
data: convertFormData({
server: server,
action: action
})
});
result = response.data;
}
catch (e) {
console.error(e);
alert(`실패했습니다: ${e}`);
return;
}
if (!result.result) {
alert(`실패했습니다: ${result.reason}`);
return;
}
if (action == 'reset') {
location.href = unwrap(result.installURL);
} else {
location.reload();
}
}
function Entrance_AdminClosedLogin(caller: HTMLElement) {
const $caller = $(caller);
const serverDir = $caller.parents('tr').data('server_name');
location.href = serverDir + "/npc_login.php";
}
function Entrance_AdminOpen119(caller: HTMLElement) {
const $caller = $(caller);
const serverDir = $caller.parents('tr').data('server_name');
location.href = `../${serverDir}/_119.php`;
}
+13 -7
View File
@@ -1,9 +1,12 @@
import axios from 'axios';
import $ from 'jquery';
import { initTooltip, TemplateEngine } from '../hwe/ts/common_legacy';
import { InvalidResponse } from './defs';
import { InvalidResponse } from '../hwe/ts/defs';
import { getDateTimeNow } from '../hwe/ts/util/getDateTimeNow';
import { setAxiosXMLHttpRequest } from '../hwe/ts/util/setAxiosXMLHttpRequest';
import { loadPlugin as loadAdminPlugin } from './admin_server';
declare const isAdmin: boolean;
const serverListTemplate = "\
<tr class='server_item bg0 server_name_<%name%>' data-server='<%name%>'>\
@@ -163,6 +166,9 @@ $(function ($) {
setAxiosXMLHttpRequest();
$("#btn_logout").on('click', Entrance_Logout);
void Entrance_UpdateServer();
if(isAdmin){
void loadAdminPlugin();
}
});
async function Entrance_UpdateServer() {
@@ -240,19 +246,19 @@ async function Entrance_drawServerList(serverInfos: ServerResponseItem[]) {
if (game.isUnited == 3) {
$serverHtml.find('.n_country').html('§이벤트 종료§');
$serverHtml.find('.server_date').html('{0} <br>~ {1}'.format(game.starttime, game.turntime));
$serverHtml.find('.server_date').html(`${game.starttime} <br>~ ${game.turntime}`);
} else if (game.isUnited == 1) {
$serverHtml.find('.n_country').html('§이벤트 진행중§');
$serverHtml.find('.server_date').html('{0} ~'.format(game.starttime));
$serverHtml.find('.server_date').html(`${game.starttime} ~`);
} else if (game.isUnited == 2) {
$serverHtml.find('.n_country').html('§천하통일§');
$serverHtml.find('.server_date').html('{0} <br>~ {1}'.format(game.starttime, game.turntime));
$serverHtml.find('.server_date').html(`${game.starttime} <br>~ ${game.turntime}`);
} else if (game.opentime <= now) {
$serverHtml.find('.n_country').html('<{0}국 경쟁중>'.format(game.nationCnt));
$serverHtml.find('.server_date').html('{0} ~'.format(game.starttime));
$serverHtml.find('.n_country').html(`<${game.nationCnt}국 경쟁중>`);
$serverHtml.find('.server_date').html(`${game.starttime} ~`);
} else {
$serverHtml.find('.n_country').html('-가오픈 중-');
$serverHtml.find('.server_date').html('{0} ~'.format(game.starttime));
$serverHtml.find('.server_date').html(`${game.starttime} ~`);
}
if (game.opentime <= now) {
+2 -2
View File
@@ -118,7 +118,7 @@ module.exports = (env) => {
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'js'),
path: path.resolve(__dirname, 'dist_js'),
},
mode: 'production',
devtool: 'source-map',
@@ -176,7 +176,7 @@ module.exports = (env) => {
plugins: [
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: '../css/[name].css'
filename: '../dist_css/[name].css'
}),
//new BundleAnalyzerPlugin()
],