BVB Source Codes

The latest thinkphp v5.2 work order system Show Smarty.class.php Source code

Return Download The latest thinkphp v5.2 work order system: download Smarty.class.php Source code - Download The latest thinkphp v5.2 work order system Source code - Type:.php
  1. <?php
  2. /**
  3. * Project:     Smarty: the PHP compiling template engine
  4. * File:        Smarty.class.php
  5. * SVN:         $Id: Smarty.class.php 2504 2011-12-28 07:35:29Z liu21st $
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20. *
  21. * For questions, help, comments, discussion, etc., please join the
  22. * Smarty mailing list. Send a blank e-mail to
  23. * smarty-discussion-subscribe@googlegroups.com
  24. *
  25. * @link http://www.smarty.net/
  26. * @copyright 2008 New Digital Group, Inc.
  27. * @author Monte Ohrt <monte at ohrt dot com>
  28. * @author Uwe Tews
  29. * @author Rodney Rehm
  30. * @package Smarty
  31. * @version 3.1.6
  32. */
  33.  
  34. /**
  35. * define shorthand directory separator constant
  36. */
  37. if (!defined('DS')) {
  38.     define('DS', DIRECTORY_SEPARATOR);
  39. }
  40.  
  41. /**
  42. * set SMARTY_DIR to absolute path to Smarty library files.
  43. * Sets SMARTY_DIR only if user application has not already defined it.
  44. */
  45. if (!defined('SMARTY_DIR')) {
  46.     define('SMARTY_DIR', dirname(__FILE__) . DS);
  47. }
  48.  
  49. /**
  50. * set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins.
  51. * Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it.
  52. */
  53. if (!defined('SMARTY_SYSPLUGINS_DIR')) {
  54.     define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS);
  55. }
  56. if (!defined('SMARTY_PLUGINS_DIR')) {
  57.     define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS);
  58. }
  59. if (!defined('SMARTY_MBSTRING')) {
  60.     define('SMARTY_MBSTRING', function_exists('mb_strlen'));
  61. }
  62. if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
  63.     // UTF-8 can only be done properly when mbstring is available!
  64.     define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1');
  65. }
  66. if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
  67.     define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y');
  68. }
  69.  
  70. /**
  71. * register the class autoloader
  72. */
  73. if (!defined('SMARTY_SPL_AUTOLOAD')) {
  74.     define('SMARTY_SPL_AUTOLOAD', 0);
  75. }
  76.  
  77. if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) {
  78.     $registeredAutoLoadFunctions = spl_autoload_functions();
  79.     if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
  80.         spl_autoload_register();
  81.     }
  82. } else {
  83.     spl_autoload_register('smartyAutoload');
  84. }
  85.  
  86. /**
  87. * Load always needed external class files
  88. */
  89. include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_data.php';
  90. include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_templatebase.php';
  91. include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_template.php';
  92. include_once SMARTY_SYSPLUGINS_DIR.'smarty_resource.php';
  93. include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_resource_file.php';
  94. include_once SMARTY_SYSPLUGINS_DIR.'smarty_cacheresource.php';
  95. include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_cacheresource_file.php';
  96.  
  97. /**
  98. * This is the main Smarty class
  99. * @package Smarty
  100. */
  101. class Smarty extends Smarty_Internal_TemplateBase {
  102.  
  103.     /**#@+
  104.     * constant definitions
  105.     */
  106.  
  107.     /**
  108.     * smarty version
  109.     */
  110.     const SMARTY_VERSION = 'Smarty-3.1.6';
  111.  
  112.     /**
  113.     * define variable scopes
  114.     */
  115.     const SCOPE_LOCAL = 0;
  116.     const SCOPE_PARENT = 1;
  117.     const SCOPE_ROOT = 2;
  118.     const SCOPE_GLOBAL = 3;
  119.     /**
  120.     * define caching modes
  121.     */
  122.     const CACHING_OFF = 0;
  123.     const CACHING_LIFETIME_CURRENT = 1;
  124.     const CACHING_LIFETIME_SAVED = 2;
  125.     /**
  126.     * define compile check modes
  127.     */
  128.     const COMPILECHECK_OFF = 0;
  129.     const COMPILECHECK_ON = 1;
  130.     const COMPILECHECK_CACHEMISS = 2;
  131.     /**
  132.     * modes for handling of "<?php ... ?>" tags in templates.
  133.     */
  134.     const PHP_PASSTHRU = 0; //-> print tags as plain text
  135.     const PHP_QUOTE = 1; //-> escape tags as entities
  136.     const PHP_REMOVE = 2; //-> escape tags as entities
  137.     const PHP_ALLOW = 3; //-> escape tags as entities
  138.     /**
  139.     * filter types
  140.     */
  141.     const FILTER_POST = 'post';
  142.     const FILTER_PRE = 'pre';
  143.     const FILTER_OUTPUT = 'output';
  144.     const FILTER_VARIABLE = 'variable';
  145.     /**
  146.     * plugin types
  147.     */
  148.     const PLUGIN_FUNCTION = 'function';
  149.     const PLUGIN_BLOCK = 'block';
  150.     const PLUGIN_COMPILER = 'compiler';
  151.     const PLUGIN_MODIFIER = 'modifier';
  152.     const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler';
  153.  
  154.     /**#@-*/
  155.  
  156.     /**
  157.     * assigned global tpl vars
  158.     */
  159.     public static $global_tpl_vars = array();
  160.  
  161.     /**
  162.      * error handler returned by set_error_hanlder() in Smarty::muteExpectedErrors()
  163.      */
  164.     public static $_previous_error_handler = null;
  165.     /**
  166.      * contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors()
  167.      */
  168.     public static $_muted_directories = array();
  169.  
  170.     /**#@+
  171.     * variables
  172.     */
  173.  
  174.     /**
  175.     * auto literal on delimiters with whitspace
  176.     * @var boolean
  177.     */
  178.     public $auto_literal = true;
  179.     /**
  180.     * display error on not assigned variables
  181.     * @var boolean
  182.     */
  183.     public $error_unassigned = false;
  184.     /**
  185.     * look up relative filepaths in include_path
  186.     * @var boolean
  187.     */
  188.     public $use_include_path = false;
  189.     /**
  190.     * template directory
  191.     * @var array
  192.     */
  193.     private $template_dir = array();
  194.     /**
  195.     * joined template directory string used in cache keys
  196.     * @var string
  197.     */
  198.     public $joined_template_dir = null;
  199.     /**
  200.     * joined config directory string used in cache keys
  201.     * @var string
  202.     */
  203.     public $joined_config_dir = null;
  204.     /**
  205.     * default template handler
  206.     * @var callable
  207.     */
  208.     public $default_template_handler_func = null;
  209.     /**
  210.     * default config handler
  211.     * @var callable
  212.     */
  213.     public $default_config_handler_func = null;
  214.     /**
  215.     * default plugin handler
  216.     * @var callable
  217.     */
  218.     public $default_plugin_handler_func = null;
  219.     /**
  220.     * compile directory
  221.     * @var string
  222.     */
  223.     private $compile_dir = null;
  224.     /**
  225.     * plugins directory
  226.     * @var array
  227.     */
  228.     private $plugins_dir = array();
  229.     /**
  230.     * cache directory
  231.     * @var string
  232.     */
  233.     private $cache_dir = null;
  234.     /**
  235.     * config directory
  236.     * @var array
  237.     */
  238.     private $config_dir = array();
  239.     /**
  240.     * force template compiling?
  241.     * @var boolean
  242.     */
  243.     public $force_compile = false;
  244.     /**
  245.     * check template for modifications?
  246.     * @var boolean
  247.     */
  248.     public $compile_check = true;
  249.     /**
  250.     * use sub dirs for compiled/cached files?
  251.     * @var boolean
  252.     */
  253.     public $use_sub_dirs = false;
  254.     /**
  255.      * allow ambiguous resources (that are made unique by the resource handler)
  256.      * @var boolean
  257.      */
  258.     public $allow_ambiguous_resources = false;
  259.     /**
  260.     * caching enabled
  261.     * @var boolean
  262.     */
  263.     public $caching = false;
  264.     /**
  265.     * merge compiled includes
  266.     * @var boolean
  267.     */
  268.     public $merge_compiled_includes = false;
  269.     /**
  270.     * cache lifetime in seconds
  271.     * @var integer
  272.     */
  273.     public $cache_lifetime = 3600;
  274.     /**
  275.     * force cache file creation
  276.     * @var boolean
  277.     */
  278.     public $force_cache = false;
  279.     /**
  280.      * Set this if you want different sets of cache files for the same
  281.      * templates.
  282.      *
  283.      * @var string
  284.      */
  285.     public $cache_id = null;
  286.     /**
  287.      * Set this if you want different sets of compiled files for the same
  288.      * templates.
  289.      *
  290.      * @var string
  291.      */
  292.     public $compile_id = null;
  293.     /**
  294.     * template left-delimiter
  295.     * @var string
  296.     */
  297.     public $left_delimiter = "{";
  298.     /**
  299.     * template right-delimiter
  300.     * @var string
  301.     */
  302.     public $right_delimiter = "}";
  303.     /**#@+
  304.     * security
  305.     */
  306.     /**
  307.     * class name
  308.     *
  309.     * This should be instance of Smarty_Security.
  310.     *
  311.     * @var string
  312.     * @see Smarty_Security
  313.     */
  314.     public $security_class = 'Smarty_Security';
  315.     /**
  316.     * implementation of security class
  317.     *
  318.     * @var Smarty_Security
  319.     */
  320.     public $security_policy = null;
  321.     /**
  322.     * controls handling of PHP-blocks
  323.     *
  324.     * @var integer
  325.     */
  326.     public $php_handling = self::PHP_PASSTHRU;
  327.     /**
  328.     * controls if the php template file resource is allowed
  329.     *
  330.     * @var bool
  331.     */
  332.     public $allow_php_templates = false;
  333.     /**
  334.     * Should compiled-templates be prevented from being called directly?
  335.     *
  336.     * {@internal
  337.     * Currently used by Smarty_Internal_Template only.
  338.     * }}
  339.     *
  340.     * @var boolean
  341.     */
  342.     public $direct_access_security = true;
  343.     /**#@-*/
  344.     /**
  345.     * debug mode
  346.     *
  347.     * Setting this to true enables the debug-console.
  348.     *
  349.     * @var boolean
  350.     */
  351.     public $debugging = false;
  352.     /**
  353.      * This determines if debugging is enable-able from the browser.
  354.      * <ul>
  355.      *  <li>NONE => no debugging control allowed</li>
  356.      *  <li>URL => enable debugging when SMARTY_DEBUG is found in the URL.</li>
  357.      * </ul>
  358.     * @var string
  359.     */
  360.     public $debugging_ctrl = 'NONE';
  361.     /**
  362.     * Name of debugging URL-param.
  363.     *
  364.     * Only used when $debugging_ctrl is set to 'URL'.
  365.     * The name of the URL-parameter that activates debugging.
  366.     *
  367.     * @var type
  368.     */
  369.     public $smarty_debug_id = 'SMARTY_DEBUG';
  370.     /**
  371.     * Path of debug template.
  372.     * @var string
  373.     */
  374.     public $debug_tpl = null;
  375.     /**
  376.     * When set, smarty uses this value as error_reporting-level.
  377.     * @var int
  378.     */
  379.     public $error_reporting = null;
  380.     /**
  381.     * Internal flag for getTags()
  382.     * @var boolean
  383.     */
  384.     public $get_used_tags = false;
  385.  
  386.     /**#@+
  387.     * config var settings
  388.     */
  389.  
  390.     /**
  391.     * Controls whether variables with the same name overwrite each other.
  392.     * @var boolean
  393.     */
  394.     public $config_overwrite = true;
  395.     /**
  396.     * Controls whether config values of on/true/yes and off/false/no get converted to boolean.
  397.     * @var boolean
  398.     */
  399.     public $config_booleanize = true;
  400.     /**
  401.     * Controls whether hidden config sections/vars are read from the file.
  402.     * @var boolean
  403.     */
  404.     public $config_read_hidden = false;
  405.  
  406.     /**#@-*/
  407.  
  408.     /**#@+
  409.     * resource locking
  410.     */
  411.  
  412.     /**
  413.     * locking concurrent compiles
  414.     * @var boolean
  415.     */
  416.     public $compile_locking = true;
  417.     /**
  418.      * Controls whether cache resources should emply locking mechanism
  419.      * @var boolean
  420.      */
  421.     public $cache_locking = false;
  422.     /**
  423.      * seconds to wait for acquiring a lock before ignoring the write lock
  424.      * @var float
  425.      */
  426.     public $locking_timeout = 10;
  427.  
  428.     /**#@-*/
  429.  
  430.     /**
  431.     * global template functions
  432.     * @var array
  433.     */
  434.     public $template_functions = array();
  435.     /**
  436.     * resource type used if none given
  437.     *
  438.     * Must be an valid key of $registered_resources.
  439.     * @var string
  440.     */
  441.     public $default_resource_type = 'file';
  442.     /**
  443.     * caching type
  444.     *
  445.     * Must be an element of $cache_resource_types.
  446.     *
  447.     * @var string
  448.     */
  449.     public $caching_type = 'file';
  450.     /**
  451.     * internal config properties
  452.     * @var array
  453.     */
  454.     public $properties = array();
  455.     /**
  456.     * config type
  457.     * @var string
  458.     */
  459.     public $default_config_type = 'file';
  460.     /**
  461.     * cached template objects
  462.     * @var array
  463.     */
  464.     public $template_objects = array();
  465.     /**
  466.     * check If-Modified-Since headers
  467.     * @var boolean
  468.     */
  469.     public $cache_modified_check = false;
  470.     /**
  471.     * registered plugins
  472.     * @var array
  473.     */
  474.     public $registered_plugins = array();
  475.     /**
  476.     * plugin search order
  477.     * @var array
  478.     */
  479.     public $plugin_search_order = array('function', 'block', 'compiler', 'class');
  480.     /**
  481.     * registered objects
  482.     * @var array
  483.     */
  484.     public $registered_objects = array();
  485.     /**
  486.     * registered classes
  487.     * @var array
  488.     */
  489.     public $registered_classes = array();
  490.     /**
  491.     * registered filters
  492.     * @var array
  493.     */
  494.     public $registered_filters = array();
  495.     /**
  496.     * registered resources
  497.     * @var array
  498.     */
  499.     public $registered_resources = array();
  500.     /**
  501.     * resource handler cache
  502.     * @var array
  503.     */
  504.     public $_resource_handlers = array();
  505.     /**
  506.     * registered cache resources
  507.     * @var array
  508.     */
  509.     public $registered_cache_resources = array();
  510.     /**
  511.     * cache resource handler cache
  512.     * @var array
  513.     */
  514.     public $_cacheresource_handlers = array();
  515.     /**
  516.     * autoload filter
  517.     * @var array
  518.     */
  519.     public $autoload_filters = array();
  520.     /**
  521.     * default modifier
  522.     * @var array
  523.     */
  524.     public $default_modifiers = array();
  525.     /**
  526.     * autoescape variable output
  527.     * @var boolean
  528.     */
  529.     public $escape_html = false;
  530.     /**
  531.     * global internal smarty vars
  532.     * @var array
  533.     */
  534.     public static $_smarty_vars = array();
  535.     /**
  536.     * start time for execution time calculation
  537.     * @var int
  538.     */
  539.     public $start_time = 0;
  540.     /**
  541.     * default file permissions
  542.     * @var int
  543.     */
  544.     public $_file_perms = 0644;
  545.     /**
  546.     * default dir permissions
  547.     * @var int
  548.     */
  549.     public $_dir_perms = 0771;
  550.     /**
  551.     * block tag hierarchy
  552.     * @var array
  553.     */
  554.     public $_tag_stack = array();
  555.     /**
  556.     * self pointer to Smarty object
  557.     * @var Smarty
  558.     */
  559.     public $smarty;
  560.     /**
  561.     * required by the compiler for BC
  562.     * @var string
  563.     */
  564.     public $_current_file = null;
  565.     /**
  566.     * internal flag to enable parser debugging
  567.     * @var bool
  568.     */
  569.     public $_parserdebug = false;
  570.     /**
  571.     * Saved parameter of merged templates during compilation
  572.     *
  573.     * @var array
  574.     */
  575.     public $merged_templates_func = array();
  576.     /**#@-*/
  577.  
  578.     /**
  579.     * Initialize new Smarty object
  580.     *
  581.     */
  582.     public function __construct()
  583.     {
  584.         // selfpointer needed by some other class methods
  585.         $this->smarty = $this;
  586.         if (is_callable('mb_internal_encoding')) {
  587.             mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET);
  588.         }
  589.         $this->start_time = microtime(true);
  590.         // set default dirs
  591.         $this->setTemplateDir('.' . DS . 'templates' . DS)
  592.             ->setCompileDir('.' . DS . 'templates_c' . DS)
  593.             ->setPluginsDir(SMARTY_PLUGINS_DIR)
  594.             ->setCacheDir('.' . DS . 'cache' . DS)
  595.             ->setConfigDir('.' . DS . 'configs' . DS);
  596.  
  597.         $this->debug_tpl = 'file:' . dirname(__FILE__) . '/debug.tpl';
  598.         if (isset($_SERVER['SCRIPT_NAME'])) {
  599.             $this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
  600.         }
  601.     }
  602.  
  603.  
  604.     /**
  605.     * Class destructor
  606.     */
  607.     public function __destruct()
  608.     {
  609.         // intentionally left blank
  610.     }
  611.  
  612.     /**
  613.     * <<magic>> set selfpointer on cloned object
  614.     */
  615.     public function __clone()
  616.     {
  617.         $this->smarty = $this;
  618.     }
  619.  
  620.  
  621.     /**
  622.     * <<magic>> Generic getter.
  623.     *
  624.     * Calls the appropriate getter function.
  625.     * Issues an E_USER_NOTICE if no valid getter is found.
  626.     *
  627.     * @param string $name property name
  628.     * @return mixed
  629.     */
  630.     public function __get($name)
  631.     {
  632.         $allowed = array(
  633.         'template_dir' => 'getTemplateDir',
  634.         'config_dir' => 'getConfigDir',
  635.         'plugins_dir' => 'getPluginsDir',
  636.         'compile_dir' => 'getCompileDir',
  637.         'cache_dir' => 'getCacheDir',
  638.         );
  639.  
  640.         if (isset($allowed[$name])) {
  641.             return $this->{$allowed[$name]}();
  642.         } else {
  643.             trigger_error('Undefined property: '. get_class($this) .'::$'. $name, E_USER_NOTICE);
  644.         }
  645.     }
  646.  
  647.     /**
  648.     * <<magic>> Generic setter.
  649.     *
  650.     * Calls the appropriate setter function.
  651.     * Issues an E_USER_NOTICE if no valid setter is found.
  652.     *
  653.     * @param string $name  property name
  654.     * @param mixed  $value parameter passed to setter
  655.     */
  656.     public function __set($name, $value)
  657.     {
  658.         $allowed = array(
  659.         'template_dir' => 'setTemplateDir',
  660.         'config_dir' => 'setConfigDir',
  661.         'plugins_dir' => 'setPluginsDir',
  662.         'compile_dir' => 'setCompileDir',
  663.         'cache_dir' => 'setCacheDir',
  664.         );
  665.  
  666.         if (isset($allowed[$name])) {
  667.             $this->{$allowed[$name]}($value);
  668.         } else {
  669.             trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
  670.         }
  671.     }
  672.  
  673.     /**
  674.     * Check if a template resource exists
  675.     *
  676.     * @param string $resource_name template name
  677.     * @return boolean status
  678.     */
  679.     public function templateExists($resource_name)
  680.     {
  681.         // create template object
  682.         $save = $this->template_objects;
  683.         $tpl = new $this->template_class($resource_name, $this);
  684.         // check if it does exists
  685.         $result = $tpl->source->exists;
  686.         $this->template_objects = $save;
  687.         return $result;
  688.     }
  689.  
  690.     /**
  691.     * Returns a single or all global  variables
  692.     *
  693.     * @param object $smarty
  694.     * @param string $varname variable name or null
  695.     * @return string variable value or or array of variables
  696.     */
  697.     public function getGlobal($varname = null)
  698.     {
  699.         if (isset($varname)) {
  700.             if (isset(self::$global_tpl_vars[$varname])) {
  701.                 return self::$global_tpl_vars[$varname]->value;
  702.             } else {
  703.                 return '';
  704.             }
  705.         } else {
  706.             $_result = array();
  707.             foreach (self::$global_tpl_vars AS $key => $var) {
  708.                 $_result[$key] = $var->value;
  709.             }
  710.             return $_result;
  711.         }
  712.     }
  713.  
  714.     /**
  715.     * Empty cache folder
  716.     *
  717.     * @param integer $exp_time expiration time
  718.     * @param string  $type     resource type
  719.     * @return integer number of cache files deleted
  720.     */
  721.     function clearAllCache($exp_time = null, $type = null)
  722.     {
  723.         // load cache resource and call clearAll
  724.         $_cache_resource = Smarty_CacheResource::load($this, $type);
  725.         Smarty_CacheResource::invalidLoadedCache($this);
  726.         return $_cache_resource->clearAll($this, $exp_time);
  727.     }
  728.  
  729.     /**
  730.     * Empty cache for a specific template
  731.     *
  732.     * @param string  $template_name template name
  733.     * @param string  $cache_id      cache id
  734.     * @param string  $compile_id    compile id
  735.     * @param integer $exp_time      expiration time
  736.     * @param string  $type          resource type
  737.     * @return integer number of cache files deleted
  738.     */
  739.     public function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
  740.     {
  741.         // load cache resource and call clear
  742.         $_cache_resource = Smarty_CacheResource::load($this, $type);
  743.         Smarty_CacheResource::invalidLoadedCache($this);
  744.         return $_cache_resource->clear($this, $template_name, $cache_id, $compile_id, $exp_time);
  745.     }
  746.  
  747.     /**
  748.     * Loads security class and enables security
  749.     *
  750.     * @param string|Smarty_Security $security_class if a string is used, it must be class-name
  751.     * @return Smarty current Smarty instance for chaining
  752.     * @throws SmartyException when an invalid class name is provided
  753.     */
  754.     public function enableSecurity($security_class = null)
  755.     {
  756.         if ($security_class instanceof Smarty_Security) {
  757.             $this->security_policy = $security_class;
  758.             return $this;
  759.         } elseif (is_object($security_class)) {
  760.             throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security.");
  761.         }
  762.         if ($security_class == null) {
  763.             $security_class = $this->security_class;
  764.         }
  765.         if (!class_exists($security_class)) {
  766.             throw new SmartyException("Security class '$security_class' is not defined");
  767.         } elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) {
  768.             throw new SmartyException("Class '$security_class' must extend Smarty_Security.");
  769.         } else {
  770.             $this->security_policy = new $security_class($this);
  771.         }
  772.  
  773.         return $this;
  774.     }
  775.  
  776.     /**
  777.     * Disable security
  778.     * @return Smarty current Smarty instance for chaining
  779.     */
  780.     public function disableSecurity()
  781.     {
  782.         $this->security_policy = null;
  783.  
  784.         return $this;
  785.     }
  786.  
  787.     /**
  788.     * Set template directory
  789.     *
  790.     * @param string|array $template_dir directory(s) of template sources
  791.     * @return Smarty current Smarty instance for chaining
  792.     */
  793.     public function setTemplateDir($template_dir)
  794.     {
  795.         $this->template_dir = array();
  796.         foreach ((array) $template_dir as $k => $v) {
  797.             $this->template_dir[$k] = rtrim($v, '/\\') . DS;
  798.         }
  799.  
  800.         $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir);
  801.         return $this;
  802.     }
  803.  
  804.     /**
  805.     * Add template directory(s)
  806.     *
  807.     * @param string|array $template_dir directory(s) of template sources
  808.     * @param string       $key          of the array element to assign the template dir to
  809.     * @return Smarty current Smarty instance for chaining
  810.     * @throws SmartyException when the given template directory is not valid
  811.     */
  812.     public function addTemplateDir($template_dir, $key=null)
  813.     {
  814.         // make sure we're dealing with an array
  815.         $this->template_dir = (array) $this->template_dir;
  816.  
  817.         if (is_array($template_dir)) {
  818.             foreach ($template_dir as $k => $v) {
  819.                 if (is_int($k)) {
  820.                     // indexes are not merged but appended
  821.                     $this->template_dir[] = rtrim($v, '/\\') . DS;
  822.                 } else {
  823.                     // string indexes are overridden
  824.                     $this->template_dir[$k] = rtrim($v, '/\\') . DS;
  825.                 }
  826.             }
  827.         } elseif ($key !== null) {
  828.             // override directory at specified index
  829.             $this->template_dir[$key] = rtrim($template_dir, '/\\') . DS;
  830.         } else {
  831.             // append new directory
  832.             $this->template_dir[] = rtrim($template_dir, '/\\') . DS;
  833.         }
  834.         $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir);
  835.         return $this;
  836.     }
  837.  
  838.     /**
  839.     * Get template directories
  840.     *
  841.     * @param mixed index of directory to get, null to get all
  842.     * @return array|string list of template directories, or directory of $index
  843.     */
  844.     public function getTemplateDir($index=null)
  845.     {
  846.         if ($index !== null) {
  847.             return isset($this->template_dir[$index]) ? $this->template_dir[$index] : null;
  848.         }
  849.  
  850.         return (array)$this->template_dir;
  851.     }
  852.  
  853.     /**
  854.     * Set config directory
  855.     *
  856.     * @param string|array $template_dir directory(s) of configuration sources
  857.     * @return Smarty current Smarty instance for chaining
  858.     */
  859.     public function setConfigDir($config_dir)
  860.     {
  861.         $this->config_dir = array();
  862.         foreach ((array) $config_dir as $k => $v) {
  863.             $this->config_dir[$k] = rtrim($v, '/\\') . DS;
  864.         }
  865.  
  866.         $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);
  867.         return $this;
  868.     }
  869.  
  870.     /**
  871.     * Add config directory(s)
  872.     *
  873.     * @param string|array $config_dir directory(s) of config sources
  874.     * @param string key of the array element to assign the config dir to
  875.     * @return Smarty current Smarty instance for chaining
  876.     */
  877.     public function addConfigDir($config_dir, $key=null)
  878.     {
  879.         // make sure we're dealing with an array
  880.         $this->config_dir = (array) $this->config_dir;
  881.  
  882.         if (is_array($config_dir)) {
  883.             foreach ($config_dir as $k => $v) {
  884.                 if (is_int($k)) {
  885.                     // indexes are not merged but appended
  886.                     $this->config_dir[] = rtrim($v, '/\\') . DS;
  887.                 } else {
  888.                     // string indexes are overridden
  889.                     $this->config_dir[$k] = rtrim($v, '/\\') . DS;
  890.                 }
  891.             }
  892.         } elseif( $key !== null ) {
  893.             // override directory at specified index
  894.             $this->config_dir[$key] = rtrim($config_dir, '/\\') . DS;
  895.         } else {
  896.             // append new directory
  897.             $this->config_dir[] = rtrim($config_dir, '/\\') . DS;
  898.         }
  899.  
  900.         $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);
  901.         return $this;
  902.     }
  903.  
  904.     /**
  905.     * Get config directory
  906.     *
  907.     * @param mixed index of directory to get, null to get all
  908.     * @return array|string configuration directory
  909.     */
  910.     public function getConfigDir($index=null)
  911.     {
  912.         if ($index !== null) {
  913.             return isset($this->config_dir[$index]) ? $this->config_dir[$index] : null;
  914.         }
  915.  
  916.         return (array)$this->config_dir;
  917.     }
  918.  
  919.     /**
  920.     * Set plugins directory
  921.     *
  922.     * @param string|array $plugins_dir directory(s) of plugins
  923.     * @return Smarty current Smarty instance for chaining
  924.     */
  925.     public function setPluginsDir($plugins_dir)
  926.     {
  927.         $this->plugins_dir = array();
  928.         foreach ((array)$plugins_dir as $k => $v) {
  929.             $this->plugins_dir[$k] = rtrim($v, '/\\') . DS;
  930.         }
  931.  
  932.         return $this;
  933.     }
  934.  
  935.     /**
  936.     * Adds directory of plugin files
  937.     *
  938.     * @param object $smarty
  939.     * @param string $ |array $ plugins folder
  940.     * @return Smarty current Smarty instance for chaining
  941.     */
  942.     public function addPluginsDir($plugins_dir)
  943.     {
  944.         // make sure we're dealing with an array
  945.         $this->plugins_dir = (array) $this->plugins_dir;
  946.  
  947.         if (is_array($plugins_dir)) {
  948.             foreach ($plugins_dir as $k => $v) {
  949.                 if (is_int($k)) {
  950.                     // indexes are not merged but appended
  951.                     $this->plugins_dir[] = rtrim($v, '/\\') . DS;
  952.                 } else {
  953.                     // string indexes are overridden
  954.                     $this->plugins_dir[$k] = rtrim($v, '/\\') . DS;
  955.                 }
  956.             }
  957.         } else {
  958.             // append new directory
  959.             $this->plugins_dir[] = rtrim($plugins_dir, '/\\') . DS;
  960.         }
  961.  
  962.         $this->plugins_dir = array_unique($this->plugins_dir);
  963.         return $this;
  964.     }
  965.  
  966.     /**
  967.     * Get plugin directories
  968.     *
  969.     * @return array list of plugin directories
  970.     */
  971.     public function getPluginsDir()
  972.     {
  973.         return (array)$this->plugins_dir;
  974.     }
  975.  
  976.     /**
  977.     * Set compile directory
  978.     *
  979.     * @param string $compile_dir directory to store compiled templates in
  980.     * @return Smarty current Smarty instance for chaining
  981.     */
  982.     public function setCompileDir($compile_dir)
  983.     {
  984.         $this->compile_dir = rtrim($compile_dir, '/\\') . DS;
  985.         if (!isset(Smarty::$_muted_directories[$this->compile_dir])) {
  986.             Smarty::$_muted_directories[$this->compile_dir] = null;
  987.         }
  988.         return $this;
  989.     }
  990.  
  991.     /**
  992.     * Get compiled directory
  993.     *
  994.     * @return string path to compiled templates
  995.     */
  996.     public function getCompileDir()
  997.     {
  998.         return $this->compile_dir;
  999.     }
  1000.  
  1001.     /**
  1002.     * Set cache directory
  1003.     *
  1004.     * @param string $cache_dir directory to store cached templates in
  1005.     * @return Smarty current Smarty instance for chaining
  1006.     */
  1007.     public function setCacheDir($cache_dir)
  1008.     {
  1009.         $this->cache_dir = rtrim($cache_dir, '/\\') . DS;
  1010.         if (!isset(Smarty::$_muted_directories[$this->cache_dir])) {
  1011.             Smarty::$_muted_directories[$this->cache_dir] = null;
  1012.         }
  1013.         return $this;
  1014.     }
  1015.  
  1016.     /**
  1017.     * Get cache directory
  1018.     *
  1019.     * @return string path of cache directory
  1020.     */
  1021.     public function getCacheDir()
  1022.     {
  1023.         return $this->cache_dir;
  1024.     }
  1025.  
  1026.     /**
  1027.     * Set default modifiers
  1028.     *
  1029.     * @param array|string $modifiers modifier or list of modifiers to set
  1030.     * @return Smarty current Smarty instance for chaining
  1031.     */
  1032.     public function setDefaultModifiers($modifiers)
  1033.     {
  1034.         $this->default_modifiers = (array) $modifiers;
  1035.         return $this;
  1036.     }
  1037.  
  1038.     /**
  1039.     * Add default modifiers
  1040.     *
  1041.     * @param array|string $modifiers modifier or list of modifiers to add
  1042.     * @return Smarty current Smarty instance for chaining
  1043.     */
  1044.     public function addDefaultModifiers($modifiers)
  1045.     {
  1046.         if (is_array($modifiers)) {
  1047.             $this->default_modifiers = array_merge($this->default_modifiers, $modifiers);
  1048.         } else {
  1049.             $this->default_modifiers[] = $modifiers;
  1050.         }
  1051.  
  1052.         return $this;
  1053.     }
  1054.  
  1055.     /**
  1056.     * Get default modifiers
  1057.     *
  1058.     * @return array list of default modifiers
  1059.     */
  1060.     public function getDefaultModifiers()
  1061.     {
  1062.         return $this->default_modifiers;
  1063.     }
  1064.  
  1065.  
  1066.     /**
  1067.     * Set autoload filters
  1068.     *
  1069.     * @param array $filters filters to load automatically
  1070.     * @param string $type "pre", "output", 鈥 specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types
  1071.     * @return Smarty current Smarty instance for chaining
  1072.     */
  1073.     public function setAutoloadFilters($filters, $type=null)
  1074.     {
  1075.         if ($type !== null) {
  1076.             $this->autoload_filters[$type] = (array) $filters;
  1077.         } else {
  1078.             $this->autoload_filters = (array) $filters;
  1079.         }
  1080.  
  1081.         return $this;
  1082.     }
  1083.  
  1084.     /**
  1085.     * Add autoload filters
  1086.     *
  1087.     * @param array $filters filters to load automatically
  1088.     * @param string $type "pre", "output", 鈥 specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types
  1089.     * @return Smarty current Smarty instance for chaining
  1090.     */
  1091.     public function addAutoloadFilters($filters, $type=null)
  1092.     {
  1093.         if ($type !== null) {
  1094.             if (!empty($this->autoload_filters[$type])) {
  1095.                 $this->autoload_filters[$type] = array_merge($this->autoload_filters[$type], (array) $filters);
  1096.             } else {
  1097.                 $this->autoload_filters[$type] = (array) $filters;
  1098.             }
  1099.         } else {
  1100.             foreach ((array) $filters as $key => $value) {
  1101.                 if (!empty($this->autoload_filters[$key])) {
  1102.                     $this->autoload_filters[$key] = array_merge($this->autoload_filters[$key], (array) $value);
  1103.                 } else {
  1104.                     $this->autoload_filters[$key] = (array) $value;
  1105.                 }
  1106.             }
  1107.         }
  1108.  
  1109.         return $this;
  1110.     }
  1111.  
  1112.     /**
  1113.     * Get autoload filters
  1114.     *
  1115.     * @param string $type type of filter to get autoloads for. Defaults to all autoload filters
  1116.     * @return array array( 'type1' => array( 'filter1', 'filter2', 鈥 ) ) or array( 'filter1', 'filter2', 鈥? if $type was specified
  1117.     */
  1118.     public function getAutoloadFilters($type=null)
  1119.     {
  1120.         if ($type !== null) {
  1121.             return isset($this->autoload_filters[$type]) ? $this->autoload_filters[$type] : array();
  1122.         }
  1123.  
  1124.         return $this->autoload_filters;
  1125.     }
  1126.  
  1127.     /**
  1128.     * return name of debugging template
  1129.     *
  1130.     * @return string
  1131.     */
  1132.     public function getDebugTemplate()
  1133.     {
  1134.         return $this->debug_tpl;
  1135.     }
  1136.  
  1137.     /**
  1138.     * set the debug template
  1139.     *
  1140.     * @param string $tpl_name
  1141.     * @return Smarty current Smarty instance for chaining
  1142.     * @throws SmartyException if file is not readable
  1143.     */
  1144.     public function setDebugTemplate($tpl_name)
  1145.     {
  1146.         if (!is_readable($tpl_name)) {
  1147.             throw new SmartyException("Unknown file '{$tpl_name}'");
  1148.         }
  1149.         $this->debug_tpl = $tpl_name;
  1150.  
  1151.         return $this;
  1152.     }
  1153.  
  1154.     /**
  1155.     * creates a template object
  1156.     *
  1157.     * @param string $template the resource handle of the template file
  1158.     * @param mixed $cache_id cache id to be used with this template
  1159.     * @param mixed $compile_id compile id to be used with this template
  1160.     * @param object $parent next higher level of Smarty variables
  1161.     * @param boolean $do_clone flag is Smarty object shall be cloned
  1162.     * @return object template object
  1163.     */
  1164.     public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true)
  1165.     {
  1166.         if (!empty($cache_id) && (is_object($cache_id) || is_array($cache_id))) {
  1167.             $parent = $cache_id;
  1168.             $cache_id = null;
  1169.         }
  1170.         if (!empty($parent) && is_array($parent)) {
  1171.             $data = $parent;
  1172.             $parent = null;
  1173.         } else {
  1174.             $data = null;
  1175.         }
  1176.         // default to cache_id and compile_id of Smarty object
  1177.         $cache_id = $cache_id === null ? $this->cache_id : $cache_id;
  1178.         $compile_id = $compile_id === null ? $this->compile_id : $compile_id;
  1179.         // already in template cache?
  1180.         if ($this->allow_ambiguous_resources) {
  1181.             $_templateId = Smarty_Resource::getUniqueTemplateName($this, $template) . $cache_id . $compile_id;
  1182.         } else {
  1183.             $_templateId = $this->joined_template_dir . '#' . $template . $cache_id . $compile_id;
  1184.         }
  1185.         if (isset($_templateId[150])) {
  1186.             $_templateId = sha1($_templateId);
  1187.         }
  1188.         if ($do_clone) {
  1189.             if (isset($this->template_objects[$_templateId])) {
  1190.                 // return cached template object
  1191.                 $tpl = clone $this->template_objects[$_templateId];
  1192.                 $tpl->smarty = clone $tpl->smarty;
  1193.                 $tpl->parent = $parent;
  1194.                 $tpl->tpl_vars = array();
  1195.                 $tpl->config_vars = array();
  1196.             } else {
  1197.                 $tpl = new $this->template_class($template, clone $this, $parent, $cache_id, $compile_id);
  1198.             }
  1199.         } else {
  1200.             if (isset($this->template_objects[$_templateId])) {
  1201.                 // return cached template object
  1202.                 $tpl = $this->template_objects[$_templateId];
  1203.                 $tpl->parent = $parent;
  1204.                 $tpl->tpl_vars = array();
  1205.                 $tpl->config_vars = array();
  1206.             } else {
  1207.                 $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id);
  1208.             }
  1209.         }
  1210.         // fill data if present
  1211.         if (!empty($data) && is_array($data)) {
  1212.             // set up variable values
  1213.             foreach ($data as $_key => $_val) {
  1214.                 $tpl->tpl_vars[$_key] = new Smarty_variable($_val);
  1215.             }
  1216.         }
  1217.         return $tpl;
  1218.     }
  1219.  
  1220.  
  1221.     /**
  1222.     * Takes unknown classes and loads plugin files for them
  1223.     * class name format: Smarty_PluginType_PluginName
  1224.     * plugin filename format: plugintype.pluginname.php
  1225.     *
  1226.     * @param string $plugin_name    class plugin name to load
  1227.     * @param bool   $check          check if already loaded
  1228.     * @return string |boolean filepath of loaded file or false
  1229.     */
  1230.     public function loadPlugin($plugin_name, $check = true)
  1231.     {
  1232.         // if function or class exists, exit silently (already loaded)
  1233.         if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) {
  1234.             return true;
  1235.         }
  1236.         // Plugin name is expected to be: Smarty_[Type]_[Name]
  1237.         $_name_parts = explode('_', $plugin_name, 3);
  1238.         // class name must have three parts to be valid plugin
  1239.         // count($_name_parts) < 3 === !isset($_name_parts[2])
  1240.         if (!isset($_name_parts[2]) || strtolower($_name_parts[0]) !== 'smarty') {
  1241.             throw new SmartyException("plugin {$plugin_name} is not a valid name format");
  1242.             return false;
  1243.         }
  1244.         // if type is "internal", get plugin from sysplugins
  1245.         if (strtolower($_name_parts[1]) == 'internal') {
  1246.             $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php';
  1247.             if (file_exists($file)) {
  1248.                 require_once($file);
  1249.                 return $file;
  1250.             } else {
  1251.                 return false;
  1252.             }
  1253.         }
  1254.         // plugin filename is expected to be: [type].[name].php
  1255.         $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
  1256.  
  1257.         // loop through plugin dirs and find the plugin
  1258.         foreach($this->getPluginsDir() as $_plugin_dir) {
  1259.             $names = array(
  1260.                 $_plugin_dir . $_plugin_filename,
  1261.                 $_plugin_dir . strtolower($_plugin_filename),
  1262.             );
  1263.             foreach ($names as $file) {
  1264.                 if (file_exists($file)) {
  1265.                     require_once($file);
  1266.                     return $file;
  1267.                 }
  1268.                 if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
  1269.                     // try PHP include_path
  1270.                     if (($file = Smarty_Internal_Get_Include_Path::getIncludePath($file)) !== false) {
  1271.                         require_once($file);
  1272.                         return $file;
  1273.                     }
  1274.                 }
  1275.             }
  1276.         }
  1277.         // no plugin loaded
  1278.         return false;
  1279.     }
  1280.  
  1281.     /**
  1282.     * Compile all template files
  1283.     *
  1284.     * @param string $extension file extension
  1285.     * @param bool $force_compile force all to recompile
  1286.     * @param int $time_limit
  1287.     * @param int $max_errors
  1288.     * @return integer number of template files recompiled
  1289.     */
  1290.     public function compileAllTemplates($extention = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
  1291.     {
  1292.         return Smarty_Internal_Utility::compileAllTemplates($extention, $force_compile, $time_limit, $max_errors, $this);
  1293.     }
  1294.  
  1295.     /**
  1296.     * Compile all config files
  1297.     *
  1298.     * @param string $extension file extension
  1299.     * @param bool $force_compile force all to recompile
  1300.     * @param int $time_limit
  1301.     * @param int $max_errors
  1302.     * @return integer number of template files recompiled
  1303.     */
  1304.     public function compileAllConfig($extention = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null)
  1305.     {
  1306.         return Smarty_Internal_Utility::compileAllConfig($extention, $force_compile, $time_limit, $max_errors, $this);
  1307.     }
  1308.  
  1309.     /**
  1310.     * Delete compiled template file
  1311.     *
  1312.     * @param string $resource_name template name
  1313.     * @param string $compile_id compile id
  1314.     * @param integer $exp_time expiration time
  1315.     * @return integer number of template files deleted
  1316.     */
  1317.     public function clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null)
  1318.     {
  1319.         return Smarty_Internal_Utility::clearCompiledTemplate($resource_name, $compile_id, $exp_time, $this);
  1320.     }
  1321.  
  1322.  
  1323.     /**
  1324.     * Return array of tag/attributes of all tags used by an template
  1325.     *
  1326.     * @param object $templae template object
  1327.     * @return array of tag/attributes
  1328.     */
  1329.     public function getTags(Smarty_Internal_Template $template)
  1330.     {
  1331.         return Smarty_Internal_Utility::getTags($template);
  1332.     }
  1333.  
  1334.     /**
  1335.      * Run installation test
  1336.      *
  1337.      * @param array $errors Array to write errors into, rather than outputting them
  1338.      * @return boolean true if setup is fine, false if something is wrong
  1339.      */
  1340.     public function testInstall(&$errors=null)
  1341.     {
  1342.         return Smarty_Internal_Utility::testInstall($this, $errors);
  1343.     }
  1344.  
  1345.     /**
  1346.      * Error Handler to mute expected messages
  1347.      *
  1348.      * @link http://php.net/set_error_handler
  1349.      * @param integer $errno Error level
  1350.      * @return boolean
  1351.      */
  1352.     public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
  1353.     {
  1354.         $_is_muted_directory = false;
  1355.  
  1356.         // add the SMARTY_DIR to the list of muted directories
  1357.         if (!isset(Smarty::$_muted_directories[SMARTY_DIR])) {
  1358.             $smarty_dir = realpath(SMARTY_DIR);
  1359.             Smarty::$_muted_directories[SMARTY_DIR] = array(
  1360.                 'file' => $smarty_dir,
  1361.                 'length' => strlen($smarty_dir),
  1362.             );
  1363.         }
  1364.  
  1365.         // walk the muted directories and test against $errfile
  1366.         foreach (Smarty::$_muted_directories as $key => &$dir) {
  1367.             if (!$dir) {
  1368.                 // resolve directory and length for speedy comparisons
  1369.                 $file = realpath($key);
  1370.                 $dir = array(
  1371.                     'file' => $file,
  1372.                     'length' => strlen($file),
  1373.                 );
  1374.             }
  1375.             if (!strncmp($errfile, $dir['file'], $dir['length'])) {
  1376.                 $_is_muted_directory = true;
  1377.                 break;
  1378.             }
  1379.         }
  1380.  
  1381.         // pass to next error handler if this error did not occur inside SMARTY_DIR
  1382.         // or the error was within smarty but masked to be ignored
  1383.         if (!$_is_muted_directory || ($errno && $errno & error_reporting())) {
  1384.             if (Smarty::$_previous_error_handler) {
  1385.                 return call_user_func(Smarty::$_previous_error_handler, $errno, $errstr, $errfile, $errline, $errcontext);
  1386.             } else {
  1387.                 return false;
  1388.             }
  1389.         }
  1390.     }
  1391.  
  1392.     /**
  1393.      * Enable error handler to mute expected messages
  1394.      *
  1395.      * @return void
  1396.      */
  1397.     public static function muteExpectedErrors()
  1398.     {
  1399.         /*
  1400.             error muting is done because some people implemented custom error_handlers using
  1401.             http://php.net/set_error_handler and for some reason did not understand the following paragraph:
  1402.  
  1403.                 It is important to remember that the standard PHP error handler is completely bypassed for the
  1404.                 error types specified by error_types unless the callback function returns FALSE.
  1405.                 error_reporting() settings will have no effect and your error handler will be called regardless -
  1406.                 however you are still able to read the current value of error_reporting and act appropriately.
  1407.                 Of particular note is that this value will be 0 if the statement that caused the error was
  1408.                 prepended by the @ error-control operator.
  1409.  
  1410.             Smarty deliberately uses @filemtime() over file_exists() and filemtime() in some places. Reasons include
  1411.                 - @filemtime() is almost twice as fast as using an additional file_exists()
  1412.                 - between file_exists() and filemtime() a possible race condition is opened,
  1413.                   which does not exist using the simple @filemtime() approach.
  1414.         */
  1415.         $error_handler = array('Smarty', 'mutingErrorHandler');
  1416.         $previous = set_error_handler($error_handler);
  1417.  
  1418.         // avoid dead loops
  1419.         if ($previous !== $error_handler) {
  1420.             Smarty::$_previous_error_handler = $previous;
  1421.         }
  1422.     }
  1423.  
  1424.     /**
  1425.      * Disable error handler muting expected messages
  1426.      *
  1427.      * @return void
  1428.      */
  1429.     public static function unmuteExpectedErrors()
  1430.     {
  1431.         restore_error_handler();
  1432.     }
  1433. }
  1434.  
  1435. /**
  1436. * Smarty exception class
  1437. * @package Smarty
  1438. */
  1439. class SmartyException extends Exception {
  1440. }
  1441.  
  1442. /**
  1443. * Smarty compiler exception class
  1444. * @package Smarty
  1445. */
  1446. class SmartyCompilerException extends SmartyException  {
  1447. }
  1448.  
  1449. /**
  1450. * Autoloader
  1451. */
  1452. function smartyAutoload($class)
  1453. {
  1454.     $_class = strtolower($class);
  1455.     $_classes = array(
  1456.         'smarty_config_source' => true,
  1457.         'smarty_config_compiled' => true,
  1458.         'smarty_security' => true,
  1459.         'smarty_cacheresource' => true,
  1460.         'smarty_cacheresource_custom' => true,
  1461.         'smarty_cacheresource_keyvaluestore' => true,
  1462.         'smarty_resource' => true,
  1463.         'smarty_resource_custom' => true,
  1464.         'smarty_resource_uncompiled' => true,
  1465.         'smarty_resource_recompiled' => true,
  1466.     );
  1467.  
  1468.     if (!strncmp($_class, 'smarty_internal_', 16) || isset($_classes[$_class])) {
  1469.         include SMARTY_SYSPLUGINS_DIR . $_class . '.php';
  1470.     }
  1471. }
  1472.  
  1473. ?>
  1474.  
downloadSmarty.class.php Source code - Download The latest thinkphp v5.2 work order system Source code
Related Source Codes/Software:
V3.3.6 Workerman high-performance PHP Socket (framework) - High performance PHP Socket framework Workerman re... 2017-05-03
The phosphor meeting room reservation system MRBS (loop reservation v16.0) - The phosphor meeting room reservation system MRBS ... 2017-05-03
IDC v5.2.3 agent center - IDC Centre IDC for exploitation is a PHP+MySQL age... 2017-05-03
Zen master v9.0.1 project management software - Zen is the first domestic open source project mana... 2017-05-03
Ray speed v7.03 employee files management system - Employee files project is various, and some conten... 2017-05-03
HITCMS Haitian responsive electronic mechanical v3.0 foreign trade website source code - HITCMS Haitian response electronic machinery trade... 2017-05-03
Ray v7.02 speed survey system - Lightning speed survey system is a. NET+MSSQL deve... 2017-05-03
Cool HITCMS reactive black v3.0 enterprise website source code - HITCMS-Haitian response black enterprises website ... 2017-05-03
WebOA v17.2 network office automation system - WebOA network using b/s structure development of o... 2017-05-03
Pure imitation of han site source code, one a 】 【 c9cms kernel v1.0 - Generic http://www.wufazhuce.com/Han one · Config... 2017-05-04
zone.js - Implements Zones for JavaScript ... 2017-05-11
dragonfly - A Ruby gem for on-the-fly processing - suitable fo... 2017-05-11
oh-my-fish - The Fishshell Framework. 2017-05-11
canvas-lms - The open LMS by Instructure, Inc. 2017-05-11
ledger - Double-entry accounting system with a command-line... 2017-05-11
Python - My Python Examples http://w... 2017-05-11
blade - 2017-05-11
LaZagne - Credentials recovery project 2017-05-10
Pull-to-Refresh.Rentals-iOS - This project aims to provide a simple and customiz... 2017-05-10
spoon - Distributing instrumentation tests to all your And... 2017-05-10

 Back to top