정적 분석 결과 반영. 익명 함수로 전환. POST 변수명.
This commit is contained in:
@@ -3,18 +3,6 @@ namespace sammo;
|
|||||||
|
|
||||||
require(__dir__.'/../vendor/autoload.php');
|
require(__dir__.'/../vendor/autoload.php');
|
||||||
|
|
||||||
function dbConnFail($params){
|
|
||||||
Json::die([
|
|
||||||
'step'=>'conn_fail'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function dbSQLFail($params){
|
|
||||||
Json::die([
|
|
||||||
'step'=>'sql_fail'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!class_exists('\\sammo\\RootDB')){
|
if(!class_exists('\\sammo\\RootDB')){
|
||||||
Json::die([
|
Json::die([
|
||||||
'step'=>'config'
|
'step'=>'config'
|
||||||
@@ -24,11 +12,20 @@ if(!class_exists('\\sammo\\RootDB')){
|
|||||||
$rootDB = RootDB::db();
|
$rootDB = RootDB::db();
|
||||||
|
|
||||||
$rootDB->throw_exception_on_nonsql_error = false;
|
$rootDB->throw_exception_on_nonsql_error = false;
|
||||||
$rootDB->nonsql_error_handler = 'dbConnFail';
|
$rootDB->nonsql_error_handler = function($params){
|
||||||
$rootDB->error_handler = 'dbSQLFail';
|
Json::die([
|
||||||
|
'step'=>'conn_fail'
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
|
$rootDB->error_handler = function($params){
|
||||||
|
Json::die([
|
||||||
|
'step'=>'sql_fail'
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
$memberCnt = $rootDB->queryFirstField('SELECT count(`NO`) from MEMBER');
|
$memberCnt = $rootDB->queryFirstField('SELECT count(`NO`) from MEMBER');
|
||||||
if($memberCnt === 0){
|
if($memberCnt == 0){
|
||||||
Json::die([
|
Json::die([
|
||||||
'step'=>'admin',
|
'step'=>'admin',
|
||||||
'globalSalt'=>RootDB::getGlobalSalt()
|
'globalSalt'=>RootDB::getGlobalSalt()
|
||||||
|
|||||||
+13
-16
@@ -3,20 +3,6 @@ namespace sammo;
|
|||||||
|
|
||||||
require(__dir__.'/../vendor/autoload.php');
|
require(__dir__.'/../vendor/autoload.php');
|
||||||
|
|
||||||
function dbConnFail($params){
|
|
||||||
Json::die([
|
|
||||||
'result'=>false,
|
|
||||||
'reason'=>'DB 접속에 실패했습니다.'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function dbSQLFail($params){
|
|
||||||
Json::die([
|
|
||||||
'result'=>false,
|
|
||||||
'reason'=>'SQL을 제대로 실행하지 못했습니다. DB상태를 확인해 주세요.'
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$host = Util::array_get($_POST['db_host']);
|
$host = Util::array_get($_POST['db_host']);
|
||||||
$port = Util::array_get($_POST['db_port']);
|
$port = Util::array_get($_POST['db_port']);
|
||||||
$username = Util::array_get($_POST['db_id']);
|
$username = Util::array_get($_POST['db_id']);
|
||||||
@@ -118,8 +104,19 @@ $rootDB = new \MeekroDB($host,$username,$password,$dbName,$port,'utf8mb4');
|
|||||||
$rootDB->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
|
$rootDB->connect_options[MYSQLI_OPT_INT_AND_FLOAT_NATIVE] = true;
|
||||||
|
|
||||||
$rootDB->throw_exception_on_nonsql_error = false;
|
$rootDB->throw_exception_on_nonsql_error = false;
|
||||||
$rootDB->nonsql_error_handler = 'dbConnFail';
|
$rootDB->nonsql_error_handler = function($params){
|
||||||
$rootDB->error_handler = 'dbSQLFail';
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'DB 접속에 실패했습니다.'
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
|
$rootDB->error_handler = function($params){
|
||||||
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'SQL을 제대로 실행하지 못했습니다. DB상태를 확인해 주세요.'
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
$mysqli_obj = $rootDB->get(); //로그인에 실패할 경우 자동으로 dbConnFail()이 실행됨.
|
$mysqli_obj = $rootDB->get(); //로그인에 실패할 경우 자동으로 dbConnFail()이 실행됨.
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,18 @@ if($session->userGrade < 5){
|
|||||||
echo '_119.php';//TODO:debug all and replace
|
echo '_119.php';//TODO:debug all and replace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$v = new Validator($_POST);
|
||||||
|
$v->rule('integer', [
|
||||||
|
'minute',
|
||||||
|
'minutes2'
|
||||||
|
]);
|
||||||
|
if(!$v->validate()){
|
||||||
|
Error($v->errorStr());
|
||||||
|
}
|
||||||
|
|
||||||
|
$minute = Util::toInt(Util::array_get($_POST['minute']));
|
||||||
|
$minute2 = Util::toInt(Util::array_get($_POST['minute2']));
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$connect=$db->get();
|
$connect=$db->get();
|
||||||
|
|
||||||
|
|||||||
@@ -49,9 +49,6 @@ $admin = getAdmin();
|
|||||||
<tr><td width=110 align=right>중원정세추가</td>
|
<tr><td width=110 align=right>중원정세추가</td>
|
||||||
<td colspan=3><input type=textarea size=90 maxlength=80 style=color:white;background-color:black; name=log><input type=submit name=btn value=로그쓰기></td></td>
|
<td colspan=3><input type=textarea size=90 maxlength=80 style=color:white;background-color:black; name=log><input type=submit name=btn value=로그쓰기></td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td width=110 align=right>쿼리 요청</td>
|
|
||||||
<td colspan=3><input type=textarea size=90 maxlength=150 style=color:white;background-color:black; name=q><input type=submit name=btn value=요청></td></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td width=110 align=right>시작시간변경</td>
|
<td width=110 align=right>시작시간변경</td>
|
||||||
<td width=285><input type=text size=20 maxlength=20 style=color:white;background-color:black;text-align:right; name=starttime value='<?=$admin['starttime'];?>'><input type=submit name=btn value=변경1></td>
|
<td width=285><input type=text size=20 maxlength=20 style=color:white;background-color:black;text-align:right; name=starttime value='<?=$admin['starttime'];?>'><input type=submit name=btn value=변경1></td>
|
||||||
|
|||||||
+13
-6
@@ -6,26 +6,33 @@ include "func.php";
|
|||||||
//로그인 검사
|
//로그인 검사
|
||||||
$session = Session::requireGameLogin()->setReadOnly();
|
$session = Session::requireGameLogin()->setReadOnly();
|
||||||
|
|
||||||
$admin = getAdmin();
|
|
||||||
|
|
||||||
if($session->userGrade < 5) {
|
if($session->userGrade < 5) {
|
||||||
//echo "<script>location.replace('_admin1.php');</script>";
|
//echo "<script>location.replace('_admin1.php');</script>";
|
||||||
echo '_admin1.php';//TODO:debug all and replace
|
echo '_admin1.php';//TODO:debug all and replace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$v = new Validator($_POST);
|
||||||
|
$v->rule('integer', [
|
||||||
|
'maxgeneral',
|
||||||
|
'minutes2'
|
||||||
|
])->rule('dateFormat', [
|
||||||
|
'starttime'
|
||||||
|
]);
|
||||||
|
if(!$v->validate()){
|
||||||
|
Error($v->errorStr());
|
||||||
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$connect=$db->get();
|
$connect=$db->get();
|
||||||
|
|
||||||
|
$admin = getAdmin();
|
||||||
|
|
||||||
switch($btn) {
|
switch($btn) {
|
||||||
case "변경":
|
case "변경":
|
||||||
$msg = addslashes(SQ2DQ($msg));
|
$msg = addslashes(SQ2DQ($msg));
|
||||||
$query = "update game set msg='$msg'";
|
$query = "update game set msg='$msg'";
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
break;
|
break;
|
||||||
case "요청":
|
|
||||||
$query = $q;
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
break;
|
|
||||||
case "로그쓰기":
|
case "로그쓰기":
|
||||||
$lognum = $admin['historyindex'] + 1;
|
$lognum = $admin['historyindex'] + 1;
|
||||||
if($lognum >= 29) { $lognum = 0; }
|
if($lognum >= 29) { $lognum = 0; }
|
||||||
|
|||||||
+1
-1
@@ -83,12 +83,12 @@ function Error($message, $url="")
|
|||||||
if(!$url){
|
if(!$url){
|
||||||
$url = $_SERVER['REQUEST_URI'];
|
$url = $_SERVER['REQUEST_URI'];
|
||||||
}
|
}
|
||||||
WebUtil::setHeaderNoCache();
|
|
||||||
file_put_contents(__dir__."/logs/_db_bug.txt", "{\"url\":\"$url\",\"msg\":\"$message\"}\n", FILE_APPEND);
|
file_put_contents(__dir__."/logs/_db_bug.txt", "{\"url\":\"$url\",\"msg\":\"$message\"}\n", FILE_APPEND);
|
||||||
|
|
||||||
$templates = new \League\Plates\Engine('templates');
|
$templates = new \League\Plates\Engine('templates');
|
||||||
|
|
||||||
ob_get_flush();
|
ob_get_flush();
|
||||||
|
WebUtil::setHeaderNoCache();
|
||||||
|
|
||||||
die($templates->render('error', [
|
die($templates->render('error', [
|
||||||
'message' => $message
|
'message' => $message
|
||||||
|
|||||||
Reference in New Issue
Block a user