Advertisement
johnburn

Untitled

Apr 30th, 2011
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 39.30 KB | None | 0 0
  1. <?php
  2.  
  3. class Smarty {
  4.     public $template_dir = "temam";
  5.     public $compile_dir = "templates_c";
  6.     public $config_dir = "configs";
  7.     public $plugins_dir = array("plugins");
  8.     public $debugging = false;
  9.     public $error_reporting = null;
  10.     public $debug_tpl = "debug.tpl";
  11.     public $debugging_ctrl = "NONE";
  12.     public $compile_check = false;
  13.     public $force_compile = false;
  14.     public $caching = 0;
  15.     public $cache_dir = "cache";
  16.     public $cache_lifetime = 3600;
  17.     public $cache_modified_check = false;
  18.     public $php_handling = SMARTY_PHP_PASSTHRU;
  19.     public $security = false;
  20.     public $secure_dir = array();
  21.     public $security_settings = array('PHP_HANDLING' => false, 'IF_FUNCS' => array("array", "list", "isset", "empty", "count", "sizeof", "in_array", "is_array", "true", "false", "null"), 'INCLUDE_ANY' => false, 'PHP_TAGS' => false, 'MODIFIER_FUNCS' => array("count"), 'ALLOW_CONSTANTS' => false);
  22.     public $trusted_dir = array();
  23.     public $left_delimiter = "{";
  24.     public $right_delimiter = "}";
  25.     public $request_vars_order = "EGPCS";
  26.     public $request_use_auto_globals = true;
  27.     public $compile_id = null;
  28.     public $use_sub_dirs = false;
  29.     public $default_modifiers = array();
  30.     public $default_resource_type = "file";
  31.     public $cache_handler_func = null;
  32.     public $autoload_filters = array();
  33.     public $config_overwrite = true;
  34.     public $config_booleanize = true;
  35.     public $config_read_hidden = false;
  36.     public $config_fix_newlines = true;
  37.     public $default_template_handler_func = "";
  38.     public $compiler_file = "Smarty_Compiler.class.php";
  39.     public $compiler_class = "Smarty_Compiler";
  40.     public $config_class = "Config_File";
  41.     public $_tpl_vars = array();
  42.     public $_smarty_vars = null;
  43.     public $_sections = array();
  44.     public $_foreach = array();
  45.     public $_tag_stack = array();
  46.     public $_conf_obj = null;
  47.     public $_config = array(array('vars' => array(), 'files' => array()));
  48.     public $_smarty_md5 = "f8d698aea36fcbead2b9d5359ffca76f";
  49.     public $_version = "2.6.18";
  50.     public $_inclusion_depth = 0;
  51.     public $_compile_id = null;
  52.     public $_smarty_debug_id = "SMARTY_DEBUG";
  53.     public $_smarty_debug_info = array();
  54.     public $_cache_info = array();
  55.     public $_file_perms = 420;
  56.     public $_dir_perms = 505;
  57.     public $_reg_objects = array();
  58.     public $_plugins = array('modifier' => array(), 'function' => array(), 'block' => array(), 'compiler' => array(), 'prefilter' => array(), 'postfilter' => array(), 'outputfilter' => array(), 'resource' => array(), 'insert' => array());
  59.     public $_cache_serials = array();
  60.     public $_cache_include = null;
  61.     public $_cache_including = false;
  62.     public function Smarty() {
  63.         $this->assign("SCRIPT_NAME", isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : $GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
  64.     }
  65.     public function assign($tpl_var, $value = null) {
  66.         if (is_array($tpl_var)) {
  67.             foreach($tpl_var as $key => $val) {
  68.                 if ($key != "") {
  69.                     $this->_tpl_vars[$key] = $val;
  70.                 }
  71.             }
  72.         } else {
  73.             if ($tpl_var != "") {
  74.                 $this->_tpl_vars[$tpl_var] = $value;
  75.             }
  76.         }
  77.     }
  78.     public function assign_by_ref($tpl_var, &$value) {
  79.         if ($tpl_var != "") {
  80.             $this->_tpl_vars[$tpl_var] = & $value;
  81.         }
  82.     }
  83.     public function append($tpl_var, $value = null, $merge = false) {
  84.         if (is_array($tpl_var)) {
  85.             do {
  86.                 foreach($tpl_var as $_key => $_val) {
  87.                     if ($_key != "") {
  88.                         if (@!is_array(@$this->_tpl_vars[$_key])) {
  89.                             settype($this->_tpl_vars[$_key], "array");
  90.                         }
  91.                         if ($merge && is_array($_val)) {
  92.                             foreach($_val as $_mkey => $_mval) {
  93.                                 $this->_tpl_vars[$_key][$_mkey] = $_mval;
  94.                             }
  95.                         } else {
  96.                             $this->_tpl_vars[$_key][] = $_val;
  97.                         }
  98.                     }
  99.                 } else {
  100.                     if ($tpl_var != "" && isset($value)) {
  101.                         if (@!is_array(@$this->_tpl_vars[$Var_1368])) {
  102.                             settype($this->_tpl_vars[$tpl_var], "array");
  103.                         }
  104.                         if (!($merge && is_array($value))) {
  105.                             break;
  106.                         } else {
  107.                             foreach($value as $_mkey => $_mval) {
  108.                                 $this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
  109.                             }
  110.                         }
  111.                     }
  112.                 }
  113.                 return;
  114.             }
  115.             while (0);
  116.             $this->_tpl_vars[$tpl_var][] = $value;
  117.         }
  118.     }
  119.     public function append_by_ref($tpl_var, &$value, $merge = false) {
  120.         if ($tpl_var != "" && isset($value)) {
  121.             if (@!is_array(@$this->_tpl_vars[$tpl_var])) {
  122.                 settype($this->_tpl_vars[$tpl_var], "array");
  123.             }
  124.             if ($merge && is_array($value)) {
  125.                 foreach($value as $_key => $_val) {
  126.                     $this->_tpl_vars[$tpl_var][$_key] = & $value[$_key];
  127.                 }
  128.             } else {
  129.                 $this->_tpl_vars[$tpl_var][] = & $value;
  130.             }
  131.         }
  132.     }
  133.     public function clear_assign($tpl_var) {
  134.         if (is_array($tpl_var)) {
  135.             foreach($tpl_var as $curr_var) {
  136.                 unset($Var_216[$curr_var]);
  137.             }
  138.         } else {
  139.             unset($Var_288[$tpl_var]);
  140.         }
  141.     }
  142.     public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null) {
  143.         $this->_plugins['function'][$function] = array($Var_192, null, null, false, $cacheable, $cache_attrs);
  144.     }
  145.     public function unregister_function($function) {
  146.         unset($Var_24['function'][$function]);
  147.     }
  148.     public function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) {
  149.         settype($allowed, "array");
  150.         settype($smarty_args, "boolean");
  151.         $this->_reg_objects[$object] = array($object_impl, $allowed, $smarty_args, $block_methods);
  152.     }
  153.     public function unregister_object($object) {
  154.         unset($Var_24[$object]);
  155.     }
  156.     public function register_block($block, $block_impl, $cacheable = true, $cache_attrs = null) {
  157.         $this->_plugins['block'][$block] = array($block_impl, null, null, false, $cacheable, $cache_attrs);
  158.     }
  159.     public function unregister_block($block) {
  160.         unset($Var_24['block'][$Var_72]);
  161.     }
  162.     public function register_compiler_function($function, $function_impl, $cacheable = true) {
  163.         $this->_plugins['compiler'][$function] = array($function_impl, null, null, false, $cacheable);
  164.     }
  165.     public function unregister_compiler_function($function) {
  166.         unset($Var_24['compiler'][$function]);
  167.     }
  168.     public function register_modifier($modifier, $modifier_impl) {
  169.         $this->_plugins['modifier'][$modifier] = array($modifier_impl, null, null, false);
  170.     }
  171.     public function unregister_modifier($modifier) {
  172.         unset($Var_24['modifier'][$modifier]);
  173.     }
  174.     public function register_resource($type, $functions) {
  175.         if ($Var_72 == 4) {
  176.             $this->_plugins['resource'][$type] = array($functions, false);
  177.         } else if (count($functions) == 5) {
  178.             $this->_plugins['resource'][$type] = array(array(array($functions[0], $functions[1]), array($functions[0], $functions[2]), array($functions[0], $functions[3]), array($functions[0], $functions[4])), false);
  179.         } else {
  180.             $this->trigger_error("malformed function-list for '{$type}' in register_resource");
  181.         }
  182.     }
  183.     public function unregister_resource($type) {
  184.         unset($Var_24['resource'][$type]);
  185.     }
  186.     public function register_prefilter($function) {
  187.         $_name = is_array($function) ? $function[1] : $function;
  188.         $this->_plugins['prefilter'][$_name] = array($function, null, null, false);
  189.     }
  190.     public function unregister_prefilter($function) {
  191.         unset($Var_48[$function]);
  192.     }
  193.     public function register_postfilter($function) {
  194.         $_name = is_array($function) ? $function[1] : $function;
  195.         $this->_plugins['postfilter'][$_name] = array($function, null, null, false);
  196.     }
  197.     public function unregister_postfilter($function) {
  198.         unset($Var_24['postfilter'][$function]);
  199.     }
  200.     public function register_outputfilter($function) {
  201.         $_name = is_array($function) ? $function[1] : $function;
  202.         $Var_216['outputfilter'][$_name] = array($function, null, null, false);
  203.     }
  204.     public function unregister_outputfilter($function) {
  205.         unset($Var_24['outputfilter'][$function]);
  206.     }
  207.     public function load_filter($type, $name) {
  208.         switch ($type) {
  209.             case "output":
  210.                 require_once (SMARTY_CORE_DIR . "core.load_plugins.php");
  211.                 smarty_core_load_plugins($_params, $this);
  212.             break;
  213.             case "pre":
  214.             break;
  215.             case "post":
  216.         }
  217.         if (!isset($this->_plugins[$type . "filter"][$name])) {
  218.             $this->_plugins[$type . "filter"][$name] = false;
  219.         }
  220. }
  221. public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) {
  222.     if (!isset($compile_id)) {
  223.         $compile_id = $this->compile_id;
  224.     }
  225.     if (!isset($tpl_file)) {
  226.         $compile_id = null;
  227.     }
  228.     $_auto_id = $this->_get_auto_id($cache_id, $compile_id);
  229.     if (!empty($this->cache_handler_func)) {
  230.         return call_user_func_array($this->cache_handler_func, array("clear", $this, $dummy, $tpl_file, $cache_id, $compile_id, $exp_time));
  231.     }
  232.     $_params = array("auto_base" => $this->cache_dir, "auto_source" => $tpl_file, "auto_id" => $_auto_id, "exp_time" => $exp_time);
  233.     require_once (SMARTY_CORE_DIR . "core.rm_auto.php");
  234.     return smarty_core_rm_auto($_params, $this);
  235. }
  236. public function clear_all_cache($exp_time = null) {
  237.     return $this->clear_cache(null, null, null, $exp_time);
  238. }
  239. public function is_cached($tpl_file, $cache_id = null, $compile_id = null) {
  240.     if (!$this->caching) {
  241.         return false;
  242.     }
  243.     if (!isset($compile_id)) {
  244.         $compile_id = $this->compile_id;
  245.     }
  246.     $_params = array("tpl_file" => $tpl_file, "cache_id" => $cache_id, "compile_id" => $compile_id);
  247.     require_once (SMARTY_CORE_DIR . "core.read_cache_file.php");
  248.     return smarty_core_read_cache_file($_params, $this);
  249. }
  250. public function clear_all_assign() {
  251.     $this->_tpl_vars = array();
  252. }
  253. public function clear_1d_tpl($tpl_file = null, $compile_id = null, $exp_time = null) {
  254.     if (!isset($compile_id)) {
  255.         $compile_id = $this->compile_id;
  256.     }
  257.     $_params = array("auto_base" => $this->compile_dir, "auto_source" => $tpl_file, "auto_id" => $compile_id, "exp_time" => $exp_time, "extensions" => array(".inc", ".php"));
  258.     require_once (SMARTY_CORE_DIR . "core.rm_auto.php");
  259.     return smarty_core_rm_auto($_params, $this);
  260. }
  261. public function template_exists($tpl_file) {
  262.     $_params = array("resource_name" => $tpl_file, "quiet" => true, "get_source" => false);
  263.     return $this->_fetch_resource_info($_params);
  264. }
  265. public function &get_template_vars($name = null) {
  266.     if (!isset($name)) {
  267.         return $this->_tpl_vars;
  268.     }
  269.     if (isset($this->_tpl_vars[$name])) {
  270.         return $this->_tpl_vars[$name];
  271.     }
  272.     $_tmp = null;
  273.     return $_tmp;
  274. }
  275. public function &get_config_vars($name = null) {
  276.     if (!isset($name) && is_array($this->_config[0])) {
  277.         return $this->_config[0]['vars'];
  278.     }
  279.     if (isset($this->_config[0]['vars'][$name])) {
  280.         return $this->_config[0]['vars'][$name];
  281.     }
  282.     $_tmp = null;
  283.     return $_tmp;
  284. }
  285. public function trigger_error($error_msg, $error_type = E_USER_WARNING) {
  286.     trigger_error("Smarty error: {$error_msg}", $error_type);
  287. }
  288. public function display($resource_name, $cache_id = null, $compile_id = null) {
  289.     $this->fetch($resource_name, $cache_id, $compile_id, true);
  290. }
  291. public function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false) {
  292.     static $_cache_info = array();
  293.     if ($this->debugging) {
  294.     } else {
  295.     }
  296.     $_smarty_old_error_level = error_reporting(isset($this->error_reporting) ? $this->error_reporting : error_reporting() & ~E_NOTICE);
  297.     if (!$this->debugging && $this->debugging_ctrl == "URL") {
  298.         $_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];
  299.         if (@strstr(@$_query_string, @$this->_smarty_debug_id)) {
  300.             if (@strstr(@$_query_string, @$this->_smarty_debug_id . "=on")) {
  301.                 @setcookie("SMARTY_DEBUG", @true);
  302.                 $this->debugging = true;
  303.             } else {
  304.                 if (@strstr(@$_query_string, @$this->_smarty_debug_id . "=off")) {
  305.                     @setcookie("SMARTY_DEBUG", @false);
  306.                     $this->debugging = false;
  307.                 } else {
  308.                     $this->debugging = true;
  309.                 }
  310.             }
  311.         } else {
  312.             $this->debugging = ( string )($this->request_use_auto_globals ? $_COOKIE['SMARTY_DEBUG'] : $GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']);
  313.         }
  314.     }
  315.     if ($this->debugging) {
  316.         $_params = array();
  317.         require_once (SMARTY_CORE_DIR . "core.get_microtime.php");
  318.         $_debug_start_time = smarty_core_get_microtime($_params, $this);
  319.         $this->_smarty_debug_info[] = array("type" => "template", "filename" => $resource_name, "depth" => 0);
  320.         $_included_tpls_idx = count($this->_smarty_debug_info) - 1;
  321.     }
  322.     if (!isset($compile_id)) {
  323.         $compile_id = $this->compile_id;
  324.     }
  325.     $this->_compile_id = $compile_id;
  326.     $this->_inclusion_depth = 0;
  327.     if ($this->caching) {
  328.         array_push($_cache_info, $this->_cache_info);
  329.         $this->_cache_info = array();
  330.         $_params = array("tpl_file" => $resource_name, "cache_id" => $cache_id, "compile_id" => $compile_id, "results" => null);
  331.         require_once (SMARTY_CORE_DIR . "core.read_cache_file.php");
  332.         if (smarty_core_read_cache_file($_params, $this)) {
  333.             $_smarty_results = $_params['results'];
  334.             if (!empty($this->_cache_info['insert_tags'])) {
  335.                 $_params = array("plugins" => $this->_cache_info['insert_tags']);
  336.                 require_once (SMARTY_CORE_DIR . "core.load_plugins.php");
  337.                 smarty_core_load_plugins($_params, $this);
  338.                 $_params = array("results" => $_smarty_results);
  339.                 require_once (SMARTY_CORE_DIR . "core.process_cached_inserts.php");
  340.                 $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
  341.             }
  342.             if (!empty($this->_cache_info['cache_serials'])) {
  343.                 $_params = array("results" => $_smarty_results);
  344.                 require_once (SMARTY_CORE_DIR . "core.process_compiled_include.php");
  345.                 $_smarty_results = smarty_core_process_compiled_include($_params, $this);
  346.             }
  347.             if ($display) {
  348.                 if ($this->debugging) {
  349.                     $_params = array();
  350.                     require_once (SMARTY_CORE_DIR . "core.get_microtime.php");
  351.                     $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
  352.                     require_once (SMARTY_CORE_DIR . "core.display_debug_console.php");
  353.                     $_smarty_results.= smarty_core_display_debug_console($_params, $this);
  354.                 }
  355.                 if ($this->cache_modified_check) {
  356.                     $_server_vars = $this->request_use_auto_globals ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
  357.                     $_last_modified_date = @substr(@$_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, @strpos(@$_server_vars['HTTP_IF_MODIFIED_SINCE'], "GMT") + 3);
  358.                     $_gmt_mtime = gmdate("D, d M Y H:i:s", $this->_cache_info['timestamp']) . " GMT";
  359.                     if (count(@$this->_cache_info['insert_tags']) == 0 && !$this->_cache_serials && $_gmt_mtime == $_last_modified_date) {
  360.                         if (php_sapi_name() == "cgi") {
  361.                             header("Status: 304 Not Modified");
  362.                         } else {
  363.                             header("HTTP/1.1 304 Not Modified");
  364.                         }
  365.                     } else {
  366.                         header("Last-Modified: " . $_gmt_mtime);
  367.                         echo $_smarty_results;
  368.                     }
  369.                 } else {
  370.                     echo $_smarty_results;
  371.                 }
  372.                 error_reporting($_smarty_old_error_level);
  373.                 $this->_cache_info = array_pop($_cache_info);
  374.                 return true;
  375.             }
  376.             error_reporting($_smarty_old_error_level);
  377.             $this->_cache_info = array_pop($_cache_info);
  378.             return $_smarty_results;
  379.         }
  380.         $this->_cache_info['template'][$resource_name] = true;
  381.         if ($this->cache_modified_check && $display) {
  382.             header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
  383.         }
  384.     }
  385.     if (count($this->autoload_filters)) {
  386.         foreach($this->autoload_filters as $_filter_type => $_filters) {
  387.             foreach($_filters as $_filter) {
  388.                 $this->load_filter($_filter_type, $_filter);
  389.             }
  390.         }
  391.     }
  392.     $_smarty_compile_path = $this->_get_compile_path($resource_name);
  393.     $_cache_including = $this->_cache_including;
  394.     $this->_cache_including = false;
  395.     if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) {
  396.         if ($this->_is_compiled($resource_name, $_smarty_compile_path) || $this->_compile_resource($resource_name, $_smarty_compile_path)) {
  397.             include ($_smarty_compile_path);
  398.         }
  399.     } else {
  400.         ob_start();
  401.         if ($this->_is_compiled($resource_name, $_smarty_compile_path) || $this->_compile_resource($resource_name, $_smarty_compile_path)) {
  402.             include ($_smarty_compile_path);
  403.         }
  404.         $_smarty_results = ob_get_contents();
  405.         ob_end_clean();
  406.         foreach(( array ) as $_output_filter) {
  407.             $_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, $this));
  408.         }
  409.     }
  410.     if ($this->caching) {
  411.         $_params = array("tpl_file" => $resource_name, "cache_id" => $cache_id, "compile_id" => $compile_id, "results" => $_smarty_results);
  412.         require_once (SMARTY_CORE_DIR . "core.write_cache_file.php");
  413.         smarty_core_write_cache_file($_params, $this);
  414.         require_once (SMARTY_CORE_DIR . "core.process_cached_inserts.php");
  415.         $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
  416.         if ($this->_cache_serials) {
  417.             $_smarty_results = preg_replace("!(\\{/?nocache\\:[0-9a-f]{32}#\\d+\\})!s", "", $_smarty_results);
  418.         }
  419.         $this->_cache_info = array_pop($_cache_info);
  420.     }
  421.     $this->_cache_including = $_cache_including;
  422.     if ($display) {
  423.         if (isset($_smarty_results)) {
  424.             echo $_smarty_results;
  425.         }
  426.         if ($this->debugging) {
  427.             $_params = array();
  428.             require_once (SMARTY_CORE_DIR . "core.get_microtime.php");
  429.             $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
  430.             require_once (SMARTY_CORE_DIR . "core.display_debug_console.php");
  431.             echo smarty_core_display_debug_console($_params, $this);
  432.         }
  433.         error_reporting($_smarty_old_error_level);
  434.     } else {
  435.         error_reporting($_smarty_old_error_level);
  436.         if (isset($_smarty_results)) {
  437.             return $_smarty_results;
  438.         }
  439.     }
  440. }
  441. public function config_load($file, $section = null, $scope = "global") {
  442.     require_once ($this->_get_plugin_filepath("function", "config_load"));
  443.     smarty_function_config_load(array("file" => $file, "section" => $section, "scope" => $scope), $this);
  444. }
  445. public function &get_registered_object($name) {
  446.     if (!isset($this->_reg_objects[$name])) {
  447.         $this->_trigger_fatal_error("'{$name}' is not a registered object");
  448.     }
  449.     if (!is_object($this->_reg_objects[$name][0])) {
  450.         $this->_trigger_fatal_error("registered '{$name}' is not an object");
  451.     }
  452.     return $this->_reg_objects[$name][0];
  453. }
  454. public function clear_config($var = null) {
  455.     if (!isset($var)) {
  456.         $this->_config = array(array("vars" => array(), "files" => array()));
  457.     } else {
  458.         unset($Var_192[0]['vars'][$var]);
  459.     }
  460. }
  461. public function _get_plugin_filepath($type, $name) {
  462.     $_params = array("type" => $type, "name" => $name);
  463.     require_once (SMARTY_CORE_DIR . "core.assemble_plugin_filepath.php");
  464.     return smarty_core_assemble_plugin_filepath($_params, $this);
  465. }
  466. public function _is_compiled($resource_name, $compile_path) {
  467.     if (!$this->force_compile && file_exists($compile_path)) {
  468.         if (!$this->compile_check) {
  469.             return true;
  470.         }
  471.         $_params = array("resource_name" => $resource_name, "get_source" => false);
  472.         if (!$this->_fetch_resource_info($_params)) {
  473.         }
  474.         if ($_params['resource_timestamp'] <= filemtime($compile_path)) {
  475.             return true;
  476.         }
  477.         return false;
  478.     }
  479.     return false;
  480. }
  481. public function _compile_resource($resource_name, $compile_path) {
  482.     $_params = array("resource_name" => $resource_name);
  483.     if (!$this->_fetch_resource_info($_params)) {
  484.         return false;
  485.     }
  486.     $_source_content = $_params['source_content'];
  487.     $_cache_include = $Var_432 . ".inc";
  488.     if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) {
  489.         if ($this->_cache_include_info) {
  490.             require_once (SMARTY_CORE_DIR . "core.write_compiled_include.php");
  491.             smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array("compiled_content" => $_compiled_content, "resource_name" => $resource_name)), $this);
  492.         }
  493.         $_params = array("compile_path" => $compile_path, "compiled_content" => $_compiled_content);
  494.         require_once (SMARTY_CORE_DIR . "core.write_compiled_resource.php");
  495.         smarty_core_write_compiled_resource($_params, $this);
  496.         return true;
  497.     }
  498.     return false;
  499. }
  500. public function _compile_source($resource_name, &$source_content, &$compiled_content, $cache_include_path = null) {
  501.     if (file_exists(SMARTY_DIR . $this->compiler_file)) {
  502.         require_once (SMARTY_DIR . $this->compiler_file);
  503.     } else {
  504.         require_once ($this->compiler_file);
  505.     }
  506.     ();
  507.     $smarty_compiler = $Var_408;
  508.     $smarty_compiler->template_dir = $this->template_dir;
  509.     $smarty_compiler->compile_dir = $this->compile_dir;
  510.     $smarty_compiler->plugins_dir = $this->plugins_dir;
  511.     $smarty_compiler->config_dir = $this->config_dir;
  512.     $smarty_compiler->force_compile = $this->force_compile;
  513.     $smarty_compiler->caching = $this->caching;
  514.     $smarty_compiler->php_handling = $this->php_handling;
  515.     $smarty_compiler->left_delimiter = $this->left_delimiter;
  516.     $smarty_compiler->right_delimiter = $this->right_delimiter;
  517.     $smarty_compiler->_version = $this->_version;
  518.     $smarty_compiler->security = $this->security;
  519.     $smarty_compiler->secure_dir = $this->secure_dir;
  520.     $smarty_compiler->security_settings = $this->security_settings;
  521.     $smarty_compiler->trusted_dir = $this->trusted_dir;
  522.     $smarty_compiler->use_sub_dirs = $this->use_sub_dirs;
  523.     $smarty_compiler->_reg_objects = & $this->_reg_objects;
  524.     $smarty_compiler->_plugins = & $this->_plugins;
  525.     $smarty_compiler->_tpl_vars = & $this->_tpl_vars;
  526.     $smarty_compiler->default_modifiers = $this->default_modifiers;
  527.     $smarty_compiler->compile_id = $this->_compile_id;
  528.     $smarty_compiler->_config = $this->_config;
  529.     $smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals;
  530.     if (isset($cache_include_path) && isset($this->_cache_serials[$cache_include_path])) {
  531.         $smarty_compiler->_cache_serial = $this->_cache_serials[$cache_include_path];
  532.     }
  533.     $smarty_compiler->_cache_include = $cache_include_path;
  534.     $_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
  535.     if ($smarty_compiler->_cache_serial) {
  536.         $this->_cache_include_info = array("cache_serial" => $smarty_compiler->_cache_serial, "plugins_code" => $smarty_compiler->_plugins_code, "include_file_path" => $cache_include_path);
  537.     } else {
  538.         $this->_cache_include_info = null;
  539.     }
  540.     return $_results;
  541. }
  542. public function _get_compile_path($resource_name) {
  543.     return $this->_get_auto_filename($this->compile_dir, $resource_name, $this->_compile_id) . ".php";
  544. }
  545. public function _fetch_resource_info(&$params) {
  546.     if (!isset($params['get_source'])) {
  547.         $params['get_source'] = true;
  548.     }
  549.     if (!isset($params['quiet'])) {
  550.         $params['quiet'] = false;
  551.     }
  552.     $_return = false;
  553.     $_params = array("resource_name" => $params['resource_name']);
  554.     if (isset($params['resource_base_path'])) {
  555.         $_params['resource_base_path'] = $params['resource_base_path'];
  556.     } else {
  557.         $_params['resource_base_path'] = $this->template_dir;
  558.     }
  559.     if ($this->_parse_resource_name($_params)) {
  560.         $_resource_type = $_params['resource_type'];
  561.         $_resource_name = $_params['resource_name'];
  562.         switch ($_resource_type) {
  563.             case "file":
  564.                 if ($params['get_source']) {
  565.                     $params['source_content'] = $this->_read_file($_resource_name);
  566.                 }
  567.                 $params['resource_timestamp'] = ($_resource_name);
  568.                 $_return = is_file($_resource_name);
  569.             break;
  570.         }
  571.         if ($params['get_source']) {
  572.             $_source_return = isset($this->_plugins['resource'][$_resource_type]) && call_user_func_array($this->_plugins['resource'][$_resource_type][0][0], array($_resource_name, $params['source_content'], $this));
  573.         } else {
  574.             $_source_return = true;
  575.         }
  576.         $_timestamp_return = isset($this->_plugins['resource'][$_resource_type]) && call_user_func_array($this->_plugins['resource'][$_resource_type][0][1], array($_resource_name, $params['resource_timestamp'], $this));
  577.         $_return = $_source_return && $_timestamp_return;
  578.         break;
  579.     }
  580.     if (!$_return && !empty($this->default_template_handler_func)) {
  581.         if (!is_callable($this->default_template_handler_func)) {
  582.             $this->trigger_error("default template handler function \"{$this->default_template_handler_func}\" doesn't exist.");
  583.         } else {
  584.             $_return = call_user_func_array($this->default_template_handler_func, array($_params['resource_type'], $_params['resource_name'], $params['source_content'], $params['resource_timestamp'], $this));
  585.         }
  586.     }
  587.     if (!$_return) {
  588.         if (!$params['quiet']) {
  589.             $this->trigger_error("unable to read resource: \"" . $params['resource_name'] . "\"");
  590.         }
  591.     } else {
  592.         if ($_return && $this->security) {
  593.             require_once (SMARTY_CORE_DIR . "core.is_secure.php");
  594.             if (!smarty_core_is_secure($_params, $this)) {
  595.                 if (!$params['quiet']) {
  596.                     $this->trigger_error("(secure mode) accessing \"" . $params['resource_name'] . "\" is not allowed");
  597.                 }
  598.                 $params['source_content'] = null;
  599.                 $params['resource_timestamp'] = null;
  600.                 return false;
  601.             }
  602.         }
  603.     }
  604.     return $_return;
  605. }
  606. public function _parse_resource_name(&$params) {
  607.     $_resource_name_parts = explode(":", $params['resource_name'], 2);
  608.     if (count($_resource_name_parts) == 1) {
  609.         $params['resource_type'] = $this->default_resource_type;
  610.         $params['resource_name'] = $_resource_name_parts[0];
  611.     } else if (strlen($_resource_name_parts[0]) == 1) {
  612.         $params['resource_type'] = $this->default_resource_type;
  613.         $params['resource_name'] = $params['resource_name'];
  614.     } else {
  615.         $params['resource_type'] = $_resource_name_parts[0];
  616.         $params['resource_name'] = $_resource_name_parts[1];
  617.     }
  618.     if ($params['resource_type'] == "file") {
  619.         if (!preg_match("/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/", $params['resource_name'])) {
  620.             foreach(( array ) as $_curr_path) {
  621.                 $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
  622.                 if (file_exists($_fullpath) && is_file($_fullpath)) {
  623.                     $params['resource_name'] = $_fullpath;
  624.                     return true;
  625.                 }
  626.                 $_params = array("file_path" => $_fullpath);
  627.                 require_once (SMARTY_CORE_DIR . "core.get_include_path.php");
  628.                 if (smarty_core_get_include_path($_params, $this)) {
  629.                     $params['resource_name'] = $_params['new_file_path'];
  630.                     return true;
  631.                     break;
  632.                 }
  633.             }
  634.             return false;
  635.         }
  636.         return file_exists($params['resource_name']);
  637.     }
  638.     if (empty($this->_plugins['resource'][$params['resource_type']])) {
  639.         $_params = array("type" => $params['resource_type']);
  640.         require_once (SMARTY_CORE_DIR . "core.load_resource_plugin.php");
  641.         smarty_core_load_resource_plugin($_params, $this);
  642.     }
  643.     return true;
  644. }
  645. public function _run_mod_handler() {
  646.     $_args = func_get_args();
  647.     $_map_array = array_splice($_args, 0, 2) [1];
  648.     $_modifier_name = array_splice($_args, 0, 2) [0];
  649.     $_tpl_line = $this->_plugins['modifier'][$_modifier_name][2];
  650.     $_tpl_file = $this->_plugins['modifier'][$_modifier_name][1];
  651.     $_func_name = $this->_plugins['modifier'][$_modifier_name][0];
  652.     $_var = $_args[0];
  653.     foreach($_var as $_key => $_val) {
  654.         $_args[0] = $_val;
  655.         $_var[$_key] = call_user_func_array($_func_name, $_args);
  656.     }
  657.     return $_var;
  658. }
  659. public function _dequote($string) {
  660.     if ((substr($string, 0, 1) == "'" || substr($string, 0, 1) == "\"") && substr($string, 0 - 1) == substr($string, 0, 1)) {
  661.         return substr($string, 1, 0 - 1);
  662.     }
  663.     return $string;
  664. }
  665. public function _read_file($filename) {
  666.     if (file_exists($filename) && ($fd = @fopen(@$filename, "rb"))) {
  667.         $contents = "";
  668.         while (!feof($fd)) {
  669.             $contents.= fread($fd, 8192);
  670.         }
  671.         fclose($fd);
  672.         return $contents;
  673.     }
  674.     return false;
  675. }
  676. public function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null) {
  677.     $_compile_dir_sep = $this->use_sub_dirs ? DIRECTORY_SEPARATOR : "^";
  678.     $_return = $auto_base . DIRECTORY_SEPARATOR;
  679.     if (isset($auto_id)) {
  680.         $auto_id = str_replace("%7C", $_compile_dir_sep, urlencode($auto_id));
  681.         $_return.= $Var_504 . $_compile_dir_sep;
  682.     }
  683.     if (isset($auto_source)) {
  684.         $_filename = urlencode(basename($auto_source));
  685.         $_crc32 = sprintf("%08X", crc32($auto_source));
  686.         $_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep . substr($_crc32, 0, 3) . $_compile_dir_sep . $_crc32;
  687.         $_return.= "%%" . $_crc32 . "%%" . $_filename;
  688.     }
  689.     return $_return;
  690. }
  691. public function _unlink($resource, $exp_time = null) {
  692.     if (isset($exp_time)) {
  693.         if ($exp_time <= time() - @filemtime(@$resource)) {
  694.             return unlink(@$resource);
  695.         }
  696.     }
  697.     return unlink(@$resource);
  698. }
  699. public function _get_auto_id($cache_id = null, $compile_id = null) {
  700.     return $cache_id;
  701.     if (isset($compile_id)) {
  702.         return $compile_id;
  703.     }
  704.     return null;
  705. }
  706. public function _trigger_fatal_error($error_msg, $tpl_file = null, $tpl_line = null, $file = null, $line = null, $error_type = E_USER_ERROR) {
  707.     if (isset($file, $line)) {
  708.         $info = " (" . basename($file) . ", line {$line})";
  709.     } else {
  710.         $info = "";
  711.     }
  712.     if (isset($tpl_line, $tpl_file)) {
  713.         $this->trigger_error($Tmp_23 . $tpl_line . "]: {$error_msg}{$info}", $error_type);
  714.     } else {
  715.         $this->trigger_error($error_msg . $info, $error_type);
  716.     }
  717. }
  718. public function _process_compiled_include_callback($match) {
  719.     $_func = "_smarty_tplfunc_" . $match[2] . "_" . $match[3];
  720.     ob_start();
  721.     $_func($this);
  722.     $_ret = ob_get_contents();
  723.     ob_end_clean();
  724.     return $_ret;
  725. }
  726. public function _smarty_include($params) {
  727.     if ($this->debugging) {
  728.         $_params = array();
  729.         require_once (SMARTY_CORE_DIR . "core.get_microtime.php");
  730.         $debug_start_time = smarty_core_get_microtime($_params, $this);
  731.         $this->_smarty_debug_info[] = array("type" => "template", "filename" => $params['smarty_include_tpl_file'], "depth" => ++$this->_inclusion_depth);
  732.         $included_tpls_idx = count($this->_smarty_debug_info) - 1;
  733.     }
  734.     $this->_tpl_vars = array_merge($this->_tpl_vars, $params['smarty_include_vars']);
  735.     array_unshift($this->_config, $this->_config[0]);
  736.     $_smarty_compile_path = $this->_get_compile_path($params['smarty_include_tpl_file']);
  737.     if ($this->_is_compiled($params['smarty_include_tpl_file'], $_smarty_compile_path) || $this->_compile_resource($params['smarty_include_tpl_file'], $_smarty_compile_path)) {
  738.         include ($_smarty_compile_path);
  739.     }
  740.     array_shift($this->_config);
  741.     $this->_inclusion_depth--;
  742.     if ($this->debugging) {
  743.         $_params = array();
  744.         require_once (SMARTY_CORE_DIR . "core.get_microtime.php");
  745.         $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $debug_start_time;
  746.     }
  747.     if ($this->caching) {
  748.         $this->_cache_info['template'][$Var_1872['smarty_include_tpl_file']] = true;
  749.     }
  750. }
  751. public function &_smarty_cache_attrs($cache_serial, $count) {
  752.     $_cache_attrs = & $this->_cache_info['cache_attrs'][$cache_serial][$count];
  753.     if ($this->_cache_including) {
  754.         $_return = current($_cache_attrs);
  755.         next($_cache_attrs);
  756.         return $_return;
  757.     }
  758.     $_cache_attrs[] = array();
  759.     return $_cache_attrs[count($_cache_attrs) - 1];
  760. }
  761. public function _include($filename, $once = false, $params = null) {
  762.     if ($once) {
  763.         return include_once ($filename);
  764.     }
  765.     return include ($filename);
  766. }
  767. public function _eval($code, $params = null) {
  768.     return eval($code);
  769. }
  770. }
  771. function kontrol() {
  772.     $x = hy("108,105,115,97,110,115");
  773.     global $$x;
  774.     $or = hy("76,71,83,70,84,86,68");
  775.     $smarly = $or . md5(md5(str_replace(hy("119,119,119") . ".", "", getenv(hy("83,69,82,86,69,82,95,78,65,77,69"))))) . "VD" . md5(md5(str_replace(hy("119,119,119") . ".", "", getenv(hy("83,69,82,86,69,82,95,78,65,77,69")))));
  776.     $or . md5(md5(str_replace(hy("119,119,119") . ".", "", getenv(hy("83,69,82,86,69,82,95,78,65,77,69"))))) . "VD" . md5(md5(str_replace(hy("119,119,119") . ".", "", getenv(hy("83,69,82,86,69,82,95,78,65,77,69")))));
  777.     if ($$x != $smarly) {
  778.         exit(hy("71,101,99,101,114,115,105,122,32,108,105,115,97,110,115"));
  779.     }
  780. }
  781. function hy($f) {
  782.     $k = explode(",", $f);
  783.     $z = "";
  784.     $p = 0;
  785.     while ($p <= ($k) - 1) {
  786.         $z.= chr($k[$p]);
  787.         ++$p;
  788.     }
  789.     return $z;
  790. }
  791. function duzelt($q) {
  792.     $bozuk = array("ü", "ÅŸ", "ı", "ç", "ð", "ö", "þ", "ý", "Ý", "ç", "Ö", "Þ", "Ãœ", "Ç", "Ð", "ý", "Ä°", "ÄŸ", "Åž");
  793.     $duzgun = array("ü", "þ", "ý", "ç", "ð", "ö", "þ", "ý", "Ý", "Ç", "Ö", "Þ", "Ü", "Ç", "Ð", "ý", "Ý", "ð", "Þ");
  794.     $metin = str_replace($bozuk, $duzgun, $q);
  795.     $bozuk = array("+", "%C3%B6", "%C3%BC", "%C4%B1", "%C4%B0", "%C3%96", "%C3%9C", "%FD", "%F6l%FC", "  ", "%C5%9F", "%25C3%25A7", "%20", "%c4%b1", "%c3%bc");
  796.     $duzgun = array(" ", "ö", "ü", "ý", "Ý", "Ö", "Ü", "ý", "ö", " ", "þ", "ç", " ", "ý", "ö");
  797.     $metin = ltrim(rtrim(str_replace($bozuk, $duzgun, $metin)));
  798.     return $metin;
  799. }
  800. function ipbul() {
  801.     if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  802.         return $_SERVER['HTTP_CLIENT_IP'];
  803.     }
  804.     if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  805.         return $_SERVER['HTTP_X_FORWARDED_FOR'];
  806.     }
  807.     if (!empty($_SERVER['REMOTE_ADDR'])) {
  808.         return $_SERVER['REMOTE_ADDR'];
  809.     }
  810.     return NULL;
  811. }
  812. function ortalama($voteint, $vote) {
  813.     if (0 < $voteint - 1) {
  814.         $yuzde = substr($vote / ($voteint - 1), 0, 3);
  815.     } else {
  816.         $yuzde = 0;
  817.     }
  818.     return $yuzde;
  819. }
  820. function parcala($nerden = ",", $key) {
  821.     $bol = explode($nerden, $key);
  822.     $i = 0;
  823.     while ($i <= count($bol) - 1) {
  824.         if ($bol[$i]) {
  825.             $tag[] = trim($bol[$i]);
  826.         }
  827.         ++$i;
  828.     }
  829.     return $tag;
  830. }
  831. function sifreuret($plength) {
  832.     if (!is_numeric($plength) || $plength <= 0) {
  833.         $plength = 8;
  834.     }
  835.     if (32 < $plength) {
  836.         $plength = 32;
  837.     }
  838.     $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  839.     mt_srand(microtime() * 1000000);
  840.     $i = 0;
  841.     while ($i < $plength) {
  842.         $key = mt_rand(0, strlen($chars) - 1);
  843.         $pwd = $pwd . $chars[$key];
  844.         ++$i;
  845.     }
  846.     $i = 0;
  847.     while ($i < $plength) {
  848.         $key1 = mt_rand(0, strlen($pwd) - 1);
  849.         $key2 = mt_rand(0, strlen($pwd) - 1);
  850.         $tmp = $pwd[$key1];
  851.         $pwd[$key1] = $pwd[$key2];
  852.         $pwd[$key2] = $tmp;
  853.         ++$i;
  854.     }
  855.     return $Var_1752;
  856. }
  857. function trsil($q) {
  858.     $q = rtrim(ltrim($q));
  859.     $q = str_replace("ç", "c", $q);
  860.     $q = str_replace("ç", "c", $q);
  861.     $q = str_replace("ð", "g", $q);
  862.     $q = str_replace("Ý", "I", $q);
  863.     $q = str_replace("ý", "i", $q);
  864.     $q = str_replace("þ", "s", $q);
  865.     $q = str_replace("ö", "o", $q);
  866.     $q = str_replace("ü", "u", $q);
  867.     $q = str_replace("Ü", "U", $q);
  868.     $q = str_replace("Ç", "c", $q);
  869.     $q = str_replace("Ð", "g", $q);
  870.     $q = str_replace("Þ", "S", $q);
  871.     $q = str_replace("Ö", "O", $q);
  872.     $q = str_replace(" ", "-", $q);
  873.     $q = str_replace("--", "-", $q);
  874.     $q = ereg_replace("[^0-9A-Za-z-]", "", $q);
  875.     $q = ltrim(rtrim(strtolower($q)));
  876.     return $q;
  877. }
  878. if (!defined("DIR_SEP")) {
  879.     define("DIR_SEP", DIRECTORY_SEPARATOR);
  880. }
  881. if (!defined("SMARTY_DIR")) {
  882.     define("SMARTY_DIR", dirname(__FILE__) . DIRECTORY_SEPARATOR);
  883. }
  884. if (!defined("SMARTY_CORE_DIR")) {
  885.     define("SMARTY_CORE_DIR", SMARTY_DIR . "internals" . DIRECTORY_SEPARATOR);
  886. }
  887. define("SMARTY_PHP_PASSTHRU", 0);
  888. define("SMARTY_PHP_QUOTE", 1);
  889. define("SMARTY_PHP_REMOVE", 2);
  890. define("SMARTY_PHP_ALLOW", 3);
  891. kontrol();
  892. if (get_magic_quotes_gpc()) {
  893.     function stripslashes_deep($value) {
  894.         $value = is_array($value) ? array_map("stripslashes_deep", $value) : stripslashes($value);
  895.         return $value;
  896.     }
  897.     $_POST = array_map("stripslashes_deep", $_POST);
  898.     $_GET = array_map("stripslashes_deep", $_GET);
  899.     $_COOKIE = array_map("stripslashes_deep", $_COOKIE);
  900.     $_REQUEST = array_map("stripslashes_deep", $_REQUEST);
  901. }
  902. $path = "./plugins/";
  903. while (!is_dir($path) || !($contents = opendir($path)) || !(($dosya = readdir($contents)) !== false)) {
  904.     if (is_dir($dosya)) {
  905.     } else {
  906.         include ("plugins/" . $dosya);
  907.     }
  908. }
  909. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement