forked from devsam/core
커맨드 유효성을 2개에서 3개구성으로 변경
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
require(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
session_start();
|
||||
session_destroy();
|
||||
@@ -10,24 +11,24 @@ $username = mb_strtolower(Util::getReq('username'), 'utf-8');
|
||||
$password = Util::getReq('password', 'string');
|
||||
$nickname = Util::getReq('nickname');
|
||||
|
||||
if(!$username || !$password || !$nickname){
|
||||
if (!$username || !$password || !$nickname) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'입력값이 설정되지 않았습니다.'
|
||||
'result' => false,
|
||||
'reason' => '입력값이 설정되지 않았습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if(strlen((string)$password)!=128){
|
||||
if (strlen((string) $password) != 128) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'올바르지 않은 비밀번호 해시 포맷입니다.'
|
||||
'result' => false,
|
||||
'reason' => '올바르지 않은 비밀번호 해시 포맷입니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if(!class_exists('\\sammo\\RootDB')){
|
||||
if (!class_exists('\\sammo\\RootDB')) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'DB 설정이 완료되지 않았습니다.'
|
||||
'result' => false,
|
||||
'reason' => 'DB 설정이 완료되지 않았습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -37,10 +38,10 @@ $rootDB = RootDB::db();
|
||||
$rootDB->query('LOCK TABLES member WRITE, member_log WRITE');
|
||||
|
||||
$memberCnt = $rootDB->queryFirstField('SELECT count(`NO`) from member');
|
||||
if($memberCnt > 0){
|
||||
if ($memberCnt > 0) {
|
||||
Json::die([
|
||||
'result'=>'false',
|
||||
'reason'=>'이미 계정이 생성되어 있습니다'
|
||||
'result' => 'false',
|
||||
'reason' => '이미 계정이 생성되어 있습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -48,32 +49,32 @@ $userSalt = bin2hex(random_bytes(8));
|
||||
$finalPassword = Util::hashPassword($userSalt, $password);
|
||||
$nowDate = TimeUtil::now();
|
||||
|
||||
$rootDB->insert('member',[
|
||||
$rootDB->insert('member', [
|
||||
'oauth_type' => 'NONE',
|
||||
'id' => $username,
|
||||
'email' => null,
|
||||
'token_valid_until'=>'2999-01-01 00:00:00',
|
||||
'token_valid_until' => '2999-01-01 00:00:00',
|
||||
'pw' => $finalPassword,
|
||||
'salt' => $userSalt,
|
||||
'grade'=> 6,
|
||||
'name'=>$nickname,
|
||||
'reg_date'=>$nowDate
|
||||
'grade' => 6,
|
||||
'name' => $nickname,
|
||||
'reg_date' => $nowDate
|
||||
]);
|
||||
$userID = $rootDB->insertId();
|
||||
|
||||
$rootDB->insert('member_log', [
|
||||
'member_no'=>$userID,
|
||||
'date'=>$nowDate,
|
||||
'action_type'=>'reg',
|
||||
'action'=>Json::encode([
|
||||
'type'=>'none',
|
||||
'aux'=>'admin',
|
||||
'id'=>$username,
|
||||
'name'=>$nickname
|
||||
'member_no' => $userID,
|
||||
'date' => $nowDate,
|
||||
'action_type' => 'reg',
|
||||
'action' => Json::encode([
|
||||
'type' => 'none',
|
||||
'aux' => 'admin',
|
||||
'id' => $username,
|
||||
'name' => $nickname
|
||||
])
|
||||
]);
|
||||
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'reason'=>'success'
|
||||
]);
|
||||
'result' => true,
|
||||
'reason' => 'success'
|
||||
]);
|
||||
|
||||
@@ -1,38 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
require(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
if(!class_exists('\\sammo\\RootDB')){
|
||||
if (!class_exists('\\sammo\\RootDB')) {
|
||||
Json::die([
|
||||
'step'=>'config'
|
||||
'step' => 'config'
|
||||
]);
|
||||
}
|
||||
|
||||
$rootDB = RootDB::db();
|
||||
|
||||
$rootDB->throw_exception_on_nonsql_error = false;
|
||||
$rootDB->nonsql_error_handler = function($params){
|
||||
$rootDB->nonsql_error_handler = function ($params) {
|
||||
Json::die([
|
||||
'step'=>'conn_fail'
|
||||
'step' => 'conn_fail'
|
||||
]);
|
||||
};
|
||||
|
||||
$rootDB->error_handler = function($params){
|
||||
$rootDB->error_handler = function ($params) {
|
||||
Json::die([
|
||||
'step'=>'sql_fail'
|
||||
'step' => 'sql_fail'
|
||||
]);
|
||||
};
|
||||
|
||||
$memberCnt = $rootDB->queryFirstField('SELECT count(`NO`) from member');
|
||||
if($memberCnt == 0){
|
||||
if ($memberCnt == 0) {
|
||||
Json::die([
|
||||
'step'=>'admin',
|
||||
'globalSalt'=>RootDB::getGlobalSalt()
|
||||
'step' => 'admin',
|
||||
'globalSalt' => RootDB::getGlobalSalt()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Json::die([
|
||||
'step'=>'done'
|
||||
]);
|
||||
'step' => 'done'
|
||||
]);
|
||||
|
||||
+102
-100
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
require(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
$host = Util::getReq('db_host');
|
||||
$port = Util::getReq('db_port', 'int');
|
||||
@@ -19,70 +20,71 @@ $kakaoAdminKey = Util::getReq('kakao_admin_key', 'string', '');
|
||||
|
||||
if (!$host || !$port || !$username || !$password || !$dbName || !$servHost || !$sharedIconPath || !$gameImagePath) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'입력 값이 올바르지 않습니다'
|
||||
'result' => false,
|
||||
'reason' => '입력 값이 올바르지 않습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!filter_var($servHost, FILTER_VALIDATE_URL)) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'접속 경로가 올바르지 않습니다.'
|
||||
'result' => false,
|
||||
'reason' => '접속 경로가 올바르지 않습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if (file_exists(ROOT.'/d_setting/RootDB.php') && is_dir(ROOT.'/d_setting/RootDB.php')) {
|
||||
if (file_exists(ROOT . '/d_setting/RootDB.php') && is_dir(ROOT . '/d_setting/RootDB.php')) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'d_setting/RootDB.php 가 디렉토리입니다'
|
||||
'result' => false,
|
||||
'reason' => 'd_setting/RootDB.php 가 디렉토리입니다'
|
||||
]);
|
||||
}
|
||||
|
||||
if (class_exists('\\sammo\\RootDB')) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'이미 RootDB.php 파일이 있습니다'
|
||||
'result' => false,
|
||||
'reason' => '이미 RootDB.php 파일이 있습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
//파일 권한 검사
|
||||
if (file_exists(AppConf::getUserIconPathFS()) && !is_dir(AppConf::getUserIconPathFS())) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>AppConf::$userIconPath.' 이 디렉토리가 아닙니다'
|
||||
'result' => false,
|
||||
'reason' => AppConf::$userIconPath . ' 이 디렉토리가 아닙니다'
|
||||
]);
|
||||
}
|
||||
|
||||
if (file_exists(ROOT.'/d_log') && !is_dir(ROOT.'/d_log')) {
|
||||
if (file_exists(ROOT . '/d_log') && !is_dir(ROOT . '/d_log')) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'d_log 가 디렉토리가 아닙니다'
|
||||
'result' => false,
|
||||
'reason' => 'd_log 가 디렉토리가 아닙니다'
|
||||
]);
|
||||
}
|
||||
|
||||
if (file_exists(ROOT.'/d_shared') && !is_dir(ROOT.'/d_shared')) {
|
||||
if (file_exists(ROOT . '/d_shared') && !is_dir(ROOT . '/d_shared')) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'d_shared 가 디렉토리가 아닙니다'
|
||||
'result' => false,
|
||||
'reason' => 'd_shared 가 디렉토리가 아닙니다'
|
||||
]);
|
||||
}
|
||||
|
||||
if (file_exists(ROOT.'/d_setting') && !is_dir(ROOT.'/d_setting')) {
|
||||
if (file_exists(ROOT . '/d_setting') && !is_dir(ROOT . '/d_setting')) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'d_shared 가 디렉토리가 아닙니다'
|
||||
'result' => false,
|
||||
'reason' => 'd_shared 가 디렉토리가 아닙니다'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!file_exists(ROOT.'/d_log')
|
||||
|| !file_exists(ROOT.'/d_shared')
|
||||
|| !file_exists(ROOT.'/d_setting')
|
||||
if (
|
||||
!file_exists(ROOT . '/d_log')
|
||||
|| !file_exists(ROOT . '/d_shared')
|
||||
|| !file_exists(ROOT . '/d_setting')
|
||||
|| !file_exists(AppConf::getUserIconPathFS())
|
||||
) {
|
||||
if (!is_writable(ROOT)) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'하위 디렉토리 생성 권한이 없습니다'
|
||||
'result' => false,
|
||||
'reason' => '하위 디렉토리 생성 권한이 없습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -91,56 +93,56 @@ if (!file_exists(ROOT.'/d_log')
|
||||
mkdir(AppConf::getUserIconPathFS());
|
||||
}
|
||||
|
||||
if (!file_exists(ROOT.'/d_log')) {
|
||||
mkdir(ROOT.'/d_log');
|
||||
if (!file_exists(ROOT . '/d_log')) {
|
||||
mkdir(ROOT . '/d_log');
|
||||
}
|
||||
|
||||
if (!file_exists(ROOT.'/d_setting')) {
|
||||
mkdir(ROOT.'/d_setting');
|
||||
if (!file_exists(ROOT . '/d_setting')) {
|
||||
mkdir(ROOT . '/d_setting');
|
||||
}
|
||||
|
||||
if (!file_exists(ROOT.'/d_shared')) {
|
||||
mkdir(ROOT.'/d_shared');
|
||||
if (!file_exists(ROOT . '/d_shared')) {
|
||||
mkdir(ROOT . '/d_shared');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!is_writable(AppConf::getUserIconPathFS())) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>AppConf::$userIconPath.' 디렉토리의 쓰기 권한이 없습니다'
|
||||
'result' => false,
|
||||
'reason' => AppConf::$userIconPath . ' 디렉토리의 쓰기 권한이 없습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!is_writable(ROOT.'/d_log')) {
|
||||
if (!is_writable(ROOT . '/d_log')) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'d_log 디렉토리의 쓰기 권한이 없습니다'
|
||||
'result' => false,
|
||||
'reason' => 'd_log 디렉토리의 쓰기 권한이 없습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!is_writable(ROOT.'/d_shared')) {
|
||||
if (!is_writable(ROOT . '/d_shared')) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'d_shared 디렉토리의 쓰기 권한이 없습니다'
|
||||
'result' => false,
|
||||
'reason' => 'd_shared 디렉토리의 쓰기 권한이 없습니다'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!is_writable(ROOT.'/d_setting')) {
|
||||
if (!is_writable(ROOT . '/d_setting')) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'d_setting 디렉토리의 쓰기 권한이 없습니다.'
|
||||
'result' => false,
|
||||
'reason' => 'd_setting 디렉토리의 쓰기 권한이 없습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!file_exists(ROOT.'/d_log/.htaccess')) {
|
||||
@file_put_contents(ROOT.'/d_log/.htaccess', 'Deny from all');
|
||||
if (!file_exists(ROOT . '/d_log/.htaccess')) {
|
||||
@file_put_contents(ROOT . '/d_log/.htaccess', 'Deny from all');
|
||||
}
|
||||
|
||||
if (!file_exists(ROOT.'/d_setting/.htaccess')) {
|
||||
@file_put_contents(ROOT.'/d_setting/.htaccess', 'Deny from all');
|
||||
if (!file_exists(ROOT . '/d_setting/.htaccess')) {
|
||||
@file_put_contents(ROOT . '/d_setting/.htaccess', 'Deny from all');
|
||||
}
|
||||
|
||||
//DB 접근 권한 검사
|
||||
@@ -151,21 +153,21 @@ $rootDB->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
|
||||
$rootDB->throw_exception_on_nonsql_error = false;
|
||||
$rootDB->nonsql_error_handler = function ($params) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'DB 접속에 실패했습니다.'
|
||||
'result' => false,
|
||||
'reason' => 'DB 접속에 실패했습니다.'
|
||||
]);
|
||||
};
|
||||
|
||||
$rootDB->error_handler = function ($params) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'SQL을 제대로 실행하지 못했습니다. DB상태를 확인해 주세요.'
|
||||
'result' => false,
|
||||
'reason' => 'SQL을 제대로 실행하지 못했습니다. DB상태를 확인해 주세요.'
|
||||
]);
|
||||
};
|
||||
|
||||
$mysqli_obj = $rootDB->get(); //로그인에 실패할 경우 자동으로 dbConnFail()이 실행됨.
|
||||
|
||||
if ($mysqli_obj->multi_query(file_get_contents(__DIR__.'/sql/common_schema.sql'))) {
|
||||
if ($mysqli_obj->multi_query(file_get_contents(__DIR__ . '/sql/common_schema.sql'))) {
|
||||
while (true) {
|
||||
if (!$mysqli_obj->more_results()) {
|
||||
break;
|
||||
@@ -191,113 +193,113 @@ $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);
|
||||
$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',
|
||||
ROOT.'/d_setting/ServConfig.php',
|
||||
__DIR__ . '/templates/ServConfig.orig.php',
|
||||
ROOT . '/d_setting/ServConfig.php',
|
||||
[
|
||||
'serverBasePath'=>$servHost,
|
||||
'sharedIconPath'=>$sharedIconPath,
|
||||
'gameImagePath'=>$gameImagePath,
|
||||
'imageRequestPath'=>$imageRequestPath,
|
||||
'imageRequestKey'=>$imageRequestKey
|
||||
'serverBasePath' => $servHost,
|
||||
'sharedIconPath' => $sharedIconPath,
|
||||
'gameImagePath' => $gameImagePath,
|
||||
'imageRequestPath' => $imageRequestPath,
|
||||
'imageRequestKey' => $imageRequestKey
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
if($imageRequestKey){
|
||||
@file_get_contents($imageKeyInstallPath.'?key='.$imageRequestKey);
|
||||
if ($imageRequestKey) {
|
||||
@file_get_contents($imageKeyInstallPath . '?key=' . $imageRequestKey);
|
||||
}
|
||||
|
||||
if ($result !== true) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>$result
|
||||
'result' => false,
|
||||
'reason' => $result
|
||||
]);
|
||||
}
|
||||
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__.'/templates/common_path.orig.js',
|
||||
ROOT.'/d_shared/common_path.js',
|
||||
__DIR__ . '/templates/common_path.orig.js',
|
||||
ROOT . '/d_shared/common_path.js',
|
||||
[
|
||||
'serverBasePath'=>$servHost,
|
||||
'sharedIconPath'=>$sharedIconPath,
|
||||
'gameImagePath'=>$gameImagePath
|
||||
'serverBasePath' => $servHost,
|
||||
'sharedIconPath' => $sharedIconPath,
|
||||
'gameImagePath' => $gameImagePath
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__.'/templates/menu.orig.json',
|
||||
ROOT.'/d_shared/menu.json',
|
||||
__DIR__ . '/templates/menu.orig.json',
|
||||
ROOT . '/d_shared/menu.json',
|
||||
[],
|
||||
true
|
||||
);
|
||||
|
||||
if ($result !== true) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>$result
|
||||
'result' => false,
|
||||
'reason' => $result
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__.'/templates/common.orig.css',
|
||||
ROOT.'/d_shared/common.css',
|
||||
__DIR__ . '/templates/common.orig.css',
|
||||
ROOT . '/d_shared/common.css',
|
||||
[
|
||||
'serverBasePath'=>$servHost,
|
||||
'sharedIconPath'=>$sharedIconPath,
|
||||
'gameImagePath'=>$gameImagePath
|
||||
'serverBasePath' => $servHost,
|
||||
'sharedIconPath' => $sharedIconPath,
|
||||
'gameImagePath' => $gameImagePath
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
if ($result !== true) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>$result
|
||||
'result' => false,
|
||||
'reason' => $result
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__.'/templates/RootDB.orig.php',
|
||||
ROOT.'/d_setting/RootDB.php',
|
||||
__DIR__ . '/templates/RootDB.orig.php',
|
||||
ROOT . '/d_setting/RootDB.php',
|
||||
[
|
||||
'host'=>$host,
|
||||
'user'=>$username,
|
||||
'password'=>$password,
|
||||
'dbName'=>$dbName,
|
||||
'port'=>$port,
|
||||
'globalSalt'=>$globalSalt,
|
||||
'host' => $host,
|
||||
'user' => $username,
|
||||
'password' => $password,
|
||||
'dbName' => $dbName,
|
||||
'port' => $port,
|
||||
'globalSalt' => $globalSalt,
|
||||
]
|
||||
);
|
||||
|
||||
$kakaoRedirectURI = WebUtil::resolveRelativePath('oauth_kakao/oauth.php', $servHost.'/');
|
||||
$kakaoRedirectURI = WebUtil::resolveRelativePath('oauth_kakao/oauth.php', $servHost . '/');
|
||||
|
||||
Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__.'/templates/KakaoKey.orig.php',
|
||||
ROOT.'/d_setting/KakaoKey.php',
|
||||
__DIR__ . '/templates/KakaoKey.orig.php',
|
||||
ROOT . '/d_setting/KakaoKey.php',
|
||||
[
|
||||
'REST_API_KEY'=>$kakaoRESTKey,
|
||||
'ADMIN_KEY'=>$kakaoAdminKey,
|
||||
'REDIRECT_URI'=>$kakaoRedirectURI
|
||||
'REST_API_KEY' => $kakaoRESTKey,
|
||||
'ADMIN_KEY' => $kakaoAdminKey,
|
||||
'REDIRECT_URI' => $kakaoRedirectURI
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
if ($result !== true) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>$result
|
||||
'result' => false,
|
||||
'reason' => $result
|
||||
]);
|
||||
}
|
||||
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'reason'=>'success',
|
||||
'globalSalt'=>$globalSalt
|
||||
'result' => true,
|
||||
'reason' => 'success',
|
||||
'globalSalt' => $globalSalt
|
||||
]);
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
require(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
$session = Session::requireLogin([])->setReadOnly();
|
||||
if($session->userGrade < 6){
|
||||
if ($session->userGrade < 6) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'관리자 아님'
|
||||
'result' => false,
|
||||
'reason' => '관리자 아님'
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -15,11 +16,11 @@ $servHost = Util::getReq('serv_host');
|
||||
$sharedIconPath = Util::getReq('shared_icon_path');
|
||||
$gameImagePath = Util::getReq('game_image_path');
|
||||
|
||||
if($servHost){
|
||||
if(!$sharedIconPath || $gameImagePath){
|
||||
if ($servHost) {
|
||||
if (!$sharedIconPath || $gameImagePath) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'serv_host가 지정된 경우, sharedIconPath와 gameImagePath가 모두 지정되어야합니다.'
|
||||
'result' => false,
|
||||
'reason' => 'serv_host가 지정된 경우, sharedIconPath와 gameImagePath가 모두 지정되어야합니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -27,58 +28,54 @@ if($servHost){
|
||||
$gameImagePath = WebUtil::resolveRelativePath($gameImagePath, $servHost);
|
||||
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__.'/templates/ServConfig.orig.php',
|
||||
ROOT.'/d_setting/ServConfig.php',
|
||||
__DIR__ . '/templates/ServConfig.orig.php',
|
||||
ROOT . '/d_setting/ServConfig.php',
|
||||
[
|
||||
'serverBasePath'=>$servHost,
|
||||
'sharedIconPath'=>$sharedIconPath,
|
||||
'gameImagePath'=>$gameImagePath
|
||||
'serverBasePath' => $servHost,
|
||||
'sharedIconPath' => $sharedIconPath,
|
||||
'gameImagePath' => $gameImagePath
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
if ($result !== true) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>$result
|
||||
'result' => false,
|
||||
'reason' => $result
|
||||
]);
|
||||
}
|
||||
}
|
||||
else if($sharedIconPath || $gameImagePath){
|
||||
} else if ($sharedIconPath || $gameImagePath) {
|
||||
$servHost = ServConfig::$serverWebPath;
|
||||
if($sharedIconPath){
|
||||
if ($sharedIconPath) {
|
||||
$sharedIconPath = WebUtil::resolveRelativePath($sharedIconPath, $servHost);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$sharedIconPath = ServConfig::$sharedIconPath;
|
||||
}
|
||||
|
||||
if($gameImagePath){
|
||||
if ($gameImagePath) {
|
||||
$gameImagePath = WebUtil::resolveRelativePath($gameImagePath, $servHost);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$gameImagePath = ServConfig::$gameImagePath;
|
||||
}
|
||||
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__.'/templates/ServConfig.orig.php',
|
||||
ROOT.'/d_setting/ServConfig.php',
|
||||
__DIR__ . '/templates/ServConfig.orig.php',
|
||||
ROOT . '/d_setting/ServConfig.php',
|
||||
[
|
||||
'serverBasePath'=>$servHost,
|
||||
'sharedIconPath'=>$sharedIconPath,
|
||||
'gameImagePath'=>$gameImagePath
|
||||
'serverBasePath' => $servHost,
|
||||
'sharedIconPath' => $sharedIconPath,
|
||||
'gameImagePath' => $gameImagePath
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
if ($result !== true) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>$result
|
||||
'result' => false,
|
||||
'reason' => $result
|
||||
]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$servHost = ServConfig::$serverWebPath;
|
||||
$sharedIconPath = ServConfig::$sharedIconPath;
|
||||
$gameImagePath = ServConfig::$gameImagePath;
|
||||
@@ -87,31 +84,31 @@ else{
|
||||
|
||||
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__.'/templates/common_path.orig.js',
|
||||
ROOT.'/d_shared/common_path.js',
|
||||
__DIR__ . '/templates/common_path.orig.js',
|
||||
ROOT . '/d_shared/common_path.js',
|
||||
[
|
||||
'serverBasePath'=>$servHost,
|
||||
'sharedIconPath'=>$sharedIconPath,
|
||||
'gameImagePath'=>$gameImagePath
|
||||
'serverBasePath' => $servHost,
|
||||
'sharedIconPath' => $sharedIconPath,
|
||||
'gameImagePath' => $gameImagePath
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
$result = Util::generateFileUsingSimpleTemplate(
|
||||
__DIR__.'/templates/common.orig.css',
|
||||
ROOT.'/d_shared/common.css',
|
||||
__DIR__ . '/templates/common.orig.css',
|
||||
ROOT . '/d_shared/common.css',
|
||||
[
|
||||
'serverBasePath'=>$servHost,
|
||||
'sharedIconPath'=>$sharedIconPath,
|
||||
'gameImagePath'=>$gameImagePath
|
||||
'serverBasePath' => $servHost,
|
||||
'sharedIconPath' => $sharedIconPath,
|
||||
'gameImagePath' => $gameImagePath
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
if ($result !== true) {
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>$result
|
||||
'result' => false,
|
||||
'reason' => $result
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
class RootDB
|
||||
@@ -30,7 +31,8 @@ class RootDB
|
||||
self::$uDB = new \MeekroDB(self::$host, self::$user, self::$password, self::$dbName, self::$port, self::$encoding);
|
||||
self::$uDB->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
|
||||
|
||||
self::$uDB->error_handler= function(){};
|
||||
self::$uDB->error_handler = function () {
|
||||
};
|
||||
self::$uDB->throw_exception_on_error = true;
|
||||
self::$uDB->throw_exception_on_nonsql_error = true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
class ServConfig
|
||||
@@ -13,32 +14,32 @@ class ServConfig
|
||||
public static $imageRequestPath = "_tK_imageRequestPath_";
|
||||
public static $imageRequestKey = '_tK_imageRequestKey_';
|
||||
|
||||
public static function getSharedIconPath(string $filepath='') : string
|
||||
public static function getSharedIconPath(string $filepath = ''): string
|
||||
{
|
||||
if($filepath){
|
||||
return static::$sharedIconPath."/{$filepath}";
|
||||
if ($filepath) {
|
||||
return static::$sharedIconPath . "/{$filepath}";
|
||||
}
|
||||
return static::$sharedIconPath;
|
||||
}
|
||||
|
||||
public static function getUserIconPath(string $filepath='') : string
|
||||
|
||||
public static function getUserIconPath(string $filepath = ''): string
|
||||
{
|
||||
return AppConf::getUserIconPathWeb($filepath);
|
||||
}
|
||||
|
||||
public static function getGameImagePath(string $filepath='') : string
|
||||
public static function getGameImagePath(string $filepath = ''): string
|
||||
{
|
||||
if($filepath){
|
||||
return static::$gameImagePath."/{$filepath}";
|
||||
if ($filepath) {
|
||||
return static::$gameImagePath . "/{$filepath}";
|
||||
}
|
||||
return static::$gameImagePath;
|
||||
}
|
||||
|
||||
public static function getImagePullURI() : string
|
||||
public static function getImagePullURI(): string
|
||||
{
|
||||
$now = time();
|
||||
$req_hash = Util::hashPassword(sprintf("%016x",$now), static::$imageRequestKey);
|
||||
return static::$imageRequestPath."?req={$req_hash}&time={$now}";
|
||||
$req_hash = Util::hashPassword(sprintf("%016x", $now), static::$imageRequestKey);
|
||||
return static::$imageRequestPath . "?req={$req_hash}&time={$now}";
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +48,8 @@ class ServConfig
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getServerBasepath() : string
|
||||
public static function getServerBasepath(): string
|
||||
{
|
||||
return self::$serverWebPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user