imagePull 기능 추가, 인스톨러 완성
This commit is contained in:
@@ -98,6 +98,38 @@ require(__dir__.'/../vendor/autoload.php');
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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"
|
||||
placeholder="이미지 서버의 hook/HashKey.php의 값과 동일하게"
|
||||
value="" />
|
||||
<div class="input-group-append">
|
||||
<button id="btn_random_generate_key" class="btn btn-secondary" type="button">랜덤 생성</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr style="width:100%; border-top: 1px solid lightgray;">
|
||||
|
||||
<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"
|
||||
placeholder="카카오톡 API의 Rest Key"
|
||||
value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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"
|
||||
placeholder="카카오톡 API의 Admin Key"
|
||||
value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-4"></div>
|
||||
<div class="col-sm-8">
|
||||
|
||||
@@ -11,6 +11,7 @@ $dbName = Util::getReq('db_name');
|
||||
$servHost = Util::getReq('serv_host');
|
||||
$sharedIconPath = Util::getReq('shared_icon_path');
|
||||
$gameImagePath = Util::getReq('game_image_path');
|
||||
$imageRequestKey = Util::getReq('image_request_key');
|
||||
|
||||
$kakaoRESTKey = Util::getReq('kakao_rest_key', 'string', '');
|
||||
$kakaoAdminKey = Util::getReq('kakao_admin_key', 'string', '');
|
||||
@@ -190,6 +191,8 @@ $globalSalt = bin2hex(random_bytes(16));
|
||||
|
||||
$sharedIconPath = WebUtil::resolveRelativePath($sharedIconPath, $servHost);
|
||||
$gameImagePath = WebUtil::resolveRelativePath($gameImagePath, $servHost);
|
||||
$imageRequestPath = WebUtil::resolveRelativePath($gameImagePath.'/../hook/git_pull.php', $servHost);
|
||||
$imageKeyInstallPath = WebUtil::resolveRelativePath($gameImagePath.'/../hook/InstallKey.php', $servHost);
|
||||
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__dir__.'/templates/ServConfig.orig.php',
|
||||
@@ -197,11 +200,17 @@ $result = Util::generateFileUsingSimpleTemplate(
|
||||
[
|
||||
'serverBasePath'=>$servHost,
|
||||
'sharedIconPath'=>$sharedIconPath,
|
||||
'gameImagePath'=>$gameImagePath
|
||||
'gameImagePath'=>$gameImagePath,
|
||||
'imageRequestPath'=>$imageRequestPath,
|
||||
'imageRequestKey'=>$imageRequestKey
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
if($imageRequestKey){
|
||||
@file_get_contents($imageKeyInstallPath.'?key='.$imageRequestKey);
|
||||
}
|
||||
|
||||
if ($result !== true) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
@@ -267,7 +276,7 @@ $result = Util::generateFileUsingSimpleTemplate(
|
||||
]
|
||||
);
|
||||
|
||||
$kakaoRedirectURI = WebUtil::resolveRelativePath('oauth_kakao/oauth.php', $servHost);
|
||||
$kakaoRedirectURI = WebUtil::resolveRelativePath('oauth_kakao/oauth.php', $servHost.'/');
|
||||
|
||||
Util::generateFileUsingSimpleTemplate(
|
||||
__dir__.'/templates/KakaoKey.orig.php',
|
||||
|
||||
@@ -10,6 +10,8 @@ class ServConfig
|
||||
public static $serverWebPath = '_tK_serverBasePath_';
|
||||
public static $sharedIconPath = '_tK_sharedIconPath_';
|
||||
public static $gameImagePath = "_tK_gameImagePath_";
|
||||
public static $imageRequestPath = "_tK_imageRequestPath_";
|
||||
public static $imageRequestKey = '_tK_imageRequestKey_';
|
||||
|
||||
public static function getSharedIconPath(string $filepath='') : string
|
||||
{
|
||||
@@ -32,6 +34,13 @@ class ServConfig
|
||||
return static::$gameImagePath;
|
||||
}
|
||||
|
||||
public static function getImagePullURI() : string
|
||||
{
|
||||
$now = time();
|
||||
$req_hash = Util::hashPassword(sprintf("%016x",$now), static::$imageRequestKey);
|
||||
return static::$imageRequestPath."?req={$req_hash}&time={$now}";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 서버 주소 반환. 서버의 경로가 하부 디렉토리인 경우에 하부 디렉토리까지 포함
|
||||
|
||||
+32
-1
@@ -150,13 +150,44 @@ if($server == $baseServerName){
|
||||
'verionGit'=>$version
|
||||
], true
|
||||
);
|
||||
|
||||
if(ServConfig::$imageRequestKey){
|
||||
try {
|
||||
$imagePullPath = ServConfig::getImagePullURI();
|
||||
$pullResult = @file_get_contents($imagePullPath);
|
||||
if($pullResult === false){
|
||||
throw new \ErrorException('Invalid URI');
|
||||
}
|
||||
$pullResult = Json::decode($pullResult);
|
||||
if($pullResult['result']){
|
||||
$imgResult = true;
|
||||
$imgDetail = $pullResult['version'];
|
||||
}
|
||||
else{
|
||||
$imgResult = false;
|
||||
$imgDetail = $pullResult['reason'];
|
||||
}
|
||||
}
|
||||
catch(\Exception $e){
|
||||
$imgResult = false;
|
||||
$imgDetail = $e->getMessage();
|
||||
}
|
||||
}
|
||||
else{
|
||||
$imgResult = true;
|
||||
$imgDetail = 'No key';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$storage->$server = [$target, $version];
|
||||
|
||||
Json::die([
|
||||
'server'=>$server,
|
||||
'result'=>true,
|
||||
'version'=>$version
|
||||
'version'=>$version,
|
||||
'imgResult'=>$imgResult,
|
||||
'imgDetail'=>$imgDetail,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
+5
-1
@@ -64,7 +64,11 @@ function serverUpdate(caller){
|
||||
}
|
||||
}).then(function(response) {
|
||||
if(response.result) {
|
||||
alert('{0} 서버가 {1} 버전으로 업데이트 되었습니다.'.format(response.server, response.version));
|
||||
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);
|
||||
|
||||
+19
-2
@@ -47,6 +47,16 @@ $(document).ready( function () {
|
||||
$('#serv_host').val(
|
||||
[location.protocol, '//', location.host, parentPathname].join('')
|
||||
);
|
||||
|
||||
$('#btn_random_generate_key').click(function(){
|
||||
var token = '';
|
||||
while(token.length < 24){
|
||||
token += (Math.random() + 1).toString(36).substring(7);
|
||||
}
|
||||
token = token.substr(0,24);
|
||||
$('#image_request_key').val(token);
|
||||
});
|
||||
|
||||
$('#db_form').validate({
|
||||
rules:{
|
||||
db_host:"required",
|
||||
@@ -56,7 +66,11 @@ $(document).ready( function () {
|
||||
db_name:"required",
|
||||
serv_host:"required",
|
||||
shared_icon_path:"required",
|
||||
game_image_path:"required"
|
||||
game_image_path:"required",
|
||||
image_request_key:{
|
||||
required:false,
|
||||
minlength:16
|
||||
}
|
||||
},
|
||||
errorElement: "div",
|
||||
errorPlacement: function ( error, element ) {
|
||||
@@ -94,7 +108,10 @@ $(document).ready( function () {
|
||||
db_name:$('#db_name').val(),
|
||||
serv_host:$('#serv_host').val(),
|
||||
shared_icon_path:$('#shared_icon_path').val(),
|
||||
game_image_path:$('#game_image_path').val()
|
||||
game_image_path:$('#game_image_path').val(),
|
||||
image_request_key:$('#image_request_key').val(),
|
||||
kakao_rest_key:$('#kakao_rest_key').val(),
|
||||
kakao_admin_key:$('#kakao_admin_key').val(),
|
||||
}
|
||||
}).then(function(result){
|
||||
var deferred = $.Deferred();
|
||||
|
||||
Reference in New Issue
Block a user