From f4d7838a8f3ad4539e89f183449d04e5225ffe7b Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Sun, 28 Jun 2015 05:00:27 +0200 Subject: [PATCH] - move getStreamVariable() into extension --- change_log.txt | 1 + libs/sysplugins/smarty_internal_data.php | 17 +------- ...smarty_internal_extension_getstreamvar.php | 42 +++++++++++++++++++ 3 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 libs/sysplugins/smarty_internal_extension_getstreamvar.php diff --git a/change_log.txt b/change_log.txt index fe0521fc..280d7970 100644 --- a/change_log.txt +++ b/change_log.txt @@ -4,6 +4,7 @@ - optimize security isTrustedResourceDir() - move auto load filter methods into extension - move $smarty->getTemplateVars() into extension + - move getStreamVariable() into extension 27.06.2015 - bugfix resolve naming conflict between custom Smarty delimiter '<%' and PHP ASP tags https://github.com/smarty-php/smarty/issues/64 diff --git a/libs/sysplugins/smarty_internal_data.php b/libs/sysplugins/smarty_internal_data.php index cefaafd8..5ea03577 100644 --- a/libs/sysplugins/smarty_internal_data.php +++ b/libs/sysplugins/smarty_internal_data.php @@ -325,21 +325,6 @@ class Smarty_Internal_Data */ public function getStreamVariable($variable) { - $_result = ''; - $fp = fopen($variable, 'r+'); - if ($fp) { - while (!feof($fp) && ($current_line = fgets($fp)) !== false) { - $_result .= $current_line; - } - fclose($fp); - - return $_result; - } - $smarty = isset($this->smarty) ? $this->smarty : $this; - if ($smarty->error_unassigned) { - throw new SmartyException('Undefined stream variable "' . $variable . '"'); - } else { - return null; - } + return Smarty_Internal_Extension_GetStreamVar::getStreamVariable($this, $variable); } } diff --git a/libs/sysplugins/smarty_internal_extension_getstreamvar.php b/libs/sysplugins/smarty_internal_extension_getstreamvar.php new file mode 100644 index 00000000..5f09e908 --- /dev/null +++ b/libs/sysplugins/smarty_internal_extension_getstreamvar.php @@ -0,0 +1,42 @@ +smarty) ? $obj->smarty : $obj; + if ($smarty->error_unassigned) { + throw new SmartyException('Undefined stream variable "' . $variable . '"'); + } else { + return null; + } + } +} \ No newline at end of file