mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 10:11:38 +09:00
Merge pull request #2140 from mmx900/feature/allow_indexing_format
첨부파일들 중 지정한 확장자에 한해 색인을 허용 기능 추가
This commit is contained in:
commit
7a7b80baa6
6 changed files with 49 additions and 2 deletions
|
|
@ -158,6 +158,7 @@ class FileAdminController extends File
|
|||
$config->allow_outlink = Context::get('allow_outlink') === 'N' ? 'N' : 'Y';
|
||||
$config->allow_outlink_format = Context::get('allow_outlink_format');
|
||||
$config->allow_outlink_site = Context::get('allow_outlink_site');
|
||||
$config->allow_indexing_format = Context::get('allow_indexing_format');
|
||||
$config->allow_multimedia_direct_download = Context::get('allow_multimedia_direct_download') === 'Y' ? 'Y' : 'N';
|
||||
$config->download_short_url = Context::get('download_short_url') === 'Y' ? 'Y' : 'N';
|
||||
$config->inline_download_format = array_map('utf8_trim', Context::get('inline_download_format') ?: []);
|
||||
|
|
|
|||
|
|
@ -400,7 +400,11 @@ class FileController extends File
|
|||
$url = getNotEncodedUrl('', 'module', 'file', 'act', 'procFileOutput', 'file_srl', $file_srl, 'file_key', $file_key, 'force_download', Context::get('force_download') === 'Y' ? 'Y' : null);
|
||||
}
|
||||
|
||||
header('X-Robots-Tag: noindex');
|
||||
if (!FileModel::isIndexable($filename, $file_module_config))
|
||||
{
|
||||
header('X-Robots-Tag: noindex');
|
||||
}
|
||||
|
||||
header('Location: ' . $url);
|
||||
Context::close();
|
||||
exit();
|
||||
|
|
@ -549,7 +553,11 @@ class FileController extends File
|
|||
header('Content-Length: ' . $range_length);
|
||||
header('Accept-Ranges: bytes');
|
||||
header('Etag: "' . $etag . '"');
|
||||
header('X-Robots-Tag: noindex');
|
||||
|
||||
if (!FileModel::isIndexable($filename, $file_config))
|
||||
{
|
||||
header('X-Robots-Tag: noindex' . false);
|
||||
}
|
||||
|
||||
// Print the file contents
|
||||
for($offset = 0; $offset < $range_length; $offset += 4096)
|
||||
|
|
|
|||
|
|
@ -181,6 +181,33 @@ class FileModel extends File
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the file is indexable
|
||||
* @param object $filename
|
||||
* @param object $file_module_config
|
||||
* @return bool
|
||||
*/
|
||||
public static function isIndexable($filename, $file_module_config)
|
||||
{
|
||||
if($file_module_config->allow_indexing_format)
|
||||
{
|
||||
$allow_indexing_format_array = array();
|
||||
$allow_indexing_format_array = explode(',', $file_module_config->allow_indexing_format);
|
||||
if(!is_array($allow_indexing_format_array)) $allow_indexing_format_array[0] = $file_module_config->allow_indexing_format;
|
||||
|
||||
foreach($allow_indexing_format_array as $val)
|
||||
{
|
||||
$val = trim($val);
|
||||
if(preg_match("/\.{$val}$/i", $filename))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the file is deletable
|
||||
*
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ $lang->status = 'Status';
|
|||
$lang->is_valid = 'Valid';
|
||||
$lang->is_stand_by = 'Stand by';
|
||||
$lang->file_list = 'Attachment List';
|
||||
$lang->allow_indexing_format = 'Allowed formats to be indexed';
|
||||
$lang->allow_outlink = 'Allow External Link to Download URL';
|
||||
$lang->allow_outlink_site = 'Allowed Websites';
|
||||
$lang->allow_outlink_format = 'Allowed Formats';
|
||||
|
|
@ -33,6 +34,7 @@ $lang->about_use_default_file_config = 'Follow the default settings from the Fil
|
|||
$lang->about_download_short_url = 'Using short URLs can fix broken filenames in Android and some other platforms.<br />Short URLs must be enabled, and rewrite rules must be updated to the latest version if you use nginx.';
|
||||
$lang->about_inline_download_format = 'Selected types of files will be opened in the current window instead of a download dialog when a user clicks the download link.';
|
||||
$lang->enable_download_group = 'Downloadable Groups';
|
||||
$lang->about_allow_indexing_format = 'These file formats will be allowed to be indexed by search engines like Google.<br />This can increase server load and traffic, and you should be careful not to expose files containing confidential information.<br />Please use a comma (,) to separate items: e.g. doc, zip, pdf';
|
||||
$lang->about_allow_outlink = 'Allow other websites to link directly to your download URLs.<br />Rhymix does not control links to image files that can be embedded directly in a document.<br />in order to block external links to such images, you may need to modify your web server configuration.';
|
||||
$lang->about_allow_outlink_format = 'These file formats will always be allowed.<br />Please use a comma (,) to separate items: e.g. doc, zip, pdf';
|
||||
$lang->about_allow_outlink_site = 'These referers will always be allowed.<br />Please enter one full address per line: e.g. https://www.rhymix.org/';
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ $lang->status = '상태';
|
|||
$lang->is_valid = '유효';
|
||||
$lang->is_stand_by = '대기';
|
||||
$lang->file_list = '첨부 파일 목록';
|
||||
$lang->allow_indexing_format = '외부 색인 허용 확장자';
|
||||
$lang->allow_outlink = '다운로드 링크 외부 접근 허용';
|
||||
$lang->allow_outlink_site = '외부 접근 허용 사이트';
|
||||
$lang->allow_outlink_format = '외부 접근 허용 확장자';
|
||||
|
|
@ -33,6 +34,7 @@ $lang->about_use_default_file_config = '파일 모듈의 기본 설정을 따릅
|
|||
$lang->about_download_short_url = '안드로이드 등 일부 환경에서 첨부파일 다운로드시 파일명이 깨지는 문제를 해결할 수 있습니다.<br />짧은주소 사용이 활성화되어 있어야 하며, nginx 사용시 rewrite 규칙을 최신 버전으로 업데이트하여야 합니다.';
|
||||
$lang->about_inline_download_format = '선택한 종류의 파일은 다운로드 링크를 클릭하더라도 다운로드 창을 열지 않고 현재 창에 표시합니다.';
|
||||
$lang->enable_download_group = '다운로드 가능 그룹';
|
||||
$lang->about_allow_indexing_format = '구글 등 검색엔진에 의한 색인을 허용하는 파일 확장자입니다.<br />서버 부하와 트래픽이 증가할 수 있으며, 개인정보가 포함된 파일이 노출되지 않게 주의해야 합니다.<br />여러 개 입력시 쉼표(,)을 이용해서 구분해 주세요. 예) doc, zip, pdf';
|
||||
$lang->about_allow_outlink = '다른 사이트에서 파일 다운로드 링크에 직접 접근하는 것을 허용합니다.<br />본문에 바로 삽입할 수 있는 이미지 파일은 라이믹스에서 접근을 통제할 수 없으며, 이를 차단하려면 웹서버 설정이 필요합니다.';
|
||||
$lang->about_allow_outlink_format = '파일 외부 링크 설정에 상관없이 허용하는 파일 확장자입니다.<br />여러 개 입력시 쉼표(,)을 이용해서 구분해 주세요. 예) doc, zip, pdf';
|
||||
$lang->about_allow_outlink_site = '파일 외부 링크 설정에 상관없이 허용하는 사이트 주소입니다.<br />여러 개 입력시 줄을 바꿔서 구분해 주세요. 예) https://www.rhymix.org/';
|
||||
|
|
|
|||
|
|
@ -57,6 +57,13 @@
|
|||
<p class="x_help-block">{$lang->about_inline_download_format}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="allow_indexing_format">{$lang->allow_indexing_format}</label>
|
||||
<div class="x_controls">
|
||||
<input type="text" name="allow_indexing_format" id="allow_indexing_format" value="{$config->allow_indexing_format}" />
|
||||
<p class="x_help-block">{$lang->about_allow_indexing_format}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_clearfix btnArea">
|
||||
<div class="x_pull-right">
|
||||
<button type="submit" class="x_btn x_btn-primary">{$lang->cmd_save}</button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue