Merge pull request #1197 from kijin/pr/customize-bottom-list

게시판 하단목록 관련 설정 추가
This commit is contained in:
Kijin Sung 2019-09-14 21:57:21 +09:00 committed by GitHub
commit ffdd36bb09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 99 additions and 13 deletions

View file

@ -115,6 +115,7 @@ return array(
'classes' => array(),
),
'security' => array(
'robot_user_agents' => array(),
'check_csrf_token' => false,
'nofollow' => false,
),

View file

@ -151,6 +151,16 @@ class UA
return self::$_robot_cache[$ua] = true;
}
// Use the custom user-agent list.
$customlist = Config::get('security.robot_user_agents') ?: array();
foreach ($customlist as $item)
{
if (strpos($ua, $item) !== false)
{
return self::$_robot_cache[$ua] = true;
}
}
// If we're here, it's probably not a robot.
return self::$_robot_cache[$ua] = false;
}

View file

@ -652,6 +652,13 @@ class adminAdminController extends admin
natcasesort($classes);
Rhymix\Framework\Config::set('mediafilter.classes', array_values($classes));
// Robot user agents
$robot_user_agents = $vars->robot_user_agents;
$robot_user_agents = array_filter(array_map('trim', preg_split('/[\r\n]/', $robot_user_agents)), function($item) {
return $item !== '';
});
Rhymix\Framework\Config::set('security.robot_user_agents', array_values($robot_user_agents));
// Remove old embed filter
$config = Rhymix\Framework\Config::getAll();
unset($config['embedfilter']);

View file

@ -438,6 +438,10 @@ class adminAdminView extends admin
context::set('mediafilter_object', implode(PHP_EOL, Rhymix\Framework\Filters\MediaFilter::getObjectWhitelist()));
context::set('mediafilter_classes', implode(PHP_EOL, Rhymix\Framework\Config::get('mediafilter.classes') ?: array()));
// Load robot user agents.
$robot_user_agents = Rhymix\Framework\Config::get('security.robot_user_agents') ?: array();
Context::set('robot_user_agents', implode(PHP_EOL, $robot_user_agents));
// Admin IP access control
$allowed_ip = Rhymix\Framework\Config::get('admin.allow');
Context::set('admin_allowed_ip', implode(PHP_EOL, $allowed_ip));

View file

@ -28,6 +28,12 @@
<textarea name="mediafilter_classes" id="mediafilter_classes" rows="4" style="width:100%;">{$mediafilter_classes}</textarea>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="robot_user_agents">Robot User Agents</label>
<div class="x_controls" style="margin-right:14px">
<textarea name="robot_user_agents" id="robot_user_agents" rows="4" style="width:100%;">{$robot_user_agents}</textarea>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="admin_allowed_ip">{$lang->admin_ip_allow}</label>
<div class="x_controls">

View file

@ -44,12 +44,16 @@ class boardAdminController extends board {
// setup other variables
if($args->except_notice != 'Y') $args->except_notice = 'N';
if($args->use_bottom_list != 'Y') $args->use_bottom_list = 'N';
if($args->skip_bottom_list_for_olddoc != 'Y') $args->skip_bottom_list_for_olddoc = 'N';
if($args->skip_bottom_list_for_robot != 'Y') $args->skip_bottom_list_for_robot = 'N';
if($args->use_anonymous != 'Y') $args->use_anonymous = 'N';
if($args->consultation != 'Y') $args->consultation = 'N';
if($args->protect_content!= 'Y') $args->protect_content = 'N';
if(!in_array($args->order_target,$this->order_target) && !array_key_exists($args->order_target, $extra_order_target)) $args->order_target = 'list_order';
if(!in_array($args->order_type, array('asc', 'desc'))) $args->order_type = 'asc';
$args->skip_bottom_list_days = max(0, intval($args->skip_bottom_list_days));
$args->browser_title = trim(utf8_normalize_spaces($args->browser_title));
$args->meta_keywords = $args->meta_keywords ? implode(', ', array_map('trim', explode(',', $args->meta_keywords))) : '';
$args->meta_description = trim(utf8_normalize_spaces($args->meta_description));

View file

@ -449,7 +449,7 @@ class boardView extends board
**/
function dispBoardNoticeList(){
// check the grant
if(!$this->grant->list)
if(!$this->grant->list || (Context::get('document_srl') && $this->module_info->use_bottom_list === 'N'))
{
Context::set('notice_list', array());
return;
@ -467,7 +467,7 @@ class boardView extends board
**/
function dispBoardContentList(){
// check the grant
if(!$this->grant->list)
if(!$this->grant->list || (Context::get('document_srl') && $this->module_info->use_bottom_list === 'N'))
{
Context::set('document_list', array());
Context::set('total_count', 0);
@ -482,7 +482,7 @@ class boardView extends board
// setup module_srl/page number/ list number/ page count
$args = new stdClass();
$args->module_srl = $this->module_srl;
$args->page = Context::get('page');
$args->page = intval(Context::get('page')) ?: null;
$args->list_count = $this->list_count;
$args->page_count = $this->page_count;
@ -525,14 +525,25 @@ class boardView extends board
// set the current page of documents
$document_srl = Context::get('document_srl');
if(!$args->page && $document_srl)
if($document_srl && $this->module_info->skip_bottom_list_for_robot === 'Y' && isCrawler())
{
Context::set('page', $args->page = null);
}
elseif(!$args->page && $document_srl)
{
$oDocument = $oDocumentModel->getDocument($document_srl);
if($oDocument->isExists() && !$oDocument->isNotice())
{
$page = $oDocumentModel->getDocumentPage($oDocument, $args);
Context::set('page', $page);
$args->page = $page;
$days = $this->module_info->skip_bottom_list_days ?: 30;
if($oDocument->getRegdateTime() < (time() - (86400 * $days)) && $this->module_info->skip_bottom_list_for_olddoc === 'Y')
{
Context::set('page', $args->page = null);
}
else
{
$args->page = $oDocumentModel->getDocumentPage($oDocument, $args);
Context::set('page', $args->page);
}
}
}

View file

@ -1,6 +1,8 @@
<?php
$lang->board = 'Board';
$lang->except_notice = 'Exclude Notices';
$lang->use_bottom_list = 'Display Bottom List';
$lang->customize_bottom_list = 'Customize Bottom List';
$lang->use_anonymous = 'Use Anonymous';
$lang->anonymous_name = 'Anonymous Name for Display';
$lang->cmd_manage_menu = 'Manage Menus';
@ -20,11 +22,14 @@ $lang->cmd_board_list = 'Boards List';
$lang->cmd_module_config = 'Common Board Setting';
$lang->cmd_board_info = 'Board Info';
$lang->cmd_list_setting = 'List Setting';
$lang->cmd_list_items = 'Displayed Items and Order';
$lang->cmd_create_board = 'Create a new board';
$lang->cmd_manage_selected_board = 'Manage Selected Board';
$lang->about_layout_setup = 'You can manually modify board layout code. Insert or manage the widget code anywhere you want';
$lang->about_board_category = 'You can make board categories. When board category is broken, try rebuilding the cache file manually.';
$lang->about_except_notice = 'Notice articles will not be displayed on normal list.';
$lang->about_except_notice = 'Notices will not be displayed in the normal list.<br />Caution: using this option can increase DB load if you have many visitors and lots of articles.';
$lang->about_use_bottom_list = 'Display the list at the bottom when viewing an article.';
$lang->about_customize_bottom_list = 'Calculating the bottom list consumes a lot of server resources.<br />You may be able to reduce DB load by not calculating it exactly when not needed.<br />This should have no effect on SEO.';
$lang->about_use_anonymous_part1 = 'Hide the author\'s nickname to turn this board into an anonymous board.';
$lang->about_use_anonymous_part2 = 'It is more useful if you also hide the nickname in the skin.<br>Please also turn off document history, or the author\'s information may be revealed by the history.';
$lang->about_anonymous_name = 'You can customize the anonymous name that is displayed instead of the author\'s nickname.<br><b>$NUM</b> will be replaced with a random number that is unique to each member. (e.g. anon_$NUM → anon_12345678)<br><b>$DAILYNUM</b> will be replaced with a random number that is unique to each member but changes every day.<br><b>$DOCNUM</b> will be replaced with a random number that is unique to each member and changes from document to document.<br><b>$DOCDAILYNUM</b> will be replaced with a random number that is unique to each member and changes every day from document to document.';
@ -36,6 +41,8 @@ $lang->about_list_config = 'If using list-style skin, you may arrange items to d
$lang->about_use_status = 'Please select status that can be selected when you write article.';
$lang->about_protect_comment = 'Prevent updating or deleting a comment if it has children.';
$lang->about_update_log = 'Store a log of every version of a document every time it is updated.';
$lang->skip_bottom_list_for_olddoc = 'Do not calculate the bottom list exactly when viewing an old article.';
$lang->skip_bottom_list_for_robot = 'Do not calculate the bottom list exactly when a robot is visiting.';
$lang->msg_not_enough_point = 'Your point is not enough to write an article in this board.';
$lang->write_comment = 'Write a comment';
$lang->msg_not_allow_comment = 'This article is not allowed to write comment.';

View file

@ -1,6 +1,8 @@
<?php
$lang->board = '게시판';
$lang->except_notice = '공지사항 제외';
$lang->use_bottom_list = '하단목록 표시';
$lang->customize_bottom_list = '하단목록 설정';
$lang->use_anonymous = '익명 사용';
$lang->anonymous_name = '익명 닉네임';
$lang->cmd_manage_menu = '메뉴관리';
@ -20,12 +22,15 @@ $lang->last_updater = '수정한 사람';
$lang->cmd_board_list = '게시판 목록';
$lang->cmd_module_config = '게시판 공통 설정';
$lang->cmd_board_info = '게시판 정보';
$lang->cmd_list_setting = '목록설정';
$lang->cmd_list_setting = '목록 설정';
$lang->cmd_list_items = '표시 항목 및 순서';
$lang->cmd_create_board = '게시판 등록';
$lang->cmd_manage_selected_board = '선택한 게시판 관리';
$lang->about_layout_setup = '블로그의 레이아웃 코드를 직접 수정할 수 있습니다. 위젯 코드를 원하는 곳에 삽입하시거나 관리하세요';
$lang->about_board_category = '분류를 만들 수 있습니다. 분류가 오동작을 할 경우 캐시파일 재생성을 수동으로 해주시면 해결이 될 수 있습니다.';
$lang->about_except_notice = '목록 상단에 늘 나타나는 공지사항을 일반 목록에서 공지사항을 출력하지 않도록 합니다.';
$lang->about_except_notice = '목록 상단에 늘 나타나는 공지사항을 일반 목록에 출력하지 않도록 합니다.<br />주의: 이용자와 게시물이 많은 게시판에서 이 옵션을 사용하면 DB 부하를 유발할 수 있습니다.';
$lang->about_use_bottom_list = '글읽기 화면 하단에도 목록을 표시합니다.';
$lang->about_customize_bottom_list = '게시물이 많은 경우 하단목록 계산에 많은 서버 자원이 소요됩니다.<br />불필요한 상황에서 하단목록을 계산하지 않도록 하면 DB 부하를 크게 줄일 수 있습니다.<br />검색 노출에는 영향을 주지 않습니다.';
$lang->about_use_anonymous_part1 = '글쓴이의 정보를 제거하고 익명으로 게시판을 사용하도록 합니다.';
$lang->about_use_anonymous_part2 = '스킨 설정에서 글쓴이 정보 등을 숨기도록 설정하면 더욱 유용합니다.<br>추가 설정에서 문서 히스토리가 켜져 있으면 문서 수정시 작성자가 표시될 수 있으니 주의하십시오.';
$lang->about_anonymous_name = '익명 기능을 사용할 때 표시할 익명 닉네임을 정할 수 있습니다.<br><b>$NUM</b>을 사용하면 회원마다 고유한 난수를 부여할 수 있습니다. (예: 익명_$NUM → 익명_12345678)<br><b>$DAILYNUM</b>을 사용하면 매일 난수가 변경되고, <b>$DOCNUM</b>을 사용하면 문서마다 변경됩니다.<br><b>$DOCDAILYNUM</b>을 사용하면 문서마다 각각, 그리고 매일 변경됩니다.';
@ -37,6 +42,8 @@ $lang->about_list_config = '게시판의 목록형식 사용시 원하는 항목
$lang->about_use_status = '글 작성 시 선택할 수 있는 상태를 지정해주세요.';
$lang->about_protect_comment = '댓글의 댓글이 있을경우 해당댓글을 삭제 및 수정을 할 수 없도록 합니다.';
$lang->about_update_log = '게시글을 수정할 경우 수정한 내역을 저장하도록 합니다.';
$lang->skip_bottom_list_for_olddoc = '오래된 게시물 열람시 하단 목록을 정확하게 계산하지 않음';
$lang->skip_bottom_list_for_robot = '로봇 방문시 하단 목록을 정확하게 계산하지 않음';
$lang->msg_not_enough_point = '포인트가 부족합니다';
$lang->write_comment = '댓글 쓰기';
$lang->msg_not_allow_comment = '해당 글의 댓글 쓰기가 잠겨있습니다.';

View file

@ -163,9 +163,9 @@
</div>
</section>
<section class="section">
<h1>{$lang->subtitle_advanced}</h1>
<h1>{$lang->cmd_list_setting}</h1>
<div class="x_control-group">
<label class="x_control-label">{$lang->cmd_list_setting}</label>
<label class="x_control-label">{$lang->cmd_list_items}</label>
<div class="x_controls">
{@$list = array_keys($list_config)}
<input type="hidden" name="list" value="{implode(',', $list)}" />
@ -209,9 +209,38 @@
<div class="x_control-group">
<label class="x_control-label">{$lang->except_notice}</label>
<div class="x_controls">
<label class="x_inline" for="except_notice"><input type="checkbox" name="except_notice" id="except_notice" value="Y" checked="checked"|cond="$module_info->except_notice != 'N'" /> {$lang->about_except_notice}</label>
<label class="x_inline" for="except_notice_Y"><input type="radio" name="except_notice" id="except_notice_Y" value="Y" checked="checked"|cond="$module_info->except_notice !== 'N'" /> {$lang->cmd_yes}</label>
<label class="x_inline" for="except_notice_N"><input type="radio" name="except_notice" id="except_notice_N" value="N" checked="checked"|cond="$module_info->except_notice === 'N'" /> {$lang->cmd_no}</label>
<p class="x_help-block">{$lang->about_except_notice}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->use_bottom_list}</label>
<div class="x_controls">
<label class="x_inline" for="use_bottom_list_Y"><input type="radio" name="use_bottom_list" id="use_bottom_list_Y" value="Y" checked="checked"|cond="$module_info->use_bottom_list !== 'N'" /> {$lang->cmd_yes}</label>
<label class="x_inline" for="use_bottom_list_N"><input type="radio" name="use_bottom_list" id="use_bottom_list_N" value="N" checked="checked"|cond="$module_info->use_bottom_list === 'N'" /> {$lang->cmd_no}</label>
<p class="x_help-block">{$lang->about_use_bottom_list}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->customize_bottom_list}</label>
<div class="x_controls">
<label for="skip_bottom_list_for_olddoc" class="x_inline">
<input type="checkbox" name="skip_bottom_list_for_olddoc" id="skip_bottom_list_for_olddoc" value="Y" checked="checked"|cond="$module_info->skip_bottom_list_for_olddoc === 'Y'" />
{$lang->skip_bottom_list_for_olddoc}
</label>
<input type="number" name="skip_bottom_list_days" value="{$module_info->skip_bottom_list_days ?: 30}" /> {$lang->unit_day}
<br />
<label for="skip_bottom_list_for_robot">
<input type="checkbox" name="skip_bottom_list_for_robot" id="skip_bottom_list_for_robot" value="Y" checked="checked"|cond="$module_info->skip_bottom_list_for_robot === 'Y'" />
{$lang->skip_bottom_list_for_robot}
</label>
<p class="x_help-block">{$lang->about_customize_bottom_list}</p>
</div>
</div>
</section>
<section class="section">
<h1>{$lang->subtitle_advanced}</h1>
<div class="x_control-group">
<label class="x_control-label">{$lang->use_anonymous}</label>
<div class="x_controls">