添加模板编译文件、缓存文件的安全代码

This commit is contained in:
TOP糯米 2019-09-01 12:01:55 +08:00
parent 139e845cc0
commit fb82505a07
2 changed files with 3 additions and 3 deletions
framework/library
cache/driver
template/driver/engine

View File

@ -67,8 +67,8 @@ class File implements CacheIfs
if (is_array($value) || is_object($value)) {
$value = json_encode($value);
}
$value = '<?php $timeout = ' . $timeout . '; ?>' . PHP_EOL . $value;
if (file_put_contents($filename, $value)) {
$content = '<?php if (!defined(\'APP_PATH\')) { exit; } $timeout = ' . $timeout . '; ?>' . PHP_EOL . $value;
if (file_put_contents($filename, $content)) {
return true;
}
return false;

View File

@ -487,7 +487,7 @@ class Engine
// 处理定义的标签
$template = $this->parseTags($template);
return $template;
return '<?php if (!defined(\'APP_PATH\')) { exit; } ?>' . $template;
}
}