mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 19:22:14 +02:00
update smarty to 4.1.1 (php 8.1 support)
This commit is contained in:
parent
2d6ded2786
commit
6eb209ac55
@ -39,7 +39,7 @@ class Smarty_Autoloader
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $rootClasses = array('smarty' => 'Smarty.class.php', 'smartybc' => 'SmartyBC.class.php',);
|
||||
public static $rootClasses = array('smarty' => 'Smarty.class.php');
|
||||
|
||||
/**
|
||||
* Registers Smarty_Autoloader backward compatible to older installations.
|
||||
@ -76,11 +76,7 @@ class Smarty_Autoloader
|
||||
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
||||
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
|
||||
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||
} else {
|
||||
spl_autoload_register(array(__CLASS__, 'autoload'));
|
||||
}
|
||||
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,7 @@
|
||||
* Smarty mailing list. Send a blank e-mail to
|
||||
* smarty-discussion-subscribe@googlegroups.com
|
||||
*
|
||||
* @link http://www.smarty.net/
|
||||
* @link https://www.smarty.net/
|
||||
* @copyright 2018 New Digital Group, Inc.
|
||||
* @copyright 2018 Uwe Tews
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
@ -60,19 +60,6 @@ if (!defined('SMARTY_MBSTRING')) {
|
||||
*/
|
||||
define('SMARTY_MBSTRING', function_exists('mb_get_info'));
|
||||
}
|
||||
if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
|
||||
// UTF-8 can only be done properly when mbstring is available!
|
||||
/**
|
||||
* @deprecated in favor of Smarty::$_CHARSET
|
||||
*/
|
||||
define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1');
|
||||
}
|
||||
if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
|
||||
/**
|
||||
* @deprecated in favor of Smarty::$_DATE_FORMAT
|
||||
*/
|
||||
define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y');
|
||||
}
|
||||
/**
|
||||
* Load Smarty_Autoloader
|
||||
*/
|
||||
@ -111,7 +98,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.43';
|
||||
const SMARTY_VERSION = '4.1.1';
|
||||
/**
|
||||
* define variable scopes
|
||||
*/
|
||||
@ -143,13 +130,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
const DEBUG_OFF = 0;
|
||||
const DEBUG_ON = 1;
|
||||
const DEBUG_INDIVIDUAL = 2;
|
||||
/**
|
||||
* modes for handling of "<?php ... ?>" tags in templates.
|
||||
*/
|
||||
const PHP_PASSTHRU = 0; //-> print tags as plain text
|
||||
const PHP_QUOTE = 1; //-> escape tags as entities
|
||||
const PHP_REMOVE = 2; //-> escape tags as entities
|
||||
const PHP_ALLOW = 3; //-> escape tags as entities
|
||||
|
||||
/**
|
||||
* filter types
|
||||
*/
|
||||
@ -179,13 +160,13 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* The character set to adhere to (e.g. "UTF-8")
|
||||
*/
|
||||
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
|
||||
public static $_CHARSET = SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1';
|
||||
|
||||
/**
|
||||
* The date format to be used internally
|
||||
* (accepts date() and strftime())
|
||||
*/
|
||||
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
|
||||
public static $_DATE_FORMAT = '%b %e, %Y';
|
||||
|
||||
/**
|
||||
* Flag denoting if PCRE should run in UTF-8 mode
|
||||
@ -369,13 +350,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public $security_policy = null;
|
||||
|
||||
/**
|
||||
* controls handling of PHP-blocks
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $php_handling = self::PHP_PASSTHRU;
|
||||
|
||||
/**
|
||||
* controls if the php template file resource is allowed
|
||||
*
|
||||
@ -666,6 +640,12 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
'cache_dir' => 'CacheDir',
|
||||
);
|
||||
|
||||
/**
|
||||
* PHP7 Compatibility mode
|
||||
* @var bool
|
||||
*/
|
||||
private $isMutingUndefinedOrNullWarnings = false;
|
||||
|
||||
/**
|
||||
* Initialize new Smarty object
|
||||
*/
|
||||
@ -688,27 +668,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable error handler to mute expected messages
|
||||
*
|
||||
* @return boolean
|
||||
* @deprecated
|
||||
*/
|
||||
public static function muteExpectedErrors()
|
||||
{
|
||||
return Smarty_Internal_ErrorHandler::muteExpectedErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable error handler muting expected messages
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public static function unmuteExpectedErrors()
|
||||
{
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a template resource exists
|
||||
*
|
||||
@ -908,7 +867,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
$this->plugins_dir = (array)$this->plugins_dir;
|
||||
}
|
||||
foreach ($this->plugins_dir as $k => $v) {
|
||||
$this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, '/\\') . DIRECTORY_SEPARATOR, true);
|
||||
$this->plugins_dir[ $k ] = $this->_realpath(rtrim($v ?? '', '/\\') . DIRECTORY_SEPARATOR, true);
|
||||
}
|
||||
$this->_cache[ 'plugin_files' ] = array();
|
||||
$this->_pluginsDirNormalized = true;
|
||||
@ -1386,12 +1345,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
private function _normalizeDir($dirName, $dir)
|
||||
{
|
||||
$this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . DIRECTORY_SEPARATOR, true);
|
||||
if (class_exists('Smarty_Internal_ErrorHandler', false)) {
|
||||
if (!isset(Smarty_Internal_ErrorHandler::$mutedDirectories[ $this->{$dirName} ])) {
|
||||
Smarty_Internal_ErrorHandler::$mutedDirectories[ $this->{$dirName} ] = null;
|
||||
}
|
||||
}
|
||||
$this->{$dirName} = $this->_realpath(rtrim($dir ?? '', "/\\") . DIRECTORY_SEPARATOR, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1413,7 +1367,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
}
|
||||
foreach ($dir as $k => $v) {
|
||||
if (!isset($processed[ $k ])) {
|
||||
$dir[ $k ] = $v = $this->_realpath(rtrim($v, "/\\") . DIRECTORY_SEPARATOR, true);
|
||||
$dir[ $k ] = $v = $this->_realpath(rtrim($v ?? '', "/\\") . DIRECTORY_SEPARATOR, true);
|
||||
$processed[ $k ] = true;
|
||||
}
|
||||
}
|
||||
@ -1421,4 +1375,23 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
$isConfig ? $this->_joined_config_dir = join('#', $this->config_dir) :
|
||||
$this->_joined_template_dir = join('#', $this->template_dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates PHP7 compatibility mode:
|
||||
* - converts E_WARNINGS for "undefined array key" and "trying to read property of null" errors to E_NOTICE
|
||||
*
|
||||
* @void
|
||||
*/
|
||||
public function muteUndefinedOrNullWarnings(): void {
|
||||
$this->isMutingUndefinedOrNullWarnings = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if PHP7 compatibility mode is set.
|
||||
* @bool
|
||||
*/
|
||||
public function isMutingUndefinedOrNullWarnings(): bool {
|
||||
return $this->isMutingUndefinedOrNullWarnings;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,477 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: SmartyBC.class.php
|
||||
* SVN: $Id: $
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Smarty mailing list. Send a blank e-mail to
|
||||
* smarty-discussion-subscribe@googlegroups.com
|
||||
*
|
||||
* @link http://www.smarty.net/
|
||||
* @copyright 2008 New Digital Group, Inc.
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
*/
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once dirname(__FILE__) . '/Smarty.class.php';
|
||||
|
||||
/**
|
||||
* Smarty Backward Compatibility Wrapper Class
|
||||
*
|
||||
* @package Smarty
|
||||
*/
|
||||
class SmartyBC extends Smarty
|
||||
{
|
||||
/**
|
||||
* Smarty 2 BC
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $_version = self::SMARTY_VERSION;
|
||||
|
||||
/**
|
||||
* This is an array of directories where trusted php scripts reside.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $trusted_dir = array();
|
||||
|
||||
/**
|
||||
* Initialize new SmartyBC object
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for assign_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to assign
|
||||
*/
|
||||
public function assign_by_ref($tpl_var, &$value)
|
||||
{
|
||||
$this->assignByRef($tpl_var, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for append_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to append
|
||||
* @param boolean $merge flag if array elements shall be merged
|
||||
*/
|
||||
public function append_by_ref($tpl_var, &$value, $merge = false)
|
||||
{
|
||||
$this->appendByRef($tpl_var, $value, $merge);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the given assigned template variable.
|
||||
*
|
||||
* @param string $tpl_var the template variable to clear
|
||||
*/
|
||||
public function clear_assign($tpl_var)
|
||||
{
|
||||
$this->clearAssign($tpl_var);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers custom function to be used in templates
|
||||
*
|
||||
* @param string $function the name of the template function
|
||||
* @param string $function_impl the name of the PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null)
|
||||
{
|
||||
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister custom function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('function', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers object to be used in templates
|
||||
*
|
||||
* @param string $object name of template object
|
||||
* @param object $object_impl the referenced PHP object to register
|
||||
* @param array $allowed list of allowed methods (empty = all)
|
||||
* @param boolean $smarty_args smarty argument format, else traditional
|
||||
* @param array $block_methods list of methods that are block format
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @internal param array $block_functs list of methods that are block format
|
||||
*/
|
||||
public function register_object(
|
||||
$object,
|
||||
$object_impl,
|
||||
$allowed = array(),
|
||||
$smarty_args = true,
|
||||
$block_methods = array()
|
||||
) {
|
||||
settype($allowed, 'array');
|
||||
settype($smarty_args, 'boolean');
|
||||
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister object
|
||||
*
|
||||
* @param string $object name of template object
|
||||
*/
|
||||
public function unregister_object($object)
|
||||
{
|
||||
$this->unregisterObject($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers block function to be used in templates
|
||||
*
|
||||
* @param string $block name of template block
|
||||
* @param string $block_impl PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_block($block, $block_impl, $cacheable = true, $cache_attrs = null)
|
||||
{
|
||||
$this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister block function
|
||||
*
|
||||
* @param string $block name of template function
|
||||
*/
|
||||
public function unregister_block($block)
|
||||
{
|
||||
$this->unregisterPlugin('block', $block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
* @param string $function_impl name of PHP function to register
|
||||
* @param bool $cacheable
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_compiler_function($function, $function_impl, $cacheable = true)
|
||||
{
|
||||
$this->registerPlugin('compiler', $function, $function_impl, $cacheable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_compiler_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('compiler', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers modifier to be used in templates
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
* @param string $modifier_impl name of PHP function to register
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_modifier($modifier, $modifier_impl)
|
||||
{
|
||||
$this->registerPlugin('modifier', $modifier, $modifier_impl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister modifier
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
*/
|
||||
public function unregister_modifier($modifier)
|
||||
{
|
||||
$this->unregisterPlugin('modifier', $modifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a resource to fetch a template
|
||||
*
|
||||
* @param string $type name of resource
|
||||
* @param array $functions array of functions to handle resource
|
||||
*/
|
||||
public function register_resource($type, $functions)
|
||||
{
|
||||
$this->registerResource($type, $functions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a resource
|
||||
*
|
||||
* @param string $type name of resource
|
||||
*/
|
||||
public function unregister_resource($type)
|
||||
{
|
||||
$this->unregisterResource($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a prefilter function to apply
|
||||
* to a template before compiling
|
||||
*
|
||||
* @param callable $function
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_prefilter($function)
|
||||
{
|
||||
$this->registerFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a prefilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_prefilter($function)
|
||||
{
|
||||
$this->unregisterFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a postfilter function to apply
|
||||
* to a compiled template after compilation
|
||||
*
|
||||
* @param callable $function
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_postfilter($function)
|
||||
{
|
||||
$this->registerFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a postfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_postfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an output filter function to apply
|
||||
* to a template output
|
||||
*
|
||||
* @param callable $function
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function register_outputfilter($function)
|
||||
{
|
||||
$this->registerFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister an outputfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_outputfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* load a filter of specified type and name
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param string $name filter name
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function load_filter($type, $name)
|
||||
{
|
||||
$this->loadFilter($type, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear cached content for the given template and cache id
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id name of cache_id
|
||||
* @param string $compile_id name of compile_id
|
||||
* @param string $exp_time expiration time
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the entire contents of cache (all templates)
|
||||
*
|
||||
* @param string $exp_time expire time
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_all_cache($exp_time = null)
|
||||
{
|
||||
return $this->clearCache(null, null, null, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* test to see if valid cache exists for this template
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id
|
||||
* @param string $compile_id
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function is_cached($tpl_file, $cache_id = null, $compile_id = null)
|
||||
{
|
||||
return $this->isCached($tpl_file, $cache_id, $compile_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear all the assigned template variables.
|
||||
*/
|
||||
public function clear_all_assign()
|
||||
{
|
||||
$this->clearAllAssign();
|
||||
}
|
||||
|
||||
/**
|
||||
* clears compiled version of specified template resource,
|
||||
* or all compiled template files if one is not specified.
|
||||
* This function is for advanced use only, not normally needed.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
* @param string $compile_id
|
||||
* @param string $exp_time
|
||||
*
|
||||
* @return boolean results of {@link smarty_core_rm_auto()}
|
||||
*/
|
||||
public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether requested template exists.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
*
|
||||
* @return bool
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function template_exists($tpl_file)
|
||||
{
|
||||
return $this->templateExists($tpl_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing template variables
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_template_vars($name = null)
|
||||
{
|
||||
return $this->getTemplateVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing config variables
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_config_vars($name = null)
|
||||
{
|
||||
return $this->getConfigVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* load configuration values
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $section
|
||||
* @param string $scope
|
||||
*/
|
||||
public function config_load($file, $section = null, $scope = 'global')
|
||||
{
|
||||
$this->ConfigLoad($file, $section, $scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* return a reference to a registered object
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function get_registered_object($name)
|
||||
{
|
||||
return $this->getRegisteredObject($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear configuration values
|
||||
*
|
||||
* @param string $var
|
||||
*/
|
||||
public function clear_config($var = null)
|
||||
{
|
||||
$this->clearConfig($var);
|
||||
}
|
||||
|
||||
/**
|
||||
* trigger Smarty error
|
||||
*
|
||||
* @param string $error_msg
|
||||
* @param integer $error_type
|
||||
*/
|
||||
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
||||
{
|
||||
trigger_error("Smarty error: $error_msg", $error_type);
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@
|
||||
* - indent_char - string (" ")
|
||||
* - wrap_boundary - boolean (true)
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
|
||||
* @link https://www.smarty.net/manual/en/language.function.textformat.php {textformat}
|
||||
* (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
@ -12,7 +12,7 @@
|
||||
* Purpose: print out a counter value
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @link http://www.smarty.net/manual/en/language.function.counter.php {counter}
|
||||
* @link https://www.smarty.net/manual/en/language.function.counter.php {counter}
|
||||
* (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
@ -28,7 +28,7 @@
|
||||
* {cycle name=row values="one,two,three" reset=true}
|
||||
* {cycle name=row}
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
|
||||
* @link https://www.smarty.net/manual/en/language.function.cycle.php {cycle}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credit to Mark Priatel <mpriatel@rogers.com>
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: fetch
|
||||
* Purpose: fetch file, web or ftp data and display results
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch}
|
||||
* @link https://www.smarty.net/manual/en/language.function.fetch.php {fetch}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
|
@ -29,7 +29,7 @@
|
||||
* - assign (optional) - assign the output as an array to this variable
|
||||
* - escape (optional) - escape the content (not value), defaults to true
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
|
||||
* (Smarty online manual)
|
||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
|
@ -21,7 +21,7 @@
|
||||
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
|
||||
* - path_prefix - prefix for path output (optional, default empty)
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.image.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credits to Duda <duda@big.hu>
|
||||
|
@ -21,7 +21,7 @@
|
||||
* - id (optional) - string default not set
|
||||
* - class (optional) - string default not set
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.options.php {html_image}
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.options.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
|
||||
|
@ -29,7 +29,7 @@
|
||||
* {html_radios values=$ids name='box' separator='<br>' output=$names}
|
||||
* {html_radios values=$ids checked=$checked separator='<br>' output=$names}
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.radios.php {html_radios}
|
||||
* (Smarty online manual)
|
||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
|
@ -28,7 +28,7 @@
|
||||
* - 2.0 complete rewrite for performance,
|
||||
* added attributes month_names, *_id
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
|
||||
* (Smarty online manual)
|
||||
* @version 2.0
|
||||
* @author Andrei Zmievski
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: html_select_time
|
||||
* Purpose: Prints the dropdowns for time selection
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
|
||||
* (Smarty online manual)
|
||||
* @author Roberto Berto <roberto@berto.net>
|
||||
* @author Monte Ohrt <monte AT ohrt DOT com>
|
||||
|
@ -38,7 +38,7 @@
|
||||
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
|
||||
* @author credit to boots <boots dot smarty at yahoo dot com>
|
||||
* @version 1.1
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.table.php {html_table}
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.table.php {html_table}
|
||||
* (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
@ -36,7 +36,7 @@
|
||||
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
|
||||
* {mailto address="me@domain.com" extra='class="mailto"'}
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
|
||||
* @link https://www.smarty.net/manual/en/language.function.mailto.php {mailto}
|
||||
* (Smarty online manual)
|
||||
* @version 1.2
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
|
@ -12,7 +12,7 @@
|
||||
* Name: math
|
||||
* Purpose: handle math computations in template
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
|
||||
* @link https://www.smarty.net/manual/en/language.function.math.php {math}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
@ -69,8 +69,8 @@ function smarty_function_math($params, $template)
|
||||
// Adapted from https://www.php.net/manual/en/function.eval.php#107377
|
||||
$number = '(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number
|
||||
$functionsOrVars = '((?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))';
|
||||
$operators = '[+\/*\^%-]'; // Allowed math operators
|
||||
$regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)+\)|\((?1)+\)))(?:'.$operators.'(?2))?)+$/';
|
||||
$operators = '[,+\/*\^%-]'; // Allowed math operators
|
||||
$regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)+\)|\((?1)+\)))(?:'.$operators.'(?1))?)+$/';
|
||||
|
||||
if (!preg_match($regexp, $equation)) {
|
||||
trigger_error("math: illegal characters", E_USER_WARNING);
|
||||
|
@ -15,7 +15,7 @@
|
||||
* - format: strftime format for output
|
||||
* - default_date: default date if $string is empty
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input date string
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: escape
|
||||
* Purpose: escape string for output
|
||||
*
|
||||
* @link http://www.smarty.net/docs/en/language.modifier.escape
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.escape
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
@ -23,15 +23,15 @@
|
||||
*/
|
||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
static $_double_encode = true;
|
||||
static $is_loaded_1 = false;
|
||||
static $is_loaded_2 = false;
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
|
||||
$string = (string)$string;
|
||||
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
if ($_double_encode) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: mb_wordwrap
|
||||
* Purpose: Wrap a string to a given number of characters
|
||||
*
|
||||
* @link http://php.net/manual/en/function.wordwrap.php for similarity
|
||||
* @link https://php.net/manual/en/function.wordwrap.php for similarity
|
||||
*
|
||||
* @param string $str the string to wrap
|
||||
* @param int $width the width of the output
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: regex_replace
|
||||
* Purpose: regular expression search/replace
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.regex.replace.php
|
||||
* regex_replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: replace
|
||||
* Purpose: simple search/replace
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
*
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: spacify
|
||||
* Purpose: add spaces between characters in a string
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
|
@ -13,7 +13,7 @@
|
||||
* optionally splitting in the middle of a word, and
|
||||
* appending the $etc string or inserting $etc into the middle.
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
@ -42,8 +42,8 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
|
||||
if (!$middle) {
|
||||
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
|
||||
}
|
||||
return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc .
|
||||
mb_substr($string, -$length / 2, $length, Smarty::$_CHARSET);
|
||||
return mb_substr($string, 0, intval($length / 2), Smarty::$_CHARSET) . $etc .
|
||||
mb_substr($string, -intval($length / 2), $length, Smarty::$_CHARSET);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
@ -56,7 +56,7 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
|
||||
if (!$middle) {
|
||||
return substr($string, 0, $length) . $etc;
|
||||
}
|
||||
return substr($string, 0, $length / 2) . $etc . substr($string, -$length / 2);
|
||||
return substr($string, 0, intval($length / 2)) . $etc . substr($string, -intval($length / 2));
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Input: string to catenate
|
||||
* Example: {$var|cat:"foo"}
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.cat.php cat
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: count_characters
|
||||
* Purpose: count the number of characters in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
|
||||
* manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: count_paragraphs
|
||||
* Purpose: count the number of paragraphs in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_paragraphs (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: count_sentences
|
||||
* Purpose: count the number of sentences in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_sentences (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: count_words
|
||||
* Purpose: count the number of words in a text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: default
|
||||
* Purpose: designate default value for empty variables
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
@ -26,7 +26,7 @@ function smarty_modifiercompiler_default($params)
|
||||
}
|
||||
array_shift($params);
|
||||
foreach ($params as $param) {
|
||||
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
|
||||
$output = '(($tmp = ' . $output . ' ?? null)===null||$tmp===\'\' ? ' . $param . ' ?? null : $tmp)';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: escape
|
||||
* Purpose: escape string for output
|
||||
*
|
||||
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
||||
* @link https://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
static $_double_encode = true;
|
||||
static $is_loaded = false;
|
||||
$compiler->template->_checkPlugins(
|
||||
array(
|
||||
@ -32,9 +32,6 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
||||
)
|
||||
)
|
||||
);
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
try {
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
||||
@ -45,10 +42,10 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
if ($_double_encode) {
|
||||
return 'htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||
return 'htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||
var_export($double_encode, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
return 'htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
||||
return 'htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
@ -57,12 +54,12 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
||||
return 'mb_convert_encoding(htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
||||
var_export($char_set, true) . ', ' . var_export($double_encode, true) .
|
||||
'), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
||||
return 'mb_convert_encoding(htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
||||
var_export($char_set, true) . '), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
@ -71,26 +68,26 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
||||
// no MBString fallback
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'htmlentities(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||
return 'htmlentities((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||
var_export($double_encode, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'htmlentities(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
||||
return 'htmlentities((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
// no break
|
||||
case 'url':
|
||||
return 'rawurlencode(' . $params[ 0 ] . ')';
|
||||
return 'rawurlencode((string)' . $params[ 0 ] . ')';
|
||||
case 'urlpathinfo':
|
||||
return 'str_replace("%2F", "/", rawurlencode(' . $params[ 0 ] . '))';
|
||||
return 'str_replace("%2F", "/", rawurlencode((string)' . $params[ 0 ] . '))';
|
||||
case 'quotes':
|
||||
// escape unescaped single quotes
|
||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[ 0 ] . ')';
|
||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'", (string)' . $params[ 0 ] . ')';
|
||||
case 'javascript':
|
||||
// escape quotes and backslashes, newlines, etc.
|
||||
// see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
||||
return 'strtr(' .
|
||||
return 'strtr((string)' .
|
||||
$params[ 0 ] .
|
||||
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/", "<!--" => "<\!--", "<s" => "<\s", "<S" => "<\S" ))';
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: indent
|
||||
* Purpose: indent lines of text
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: lower
|
||||
* Purpose: convert string to lowercase
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
*
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: string_format
|
||||
* Purpose: format strings via sprintf
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Example: {$var|strip} {$var|strip:" "}
|
||||
* Date: September 25th, 2002
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: strip_tags
|
||||
* Purpose: strip html tags from text
|
||||
*
|
||||
* @link http://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: lower
|
||||
* Purpose: convert string to uppercase
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Name: wordwrap
|
||||
* Purpose: wrap a string of text at a given length
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
@ -41,7 +41,7 @@ function smarty_outputfilter_trimwhitespace($source)
|
||||
}
|
||||
}
|
||||
// Strip all HTML-Comments
|
||||
// yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124
|
||||
// yes, even the ones in <script> - see https://stackoverflow.com/a/808850/515124
|
||||
$source = preg_replace('#<!--.*?-->#ms', '', $source);
|
||||
// capture html elements not to be messed with
|
||||
$_offset = 0;
|
||||
|
@ -20,13 +20,7 @@
|
||||
function smarty_function_escape_special_chars($string)
|
||||
{
|
||||
if (!is_array($string)) {
|
||||
if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
|
||||
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
|
||||
} else {
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||
}
|
||||
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ if (!function_exists('smarty_mb_str_replace')) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$parts = mb_split(preg_quote($search), $subject);
|
||||
$parts = mb_split(preg_quote($search), $subject) ?: array();
|
||||
$count = count($parts) - 1;
|
||||
$subject = implode($replace, $parts);
|
||||
}
|
||||
|
@ -196,12 +196,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
*/
|
||||
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||
clearstatcache(true, $cached->lock_id);
|
||||
} else {
|
||||
clearstatcache();
|
||||
}
|
||||
if (is_file($cached->lock_id)) {
|
||||
clearstatcache(true, $cached->lock_id ?? '');
|
||||
if (null !== $cached->lock_id && is_file($cached->lock_id)) {
|
||||
$t = filemtime($cached->lock_id);
|
||||
return $t && (time() - $t < $smarty->locking_timeout);
|
||||
} else {
|
||||
|
@ -125,7 +125,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
|
||||
// setup buffer for template function code
|
||||
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
||||
$output = "<?php\n";
|
||||
$output .= "/* {block {$_name}} */\n";
|
||||
$output .= $compiler->cStyleComment(" {block {$_name}} ") . "\n";
|
||||
$output .= "class {$_className} extends Smarty_Internal_Block\n";
|
||||
$output .= "{\n";
|
||||
foreach ($_block as $property => $value) {
|
||||
@ -155,7 +155,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
|
||||
}
|
||||
$output .= "}\n";
|
||||
$output .= "}\n";
|
||||
$output .= "/* {/block {$_name}} */\n\n";
|
||||
$output .= $compiler->cStyleComment(" {/block {$_name}} ") . "\n\n";
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
|
@ -18,7 +18,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Compiles code for the {for} tag
|
||||
* Smarty 3 does implement two different syntax's:
|
||||
* Smarty supports two different syntax's:
|
||||
* - {for $var in $array}
|
||||
* For looping over arrays or iterators
|
||||
* - {for $x=0; $x<$y; $x++}
|
||||
|
@ -219,9 +219,9 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
||||
if (isset($itemAttr[ 'index' ])) {
|
||||
$output .= "{$itemVar}->index = -1;\n";
|
||||
}
|
||||
$output .= "{$itemVar}->do_else = true;\n";
|
||||
$output .= "{$itemVar}->do_else = true;\n";
|
||||
$output .= "if (\$_from !== null) foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
|
||||
$output .= "{$itemVar}->do_else = false;\n";
|
||||
$output .= "{$itemVar}->do_else = false;\n";
|
||||
if (isset($attributes[ 'key' ]) && isset($itemAttr[ 'key' ])) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
if ($compiler->template->compiled->has_nocache_code) {
|
||||
$compiler->parent_compiler->tpl_function[ $_name ][ 'call_name_caching' ] = $_funcNameCaching;
|
||||
$output = "<?php\n";
|
||||
$output .= "/* {$_funcNameCaching} */\n";
|
||||
$output .= $compiler->cStyleComment(" {$_funcNameCaching} ") . "\n";
|
||||
$output .= "if (!function_exists('{$_funcNameCaching}')) {\n";
|
||||
$output .= "function {$_funcNameCaching} (Smarty_Internal_Template \$_smarty_tpl,\$params) {\n";
|
||||
$output .= "ob_start();\n";
|
||||
@ -157,9 +157,9 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
||||
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n";
|
||||
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>";
|
||||
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n";
|
||||
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash ?? '', ob_get_clean());\n";
|
||||
$output .= "}\n}\n";
|
||||
$output .= "/*/ {$_funcName}_nocache */\n\n";
|
||||
$output .= $compiler->cStyleComment("/ {$_funcName}_nocache ") . "\n\n";
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
@ -179,7 +179,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
}
|
||||
$compiler->parent_compiler->tpl_function[ $_name ][ 'call_name' ] = $_funcName;
|
||||
$output = "<?php\n";
|
||||
$output .= "/* {$_funcName} */\n";
|
||||
$output .= $compiler->cStyleComment(" {$_funcName} ") . "\n";
|
||||
$output .= "if (!function_exists('{$_funcName}')) {\n";
|
||||
$output .= "function {$_funcName}(Smarty_Internal_Template \$_smarty_tpl,\$params) {\n";
|
||||
$output .= $_paramsCode;
|
||||
@ -196,7 +196,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
);
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||
$output = "<?php\n}}\n";
|
||||
$output .= "/*/ {$_funcName} */\n\n";
|
||||
$output .= $compiler->cStyleComment("/ {$_funcName} ") . "\n\n";
|
||||
$output .= "?>\n";
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
|
@ -318,14 +318,14 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
}
|
||||
// get compiled code
|
||||
$compiled_code = "<?php\n\n";
|
||||
$compiled_code .= "/* Start inline template \"{$sourceInfo}\" =============================*/\n";
|
||||
$compiled_code .= $compiler->cStyleComment(" Start inline template \"{$sourceInfo}\" =============================") . "\n";
|
||||
$compiled_code .= "function {$tpl->compiled->unifunc} (Smarty_Internal_Template \$_smarty_tpl) {\n";
|
||||
$compiled_code .= "?>\n" . $tpl->compiler->compileTemplateSource($tpl, null, $compiler->parent_compiler);
|
||||
$compiled_code .= "<?php\n";
|
||||
$compiled_code .= "}\n?>\n";
|
||||
$compiled_code .= $tpl->compiler->postFilter($tpl->compiler->blockOrFunctionCode);
|
||||
$compiled_code .= "<?php\n\n";
|
||||
$compiled_code .= "/* End inline template \"{$sourceInfo}\" =============================*/\n";
|
||||
$compiled_code .= $compiler->cStyleComment(" End inline template \"{$sourceInfo}\" =============================") . "\n";
|
||||
$compiled_code .= '?>';
|
||||
unset($tpl->compiler);
|
||||
if ($tpl->compiled->has_nocache_code) {
|
||||
|
@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Include PHP
|
||||
* Compiles the {include_php} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Insert Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('file');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('file');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('once', 'assign');
|
||||
|
||||
/**
|
||||
* Compiles code for the {include_php} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
*
|
||||
* @return string
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||
throw new SmartyException("{include_php} is deprecated, use SmartyBC class to enable");
|
||||
}
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var Smarty_Internal_Template $_smarty_tpl
|
||||
* used in evaluated code
|
||||
*/
|
||||
$_smarty_tpl = $compiler->template;
|
||||
$_filepath = false;
|
||||
$_file = null;
|
||||
eval('$_file = @' . $_attr[ 'file' ] . ';');
|
||||
if (!isset($compiler->smarty->security_policy) && file_exists($_file)) {
|
||||
$_filepath = $compiler->smarty->_realpath($_file, true);
|
||||
} else {
|
||||
if (isset($compiler->smarty->security_policy)) {
|
||||
$_dir = $compiler->smarty->security_policy->trusted_dir;
|
||||
} else {
|
||||
$_dir = $compiler->smarty->trusted_dir;
|
||||
}
|
||||
if (!empty($_dir)) {
|
||||
foreach ((array)$_dir as $_script_dir) {
|
||||
$_path = $compiler->smarty->_realpath($_script_dir . DIRECTORY_SEPARATOR . $_file, true);
|
||||
if (file_exists($_path)) {
|
||||
$_filepath = $_path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($_filepath === false) {
|
||||
$compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", null, true);
|
||||
}
|
||||
if (isset($compiler->smarty->security_policy)) {
|
||||
$compiler->smarty->security_policy->isTrustedPHPDir($_filepath);
|
||||
}
|
||||
if (isset($_attr[ 'assign' ])) {
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr[ 'assign' ];
|
||||
}
|
||||
$_once = '_once';
|
||||
if (isset($_attr[ 'once' ])) {
|
||||
if ($_attr[ 'once' ] === 'false') {
|
||||
$_once = '';
|
||||
}
|
||||
}
|
||||
if (isset($_assign)) {
|
||||
return "<?php ob_start();\ninclude{$_once} ('{$_filepath}');\n\$_smarty_tpl->assign({$_assign},ob_get_clean());\n?>";
|
||||
} else {
|
||||
return "<?php include{$_once} ('{$_filepath}');?>\n";
|
||||
}
|
||||
}
|
||||
}
|
@ -89,11 +89,11 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
||||
if (isset($compiler->smarty->security_policy)) {
|
||||
$_dir = $compiler->smarty->security_policy->trusted_dir;
|
||||
} else {
|
||||
$_dir = $compiler->smarty instanceof SmartyBC ? $compiler->smarty->trusted_dir : null;
|
||||
$_dir = null;
|
||||
}
|
||||
if (!empty($_dir)) {
|
||||
foreach ((array)$_dir as $_script_dir) {
|
||||
$_script_dir = rtrim($_script_dir, '/\\') . DIRECTORY_SEPARATOR;
|
||||
$_script_dir = rtrim($_script_dir ?? '', '/\\') . DIRECTORY_SEPARATOR;
|
||||
if (file_exists($_script_dir . $_script)) {
|
||||
$_filepath = $_script_dir . $_script;
|
||||
break;
|
||||
|
@ -1,253 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile PHP Expression
|
||||
* Compiles any tag which will output an expression or variable
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile PHP Expression Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('code', 'type');
|
||||
|
||||
/**
|
||||
* Compiles code for generating output from any expression
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$compiler->has_code = false;
|
||||
if ($_attr[ 'type' ] === 'xml') {
|
||||
$compiler->tag_nocache = true;
|
||||
$output = addcslashes($_attr[ 'code' ], "'\\");
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag(
|
||||
$compiler->parser,
|
||||
$compiler->processNocacheCode(
|
||||
"<?php echo '{$output}';?>\n",
|
||||
true
|
||||
)
|
||||
)
|
||||
);
|
||||
return '';
|
||||
}
|
||||
if ($_attr[ 'type' ] !== 'tag') {
|
||||
if ($compiler->php_handling === Smarty::PHP_REMOVE) {
|
||||
return '';
|
||||
} elseif ($compiler->php_handling === Smarty::PHP_QUOTE) {
|
||||
$output =
|
||||
preg_replace_callback(
|
||||
'#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i',
|
||||
array($this, 'quote'),
|
||||
$_attr[ 'code' ]
|
||||
);
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Text($output)
|
||||
);
|
||||
return '';
|
||||
} elseif ($compiler->php_handling === Smarty::PHP_PASSTHRU || $_attr[ 'type' ] === 'unmatched') {
|
||||
$compiler->tag_nocache = true;
|
||||
$output = addcslashes($_attr[ 'code' ], "'\\");
|
||||
$compiler->parser->current_buffer->append_subtree(
|
||||
$compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag(
|
||||
$compiler->parser,
|
||||
$compiler->processNocacheCode(
|
||||
"<?php echo '{$output}';?>\n",
|
||||
true
|
||||
)
|
||||
)
|
||||
);
|
||||
return '';
|
||||
} elseif ($compiler->php_handling === Smarty::PHP_ALLOW) {
|
||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||
$compiler->trigger_template_error(
|
||||
'$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it',
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
$compiler->has_code = true;
|
||||
return $_attr[ 'code' ];
|
||||
} else {
|
||||
$compiler->trigger_template_error('Illegal $smarty->php_handling value', null, true);
|
||||
}
|
||||
} else {
|
||||
$compiler->has_code = true;
|
||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||
$compiler->trigger_template_error(
|
||||
'{php}{/php} tags not allowed. Use SmartyBC to enable them',
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
$ldel = preg_quote($compiler->smarty->left_delimiter, '#');
|
||||
$rdel = preg_quote($compiler->smarty->right_delimiter, '#');
|
||||
preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr[ 'code' ], $match);
|
||||
if (!empty($match[ 2 ])) {
|
||||
if ('nocache' === trim($match[ 2 ])) {
|
||||
$compiler->tag_nocache = true;
|
||||
} else {
|
||||
$compiler->trigger_template_error("illegal value of option flag '{$match[2]}'", null, true);
|
||||
}
|
||||
}
|
||||
return preg_replace(
|
||||
array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"),
|
||||
array('<?php ', '?>'),
|
||||
$_attr[ 'code' ]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lexer code for PHP tags
|
||||
*
|
||||
* This code has been moved from lexer here fo easier debugging and maintenance
|
||||
*
|
||||
* @param Smarty_Internal_Templatelexer $lex
|
||||
*
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function parsePhp(Smarty_Internal_Templatelexer $lex)
|
||||
{
|
||||
$lex->token = Smarty_Internal_Templateparser::TP_PHP;
|
||||
$close = 0;
|
||||
$lex->taglineno = $lex->line;
|
||||
$closeTag = '?>';
|
||||
if (strpos($lex->value, '<?xml') === 0) {
|
||||
$lex->is_xml = true;
|
||||
$lex->phpType = 'xml';
|
||||
return;
|
||||
} elseif (strpos($lex->value, '<?') === 0) {
|
||||
$lex->phpType = 'php';
|
||||
} elseif (strpos($lex->value, '<%') === 0) {
|
||||
$lex->phpType = 'asp';
|
||||
$closeTag = '%>';
|
||||
} elseif (strpos($lex->value, '%>') === 0) {
|
||||
$lex->phpType = 'unmatched';
|
||||
} elseif (strpos($lex->value, '?>') === 0) {
|
||||
if ($lex->is_xml) {
|
||||
$lex->is_xml = false;
|
||||
$lex->phpType = 'xml';
|
||||
return;
|
||||
}
|
||||
$lex->phpType = 'unmatched';
|
||||
} elseif (strpos($lex->value, '<s') === 0) {
|
||||
$lex->phpType = 'script';
|
||||
$closeTag = '</script>';
|
||||
} elseif (strpos($lex->value, $lex->smarty->left_delimiter) === 0) {
|
||||
if ($lex->isAutoLiteral()) {
|
||||
$lex->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
return;
|
||||
}
|
||||
$closeTag = "{$lex->smarty->left_delimiter}/php{$lex->smarty->right_delimiter}";
|
||||
if ($lex->value === $closeTag) {
|
||||
$lex->compiler->trigger_template_error("unexpected closing tag '{$closeTag}'");
|
||||
}
|
||||
$lex->phpType = 'tag';
|
||||
}
|
||||
if ($lex->phpType === 'unmatched') {
|
||||
return;
|
||||
}
|
||||
if (($lex->phpType === 'php' || $lex->phpType === 'asp')
|
||||
&&
|
||||
($lex->compiler->php_handling === Smarty::PHP_PASSTHRU ||
|
||||
$lex->compiler->php_handling === Smarty::PHP_QUOTE)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
$start = $lex->counter + strlen($lex->value);
|
||||
$body = true;
|
||||
if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
|
||||
$close = $match[ 0 ][ 1 ];
|
||||
} else {
|
||||
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
|
||||
}
|
||||
while ($body) {
|
||||
if (preg_match(
|
||||
'~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~',
|
||||
$lex->data,
|
||||
$match,
|
||||
PREG_OFFSET_CAPTURE,
|
||||
$start
|
||||
)
|
||||
) {
|
||||
$value = $match[ 0 ][ 0 ];
|
||||
$from = $pos = $match[ 0 ][ 1 ];
|
||||
if ($pos > $close) {
|
||||
$body = false;
|
||||
} else {
|
||||
$start = $pos + strlen($value);
|
||||
$phpCommentStart = $value === '/*';
|
||||
if ($phpCommentStart) {
|
||||
$phpCommentEnd = preg_match('~([*][/])~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start);
|
||||
if ($phpCommentEnd) {
|
||||
$pos2 = $match[ 0 ][ 1 ];
|
||||
$start = $pos2 + strlen($match[ 0 ][ 0 ]);
|
||||
}
|
||||
}
|
||||
while ($close > $pos && $close < $start) {
|
||||
if (preg_match(
|
||||
'~' . preg_quote($closeTag, '~') . '~i',
|
||||
$lex->data,
|
||||
$match,
|
||||
PREG_OFFSET_CAPTURE,
|
||||
$from
|
||||
)
|
||||
) {
|
||||
$close = $match[ 0 ][ 1 ];
|
||||
$from = $close + strlen($match[ 0 ][ 0 ]);
|
||||
} else {
|
||||
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
|
||||
}
|
||||
}
|
||||
if ($phpCommentStart && (!$phpCommentEnd || $pos2 > $close)) {
|
||||
$lex->taglineno = $lex->line + substr_count(substr($lex->data, $lex->counter, $start), "\n");
|
||||
$lex->compiler->trigger_template_error("missing PHP comment closing tag '*/'");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$body = false;
|
||||
}
|
||||
}
|
||||
$lex->value = substr($lex->data, $lex->counter, $close + strlen($closeTag) - $lex->counter);
|
||||
}
|
||||
|
||||
/*
|
||||
* Call back function for $php_handling = PHP_QUOTE
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @param $match
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function quote($match)
|
||||
{
|
||||
return htmlspecialchars($match[ 0 ], ENT_QUOTES);
|
||||
}
|
||||
}
|
@ -157,10 +157,12 @@ class Smarty_Internal_Config_File_Compiler
|
||||
$this->smarty->_debug->end_compile($this->template);
|
||||
}
|
||||
// template header code
|
||||
$template_header =
|
||||
"<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
|
||||
"\n";
|
||||
$template_header .= " compiled from '{$this->template->source->filepath}' */ ?>\n";
|
||||
$template_header = sprintf(
|
||||
"<?php /* Smarty version %s, created on %s\n compiled from '%s' */ ?>\n",
|
||||
Smarty::SMARTY_VERSION,
|
||||
date("Y-m-d H:i:s"),
|
||||
str_replace('*/', '* /' , $this->template->source->filepath)
|
||||
);
|
||||
$code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' .
|
||||
var_export($this->config_data, true) . '); ?>';
|
||||
return $template_header . $this->template->smarty->ext->_codeFrame->create($this->template, $code);
|
||||
|
@ -121,7 +121,7 @@ abstract class Smarty_Internal_Data
|
||||
* appends values to template variables
|
||||
*
|
||||
* @api Smarty::append()
|
||||
* @link http://www.smarty.net/docs/en/api.append.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.append.tpl
|
||||
*
|
||||
* @param array|string $tpl_var the template variable name(s)
|
||||
* @param mixed $value the value to append
|
||||
@ -182,7 +182,7 @@ abstract class Smarty_Internal_Data
|
||||
* Returns a single or all template variables
|
||||
*
|
||||
* @api Smarty::getTemplateVars()
|
||||
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.get.template.vars.tpl
|
||||
*
|
||||
* @param string $varName variable name or null
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
|
||||
@ -195,26 +195,6 @@ abstract class Smarty_Internal_Data
|
||||
return $this->ext->getTemplateVars->getTemplateVars($this, $varName, $_ptr, $searchParents);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the object of a Smarty variable
|
||||
*
|
||||
* @param string $variable the name of the Smarty variable
|
||||
* @param Smarty_Internal_Data $_ptr optional pointer to data object
|
||||
* @param boolean $searchParents search also in parent data
|
||||
* @param bool $error_enable
|
||||
*
|
||||
* @return Smarty_Variable|Smarty_Undefined_Variable the object of the variable
|
||||
* @deprecated since 3.1.28 please use Smarty_Internal_Data::getTemplateVars() instead.
|
||||
*/
|
||||
public function getVariable(
|
||||
$variable = null,
|
||||
Smarty_Internal_Data $_ptr = null,
|
||||
$searchParents = true,
|
||||
$error_enable = true
|
||||
) {
|
||||
return $this->ext->getTemplateVars->_getVariable($this, $variable, $_ptr, $searchParents, $error_enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow the parent chain an merge template and config variables
|
||||
*
|
||||
|
@ -1,61 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty error handler
|
||||
* Smarty error handler to fix new error levels in PHP8 for backwards compatibility
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
* @author Simon Wisselink
|
||||
*
|
||||
* @deprecated
|
||||
Smarty does no longer use @filemtime()
|
||||
*/
|
||||
class Smarty_Internal_ErrorHandler
|
||||
{
|
||||
/**
|
||||
* contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors()
|
||||
*/
|
||||
public static $mutedDirectories = array();
|
||||
|
||||
/**
|
||||
* error handler returned by set_error_handler() in self::muteExpectedErrors()
|
||||
* Allows {$foo} where foo is unset.
|
||||
* @var bool
|
||||
*/
|
||||
private static $previousErrorHandler = null;
|
||||
public $allowUndefinedVars = true;
|
||||
|
||||
/**
|
||||
* Enable error handler to mute expected messages
|
||||
*
|
||||
* Allows {$foo.bar} where bar is unset and {$foo.bar1.bar2} where either bar1 or bar2 is unset.
|
||||
* @var bool
|
||||
*/
|
||||
public static function muteExpectedErrors()
|
||||
{
|
||||
public $allowUndefinedArrayKeys = true;
|
||||
|
||||
private $previousErrorHandler = null;
|
||||
|
||||
/**
|
||||
* Enable error handler to intercept errors
|
||||
*/
|
||||
public function activate() {
|
||||
/*
|
||||
error muting is done because some people implemented custom error_handlers using
|
||||
http://php.net/set_error_handler and for some reason did not understand the following paragraph:
|
||||
Error muting is done because some people implemented custom error_handlers using
|
||||
https://php.net/set_error_handler and for some reason did not understand the following paragraph:
|
||||
|
||||
It is important to remember that the standard PHP error handler is completely bypassed for the
|
||||
error types specified by error_types unless the callback function returns FALSE.
|
||||
error_reporting() settings will have no effect and your error handler will be called regardless -
|
||||
however you are still able to read the current value of error_reporting and act appropriately.
|
||||
Of particular note is that this value will be 0 if the statement that caused the error was
|
||||
prepended by the @ error-control operator.
|
||||
|
||||
Smarty deliberately uses @filemtime() over file_exists() and filemtime() in some places. Reasons include
|
||||
- @filemtime() is almost twice as fast as using an additional file_exists()
|
||||
- between file_exists() and filemtime() a possible race condition is opened,
|
||||
which does not exist using the simple @filemtime() approach.
|
||||
It is important to remember that the standard PHP error handler is completely bypassed for the
|
||||
error types specified by error_types unless the callback function returns FALSE.
|
||||
error_reporting() settings will have no effect and your error handler will be called regardless -
|
||||
however you are still able to read the current value of error_reporting and act appropriately.
|
||||
Of particular note is that this value will be 0 if the statement that caused the error was
|
||||
prepended by the @ error-control operator.
|
||||
*/
|
||||
$error_handler = array('Smarty_Internal_ErrorHandler', 'mutingErrorHandler');
|
||||
$previous = set_error_handler($error_handler);
|
||||
// avoid dead loops
|
||||
if ($previous !== $error_handler) {
|
||||
self::$previousErrorHandler = $previous;
|
||||
}
|
||||
$this->previousErrorHandler = set_error_handler([$this, 'handleError']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable error handler
|
||||
*/
|
||||
public function deactivate() {
|
||||
restore_error_handler();
|
||||
$this->previousErrorHandler = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error Handler to mute expected messages
|
||||
*
|
||||
* @link http://php.net/set_error_handler
|
||||
* @link https://php.net/set_error_handler
|
||||
*
|
||||
* @param integer $errno Error level
|
||||
* @param $errstr
|
||||
@ -65,49 +64,21 @@ class Smarty_Internal_ErrorHandler
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext = array())
|
||||
public function handleError($errno, $errstr, $errfile, $errline, $errcontext = [])
|
||||
{
|
||||
$_is_muted_directory = false;
|
||||
// add the SMARTY_DIR to the list of muted directories
|
||||
if (!isset(self::$mutedDirectories[ SMARTY_DIR ])) {
|
||||
$smarty_dir = realpath(SMARTY_DIR);
|
||||
if ($smarty_dir !== false) {
|
||||
self::$mutedDirectories[ SMARTY_DIR ] =
|
||||
array('file' => $smarty_dir, 'length' => strlen($smarty_dir),);
|
||||
}
|
||||
if ($this->allowUndefinedVars && $errstr == 'Attempt to read property "value" on null') {
|
||||
return; // suppresses this error
|
||||
}
|
||||
// walk the muted directories and test against $errfile
|
||||
foreach (self::$mutedDirectories as $key => &$dir) {
|
||||
if (!$dir) {
|
||||
// resolve directory and length for speedy comparisons
|
||||
$file = realpath($key);
|
||||
if ($file === false) {
|
||||
// this directory does not exist, remove and skip it
|
||||
unset(self::$mutedDirectories[ $key ]);
|
||||
continue;
|
||||
}
|
||||
$dir = array('file' => $file, 'length' => strlen($file),);
|
||||
}
|
||||
if (!strncmp($errfile, $dir[ 'file' ], $dir[ 'length' ])) {
|
||||
$_is_muted_directory = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// pass to next error handler if this error did not occur inside SMARTY_DIR
|
||||
// or the error was within smarty but masked to be ignored
|
||||
if (!$_is_muted_directory || ($errno && $errno & error_reporting())) {
|
||||
if (self::$previousErrorHandler) {
|
||||
return call_user_func(
|
||||
self::$previousErrorHandler,
|
||||
$errno,
|
||||
$errstr,
|
||||
$errfile,
|
||||
$errline,
|
||||
$errcontext
|
||||
);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->allowUndefinedArrayKeys && preg_match(
|
||||
'/^(Undefined array key|Trying to access array offset on value of type null)/',
|
||||
$errstr
|
||||
)) {
|
||||
return; // suppresses this error
|
||||
}
|
||||
|
||||
// pass all other errors through to the previous error handler or to the default PHP error handler
|
||||
return $this->previousErrorHandler ?
|
||||
call_user_func($this->previousErrorHandler, $errno, $errstr, $errfile, $errline, $errcontext) : false;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_Append
|
||||
* appends values to template variables
|
||||
*
|
||||
* @api Smarty::append()
|
||||
* @link http://www.smarty.net/docs/en/api.append.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.append.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||
* @param array|string $tpl_var the template variable name(s)
|
||||
|
@ -15,7 +15,7 @@ class Smarty_Internal_Method_AppendByRef
|
||||
* appends values to template variables by reference
|
||||
*
|
||||
* @api Smarty::appendByRef()
|
||||
* @link http://www.smarty.net/docs/en/api.append.by.ref.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.append.by.ref.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||
* @param string $tpl_var the template variable name
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearAllAssign
|
||||
* clear all the assigned template variables.
|
||||
*
|
||||
* @api Smarty::clearAllAssign()
|
||||
* @link http://www.smarty.net/docs/en/api.clear.all.assign.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.clear.all.assign.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||
*
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearAllCache
|
||||
* Empty cache folder
|
||||
*
|
||||
* @api Smarty::clearAllCache()
|
||||
* @link http://www.smarty.net/docs/en/api.clear.all.cache.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.clear.all.cache.tpl
|
||||
*
|
||||
* @param \Smarty $smarty
|
||||
* @param integer $exp_time expiration time
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearAssign
|
||||
* clear the given assigned template variable(s).
|
||||
*
|
||||
* @api Smarty::clearAssign()
|
||||
* @link http://www.smarty.net/docs/en/api.clear.assign.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.clear.assign.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||
* @param string|array $tpl_var the template variable(s) to clear
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearCache
|
||||
* Empty cache for a specific template
|
||||
*
|
||||
* @api Smarty::clearCache()
|
||||
* @link http://www.smarty.net/docs/en/api.clear.cache.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.clear.cache.tpl
|
||||
*
|
||||
* @param \Smarty $smarty
|
||||
* @param string $template_name template name
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearCompiledTemplate
|
||||
* Delete compiled template file
|
||||
*
|
||||
* @api Smarty::clearCompiledTemplate()
|
||||
* @link http://www.smarty.net/docs/en/api.clear.compiled.template.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.clear.compiled.template.tpl
|
||||
*
|
||||
* @param \Smarty $smarty
|
||||
* @param string $resource_name template name
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearConfig
|
||||
* clear a single or all config variables
|
||||
*
|
||||
* @api Smarty::clearConfig()
|
||||
* @link http://www.smarty.net/docs/en/api.clear.config.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.clear.config.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||
* @param string|null $name variable name or null
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_ConfigLoad
|
||||
* load a config file, optionally load just selected sections
|
||||
*
|
||||
* @api Smarty::configLoad()
|
||||
* @link http://www.smarty.net/docs/en/api.config.load.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.config.load.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||
* @param string $config_file filename
|
||||
@ -42,7 +42,7 @@ class Smarty_Internal_Method_ConfigLoad
|
||||
* load a config file, optionally load just selected sections
|
||||
*
|
||||
* @api Smarty::configLoad()
|
||||
* @link http://www.smarty.net/docs/en/api.config.load.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.config.load.tpl
|
||||
*
|
||||
* @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data
|
||||
* @param string $config_file filename
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_CreateData
|
||||
* creates a data object
|
||||
*
|
||||
* @api Smarty::createData()
|
||||
* @link http://www.smarty.net/docs/en/api.create.data.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.create.data.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param \Smarty_Internal_Template|\Smarty_Internal_Data|\Smarty_Data|\Smarty $parent next higher level of Smarty
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetConfigVars
|
||||
* Returns a single or all config variables
|
||||
*
|
||||
* @api Smarty::getConfigVars()
|
||||
* @link http://www.smarty.net/docs/en/api.get.config.vars.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.get.config.vars.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||
* @param string $varname variable name or null
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetRegisteredObject
|
||||
* return a reference to a registered object
|
||||
*
|
||||
* @api Smarty::getRegisteredObject()
|
||||
* @link http://www.smarty.net/docs/en/api.get.registered.object.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.get.registered.object.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $object_name object name
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetTags
|
||||
* Return array of tag/attributes of all tags used by an template
|
||||
*
|
||||
* @api Smarty::getTags()
|
||||
* @link http://www.smarty.net/docs/en/api.get.tags.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.get.tags.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param null|string|Smarty_Internal_Template $template
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetTemplateVars
|
||||
* Returns a single or all template variables
|
||||
*
|
||||
* @api Smarty::getTemplateVars()
|
||||
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.get.template.vars.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||
* @param string $varName variable name or null
|
||||
|
@ -30,7 +30,7 @@ class Smarty_Internal_Method_LoadFilter
|
||||
*
|
||||
* @api Smarty::loadFilter()
|
||||
*
|
||||
* @link http://www.smarty.net/docs/en/api.load.filter.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.load.filter.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $type filter type
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterCacheResource
|
||||
* Registers a resource to fetch a template
|
||||
*
|
||||
* @api Smarty::registerCacheResource()
|
||||
* @link http://www.smarty.net/docs/en/api.register.cacheresource.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.register.cacheresource.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $name name of resource type
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterClass
|
||||
* Registers static classes to be used in templates
|
||||
*
|
||||
* @api Smarty::registerClass()
|
||||
* @link http://www.smarty.net/docs/en/api.register.class.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.register.class.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $class_name
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterDefaultPluginHandler
|
||||
* Registers a default plugin handler
|
||||
*
|
||||
* @api Smarty::registerDefaultPluginHandler()
|
||||
* @link http://www.smarty.net/docs/en/api.register.default.plugin.handler.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.register.default.plugin.handler.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param callable $callback class/method name
|
||||
|
@ -30,7 +30,7 @@ class Smarty_Internal_Method_RegisterFilter
|
||||
*
|
||||
* @api Smarty::registerFilter()
|
||||
*
|
||||
* @link http://www.smarty.net/docs/en/api.register.filter.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.register.filter.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $type filter type
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterObject
|
||||
* Registers object to be used in templates
|
||||
*
|
||||
* @api Smarty::registerObject()
|
||||
* @link http://www.smarty.net/docs/en/api.register.object.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.register.object.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $object_name
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterPlugin
|
||||
* Registers plugin to be used in templates
|
||||
*
|
||||
* @api Smarty::registerPlugin()
|
||||
* @link http://www.smarty.net/docs/en/api.register.plugin.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.register.plugin.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $type plugin type
|
||||
|
@ -22,25 +22,18 @@ class Smarty_Internal_Method_RegisterResource
|
||||
* Registers a resource to fetch a template
|
||||
*
|
||||
* @api Smarty::registerResource()
|
||||
* @link http://www.smarty.net/docs/en/api.register.resource.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.register.resource.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $name name of resource type
|
||||
* @param Smarty_Resource|array $resource_handler or instance of
|
||||
* Smarty_Resource,
|
||||
* or array of
|
||||
* callbacks to
|
||||
* handle
|
||||
* resource
|
||||
* (deprecated)
|
||||
* @param Smarty_Resource $resource_handler instance of Smarty_Resource
|
||||
*
|
||||
* @return \Smarty|\Smarty_Internal_Template
|
||||
*/
|
||||
public function registerResource(Smarty_Internal_TemplateBase $obj, $name, $resource_handler)
|
||||
public function registerResource(Smarty_Internal_TemplateBase $obj, $name, Smarty_Resource $resource_handler)
|
||||
{
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$smarty->registered_resources[ $name ] =
|
||||
$resource_handler instanceof Smarty_Resource ? $resource_handler : array($resource_handler, false);
|
||||
$smarty->registered_resources[ $name ] = $resource_handler;
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class Smarty_Internal_Method_UnloadFilter extends Smarty_Internal_Method_LoadFil
|
||||
*
|
||||
* @api Smarty::unloadFilter()
|
||||
*
|
||||
* @link http://www.smarty.net/docs/en/api.unload.filter.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.unload.filter.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $type filter type
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterCacheResource
|
||||
* Registers a resource to fetch a template
|
||||
*
|
||||
* @api Smarty::unregisterCacheResource()
|
||||
* @link http://www.smarty.net/docs/en/api.unregister.cacheresource.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.unregister.cacheresource.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param $name
|
||||
|
@ -16,7 +16,7 @@ class Smarty_Internal_Method_UnregisterFilter extends Smarty_Internal_Method_Reg
|
||||
*
|
||||
* @api Smarty::unregisterFilter()
|
||||
*
|
||||
* @link http://www.smarty.net/docs/en/api.unregister.filter.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.unregister.filter.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $type filter type
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterObject
|
||||
* Registers plugin to be used in templates
|
||||
*
|
||||
* @api Smarty::unregisterObject()
|
||||
* @link http://www.smarty.net/docs/en/api.unregister.object.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.unregister.object.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $object_name name of object
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterPlugin
|
||||
* Registers plugin to be used in templates
|
||||
*
|
||||
* @api Smarty::unregisterPlugin()
|
||||
* @link http://www.smarty.net/docs/en/api.unregister.plugin.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.unregister.plugin.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $type plugin type
|
||||
|
@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterResource
|
||||
* Registers a resource to fetch a template
|
||||
*
|
||||
* @api Smarty::unregisterResource()
|
||||
* @link http://www.smarty.net/docs/en/api.unregister.resource.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.unregister.resource.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $type name of resource type
|
||||
|
@ -87,83 +87,83 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
|
||||
$code = '';
|
||||
|
||||
foreach ($this->getChunkedSubtrees() as $chunk) {
|
||||
$text = '';
|
||||
switch ($chunk['mode']) {
|
||||
case 'textstripped':
|
||||
foreach ($chunk['subtrees'] as $subtree) {
|
||||
$text .= $subtree->to_smarty_php($parser);
|
||||
}
|
||||
$code .= preg_replace(
|
||||
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
|
||||
"<?php echo '\$1'; ?>\n",
|
||||
$parser->compiler->processText($text)
|
||||
);
|
||||
break;
|
||||
case 'text':
|
||||
foreach ($chunk['subtrees'] as $subtree) {
|
||||
$text .= $subtree->to_smarty_php($parser);
|
||||
}
|
||||
$code .= preg_replace(
|
||||
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
|
||||
"<?php echo '\$1'; ?>\n",
|
||||
$text
|
||||
);
|
||||
break;
|
||||
case 'tag':
|
||||
foreach ($chunk['subtrees'] as $subtree) {
|
||||
$text = $parser->compiler->appendCode($text, $subtree->to_smarty_php($parser));
|
||||
}
|
||||
$code .= $text;
|
||||
break;
|
||||
default:
|
||||
foreach ($chunk['subtrees'] as $subtree) {
|
||||
$text = $subtree->to_smarty_php($parser);
|
||||
}
|
||||
$code .= $text;
|
||||
$text = '';
|
||||
switch ($chunk['mode']) {
|
||||
case 'textstripped':
|
||||
foreach ($chunk['subtrees'] as $subtree) {
|
||||
$text .= $subtree->to_smarty_php($parser);
|
||||
}
|
||||
$code .= preg_replace(
|
||||
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
|
||||
"<?php echo '\$1'; ?>\n",
|
||||
$parser->compiler->processText($text)
|
||||
);
|
||||
break;
|
||||
case 'text':
|
||||
foreach ($chunk['subtrees'] as $subtree) {
|
||||
$text .= $subtree->to_smarty_php($parser);
|
||||
}
|
||||
$code .= preg_replace(
|
||||
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
|
||||
"<?php echo '\$1'; ?>\n",
|
||||
$text
|
||||
);
|
||||
break;
|
||||
case 'tag':
|
||||
foreach ($chunk['subtrees'] as $subtree) {
|
||||
$text = $parser->compiler->appendCode($text, $subtree->to_smarty_php($parser));
|
||||
}
|
||||
$code .= $text;
|
||||
break;
|
||||
default:
|
||||
foreach ($chunk['subtrees'] as $subtree) {
|
||||
$text = $subtree->to_smarty_php($parser);
|
||||
}
|
||||
$code .= $text;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
|
||||
private function getChunkedSubtrees() {
|
||||
$chunks = array();
|
||||
$currentMode = null;
|
||||
$currentChunk = array();
|
||||
for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) {
|
||||
$chunks = array();
|
||||
$currentMode = null;
|
||||
$currentChunk = array();
|
||||
for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) {
|
||||
|
||||
if ($this->subtrees[ $key ]->data === '' && in_array($currentMode, array('textstripped', 'text', 'tag'))) {
|
||||
continue;
|
||||
}
|
||||
if ($this->subtrees[ $key ]->data === '' && in_array($currentMode, array('textstripped', 'text', 'tag'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text
|
||||
&& $this->subtrees[ $key ]->isToBeStripped()) {
|
||||
$newMode = 'textstripped';
|
||||
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text) {
|
||||
$newMode = 'text';
|
||||
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) {
|
||||
$newMode = 'tag';
|
||||
} else {
|
||||
$newMode = 'other';
|
||||
}
|
||||
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text
|
||||
&& $this->subtrees[ $key ]->isToBeStripped()) {
|
||||
$newMode = 'textstripped';
|
||||
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text) {
|
||||
$newMode = 'text';
|
||||
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) {
|
||||
$newMode = 'tag';
|
||||
} else {
|
||||
$newMode = 'other';
|
||||
}
|
||||
|
||||
if ($newMode == $currentMode) {
|
||||
$currentChunk[] = $this->subtrees[ $key ];
|
||||
} else {
|
||||
$chunks[] = array(
|
||||
'mode' => $currentMode,
|
||||
'subtrees' => $currentChunk
|
||||
);
|
||||
$currentMode = $newMode;
|
||||
$currentChunk = array($this->subtrees[ $key ]);
|
||||
}
|
||||
}
|
||||
if ($currentMode && $currentChunk) {
|
||||
$chunks[] = array(
|
||||
'mode' => $currentMode,
|
||||
'subtrees' => $currentChunk
|
||||
);
|
||||
}
|
||||
return $chunks;
|
||||
if ($newMode == $currentMode) {
|
||||
$currentChunk[] = $this->subtrees[ $key ];
|
||||
} else {
|
||||
$chunks[] = array(
|
||||
'mode' => $currentMode,
|
||||
'subtrees' => $currentChunk
|
||||
);
|
||||
$currentMode = $newMode;
|
||||
$currentChunk = array($this->subtrees[ $key ]);
|
||||
}
|
||||
}
|
||||
if ($currentMode && $currentChunk) {
|
||||
$chunks[] = array(
|
||||
'mode' => $currentMode,
|
||||
'subtrees' => $currentChunk
|
||||
);
|
||||
}
|
||||
return $chunks;
|
||||
}
|
||||
}
|
||||
|
@ -17,30 +17,30 @@
|
||||
class Smarty_Internal_ParseTree_Text extends Smarty_Internal_ParseTree
|
||||
{
|
||||
|
||||
/**
|
||||
* Wether this section should be stripped on output to smarty php
|
||||
* @var bool
|
||||
*/
|
||||
private $toBeStripped = false;
|
||||
/**
|
||||
* Wether this section should be stripped on output to smarty php
|
||||
* @var bool
|
||||
*/
|
||||
private $toBeStripped = false;
|
||||
|
||||
/**
|
||||
* Create template text buffer
|
||||
*
|
||||
* @param string $data text
|
||||
* @param bool $toBeStripped wether this section should be stripped on output to smarty php
|
||||
*/
|
||||
/**
|
||||
* Create template text buffer
|
||||
*
|
||||
* @param string $data text
|
||||
* @param bool $toBeStripped wether this section should be stripped on output to smarty php
|
||||
*/
|
||||
public function __construct($data, $toBeStripped = false)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->toBeStripped = $toBeStripped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wether this section should be stripped on output to smarty php
|
||||
* @return bool
|
||||
*/
|
||||
public function isToBeStripped() {
|
||||
return $this->toBeStripped;
|
||||
/**
|
||||
* Wether this section should be stripped on output to smarty php
|
||||
* @return bool
|
||||
*/
|
||||
public function isToBeStripped() {
|
||||
return $this->toBeStripped;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,101 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Resource Registered
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage TemplateResources
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Resource Registered
|
||||
* Implements the registered resource for Smarty template
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage TemplateResources
|
||||
* @deprecated
|
||||
*/
|
||||
class Smarty_Internal_Resource_Registered extends Smarty_Resource
|
||||
{
|
||||
/**
|
||||
* populate Source Object with meta data from Resource
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
|
||||
{
|
||||
$source->filepath = $source->type . ':' . $source->name;
|
||||
$source->uid = sha1($source->filepath . $source->smarty->_joined_template_dir);
|
||||
$source->timestamp = $this->getTemplateTimestamp($source);
|
||||
$source->exists = !!$source->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* populate Source Object with timestamp and exists from Resource
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function populateTimestamp(Smarty_Template_Source $source)
|
||||
{
|
||||
$source->timestamp = $this->getTemplateTimestamp($source);
|
||||
$source->exists = !!$source->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get timestamp (epoch) the template source was modified
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
*
|
||||
* @return integer|boolean timestamp (epoch) the template was modified, false if resources has no timestamp
|
||||
*/
|
||||
public function getTemplateTimestamp(Smarty_Template_Source $source)
|
||||
{
|
||||
// return timestamp
|
||||
$time_stamp = false;
|
||||
call_user_func_array(
|
||||
$source->smarty->registered_resources[ $source->type ][ 0 ][ 1 ],
|
||||
array($source->name, &$time_stamp, $source->smarty)
|
||||
);
|
||||
return is_numeric($time_stamp) ? (int)$time_stamp : $time_stamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load template's source by invoking the registered callback into current template object
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
*
|
||||
* @return string template source
|
||||
* @throws SmartyException if source cannot be loaded
|
||||
*/
|
||||
public function getContent(Smarty_Template_Source $source)
|
||||
{
|
||||
// return template string
|
||||
$content = null;
|
||||
$t = call_user_func_array(
|
||||
$source->smarty->registered_resources[ $source->type ][ 0 ][ 0 ],
|
||||
array($source->name, &$content, $source->smarty)
|
||||
);
|
||||
if (is_bool($t) && !$t) {
|
||||
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine basename for compiled filename
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
*
|
||||
* @return string resource's basename
|
||||
*/
|
||||
public function getBasename(Smarty_Template_Source $source)
|
||||
{
|
||||
return basename($source->name);
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
* Smarty Internal Plugin Resource Stream
|
||||
* Implements the streams as resource for Smarty template
|
||||
*
|
||||
* @link http://php.net/streams
|
||||
* @link https://php.net/streams
|
||||
* @package Smarty
|
||||
* @subpackage TemplateResources
|
||||
*/
|
||||
|
@ -44,9 +44,12 @@ class Smarty_Internal_Runtime_CodeFrame
|
||||
$properties[ 'file_dependency' ] = $_template->cached->file_dependency;
|
||||
$properties[ 'cache_lifetime' ] = $_template->cache_lifetime;
|
||||
}
|
||||
$output = "<?php\n";
|
||||
$output .= "/* Smarty version {$properties[ 'version' ]}, created on " . strftime("%Y-%m-%d %H:%M:%S") .
|
||||
"\n from '" . str_replace('*/', '* /', $_template->source->filepath) . "' */\n\n";
|
||||
$output = sprintf(
|
||||
"<?php\n/* Smarty version %s, created on %s\n from '%s' */\n\n",
|
||||
$properties[ 'version' ],
|
||||
date("Y-m-d H:i:s"),
|
||||
str_replace('*/', '* /', $_template->source->filepath)
|
||||
);
|
||||
$output .= "/* @var Smarty_Internal_Template \$_smarty_tpl */\n";
|
||||
$dec = "\$_smarty_tpl->_decodeProperties(\$_smarty_tpl, " . var_export($properties, true) . ',' .
|
||||
($cache ? 'true' : 'false') . ')';
|
||||
|
@ -138,7 +138,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
* test if cache is valid
|
||||
*
|
||||
* @api Smarty::isCached()
|
||||
* @link http://www.smarty.net/docs/en/api.is.cached.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.is.cached.tpl
|
||||
*
|
||||
* @param null|string|\Smarty_Internal_Template $template the resource handle of the template file or template
|
||||
* object
|
||||
@ -199,6 +199,12 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
try {
|
||||
$_smarty_old_error_level =
|
||||
isset($smarty->error_reporting) ? error_reporting($smarty->error_reporting) : null;
|
||||
|
||||
if ($smarty->isMutingUndefinedOrNullWarnings()) {
|
||||
$errorHandler = new Smarty_Internal_ErrorHandler();
|
||||
$errorHandler->activate();
|
||||
}
|
||||
|
||||
if ($this->_objType === 2) {
|
||||
/* @var Smarty_Internal_Template $this */
|
||||
$template->tplFunctions = $this->tplFunctions;
|
||||
@ -242,6 +248,11 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($errorHandler)) {
|
||||
$errorHandler->deactivate();
|
||||
}
|
||||
|
||||
if (isset($_smarty_old_error_level)) {
|
||||
error_reporting($_smarty_old_error_level);
|
||||
}
|
||||
@ -250,6 +261,10 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
while (ob_get_level() > $level) {
|
||||
ob_end_clean();
|
||||
}
|
||||
if (isset($errorHandler)) {
|
||||
$errorHandler->deactivate();
|
||||
}
|
||||
|
||||
if (isset($_smarty_old_error_level)) {
|
||||
error_reporting($_smarty_old_error_level);
|
||||
}
|
||||
@ -261,7 +276,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
* Registers plugin to be used in templates
|
||||
*
|
||||
* @api Smarty::registerPlugin()
|
||||
* @link http://www.smarty.net/docs/en/api.register.plugin.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.register.plugin.tpl
|
||||
*
|
||||
* @param string $type plugin type
|
||||
* @param string $name name of template tag
|
||||
@ -281,7 +296,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
* load a filter of specified type and name
|
||||
*
|
||||
* @api Smarty::loadFilter()
|
||||
* @link http://www.smarty.net/docs/en/api.load.filter.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.load.filter.tpl
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param string $name filter name
|
||||
@ -298,7 +313,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
* Registers a filter function
|
||||
*
|
||||
* @api Smarty::registerFilter()
|
||||
* @link http://www.smarty.net/docs/en/api.register.filter.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.register.filter.tpl
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param callable $callback
|
||||
@ -316,7 +331,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
* Registers object to be used in templates
|
||||
*
|
||||
* @api Smarty::registerObject()
|
||||
* @link http://www.smarty.net/docs/en/api.register.object.tpl
|
||||
* @link https://www.smarty.net/docs/en/api.register.object.tpl
|
||||
*
|
||||
* @param string $object_name
|
||||
* @param object $object the referenced PHP object to register
|
||||
|
@ -203,13 +203,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
public $blockOrFunctionCode = '';
|
||||
|
||||
/**
|
||||
* php_handling setting either from Smarty or security
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $php_handling = 0;
|
||||
|
||||
/**
|
||||
* flags for used modifier plugins
|
||||
*
|
||||
@ -438,11 +431,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
$this->smarty->_debug->start_compile($this->template);
|
||||
}
|
||||
if (isset($this->template->smarty->security_policy)) {
|
||||
$this->php_handling = $this->template->smarty->security_policy->php_handling;
|
||||
} else {
|
||||
$this->php_handling = $this->template->smarty->php_handling;
|
||||
}
|
||||
$this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
|
||||
$nocache = isset($nocache) ? $nocache : false;
|
||||
if (empty($template->compiled->nocache_hash)) {
|
||||
@ -627,11 +615,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$this->trigger_template_error('Illegal number of parameter in "isset()"');
|
||||
}
|
||||
|
||||
$pa = array();
|
||||
foreach ($parameter as $p) {
|
||||
$pa[] = $this->syntaxMatchesVariable($p) ? 'isset(' . $p . ')' : '(' . $p . ' !== null )';
|
||||
}
|
||||
return '(' . implode(' && ', $pa) . ')';
|
||||
$pa = array();
|
||||
foreach ($parameter as $p) {
|
||||
$pa[] = $this->syntaxMatchesVariable($p) ? 'isset(' . $p . ')' : '(' . $p . ' !== null )';
|
||||
}
|
||||
return '(' . implode(' && ', $pa) . ')';
|
||||
|
||||
} elseif (in_array(
|
||||
$func_name,
|
||||
@ -649,12 +637,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$this->trigger_template_error("Illegal number of parameter in '{$func_name()}'");
|
||||
}
|
||||
if ($func_name === 'empty') {
|
||||
if (!$this->syntaxMatchesVariable($parameter[0]) && version_compare(PHP_VERSION, '5.5.0', '<')) {
|
||||
return '(' . $parameter[ 0 ] . ' === false )';
|
||||
} else {
|
||||
return $func_name . '(' .
|
||||
str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')';
|
||||
}
|
||||
return $func_name . '(' .
|
||||
str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')';
|
||||
} else {
|
||||
return $func_name . '(' . $parameter[ 0 ] . ')';
|
||||
}
|
||||
@ -667,16 +651,16 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the passed string represents a valid (PHP) variable.
|
||||
* This is important, because `isset()` only works on variables and `empty()` can only be passed
|
||||
* a variable prior to php5.5
|
||||
* @param $string
|
||||
* @return bool
|
||||
*/
|
||||
private function syntaxMatchesVariable($string) {
|
||||
static $regex_pattern = '/^\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*((->)[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*|\[.*]*\])*$/';
|
||||
return 1 === preg_match($regex_pattern, trim($string));
|
||||
/**
|
||||
* Determines whether the passed string represents a valid (PHP) variable.
|
||||
* This is important, because `isset()` only works on variables and `empty()` can only be passed
|
||||
* a variable prior to php5.5
|
||||
* @param $string
|
||||
* @return bool
|
||||
*/
|
||||
private function syntaxMatchesVariable($string) {
|
||||
static $regex_pattern = '/^\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*((->)[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*|\[.*]*\])*$/';
|
||||
return 1 === preg_match($regex_pattern, trim($string));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -691,11 +675,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
{
|
||||
|
||||
if (strpos($text, '<') === false) {
|
||||
return preg_replace($this->stripRegEx, '', $text);
|
||||
return preg_replace($this->stripRegEx, '', $text);
|
||||
}
|
||||
|
||||
$store = array();
|
||||
$_store = 0;
|
||||
$store = array();
|
||||
$_store = 0;
|
||||
|
||||
// capture html elements not to be messed with
|
||||
$_offset = 0;
|
||||
@ -1151,7 +1135,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
flush();
|
||||
}
|
||||
$e = new SmartyCompilerException($error_text);
|
||||
$e->line = $line;
|
||||
$e->setLine($line);
|
||||
$e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ]));
|
||||
$e->desc = $args;
|
||||
$e->template = $this->template->source->filepath;
|
||||
@ -1455,6 +1439,10 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
abstract protected function doCompile($_content, $isTemplateSource = false);
|
||||
|
||||
public function cStyleComment($string) {
|
||||
return '/*' . str_replace('*/', '* /' , $string) . '*/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile Tag
|
||||
*
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -362,7 +362,6 @@ class Smarty_Internal_TestInstall
|
||||
'smarty_internal_compile_function.php' => true,
|
||||
'smarty_internal_compile_if.php' => true,
|
||||
'smarty_internal_compile_include.php' => true,
|
||||
'smarty_internal_compile_include_php.php' => true,
|
||||
'smarty_internal_compile_insert.php' => true,
|
||||
'smarty_internal_compile_ldelim.php' => true,
|
||||
'smarty_internal_compile_make_nocache.php' => true,
|
||||
@ -373,7 +372,6 @@ class Smarty_Internal_TestInstall
|
||||
'smarty_internal_compile_private_modifier.php' => true,
|
||||
'smarty_internal_compile_private_object_block_function.php' => true,
|
||||
'smarty_internal_compile_private_object_function.php' => true,
|
||||
'smarty_internal_compile_private_php.php' => true,
|
||||
'smarty_internal_compile_private_print_expression.php' => true,
|
||||
'smarty_internal_compile_private_registered_block.php' => true,
|
||||
'smarty_internal_compile_private_registered_function.php' => true,
|
||||
@ -388,7 +386,6 @@ class Smarty_Internal_TestInstall
|
||||
'smarty_internal_config_file_compiler.php' => true,
|
||||
'smarty_internal_data.php' => true,
|
||||
'smarty_internal_debug.php' => true,
|
||||
'smarty_internal_errorhandler.php' => true,
|
||||
'smarty_internal_extension_handler.php' => true,
|
||||
'smarty_internal_method_addautoloadfilters.php' => true,
|
||||
'smarty_internal_method_adddefaultmodifiers.php' => true,
|
||||
@ -450,7 +447,6 @@ class Smarty_Internal_TestInstall
|
||||
'smarty_internal_resource_extends.php' => true,
|
||||
'smarty_internal_resource_file.php' => true,
|
||||
'smarty_internal_resource_php.php' => true,
|
||||
'smarty_internal_resource_registered.php' => true,
|
||||
'smarty_internal_resource_stream.php' => true,
|
||||
'smarty_internal_resource_string.php' => true,
|
||||
'smarty_internal_runtime_cachemodify.php' => true,
|
||||
|
@ -72,9 +72,7 @@ abstract class Smarty_Resource
|
||||
}
|
||||
// try registered resource
|
||||
if (isset($smarty->registered_resources[ $type ])) {
|
||||
return $smarty->_cache[ 'resource_handlers' ][ $type ] =
|
||||
$smarty->registered_resources[ $type ] instanceof Smarty_Resource ?
|
||||
$smarty->registered_resources[ $type ] : new Smarty_Internal_Resource_Registered();
|
||||
return $smarty->_cache[ 'resource_handlers' ][ $type ] = $smarty->registered_resources[ $type ];
|
||||
}
|
||||
// try sysplugins dir
|
||||
if (isset(self::$sysplugins[ $type ])) {
|
||||
|
@ -21,19 +21,6 @@
|
||||
*/
|
||||
class Smarty_Security
|
||||
{
|
||||
/**
|
||||
* This determines how Smarty handles "<?php ... ?>" tags in templates.
|
||||
* possible values:
|
||||
* <ul>
|
||||
* <li>Smarty::PHP_PASSTHRU -> echo PHP tags as they are</li>
|
||||
* <li>Smarty::PHP_QUOTE -> escape tags as entities</li>
|
||||
* <li>Smarty::PHP_REMOVE -> remove php tags</li>
|
||||
* <li>Smarty::PHP_ALLOW -> execute php tags</li>
|
||||
* </ul>
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $php_handling = Smarty::PHP_PASSTHRU;
|
||||
|
||||
/**
|
||||
* This is the list of template directories that are considered secure.
|
||||
|
@ -16,12 +16,12 @@ class SmartyCompilerException extends SmartyException
|
||||
}
|
||||
|
||||
/**
|
||||
* The line number of the template error
|
||||
*
|
||||
* @type int|null
|
||||
* @param int $line
|
||||
*/
|
||||
public $line = null;
|
||||
|
||||
public function setLine($line)
|
||||
{
|
||||
$this->line = $line;
|
||||
}
|
||||
/**
|
||||
* The template source snippet relating to the error
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user