Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/mangboard/api/mb-board.php
+++ b/mangboard/api/mb-board.php
@@ -29,6 +29,8 @@
$upload_check = false;
if(mbw_get_param("mode")=="write"){
$upload_check = mbw_check_api_file("board");
+}else if(mbw_get_param("mode")=="comment"){
+ mbw_error_message("MSG_PERMISSION_ERROR", $mb_languages["W_ACCESS"],"1102");
}
if(mbw_get_result_data("state")=="error"){
@@ -63,7 +65,11 @@
else $send_data[$api_fields["fn_is_secret"]] = 1;
}
- $where_data[$api_fields["fn_pid"]] = $board_pid;
+ $where_data[$api_fields["fn_pid"]] = $board_pid;
+ if( (intval(mbw_get_user("fn_user_level")) < intval(mbw_get_board_option("fn_modify_level"))) && !empty($api_fields["fn_user_pid"]) ){
+ $where_data[$api_fields["fn_user_pid"]] = mbw_get_user("fn_pid");
+ }
+
}else if((intval(mbw_get_board_option("fn_modify_level")) <= intval(mbw_get_user("fn_user_level"))) && mbw_get_param("board_action")=="multi_modify"){
//체크박스가 선택된 항목만 수정
$check_array = mbw_get_param("check_array");
@@ -122,7 +128,10 @@
}else if(mbw_get_param("board_action")=="delete"){
if(mbw_get_param("board_name")!="" && !empty($board_pid)){
$query_command = "DELETE";
- $where_data[$api_fields["fn_pid"]] = $board_pid;
+ $where_data[$api_fields["fn_pid"]] = $board_pid;
+ if( (intval(mbw_get_user("fn_user_level")) < intval(mbw_get_board_option("fn_delete_level"))) && !empty($api_fields["fn_user_pid"]) ){
+ $where_data[$api_fields["fn_user_pid"]] = mbw_get_user("fn_pid");
+ }
//게시물 삭제시 파일 연결 해제
$query_data[] = $mdb->prepare( "UPDATE ".$mb_admin_tables["files"]." set ".$mb_fields["files"]["fn_board_pid"]."=0 where ".$mb_fields["files"]["fn_table_name"]."=%s and ".$mb_fields["files"]["fn_board_pid"]."=%d", $mb_board_table_name, $board_pid);
--- a/mangboard/api/mb-comment.php
+++ b/mangboard/api/mb-comment.php
@@ -9,10 +9,10 @@
}
$query_command = "";
-$send_data = array();
+$send_data = array();
$where_data = array();
$query_data = array();
-$parent_pid = intval(mbw_get_param("parent_pid"));
+$parent_pid = intval(mbw_get_param("parent_pid"));
$comment_pid = intval(mbw_get_param("comment_pid"));
$comment_parent_pid = 0;
@@ -68,10 +68,16 @@
$query_command = "UPDATE";
if(isset($api_fields["fn_parent_pid"]) && empty($send_data[$api_fields["fn_parent_pid"]])) unset($send_data[$api_fields["fn_parent_pid"]]);
$where_data[$api_fields["fn_pid"]] = $comment_pid;
+ if( (intval(mbw_get_user("fn_user_level")) < intval(mbw_get_board_option("fn_modify_level")) ) && !empty($api_fields["fn_user_pid"]) ){
+ $where_data[$api_fields["fn_user_pid"]] = mbw_get_user("fn_pid");
+ }
}else if(mbw_get_param("board_action")=="delete"){
if(!empty($comment_pid)){
$query_command = "DELETE";
- $where_data[$api_fields["fn_pid"]] = $comment_pid;
+ $where_data[$api_fields["fn_pid"]] = $comment_pid;
+ if( (intval(mbw_get_user("fn_user_level")) < intval(mbw_get_board_option("fn_delete_level"))) && !empty($api_fields["fn_user_pid"]) ){
+ $where_data[$api_fields["fn_user_pid"]] = mbw_get_user("fn_pid");
+ }
if(mbw_get_param("board_name")!=""){
//댓글 삭제시 댓글에 연결된 쿠키정보 삭제
@@ -112,7 +118,7 @@
mbw_set_user_point("comment",mbw_get_param("board_action"));
$mb_user_level = mbw_get_user("fn_user_level");
-$mb_user_pid = mbw_get_user("fn_pid");
+$mb_user_pid = mbw_get_user("fn_pid");
$comment_mode = "view";
$where_query = $mdb->prepare(" where ".$api_fields["fn_parent_pid"]."=%d", $parent_pid);
--- a/mangboard/api/mb-template.php
+++ b/mangboard/api/mb-template.php
@@ -145,7 +145,8 @@
if(!empty($mb_fields["select_board"]["fn_data_type"]) && !empty($item[$mb_fields["select_board"]["fn_data_type"]]) && ($item[$mb_fields["select_board"]["fn_data_type"]]=="html")){
$content = mbw_htmlspecialchars_decode($content);
$item_level = intval($item[$mb_fields["select_board"]["fn_level"]]);
- if ( $item_level == 0 ) { //비회원이 작성한 게시물은 추가 보안 검증
+ //레벨 10 (관리자) 이하의 회원이 작성했거나 DISALLOW_UNFILTERED_HTML 설정이 있을 경우 추가 검증
+ if ( $item_level < 10 || (defined('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML) ) {
if( function_exists('mbw_get_htmlpurify') && version_compare(PHP_VERSION, '5.4.0', '>=') ){
$content = mbw_get_htmlpurify($content);
} else {
--- a/mangboard/includes/class.store.php
+++ b/mangboard/includes/class.store.php
@@ -152,9 +152,9 @@
if ( !empty($this->params["user_name"]) ) {
$this->params["user_name"] = preg_replace('/[()=]/', '', $this->params["user_name"]);
}
-
+
//image_path 에서 파일 이름 및 확장자 체크
- if ( !empty($this->params["image_path"]) ) {
+ if ( !empty($this->params["image_path"]) && is_string($this->params["image_path"]) ) {
$image_path = $this->params["image_path"];
if(strpos($image_path, '.php')!==false || strpos($image_path, '.phar')!==false || strpos($image_path, '.phtm')!==false){
$this->params["image_path"] = "";
--- a/mangboard/includes/functions/func.api.php
+++ b/mangboard/includes/functions/func.api.php
@@ -50,9 +50,9 @@
mbw_add_trace("mbw_set_api_params");
global $mstore,$mdb,$mb_admin_tables,$mb_fields;
global $mb_board_table_name,$mb_comment_table_name;
- $api_fields = $fields;
+ $api_fields = $fields;
$check_fields = $fields;
- $send_data = array();
+ $send_data = array();
$mb_user_level = mbw_get_user("fn_user_level");
//관리자 테이블에는 htmlspecialchars 기능 적용 안함
@@ -77,22 +77,22 @@
if ( is_array($data_type) ) {
$data_type = implode(",", $data_type);
}
- $data_type = mbw_value_filter($data_type);
+ $data_type = mbw_value_filter($data_type);
}else{
- $data_type = "html";
+ if(isset($api_fields["fn_data_type"]) && mbw_get_param("content")!=""){
+ $data_type = "html";
+ }
}
mbw_set_param("data_type", $data_type);
- if( ($check_htmlspecialchars && ( strpos($data_type, "html") !== false )) || !is_string($data_type) ){
- if(mbw_get_param("content")!=""){
- $tmp_content = mbw_get_param("content");
- if(!mbw_is_admin() || (defined('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML) || mbw_get_option("anti_spam_protection") === 0){
- if( function_exists('mbw_get_htmlpurify') && version_compare(PHP_VERSION, '5.4.0', '>=') ){
- mbw_set_param("content",mbw_get_htmlpurify($tmp_content));
- } else {
- mbw_set_param("content",wp_kses_post($tmp_content));
- }
- }
+ $tmp_content = mbw_get_param("content");
+ if( !empty($tmp_content) && $check_htmlspecialchars && ( strpos($data_type, "html") !== false || strpos($tmp_content, '<') !== false ) ){
+ if(!mbw_is_admin() || (defined('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML) || mbw_get_option("anti_spam_protection") === 0){
+ if( function_exists('mbw_get_htmlpurify') && version_compare(PHP_VERSION, '5.4.0', '>=') ){
+ mbw_set_param("content",mbw_get_htmlpurify($tmp_content));
+ } else {
+ mbw_set_param("content",wp_kses_post($tmp_content));
+ }
}
}
@@ -130,11 +130,16 @@
foreach($check_fields as $key => $value){
$param_key = str_replace("fn_", "", $key);
- if(strpos($key, 'fn_')===0 && isset($_REQUEST[$param_key]) && $key!="fn_pid"){
- if(!empty($allow_fields) && strpos($allow_fields, ','.$param_key.',')===false) continue;
+ if ( strpos($key, 'fn_') === 0 && isset($_REQUEST[$param_key]) && $key != "fn_pid" ) {
+ if ( !empty($allow_fields) && strpos($allow_fields, ','.$param_key.',') === false ) {
+ continue;
+ }
$param_data = mbw_get_param($param_key);
if ( $key == "fn_data_type" ) {
+ if ( mbw_get_param("mode")=="write" && !isset($_REQUEST["content"]) ) {
+ continue;
+ }
if ( is_array($param_data) ) {
$param_data = implode(",", $param_data);
}
@@ -455,35 +460,39 @@
if(mbw_get_param("mode")=="comment"){
$table_name = $mb_comment_table_name;
- $pid = mbw_get_param("comment_pid");
+ $pid = mbw_get_param("comment_pid");
}else{
$table_name = $mb_board_table_name;
- $pid = mbw_get_param("board_pid");
+ $pid = mbw_get_param("board_pid");
}
//접근 권한 체크
- $mb_user_level = mbw_get_user("fn_user_level");
- $mb_user_pid = intval(mbw_get_user("fn_pid"));
+ $mb_user_level = mbw_get_user("fn_user_level");
+ $mb_user_pid = intval(mbw_get_user("fn_pid"));
if(strpos(mbw_get_param("board_action"),"delete")!==false){
if(intval(mbw_get_board_option("fn_delete_level")) > $mb_user_level){
//user_pid 필드가 없는 게시판은 일반 유저가 삭제하지 못하도록 설정
if(!empty($api_fields["fn_user_pid"])){
$board_item = $mdb->get_row($mdb->prepare("select * from ".$table_name." where ".$api_fields["fn_pid"]."=%d limit 1", $pid),ARRAY_A);
-
- //비회원이 작성한 글일 경우 비밀번호가 일치하는지 확인
- if($board_item[$api_fields["fn_user_pid"]]=="0"){
- if(!empty($api_fields["fn_passwd"])){
- if(empty($send_data[$api_fields["fn_passwd"]])){
- mbw_error_message("MSG_FIELD_EMPTY_ERROR1", $mb_languages["W_PASSWORD"],"1201");
- }else if(!mbw_check_password(mbw_get_param("passwd"), $board_item[$api_fields["fn_passwd"]])){
- mbw_error_message("MSG_MATCH_ERROR", $mb_languages["W_PASSWORD"],"1206","passwd");
- }
- }
- //회원이 작성한 글일 경우 본인 글이 아닐 경우 에러 출력
+
+ if(empty($board_item)){
+ mbw_error_message("MSG_ITEM_NOT_EXIST");
}else{
- if($mb_user_pid!=$board_item[$api_fields["fn_user_pid"]]){
- mbw_error_message("MSG_PERMISSION_ERROR", $mb_languages["W_DELETE"],"1102");
+ //비회원이 작성한 글일 경우 비밀번호가 일치하는지 확인
+ if($board_item[$api_fields["fn_user_pid"]]=="0"){
+ if(!empty($api_fields["fn_passwd"])){
+ if(empty($send_data[$api_fields["fn_passwd"]])){
+ mbw_error_message("MSG_FIELD_EMPTY_ERROR1", $mb_languages["W_PASSWORD"],"1201");
+ }else if(!mbw_check_password(mbw_get_param("passwd"), $board_item[$api_fields["fn_passwd"]])){
+ mbw_error_message("MSG_MATCH_ERROR", $mb_languages["W_PASSWORD"],"1206","passwd");
+ }
+ }
+ //회원이 작성한 글일 경우 본인 글이 아닐 경우 에러 출력
+ }else{
+ if ( $mb_user_pid === 0 || $mb_user_pid != $board_item[$api_fields["fn_user_pid"]] ) {
+ mbw_error_message("MSG_PERMISSION_ERROR", $mb_languages["W_DELETE"],"1102");
+ }
}
}
}else{
@@ -491,29 +500,32 @@
}
}
}else if(strpos(mbw_get_param("board_action"),"modify")!==false){
- $board_item = $mdb->get_row($mdb->prepare("select * from ".$table_name." where ".$api_fields["fn_pid"]."=%d limit 1", $pid),ARRAY_A);
-
- if(intval(mbw_get_board_option("fn_modify_level")) > $mb_user_level){
- //비회원이 작성한 글일 경우 비밀번호가 일치하는지 확인
- if(!empty($api_fields["fn_user_pid"])){
- if($board_item[$api_fields["fn_user_pid"]]=="0"){
- if(empty($send_data[$api_fields["fn_passwd"]])){
- mbw_error_message("MSG_FIELD_EMPTY_ERROR1", $mb_languages["W_PASSWORD"],"1201");
- }else if(!mbw_check_password(mbw_get_param("passwd"), $board_item[$api_fields["fn_passwd"]])){
- mbw_error_message("MSG_MATCH_ERROR", $mb_languages["W_PASSWORD"],"1206","passwd");
+ if(intval(mbw_get_board_option("fn_modify_level")) > $mb_user_level){
+ $board_item = $mdb->get_row($mdb->prepare("select * from ".$table_name." where ".$api_fields["fn_pid"]."=%d limit 1", $pid),ARRAY_A);
+ if(empty($board_item)){
+ mbw_error_message("MSG_ITEM_NOT_EXIST");
+ }else{
+ //비회원이 작성한 글일 경우 비밀번호가 일치하는지 확인
+ if(!empty($api_fields["fn_user_pid"])){
+ if($board_item[$api_fields["fn_user_pid"]]=="0"){
+ if(empty($send_data[$api_fields["fn_passwd"]])){
+ mbw_error_message("MSG_FIELD_EMPTY_ERROR1", $mb_languages["W_PASSWORD"],"1201");
+ }else if(!mbw_check_password(mbw_get_param("passwd"), $board_item[$api_fields["fn_passwd"]])){
+ mbw_error_message("MSG_MATCH_ERROR", $mb_languages["W_PASSWORD"],"1206","passwd");
+ }
+ //회원이 작성한 글일 경우 본인 글이 아닐 경우 에러 출력
+ }else{
+ if ( $mb_user_pid === 0 || $mb_user_pid != $board_item[$api_fields["fn_user_pid"]] ) {
+ mbw_error_message("MSG_PERMISSION_ERROR", $mb_languages["W_MODIFY"],"1102");
+ }
}
- //회원이 작성한 글일 경우 본인 글이 아닐 경우 에러 출력
- }else{
- if($mb_user_pid!=$board_item[$api_fields["fn_user_pid"]]){
+ }else if($mb_board_table_name==$mb_admin_tables["users"]){
+ if ( $mb_user_pid === 0 || $mb_user_pid != $board_item[$api_fields["fn_pid"]] ) {
mbw_error_message("MSG_PERMISSION_ERROR", $mb_languages["W_MODIFY"],"1102");
}
- }
- }else if($mb_board_table_name==$mb_admin_tables["users"]){
- if($mb_user_pid!=$board_item[$api_fields["fn_pid"]]){
+ }else{
mbw_error_message("MSG_PERMISSION_ERROR", $mb_languages["W_MODIFY"],"1102");
}
- }else{
- mbw_error_message("MSG_PERMISSION_ERROR", $mb_languages["W_MODIFY"],"1102");
}
}
@@ -553,6 +565,7 @@
$name_array = explode('.',$file_name);
if(count($name_array)==1) return false;
$file_ext = strtolower(array_pop($name_array));
+ $file_ext = mbw_value_filter($file_ext, "name");
if($file_size==0){
mbw_error_message("MSG_UPLOAD_SIZE_ERROR", mbw_get_option("upload_file_size"),"1503");
@@ -575,6 +588,7 @@
$name_array = explode('.',$file_name);
if(count($name_array)==1) return false;
$file_ext = strtolower(array_pop($name_array));
+ $file_ext = mbw_value_filter($file_ext, "name");
if($file_size==0){
mbw_error_message("MSG_UPLOAD_SIZE_ERROR", mbw_get_option("upload_file_size"),"1503");
@@ -731,7 +745,8 @@
$name_array = explode('.',$upload_data["name"]);
if(count($name_array)==1) return $upload_data;
- $file_ext = strtolower(array_pop($name_array));
+ $file_ext = strtolower(array_pop($name_array));
+ $file_ext = mbw_value_filter($file_ext, "name");
if(!is_uploaded_file($file_tmp)){
mbw_error_message("MSG_ERROR", "Upload","1500");
@@ -799,7 +814,8 @@
$upload_data["name"] = mbw_check_upload_filename($file_data["name"]);
$name_array = explode('.',$upload_data["name"]);
if(count($name_array)==1) return $upload_data;
- $file_ext = strtolower(array_pop($name_array));
+ $file_ext = strtolower(array_pop($name_array));
+ $file_ext = mbw_value_filter($file_ext, "name");
if(!is_uploaded_file($file_tmp)){
mbw_error_message("MSG_ERROR", "Upload","1500");
@@ -884,8 +900,8 @@
$name_array = explode('.',$upload_data["name"]);
if(count($name_array)==1) return array("name"=>"");
- $file_ext = array_pop($name_array);
- $file_ext = strtolower($file_ext);
+ $file_ext = strtolower(array_pop($name_array));
+ $file_ext = mbw_value_filter($file_ext, "name");
if(!in_array($file_ext, $check_ext)){
mbw_error_message("MSG_UPLOAD_EXT_ERROR", $file_ext,"1502");
@@ -946,6 +962,7 @@
$name_array = explode('.',$upload_data["name"]);
if(count($name_array)==1) return $upload_data;
$file_ext = strtolower(array_pop($name_array));
+ $file_ext = mbw_value_filter($file_ext, "name");
if(mbw_get_param("file_type")!=""){
$file_type = mbw_get_param("file_type");
}else{
@@ -968,39 +985,42 @@
$upload_data["path"] = $datePath.$file_name;
if(defined('MBW_IMAGE_EDITOR') && mbw_get_param("mode")=="write" && mbw_get_param("board_action")=="modify" && mbw_get_param("image_path")!=""){ //게시물 수정시 대표이미지가 존재할 경우 해당 경로에 덮어쓰기로 저장
$image_path = mbw_get_param("image_path");
- $file_item = $mdb->get_row($mdb->prepare("select * from `".$mb_admin_tables["files"]."` where ".$mb_fields["files"]["fn_file_path"]."=%s limit 1;", $image_path),ARRAY_A);
- if(empty($file_item)){ //수정할 이미지가 삭제되었을 경우 대표 이미지 경로에 다시 저장
- $file_name = basename($image_path);
- $datePath = preg_replace('/[^0-9a-zA-Z/]/', '', str_replace($file_name, "", $image_path));
-
- $file_name = mbw_check_upload_filename($file_name);
- $name_array = explode('.',$file_name);
- $file_ext = strtolower(array_pop($name_array));
-
- if(!in_array($file_ext, $mb_image_upload_files)){
- mbw_error_message("MSG_UPLOAD_EXT_ERROR", $file_ext,"1502");
- return array("name"=>"");
- }else{
- if(strpos($file_name, 'F')===0 && strpos($file_name, '_')!==false){
- $upload_data["name"] = substr($file_name,strpos($file_name, '_')+1);
- }else{
- $upload_data["name"] = $file_name;
- }
- $upload_data["path"] = $datePath.$file_name;
- $board_pid = mbw_get_param("board_pid");
- if(!empty($board_pid)){
- if(isset($api_fields["fn_board_pid"])){
- $send_data[$api_fields["fn_board_pid"]] = intval($board_pid);
+ if ( is_string($image_path) ) {
+ $file_item = $mdb->get_row($mdb->prepare("select * from `".$mb_admin_tables["files"]."` where ".$mb_fields["files"]["fn_file_path"]."=%s limit 1;", $image_path),ARRAY_A);
+ if(empty($file_item)){ //수정할 이미지가 삭제되었을 경우 대표 이미지 경로에 다시 저장
+ $file_name = basename($image_path);
+ $datePath = preg_replace('/[^0-9a-zA-Z/]/', '', str_replace($file_name, "", $image_path));
+
+ $file_name = mbw_check_upload_filename($file_name);
+ $name_array = explode('.',$file_name);
+ $file_ext = strtolower(array_pop($name_array));
+ $file_ext = mbw_value_filter($file_ext, "name");
+
+ if(!in_array($file_ext, $mb_image_upload_files)){
+ mbw_error_message("MSG_UPLOAD_EXT_ERROR", $file_ext,"1502");
+ return array("name"=>"");
+ }else{
+ if(strpos($file_name, 'F')===0 && strpos($file_name, '_')!==false){
+ $upload_data["name"] = substr($file_name,strpos($file_name, '_')+1);
+ }else{
+ $upload_data["name"] = $file_name;
}
- $board_name = mbw_get_param("board_name");
- if(!empty($board_name)){
- if(isset($api_fields["fn_board_name"])){
- $send_data[$api_fields["fn_board_name"]] = mbw_htmlspecialchars2($board_name);
+ $upload_data["path"] = $datePath.$file_name;
+ $board_pid = mbw_get_param("board_pid");
+ if(!empty($board_pid)){
+ if(isset($api_fields["fn_board_pid"])){
+ $send_data[$api_fields["fn_board_pid"]] = intval($board_pid);
+ }
+ $board_name = mbw_get_param("board_name");
+ if(!empty($board_name)){
+ if(isset($api_fields["fn_board_name"])){
+ $send_data[$api_fields["fn_board_name"]] = mbw_htmlspecialchars2($board_name);
+ }
+ $table_name = mbw_get_board_table_name($board_name);
+ if(isset($api_fields["fn_table_name"]) && !empty($table_name)){
+ $send_data[$api_fields["fn_table_name"]] = mbw_htmlspecialchars2($table_name);
+ }
}
- $table_name = mbw_get_board_table_name($board_name);
- if(isset($api_fields["fn_table_name"]) && !empty($table_name)){
- $send_data[$api_fields["fn_table_name"]] = mbw_htmlspecialchars2($table_name);
- }
}
}
}
@@ -1051,6 +1071,7 @@
$name_array = explode('.', $file_name);
$file_ext = strtolower(array_pop($name_array));
+ $file_ext = mbw_value_filter($file_ext, "name");
if(strpos($mime_type,"image/")!==0){
mbw_error_message("MSG_ERROR", "Upload","1500");
@@ -1058,28 +1079,11 @@
mbw_error_message("MSG_ERROR", "Upload","1500");
}else if(!in_array($file_ext, $mb_image_upload_files)){
mbw_error_message("MSG_UPLOAD_EXT_ERROR", $file_ext,"1502");
- }else{
- $fp_path = $uploadPath.$datePath.$file_name;
- if ( function_exists('imagecreatefromstring') && ($file_ext === 'jpg' || $file_ext === 'jpeg' || $file_ext === 'png') ) {
- //보안 처리를 위해 jpg, png 파일은 안전한 방식으로 이미지 생성
- //이미지 에디터는 jpg, png 확장자만 사용, 업로드 플러그인은 gif, bmp 확장자도 지원
- //imagegif 함수는 gif 모션기능이 제거되기 때문에 fwrite 함수로 저장
- $image = @imagecreatefromstring($fd);
- if ($image !== false) {
- if ($file_ext === 'jpg' || $file_ext === 'jpeg') {
- imagejpeg($image, $fp_path, 90);
- } elseif ($file_ext === 'png') {
- imagealphablending($image, false);
- imagesavealpha($image, true);
- imagepng($image, $fp_path);
- }
- imagedestroy($image);
- }
- } else {
- $fp = fopen($fp_path,"w");
- fwrite($fp,$fd);
- fclose($fp);
- }
+ }else{
+ $fp_path = $uploadPath.$datePath.$file_name;
+ $fp = fopen($fp_path,"w");
+ fwrite($fp,$fd);
+ fclose($fp);
if ( is_file($fp_path) ) {
@chmod($fp_path, 0644);
}
@@ -1110,10 +1114,15 @@
if(empty($image_size)) return false;
$image_type = $image_size[2];
}
+ $source = null;
if($image_type==2){ //jpg
$source = @imagecreatefromjpeg($filename);
}else if($image_type==3){ //png
$source = @imagecreatefrompng($filename);
+ if($source) {
+ imagealphablending($source, false);
+ imagesavealpha($source, true);
+ }
}
if(!empty($source)){
$orientation = $exif['Orientation'];
@@ -1126,13 +1135,17 @@
}else{
$angle = 0;
}
- $image = imagerotate($source, $angle, 0);
if($image_type==3 && function_exists("imagepng")){
+ $bg_color = imagecolorallocatealpha($source, 0, 0, 0, 127);
+ $image = imagerotate($source, $angle, $bg_color);
@imagepng($image, $filename);
+ @imagedestroy($image);
}else if(function_exists("imagejpeg")){
+ $bg_color = imagecolorallocate($source, 0, 0, 0);
+ $image = imagerotate($source, $angle, $bg_color);
@imagejpeg($image, $filename,100);
- }
- @imagedestroy($image);
+ @imagedestroy($image);
+ }
}
}
}
--- a/mangboard/includes/functions/func.board.php
+++ b/mangboard/includes/functions/func.board.php
@@ -80,14 +80,14 @@
global $mstore;
$content_length = $_SERVER['CONTENT_LENGTH'];
$upload_max = mbw_convert_to_bytes(ini_get("upload_max_filesize"));
- $post_max = mbw_convert_to_bytes(ini_get("post_max_size"));
+ $post_max = mbw_convert_to_bytes(ini_get("post_max_size"));
if($post_max<$upload_max) $upload_max = $post_max;
if($upload_max<$content_length){
mbw_error_message("MSG_UPLOAD_SIZE_ERROR", mbw_convert_to_bytes($upload_max,'mb'),"1503");
if(mbw_get_param('mode')=='basic' && mbw_get_param('action')=='mb_uploader'){
- echo mbw_get_result_data("message"); // phpcs:ignore
+ echo esc_html(strip_tags(mbw_get_result_data("message")));
}else{
wp_send_json(mbw_get_result_array());
}
@@ -1049,7 +1049,10 @@
$permission_name = __MW("W_COMMENT_WRITE");
}else if(mbw_get_param("board_action")=="modify"){
$permission_level = $comment_level;
- $permission_name = __MW("W_COMMENT_WRITE");
+ $permission_name = __MW("W_MODIFY");
+ }else if(mbw_get_param("board_action")=="delete"){
+ $permission_level = $comment_level;
+ $permission_name = __MW("W_DELETE");
}else{
$permission_level = $view_level;
$permission_name = __MW("W_VIEW");
@@ -1169,8 +1172,9 @@
}
$mb_error_message[] = $error_message;
- if(count($mb_error_message)==1){
- mbw_set_result_data(array("state"=>"error","code"=>$code,"target_name"=>$target_name,"message"=>$error_message));
+ if(count($mb_error_message)==1){
+ $error_message = wp_kses_post($error_message);
+ mbw_set_result_data(array("state"=>"error","code"=>esc_html($code),"target_name"=>esc_html($target_name),"message"=>$error_message));
//Error 로그 남기기
if(mbw_get_option("error_log")) mbw_set_log("error",$error_message);
return '<div class="mb-error-message-box">'.$error_message.'</div>';
@@ -1724,7 +1728,6 @@
}
}
-
if(!function_exists('mbw_is_image_file')){
function mbw_is_image_file($name){
global $mb_image_upload_files;
--- a/mangboard/includes/functions/func.store.php
+++ b/mangboard/includes/functions/func.store.php
@@ -332,6 +332,12 @@
$value = strip_tags(mbw_htmlspecialchars_decode($value));
}
}
+ if($field=="fn_modify_level" || $field=="fn_secret_level" || $field=="fn_delete_level" || $field=="fn_manage_level"){
+ $value = intval($value);
+ if($value<5){
+ $value = 5;
+ }
+ }
return $value;
}
}
--- a/mangboard/includes/functions/func.user.php
+++ b/mangboard/includes/functions/func.user.php
@@ -34,9 +34,11 @@
}
}else if($target=="board"){
$sign = "+";
- if($action=="write") $point = intval(mbw_get_board_option("fn_point_board_write"));
- else if($action=="reply") $point = intval(mbw_get_board_option("fn_point_board_reply"));
- else if($action=="delete"){
+ if(mbw_get_param("mode")=="write" && $action=="write"){
+ $point = intval(mbw_get_board_option("fn_point_board_write"));
+ }else if(mbw_get_param("mode")=="write" && $action=="reply"){
+ $point = intval(mbw_get_board_option("fn_point_board_reply"));
+ }else if($action=="delete"){
$point = intval(mbw_get_board_option("fn_point_board_write"))*(-1);
$board_pid = mbw_get_param("board_pid");
if(!empty($board_pid)){
@@ -246,9 +248,11 @@
}
}else if($target=="board"){
$sign = "+";
- if($action=="write") $point = intval(mbw_get_board_option("fn_point_board_write"));
- else if($action=="reply") $point = intval(mbw_get_board_option("fn_point_board_reply"));
- else if($action=="delete"){
+ if(mbw_get_param("mode")=="write" && $action=="write"){
+ $point = intval(mbw_get_board_option("fn_point_board_write"));
+ }else if(mbw_get_param("mode")=="write" && $action=="reply"){
+ $point = intval(mbw_get_board_option("fn_point_board_reply"));
+ }else if($action=="delete"){
$point = intval(mbw_get_board_option("fn_point_board_write"))*(-1);
$board_pid = mbw_get_param("board_pid");
if(!empty($board_pid)){
--- a/mangboard/includes/mb-actions.php
+++ b/mangboard/includes/mb-actions.php
@@ -539,12 +539,18 @@
mbw_add_trace("mbw_api_callback");
global $mdb,$mstore,$mb_fields,$mb_request_mode,$mb_languages,$send_data;
global $mb_admin_tables,$mb_board_table_name,$mb_comment_table_name;
+ $mode = mbw_value_filter(mbw_get_param("mode"), "name");
$action = mbw_value_filter(mbw_get_param("action"), "name");
$file_name = str_replace( "_", "-", $action).".php";
$store_path = mbw_get_option("store_path");
if ( !empty($store_path) ) {
$store_path = mbw_value_filter($store_path, "path");
}
+ // mode 값이 comment 로 설정되어 있고, action에 board 값이 존재할 경우 기본 api 파일로 설정
+ if ( $mode == "comment" && strpos($action, 'board') !== false) {
+ $file_name = "mb-comment.php";
+ }
+
/*
//구형 브라우저에서 오류가 발생하는 문제 때문에 보류 2026-10-27
if ( !mbw_is_login() ) {
--- a/mangboard/includes/mb-uploader.php
+++ b/mangboard/includes/mb-uploader.php
@@ -66,12 +66,10 @@
}
}
}else{
- // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- echo mbw_get_result_data("message");
+ echo esc_html(strip_tags(mbw_get_result_data("message")));
}
}else if(mbw_get_result_data("state")=="error"){
- // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- echo mbw_get_result_data("message");
+ echo esc_html(strip_tags(mbw_get_result_data("message")));
}
}
do_action('mbw_uploader_api_footer');
--- a/mangboard/includes/mb-version.php
+++ b/mangboard/includes/mb-version.php
@@ -1,5 +1,5 @@
<?php
-$mb_version = '2.4.7';
-$mb_index = '251';
+$mb_version = '2.4.8';
+$mb_index = '256';
$mb_db_version = '1.0.7';
?>
No newline at end of file
--- a/mangboard/includes/skin-filters.php
+++ b/mangboard/includes/skin-filters.php
@@ -75,7 +75,8 @@
$item["value"] = mbw_htmlspecialchars_decode($item["value"]);
$item_level = intval(mbw_get_board_item("fn_level", false));
- if ( $item_level == 0 ) { //비회원이 작성한 게시물은 추가 보안 검증
+ //레벨 10 (관리자) 이하의 회원이 작성했거나 DISALLOW_UNFILTERED_HTML 설정이 있을 경우 추가 검증
+ if ( $item_level < 10 || (defined('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML) ) {
if( function_exists('mbw_get_htmlpurify') && version_compare(PHP_VERSION, '5.4.0', '>=') ){
$item["value"] = mbw_get_htmlpurify($item["value"]);
} else {
--- a/mangboard/mangboard.php
+++ b/mangboard/mangboard.php
@@ -3,7 +3,7 @@
* Plugin Name: MangBoard
* Plugin URI: https://mangboard.com/
* Description: MangBoard는 Wordpress에서 게시판을 생성/관리 할 수 있는 기능을 제공합니다
- * Version: 2.4.7
+ * Version: 2.4.8
* Author: Hometory
* Author URI: https://www.hometory.com/
* License: GPLv2 or later
--- a/mangboard/models/admin/board_options.php
+++ b/mangboard/models/admin/board_options.php
@@ -113,10 +113,10 @@
{"field":"fn_view_level","name":"W_AUTHORITY_VIEW","width":"100px","type":"select","data":"0,1,2,3,4,5,6,7,8,9,10","default":"0","description":"<br>(MSG_SET_VIEW)"},
{"field":"fn_reply_level","name":"W_AUTHORITY_REPLAY","width":"100px","type":"select","data":"0,1,2,3,4,5,6,7,8,9,10,11","default":"0","description":"<br>(MSG_SET_REPLY)"},
{"field":"fn_comment_level","name":"W_AUTHORITY_COMMENT","width":"100px","type":"select","data":"0,1,2,3,4,5,6,7,8,9,10","default":"0","description":"<br>(MSG_SET_COMMENT)"},
-{"field":"fn_modify_level","name":"W_AUTHORITY_MODIFY","width":"100px","type":"select","data":"0,1,2,3,4,5,6,7,8,9,10","default":"8","description":"<br>(MSG_AUTHORITY_MODIFY)"},
-{"field":"fn_secret_level","name":"W_AUTHORITY_SECRET","width":"100px","type":"select","data":"0,1,2,3,4,5,6,7,8,9,10","default":"8","description":"<br>(MSG_AUTHORITY_SECRET_MSG)"},
-{"field":"fn_delete_level","name":"W_AUTHORITY_DELETE","width":"100px","type":"select","data":"0,1,2,3,4,5,6,7,8,9,10","default":"8","description":"<br>(MSG_AUTHORITY_DELETE)"},
-{"field":"fn_manage_level","name":"W_AUTHORITY_ADMIN","width":"100px","type":"select","data":"0,1,2,3,4,5,6,7,8,9,10","default":"8","description":"<br>(MSG_AUTHORITY_BOARD_ADMIN)"},
+{"field":"fn_modify_level","name":"W_AUTHORITY_MODIFY","width":"100px","type":"select","data":"5,6,7,8,9,10","default":"8","description":"<br>(MSG_AUTHORITY_MODIFY)"},
+{"field":"fn_secret_level","name":"W_AUTHORITY_SECRET","width":"100px","type":"select","data":"5,6,7,8,9,10","default":"8","description":"<br>(MSG_AUTHORITY_SECRET_MSG)"},
+{"field":"fn_delete_level","name":"W_AUTHORITY_DELETE","width":"100px","type":"select","data":"5,6,7,8,9,10","default":"8","description":"<br>(MSG_AUTHORITY_DELETE)"},
+{"field":"fn_manage_level","name":"W_AUTHORITY_ADMIN","width":"100px","type":"select","data":"5,6,7,8,9,10","default":"8","description":"<br>(MSG_AUTHORITY_BOARD_ADMIN)"},
{"tpl":"tag","tag_name":"table","type":"end"},
{"tpl":"tag","tag_name":"div","text":"■ '.__MW('W_POINT_SET').'","style":"margin-top:20px;font-weight:600;font-size:14px;padding:5px 2px;"},
--- a/mangboard/models/admin/users.php
+++ b/mangboard/models/admin/users.php
@@ -61,7 +61,7 @@
$desktop_model['write'] = '
{"tpl":"tag","tag_name":"table","type":"start","name":"W_EDIT_USER_INFO","width":"15%,*","mobile_width":"90px,*","class":"table table-write"},
{"field":"fn_user_id","name":"W_ID","width":"300px","required":"(*)","required_action":"write","unique":"","modify":"static","maxlength":"140","pattern":"pattern_en_num_4ge","pattern_error":"MSG_ID_INPUT_CHECK"},
-{"field":"fn_user_name","name":"W_NAME","width":"300px","required":"(*)","maxlength":"30","pattern":"pattern_2ge","pattern_error":"MSG_NAME_INPUT_2MORE"},
+{"field":"fn_user_name","name":"W_NAME","width":"300px","required":"(*)","required_error":"MSG_FIELD_EMPTY_ERROR2","maxlength":"30","pattern":"pattern_2ge","pattern_error":"MSG_NAME_INPUT_2MORE"},
{"field":"fn_passwd","name":"W_PASSWORD","width":"300px","type":"password","modify":"admin_user_name_password","pattern":"pattern_4ge","pattern_error":"MSG_PASSWORD_INPUT_4MORE"},
{"field":"fn_user_group","name":"W_GROUP","width":"300px","maxlength":"50"},
{"field":"fn_user_level","name":"W_LEVEL","width":"100px","type":"select","data":"0,1,2,3,4,5,6,7,8,9,10","default":"1","description":""},