Fix #2114 Allow specifying file formats to be indexed

This commit is contained in:
mmx900 2023-06-14 19:13:48 +09:00
parent 22abeb7a88
commit 9611fc7bda
5 changed files with 36 additions and 1 deletions

View file

@ -400,7 +400,30 @@ 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');
$allow_indexing = false;
// Handles extension to allow indexing
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))
{
$allow_indexing = true;
break;
}
}
}
if(!$allow_indexing)
{
header('X-Robots-Tag: noindex');
}
header('Location: ' . $url);
Context::close();
exit();