forked from devsam/core
_Setting, _String, _Time 클래스 재 명명
- autoload로 변환
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
namespace sammo;
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(__DIR__.'/../f_func/class._Setting.php');
|
||||
|
||||
$SETTING = new _Setting(__DIR__.'/..');
|
||||
$SETTING = new Setting(__DIR__.'/..');
|
||||
|
||||
|
||||
|
||||
+6
-6
@@ -2,7 +2,7 @@
|
||||
namespace sammo;
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.'/f_func/class._Setting.php');
|
||||
require_once(ROOT.'/f_func/class.Setting.php');
|
||||
|
||||
|
||||
function getServerConfigList(){
|
||||
@@ -11,11 +11,11 @@ function getServerConfigList(){
|
||||
return $serverList;
|
||||
}
|
||||
$serverList = [
|
||||
'che'=>['체', 'white', new _Setting(__DIR__.'/../che')],
|
||||
'kwe'=>['퀘', 'yellow', new _Setting(__DIR__.'/../kwe')],
|
||||
'pwe'=>['풰', 'orange', new _Setting(__DIR__.'/../pwe')],
|
||||
'twe'=>['퉤', 'magenta', new _Setting(__DIR__.'/../twe')],
|
||||
'hwe'=>['훼', 'red', new _Setting(__DIR__.'/../hwe')]
|
||||
'che'=>['체', 'white', new Setting(__DIR__.'/../che')],
|
||||
'kwe'=>['퀘', 'yellow', new Setting(__DIR__.'/../kwe')],
|
||||
'pwe'=>['풰', 'orange', new Setting(__DIR__.'/../pwe')],
|
||||
'twe'=>['퉤', 'magenta', new Setting(__DIR__.'/../twe')],
|
||||
'hwe'=>['훼', 'red', new Setting(__DIR__.'/../hwe')]
|
||||
];
|
||||
return $serverList;
|
||||
}
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
ob_start();
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
define('__LINE__',__FILE__." ".__FUNCTION__." ".__LINE__." : ");
|
||||
ob_start();
|
||||
|
||||
|
||||
define('IMAGE', '../../image');
|
||||
define('IMAGES', '../../images');
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
namespace sammo;
|
||||
|
||||
require('_common.php');
|
||||
require(ROOT.'/f_func/class._Time.php');
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace sammo;
|
||||
|
||||
require('_common.php');
|
||||
require(__DIR__.'/../f_config/SETTING.php');
|
||||
require(ROOT.'/f_func/class._Time.php');
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +51,7 @@ if($memberCnt > 0){
|
||||
|
||||
$userSalt = bin2hex(random_bytes(8));
|
||||
$finalPassword = hashPassword($userSalt, $password);
|
||||
$nowDate = _Time::DatetimeNow();
|
||||
$nowDate = TimeUtil::DatetimeNow();
|
||||
|
||||
$rootDB->insert('member',[
|
||||
'oauth_type' => 'NONE',
|
||||
|
||||
@@ -3,7 +3,6 @@ namespace sammo;
|
||||
|
||||
require('_common.php');
|
||||
require(__DIR__.'/../f_config/SETTING.php');
|
||||
require(__DIR__.'/../f_func/class._Time.php');
|
||||
|
||||
|
||||
|
||||
@@ -136,8 +135,8 @@ if($mysqli_obj->multi_query(file_get_contents(__dir__.'/sql/common_schema.sql'))
|
||||
$rootDB->insert('system', array(
|
||||
'REG' => 'N',
|
||||
'LOGIN' => 'N',
|
||||
'CRT_DATE' => _Time::DatetimeNow(),
|
||||
'MDF_DATE' => _Time::DatetimeNow()
|
||||
'CRT_DATE' => TimeUtil::DatetimeNow(),
|
||||
'MDF_DATE' => TimeUtil::DatetimeNow()
|
||||
));
|
||||
|
||||
$globalSalt = bin2hex(random_bytes(16));
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
namespace sammo;
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.'/f_func/class._Time.php');
|
||||
require_once(ROOT.'/f_config/DB.php');
|
||||
|
||||
$session = Session::Instance();
|
||||
@@ -47,7 +46,7 @@ if($userInfo['delete_after']){
|
||||
}
|
||||
|
||||
$db->update('member',[
|
||||
'delete_after'=>_Time::DatetimeFromNowMinute(60*24*30)
|
||||
'delete_after'=>TimeUtil::DatetimeFromNowMinute(60*24*30)
|
||||
], 'no=%i', $session->userID);
|
||||
|
||||
if(!$db->affectedRows()){
|
||||
|
||||
+1
-3
@@ -2,8 +2,6 @@
|
||||
namespace sammo;
|
||||
|
||||
require_once('_common.php');
|
||||
require_once(ROOT.'/f_func/class._String.php');
|
||||
require(ROOT.'/f_func/class._Time.php');
|
||||
require_once(ROOT.'/f_config/DB.php');
|
||||
|
||||
|
||||
@@ -46,7 +44,7 @@ if(!$userInfo){
|
||||
]);
|
||||
}
|
||||
|
||||
$nowDate = _Time::DatetimeNow();
|
||||
$nowDate = TimeUtil::DatetimeNow();
|
||||
if($userInfo['delete_after']){
|
||||
if($userInfo['delete_after'] < $nowDate){
|
||||
getRootDB()->delete('member', 'no=%i', $userInfo['no']);
|
||||
|
||||
@@ -4,11 +4,10 @@ namespace sammo;
|
||||
require(__DIR__.'/../d_setting/conf_kakao.php');
|
||||
require('_common.php');
|
||||
require(ROOT.'/f_config/DB.php');
|
||||
require(ROOT.'/f_func/class._Time.php');
|
||||
|
||||
use \kakao\Kakao_REST_API_Helper as Kakao_REST_API_Helper;
|
||||
|
||||
$nowDate = _Time::DatetimeNow();
|
||||
$nowDate = TimeUtil::DatetimeNow();
|
||||
|
||||
$session = Session::Instance();
|
||||
if(!$session->isLoggedIn()){
|
||||
@@ -54,10 +53,10 @@ if($expires < $nowDate){
|
||||
}
|
||||
|
||||
$access_token = $result['access_token'];
|
||||
$expires = _Time::DatetimeFromNowSecond($nowDate, $result['expires_in']);
|
||||
$expires = TimeUtil::DatetimeFromNowSecond($nowDate, $result['expires_in']);
|
||||
if(isset($result['refresh_token'])){
|
||||
$refresh_token = util::array_get($result['refresh_token']);
|
||||
$refresh_token_expires = _Time::DatetimeFromNowSecond($nowDate, $result['refresh_token_expires_in']);
|
||||
$refresh_token_expires = TimeUtil::DatetimeFromNowSecond($nowDate, $result['refresh_token_expires_in']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace sammo;
|
||||
require(__DIR__.'/../d_setting/conf_kakao.php');
|
||||
require_once('_common.php');
|
||||
require('lib.join.php');
|
||||
require_once(ROOT.'/f_func/class._Time.php');
|
||||
require('kakao.php');
|
||||
|
||||
use \kakao\Kakao_REST_API_Helper as Kakao_REST_API_Helper;
|
||||
@@ -19,7 +18,7 @@ if($canJoin != 'Y'){
|
||||
]);
|
||||
}
|
||||
|
||||
$nowDate = _Time::DatetimeNow();
|
||||
$nowDate = TimeUtil::DatetimeNow();
|
||||
|
||||
$access_token = util::array_get($_SESSION['access_token']);
|
||||
$expires = util::array_get($_SESSION['expires']);
|
||||
@@ -97,10 +96,10 @@ if($expires < $nowDate){
|
||||
}
|
||||
|
||||
$access_token = $result['access_token'];
|
||||
$expires = _Time::DatetimeFromNowSecond($nowDate, $result['expires_in']);
|
||||
$expires = TimeUtil::DatetimeFromNowSecond($nowDate, $result['expires_in']);
|
||||
if(isset($result['refresh_token'])){
|
||||
$refresh_token = util::array_get($result['refresh_token']);
|
||||
$refresh_token_expires = _Time::DatetimeFromNowSecond($nowDate, $result['refresh_token_expires_in']);
|
||||
$refresh_token_expires = TimeUtil::DatetimeFromNowSecond($nowDate, $result['refresh_token_expires_in']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace sammo;
|
||||
require(__DIR__.'/../d_setting/conf_kakao.php');
|
||||
require('_common.php');
|
||||
require(ROOT.'/f_config/DB.php');
|
||||
require(ROOT.'/f_func/class._Time.php');
|
||||
require('kakao.php');
|
||||
|
||||
use \kakao\Kakao_REST_API_Helper as Kakao_REST_API_Helper;
|
||||
@@ -23,7 +22,7 @@ if($canLogin != 'Y'){
|
||||
]);
|
||||
}
|
||||
|
||||
$nowDate = _Time::DatetimeNow();
|
||||
$nowDate = TimeUtil::DatetimeNow();
|
||||
|
||||
$access_token = util::array_get($_SESSION['access_token']);
|
||||
$expires = util::array_get($_SESSION['expires']);
|
||||
@@ -62,10 +61,10 @@ if($expires < $nowDate){
|
||||
}
|
||||
|
||||
$access_token = $result['access_token'];
|
||||
$expires = _Time::DatetimeFromNowSecond($nowDate, $result['expires_in']);
|
||||
$expires = TimeUtil::DatetimeFromNowSecond($nowDate, $result['expires_in']);
|
||||
if(isset($result['refresh_token'])){
|
||||
$refresh_token = util::array_get($result['refresh_token']);
|
||||
$refresh_token_expires = _Time::DatetimeFromNowSecond($nowDate, $result['refresh_token_expires_in']);
|
||||
$refresh_token_expires = TimeUtil::DatetimeFromNowSecond($nowDate, $result['refresh_token_expires_in']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
namespace sammo;
|
||||
|
||||
require('_common.php');
|
||||
require(ROOT.'/f_func/class._Time.php');
|
||||
require_once(__dir__.'/../d_setting/conf.php');
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace sammo;
|
||||
require_once('_common.php');
|
||||
require_once(__dir__.'/../d_setting/conf.php');
|
||||
require_once(__dir__.'/../f_func/func.php');
|
||||
require_once(ROOT.'/f_func/class._Time.php');
|
||||
|
||||
function checkUsernameDup($username){
|
||||
if(!$username){
|
||||
@@ -54,7 +53,7 @@ function checkEmailDup($email){
|
||||
|
||||
$userInfo = getRootDB()->queryFirstField('SELECT `no`, `delete_after` FROM member WHERE `email` = %s LIMIT 1', $email);
|
||||
if($userInfo){
|
||||
$nowDate = _Time::DatetimeNow();
|
||||
$nowDate = TimeUtil::DatetimeNow();
|
||||
if (!$userInfo['delete_after']) {
|
||||
return '이미 사용중인 이메일입니다. 관리자에게 문의해주세요.';
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ namespace sammo;
|
||||
|
||||
require(__DIR__.'/../d_setting/conf_kakao.php');
|
||||
require('_common.php');
|
||||
require(ROOT.'/f_func/class._Time.php');
|
||||
|
||||
use \kakao\Kakao_REST_API_Helper as Kakao_REST_API_Helper;
|
||||
|
||||
@@ -29,11 +28,11 @@ $result = $restAPI->create_access_token($auth_code);
|
||||
if(util::array_get($result['expires_in'], -1) > 0){
|
||||
session_start();
|
||||
$restAPI->set_access_token($result['access_token']);
|
||||
$now = _Time::DatetimeNow();
|
||||
$now = TimeUtil::DatetimeNow();
|
||||
$_SESSION['access_token'] = $result['access_token'];
|
||||
$_SESSION['expires'] = _Time::DatetimeFromSecond($now, $result['expires_in']);
|
||||
$_SESSION['expires'] = TimeUtil::DatetimeFromSecond($now, $result['expires_in']);
|
||||
$_SESSION['refresh_token'] = util::array_get($result['refresh_token']);
|
||||
$_SESSION['refresh_token_expires'] = _Time::DatetimeFromSecond($now, $result['refresh_token_expires_in']);
|
||||
$_SESSION['refresh_token_expires'] = TimeUtil::DatetimeFromSecond($now, $result['refresh_token_expires_in']);
|
||||
}
|
||||
else{
|
||||
die('알 수 없는 에러:'.$me['msg']);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
require_once('_common.php');
|
||||
|
||||
class _Setting {
|
||||
class Setting {
|
||||
private $basepath;
|
||||
private $settingFile;
|
||||
private $exist = false;
|
||||
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
class _String {
|
||||
class StringUtil {
|
||||
public static function GetStrLen($str) {
|
||||
$count = strlen($str);
|
||||
$len = 0;
|
||||
@@ -157,7 +155,11 @@ class _String {
|
||||
return $str;
|
||||
}
|
||||
|
||||
static function Fill($str, $maxsize, $ch) {
|
||||
//중간정렬
|
||||
public static function staticFill($str, $maxsize, $ch) {
|
||||
if(!$str){
|
||||
$str = '';
|
||||
}
|
||||
$size = strlen($str);
|
||||
|
||||
$count = ($maxsize - $size) / 2;
|
||||
@@ -171,12 +173,35 @@ class _String {
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function Fill($str, $maxsize, $ch) {
|
||||
if(!$str){
|
||||
$str = '';
|
||||
}
|
||||
$size = strlen($str);
|
||||
|
||||
static function Fill2($str, $maxsize, $ch='0') {
|
||||
$count = ($maxsize - $size) / 2;
|
||||
|
||||
$string = '';
|
||||
for($i=0; $i < $count; $i++) {
|
||||
$string = $string.$ch;
|
||||
}
|
||||
$string = $string.$str;
|
||||
for($i=0; $i < $count; $i++) {
|
||||
$string = $string.$ch;
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
//우측정렬
|
||||
public static function Fill2($str, $maxsize, $ch='0') {
|
||||
if(!$str){
|
||||
$str = '';
|
||||
}
|
||||
$size = strlen($str);
|
||||
|
||||
$count = ($maxsize - $size);
|
||||
$string = '';
|
||||
$string = '';
|
||||
for($i=0; $i < $count; $i++) {
|
||||
$string = $string.$ch;
|
||||
}
|
||||
@@ -236,4 +261,3 @@ class _String {
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
class _Time {
|
||||
class TimeUtil {
|
||||
public static function DateToday() {
|
||||
return date('Y-m-d');
|
||||
}
|
||||
+1
-1
@@ -84,7 +84,7 @@ $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""
|
||||
$histCount = MYDB_num_rows($result);
|
||||
for($i=0; $i < $histCount; $i++) {
|
||||
$history = MYDB_fetch_array($result);
|
||||
$value = "".$history['year']._String::Fill2($history['month'], 2, "0");
|
||||
$value = "".$history['year'].StringUtil::Fill2($history['month'], 2, "0");
|
||||
if($history['year'] == $year && $history['month'] == $month) {
|
||||
echo "
|
||||
<option selected value={$value}>{$history['year']}년 {$history['month']}월</option>";
|
||||
|
||||
@@ -53,7 +53,7 @@ if($me['level'] == 0) {
|
||||
echo "
|
||||
<option value={$city['city']}";
|
||||
if($city['city'] == $_REQUEST['citylist']) { echo " selected"; $valid = 1; }
|
||||
echo ">==================================================【"._String::Fill($city['name'], 4, '_')."】";
|
||||
echo ">==================================================【".StringUtil::Fill($city['name'], 4, '_')."】";
|
||||
if($city['nation'] == 0) echo "공백지";
|
||||
elseif($me['nation'] == $city['nation']) echo "본국==";
|
||||
else echo "타국==";
|
||||
@@ -69,7 +69,7 @@ if($me['level'] == 0) {
|
||||
echo "
|
||||
<option value={$city['city']}";
|
||||
if($city['city'] == $_REQUEST['citylist']) { echo " selected"; $valid = 1; }
|
||||
echo ">==================================================【"._String::Fill($city['name'], 4, '_')."】";
|
||||
echo ">==================================================【".StringUtil::Fill($city['name'], 4, '_')."】";
|
||||
if($city['nation'] == 0) echo "공백지";
|
||||
elseif($me['nation'] == $city['nation']) echo "본국==";
|
||||
else echo "타국==";
|
||||
@@ -86,7 +86,7 @@ if($me['level'] == 0) {
|
||||
echo "
|
||||
<option value={$city['city']}";
|
||||
if($city['city'] == $_REQUEST['citylist']) { echo " selected"; $valid = 1; }
|
||||
echo ">==================================================【"._String::Fill($city['name'], 4, '_')."】";
|
||||
echo ">==================================================【".StringUtil::Fill($city['name'], 4, '_')."】";
|
||||
if($city['nation'] == 0) echo "공백지";
|
||||
elseif($me['nation'] == $city['nation']) echo "본국==";
|
||||
else echo "타국==";
|
||||
@@ -112,7 +112,7 @@ if($myNation['level'] > 0) {
|
||||
echo "
|
||||
<option value={$city['city']}";
|
||||
if($city['city'] == $_REQUEST['citylist']) { echo " selected"; $valid = 1; }
|
||||
echo ">==================================================【"._String::Fill($city['name'], 4, '_')."】";
|
||||
echo ">==================================================【".StringUtil::Fill($city['name'], 4, '_')."】";
|
||||
if($city['nation'] == 0) echo "공백지";
|
||||
elseif($me['nation'] == $city['nation']) echo "본국==";
|
||||
else echo "타국==";
|
||||
|
||||
+1
-1
@@ -173,7 +173,7 @@ for($j=0; $j < $gencount; $j++) {
|
||||
$turn = getTurn($connect, $general, 1, 0);
|
||||
|
||||
for($i=0; $i < 5; $i++) {
|
||||
$turn[$i] = _String::SubStrForWidth($turn[$i], 0, 20);
|
||||
$turn[$i] = StringUtil::SubStrForWidth($turn[$i], 0, 20);
|
||||
$k = $i+1;
|
||||
echo "
|
||||
$k : $turn[$i] <br>";
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@ if($command == 46) {
|
||||
$name = str_replace(" ", "", $name);
|
||||
$name = str_replace(" ", "뷁", $name);
|
||||
if($name == "") { $name = "무명"; }
|
||||
$name = _String::SubStrForWidth($name, 0, 12);
|
||||
$name = StringUtil::SubStrForWidth($name, 0, 12);
|
||||
|
||||
$query = "update general set makenation='{$name}' where owner='{$_SESSION['userID']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
@@ -56,7 +56,7 @@ if($command == 46) {
|
||||
$nationname = str_replace(" ", "", $nationname);
|
||||
$nationname = str_replace(" ", "뷁", $nationname);
|
||||
if($nationname == "") { $nationname = "무명"; }
|
||||
$nationname = _String::SubStrForWidth($nationname, 0, 12);
|
||||
$nationname = StringUtil::SubStrForWidth($nationname, 0, 12);
|
||||
|
||||
$query = "update general set makenation='{$nationname}' where level>=5 and nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
@@ -82,7 +82,7 @@ if($command == 46) {
|
||||
$note = str_replace("|", "", $note);
|
||||
$note = str_replace(" ", "", $note);
|
||||
$note = str_replace(" ", "뷁", $note);
|
||||
$note = _String::SubStrForWidth($note, 0, 90);
|
||||
$note = StringUtil::SubStrForWidth($note, 0, 90);
|
||||
|
||||
$query = "update diplomacy set reserved='{$note}' where me='{$me['nation']}' and you='$double'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
+19
-19
@@ -1510,7 +1510,7 @@ function PushMsg($type, $nation, $picture, $imgsvr, $from, $fromcolor, $to, $toc
|
||||
else { $file = "_nation_msg{$nation}.txt"; }
|
||||
$fp = fopen("logs/{$file}", "a");
|
||||
//로그 파일에 기록
|
||||
$str = "{$type}|"._String::Fill($from,12," ")."|"._String::Fill($to,12," ")."|".$date."|".$msg."|".$fromcolor."|".$tocolor."|".$picture."|".$imgsvr;
|
||||
$str = "{$type}|".StringUtil::Fill($from,12," ")."|".StringUtil::Fill($to,12," ")."|".$date."|".$msg."|".$fromcolor."|".$tocolor."|".$picture."|".$imgsvr;
|
||||
fwrite($fp, "{$str}\n");
|
||||
fclose($fp);
|
||||
}
|
||||
@@ -1599,11 +1599,11 @@ function addTurn($date, $turnterm=1) {
|
||||
if($day > $lastday[$month]) { $month++; $day = 1; }
|
||||
if($month >= 13) { $year++; $month = 1; }
|
||||
|
||||
$month = _String::Fill2($month, 2, "0");
|
||||
$day = _String::Fill2($day, 2, "0");
|
||||
$hour = _String::Fill2($hour, 2, "0");
|
||||
$min = _String::Fill2($min, 2, "0");
|
||||
$sec = _String::Fill2($sec, 2, "0");
|
||||
$month = StringUtil::Fill2($month, 2, "0");
|
||||
$day = StringUtil::Fill2($day, 2, "0");
|
||||
$hour = StringUtil::Fill2($hour, 2, "0");
|
||||
$min = StringUtil::Fill2($min, 2, "0");
|
||||
$sec = StringUtil::Fill2($sec, 2, "0");
|
||||
|
||||
return "{$year}-{$month}-{$day} {$hour}:{$min}:{$sec}";
|
||||
}
|
||||
@@ -1635,11 +1635,11 @@ function add12Turn($date, $turnterm=1) {
|
||||
if($day > $lastday[$month]) { $month++; $day = 1; }
|
||||
if($month >= 13) { $year++; $month = 1; }
|
||||
|
||||
$month = _String::Fill2($month, 2, "0");
|
||||
$day = _String::Fill2($day, 2, "0");
|
||||
$hour = _String::Fill2($hour, 2, "0");
|
||||
$min = _String::Fill2($min, 2, "0");
|
||||
$sec = _String::Fill2($sec, 2, "0");
|
||||
$month = StringUtil::Fill2($month, 2, "0");
|
||||
$day = StringUtil::Fill2($day, 2, "0");
|
||||
$hour = StringUtil::Fill2($hour, 2, "0");
|
||||
$min = StringUtil::Fill2($min, 2, "0");
|
||||
$sec = StringUtil::Fill2($sec, 2, "0");
|
||||
|
||||
return "{$year}-{$month}-{$day} {$hour}:{$min}:{$sec}";
|
||||
}
|
||||
@@ -1671,12 +1671,12 @@ function subTurn($date, $turnterm=1) {
|
||||
if($day <= 0) { $month--; $day = $lastday[$month]; }
|
||||
if($month <= 0) { $year--; $month = 12; }
|
||||
|
||||
$year = _String::Fill2($year, 2, "0");
|
||||
$month = _String::Fill2($month, 2, "0");
|
||||
$day = _String::Fill2($day, 2, "0");
|
||||
$hour = _String::Fill2($hour, 2, "0");
|
||||
$min = _String::Fill2($min, 2, "0");
|
||||
$sec = _String::Fill2($sec, 2, "0");
|
||||
$year = StringUtil::Fill2($year, 2, "0");
|
||||
$month = StringUtil::Fill2($month, 2, "0");
|
||||
$day = StringUtil::Fill2($day, 2, "0");
|
||||
$hour = StringUtil::Fill2($hour, 2, "0");
|
||||
$min = StringUtil::Fill2($min, 2, "0");
|
||||
$sec = StringUtil::Fill2($sec, 2, "0");
|
||||
|
||||
return "{$year}-{$month}-{$day} {$hour}:{$min}:{$sec}";
|
||||
}
|
||||
@@ -1809,7 +1809,7 @@ function increaseRefresh($type="", $cnt=1) {
|
||||
$date2 = substr($date, 0, 10);
|
||||
$online = getOnlineNum();
|
||||
$fp = fopen("logs/_{$date2}_refresh.txt", "a");
|
||||
$msg = _String::Fill2($date,20," ")._String::Fill2($_SESSION['userName'],13," ")._String::Fill2($_SESSION['p_name'],13," ")._String::Fill2($_SESSION['p_ip'],16," ")._String::Fill2($type, 10, " ")." 동접자: {$online}";
|
||||
$msg = StringUtil::Fill2($date,20," ").StringUtil::Fill2($_SESSION['userName'],13," ").StringUtil::Fill2($_SESSION['p_name'],13," ").StringUtil::Fill2($_SESSION['p_ip'],16," ").StringUtil::Fill2($type, 10, " ")." 동접자: {$online}";
|
||||
fwrite($fp, $msg."\n");
|
||||
fclose($fp);
|
||||
|
||||
@@ -1867,7 +1867,7 @@ function updateTraffic() {
|
||||
$date = date('Y-m-d H:i:s');
|
||||
$fp = fopen("logs/_traffic.txt", "a");
|
||||
//일시|년|월|총갱신|접속자|최다갱신자
|
||||
$msg = _String::Fill2($date,20," ")."|"._String::Fill2($game['year'],3," ")."|"._String::Fill2($game['month'],2," ")."|"._String::Fill2($game['refresh'],8," ")."|"._String::Fill2($online,5," ")."|"._String::Fill2($user['name']."(".$user['refresh'].")",20," ");
|
||||
$msg = StringUtil::Fill2($date,20," ")."|".StringUtil::Fill2($game['year'],3," ")."|".StringUtil::Fill2($game['month'],2," ")."|".StringUtil::Fill2($game['refresh'],8," ")."|".StringUtil::Fill2($online,5," ")."|".StringUtil::Fill2($user['name']."(".$user['refresh'].")",20," ");
|
||||
fwrite($fp, $msg."\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
@@ -715,10 +715,10 @@ function command_Other($connect, $turn, $commandtype) {
|
||||
|
||||
|
||||
function EncodeCommand($fourth, $third, $double, $command) {
|
||||
$str = _String::Fill2($fourth, 4, "0");
|
||||
$str .= _String::Fill2($third, 4, "0");
|
||||
$str .= _String::Fill2($double, 4, "0");
|
||||
$str .= _String::Fill2($command, 2, "0");
|
||||
$str = StringUtil::Fill2($fourth, 4, "0");
|
||||
$str .= StringUtil::Fill2($third, 4, "0");
|
||||
$str .= StringUtil::Fill2($double, 4, "0");
|
||||
$str .= StringUtil::Fill2($command, 2, "0");
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -563,7 +563,7 @@ function processAI($connect, $no) {
|
||||
$colors = GetNationColors();
|
||||
$color = rand() % count($colors);
|
||||
$command = EncodeCommand(0, $type, $color, 46);
|
||||
$nationName = "㉿"._String::SubStr($general['name'], 1);
|
||||
$nationName = "㉿".StringUtil::SubStr($general['name'], 1);
|
||||
//건국
|
||||
$query = "update general set turn0='$command',makenation='$nationName' where no='{$general['no']}'";
|
||||
MYDB_query($query, $connect) or Error("processAI08 ".MYDB_error($connect),"");
|
||||
|
||||
@@ -1603,11 +1603,11 @@ function process_31($connect, &$general) {
|
||||
$alllog[] = "<C>●</>{$admin['month']}월:누군가가 <G><b>{$city['name']}</b></>(을)를 살피는 것 같습니다.";
|
||||
$log[] = "<C>●</>{$admin['month']}월:<G><b>{$city['name']}</b></>의 많은 정보를 얻었습니다. <1>$date</>";
|
||||
$msg[count($msg)] = "【<S>병종</>】";
|
||||
for($i=0; $i <= 5; $i++) { if($typecount[$i] != 0) { $msg[count($msg)] = _String::SubStr(getTypename($i), 0, 2).":$typecount[$i]"; } }
|
||||
for($i=10; $i <= 14; $i++) { if($typecount[$i] != 0) { $msg[count($msg)] = _String::SubStr(getTypename($i), 0, 2).":$typecount[$i]"; } }
|
||||
for($i=20; $i <= 27; $i++) { if($typecount[$i] != 0) { $msg[count($msg)] = _String::SubStr(getTypename($i), 0, 2).":$typecount[$i]"; } }
|
||||
for($i=30; $i <= 38; $i++) { if($typecount[$i] != 0) { $msg[count($msg)] = _String::SubStr(getTypename($i), 0, 2).":$typecount[$i]"; } }
|
||||
for($i=40; $i <= 43; $i++) { if($typecount[$i] != 0) { $msg[count($msg)] = _String::SubStr(getTypename($i), 0, 2).":$typecount[$i]"; } }
|
||||
for($i=0; $i <= 5; $i++) { if($typecount[$i] != 0) { $msg[count($msg)] = StringUtil::SubStr(getTypename($i), 0, 2).":$typecount[$i]"; } }
|
||||
for($i=10; $i <= 14; $i++) { if($typecount[$i] != 0) { $msg[count($msg)] = StringUtil::SubStr(getTypename($i), 0, 2).":$typecount[$i]"; } }
|
||||
for($i=20; $i <= 27; $i++) { if($typecount[$i] != 0) { $msg[count($msg)] = StringUtil::SubStr(getTypename($i), 0, 2).":$typecount[$i]"; } }
|
||||
for($i=30; $i <= 38; $i++) { if($typecount[$i] != 0) { $msg[count($msg)] = StringUtil::SubStr(getTypename($i), 0, 2).":$typecount[$i]"; } }
|
||||
for($i=40; $i <= 43; $i++) { if($typecount[$i] != 0) { $msg[count($msg)] = StringUtil::SubStr(getTypename($i), 0, 2).":$typecount[$i]"; } }
|
||||
|
||||
$count = ceil(count($msg) / 8) * 8;
|
||||
for($i=$count; $i > 0; $i-=8) {
|
||||
|
||||
@@ -764,7 +764,7 @@ function process_55($connect, &$general) {
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$nationcount = MYDB_num_rows($result);
|
||||
|
||||
if($nationcount > 0) { $makename = _String::SubStr("$nationcount".$general['name'], 0, 6); }
|
||||
if($nationcount > 0) { $makename = StringUtil::SubStr("$nationcount".$general['name'], 0, 6); }
|
||||
else { $makename = $general['name']; }
|
||||
|
||||
if($general['level'] != 0) {
|
||||
|
||||
@@ -70,264 +70,5 @@ function tab2($str, $maxsize, $ch) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
class _String {
|
||||
public static function GetStrLen($str) {
|
||||
$count = strlen($str);
|
||||
$len = 0;
|
||||
for($i=0; $i < $count; ) {
|
||||
$code = ord($str[$i]);
|
||||
|
||||
if($code >= 0xf0) {
|
||||
$len++;
|
||||
$i += 4;
|
||||
} elseif($code >= 0xe0) {
|
||||
$len++;
|
||||
$i += 3;
|
||||
} elseif($code >= 0xc2) {
|
||||
$len++;
|
||||
$i += 2;
|
||||
} else {
|
||||
$len++;
|
||||
$i += 1;
|
||||
}
|
||||
}
|
||||
return $len;
|
||||
}
|
||||
|
||||
public static function SubStr($str, $s, $l=1000) {
|
||||
$count = strlen($str);
|
||||
$startByte = 0; $isSet = 0;
|
||||
$endByte = $count;
|
||||
$len = 0;
|
||||
for($i=0; $i < $count; ) {
|
||||
$code = ord($str[$i]);
|
||||
|
||||
if($isSet == 0 && $len >= $s) {
|
||||
$startByte = $i; $isSet = 1;
|
||||
}
|
||||
if($isSet == 1 && $len-$s >= $l) {
|
||||
$endByte = $i;
|
||||
break;
|
||||
}
|
||||
|
||||
if($code >= 0xf0) {
|
||||
$len++;
|
||||
$i += 4;
|
||||
} elseif($code >= 0xe0) {
|
||||
$len++;
|
||||
$i += 3;
|
||||
} elseif($code >= 0xc2) {
|
||||
$len++;
|
||||
$i += 2;
|
||||
} else {
|
||||
$len++;
|
||||
$i += 1;
|
||||
}
|
||||
}
|
||||
$str = substr($str, $startByte, $endByte-$startByte);
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function SubStrForWidth($str, $s, $w) {
|
||||
$count = strlen($str);
|
||||
$startByte = 0; $isSet = 0;
|
||||
$endByte = $count; $last = 0;
|
||||
$len = 0;
|
||||
$width = 0;
|
||||
for($i=0; $i < $count; ) {
|
||||
$code = ord($str[$i]);
|
||||
|
||||
if($isSet == 0 && $len >= $s) {
|
||||
$startByte = $i; $isSet = 1;
|
||||
$width = 0;
|
||||
}
|
||||
if($isSet == 1 && $width == $w) {
|
||||
$endByte = $i;
|
||||
break;
|
||||
}
|
||||
if($isSet == 1 && $width > $w) {
|
||||
$endByte = $i - $last;
|
||||
break;
|
||||
}
|
||||
|
||||
if($code >= 0xf0) {
|
||||
$len++;
|
||||
$width += 2;
|
||||
$last = 4;
|
||||
$i += 4;
|
||||
} elseif($code >= 0xe0) {
|
||||
$len++;
|
||||
$width += 2;
|
||||
$last = 3;
|
||||
$i += 3;
|
||||
} elseif($code >= 0xc2) {
|
||||
$len++;
|
||||
$width += 2;
|
||||
$last = 2;
|
||||
$i += 2;
|
||||
} else {
|
||||
$len++;
|
||||
$width += 1;
|
||||
$last = 1;
|
||||
$i += 1;
|
||||
}
|
||||
}
|
||||
$str = substr($str, $startByte, $endByte-$startByte);
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function CutStrForWidth($str, $s, $w, $ch='..') {
|
||||
$isCut = 0;
|
||||
$count = strlen($str);
|
||||
$startByte = 0; $isSet = 0;
|
||||
$endByte = $count; $last = 0;
|
||||
$len = 0;
|
||||
$width = 0;
|
||||
for($i=0; $i < $count; ) {
|
||||
$code = ord($str[$i]);
|
||||
|
||||
if($isSet == 0 && $len >= $s) {
|
||||
$startByte = $i; $isSet = 1;
|
||||
$width = 0;
|
||||
}
|
||||
if($isSet == 1 && $width >= $w) {
|
||||
$endByte = $i - $last;
|
||||
$isCut = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if($code >= 0xf0) {
|
||||
$len++;
|
||||
$width += 2;
|
||||
$last = 4;
|
||||
$i += 4;
|
||||
} elseif($code >= 0xe0) {
|
||||
$len++;
|
||||
$width += 2;
|
||||
$last = 3;
|
||||
$i += 3;
|
||||
} elseif($code >= 0xc2) {
|
||||
$len++;
|
||||
$width += 2;
|
||||
$last = 2;
|
||||
$i += 2;
|
||||
} else {
|
||||
$len++;
|
||||
$width += 1;
|
||||
$last = 1;
|
||||
$i += 1;
|
||||
}
|
||||
}
|
||||
if($isCut != 0) {
|
||||
$str = substr($str, $startByte, $endByte-$startByte) . $ch;
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
//중간정렬
|
||||
public static function staticFill($str, $maxsize, $ch) {
|
||||
if(!$str){
|
||||
$str = '';
|
||||
}
|
||||
$size = strlen($str);
|
||||
|
||||
$count = ($maxsize - $size) / 2;
|
||||
|
||||
for($i=0; $i < $count; $i++) {
|
||||
$string = $string.$ch;
|
||||
}
|
||||
$string = $string.$str;
|
||||
for($i=0; $i < $count; $i++) {
|
||||
$string = $string.$ch;
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function Fill($str, $maxsize, $ch) {
|
||||
if(!$str){
|
||||
$str = '';
|
||||
}
|
||||
$size = strlen($str);
|
||||
|
||||
$count = ($maxsize - $size) / 2;
|
||||
|
||||
$string = '';
|
||||
for($i=0; $i < $count; $i++) {
|
||||
$string = $string.$ch;
|
||||
}
|
||||
$string = $string.$str;
|
||||
for($i=0; $i < $count; $i++) {
|
||||
$string = $string.$ch;
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
//우측정렬
|
||||
public static function Fill2($str, $maxsize, $ch='0') {
|
||||
if(!$str){
|
||||
$str = '';
|
||||
}
|
||||
$size = strlen($str);
|
||||
|
||||
$count = ($maxsize - $size);
|
||||
$string = '';
|
||||
for($i=0; $i < $count; $i++) {
|
||||
$string = $string.$ch;
|
||||
}
|
||||
$string = $string.$str;
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function EscapeTag($str) {
|
||||
$str = htmlspecialchars($str);
|
||||
$str = str_replace("\r\n", "<br>", $str);
|
||||
$str = str_replace("\n", "<br>", $str);
|
||||
// return nl2br(htmlspecialchars($str));
|
||||
// return htmlspecialchars($str);
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function NoSpecialCharacter($str) {
|
||||
$str = str_replace(" ", "", $str);
|
||||
$str = str_replace("\"", "", $str);
|
||||
$str = str_replace("'", "", $str);
|
||||
$str = str_replace("ⓝ", "", $str);
|
||||
$str = str_replace("ⓜ", "", $str);
|
||||
$str = str_replace("ⓖ", "", $str);
|
||||
$str = str_replace("\\", "", $str);
|
||||
$str = str_replace("/", "", $str);
|
||||
$str = str_replace("`", "", $str);
|
||||
$str = str_replace("-", "", $str);
|
||||
$str = str_replace("=", "", $str);
|
||||
$str = str_replace("[", "", $str);
|
||||
$str = str_replace("]", "", $str);
|
||||
$str = str_replace(";", "", $str);
|
||||
$str = str_replace(",", "", $str);
|
||||
$str = str_replace(".", "", $str);
|
||||
$str = str_replace("~", "", $str);
|
||||
$str = str_replace("!", "", $str);
|
||||
$str = str_replace("@", "", $str);
|
||||
$str = str_replace("#", "", $str);
|
||||
$str = str_replace("$", "", $str);
|
||||
$str = str_replace("%", "", $str);
|
||||
$str = str_replace("^", "", $str);
|
||||
$str = str_replace("&", "", $str);
|
||||
$str = str_replace("*", "", $str);
|
||||
$str = str_replace("(", "", $str);
|
||||
$str = str_replace(")", "", $str);
|
||||
$str = str_replace("_", "", $str);
|
||||
$str = str_replace("+", "", $str);
|
||||
$str = str_replace("|", "", $str);
|
||||
$str = str_replace("{", "", $str);
|
||||
$str = str_replace("}", "", $str);
|
||||
$str = str_replace(":", "", $str);
|
||||
$str = str_replace("", "", $str);
|
||||
$str = str_replace("<", "", $str);
|
||||
$str = str_replace(">", "", $str);
|
||||
$str = str_replace("?", "", $str);
|
||||
$str = str_replace(" ", "", $str);
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ function processGoldIncome($connect) {
|
||||
// 실지급율
|
||||
$ratio = $realoutcome / $originoutcome;
|
||||
}
|
||||
$adminLog[count($adminLog)] = _String::Fill2($nation['name'],12," ")." // 세금 : "._String::Fill2($income,6," ")." // 세출 : "._String::Fill2($originoutcome,6," ")." // 실제 : ".tab2($realoutcome,6," ")." // 지급율 : ".tab2(round($ratio*100,2),5," ")." % // 결과금 : ".tab2($nation['gold'],6," ");
|
||||
$adminLog[count($adminLog)] = StringUtil::Fill2($nation['name'],12," ")." // 세금 : ".StringUtil::Fill2($income,6," ")." // 세출 : ".StringUtil::Fill2($originoutcome,6," ")." // 실제 : ".tab2($realoutcome,6," ")." // 지급율 : ".tab2(round($ratio*100,2),5," ")." % // 결과금 : ".tab2($nation['gold'],6," ");
|
||||
|
||||
$query = "select no,name,nation from general where nation='{$nation['nation']}' and level>='9'";
|
||||
$coreresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
@@ -368,7 +368,7 @@ function processRiceIncome($connect) {
|
||||
// 실지급율
|
||||
$ratio = $realoutcome / $originoutcome;
|
||||
}
|
||||
$adminLog[count($adminLog)] = _String::Fill2($nation['name'],12," ")." // 세곡 : "._String::Fill2($income,6," ")." // 세출 : "._String::Fill2($originoutcome,6," ")." // 실제 : ".tab2($realoutcome,6," ")." // 지급율 : ".tab2(round($ratio*100,2),5," ")." % // 결과곡 : ".tab2($nation['rice'],6," ");
|
||||
$adminLog[count($adminLog)] = StringUtil::Fill2($nation['name'],12," ")." // 세곡 : ".StringUtil::Fill2($income,6," ")." // 세출 : ".StringUtil::Fill2($originoutcome,6," ")." // 실제 : ".tab2($realoutcome,6," ")." // 지급율 : ".tab2(round($ratio*100,2),5," ")." % // 결과곡 : ".tab2($nation['rice'],6," ");
|
||||
|
||||
$query = "select no,name,nation from general where nation='{$nation['nation']}' and level>='9'";
|
||||
$coreresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
@@ -900,7 +900,7 @@ function fight($connect, $tnmt_type, $tnmt, $phs, $group, $g1, $g2, $type) {
|
||||
$energy1 = round($energy1); $energy2 = round($energy2);
|
||||
$damage1 = round($damage1); $damage2 = round($damage2);
|
||||
|
||||
$log[] = "<S>●</> "._String::Fill2($phase, 2, "0")."合 : <C>"._String::Fill2($energy1, 3, "0")."</> <span class='ev_highlight'>(-"._String::Fill2($damage1, 3, "0").")</span> vs <span class='ev_highlight'>(-"._String::Fill2($damage2, 3, "0").")</span> <C>"._String::Fill2($energy2, 3, "0")."</>";
|
||||
$log[] = "<S>●</> ".StringUtil::Fill2($phase, 2, "0")."合 : <C>".StringUtil::Fill2($energy1, 3, "0")."</> <span class='ev_highlight'>(-".StringUtil::Fill2($damage1, 3, "0").")</span> vs <span class='ev_highlight'>(-".StringUtil::Fill2($damage2, 3, "0").")</span> <C>".StringUtil::Fill2($energy2, 3, "0")."</>";
|
||||
|
||||
if($energy1 <= 0 && $energy2 <= 0) {
|
||||
if($type == 0) { $sel = 2; break; }
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ include "func.php";
|
||||
|
||||
|
||||
$name = $_POST['name'];
|
||||
$name = _String::NoSpecialCharacter($name);
|
||||
$name = StringUtil::NoSpecialCharacter($name);
|
||||
$pic = util::array_get($_POST['pic'],'');
|
||||
$character = $_POST['character'];
|
||||
|
||||
@@ -78,7 +78,7 @@ if($id_num) {
|
||||
history.go(-1)
|
||||
</script>");
|
||||
exit;
|
||||
} elseif(_String::GetStrLen($name) < 1) {
|
||||
} elseif(StringUtil::GetStrLen($name) < 1) {
|
||||
echo("<script>
|
||||
window.alert('이름이 짧습니다. 다시 가입해주세요!')
|
||||
history.go(-1)
|
||||
@@ -90,7 +90,7 @@ if($id_num) {
|
||||
history.go(-1)
|
||||
</script>");
|
||||
exit;
|
||||
} elseif(_String::GetStrLen($name) > 6) {
|
||||
} elseif(StringUtil::GetStrLen($name) > 6) {
|
||||
echo("<script>
|
||||
window.alert('이름이 유효하지 않습니다. 다시 가입해주세요!')
|
||||
history.go(-1)
|
||||
|
||||
@@ -50,7 +50,7 @@ MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$date = date('Y_m_d H:i:s');
|
||||
$date2 = substr($date, 0, 10);
|
||||
$fp = fopen("logs/_{$date2}_login.txt", "a");
|
||||
$msg = _String::Fill2($date,20," ").tab2($id,13," ")._String::Fill2($me['name'],13," ")._String::Fill2($_SESSION['p_ip'],16," ");
|
||||
$msg = StringUtil::Fill2($date,20," ").tab2($id,13," ").StringUtil::Fill2($me['name'],13," ").StringUtil::Fill2($_SESSION['p_ip'],16," ");
|
||||
fwrite($fp, $msg."\n");
|
||||
fclose($fp);
|
||||
|
||||
|
||||
+3
-3
@@ -380,7 +380,7 @@ function processWar($connect, $general, $city) {
|
||||
}
|
||||
|
||||
$render_attacker = [
|
||||
'crewtype' => _String::SubStr(getTypename($general['crewtype']), 0, 2),
|
||||
'crewtype' => StringUtil::SubStr(getTypename($general['crewtype']), 0, 2),
|
||||
'name'=> $general['name'],
|
||||
'remain_crew' => $general['crew'],
|
||||
'killed_crew' => -$mydeathnum
|
||||
@@ -1257,13 +1257,13 @@ function processWar($connect, $general, $city) {
|
||||
}
|
||||
|
||||
$render_attacker = [
|
||||
'crewtype' => _String::SubStr(getTypename($general['crewtype']), 0, 2),
|
||||
'crewtype' => StringUtil::SubStr(getTypename($general['crewtype']), 0, 2),
|
||||
'name'=> $general['name'],
|
||||
'remain_crew' => $general['crew'],
|
||||
'killed_crew' => -$mydeathnum
|
||||
];
|
||||
$render_defender = [
|
||||
'crewtype' => _String::SubStr(getTypename($oppose['crewtype']), 0, 2),
|
||||
'crewtype' => StringUtil::SubStr(getTypename($oppose['crewtype']), 0, 2),
|
||||
'name'=> $oppose['name'],
|
||||
'remain_crew' => $oppose['crew'],
|
||||
'killed_crew' => -$opdeathnum
|
||||
|
||||
Reference in New Issue
Block a user