정적 분석 결과 반영. 익명 함수로 전환. POST 변수명.

This commit is contained in:
2018-04-07 13:45:17 +09:00
parent 28aa4c004b
commit 6140da5783
6 changed files with 51 additions and 41 deletions
+12 -15
View File
@@ -3,18 +3,6 @@ namespace sammo;
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')){
Json::die([
'step'=>'config'
@@ -24,11 +12,20 @@ if(!class_exists('\\sammo\\RootDB')){
$rootDB = RootDB::db();
$rootDB->throw_exception_on_nonsql_error = false;
$rootDB->nonsql_error_handler = 'dbConnFail';
$rootDB->error_handler = 'dbSQLFail';
$rootDB->nonsql_error_handler = function($params){
Json::die([
'step'=>'conn_fail'
]);
};
$rootDB->error_handler = function($params){
Json::die([
'step'=>'sql_fail'
]);
};
$memberCnt = $rootDB->queryFirstField('SELECT count(`NO`) from MEMBER');
if($memberCnt === 0){
if($memberCnt == 0){
Json::die([
'step'=>'admin',
'globalSalt'=>RootDB::getGlobalSalt()
+13 -16
View File
@@ -3,20 +3,6 @@ namespace sammo;
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']);
$port = Util::array_get($_POST['db_port']);
$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->throw_exception_on_nonsql_error = false;
$rootDB->nonsql_error_handler = 'dbConnFail';
$rootDB->error_handler = 'dbSQLFail';
$rootDB->nonsql_error_handler = function($params){
Json::die([
'result'=>false,
'reason'=>'DB 접속에 실패했습니다.'
]);
};
$rootDB->error_handler = function($params){
Json::die([
'result'=>false,
'reason'=>'SQL을 제대로 실행하지 못했습니다. DB상태를 확인해 주세요.'
]);
};
$mysqli_obj = $rootDB->get(); //로그인에 실패할 경우 자동으로 dbConnFail()이 실행됨.
+12
View File
@@ -11,6 +11,18 @@ if($session->userGrade < 5){
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();
$connect=$db->get();
-3
View File
@@ -49,9 +49,6 @@ $admin = getAdmin();
<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>
</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>
<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>
+13 -6
View File
@@ -6,26 +6,33 @@ include "func.php";
//로그인 검사
$session = Session::requireGameLogin()->setReadOnly();
$admin = getAdmin();
if($session->userGrade < 5) {
//echo "<script>location.replace('_admin1.php');</script>";
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();
$connect=$db->get();
$admin = getAdmin();
switch($btn) {
case "변경":
$msg = addslashes(SQ2DQ($msg));
$query = "update game set msg='$msg'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
break;
case "요청":
$query = $q;
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
break;
case "로그쓰기":
$lognum = $admin['historyindex'] + 1;
if($lognum >= 29) { $lognum = 0; }
+1 -1
View File
@@ -83,12 +83,12 @@ function Error($message, $url="")
if(!$url){
$url = $_SERVER['REQUEST_URI'];
}
WebUtil::setHeaderNoCache();
file_put_contents(__dir__."/logs/_db_bug.txt", "{\"url\":\"$url\",\"msg\":\"$message\"}\n", FILE_APPEND);
$templates = new \League\Plates\Engine('templates');
ob_get_flush();
WebUtil::setHeaderNoCache();
die($templates->render('error', [
'message' => $message