public function compileTemplate(Smarty_Internal_Template $template)
 {
     if (empty($template->properties['nocache_hash'])) {
         $template->properties['nocache_hash'] = $this->nocache_hash;
     } else {
         $this->nocache_hash = $template->properties['nocache_hash'];
     }
     $this->nocache = false;
     $this->tag_nocache = false;
     $this->template = $template;
     $this->template->has_nocache_code = false;
     $this->smarty->_current_file = $saved_filepath = $this->template->source->filepath;
     $template_header = '';
     if (!$this->suppressHeader) {
         $template_header .= "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
         $template_header .= "         compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
     }
     do {
         $this->abort_and_recompile = false;
         $_content = $template->source->content;
         if (isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) {
             $_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
         }
         if ($_content == '') {
             if ($this->suppressTemplatePropertyHeader) {
                 $code = '';
             } else {
                 $code = $template_header . $template->createTemplateCodeFrame();
             }
             return $code;
         }
         $_compiled_code = $this->doCompile($_content);
     } while ($this->abort_and_recompile);
     $this->template->source->filepath = $saved_filepath;
     unset($this->parser->root_buffer, $this->parser->current_buffer, $this->parser, $this->lex, $this->template);
     self::$_tag_objects = array();
     $merged_code = '';
     if (!$this->suppressMergedTemplates && !empty($this->merged_templates)) {
         foreach ($this->merged_templates as $code) {
             $merged_code .= $code;
         }
         if (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) {
             $merged_code = Smarty_Internal_Filter_Handler::runFilter('post', $merged_code, $template);
         }
     }
     if (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) {
         $_compiled_code = Smarty_Internal_Filter_Handler::runFilter('post', $_compiled_code, $template);
     }
     if ($this->suppressTemplatePropertyHeader) {
         $code = $_compiled_code . $merged_code;
     } else {
         $code = $template_header . $template->createTemplateCodeFrame($_compiled_code) . $merged_code;
     }
     unset($template->source->content);
     return $code;
 }
Пример #2
0
 public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
 {
     if ($template === null && $this instanceof $this->template_class) {
         $template = $this;
     }
     if ($cache_id !== null && is_object($cache_id)) {
         $parent = $cache_id;
         $cache_id = null;
     }
     if ($parent === null && ($this instanceof Smarty || is_string($template))) {
         $parent = $this;
     }
     $_template = $template instanceof $this->template_class ? $template : $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false);
     if ($this instanceof Smarty) {
         $_template->caching = $this->caching;
     }
     if ($merge_tpl_vars) {
         $save_tpl_vars = $_template->tpl_vars;
         $save_config_vars = $_template->config_vars;
         $ptr_array = array($_template);
         $ptr = $_template;
         while (isset($ptr->parent)) {
             $ptr_array[] = $ptr = $ptr->parent;
         }
         $ptr_array = array_reverse($ptr_array);
         $parent_ptr = reset($ptr_array);
         $tpl_vars = $parent_ptr->tpl_vars;
         $config_vars = $parent_ptr->config_vars;
         while ($parent_ptr = next($ptr_array)) {
             if (!empty($parent_ptr->tpl_vars)) {
                 $tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars);
             }
             if (!empty($parent_ptr->config_vars)) {
                 $config_vars = array_merge($config_vars, $parent_ptr->config_vars);
             }
         }
         if (!empty(Smarty::$global_tpl_vars)) {
             $tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars);
         }
         $_template->tpl_vars = $tpl_vars;
         $_template->config_vars = $config_vars;
     }
     if (!isset($_template->tpl_vars['smarty'])) {
         $_template->tpl_vars['smarty'] = new Smarty_Variable();
     }
     if (isset($this->smarty->error_reporting)) {
         $_smarty_old_error_level = error_reporting($this->smarty->error_reporting);
     }
     if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
         if (isset($_SERVER['QUERY_STRING'])) {
             $_query_string = $_SERVER['QUERY_STRING'];
         } else {
             $_query_string = '';
         }
         if (false !== strpos($_query_string, $this->smarty->smarty_debug_id)) {
             if (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=on')) {
                 setcookie('SMARTY_DEBUG', true);
                 $this->smarty->debugging = true;
             } elseif (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=off')) {
                 setcookie('SMARTY_DEBUG', false);
                 $this->smarty->debugging = false;
             } else {
                 $this->smarty->debugging = true;
             }
         } else {
             if (isset($_COOKIE['SMARTY_DEBUG'])) {
                 $this->smarty->debugging = true;
             }
         }
     }
     $_template->smarty->merged_templates_func = array();
     if ($_template->source->recompiled) {
         $_template->caching = false;
     }
     if (!$_template->source->exists) {
         if ($_template->parent instanceof Smarty_Internal_Template) {
             $parent_resource = " in '{$_template->parent->template_resource}'";
         } else {
             $parent_resource = '';
         }
         throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}");
     }
     if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || !$_template->cached->valid) {
         if (!$_template->source->uncompiled) {
             $_smarty_tpl = $_template;
             if ($_template->source->recompiled) {
                 $code = $_template->compiler->compileTemplate($_template);
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 try {
                     ob_start();
                     eval('?>' . $code);
                     unset($code);
                 } catch (Exception $e) {
                     ob_get_clean();
                     throw $e;
                 }
             } else {
                 if (!$_template->compiled->exists || $_template->smarty->force_compile && !$_template->compiled->isCompiled) {
                     $_template->compileTemplateSource();
                     $code = file_get_contents($_template->compiled->filepath);
                     eval('?>' . $code);
                     unset($code);
                     $_template->compiled->loaded = true;
                     $_template->compiled->isCompiled = true;
                 }
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 if (!$_template->compiled->loaded) {
                     include $_template->compiled->filepath;
                     if ($_template->mustCompile) {
                         $_template->compileTemplateSource();
                         $code = file_get_contents($_template->compiled->filepath);
                         eval('?>' . $code);
                         unset($code);
                         $_template->compiled->isCompiled = true;
                     }
                     $_template->compiled->loaded = true;
                 } else {
                     $_template->decodeProperties($_template->compiled->_properties, false);
                 }
                 try {
                     ob_start();
                     if (empty($_template->properties['unifunc']) || !is_callable($_template->properties['unifunc'])) {
                         throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'");
                     }
                     array_unshift($_template->_capture_stack, array());
                     $_template->properties['unifunc']($_template);
                     if (isset($_template->_capture_stack[0][0])) {
                         $_template->capture_error();
                     }
                     array_shift($_template->_capture_stack);
                 } catch (Exception $e) {
                     ob_get_clean();
                     throw $e;
                 }
             }
         } else {
             if ($_template->source->uncompiled) {
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 try {
                     ob_start();
                     $_template->source->renderUncompiled($_template);
                 } catch (Exception $e) {
                     ob_get_clean();
                     throw $e;
                 }
             } else {
                 throw new SmartyException("Resource '{$_template->source}->type' must have 'renderUncompiled' method");
             }
         }
         $_output = ob_get_clean();
         if (!$_template->source->recompiled && empty($_template->properties['file_dependency'][$_template->source->uid])) {
             $_template->properties['file_dependency'][$_template->source->uid] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type);
         }
         if ($_template->parent instanceof Smarty_Internal_Template) {
             $_template->parent->properties['file_dependency'] = array_merge($_template->parent->properties['file_dependency'], $_template->properties['file_dependency']);
             foreach ($_template->required_plugins as $code => $tmp1) {
                 foreach ($tmp1 as $name => $tmp) {
                     foreach ($tmp as $type => $data) {
                         $_template->parent->required_plugins[$code][$name][$type] = $data;
                     }
                 }
             }
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_render($_template);
         }
         if (!$_template->source->recompiled && ($_template->caching == Smarty::CACHING_LIFETIME_SAVED || $_template->caching == Smarty::CACHING_LIFETIME_CURRENT)) {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_cache($_template);
             }
             $_template->properties['has_nocache_code'] = false;
             $cache_split = preg_split("!/\\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!s", $_output);
             preg_match_all("!/\\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!s", $_output, $cache_parts);
             $output = '';
             foreach ($cache_split as $curr_idx => $curr_split) {
                 $output .= preg_replace('/(<%|%>|<\\?php|<\\?|\\?>)/', "<?php echo '\$1'; ?>\n", $curr_split);
                 if (isset($cache_parts[0][$curr_idx])) {
                     $_template->properties['has_nocache_code'] = true;
                     $output .= preg_replace("!/\\*/?%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!", '', $cache_parts[0][$curr_idx]);
                 }
             }
             if (!$no_output_filter && !$_template->has_nocache_code && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
                 $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template);
             }
             $_smarty_tpl = $_template;
             try {
                 ob_start();
                 eval('?>' . $output);
                 $_output = ob_get_clean();
             } catch (Exception $e) {
                 ob_get_clean();
                 throw $e;
             }
             $_template->writeCachedContent($output);
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_cache($_template);
             }
         } else {
             if (!empty($_template->properties['nocache_hash']) && !empty($_template->parent->properties['nocache_hash'])) {
                 $_output = str_replace("{$_template->properties['nocache_hash']}", $_template->parent->properties['nocache_hash'], $_output);
                 $_template->parent->has_nocache_code = $_template->parent->has_nocache_code || $_template->has_nocache_code;
             }
         }
     } else {
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_cache($_template);
         }
         try {
             ob_start();
             array_unshift($_template->_capture_stack, array());
             $_template->properties['unifunc']($_template);
             if (isset($_template->_capture_stack[0][0])) {
                 $_template->capture_error();
             }
             array_shift($_template->_capture_stack);
             $_output = ob_get_clean();
         } catch (Exception $e) {
             ob_get_clean();
             throw $e;
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_cache($_template);
         }
     }
     if ((!$this->caching || $_template->has_nocache_code || $_template->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
         $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_output, $_template);
     }
     if (isset($this->error_reporting)) {
         error_reporting($_smarty_old_error_level);
     }
     if ($display) {
         if ($this->caching && $this->cache_modified_check) {
             $_isCached = $_template->isCached() && !$_template->has_nocache_code;
             $_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
             if ($_isCached && $_template->cached->timestamp <= strtotime($_last_modified_date)) {
                 switch (PHP_SAPI) {
                     case 'cgi':
                     case 'cgi-fcgi':
                     case 'fpm-fcgi':
                         header('Status: 304 Not Modified');
                         break;
                     case 'cli':
                         if (!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])) {
                             $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified';
                         }
                         break;
                     default:
                         header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
                         break;
                 }
             } else {
                 switch (PHP_SAPI) {
                     case 'cli':
                         if (!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])) {
                             $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT';
                         }
                         break;
                     default:
                         header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT');
                         break;
                 }
                 echo $_output;
             }
         } else {
             echo $_output;
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::display_debug($_template);
         }
         if ($merge_tpl_vars) {
             $_template->tpl_vars = $save_tpl_vars;
             $_template->config_vars = $save_config_vars;
         }
         return;
     } else {
         if ($merge_tpl_vars) {
             $_template->tpl_vars = $save_tpl_vars;
             $_template->config_vars = $save_config_vars;
         }
         return $_output;
     }
 }
 /**
  * fetches a rendered Smarty template
  *
  * @param  string $template         the resource handle of the template file or template object
  * @param  mixed  $cache_id         cache id to be used with this template
  * @param  mixed  $compile_id       compile id to be used with this template
  * @param  object $parent           next higher level of Smarty variables
  * @param  bool   $display          true: display, false: fetch
  * @param  bool   $merge_tpl_vars   if true parent template variables merged in to local scope
  * @param  bool   $no_output_filter if true do not run output filter
  *
  * @throws Exception
  * @throws SmartyException
  * @return string rendered template output
  */
 public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
 {
     if ($template === null && $this instanceof $this->template_class) {
         $template = $this;
     }
     if ($cache_id !== null && is_object($cache_id)) {
         $parent = $cache_id;
         $cache_id = null;
     }
     if ($parent === null && ($this instanceof Smarty || is_string($template))) {
         $parent = $this;
     }
     // create template object if necessary
     $_template = $template instanceof $this->template_class ? $template : $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false);
     // if called by Smarty object make sure we use current caching status
     if ($this instanceof Smarty) {
         $_template->caching = $this->caching;
     }
     // merge all variable scopes into template
     if ($merge_tpl_vars) {
         // save local variables
         $save_tpl_vars = $_template->tpl_vars;
         $save_config_vars = $_template->config_vars;
         $ptr_array = array($_template);
         $ptr = $_template;
         while (isset($ptr->parent)) {
             $ptr_array[] = $ptr = $ptr->parent;
         }
         $ptr_array = array_reverse($ptr_array);
         $parent_ptr = reset($ptr_array);
         $tpl_vars = $parent_ptr->tpl_vars;
         $config_vars = $parent_ptr->config_vars;
         while ($parent_ptr = next($ptr_array)) {
             if (!empty($parent_ptr->tpl_vars)) {
                 $tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars);
             }
             if (!empty($parent_ptr->config_vars)) {
                 $config_vars = array_merge($config_vars, $parent_ptr->config_vars);
             }
         }
         if (!empty(Smarty::$global_tpl_vars)) {
             $tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars);
         }
         $_template->tpl_vars = $tpl_vars;
         $_template->config_vars = $config_vars;
     }
     // dummy local smarty variable
     if (!isset($_template->tpl_vars['smarty'])) {
         $_template->tpl_vars['smarty'] = new Smarty_Variable();
     }
     if (isset($this->smarty->error_reporting)) {
         $_smarty_old_error_level = error_reporting($this->smarty->error_reporting);
     }
     // check URL debugging control
     if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
         if (isset($_SERVER['QUERY_STRING'])) {
             $_query_string = $_SERVER['QUERY_STRING'];
         } else {
             $_query_string = '';
         }
         if (false !== strpos($_query_string, $this->smarty->smarty_debug_id)) {
             if (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=on')) {
                 // enable debugging for this browser session
                 setcookie('SMARTY_DEBUG', true);
                 $this->smarty->debugging = true;
             } elseif (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=off')) {
                 // disable debugging for this browser session
                 setcookie('SMARTY_DEBUG', false);
                 $this->smarty->debugging = false;
             } else {
                 // enable debugging for this page
                 $this->smarty->debugging = true;
             }
         } else {
             if (isset($_COOKIE['SMARTY_DEBUG'])) {
                 $this->smarty->debugging = true;
             }
         }
     }
     // must reset merge template date
     $_template->smarty->merged_templates_func = array();
     // get rendered template
     // disable caching for evaluated code
     if ($_template->source->recompiled) {
         $_template->caching = false;
     }
     // checks if template exists
     if (!$_template->source->exists) {
         if ($_template->parent instanceof Smarty_Internal_Template) {
             $parent_resource = " in '{$_template->parent->template_resource}'";
         } else {
             $parent_resource = '';
         }
         throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}");
     }
     // read from cache or render
     if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || !$_template->cached->valid) {
         // render template (not loaded and not in cache)
         if (!$_template->source->uncompiled) {
             /** @var Smarty_Internal_Template $_smarty_tpl
              * used in evaluated code
              */
             $_smarty_tpl = $_template;
             if ($_template->source->recompiled) {
                 $code = $_template->compiler->compileTemplate($_template);
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 try {
                     ob_start();
                     /// dark edit
                     \Dark\SmartyView\SmartyEngine::integrateViewComposers($_template);
                     /// end edit
                     eval("?>" . $code);
                     unset($code);
                 } catch (Exception $e) {
                     ob_get_clean();
                     throw $e;
                 }
             } else {
                 if (!$_template->compiled->exists || $_template->smarty->force_compile && !$_template->compiled->isCompiled) {
                     $_template->compileTemplateSource();
                     $code = file_get_contents($_template->compiled->filepath);
                     eval("?>" . $code);
                     unset($code);
                     $_template->compiled->loaded = true;
                     $_template->compiled->isCompiled = true;
                 }
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 if (!$_template->compiled->loaded) {
                     include $_template->compiled->filepath;
                     if ($_template->mustCompile) {
                         // recompile and load again
                         $_template->compileTemplateSource();
                         $code = file_get_contents($_template->compiled->filepath);
                         eval("?>" . $code);
                         unset($code);
                         $_template->compiled->isCompiled = true;
                     }
                     $_template->compiled->loaded = true;
                 } else {
                     $_template->decodeProperties($_template->compiled->_properties, false);
                 }
                 try {
                     ob_start();
                     if (empty($_template->properties['unifunc']) || !is_callable($_template->properties['unifunc'])) {
                         throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'");
                     }
                     array_unshift($_template->_capture_stack, array());
                     /// dark edit
                     \Dark\SmartyView\SmartyEngine::integrateViewComposers($_template);
                     /// end edit
                     //
                     // render compiled template
                     //
                     $_template->properties['unifunc']($_template);
                     // any unclosed {capture} tags ?
                     if (isset($_template->_capture_stack[0][0])) {
                         $_template->capture_error();
                     }
                     array_shift($_template->_capture_stack);
                 } catch (Exception $e) {
                     ob_get_clean();
                     throw $e;
                 }
             }
         } else {
             if ($_template->source->uncompiled) {
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 try {
                     ob_start();
                     /// dark edit
                     \Dark\SmartyView\SmartyEngine::integrateViewComposers($_template);
                     /// end edit
                     $_template->source->renderUncompiled($_template);
                 } catch (Exception $e) {
                     ob_get_clean();
                     throw $e;
                 }
             } else {
                 throw new SmartyException("Resource '{$_template->source}->type' must have 'renderUncompiled' method");
             }
         }
         $_output = ob_get_clean();
         if ($_template->template_resource == './_footer.html' && empty($_template->tpl_vars['navs']->value)) {
             $_output = preg_replace('/<a href="' . str_replace("/", "\\/", $_template->tpl_vars['site_url']->value) . '"( target="_blank")?( )?>首页<\\/a>( )?\\|([\\s]+)?(<br \\/>)?(<br>)?/is', "", $_output);
             $_output = preg_replace('/<a href="' . str_replace("/", "\\/", $_template->tpl_vars['site_url']->value) . '"( target="_blank")?( )?>Home<\\/a>( )?\\|([\\s]+)?(<br \\/>)?(<br>)?/is', "", $_output);
         }
         //===调用交互服务器接口文件中js,加载访问统计===
         /**
          * 获取域名->获取ip
          * 根据IP和域名获取数据库信息(交互服务器上)
          * ->判断ip是否登录过
          * 
          */
         //			if ($_template->template_resource == './_footer.html') {
         //				$postFun = new CommonController;
         //				$domain = $_SERVER['HTTP_HOST'] ? 'http://' . $_SERVER['HTTP_HOST'] : '';
         //				$ip_address = ($_SERVER['REMOTE_ADDR']);
         //				$today = date('Y-m-d');
         ////				$param['domain'] = $domain;
         ////				$param['ip_address'] = $ip_address;
         //				$flag = true;
         ////				$stats_log_info = DB::table('stats_log')->where('ip_address', $ip_address)->where('pc_domain', $domain)->orWhere('mobile_domain', $domain)->first();
         //				$data = array(
         //					'pc_domain' => $domain,
         //					'mobile_domain' => $domain,
         //				);
         //				$stats_log_info = $postFun->postsend("http://swap.5067.org/stats.php?key=get_stats_log",$data); //获取交互服务器上访问日志
         //				$stats_log_info=  json_decode($stats_log_info);
         //				if (empty($stats_log_info) || $stats_log_info == 'null') {//新增
         ////					echo '1---<br>';
         //					$data = array(
         //						'pc_domain' => $customer_info->pc_domain ? $customer_info->pc_domain : $domain,
         //						'mobile_domain' => $customer_info->mobile_domain ? $customer_info->mobile_domain : $domain,
         //					);
         ////					$customer_info = DB::table('customer_info')->where('pc_domain', $domain)->orWhere('mobile_domain', $domain)->select('cus_id', 'pc_domain', 'mobile_domain')->first();
         //					$customer_info = $postFun->postsend("http://swap.5067.org/stats.php?key=get_customer_info", $data); //获取客户信息
         //					$customer_info = json_decode($customer_info);
         //					$data = array(
         //						'pc_domain' => $customer_info->pc_domain ? $customer_info->pc_domain : $domain,
         //						'mobile_domain' => $customer_info->mobile_domain ? $customer_info->mobile_domain : $domain,
         //					);
         ////					$stats_log_id = DB::table('stats_log')->insertGetId($data);
         //					$stats_log_id = $postFun->postsend("http://swap.5067.org/stats.php?key=insert_stats_log", $data); //添加用户登录日志
         //				} else {//判断单日是否已经登录过
         ////					echo '2---<br>';
         //					if ($stats_log_info->lasttime != $today) {//不是当日更新为今天日期、并且计数+1
         //						$stats_log_id = $stats_log_info->id;
         //						$data = array(
         //							'id' => $stats_log_id,
         //						);
         ////						DB::table('stats_log')->where('id', $stats_log_info->id)->update($data);
         //						$res = $postFun->postsend("http://swap.5067.org/stats.php?key=update_stats_log", $data); //更新用户登录日志
         //					} else {//当日已登录
         //						$flag = FALSE; //不做操作
         //					}
         //				}
         //				if (!$flag) {
         ////					$stats_info = DB::table('stats')->where('cus_id', $customer_info->cus_id)->first();
         //					$data = array(
         //						'cus_id' => $customer_info->cus_id,
         //					);
         //					$stats_info = $postFun->postsend("http://swap.5067.org/stats.php?key=get_stats", $data); //获取客户访问统计信息
         //					$stats_info = json_decode($stats_info);
         //					if (empty($stats_info) || $stats_info == 'null') {//统计为空,新增数据
         ////						echo '2---1---<br>';
         //						$data3 = array(
         //							'cus_id' => $customer_info->cus_id,
         //							'pc_domain' => $customer_info->pc_domain ? $customer_info->pc_domain : $domain,
         //							'mobile_domain' => $customer_info->mobile_domain ? $customer_info->mobile_domain : $domain,
         //						);
         //						$stats_id = $postFun->postsend("http://swap.5067.org/stats.php?key=insert_stats", $data3); //添加客户访问统计信息
         //						$data2 = array(
         //							'id' => $stats_id,
         //							'page_count_num' => 1,
         //							'page_today_num' => 1,
         //						);
         //					} else {//统计不为空,累加数据
         ////						echo '2---2---<br>';
         //						$stats_id = $stats_info->id;
         //						if ($stats_info->lasttime != $today) {//查看lasttime是否为今天,不是今天更新lasttime,并重新统计当日访问数
         //							$data2 = array(
         //								'id' => $stats_id,
         //								'page_count_num' => $stats_info->page_count_num + 1,
         //								'page_today_num' => 1,
         //								'lasttime' => 1
         //							);
         //						} else {//是当日,累加访问数
         //							$data2 = array(
         //								'id' => $stats_id,
         //								'page_count_num' => $stats_info->page_count_num + 1,
         //								'page_today_num' => $stats_info->page_today_num + 1
         //							);
         //						}
         //					}
         //					$resa = $postFun->postsend("http://swap.5067.org/stats.php?key=update_stats", $data2); //更新客户访问统计信息
         //				}
         //			}
         if (!$_template->source->recompiled && empty($_template->properties['file_dependency'][$_template->source->uid])) {
             $_template->properties['file_dependency'][$_template->source->uid] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type);
         }
         if ($_template->parent instanceof Smarty_Internal_Template) {
             $_template->parent->properties['file_dependency'] = array_merge($_template->parent->properties['file_dependency'], $_template->properties['file_dependency']);
             foreach ($_template->required_plugins as $code => $tmp1) {
                 foreach ($tmp1 as $name => $tmp) {
                     foreach ($tmp as $type => $data) {
                         $_template->parent->required_plugins[$code][$name][$type] = $data;
                     }
                 }
             }
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_render($_template);
         }
         // write to cache when nessecary
         if (!$_template->source->recompiled && ($_template->caching == Smarty::CACHING_LIFETIME_SAVED || $_template->caching == Smarty::CACHING_LIFETIME_CURRENT)) {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_cache($_template);
             }
             $_template->properties['has_nocache_code'] = false;
             // get text between non-cached items
             $cache_split = preg_split("!/\\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!s", $_output);
             // get non-cached items
             preg_match_all("!/\\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!s", $_output, $cache_parts);
             $output = '';
             // loop over items, stitch back together
             foreach ($cache_split as $curr_idx => $curr_split) {
                 // escape PHP tags in template content
                 $output .= preg_replace('/(<%|%>|<\\?php|<\\?|\\?>)/', "<?php echo '\$1'; ?>\n", $curr_split);
                 if (isset($cache_parts[0][$curr_idx])) {
                     $_template->properties['has_nocache_code'] = true;
                     // remove nocache tags from cache output
                     $output .= preg_replace("!/\\*/?%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!", '', $cache_parts[0][$curr_idx]);
                 }
             }
             if (!$no_output_filter && !$_template->has_nocache_code && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
                 $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template);
             }
             // rendering (must be done before writing cache file because of {function} nocache handling)
             /** @var Smarty_Internal_Template $_smarty_tpl
              * used in evaluated code
              */
             $_smarty_tpl = $_template;
             try {
                 ob_start();
                 /// dark edit
                 \Dark\SmartyView\SmartyEngine::integrateViewComposers($_template);
                 /// end edit
                 eval("?>" . $output);
                 $_output = ob_get_clean();
             } catch (Exception $e) {
                 ob_get_clean();
                 throw $e;
             }
             // write cache file content
             $_template->writeCachedContent($output);
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_cache($_template);
             }
         } else {
             // var_dump('renderTemplate', $_template->has_nocache_code, $_template->template_resource, $_template->properties['nocache_hash'], $_template->parent->properties['nocache_hash'], $_output);
             if (!empty($_template->properties['nocache_hash']) && !empty($_template->parent->properties['nocache_hash'])) {
                 // replace nocache_hash
                 $_output = str_replace("{$_template->properties['nocache_hash']}", $_template->parent->properties['nocache_hash'], $_output);
                 $_template->parent->has_nocache_code = $_template->parent->has_nocache_code || $_template->has_nocache_code;
             }
         }
     } else {
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_cache($_template);
         }
         try {
             ob_start();
             /// dark edit
             \Dark\SmartyView\SmartyEngine::integrateViewComposers($_template);
             /// end edit
             array_unshift($_template->_capture_stack, array());
             //
             // render cached template
             //
             $_template->properties['unifunc']($_template);
             // any unclosed {capture} tags ?
             if (isset($_template->_capture_stack[0][0])) {
                 $_template->capture_error();
             }
             array_shift($_template->_capture_stack);
             $_output = ob_get_clean();
         } catch (Exception $e) {
             ob_get_clean();
             throw $e;
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_cache($_template);
         }
     }
     if ((!$this->caching || $_template->has_nocache_code || $_template->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
         $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_output, $_template);
     }
     if (isset($this->error_reporting)) {
         error_reporting($_smarty_old_error_level);
     }
     // display or fetch
     if ($display) {
         if ($this->caching && $this->cache_modified_check) {
             $_isCached = $_template->isCached() && !$_template->has_nocache_code;
             $_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
             if ($_isCached && $_template->cached->timestamp <= strtotime($_last_modified_date)) {
                 switch (PHP_SAPI) {
                     case 'cgi':
                         // php-cgi < 5.3
                     // php-cgi < 5.3
                     case 'cgi-fcgi':
                         // php-cgi >= 5.3
                     // php-cgi >= 5.3
                     case 'fpm-fcgi':
                         // php-fpm >= 5.3.3
                         header('Status: 304 Not Modified');
                         break;
                     case 'cli':
                         if (!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])) {
                             $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified';
                         }
                         break;
                     default:
                         header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
                         break;
                 }
             } else {
                 switch (PHP_SAPI) {
                     case 'cli':
                         if (!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])) {
                             $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT';
                         }
                         break;
                     default:
                         header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT');
                         break;
                 }
                 echo $_output;
             }
         } else {
             echo $_output;
         }
         // debug output
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::display_debug($_template);
         }
         if ($merge_tpl_vars) {
             // restore local variables
             $_template->tpl_vars = $save_tpl_vars;
             $_template->config_vars = $save_config_vars;
         }
         return;
     } else {
         if ($merge_tpl_vars) {
             // restore local variables
             $_template->tpl_vars = $save_tpl_vars;
             $_template->config_vars = $save_config_vars;
         }
         // return fetched content
         return $_output;
     }
 }
if (!defined('SMARTY_DIR')) {
    exit('no direct access allowed');
}
$_smarty_tpl->decodeProperties(array('file_dependency' => array('2500a64b55407e6ad4a402f576366b3f3c5c80d2' => array(0 => '/Users/zhangwenhan/web/www/backend/missy-blue/app/admin/templates/left.html', 1 => 1402727411, 2 => 'file')), 'nocache_hash' => '611926147539bec0604c207-13318892', 'function' => array(), 'has_nocache_code' => false));
/*/%%SmartyHeaderCode%%*/
if (!is_callable('smarty_function_createUrl')) {
    include '/Users/zhangwenhan/web/www/backend/missy-blue/libs/view/myplugins/function.createUrl.php';
}
?>
<!-- 树状菜单 -->
<!--
<h1 class="item1">XX管理</h1>
<div class="block">
    <ul>
        <li><a href="<?php 
echo Smarty_Internal_Filter_Handler::runFilter('variable', @URL_ROOT, $_smarty_tpl, true);
?>
index.php?c=xx&a=xx">xx管理</a></li>
    </ul>
</div>
-->
<div id="menutree" class="ui-menutree">
<!--
    <h1 class="menu-itemHeader menu-extension">测试管理</h1>
    <div class="menu-itemCont">
        <ul>
            <li><a href="<?php 
echo smarty_function_createUrl(array('controller' => 'test', 'action' => 'view'), $_smarty_tpl);
?>
">测试列表</a></li>
        </ul>
 /**
  * Method to compile a Smarty template
  *
  * @param  Smarty_Internal_Template $template template object to compile
  * @return bool true if compiling succeeded, false if it failed
  */
 public function compileTemplate(Smarty_Internal_Template $template)
 {
     if (empty($template->properties['nocache_hash'])) {
         $template->properties['nocache_hash'] = $this->nocache_hash;
     } else {
         $this->nocache_hash = $template->properties['nocache_hash'];
     }
     // flag for nochache sections
     $this->nocache = false;
     $this->tag_nocache = false;
     // save template object in compiler class
     $this->template = $template;
     // reset has noche code flag
     $this->template->has_nocache_code = false;
     $this->smarty->_current_file = $saved_filepath = $this->template->source->filepath;
     // template header code
     $template_header = '';
     if (!$this->suppressHeader) {
         $template_header .= "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
         $template_header .= "         compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
     }
     do {
         // flag for aborting current and start recompile
         $this->abort_and_recompile = false;
         // get template source
         $_content = $template->source->content;
         // run prefilter if required
         if (isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) {
             $_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
         }
         // on empty template just return header
         if ($_content == '') {
             if ($this->suppressTemplatePropertyHeader) {
                 $code = '';
             } else {
                 $code = $template_header . $template->createTemplateCodeFrame();
             }
             return $code;
         }
         // call compiler
         $_compiled_code = $this->doCompile($_content);
     } while ($this->abort_and_recompile);
     $this->template->source->filepath = $saved_filepath;
     // free memory
     unset($this->parser->root_buffer, $this->parser->current_buffer, $this->parser, $this->lex, $this->template);
     self::$_tag_objects = array();
     // return compiled code to template object
     $merged_code = '';
     if (!$this->suppressMergedTemplates && !empty($this->merged_templates)) {
         foreach ($this->merged_templates as $code) {
             $merged_code .= $code;
         }
         // run postfilter if required on merged code
         if (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) {
             $merged_code = Smarty_Internal_Filter_Handler::runFilter('post', $merged_code, $template);
         }
     }
     // run postfilter if required on compiled template code
     if (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) {
         $_compiled_code = Smarty_Internal_Filter_Handler::runFilter('post', $_compiled_code, $template);
     }
     if ($this->suppressTemplatePropertyHeader) {
         $code = $_compiled_code . $merged_code;
     } else {
         $code = $template_header . $template->createTemplateCodeFrame($_compiled_code) . $merged_code;
     }
     return $code;
 }
 /**
  * Find matches in all parent template source
  *
  * @param \Smarty_Internal_TemplateCompilerBase $compiler
  */
 public function matchParentTemplateSource(Smarty_Internal_TemplateCompilerBase $compiler)
 {
     // search parent compiler template source
     $nextCompiler = $compiler;
     while ($nextCompiler !== $nextCompiler->parent_compiler) {
         $nextCompiler = $nextCompiler->parent_compiler;
         if ($compiler !== $nextCompiler) {
             // get template source
             $_content = $nextCompiler->template->source->getContent();
             if ($_content != '') {
                 // run pre filter if required
                 if (isset($nextCompiler->smarty->autoload_filters['pre']) || isset($nextCompiler->smarty->registered_filters['pre'])) {
                     $_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $nextCompiler->template);
                 }
                 $this->matchProperty($_content);
             }
         }
     }
 }
 /**
  * render template
  *
  * @param  bool $merge_tpl_vars   if true parent template variables merged in to local scope
  * @param  bool $no_output_filter if true do not run output filter
  * @param  bool $display          true: display, false: fetch null: subtemplate
  *
  * @throws Exception
  * @throws SmartyException
  * @return string rendered template output
  */
 public function render($merge_tpl_vars = false, $no_output_filter = true, $display = null)
 {
     $parentIsTpl = isset($this->parent) && $this->parent->_objType == 2;
     if ($this->smarty->debugging) {
         $this->smarty->_debug->start_template($this, $display);
     }
     // checks if template exists
     if (!$this->source->exists) {
         if ($parentIsTpl) {
             $parent_resource = " in '{$this->parent->template_resource}'";
         } else {
             $parent_resource = '';
         }
         throw new SmartyException("Unable to load template {$this->source->type} '{$this->source->name}'{$parent_resource}");
     }
     $save_tpl_vars = null;
     $save_config_vars = null;
     // merge all variable scopes into template
     if ($merge_tpl_vars) {
         // save local variables
         $save_tpl_vars = $this->tpl_vars;
         $save_config_vars = $this->config_vars;
         $ptr_array = array($this);
         $ptr = $this;
         while (isset($ptr->parent)) {
             $ptr_array[] = $ptr = $ptr->parent;
         }
         $ptr_array = array_reverse($ptr_array);
         $parent_ptr = reset($ptr_array);
         $tpl_vars = $parent_ptr->tpl_vars;
         $config_vars = $parent_ptr->config_vars;
         while ($parent_ptr = next($ptr_array)) {
             if (!empty($parent_ptr->tpl_vars)) {
                 $tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars);
             }
             if (!empty($parent_ptr->config_vars)) {
                 $config_vars = array_merge($config_vars, $parent_ptr->config_vars);
             }
         }
         if (!empty(Smarty::$global_tpl_vars)) {
             $tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars);
         }
         $this->tpl_vars = $tpl_vars;
         $this->config_vars = $config_vars;
     }
     // check URL debugging control
     if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
         $this->smarty->_debug->debugUrl($this);
     }
     // disable caching for evaluated code
     if ($this->source->handler->recompiled) {
         $this->caching = false;
     }
     // read from cache or render
     $isCacheTpl = $this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED;
     if ($isCacheTpl) {
         if (!isset($this->cached)) {
             $this->loadCached();
         }
         $this->cached->render($this, $no_output_filter);
     } elseif ($this->source->handler->uncompiled) {
         $this->source->render($this);
     } else {
         if (!isset($this->compiled)) {
             $this->loadCompiled();
         }
         $this->compiled->render($this);
     }
     $content = null;
     if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
         $content = Smarty_Internal_Filter_Handler::runFilter('output', ob_get_clean(), $this);
     }
     // display or fetch
     if ($display) {
         if ($this->caching && $this->smarty->cache_modified_check) {
             $this->cached->cacheModifiedCheck($this, isset($content) ? $content : ob_get_clean());
         } else {
             echo isset($content) ? $content : ob_get_clean();
         }
         if ($this->smarty->debugging) {
             $this->smarty->_debug->end_template($this);
         }
         // debug output
         if ($this->smarty->debugging) {
             $this->smarty->_debug->display_debug($this, true);
         }
         if ($merge_tpl_vars) {
             // restore local variables
             $this->tpl_vars = $save_tpl_vars;
             $this->config_vars = $save_config_vars;
         }
         return '';
     } else {
         if ($merge_tpl_vars) {
             // restore local variables
             $this->tpl_vars = $save_tpl_vars;
             $this->config_vars = $save_config_vars;
         }
         if ($this->smarty->debugging) {
             $this->smarty->_debug->end_template($this);
         }
         if ($this->smarty->debugging == 2 and $display === false) {
             if ($this->smarty->debugging) {
                 $this->smarty->_debug->display_debug($this, true);
             }
         }
         if ($parentIsTpl) {
             if (!empty($this->tpl_function)) {
                 $this->parent->tpl_function = array_merge($this->parent->tpl_function, $this->tpl_function);
             }
             foreach ($this->compiled->required_plugins as $code => $tmp1) {
                 foreach ($tmp1 as $name => $tmp) {
                     foreach ($tmp as $type => $data) {
                         $this->parent->compiled->required_plugins[$code][$name][$type] = $data;
                     }
                 }
             }
         }
         // return cache content
         return $content === null ? null : $content;
     }
 }
 /**
  * Methode to compile a Smarty template
  * 
  * @param  $template template object to compile
  * @return bool true if compiling succeeded, false if it failed
  */
 public function compileTemplate($template)
 {
     if (empty($template->properties['nocache_hash'])) {
         $template->properties['nocache_hash'] = $this->nocache_hash;
     } else {
         $this->nocache_hash = $template->properties['nocache_hash'];
     }
     // flag for nochache sections
     $this->nocache = false;
     $this->tag_nocache = false;
     // save template object in compiler class
     $this->template = $template;
     $this->smarty->_current_file = $this->template->getTemplateFilepath();
     // template header code
     $template_header = '';
     if (!$template->suppressHeader) {
         $template_header .= "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
         $template_header .= "         compiled from \"" . $this->template->getTemplateFilepath() . "\" */ ?>\n";
     }
     do {
         // flag for aborting current and start recompile
         $this->abort_and_recompile = false;
         // get template source
         $_content = $template->getTemplateSource();
         // run prefilter if required
         if (isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) {
             $template->template_source = $_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
         }
         // on empty template just return header
         if ($_content == '') {
             if ($template->suppressFileDependency) {
                 $template->compiled_template = '';
             } else {
                 $template->compiled_template = $template_header . $template->createPropertyHeader();
             }
             return true;
         }
         // call compiler
         $_compiled_code = $this->doCompile($_content);
     } while ($this->abort_and_recompile);
     // return compiled code to template object
     if ($template->suppressFileDependency) {
         $template->compiled_template = $_compiled_code;
     } else {
         $template->compiled_template = $template_header . $template->createPropertyHeader() . $_compiled_code;
     }
     // run postfilter if required
     if (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) {
         $template->compiled_template = Smarty_Internal_Filter_Handler::runFilter('post', $template->compiled_template, $template);
     }
 }
Пример #9
0
 /**
  * fetches a rendered Smarty template
  * 
  * @param string $template the resource handle of the template file or template object
  * @param mixed $cache_id cache id to be used with this template
  * @param mixed $compile_id compile id to be used with this template
  * @param object $ |null $parent next higher level of Smarty variables
  * @return string rendered template output
  */
 public function fetch($template, $cache_id = null, $compile_id = null, $parent = null)
 {
     if (is_object($cache_id)) {
         $parent = $cache_id;
         $cache_id = null;
     }
     if ($parent === null) {
         // get default Smarty data object
         $parent = $this;
     }
     // create template object if necessary
     $template instanceof $this->template_class ? $_template = $template : ($_template = $this->createTemplate($template, $cache_id, $compile_id, $parent));
     $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting) ? $this->error_reporting : error_reporting() & ~E_NOTICE);
     // return redered template
     if (isset($this->autoload_filters['output']) || isset($this->registered_filters['output'])) {
         $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $this);
     } else {
         $_output = $_template->getRenderedTemplate();
     }
     $_template->rendered_content = null;
     error_reporting($_smarty_old_error_level);
     return $_output;
 }
    return true;
    }

    function endGetData(obj, data) {
        switch (obj.data('opt_id')) {
            case '***':
                //do samething;
                break;
        }
        return true;
    }
</script>

            </div>
        </div>
        <!--content end-->
        <!-- footer -->
        <div class="footer">
            <p>Copyright &copy; 1996-<?php 
echo Smarty_Internal_Filter_Handler::runFilter('variable', date('Y'), $_smarty_tpl, true);
?>
 SINA Corporation, All Rights Reserved</p>
            <p></p>
            <p>新浪公司 <a href="http://www.sina.com.cn/intro/copyright.shtml">版权所有</a></p>
        </div>
        <!-- end footer -->
    </div>
    <script type="text/javascript" src="/js/admin/common.js"></script>
</body>
</html>
 /**
  * Create code frame for compiled and cached templates
  *
  * @param Smarty_Internal_Template $_template
  * @param array                    $properties
  * @param  string                  $content optional template content
  * @param  string                  $header
  * @param  bool                    $cache   flag for cache file
  *
  * @return string
  * @throws \SmartyException
  */
 public static function create(Smarty_Internal_Template $_template, $properties, $content = '', $header = '', $cache = false)
 {
     // build property code
     $hash = str_replace(array('.', ','), '_', uniqid('', true));
     $class = "__Code_{$hash}_";
     $output = "<?php\n\n";
     $output .= $header . "\n\n";
     $output .= "if (!class_exists('{$class}',false)) {\n";
     $output .= "class {$class} extends Smarty_Internal_Runtime \n";
     $output .= "{\n";
     $version = Smarty::SMARTY_VERSION;
     $output .= "public \$version = '{$version}';\n";
     $output .= "public \$hash = '{$hash}';\n";
     foreach ($properties as $name => $value) {
         $output .= "public \${$name} = " . var_export($value, true) . ";\n";
     }
     $output .= "public function render (\$_smarty_tpl) {\n";
     $output .= $content;
     $output .= "}\n";
     if (!$cache) {
         if (!empty($_template->compiler->templateFunctionCode)) {
             $i = 0;
             while (isset($_template->compiler->templateFunctionCode[$i])) {
                 // run postfilter if required on compiled template code
                 if ((isset($_template->smarty->autoload_filters['post']) || isset($_template->smarty->registered_filters['post'])) && !$_template->compiler->suppressFilter) {
                     $output .= Smarty_Internal_Filter_Handler::runFilter('post', $_template->compiler->templateFunctionCode[$i], $_template);
                 } else {
                     $output .= $_template->compiler->templateFunctionCode[$i];
                 }
                 unset($_template->compiler->templateFunctionCode[$i]);
                 $output .= "\n";
                 $i++;
             }
         }
         if (!empty($_template->compiler->mergedSubTemplatesCode)) {
             foreach ($_template->compiler->mergedSubTemplatesCode as $name => $code) {
                 unset($_template->compiler->mergedSubTemplatesCode[$name]);
                 $output .= $code;
                 $output .= "\n";
             }
         }
     } else {
         if (isset($_template->context)) {
             foreach ($_template->context->templateFunctions as $name => $funcParam) {
                 if (is_file($funcParam['compiled_filepath'])) {
                     // read compiled file
                     $code = file_get_contents($funcParam['compiled_filepath']);
                     // grab template function
                     if (preg_match("/\\/\\* {$funcParam['method']} \\*\\/\\s*public\\s*([\\S\\s]*?)\\/\\*\\/ {$funcParam['method']} \\*\\//", $code, $match)) {
                         unset($code);
                         $output .= $match[0] . "\n";
                     }
                 }
             }
         }
     }
     $output .= "/* - end class - */\n}";
     $output .= "\n}\n";
     $output .= "\$this->compiledClass = '{$class}';\n";
     return self::format_string($output);
 }
 /**
  * Run optional prefilter
  *
  * @param string $_content template source
  *
  * @return string
  * @throws \SmartyException
  */
 public function preFilter($_content)
 {
     // run pre filter if required
     if ($_content != '' && (isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre']))) {
         return Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $this->template);
     } else {
         return $_content;
     }
 }
 /**
  * Method to compile a Smarty template
  *
  * @param  Smarty_Internal_Template $template template object to compile
  * @param  bool                     $nocache  true is shall be compiled in nocache mode
  *
  * @param Smarty_Internal_TemplateCompilerBase                    $parent_compiler
  *
  * @return bool true if compiling succeeded, false if it failed
  * @throws \SmartyException
  */
 public function compileTemplate(Smarty_Internal_Template $template, $nocache = null, Smarty_Internal_TemplateCompilerBase $parent_compiler = null)
 {
     $this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
     $nocache = isset($nocache) ? $nocache : false;
     // flag for nochache sections
     $this->nocache = $nocache;
     $this->tag_nocache = false;
     // save template object in compiler class
     $this->template = $template;
     // template header code
     $template_header = '';
     if (!$this->suppressHeader) {
         $template_header .= "/* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
         $template_header .= "         compiled from \"" . $this->template->source->filepath . "\" */\n";
     }
     if ($isExtendsResource = !empty($this->template->source->components)) {
         // we have array of inheritance templates by extends: resource
         $this->sources = array_reverse($template->source->components);
     }
     // the $this->sources array can get additional elements while compiling by the {extends} tag
     if (!$isExtendsResource) {
         $this->inheritance_child = $this->template->source->isChild;
         $this->smarty->_current_file = $this->template->source->filepath;
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_compile($this->template);
         }
         if (!($this->template->source->recompiled || $this->template->source->type == 'string' || $this->template->source->type == 'extends')) {
             $this->parent_compiler->resourceInfo[$this->template->source->uid] = $this->template->source->getResourceInfo($this->template);
         }
     }
     do {
         // flag for aborting current and start recompile
         $this->abort_and_recompile = false;
         if ($isExtendsResource) {
             $_content = '';
         } else {
             // get template source
             $_content = $this->template->source->content;
         }
         if ($_content != '') {
             // run prefilter if required
             if ((isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) && !$this->suppressFilter) {
                 $_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
             }
         }
         // call compiler
         $_compiled_code = $this->doCompile($_content);
     } while ($this->abort_and_recompile);
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::end_compile($this->template);
     }
     // free memory
     unset($this->parser->root_buffer, $this->parser->current_buffer, $this->parser, $this->lex);
     self::$_tag_objects = array();
     // return compiled code to template object
     // run postfilter if required on compiled template code
     if ((isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) && !$this->suppressFilter && $_compiled_code != '') {
         $_compiled_code = Smarty_Internal_Filter_Handler::runFilter('post', $_compiled_code, $template);
     }
     // unset content because template inheritance could have replace source with parent code
     unset($template->source->content);
     $this->parent_compiler = null;
     $this->template = null;
     if ($this->suppressTemplatePropertyHeader) {
         return $_compiled_code;
     } else {
         $properties = array('resourceInfo' => $this->resourceInfo, 'isInheritanceChild' => $this->inheritance_child);
         if (isset($this->templateProperties['tpl_function'])) {
             $properties['templateFunctions'] = $this->templateProperties['tpl_function'];
         }
         if (isset($this->templateProperties['block_function'])) {
             $properties['blockFunctions'] = $this->templateProperties['block_function'];
         }
         foreach ($this->plugins as $tmp) {
             foreach ($tmp as $plugin) {
                 $properties['plugins'][$plugin['file']] = $plugin['function'];
             }
         }
         foreach ($this->nocachePlugins as $tmp) {
             foreach ($tmp as $plugin) {
                 $properties['nocachePlugins'][$plugin['file']] = $plugin['function'];
             }
         }
         return Smarty_Internal_Extension_CodeFrame::create($template, $properties, $_compiled_code, $template_header);
     }
 }
 /**
  * Method to compile a Smarty template
  *
  * @param  Smarty_Internal_Template                 $template template object to compile
  * @param  bool                                     $nocache  true is shall be compiled in nocache mode
  * @param null|Smarty_Internal_TemplateCompilerBase $parent_compiler
  *
  * @return bool true if compiling succeeded, false if it failed
  * @throws \Exception
  */
 public function compileTemplate(Smarty_Internal_Template $template, $nocache = null, $parent_compiler = null)
 {
     if (property_exists($template->smarty, 'plugin_search_order')) {
         $this->plugin_search_order = $template->smarty->plugin_search_order;
     }
     // save template object in compiler class
     $this->template = $template;
     $this->savedSource = $this->template->source;
     try {
         if (isset($this->template->smarty->security_policy)) {
             $this->php_handling = $this->template->smarty->security_policy->php_handling;
         } else {
             $this->php_handling = $this->template->smarty->php_handling;
         }
         $this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
         $nocache = isset($nocache) ? $nocache : false;
         if (empty($template->compiled->nocache_hash)) {
             $template->compiled->nocache_hash = $this->nocache_hash;
         } else {
             $this->nocache_hash = $template->compiled->nocache_hash;
         }
         // template header code
         $template_header = '';
         if (!$this->suppressHeader) {
             $template_header .= "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
             $template_header .= "         compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
         }
         $_compiled_code = '';
         $this->smarty->_current_file = $this->template->source->filepath;
         if ($this->smarty->debugging) {
             $this->smarty->_debug->start_compile($this->template);
         }
         $this->parent_compiler->template->compiled->file_dependency[$this->template->source->uid] = array($this->template->source->filepath, $this->template->source->getTimeStamp(), $this->template->source->type);
         // compile for child template?
         $this->inheritance_child = $this->template->isChild;
         // flag for nochache sections
         $this->nocache = $nocache;
         $this->tag_nocache = false;
         // reset has nocache code flag
         $this->template->compiled->has_nocache_code = false;
         $this->has_variable_string = false;
         $this->prefix_code = array();
         // get template source
         if (!empty($this->template->source->components)) {
             // we have array of inheritance templates by extends: resource
             $this->sources = array_reverse($template->source->components);
             $_content = '';
         } else {
             // get template source
             $_content = $this->template->source->getContent();
         }
         if ($_content != '') {
             // run pre filter if required
             if ($_content != '' && ((isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) && !$this->suppressFilter)) {
                 $_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
             }
         }
         // call compiler
         $_compiled_code = $this->doCompile($_content, true);
         if ($this->smarty->debugging) {
             $this->smarty->_debug->end_compile($this->template);
         }
         // free memory
         $this->parser = null;
         // restore source
         $this->template->source = $this->savedSource;
         $this->savedSource = null;
         $this->smarty->_current_file = $this->template->source->filepath;
         // return compiled code to template object
         $merged_code = '';
         if (!empty($this->mergedSubTemplatesCode)) {
             foreach ($this->mergedSubTemplatesCode as $code) {
                 $merged_code .= $code;
             }
         }
         // run post filter if required on compiled template code
         if ((isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) && !$this->suppressFilter && $_compiled_code != '') {
             $_compiled_code = Smarty_Internal_Filter_Handler::runFilter('post', $_compiled_code, $template);
         }
         if ($this->suppressTemplatePropertyHeader) {
             $_compiled_code .= $merged_code;
         } else {
             $_compiled_code = $template_header . Smarty_Internal_Extension_CodeFrame::create($template, $_compiled_code) . $merged_code;
         }
         if (!empty($this->templateFunctionCode)) {
             // run post filter if required on compiled template code
             if ((isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) && !$this->suppressFilter) {
                 $_compiled_code .= Smarty_Internal_Filter_Handler::runFilter('post', $this->templateFunctionCode, $template);
             } else {
                 $_compiled_code .= $this->templateFunctionCode;
             }
         }
     } catch (Exception $e) {
         $this->_tag_stack = array();
         $this->_tag_objects = array();
         // restore source
         $this->template->source = $this->savedSource;
         $this->savedSource = null;
         $this->smarty->_current_file = $this->template->source->filepath;
         // free memory
         $this->parent_compiler = null;
         $this->template = null;
         $this->parser = null;
         throw $e;
     }
     $this->parent_compiler = null;
     $this->template = null;
     return $_compiled_code;
 }
 /**
  * fetches a rendered Smarty template
  * 
  * @param string $template the resource handle of the template file or template object
  * @param mixed $cache_id cache id to be used with this template
  * @param mixed $compile_id compile id to be used with this template
  * @param object $ |null $parent next higher level of Smarty variables
  * @return string rendered template output
  */
 public function fetch($template, $cache_id = null, $compile_id = null, $parent = null, $display = false)
 {
     if (is_object($cache_id)) {
         $parent = $cache_id;
         $cache_id = null;
     }
     if ($parent === null) {
         // get default Smarty data object
         $parent = $this;
     }
     array_push($this->block_data_stack, $this->block_data);
     $this->block_data = array();
     // create template object if necessary
     $template instanceof $this->template_class ? $_template = $template : ($_template = $this->createTemplate($template, $cache_id, $compile_id, $parent));
     $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting) ? $this->error_reporting : error_reporting() & ~E_NOTICE);
     // obtain data for cache modified check
     if ($this->cache_modified_check && $this->caching && $display) {
         $_isCached = $_template->isCached() && !$_template->has_nocache_code;
         if ($_isCached) {
             $_gmt_mtime = gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT';
         } else {
             $_gmt_mtime = '';
         }
     }
     // return redered template
     if (isset($this->autoload_filters['output']) || isset($this->registered_filters['output'])) {
         $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $this, $_template);
     } else {
         $_output = $_template->getRenderedTemplate();
     }
     $_template->rendered_content = null;
     error_reporting($_smarty_old_error_level);
     // display or fetch
     if ($display) {
         if ($this->caching && $this->cache_modified_check) {
             $_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
             if ($_isCached && $_gmt_mtime == $_last_modified_date) {
                 if (php_sapi_name() == 'cgi') {
                     header('Status: 304 Not Modified');
                 } else {
                     header('HTTP/1.1 304 Not Modified');
                 }
             } else {
                 header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT');
                 echo $_output;
             }
         } else {
             echo $_output;
         }
         // debug output
         if ($this->debugging) {
             Smarty_Internal_Debug::display_debug($this);
         }
         $this->block_data = array_pop($this->block_data_stack);
         return;
     } else {
         // return fetched content
         $this->block_data = array_pop($this->block_data_stack);
         return $_output;
     }
 }
 /**
  * Method to compile a Smarty template
  *
  * @param  Smarty_Internal_Template                 $template template object to compile
  * @param  bool                                     $nocache  true is shall be compiled in nocache mode
  * @param null|Smarty_Internal_TemplateCompilerBase $parent_compiler
  *
  * @return bool true if compiling succeeded, false if it failed
  */
 public function compileTemplate(Smarty_Internal_Template $template, $nocache = null, $parent_compiler = null)
 {
     // save template object in compiler class
     $this->template = $template;
     if (isset($this->template->smarty->security_policy)) {
         $this->php_handling = $this->template->smarty->security_policy->php_handling;
     } else {
         $this->php_handling = $this->template->smarty->php_handling;
     }
     $this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
     $nocache = isset($nocache) ? $nocache : false;
     if (empty($template->properties['nocache_hash'])) {
         $template->properties['nocache_hash'] = $this->nocache_hash;
     } else {
         $this->nocache_hash = $template->properties['nocache_hash'];
     }
     $save_source = $this->template->source;
     // template header code
     $template_header = '';
     if (!$this->suppressHeader) {
         $template_header .= "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
         $template_header .= "         compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
     }
     if (empty($this->template->source->components)) {
         $this->sources = array($template->source);
     } else {
         // we have array of inheritance templates by extends: resource
         $this->sources = array_reverse($template->source->components);
     }
     $loop = 0;
     // the $this->sources array can get additional elements while compiling by the {extends} tag
     while ($this->template->source = array_shift($this->sources)) {
         $this->smarty->_current_file = $this->template->source->filepath;
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_compile($this->template);
         }
         $no_sources = count($this->sources);
         $this->parent_compiler->template->properties['file_dependency'][$this->template->source->uid] = array($this->template->source->filepath, $this->template->source->getTimeStamp(), $this->template->source->type);
         $loop++;
         if ($no_sources) {
             $this->inheritance_child = true;
         } else {
             $this->inheritance_child = false;
         }
         // flag for nochache sections
         $this->nocache = $nocache;
         $this->tag_nocache = false;
         // reset has nocache code flag
         $this->template->has_nocache_code = false;
         $this->has_variable_string = false;
         $this->prefix_code = array();
         $_compiled_code = '';
         // get template source
         $_content = $this->template->source->getContent();
         if ($_content != '') {
             // run pre filter if required
             if ((isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) && !$this->suppressFilter) {
                 $_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
             }
             // call compiler
             $_compiled_code = $this->doCompile($_content, true);
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_compile($this->template);
         }
     }
     // restore source
     $this->template->source = $save_source;
     unset($save_source);
     $this->smarty->_current_file = $this->template->source->filepath;
     // free memory
     unset($this->parser->root_buffer, $this->parser->current_buffer, $this->parser, $this->lex);
     // return compiled code to template object
     $merged_code = '';
     if (!empty($this->mergedSubTemplatesCode)) {
         foreach ($this->mergedSubTemplatesCode as $code) {
             $merged_code .= $code;
         }
     }
     // run post filter if required on compiled template code
     if ((isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) && !$this->suppressFilter && $_compiled_code != '') {
         $_compiled_code = Smarty_Internal_Filter_Handler::runFilter('post', $_compiled_code, $template);
     }
     if ($this->suppressTemplatePropertyHeader) {
         $_compiled_code .= $merged_code;
     } else {
         $_compiled_code = $template_header . Smarty_Internal_Extension_CodeFrame::create($template, $_compiled_code) . $merged_code;
     }
     if (!empty($this->templateFunctionCode)) {
         // run post filter if required on compiled template code
         if ((isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) && !$this->suppressFilter) {
             $_compiled_code .= Smarty_Internal_Filter_Handler::runFilter('post', $this->templateFunctionCode, $template);
         } else {
             $_compiled_code .= $this->templateFunctionCode;
         }
     }
     $this->parent_compiler = null;
     $this->template = null;
     return $_compiled_code;
 }
 /**
  * Method to compile a Smarty template
  *
  * @param  Smarty_Internal_Template $template template object to compile
  * @param  bool $nocache    true is shall be compiled in nocache mode
  * @return bool             true if compiling succeeded, false if it failed
  */
 public function compileTemplate(Smarty_Internal_Template $template, $nocache = false)
 {
     if (empty($template->properties['nocache_hash'])) {
         $template->properties['nocache_hash'] = $this->nocache_hash;
     } else {
         $this->nocache_hash = $template->properties['nocache_hash'];
     }
     // flag for nochache sections
     $this->nocache = $nocache;
     $this->tag_nocache = false;
     // save template object in compiler class
     $this->template = $template;
     // reset has nocache code flag
     $this->template->has_nocache_code = false;
     $save_source = $this->template->source;
     // template header code
     $template_header = '';
     if (!$this->suppressHeader) {
         $template_header .= "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
         $template_header .= "         compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
     }
     if (empty($this->template->source->components)) {
         $this->sources = array($template->source);
     } else {
         // we have array of inheritance templates by extends: resource
         $this->sources = array_reverse($template->source->components);
     }
     $loop = 0;
     // the $this->sources array can get additional elements while compiling by the {extends} tag
     while ($this->template->source = array_shift($this->sources)) {
         $this->smarty->_current_file = $this->template->source->filepath;
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_compile($this->template);
         }
         $no_sources = count($this->sources);
         if ($loop || $no_sources) {
             $this->template->properties['file_dependency'][$this->template->source->uid] = array($this->template->source->filepath, $this->template->source->timestamp, $this->template->source->type);
         }
         $loop++;
         if ($no_sources) {
             $this->inheritance_child = true;
         } else {
             $this->inheritance_child = false;
         }
         do {
             $_compiled_code = '';
             // flag for aborting current and start recompile
             $this->abort_and_recompile = false;
             // get template source
             $_content = $this->template->source->content;
             if ($_content != '') {
                 // run prefilter if required
                 if ((isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) && !$this->suppressFilter) {
                     $_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
                 }
                 // call compiler
                 $_compiled_code = $this->doCompile($_content);
             }
         } while ($this->abort_and_recompile);
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_compile($this->template);
         }
     }
     // restore source
     $this->template->source = $save_source;
     unset($save_source);
     $this->smarty->_current_file = $this->template->source->filepath;
     // free memory
     unset($this->parser->root_buffer, $this->parser->current_buffer, $this->parser, $this->lex, $this->template);
     self::$_tag_objects = array();
     // return compiled code to template object
     $merged_code = '';
     if (!$this->suppressMergedTemplates && !empty($this->merged_templates)) {
         foreach ($this->merged_templates as $code) {
             $merged_code .= $code;
         }
     }
     // run postfilter if required on compiled template code
     if ((isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) && !$this->suppressFilter && $_compiled_code != '') {
         $_compiled_code = Smarty_Internal_Filter_Handler::runFilter('post', $_compiled_code, $template);
     }
     if ($this->suppressTemplatePropertyHeader) {
         $code = $_compiled_code . $merged_code;
     } else {
         $code = $template_header . $template->createTemplateCodeFrame($_compiled_code) . $merged_code;
     }
     // unset content because template inheritance could have replace source with parent code
     unset($template->source->content);
     return $code;
 }
 /**
  * fetches a rendered Smarty template
  *
  * @param string $template          the resource handle of the template file or template object
  * @param mixed  $cache_id          cache id to be used with this template
  * @param mixed  $compile_id        compile id to be used with this template
  * @param object $parent            next higher level of Smarty variables
  * @param bool   $display           true: display, false: fetch
  * @param bool   $merge_tpl_vars    if true parent template variables merged in to local scope
  * @param bool   $no_output_filter  if true do not run output filter
  * @return string rendered template output
  */
 public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
 {
     if ($template === null && $this instanceof $this->template_class) {
         $template = $this;
     }
     if (!empty($cache_id) && is_object($cache_id)) {
         $parent = $cache_id;
         $cache_id = null;
     }
     if ($parent === null && ($this instanceof Smarty || is_string($template))) {
         $parent = $this;
     }
     // create template object if necessary
     $_template = $template instanceof $this->template_class ? $template : $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false);
     // if called by Smarty object make sure we use current caching status
     if ($this instanceof Smarty) {
         $_template->caching = $this->caching;
     }
     // merge all variable scopes into template
     if ($merge_tpl_vars) {
         // save local variables
         $save_tpl_vars = $_template->tpl_vars;
         $save_config_vars = $_template->config_vars;
         $ptr_array = array($_template);
         $ptr = $_template;
         while (isset($ptr->parent)) {
             $ptr_array[] = $ptr = $ptr->parent;
         }
         $ptr_array = array_reverse($ptr_array);
         $parent_ptr = reset($ptr_array);
         $tpl_vars = $parent_ptr->tpl_vars;
         $config_vars = $parent_ptr->config_vars;
         while ($parent_ptr = next($ptr_array)) {
             if (!empty($parent_ptr->tpl_vars)) {
                 $tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars);
             }
             if (!empty($parent_ptr->config_vars)) {
                 $config_vars = array_merge($config_vars, $parent_ptr->config_vars);
             }
         }
         if (!empty(Smarty::$global_tpl_vars)) {
             $tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars);
         }
         $_template->tpl_vars = $tpl_vars;
         $_template->config_vars = $config_vars;
     }
     // dummy local smarty variable
     if (!isset($_template->tpl_vars['smarty'])) {
         $_template->tpl_vars['smarty'] = new Smarty_Variable();
     }
     if (isset($this->smarty->error_reporting)) {
         $_smarty_old_error_level = error_reporting($this->smarty->error_reporting);
     }
     // check URL debugging control
     if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
         if (isset($_SERVER['QUERY_STRING'])) {
             $_query_string = $_SERVER['QUERY_STRING'];
         } else {
             $_query_string = '';
         }
         if (false !== strpos($_query_string, $this->smarty->smarty_debug_id)) {
             if (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=on')) {
                 // enable debugging for this browser session
                 setcookie('SMARTY_DEBUG', true);
                 $this->smarty->debugging = true;
             } elseif (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=off')) {
                 // disable debugging for this browser session
                 setcookie('SMARTY_DEBUG', false);
                 $this->smarty->debugging = false;
             } else {
                 // enable debugging for this page
                 $this->smarty->debugging = true;
             }
         } else {
             if (isset($_COOKIE['SMARTY_DEBUG'])) {
                 $this->smarty->debugging = true;
             }
         }
     }
     // must reset merge template date
     $_template->smarty->merged_templates_func = array();
     // get rendered template
     // disable caching for evaluated code
     if ($_template->source->recompiled) {
         $_template->caching = false;
     }
     // checks if template exists
     if (!$_template->source->exists) {
         if ($_template->parent instanceof Smarty_Internal_Template) {
             $parent_resource = " in '{$_template->parent->template_resource}'";
         } else {
             $parent_resource = '';
         }
         throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}");
     }
     // read from cache or render
     if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || !$_template->cached->valid) {
         // render template (not loaded and not in cache)
         if (!$_template->source->uncompiled) {
             $_smarty_tpl = $_template;
             if ($_template->source->recompiled) {
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_compile($_template);
                 }
                 $code = $_template->compiler->compileTemplate($_template);
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::end_compile($_template);
                 }
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 try {
                     ob_start();
                     eval("?>" . $code);
                     unset($code);
                 } catch (Exception $e) {
                     ob_get_clean();
                     throw $e;
                 }
             } else {
                 if (!$_template->compiled->exists || $_template->smarty->force_compile && !$_template->compiled->isCompiled) {
                     $_template->compileTemplateSource();
                 }
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 if (!$_template->compiled->loaded) {
                     include $_template->compiled->filepath;
                     if ($_template->mustCompile) {
                         // recompile and load again
                         $_template->compileTemplateSource();
                         include $_template->compiled->filepath;
                     }
                     $_template->compiled->loaded = true;
                 } else {
                     $_template->decodeProperties($_template->compiled->_properties, false);
                 }
                 try {
                     ob_start();
                     if (empty($_template->properties['unifunc']) || !is_callable($_template->properties['unifunc'])) {
                         throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'");
                     }
                     array_unshift($_template->_capture_stack, array());
                     //
                     // render compiled template
                     //
                     $_template->properties['unifunc']($_template);
                     // any unclosed {capture} tags ?
                     if (isset($_template->_capture_stack[0][0])) {
                         $_template->capture_error();
                     }
                     array_shift($_template->_capture_stack);
                 } catch (Exception $e) {
                     ob_get_clean();
                     throw $e;
                 }
             }
         } else {
             if ($_template->source->uncompiled) {
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 try {
                     ob_start();
                     $_template->source->renderUncompiled($_template);
                 } catch (Exception $e) {
                     ob_get_clean();
                     throw $e;
                 }
             } else {
                 throw new SmartyException("Resource '{$_template->source}->type' must have 'renderUncompiled' method");
             }
         }
         $_output = ob_get_clean();
         if (!$_template->source->recompiled && empty($_template->properties['file_dependency'][$_template->source->uid])) {
             $_template->properties['file_dependency'][$_template->source->uid] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type);
         }
         if ($_template->parent instanceof Smarty_Internal_Template) {
             $_template->parent->properties['file_dependency'] = array_merge($_template->parent->properties['file_dependency'], $_template->properties['file_dependency']);
             foreach ($_template->required_plugins as $code => $tmp1) {
                 foreach ($tmp1 as $name => $tmp) {
                     foreach ($tmp as $type => $data) {
                         $_template->parent->required_plugins[$code][$name][$type] = $data;
                     }
                 }
             }
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_render($_template);
         }
         // write to cache when nessecary
         if (!$_template->source->recompiled && ($_template->caching == Smarty::CACHING_LIFETIME_SAVED || $_template->caching == Smarty::CACHING_LIFETIME_CURRENT)) {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_cache($_template);
             }
             $_template->properties['has_nocache_code'] = false;
             // get text between non-cached items
             $cache_split = preg_split("!/\\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!s", $_output);
             // get non-cached items
             preg_match_all("!/\\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!s", $_output, $cache_parts);
             $output = '';
             // loop over items, stitch back together
             foreach ($cache_split as $curr_idx => $curr_split) {
                 // escape PHP tags in template content
                 $output .= preg_replace('/(<%|%>|<\\?php|<\\?|\\?>)/', '<?php echo \'$1\'; ?>', $curr_split);
                 if (isset($cache_parts[0][$curr_idx])) {
                     $_template->properties['has_nocache_code'] = true;
                     // remove nocache tags from cache output
                     $output .= preg_replace("!/\\*/?%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!", '', $cache_parts[0][$curr_idx]);
                 }
             }
             if (!$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
                 $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template);
             }
             // rendering (must be done before writing cache file because of {function} nocache handling)
             $_smarty_tpl = $_template;
             try {
                 ob_start();
                 eval("?>" . $output);
                 $_output = ob_get_clean();
             } catch (Exception $e) {
                 ob_get_clean();
                 throw $e;
             }
             // write cache file content
             $_template->writeCachedContent($output);
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_cache($_template);
             }
         } else {
             // var_dump('renderTemplate', $_template->has_nocache_code, $_template->template_resource, $_template->properties['nocache_hash'], $_template->parent->properties['nocache_hash'], $_output);
             if (!empty($_template->properties['nocache_hash']) && !empty($_template->parent->properties['nocache_hash'])) {
                 // replace nocache_hash
                 $_output = preg_replace("/{$_template->properties['nocache_hash']}/", $_template->parent->properties['nocache_hash'], $_output);
                 $_template->parent->has_nocache_code = $_template->parent->has_nocache_code || $_template->has_nocache_code;
             }
         }
     } else {
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_cache($_template);
         }
         try {
             ob_start();
             array_unshift($_template->_capture_stack, array());
             //
             // render cached template
             //
             $_template->properties['unifunc']($_template);
             // any unclosed {capture} tags ?
             if (isset($_template->_capture_stack[0][0])) {
                 $_template->capture_error();
             }
             array_shift($_template->_capture_stack);
             $_output = ob_get_clean();
         } catch (Exception $e) {
             ob_get_clean();
             throw $e;
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_cache($_template);
         }
     }
     if ((!$this->caching || $_template->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
         $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_output, $_template);
     }
     if (isset($this->error_reporting)) {
         error_reporting($_smarty_old_error_level);
     }
     // display or fetch
     if ($display) {
         if ($this->caching && $this->cache_modified_check) {
             $_isCached = $_template->isCached() && !$_template->has_nocache_code;
             $_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
             if ($_isCached && $_template->cached->timestamp <= strtotime($_last_modified_date)) {
                 switch (PHP_SAPI) {
                     case 'cgi':
                         // php-cgi < 5.3
                     // php-cgi < 5.3
                     case 'cgi-fcgi':
                         // php-cgi >= 5.3
                     // php-cgi >= 5.3
                     case 'fpm-fcgi':
                         // php-fpm >= 5.3.3
                         header('Status: 304 Not Modified');
                         break;
                     case 'cli':
                         if (!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])) {
                             $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified';
                         }
                         break;
                     default:
                         header('HTTP/1.1 304 Not Modified');
                         break;
                 }
             } else {
                 switch (PHP_SAPI) {
                     case 'cli':
                         if (!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])) {
                             $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT';
                         }
                         break;
                     default:
                         header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT');
                         break;
                 }
                 echo $_output;
             }
         } else {
             echo $_output;
         }
         // debug output
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::display_debug($this);
         }
         if ($merge_tpl_vars) {
             // restore local variables
             $_template->tpl_vars = $save_tpl_vars;
             $_template->config_vars = $save_config_vars;
         }
         return;
     } else {
         if ($merge_tpl_vars) {
             // restore local variables
             $_template->tpl_vars = $save_tpl_vars;
             $_template->config_vars = $save_config_vars;
         }
         // return fetched content
         return $_output;
     }
 }
 /**
  * render template
  *
  * @param  bool                         $display       true: display, false: fetch
  * @param bool                          $isSubTemplate
  * @param bool                          $runOutputFilter
  * @param null|\Smarty_Internal_Context $_contextObjIn optional buffer object
  *
  * @return string
  * @throws \SmartyException
  */
 public function render($display = false, $isSubTemplate = false, $runOutputFilter = true, Smarty_Internal_Context $_contextObjIn = null)
 {
     $level = ob_get_level();
     try {
         if (!isset($this->source)) {
             $this->source = Smarty_Template_Source::load($this);
         }
         // checks if template exists
         if (!$this->source->exists) {
             if ($this->parent instanceof Smarty_Internal_Template) {
                 $parent_resource = " in '{$this->parent->template_resource}'";
             } else {
                 $parent_resource = '';
             }
             throw new SmartyException("Unable to load template {$this->source->type} '{$this->source->name}'{$parent_resource}");
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_template($this);
         }
         $this->context = $_contextObjIn === null ? new Smarty_Internal_Context() : $_contextObjIn;
         // merge all variable scopes into template
         if (!$isSubTemplate) {
             $savedErrorLevel = isset($this->smarty->error_reporting) ? error_reporting($this->smarty->error_reporting) : null;
             // save local variables
             $savedTplVars = $this->tpl_vars;
             $savedConfigVars = $this->config_vars;
             $ptr_array = array($this);
             $ptr = $this;
             while (isset($ptr->parent)) {
                 $ptr_array[] = $ptr = $ptr->parent;
             }
             $ptr_array = array_reverse($ptr_array);
             $parent_ptr = reset($ptr_array);
             $tpl_vars = $parent_ptr->tpl_vars;
             $config_vars = $parent_ptr->config_vars;
             while ($parent_ptr = next($ptr_array)) {
                 if (!empty($parent_ptr->tpl_vars)) {
                     $tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars);
                 }
                 if (!empty($parent_ptr->config_vars)) {
                     $config_vars = array_merge($config_vars, $parent_ptr->config_vars);
                 }
             }
             if (!empty(Smarty::$global_tpl_vars)) {
                 $tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars);
             }
             $this->tpl_vars = $tpl_vars;
             $this->config_vars = $config_vars;
         } else {
             $savedTplVars = null;
             $savedConfigVars = null;
             $savedErrorLevel = null;
         }
         // dummy local smarty variable
         if (!isset($this->tpl_vars['smarty'])) {
             $this->tpl_vars['smarty'] = new Smarty_Variable();
         }
         // disable caching for evaluated code
         if ($this->source->recompiled) {
             $this->caching = false;
         }
         $_caching = $this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED;
         // read from cache or render
         if ($_caching && !isset($this->cached)) {
             $this->cached = Smarty_Template_Cached::load($this);
         }
         if (!$_caching || !$this->cached->valid) {
             // render template (not loaded and not in cache)
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_render($this, null);
             }
             if (isset($this->cached)) {
                 $_savedContext = $this->context;
                 $this->context = new Smarty_Internal_Context(true);
             }
             if (!$this->source->uncompiled) {
                 // render compiled code
                 if (!isset($this->compiled)) {
                     $this->compiled = Smarty_Template_Compiled::load($this);
                 }
                 $this->compiled->render($this);
             } else {
                 $this->source->renderUncompiled($this);
             }
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_render($this, null);
             }
             // write to cache when necessary
             if ($_caching && !$this->source->recompiled) {
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_cache($this);
                 }
                 // write cache file content
                 if ($runOutputFilter && !$this->context->hasNocacheCode && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
                     $this->cached->writeCachedContent($this, $this->context, Smarty_Internal_Filter_Handler::runFilter('output', $this->context->getContent(), $this));
                 } else {
                     $this->cached->writeCachedContent($this, $this->context);
                 }
                 $this->context = $_savedContext;
                 $compile_check = $this->smarty->compile_check;
                 $this->smarty->compile_check = false;
                 if (!$this->cached->processed) {
                     $this->cached->process($this);
                 }
                 $this->smarty->compile_check = $compile_check;
                 $this->cached->compiledTplObj->getRenderedTemplateCode($this);
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::end_cache($this);
                 }
             }
         } else {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_cache($this);
             }
             $this->cached->render($this);
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_cache($this);
             }
         }
         if ($runOutputFilter && (!$this->caching || $this->context->hasNocacheCode || $this->source->recompiled) && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
             $this->context->flushBuffer();
             $this->context->content = Smarty_Internal_Filter_Handler::runFilter('output', $this->context->content, $this);
         }
         // display or fetch
         if ($display) {
             $this->context->endBuffer();
             if ($this->caching && $this->smarty->cache_modified_check) {
                 $this->cached->cacheModifiedCheck($this, $this->context->content);
             } else {
                 echo $this->context->content;
             }
             $this->context = null;
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_template($this);
         }
         if ($display) {
             // debug output
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::display_debug($this, true);
             }
         }
         if (!$isSubTemplate) {
             // restore local variables
             $this->tpl_vars = $savedTplVars;
             $this->config_vars = $savedConfigVars;
             if (isset($savedErrorLevel)) {
                 error_reporting($savedErrorLevel);
             }
         }
     } catch (Exception $e) {
         while (ob_get_level() > $level) {
             ob_end_clean();
         }
         throw $e;
     }
     if (!$display && $_contextObjIn === null) {
         // return fetched content
         $this->context->endBuffer();
         $output = $this->context->content;
         $this->context = null;
         return $output;
     }
     $this->context = null;
     return '';
 }
Пример #20
0
 /**
  * render template
  *
  * @param  bool $merge_tpl_vars if true parent template variables merged in to local scope
  * @param  bool $no_output_filter if true do not run output filter
  * @param  bool $display true: display, false: fetch null: subtemplate
  *
  * @throws Exception
  * @throws SmartyException
  * @return string rendered template output
  */
 public function render($merge_tpl_vars = false, $no_output_filter = true, $display = null)
 {
     $parentIsTpl = $this->parent instanceof Smarty_Internal_Template;
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::start_template($this, $display);
     }
     $save_tpl_vars = null;
     $save_config_vars = null;
     // merge all variable scopes into template
     if ($merge_tpl_vars) {
         // save local variables
         $save_tpl_vars = $this->tpl_vars;
         $save_config_vars = $this->config_vars;
         $ptr_array = [$this];
         $ptr = $this;
         while (isset($ptr->parent)) {
             $ptr_array[] = $ptr = $ptr->parent;
         }
         $ptr_array = array_reverse($ptr_array);
         $parent_ptr = reset($ptr_array);
         $tpl_vars = $parent_ptr->tpl_vars;
         $config_vars = $parent_ptr->config_vars;
         while ($parent_ptr = next($ptr_array)) {
             if (!empty($parent_ptr->tpl_vars)) {
                 $tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars);
             }
             if (!empty($parent_ptr->config_vars)) {
                 $config_vars = array_merge($config_vars, $parent_ptr->config_vars);
             }
         }
         if (!empty(Smarty::$global_tpl_vars)) {
             $tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars);
         }
         $this->tpl_vars = $tpl_vars;
         $this->config_vars = $config_vars;
     }
     // dummy local smarty variable
     if (!isset($this->tpl_vars['smarty'])) {
         $this->tpl_vars['smarty'] = new Smarty_Variable();
     }
     $_smarty_old_error_level = isset($this->smarty->error_reporting) ? error_reporting($this->smarty->error_reporting) : null;
     // check URL debugging control
     if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
         Smarty_Internal_Debug::debugUrl($this);
     }
     if (!isset($this->source)) {
         $this->loadSource();
     }
     // checks if template exists
     if (!$this->source->exists) {
         if ($parentIsTpl) {
             $parent_resource = " in '{$this->parent->template_resource}'";
         } else {
             $parent_resource = '';
         }
         throw new SmartyException("Unable to load template {$this->source->type} '{$this->source->name}'{$parent_resource}");
     }
     // disable caching for evaluated code
     if ($this->source->recompiled) {
         $this->caching = false;
     }
     // read from cache or render
     $isCacheTpl = $this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED;
     if ($isCacheTpl) {
         if (!isset($this->cached)) {
             $this->loadCached();
         }
         $this->cached->isCached($this);
     }
     if (!$isCacheTpl || !$this->cached->valid) {
         if ($isCacheTpl) {
             $this->properties['tpl_function'] = [];
         }
         // render template (not loaded and not in cache)
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_render($this);
         }
         if (!$this->source->uncompiled) {
             // render compiled code
             if (!isset($this->compiled)) {
                 $this->loadCompiled();
             }
             $content = $this->compiled->render($this);
         } else {
             $content = $this->source->renderUncompiled($this);
         }
         if (!$this->source->recompiled && empty($this->properties['file_dependency'][$this->source->uid])) {
             $this->properties['file_dependency'][$this->source->uid] = [$this->source->filepath, $this->source->timestamp, $this->source->type];
         }
         if ($parentIsTpl) {
             $this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']);
             //$this->parent->properties['tpl_function'] = array_merge($this->parent->properties['tpl_function'], $this->properties['tpl_function']);
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_render($this);
         }
         // write to cache when necessary
         if (!$this->source->recompiled && $isCacheTpl) {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_cache($this);
             }
             $this->cached->updateCache($this, $content, $no_output_filter);
             $compile_check = $this->smarty->compile_check;
             $this->smarty->compile_check = false;
             if ($parentIsTpl) {
                 $this->properties['tpl_function'] = $this->parent->properties['tpl_function'];
             }
             if (!$this->cached->processed) {
                 $this->cached->process($this);
             }
             $this->smarty->compile_check = $compile_check;
             $content = $this->getRenderedTemplateCode();
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_cache($this);
             }
         } else {
             if (!empty($this->properties['nocache_hash']) && !empty($this->parent->properties['nocache_hash'])) {
                 // replace nocache_hash
                 $content = str_replace("{$this->properties['nocache_hash']}", $this->parent->properties['nocache_hash'], $content);
                 $this->parent->has_nocache_code = $this->parent->has_nocache_code || $this->has_nocache_code;
             }
         }
     } else {
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_cache($this);
         }
         $content = $this->cached->render($this);
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_cache($this);
         }
     }
     if ((!$this->caching || $this->has_nocache_code || $this->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
         $content = Smarty_Internal_Filter_Handler::runFilter('output', $content, $this);
     }
     if (isset($_smarty_old_error_level)) {
         error_reporting($_smarty_old_error_level);
     }
     // display or fetch
     if ($display) {
         if ($this->caching && $this->smarty->cache_modified_check) {
             $this->cached->cacheModifiedCheck($this, $content);
         } else {
             echo $content;
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_template($this);
         }
         // debug output
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::display_debug($this, true);
         }
         if ($merge_tpl_vars) {
             // restore local variables
             $this->tpl_vars = $save_tpl_vars;
             $this->config_vars = $save_config_vars;
         }
         return '';
     } else {
         if ($merge_tpl_vars) {
             // restore local variables
             $this->tpl_vars = $save_tpl_vars;
             $this->config_vars = $save_config_vars;
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_template($this);
         }
         if ($this->smarty->debugging == 2 and $display === false) {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::display_debug($this, true);
             }
         }
         if ($parentIsTpl) {
             $this->parent->properties['tpl_function'] = array_merge($this->parent->properties['tpl_function'], $this->properties['tpl_function']);
             foreach ($this->required_plugins as $code => $tmp1) {
                 foreach ($tmp1 as $name => $tmp) {
                     foreach ($tmp as $type => $data) {
                         $this->parent->required_plugins[$code][$name][$type] = $data;
                     }
                 }
             }
         }
         // return cache content
         return $content;
     }
 }
 /**
  * Sanitize content and write it to cache resource
  *
  * @param Smarty_Internal_Template $_template
  * @param bool                     $no_output_filter
  *
  * @throws \SmartyException
  */
 public function updateCache(Smarty_Internal_Template $_template, $no_output_filter)
 {
     $content = ob_get_clean();
     unset($this->hashes[$_template->compiled->nocache_hash]);
     if (!empty($this->hashes)) {
         $hash_array = array();
         foreach ($this->hashes as $hash => $foo) {
             $hash_array[] = "/{$hash}/";
         }
         $content = preg_replace($hash_array, $_template->compiled->nocache_hash, $content);
     }
     $_template->cached->has_nocache_code = false;
     // get text between non-cached items
     $cache_split = preg_split("!/\\*%%SmartyNocache:{$_template->compiled->nocache_hash}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->compiled->nocache_hash}%%\\*/!s", $content);
     // get non-cached items
     preg_match_all("!/\\*%%SmartyNocache:{$_template->compiled->nocache_hash}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->compiled->nocache_hash}%%\\*/!s", $content, $cache_parts);
     $content = '';
     // loop over items, stitch back together
     foreach ($cache_split as $curr_idx => $curr_split) {
         // escape PHP tags in template content
         $content .= preg_replace('/(<%|%>|<\\?php|<\\?|\\?>|<script\\s+language\\s*=\\s*[\\"\']?\\s*php\\s*[\\"\']?\\s*>)/', "<?php echo '\$1'; ?>\n", $curr_split);
         if (isset($cache_parts[0][$curr_idx])) {
             $_template->cached->has_nocache_code = true;
             $content .= $cache_parts[1][$curr_idx];
         }
     }
     if (!$no_output_filter && !$_template->compiled->has_nocache_code && (isset($_template->smarty->autoload_filters['output']) || isset($_template->smarty->registered_filters['output']))) {
         $content = Smarty_Internal_Filter_Handler::runFilter('output', $content, $_template);
     }
     // write cache file content
     $this->writeCachedContent($_template, $content);
 }
Пример #22
0
 /**
  * Render the output using the compiled template or the PHP template source
  * 
  * The rendering process is accomplished by just including the PHP files.
  * The only exceptions are evaluated templates (string template). Their code has 
  * to be evaluated
  */
 public function renderTemplate()
 {
     if ($this->resource_object->usesCompiler) {
         if ($this->mustCompile() && $this->compiled_template === null) {
             $this->compileTemplateSource();
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_render($this);
         }
         $_smarty_tpl = $this;
         ob_start();
         if ($this->resource_object->isEvaluated) {
             eval("?>" . $this->compiled_template);
         } else {
             include $this->getCompiledFilepath();
             // check file dependencies at compiled code
             if ($this->smarty->compile_check) {
                 if (!empty($this->properties['file_dependency'])) {
                     $this->mustCompile = false;
                     $resource_type = null;
                     $resource_name = null;
                     foreach ($this->properties['file_dependency'] as $_file_to_check) {
                         if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'extends' || $_file_to_check[2] == 'php') {
                             $mtime = filemtime($_file_to_check[0]);
                         } else {
                             $this->getResourceTypeName($_file_to_check[0], $resource_type, $resource_name);
                             $resource_handler = $this->loadTemplateResourceHandler($resource_type);
                             $mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name);
                         }
                         // If ($mtime != $_file_to_check[1]) {
                         if ($mtime > $_file_to_check[1]) {
                             $this->mustCompile = true;
                             break;
                         }
                     }
                     if ($this->mustCompile) {
                         // recompile and render again
                         ob_GET_clean();
                         $this->compileTemplateSource();
                         ob_start();
                         include $this->getCompiledFilepath();
                     }
                 }
             }
         }
     } else {
         if (is_callable(array($this->resource_object, 'renderUncompiled'))) {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_render($this);
             }
             ob_start();
             $this->resource_object->renderUncompiled($this);
         } else {
             throw new SmartyException("Resource '{$this->resource_type}' must have 'renderUncompiled' methode");
         }
     }
     $this->rendered_content = ob_GET_clean();
     if (!$this->resource_object->isEvaluated && empty($this->properties['file_dependency'][$this->templateUid])) {
         $this->properties['file_dependency'][$this->templateUid] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp(), $this->resource_type);
     }
     if ($this->parent instanceof Smarty_Internal_Template) {
         $this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']);
         foreach ($this->required_plugins as $code => $tmp1) {
             foreach ($tmp1 as $name => $tmp) {
                 foreach ($tmp as $type => $data) {
                     $this->parent->required_plugins[$code][$name][$type] = $data;
                 }
             }
         }
     }
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::end_render($this);
     }
     // write to cache when nessecary
     if (!$this->resource_object->isEvaluated && ($this->caching == Smarty::CACHING_LIFETIME_SAVED || $this->caching == Smarty::CACHING_LIFETIME_CURRENT)) {
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_cache($this);
         }
         $this->properties['has_nocache_code'] = false;
         // get text between non-cached items
         $cache_split = preg_split("!/\\*%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*/!s", $this->rendered_content);
         // get non-cached items
         preg_match_all("!/\\*%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*/!s", $this->rendered_content, $cache_parts);
         $output = '';
         // loop over items, stitch back together
         foreach ($cache_split as $curr_idx => $curr_split) {
             // escape PHP tags in template content
             $output .= preg_replace('/(<%|%>|<\\?php|<\\?|\\?>)/', '<?php echo \'$1\'; ?>', $curr_split);
             if (isset($cache_parts[0][$curr_idx])) {
                 $this->properties['has_nocache_code'] = true;
                 // remove nocache tags from cache output
                 $output .= preg_replace("!/\\*/?%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*/!", '', $cache_parts[0][$curr_idx]);
             }
         }
         if (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output'])) {
             $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $this);
         }
         // rendering (must be done before writing cache file because of {function} nocache handling)
         $_smarty_tpl = $this;
         ob_start();
         eval("?>" . $output);
         $this->rendered_content = ob_GET_clean();
         // write cache file content
         $this->writeCachedContent('<?php if (!$no_render) {?>' . $output . '<?php } ?>');
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_cache($this);
         }
     } else {
         // var_dump('renderTemplate', $this->has_nocache_code, $this->template_resource, $this->properties['nocache_hash'], $this->parent->properties['nocache_hash'], $this->rendered_content);
         if ($this->has_nocache_code && !empty($this->properties['nocache_hash']) && !empty($this->parent->properties['nocache_hash'])) {
             // replace nocache_hash
             $this->rendered_content = preg_replace("/{$this->properties['nocache_hash']}/", $this->parent->properties['nocache_hash'], $this->rendered_content);
             $this->parent->has_nocache_code = $this->has_nocache_code;
         }
     }
 }
Пример #23
0
 /**
  * Sanitize content and write it to cache resource
  *
  * @param Smarty_Internal_Template $_template
  * @param string                   $content
  * @param bool                     $no_output_filter
  *
  * @throws SmartyException
  */
 public function updateCache(Smarty_Internal_Template $_template, $content, $no_output_filter)
 {
     $_template->properties['has_nocache_code'] = false;
     // get text between non-cached items
     $cache_split = preg_split("!/\\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!s", $content);
     // get non-cached items
     preg_match_all("!/\\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!s", $content, $cache_parts);
     $output = '';
     // loop over items, stitch back together
     foreach ($cache_split as $curr_idx => $curr_split) {
         // escape PHP tags in template content
         $output .= preg_replace('/(<%|%>|<\\?php|<\\?|\\?>|<script\\s+language\\s*=\\s*[\\"\']?\\s*php\\s*[\\"\']?\\s*>)/', "<?php echo '\$1'; ?>\n", $curr_split);
         if (isset($cache_parts[0][$curr_idx])) {
             $_template->properties['has_nocache_code'] = true;
             $output .= $cache_parts[1][$curr_idx];
         }
     }
     if (!$no_output_filter && !$_template->has_nocache_code && (isset($_template->smarty->autoload_filters['output']) || isset($_template->smarty->registered_filters['output']))) {
         $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template);
     }
     // write cache file content
     $this->writeCachedContent($_template, $output);
 }
Пример #24
0
 /**
  * fetches a rendered Smarty template
  * 
  * @param string $template the resource handle of the template file or template object
  * @param mixed $cache_id cache id to be used with this template
  * @param mixed $compile_id compile id to be used with this template
  * @param object $ |null $parent next higher level of Smarty variables
  * @return string rendered template output
  */
 public function fetch($template, $cache_id = null, $compile_id = null, $parent = null, $display = false)
 {
     if (!empty($cache_id) && is_object($cache_id)) {
         $parent = $cache_id;
         $cache_id = null;
     }
     if ($parent === null) {
         // get default Smarty data object
         $parent = $this;
     }
     // create template object if necessary
     $template instanceof $this->template_class ? $_template = $template : ($_template = $this->createTemplate($template, $cache_id, $compile_id, $parent, false));
     if (isset($this->error_reporting)) {
         $_smarty_old_error_level = error_reporting($this->error_reporting);
     }
     // check URL debugging control
     if (!$this->debugging && $this->debugging_ctrl == 'URL') {
         if (isset($_SERVER['QUERY_STRING'])) {
             $_query_string = $_SERVER['QUERY_STRING'];
         } else {
             $_query_string = '';
         }
         if (false !== strpos($_query_string, $this->smarty_debug_id)) {
             if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) {
                 // enable debugging for this browser session
                 setcookie('SMARTY_DEBUG', true);
                 $this->debugging = true;
             } elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) {
                 // disable debugging for this browser session
                 setcookie('SMARTY_DEBUG', false);
                 $this->debugging = false;
             } else {
                 // enable debugging for this page
                 $this->debugging = true;
             }
         } else {
             if (isset($_COOKIE['SMARTY_DEBUG'])) {
                 $this->debugging = true;
             }
         }
     }
     // obtain data for cache modified check
     if ($this->cache_modified_check && $this->caching && $display) {
         $_isCached = $_template->isCached() && !$_template->has_nocache_code;
         if ($_isCached) {
             $_gmt_mtime = gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT';
         } else {
             $_gmt_mtime = '';
         }
     }
     // return rendered template
     if ((!$this->caching || $_template->resource_object->isEvaluated) && (isset($this->autoload_filters['output']) || isset($this->registered_filters['output']))) {
         $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $_template);
     } else {
         $_output = $_template->getRenderedTemplate();
     }
     $_template->rendered_content = null;
     if (isset($this->error_reporting)) {
         error_reporting($_smarty_old_error_level);
     }
     // display or fetch
     if ($display) {
         if ($this->caching && $this->cache_modified_check) {
             $_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
             if ($_isCached && $_gmt_mtime == $_last_modified_date) {
                 if (php_sapi_name() == 'cgi') {
                     header('Status: 304 Not Modified');
                 } else {
                     header('HTTP/1.1 304 Not Modified');
                 }
             } else {
                 header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT');
                 echo $_output;
             }
         } else {
             echo $_output;
         }
         // debug output
         if ($this->debugging) {
             Smarty_Internal_Debug::display_debug($this);
         }
         return;
     } else {
         // return fetched content
         return $_output;
     }
 }
<span class="pagebox_num"><a href="<?php 
    echo Smarty_Internal_Filter_Handler::runFilter('variable', $_smarty_tpl->getVariable('paramStr')->value, $_smarty_tpl, true);
    echo Smarty_Internal_Filter_Handler::runFilter('variable', $_smarty_tpl->getVariable('pName')->value, $_smarty_tpl, true);
    ?>
=<?php 
    echo smarty_function_math(array('equation' => "x + y", 'x' => $_smarty_tpl->getVariable('page')->value, 'y' => 4), $_smarty_tpl);
    ?>
"><?php 
    echo smarty_function_math(array('equation' => "x + y", 'x' => $_smarty_tpl->getVariable('page')->value, 'y' => 4), $_smarty_tpl);
    ?>
</a></span><?php 
}
?>
	<?php 
if ($_smarty_tpl->getVariable('lastPage')->value - $_smarty_tpl->getVariable('page')->value >= 1) {
    ?>
<span class="pagebox_next"><a href="<?php 
    echo Smarty_Internal_Filter_Handler::runFilter('variable', $_smarty_tpl->getVariable('paramStr')->value, $_smarty_tpl, true);
    echo Smarty_Internal_Filter_Handler::runFilter('variable', $_smarty_tpl->getVariable('pName')->value, $_smarty_tpl, true);
    ?>
=<?php 
    echo Smarty_Internal_Filter_Handler::runFilter('variable', $_smarty_tpl->getVariable('nextPage')->value, $_smarty_tpl, true);
    ?>
">下一页</a></span><?php 
} else {
    ?>
<span class="pagebox_next_nolink">下一页</span><?php 
}
?>
</span>