에디터 모듈에 HTML 허용 설정 추가

회원 모듈에도 no html 서명을 위한 옵션 추가
This commit is contained in:
conory 2017-07-13 00:46:28 +09:00
parent f7915f8204
commit da0ad3bd39
20 changed files with 179 additions and 142 deletions

View file

@ -358,7 +358,9 @@ class commentController extends comment
{
return new Object(-1, 'msg_invalid_document');
}
// creat the comment model object
$oCommentModel = getModel('comment');
// get a object of document model
$oDocumentModel = getModel('document');
@ -436,28 +438,7 @@ class commentController extends comment
// if use editor of nohtml, Remove HTML tags from the contents.
if(!$manual_inserted)
{
$editor_config = getModel('editor')->getEditorConfig($obj->module_srl);
if (strpos($editor_config->sel_comment_editor_colorset, 'nohtml') !== false)
{
$is_html_content = false;
}
elseif ($obj->use_editor === 'Y' || $obj->use_html === 'Y')
{
$is_html_content = true;
}
elseif ($obj->use_editor === 'N' || $obj->use_html === 'N')
{
$is_html_content = false;
}
else
{
$is_html_content = is_html_content($obj->content);
}
if (!$is_html_content)
{
$obj->content = nl2br($obj->use_html === 'Y' ? $obj->content : escape($obj->content, false));
}
$obj->content = $oCommentModel->filterHtml($obj);
}
if(!$obj->regdate)
@ -558,10 +539,7 @@ class commentController extends comment
$oDB->rollback();
return $output;
}
// creat the comment model object
$oCommentModel = getModel('comment');
// get the number of all comments in the posting
$comment_count = $oCommentModel->getCommentCount($document_srl);
@ -810,28 +788,7 @@ class commentController extends comment
// if use editor of nohtml, Remove HTML tags from the contents.
if(!$manual_updated)
{
$editor_config = getModel('editor')->getEditorConfig($obj->module_srl);
if (strpos($editor_config->sel_comment_editor_colorset, 'nohtml') !== false)
{
$is_html_content = false;
}
elseif ($obj->use_editor === 'Y' || $obj->use_html === 'Y')
{
$is_html_content = true;
}
elseif ($obj->use_editor === 'N' || $obj->use_html === 'N')
{
$is_html_content = false;
}
else
{
$is_html_content = is_html_content($obj->content);
}
if (!$is_html_content)
{
$obj->content = nl2br($obj->use_html === 'Y' ? $obj->content : escape($obj->content, false));
}
$obj->content = $oCommentModel->filterHtml($obj);
}
// remove iframe and script if not a top administrator on the session

View file

@ -951,6 +951,42 @@ class commentModel extends comment
return $comment_config;
}
/**
* Return filtered content
* @param object $obj
* @return string
*/
function filterHtml($obj)
{
$no_html = false;
$editor_config = getModel('editor')->getEditorConfig($obj->module_srl);
if ($editor_config->allow_html === 'N')
{
$no_html = true;
}
elseif (strpos($editor_config->sel_comment_editor_colorset, 'nohtml') !== false)
{
$no_html = true;
}
elseif ($obj->use_html === 'N')
{
$no_html = true;
}
if ($no_html || $obj->use_editor === 'N' || !is_html_content($obj->content))
{
if ($no_html)
{
$obj->content = escape(strip_tags($obj->content), false);
}
$obj->content = nl2br($obj->content);
}
return $obj->content;
}
/**
* Return a list of voting member

View file

@ -457,28 +457,7 @@ class documentController extends document
// if use editor of nohtml, Remove HTML tags from the contents.
if(!$manual_inserted)
{
$editor_config = getModel('editor')->getEditorConfig($obj->module_srl);
if (strpos($editor_config->sel_editor_colorset, 'nohtml') !== false)
{
$is_html_content = false;
}
elseif ($obj->use_editor === 'Y' || $obj->use_html === 'Y')
{
$is_html_content = true;
}
elseif ($obj->use_editor === 'N' || $obj->use_html === 'N')
{
$is_html_content = false;
}
else
{
$is_html_content = is_html_content($obj->content);
}
if (!$is_html_content)
{
$obj->content = nl2br($obj->use_html === 'Y' ? $obj->content : escape($obj->content, false));
}
$obj->content = $oDocumentModel->filterHtml($obj);
}
// Remove iframe and script if not a top adminisrator in the session.
@ -716,30 +695,9 @@ class documentController extends document
// if use editor of nohtml, Remove HTML tags from the contents.
if(!$manual_updated)
{
$editor_config = getModel('editor')->getEditorConfig($obj->module_srl);
if (strpos($editor_config->sel_editor_colorset, 'nohtml') !== false)
{
$is_html_content = false;
}
elseif ($obj->use_editor === 'Y' || $obj->use_html === 'Y')
{
$is_html_content = true;
}
elseif ($obj->use_editor === 'N' || $obj->use_html === 'N')
{
$is_html_content = false;
}
else
{
$is_html_content = is_html_content($obj->content);
}
if (!$is_html_content)
{
$obj->content = nl2br($obj->use_html === 'Y' ? $obj->content : escape($obj->content, false));
}
$obj->content = $oDocumentModel->filterHtml($obj);
}
// Change not extra vars but language code of the original document if document's lang_code is different from author's setting.
if($source_obj->get('lang_code') != Context::getLangType())
{

View file

@ -1246,7 +1246,43 @@ class documentModel extends document
return array_flip($this->getStatusList());
else return $lang->status_name_list;
}
/**
* Return filtered content
* @param object $obj
* @return string
*/
function filterHtml($obj)
{
$no_html = false;
$editor_config = getModel('editor')->getEditorConfig($obj->module_srl);
if ($editor_config->allow_html === 'N')
{
$no_html = true;
}
elseif (strpos($editor_config->sel_editor_colorset, 'nohtml') !== false)
{
$no_html = true;
}
elseif ($obj->use_html === 'N')
{
$no_html = true;
}
if ($no_html || $obj->use_editor === 'N' || !is_html_content($obj->content))
{
if ($no_html)
{
$obj->content = escape(strip_tags($obj->content), false);
}
$obj->content = nl2br($obj->content);
}
return $obj->content;
}
/**
* Setting sort index
* @param object $obj

View file

@ -147,21 +147,21 @@ class editorController extends editor
$editor_config->{$key} = explode('|@|', $grant);
}
}
$editor_config->editor_height = (int)Context::get('editor_height');
$editor_config->comment_editor_height = (int)Context::get('comment_editor_height');
$editor_config->enable_autosave = Context::get('enable_autosave');
if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N';
$editor_config->enable_autosave = Context::get('enable_autosave') ?: 'N';
$editor_config->allow_html = Context::get('allow_html') ?: 'Y';
$oModuleController = getController('module');
foreach ($module_srl as $srl)
{
$oModuleController->insertModulePartConfig('editor',$srl,$editor_config);
$oModuleController->insertModulePartConfig('editor', $srl, $editor_config);
}
$this->setError(-1);
$this->setMessage('success_updated', 'info');
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispBoardAdminContent');
$this->setRedirectUrl($returnUrl);
}

View file

@ -43,7 +43,8 @@ class editorModel extends editor
}
// Fill in some other values.
if($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y';
$editor_config->enable_autosave = $editor_config->enable_autosave ?: 'Y';
$editor_config->allow_html = $editor_config->allow_html ?: 'Y';
if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array();
if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array();
if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array();
@ -252,6 +253,9 @@ class editorModel extends editor
}
Context::set('enable_autosave', $option->enable_autosave);
// Set allow html
Context::set('allow_html', ($option->allow_html === false || $option->allow_html === 'N') ? false : true);
// Load editor components.
$site_srl = Context::get('site_module_info')->site_srl ?: 0;
if($option->editor_skin === 'dreditor')

View file

@ -71,6 +71,7 @@ $lang->enable_default_component_grant = 'Permission to use default components';
$lang->enable_extra_component_grant = 'Permission to use extra components';
$lang->enable_html_grant = 'Permission to edit HTML';
$lang->enable_autosave = 'Enable Auto-Save';
$lang->allow_html = 'allow HTML';
$lang->height_resizable = 'Height Resizable';
$lang->editor_height = 'Height of Editor';
$lang->about_default_editor_settings = 'Follow editor settings of Rhymix Admin page through whole site.';

View file

@ -75,6 +75,7 @@ $lang->enable_default_component_grant = '기본 컴포넌트 사용 권한';
$lang->enable_extra_component_grant = '확장 컴포넌트 사용 권한';
$lang->enable_html_grant = 'HTML 편집 권한';
$lang->enable_autosave = '자동저장 사용';
$lang->allow_html = 'HTML 허용';
$lang->height_resizable = '높이 조절 가능';
$lang->editor_height = '에디터 높이';
$lang->about_default_editor_settings = '사이트 전체 에디터 설정을 통일하여서 모듈별 에디터 설정을 단순하게 합니다.';

View file

@ -1,8 +1,3 @@
.rx_editor_wrapper {
clear: both;
}
.rx_editor_wrapper .rx_editor_textarea {
width: 100%;
min-height: 64px;
@ -16,4 +11,5 @@
.rx_editor_wrapper .rx_editor_textarea.dark {
border-color: #111;
background: #333;
color: #fff;
}

View file

@ -27,6 +27,11 @@
}
// Save edited content
<!--@if(!$allow_html)-->
textarea.on("change", function() {
content_input.val(String($(this).val()).escape());
});
<!--@else-->
textarea.on("change", function() {
content_input.val("<p>" + String($(this).val()).escape().replace(/\r?\n/g, "</p>\n<p>") + "</p>");
});
@ -45,7 +50,7 @@
} else {
parentform.append('<input type="hidden" name="use_html" value="Y" />');
}
<!--@end-->
});
</script>
</div>

View file

@ -89,6 +89,13 @@
</label>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right">{$lang->allow_html}</th>
<td colspan="2">
<label class="x_inline"><input type="radio" name="allow_html" value="Y" checked="checked"|cond="$editor_config->allow_html != 'N'" /> {$lang->cmd_yes}</label>
<label class="x_inline"><input type="radio" name="allow_html" value="N" checked="checked"|cond="$editor_config->allow_html == 'N'" /> {$lang->cmd_no}</label>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right">{$lang->enable_html_grant}</th>
<td>

View file

@ -74,6 +74,8 @@ $lang->options = 'Options';
$lang->about_keep_signed = 'You will be still signed in even when the browser is closed.\\n\\nIt is not recommended to use this if you are using a public computer, for your personal information could be violated.';
$lang->about_keep_warning = 'You will be still signed in even when the browser is closed. It is not recommended to use this if you are using a public computer, for your personal information could be violated';
$lang->about_webmaster_email = 'This setting can be changed in the <a href="index.php?module=admin&act=dispAdminConfigNotification" target="_blank">Notification Settings</a> screen.';
$lang->retroactive_application = 'retroact';
$lang->signature_html_retroact = 'also remove HTML in past inseted HTML signature. Can not be reversed.';
$lang->search_target_list['email_address'] = 'Email Address';
$lang->search_target_list['regdate'] = 'Sign up Date';
$lang->search_target_list['regdate_more'] = 'Sign up Date (more)';

View file

@ -76,6 +76,8 @@ $lang->options = '선택 옵션';
$lang->about_keep_signed = '브라우저를 닫더라도 로그인이 계속 유지될 수 있습니다.\\n\\n로그인 유지 기능을 사용할 경우 다음 접속부터는 로그인할 필요가 없습니다.\\n\\n단, PC방, 학교, 도서관 등 공공장소에서 이용 시 개인정보가 유출될 수 있으니 꼭 로그아웃을 해주세요.';
$lang->about_keep_warning = '브라우저를 닫더라도 로그인이 계속 유지될 수 있습니다. 로그인 유지 기능을 사용할 경우 다음 접속부터는 로그인할 필요가 없습니다. 단, PC방, 학교, 도서관 등 공공장소에서 이용 시 개인정보가 유출될 수 있으니 꼭 로그아웃을 해주세요.';
$lang->about_webmaster_email = '이 설정은 <a href="index.php?module=admin&act=dispAdminConfigNotification" target="_blank">알림 설정</a> 화면에서 변경할 수 있습니다.';
$lang->retroactive_application = '소급적용';
$lang->signature_html_retroact = '이전에 입력된 HTML 서명에서도 HTML을 제거 합니다. 되돌릴 수 없습니다.';
$lang->search_target_list['email_address'] = '이메일';
$lang->search_target_list['regdate'] = '가입일시';
$lang->search_target_list['regdate_more'] = '가입일시(이상)';
@ -120,7 +122,6 @@ $lang->cmd_view_scrapped_document = '스크랩 보기';
$lang->cmd_view_saved_document = '저장함 보기';
$lang->cmd_send_email = '메일 보내기';
$lang->cmd_modify_nickname_log = '닉네임 변경 기록';
$lang->cmd_member_file_upload = '서명에 파일 첨부 사용';
$lang->cmd_member_profile_view = '회원 프로필사진 보이기';
$lang->msg_email_not_exists = '이메일 주소가 존재하지 않습니다.';
$lang->msg_alreay_scrapped = '이미 스크랩된 게시물입니다.';
@ -170,7 +171,6 @@ $lang->msg_admin_ip_not_allowed = '접속하신 IP 주소에서는 관리자 로
$lang->about_rechecked_password = '회원의 정보를 안전하게 보호하기 위해 비밀번호를 다시 한번 확인 합니다.';
$lang->about_user_id = '회원 ID는 3~20자 사이의 영문+숫자로 이루어져야 하며 영문으로 시작해야 합니다.';
$lang->about_password = '비밀번호는 6~20자로 되어야 합니다.';
$lang->about_member_file_upload = '회원정보의 서명에 파일을 첨부할 수 있도록 합니다.';
$lang->cmd_config_password_strength = '비밀번호 보안수준';
$lang->cmd_password_hashing_algorithm = '비밀번호 암호화 알고리듬';
$lang->cmd_password_hashing_work_factor = '비밀번호 암호화 소요시간';

View file

@ -186,7 +186,6 @@ class memberAdminController extends member
'password_hashing_auto_upgrade',
'password_change_invalidate_other_sessions',
'update_nickname_log',
'member_allow_fileupload',
'member_profile_view'
);
@ -261,7 +260,7 @@ class memberAdminController extends member
'profile_image', 'profile_image_max_width', 'profile_image_max_height',
'image_name', 'image_name_max_width', 'image_name_max_height',
'image_mark', 'image_mark_max_width', 'image_mark_max_height',
'signature_editor_skin', 'sel_editor_colorset'
'signature_editor_skin', 'sel_editor_colorset', 'signature_html', 'signature_html_retroact', 'member_allow_fileupload'
);
$list_order = Context::get('list_order');

View file

@ -387,6 +387,7 @@ class memberAdminView extends member
$option = new stdClass;
$option->primary_key_name = 'member_srl';
$option->content_key_name = 'signature';
$option->allow_html = $member_config->signature_html !== 'N';
$option->allow_fileupload = $member_config->member_allow_fileupload === 'Y';
$option->enable_autosave = false;
$option->enable_default_component = true;

View file

@ -1618,18 +1618,22 @@ class memberController extends member
*/
function putSignature($member_srl, $signature)
{
$signature = trim(removeHackTag($signature));
$signature = preg_replace('/<(\/?)(embed|object|param)/is', '&lt;$1$2', $signature);
$check_signature = trim(str_replace(array('&nbsp;',"\n","\r"),'',strip_tags($signature,'<img><object>')));
$path = sprintf('files/member_extra_info/signature/%s/', getNumberingPath($member_srl));
$filename = sprintf('%s%d.signature.php', $path, $member_srl);
if(!$check_signature) return FileHandler::removeFile($filename);
if((!$signature = trim(removeHackTag($signature))) || is_empty_html_content($signature))
{
getController('member')->delSignature($member_srl);
return;
}
if(getModel('member')->getMemberConfig()->signature_html == 'N')
{
$signature = nl2br(escape(strip_tags($signature), false));
}
$filename = sprintf('files/member_extra_info/signature/%s%d.signature.php', getNumberingPath($member_srl), $member_srl);
$buff = sprintf('<?php if(!defined("__XE__")) exit();?>%s', $signature);
FileHandler::makeDir($path);
FileHandler::writeFile($filename, $buff);
Rhymix\Framework\Storage::write($filename, $buff);
return $signature;
}
/**

View file

@ -1030,12 +1030,23 @@ class memberModel extends member
$filename = sprintf('files/member_extra_info/signature/%s%d.signature.php', getNumberingPath($member_srl), $member_srl);
if(file_exists($filename))
{
$buff = FileHandler::readFile($filename);
$signature = preg_replace('/<\?.*\?>/', '', $buff);
$signature = preg_replace('/<\?.*\?>/', '', FileHandler::readFile($filename));
// retroact
$config = getModel('member')->getMemberConfig();
if($config->signature_html_retroact == 'Y' && $config->signature_html == 'N' && preg_match('/<[^br]+>/i', $signature))
{
return getController('member')->putSignature($member_srl, $signature);
}
$GLOBALS['__member_info__']['signature'][$member_srl] = $signature;
}
else $GLOBALS['__member_info__']['signature'][$member_srl] = null;
else
{
$GLOBALS['__member_info__']['signature'][$member_srl] = '';
}
}
return $GLOBALS['__member_info__']['signature'][$member_srl];
}

View file

@ -217,6 +217,7 @@ class memberView extends member
$option = new stdClass;
$option->primary_key_name = 'member_srl';
$option->content_key_name = 'signature';
$option->allow_html = $member_config->signature_html !== 'N';
$option->allow_fileupload = false;
$option->enable_autosave = false;
$option->enable_default_component = true;
@ -314,6 +315,7 @@ class memberView extends member
$option = new stdClass;
$option->primary_key_name = 'member_srl';
$option->content_key_name = 'signature';
$option->allow_html = $member_config->signature_html !== 'N';
$option->allow_fileupload = $member_config->member_allow_fileupload === 'Y';
$option->enable_autosave = false;
$option->enable_default_component = true;

View file

@ -108,14 +108,6 @@
<p class="x_help-inline">{$lang->about_member_sync}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->cmd_member_file_upload}</label>
<div class="x_controls">
<label for="member_allow_fileupload_y" class="x_inline"><input type="radio" name="member_allow_fileupload" id="member_allow_fileupload_y" value="Y" checked="checked"|cond="$config->member_allow_fileupload == 'Y'" /> {$lang->cmd_yes}</label>
<label for="member_allow_fileupload_n" class="x_inline"><input type="radio" name="member_allow_fileupload" id="member_allow_fileupload_n" value="N" checked="checked"|cond="$config->member_allow_fileupload != 'Y'" /> {$lang->cmd_no}</label>
<p class="x_help-block">{$lang->about_member_file_upload}</p>
</div>
</div>
<div class="btnArea x_clearfix">
<span class="x_pull-right"><input class="x_btn x_btn-primary" type="submit" value="{$lang->cmd_save}" /></span>
</div>

View file

@ -152,15 +152,40 @@
</div>
<div cond="$item->name == 'signature'" class="_subItem" style="display:none;padding-top:5px"|cond="!$item->isUse">
<select id="signature_editor" name="signature_editor_skin" onchange="getEditorSkinColorList(this.value)">
<!--@foreach($editor_skin_list as $editor_skin)-->
<option value="{$editor_skin}" selected="selected"|cond="$editor_skin==$config->signature_editor_skin">{$editor_skin}</option>
<!--@end-->
<!--@foreach($editor_skin_list as $editor_skin)-->
<option value="{$editor_skin}" selected="selected"|cond="$editor_skin == $config->signature_editor_skin">{$editor_skin}</option>
<!--@end-->
</select>
<select name="sel_editor_colorset" id="sel_editor_colorset" style="display:none">
</select>
<script>//<![CDATA[
<select name="sel_editor_colorset" id="sel_editor_colorset" style="display:none"></select>
<p class="x_help-block">{$lang->allow_html}
<label class="x_inline"><input type="radio" name="signature_html" id="signature_html_yes" value="Y" checked="checked"|cond="$config->signature_html != 'N'" /> {$lang->cmd_yes}</label>
<label class="x_inline"><input type="radio" name="signature_html" id="signature_html_no" value="N" checked="checked"|cond="$config->signature_html == 'N'" /> {$lang->cmd_no}</label>
<label class="x_inline" id="signature_html_retroact" title="{$lang->signature_html_retroact}" style="">
<input type="checkbox" name="signature_html_retroact" value="Y" checked="checked"|cond="$config->signature_html_retroact == 'Y'" /> {$lang->retroactive_application}
</label>
</p>
<p class="x_help-block">{$lang->file_upload}
<label class="x_inline"><input type="radio" name="member_allow_fileupload" value="Y" checked="checked"|cond="$config->member_allow_fileupload == 'Y'" /> {$lang->cmd_yes}</label>
<label class="x_inline"><input type="radio" name="member_allow_fileupload" value="N" checked="checked"|cond="$config->member_allow_fileupload != 'Y'" /> {$lang->cmd_no}</label>
</p>
<script>
getEditorSkinColorList('{$config->signature_editor_skin}','{$config->sel_editor_colorset}');
//]]></script>
if(!$('#signature_html_no').is(':checked'))
{
$('#signature_html_retroact').hide();
}
$('#signature_html_yes').change(function(){
if($(this).is(':checked')){
$('#signature_html_retroact').hide();
}
});
$('#signature_html_no').change(function(){
if($(this).is(':checked')){
$('#signature_html_retroact').show();
}
});
</script>
</div>
</td>
<td class="desc">&nbsp;</td>