/**
* Add templates to the archive
*
* @param ZipWriter $objArchive
* @param string $strFolder
*/
protected function addTemplatesToArchive(ZipWriter $objArchive, $strFolder)
{
// Strip the templates folder name
$strFolder = preg_replace('@^templates/@', '', $strFolder);
// Re-add the templates folder name
if ($strFolder == '') {
$strFolder = 'templates';
} else {
$strFolder = 'templates/' . $strFolder;
}
if (\Validator::isInsecurePath($strFolder)) {
throw new \RuntimeException('Insecure path ' . $strFolder);
}
// Return if the folder does not exist
if (!is_dir(TL_ROOT . '/' . $strFolder)) {
return;
}
$arrAllowed = \StringUtil::trimsplit(',', strtolower(\Config::get('templateFiles')));
array_push($arrAllowed, 'sql');
// see #7048
// Add all template files to the archive
foreach (scan(TL_ROOT . '/' . $strFolder) as $strFile) {
if (preg_match('/\\.(' . implode('|', $arrAllowed) . ')$/', $strFile) && strncmp($strFile, 'be_', 3) !== 0 && strncmp($strFile, 'nl_', 3) !== 0) {
$objArchive->addFile($strFolder . '/' . $strFile);
}
}
}