From 5ca8a6ecfa80592a8dfdc2de736b8e0abbafa196 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 24 Jun 2018 03:47:44 +0900 Subject: [PATCH] =?UTF-8?q?purifier=201=EC=B0=A8=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + hwe/b_dipcenter.php | 4 ++-- hwe/c_dipcenter.php | 26 ++++++++++++-------------- hwe/c_vote.php | 4 ++-- hwe/func_string.php | 7 ------- hwe/processing.php | 13 ++++++++----- src/sammo/WebUtil.php | 10 ++++++++++ 7 files changed, 35 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 1cfa8731..61a7af99 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ test.php /twe phpinfo.php +vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/* diff --git a/hwe/b_dipcenter.php b/hwe/b_dipcenter.php index ad0810f0..1dd949c9 100644 --- a/hwe/b_dipcenter.php +++ b/hwe/b_dipcenter.php @@ -217,8 +217,8 @@ if ($budgetricediff > 0) {
국 가 방 침 & 임관 권유 메세지 - 국가 방침 name=btn value=국가방침> - 임관 권유 maxlength=500 style=color:white;background-color:black;width:830px; name=scoutmsg value=''> name=btn value=임관권유> + 국가 방침 name=btn value=국가방침> + 임관 권유 maxlength=1000 style=color:white;background-color:black;width:830px; name=scoutmsg value=''> name=btn value=임관권유> 870 x 200px 넘는 크기를 점유할 시 통보없이 제한될 수 있습니다. 예 산 & 정 책 diff --git a/hwe/c_dipcenter.php b/hwe/c_dipcenter.php index 929543ee..07c8424c 100644 --- a/hwe/c_dipcenter.php +++ b/hwe/c_dipcenter.php @@ -19,11 +19,8 @@ $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); $db = DB::db(); -$connect=$db->get(); -$query = "select no,nation,level from general where owner='{$userID}'"; -$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); -$me = MYDB_fetch_array($result); +$me = $db->queryFirstRow('SELECT `no`,nation,`level` FROM general WHERE `owner`=%i', $userID); //내가 수뇌부이어야함 if($me['level'] < 5) { @@ -32,21 +29,21 @@ if($me['level'] < 5) { } if($btn == "국가방침") { - $msg == mb_substr($msg, 0, 1000); + $msg = mb_substr($msg, 0, 16384); //$msg = StringUtil:: $db->update('nation', [ - 'msg'=>BadTag2Code($msg) + 'msg'=>WebUtil::htmlPurify($msg) ], 'nation=%i',$me['nation']); } elseif($btn == "임관권유") { - $scoutmsg == mb_substr($msg, 0, 500); + $scoutmsg = mb_substr($scoutmsg, 0, 1000); $db->update('nation', [ - 'scoutmsg'=>BadTag2Code($scoutmsg) + 'scoutmsg'=>WebUtil::htmlPurify($scoutmsg) ], 'nation=%i',$me['nation']); } elseif($btn == "세율") { - if($rate < 5) { $rate = 5; } - if($rate > 30) { $rate = 30; } - $query = "update nation set rate='$rate' where nation='{$me['nation']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $rate = Util::valueFit($rate, 5, 30); + $db->update('nation', [ + 'rate'=>$rate, + ], 'nation=%i', $me['nation']); } elseif($btn == "지급율") { $bill = Util::valueFit($bill, 20, 200); $db->update('nation', [ @@ -70,8 +67,9 @@ if($btn == "국가방침") { 'war'=>1 ], 'nation=%i',$me['nation']); } elseif($btn == "전쟁 허가") { - $query = "update nation set war='0' where nation='{$me['nation']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $db->update('nation', [ + 'war'=>0 + ], 'nation=%i',$me['nation']); } header('location:b_dipcenter.php'); diff --git a/hwe/c_vote.php b/hwe/c_vote.php index 7653edb5..7224f476 100644 --- a/hwe/c_vote.php +++ b/hwe/c_vote.php @@ -58,14 +58,14 @@ if(!$isVoteAdmin){ if($btn == "수정") { if($title != "") { - $gameStor->vote_title = $title; + $gameStor->vote_title = WebUtil::htmlPurify($title); } } elseif($btn == "추가") { if($str != "") { if(!$admin['vote']){ $admin['vote'] = []; } - $admin['vote'][] = $str; + $admin['vote'][] = WebUtil::htmlPurify($str); $gameStor->vote=$admin['vote']; } } elseif($btn == "리셋") { diff --git a/hwe/func_string.php b/hwe/func_string.php index fb50e16e..6f6c93a2 100644 --- a/hwe/func_string.php +++ b/hwe/func_string.php @@ -24,13 +24,6 @@ function Tag2Code(string $str) { return nl2br($str); } -function BadTag2Code(string $str) { - /* FIXME: 제대로된 tag 변환 코드 사용 */ - $str = str_replace("{$nation['name']}-"; - } else { - $scoutStr .= "{$nation['name']}".$nation['scoutmsg'].""; - } + $scoutStr .= + "" + ."" + .$nation['name'] + ."" + ."" + .($nation['scoutmsg']?:'-') + .''; if($gameStor->year < $gameStor->startyear+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit) { echo " diff --git a/src/sammo/WebUtil.php b/src/sammo/WebUtil.php index 969b2046..05f77318 100644 --- a/src/sammo/WebUtil.php +++ b/src/sammo/WebUtil.php @@ -125,4 +125,14 @@ class WebUtil } return "\n"; } + + public static function htmlPurify(?string $text): string{ + if(!$text){ + return ''; + } + + $config = \HTMLPurifier_HTML5Config::createDefault(); + $purifier = new \HTMLPurifier($config); + return $purifier->purify($text); + } }