function _display($output = '')
 {
     parent::_display($output);
     if (class_exists('CI_Controller') && class_exists('Smarty_Internal_Debug') && (config_item('smarty_debug') || $this->enable_profiler)) {
         $CI =& get_instance();
         $smarty_debug = new Smarty_Internal_Debug();
         $smarty_debug->display_debug($CI->ci_smarty);
     }
 }
    function content_5467bc02e6f7f7_87226601($_smarty_tpl)
    {
        $_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Debug');
        Smarty_Internal_Debug::display_debug($_smarty_tpl);
        ?>
test<?php 
    }
Exemplo n.º 3
0
 /**
  * creates a data object
  *
  * @param object $parent next higher level of Smarty variables
  * @param string $name   optional data block name
  *
  * @returns Smarty_Data data object
  */
 public function createData($parent = null, $name = null)
 {
     $dataObj = new Smarty_Data($parent, $this, $name);
     if ($this->debugging) {
         Smarty_Internal_Debug::register_data($dataObj);
     }
     return $dataObj;
 }
Exemplo n.º 4
0
 public function _display($output = '')
 {
     parent::_display($output);
     // If Smarty is active - NOTE: $this->output->enable_profiler(TRUE) active Smarty debug to simplify
     if (class_exists('CI_Controller') && class_exists('Smarty_Internal_Debug') && (config_item('smarty_debug') || $this->enable_profiler)) {
         $CI =& get_instance();
         Smarty_Internal_Debug::display_debug($CI->smarty);
     }
 }
 /**
  * creates a data object
  *
  * @api  Smarty::createData()
  * @link http://www.smarty.net/docs/en/api.create.data.tpl
  *
  * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty      $obj
  * @param \Smarty_Internal_Template|\Smarty_Internal_Data|\Smarty_Data|\Smarty $parent next higher level of Smarty
  *                                                                                     variables
  * @param string                                                               $name   optional data block name
  *
  * @returns Smarty_Data data object
  */
 public function createData(Smarty_Internal_TemplateBase $obj, Smarty_Internal_Data $parent = null, $name = null)
 {
     /* @var Smarty $smarty */
     $smarty = isset($this->smarty) ? $this->smarty : $obj;
     $dataObj = new Smarty_Data($parent, $smarty, $name);
     if ($smarty->debugging) {
         Smarty_Internal_Debug::register_data($dataObj);
     }
     return $dataObj;
 }
 /**
  * @param        $obj
  * @param        $config_file
  * @param null   $sections
  * @param string $scope
  */
 static function configLoad($obj, $config_file, $sections = null, $scope = 'local')
 {
     $smarty = isset($obj->smarty) ? $obj->smarty : $obj;
     $confObj = new $smarty->template_class($config_file, $smarty, $obj);
     $confObj->caching = Smarty::CACHING_OFF;
     $confObj->source = Smarty_Template_Config::load($confObj);
     $confObj->source->config_sections = $sections;
     $confObj->source->scope = $scope;
     $confObj->compiled = Smarty_Template_Compiled::load($confObj);
     if ($confObj->smarty->debugging) {
         Smarty_Internal_Debug::start_render($confObj);
     }
     $confObj->compiled->render($confObj);
     if ($confObj->smarty->debugging) {
         Smarty_Internal_Debug::end_render($confObj);
     }
     if ($obj instanceof Smarty_Internal_Template) {
         $obj->properties['file_dependency'][$confObj->source->uid] = array($confObj->source->filepath, $confObj->source->timestamp, $confObj->source->type);
     }
 }
 /**
  * @param                         $obj
  * @param                         $config_file
  * @param null                    $sections
  * @param string                  $scope
  *
  * @throws \SmartyException
  */
 static function configLoad($obj, $config_file, $sections = null, $scope = 'local')
 {
     $smarty = isset($obj->smarty) ? $obj->smarty : $obj;
     $confObj = new $smarty->template_class($config_file, $smarty, $obj);
     $confObj->context = new Smarty_Internal_Context();
     $confObj->caching = Smarty::CACHING_OFF;
     $confObj->source = Smarty_Template_Config::load($confObj);
     $confObj->source->config_sections = $sections;
     $confObj->source->scope = $scope;
     $confObj->compiled = Smarty_Template_Compiled::load($confObj);
     if ($confObj->smarty->debugging) {
         Smarty_Internal_Debug::start_render($confObj);
     }
     $confObj->compiled->render($confObj);
     $confObj->context = null;
     if ($confObj->smarty->debugging) {
         Smarty_Internal_Debug::end_render($confObj);
     }
     if ($obj instanceof Smarty_Internal_Template && isset($obj->context)) {
         $obj->context->resourceInfo[$confObj->source->uid] = array($confObj->source->filepath, $confObj->source->timestamp, $confObj->source->type);
     } else {
         // TODO   config file dependency if loaded in Smarty, Data or Template object
     }
 }
Exemplo n.º 8
0
 function smartyDebug()
 {
     if (!defined('Smarty::SMARTY_VERSION')) {
         return;
     }
     $c = Ethna_Controller::getInstance();
     $debug_tpl = $c->getDirectory('template') . "/smarty_debug.tpl";
     //if smarty2
     //if (!file_exists($debug_tpl)) {
     //    Ethna::raiseWarning(sprintf("Smarty debug template not found, please set %s.", $debug_tpl), E_USER_WARNING);
     //    return null;
     //}
     require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_debug.php';
     // get template directory
     $r = $c->getRenderer();
     $smarty = $r->getEngine();
     $vars = Smarty_Internal_Debug::get_debug_vars($smarty);
     //$smarty_original_debugging = $smarty->debugging;
     //$smarty_original_debugtpl = $smarty->debug_tpl;
     //$smarty->debugging = true;
     //$smarty->debug_tpl = $debug_tpl;
     //$smarty->assign('_smarty_debug_output', 'html');
     echo '<div class="ethna-debug" id="ethna-debug-smartydebugwindow">';
     echo '<div class="ethna-debug-title">SmartyDebug</div>';
     echo '<div class="ethna-debug-subtitle">Smarty template vars</div>';
     echo "<div class=\"ethna-debug-log\">";
     foreach ($vars->tpl_vars as $k => $v) {
         $v = array($k => $v->value);
         self::dumpArray($v);
     }
     echo "</div> \n";
     echo '<div class="ethna-debug-subtitle">Smarty config vars</div>';
     echo "<div class=\"ethna-debug-log\">";
     foreach ($vars->config_vars as $k => $v) {
         $v = array($k => $v->value);
         self::dumpArray($v);
         //self::dumpArray($v->value);
     }
     echo "</div> \n";
     echo "</div> \n";
     echo '</div>';
     //$smarty->debugging = $smarty_original_debugging;
     //$smarty->debug_tpl = $smarty_original_debugtpl;
 }
 /**
  * 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;
                     foreach ($this->properties['file_dependency'] as $_file_to_check) {
                         $this->getResourceTypeName($_file_to_check[0], $resource_type, $resource_name);
                         if ($resource_type == 'file') {
                             $mtime = filemtime($_file_to_check[0]);
                         } else {
                             $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 Exception("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());
     }
     if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) {
         $this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']);
         $this->parent->required_plugins['compiled'] = array_merge($this->parent->required_plugins['compiled'], $this->required_plugins['compiled']);
         $this->parent->required_plugins['cache'] = array_merge($this->parent->required_plugins['cache'], $this->required_plugins['cache']);
     }
     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]);
             }
         }
         // 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($output);
         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;
         }
     }
 }
Exemplo n.º 10
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 $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;
     }
 }
 /**
  *  restore file and line offset
  */
 public function popTrace()
 {
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::end_compile($this->template);
     }
     $r = array_pop($this->trace_stack);
     $this->smarty->_current_file = $r[0];
     $this->trace_filepath = $r[1];
     $this->trace_uid = $r[2];
     $this->trace_line_offset = $r[3];
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::start_compile($this->template);
     }
 }
Exemplo n.º 12
0
 /**
  * Template code runtime function to set up an inline subtemplate
  *
  * @param string  $template the resource handle of the template file
  * @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 integer $caching cache mode
  * @param integer $cache_lifetime life time of cache data
  * @param array   $data passed parameter template variables
  * @param int     $parent_scope scope in which {include} should execute
  * @param string  $hash nocache hash code
  * @param string  $content_func name of content function
  *
  * @returns object template content
  */
 public function getInlineSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope, $hash, $content_func)
 {
     $tpl = $this->setupSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope);
     $tpl->properties['nocache_hash'] = $hash;
     if (!isset($this->smarty->template_objects[$tpl->templateId])) {
         $this->smarty->template_objects[$tpl->templateId] = $tpl;
     }
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::start_template($tpl);
         Smarty_Internal_Debug::start_render($tpl);
     }
     $tpl->properties['unifunc'] = $content_func;
     $output = $tpl->getRenderedTemplateCode();
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::end_template($tpl);
         Smarty_Internal_Debug::end_render($tpl);
     }
     if (!empty($tpl->properties['file_dependency'])) {
         $this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $tpl->properties['file_dependency']);
     }
     $this->properties['tpl_function'] = $tpl->properties['tpl_function'];
     return str_replace($tpl->properties['nocache_hash'], $this->properties['nocache_hash'], $output);
 }
 /**
  * Compiles the template
  *
  * If the template is not evaluated the compiled template is saved on disk
  */
 public function compileTemplateSource()
 {
     if (!$this->source->recompiled) {
         $this->properties['file_dependency'] = array();
         if ($this->source->components) {
             // uses real resource for file dependency
             $source = end($this->source->components);
             $this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $source->type);
         } else {
             $this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $this->source->type);
         }
     }
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::start_compile($this);
     }
     // compile locking
     if ($this->smarty->compile_locking && !$this->source->recompiled) {
         if ($saved_timestamp = $this->compiled->timestamp) {
             touch($this->compiled->filepath);
         }
     }
     // call compiler
     try {
         $code = $this->compiler->compileTemplate($this);
     } catch (Exception $e) {
         // restore old timestamp in case of error
         if ($this->smarty->compile_locking && !$this->source->recompiled && $saved_timestamp) {
             touch($this->compiled->filepath, $saved_timestamp);
         }
         throw $e;
     }
     // compiling succeded
     if (!$this->source->recompiled && $this->compiler->write_compiled_code) {
         // write compiled template
         $_filepath = $this->compiled->filepath;
         if ($_filepath === false) {
             throw new SmartyException('getCompiledFilepath() did not return a destination to save the compiled template to');
         }
         Smarty_Internal_Write_File::writeFile($_filepath, $code, $this->smarty);
         $this->compiled->exists = true;
         $this->compiled->isCompiled = true;
     }
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::end_compile($this);
     }
     // release compiler object to free memory
     unset($this->compiler);
 }
 /**
  * Method to compile Smarty config source.
  *
  * @param Smarty_Internal_Template $template
  *
  * @return bool true if compiling succeeded, false if it failed
  */
 public function compileTemplate(Smarty_Internal_Template $template)
 {
     $this->template = $template;
     $this->template->properties['file_dependency'][$this->template->source->uid] = [$this->template->source->name, $this->template->source->timestamp, $this->template->source->type];
     // on empty config just return
     if ($template->source->content == '') {
         return true;
     }
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::start_compile($this->template);
     }
     // init the lexer/parser to compile the config file
     $lex = new $this->lexer_class(str_replace(["\r\n", "\r"], "\n", $template->source->content) . "\n", $this);
     $parser = new $this->parser_class($lex, $this);
     if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) {
         $mbEncoding = mb_internal_encoding();
         mb_internal_encoding('ASCII');
     } else {
         $mbEncoding = null;
     }
     if ($this->smarty->_parserdebug) {
         $parser->PrintTrace();
     }
     // get tokens from lexer and parse them
     while ($lex->yylex()) {
         if ($this->smarty->_parserdebug) {
             echo "<br>Parsing  {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n";
         }
         $parser->doParse($lex->token, $lex->value);
     }
     // finish parsing process
     $parser->doParse(0, 0);
     if ($mbEncoding) {
         mb_internal_encoding($mbEncoding);
     }
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::end_compile($this->template);
     }
     // template header code
     $template_header = "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
     $template_header .= "         compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
     $code = '<?php Smarty_Internal_Extension_Config::loadConfigVars($_smarty_tpl, ' . var_export($this->config_data, true) . '); ?>';
     return $template_header . Smarty_Internal_Extension_CodeFrame::create($this->template, $code);
 }
Exemplo n.º 15
0
 /**
  * creates a template object
  *
  * @param  string  $template   the resource handle of the template file
  * @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  boolean $do_clone   flag is Smarty object shall be cloned
  *
  * @return object  template object
  */
 public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true)
 {
     if ($cache_id !== null && (is_object($cache_id) || is_array($cache_id))) {
         $parent = $cache_id;
         $cache_id = null;
     }
     if ($parent !== null && is_array($parent)) {
         $data = $parent;
         $parent = null;
     } else {
         $data = null;
     }
     $_templateId = $this->getTemplateId($template, $cache_id, $compile_id);
     if (isset($this->template_objects[$_templateId])) {
         if ($do_clone) {
             $tpl = clone $this->template_objects[$_templateId];
             $tpl->smarty = clone $tpl->smarty;
         } else {
             $tpl = $this->template_objects[$_templateId];
         }
         $tpl->parent = $parent;
         $tpl->tpl_vars = array();
         $tpl->config_vars = array();
     } else {
         $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id);
         if ($do_clone) {
             $tpl->smarty = clone $tpl->smarty;
         }
         $tpl->templateId = $_templateId;
     }
     // fill data if present
     if (!empty($data) && is_array($data)) {
         // set up variable values
         foreach ($data as $_key => $_val) {
             $tpl->tpl_vars[$_key] = new Smarty_Variable($_val);
         }
     }
     if ($this->debugging) {
         Smarty_Internal_Debug::register_template($tpl);
     }
     return $tpl;
 }
 /**
  *  push current file and line offset on stack for tracing {block} source lines
  * @param string $file new filename
  * @param string $uid uid of file
  * @param int $line line offset to source
  * @param bool $debug false debug end_compile shall not be called
  */
 public function pushTrace($file, $uid, $line, $debug = TRUE)
 {
     if ($this->smarty->debugging && $debug) {
         Smarty_Internal_Debug::end_compile($this->template);
     }
     array_push($this->trace_stack, [$this->smarty->_current_file, $this->trace_filepath, $this->trace_uid, $this->trace_line_offset]);
     $this->trace_filepath = $this->smarty->_current_file = $file;
     $this->trace_uid = $uid;
     $this->trace_line_offset = $line;
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::start_compile($this->template);
     }
 }
Exemplo n.º 17
0
 /**
  * Template code runtime function to set up an inline subtemplate
  *
  * @param string  $template       the resource handle of the template file
  * @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 integer $caching        cache mode
  * @param integer $cache_lifetime life time of cache data
  * @param array   $data           passed parameter template variables
  * @param         $_scope
  * @param         $parent
  * @param string  $content_func   name of content function
  *
  * @param bool    $newBuffer
  *
  * @return object template content
  */
 public function getInlineSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $_scope, $parent, $params, $newBuffer = false)
 {
     $tpl = $parent->smarty->setupTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $_scope, $parent);
     $tpl->context = $newBuffer ? new Smarty_Internal_Context() : $parent->context;
     if ($tpl->smarty->debugging) {
         Smarty_Internal_Debug::start_template($tpl);
         Smarty_Internal_Debug::start_render($tpl);
     }
     $this->getRenderedTemplateCode($tpl, $params['func']);
     if ($tpl->smarty->debugging) {
         Smarty_Internal_Debug::end_template($tpl);
         Smarty_Internal_Debug::end_render($tpl);
     }
     if ($newBuffer) {
         $output = $tpl->context->getContent();
         $tpl->context = null;
         return $output;
     }
     $tpl->context = null;
     return '';
 }
    function content_5658c1ca58b0a9_07432000($_smarty_tpl)
    {
        $_smarty_tpl->properties['nocache_hash'] = '139795658c1ca453b72_59622192';
        $_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Debug');
        Smarty_Internal_Debug::display_debug($_smarty_tpl);
        echo $_smarty_tpl->getSubTemplate("head.html", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0);
        ?>


<!--<nav>
	<ul>
		<?php 
        $_from = $_smarty_tpl->tpl_vars['items']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['item']->_loop = false;
        foreach ($_from as $_smarty_tpl->tpl_vars['item']->value) {
            $_smarty_tpl->tpl_vars['item']->_loop = true;
            $foreach_item_Sav = $_smarty_tpl->tpl_vars['item'];
            ?>
			<li><a href="<?php 
            echo $_smarty_tpl->tpl_vars['item']->value['lien'];
            ?>
"><?php 
            echo $_smarty_tpl->tpl_vars['item']->value['texte'];
            ?>
</a></li>
		<?php 
            $_smarty_tpl->tpl_vars['item'] = $foreach_item_Sav;
        }
        ?>
	</ul>
</nav>
-->
<?php 
        $_smarty_tpl->properties['nocache_hash'] = '139795658c1ca453b72_59622192';
        ?>


<form action="validation.php" method = "POST">

<p>Un seul vote par jour et par IP.</p>

<label for="categorie">Catégorie du vote :</label>
<select name="categorie" required>
	<option></option>
	<?php 
        $_from = $_smarty_tpl->tpl_vars['categories']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        $_smarty_tpl->tpl_vars['categorie'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['categorie']->_loop = false;
        foreach ($_from as $_smarty_tpl->tpl_vars['categorie']->value) {
            $_smarty_tpl->tpl_vars['categorie']->_loop = true;
            $foreach_categorie_Sav = $_smarty_tpl->tpl_vars['categorie'];
            ?>
		<option value="<?php 
            echo $_smarty_tpl->tpl_vars['categorie']->value;
            ?>
"><?php 
            echo $_smarty_tpl->tpl_vars['categorie']->value;
            ?>
</option>
	<?php 
            $_smarty_tpl->tpl_vars['categorie'] = $foreach_categorie_Sav;
        }
        ?>
</select>
<br />

<label for="positif" required>Vote :</label>
<select name="positif">
	<option></option>
	<?php 
        $_from = $_smarty_tpl->tpl_vars['matieres']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        $_smarty_tpl->tpl_vars['matiere'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['matiere']->_loop = false;
        foreach ($_from as $_smarty_tpl->tpl_vars['matiere']->value) {
            $_smarty_tpl->tpl_vars['matiere']->_loop = true;
            $foreach_matiere_Sav = $_smarty_tpl->tpl_vars['matiere'];
            ?>
	<optgroup label="<?php 
            echo $_smarty_tpl->tpl_vars['matiere']->value;
            ?>
">
		<?php 
            $_from = $_smarty_tpl->tpl_vars['profs']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            $_smarty_tpl->tpl_vars['prof'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['prof']->_loop = false;
            foreach ($_from as $_smarty_tpl->tpl_vars['prof']->value) {
                $_smarty_tpl->tpl_vars['prof']->_loop = true;
                $foreach_prof_Sav = $_smarty_tpl->tpl_vars['prof'];
                ?>
			<?php 
                ob_start();
                echo $_smarty_tpl->tpl_vars['prof']->value['matiere'];
                $_tmp1 = ob_get_clean();
                ob_start();
                echo $_smarty_tpl->tpl_vars['matiere']->value;
                $_tmp2 = ob_get_clean();
                if ($_tmp1 == $_tmp2) {
                    ?>
			<option value="<?php 
                    echo $_smarty_tpl->tpl_vars['prof']->value['id'];
                    ?>
"><?php 
                    echo $_smarty_tpl->tpl_vars['prof']->value['nom'];
                    ?>
</option>
			<?php 
                }
                ?>
		<?php 
                $_smarty_tpl->tpl_vars['prof'] = $foreach_prof_Sav;
            }
            ?>
	</optgroup>
	<?php 
            $_smarty_tpl->tpl_vars['matiere'] = $foreach_matiere_Sav;
        }
        ?>
</select>

<input type="submit" />
</form>


<?php 
        echo $_smarty_tpl->getSubTemplate("footer.html", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 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 (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;
     }
 }
Exemplo n.º 20
0
 /**
  * Same as flush() but with optional debugging.
  * @see Template::flush()
  */
 function p()
 {
     $this->flush();
     if ($this->smarty->debugging) {
         global $t2;
         $this->smarty->assign(array('AAAA_DEBUG_TOTAL_TIME__' => get_elapsed_time($t2, get_moment())));
         Smarty_Internal_Debug::display_debug($this->smarty);
     }
 }
 /**
  * Compile saved child block source
  *
  * @param object $compiler  compiler object
  * @param string $_name     optional name of child block
  * @return string   compiled code of child block
  */
 static function compileChildBlock($compiler, $_name = null)
 {
     if ($compiler->inheritance_child) {
         $name1 = Smarty_Internal_Compile_Block::$nested_block_names[0];
         if (isset($compiler->template->block_data[$name1])) {
             //  replace inner block name with generic
             Smarty_Internal_Compile_Block::$block_data[$name1]['source'] .= $compiler->template->block_data[$name1]['source'];
             Smarty_Internal_Compile_Block::$block_data[$name1]['child'] = true;
         }
         $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBLOCK);
         $compiler->has_code = false;
         return;
     }
     // if called by {$smarty.block.child} we must search the name of enclosing {block}
     if ($_name == null) {
         $stack_count = count($compiler->_tag_stack);
         while (--$stack_count >= 0) {
             if ($compiler->_tag_stack[$stack_count][0] == 'block') {
                 $_name = trim($compiler->_tag_stack[$stack_count][1][0]['name'], "\"'");
                 break;
             }
         }
     }
     if ($_name == null) {
         $compiler->trigger_template_error(' tag {$smarty.block.child} used outside {block} tags ', $compiler->lex->taglineno);
     }
     // undefined child?
     if (!isset($compiler->template->block_data[$_name]['source'])) {
         $compiler->popTrace();
         return '';
     }
     // flag that child is already compile by {$smarty.block.child} inclusion
     $compiler->template->block_data[$_name]['compiled'] = true;
     $_tpl = new Smarty_Internal_template('string:' . $compiler->template->block_data[$_name]['source'], $compiler->smarty, $compiler->template, $compiler->template->cache_id,
         $compiler->template->compile_id, $compiler->template->caching, $compiler->template->cache_lifetime);
     if ($compiler->smarty->debugging) {
         Smarty_Internal_Debug::ignore($_tpl);
     }
     $_tpl->tpl_vars = $compiler->template->tpl_vars;
     $_tpl->variable_filters = $compiler->template->variable_filters;
     $_tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash'];
     $_tpl->allow_relative_path = true;
     $_tpl->compiler->inheritance = true;
     $_tpl->compiler->suppressHeader = true;
     $_tpl->compiler->suppressFilter = true;
     $_tpl->compiler->suppressTemplatePropertyHeader = true;
     $_tpl->compiler->suppressMergedTemplates = true;
     $nocache = $compiler->nocache || $compiler->tag_nocache;
     if (strpos($compiler->template->block_data[$_name]['source'], self::parent) !== false) {
         $_output = str_replace(self::parent, $compiler->parser->current_buffer->to_smarty_php(), $_tpl->compiler->compileTemplate($_tpl, $nocache));
     } elseif ($compiler->template->block_data[$_name]['mode'] == 'prepend') {
         $_output = $_tpl->compiler->compileTemplate($_tpl, $nocache) . $compiler->parser->current_buffer->to_smarty_php();
     } elseif ($compiler->template->block_data[$_name]['mode'] == 'append') {
         $_output = $compiler->parser->current_buffer->to_smarty_php() . $_tpl->compiler->compileTemplate($_tpl, $nocache);
     } elseif (!empty($compiler->template->block_data[$_name])) {
         $_output = $_tpl->compiler->compileTemplate($_tpl, $nocache);
     }
     $compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $_tpl->properties['file_dependency']);
     $compiler->template->properties['function'] = array_merge($compiler->template->properties['function'], $_tpl->properties['function']);
     $compiler->merged_templates = array_merge($compiler->merged_templates, $_tpl->compiler->merged_templates);
     $compiler->template->variable_filters = $_tpl->variable_filters;
     if ($_tpl->has_nocache_code) {
         $compiler->template->has_nocache_code = true;
     }
     foreach ($_tpl->required_plugins as $key => $tmp1) {
         if ($compiler->nocache && $compiler->template->caching) {
             $code = 'nocache';
         } else {
             $code = $key;
         }
         foreach ($tmp1 as $name => $tmp) {
             foreach ($tmp as $type => $data) {
                 $compiler->template->required_plugins[$code][$name][$type] = $data;
             }
         }
     }
     unset($_tpl);
     $compiler->has_code = true;
     return $_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;
     }
     $_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) {
                 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) {
                         $_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());
                     $_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\'; ?>', $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($this);
         }
         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
  * @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 '';
 }
Exemplo n.º 25
0
 /**
  * create Cached Object container
  *
  * @param Smarty_Internal_Template $_template template object
  */
 public function __construct(Smarty_Internal_Template $_template)
 {
     $this->compile_id = $_template->compile_id;
     $this->cache_id = $_template->cache_id;
     $this->source = $_template->source;
     $_template->cached = $this;
     $smarty = $_template->smarty;
     //
     // load resource handler
     //
     $this->handler = $handler = Smarty_CacheResource::load($smarty);
     // Note: prone to circular references
     //
     //    check if cache is valid
     //
     if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || $_template->source->recompiled) {
         $handler->populate($this, $_template);
         return;
     }
     while (true) {
         while (true) {
             $handler->populate($this, $_template);
             if ($this->timestamp === false || $smarty->force_compile || $smarty->force_cache) {
                 $this->valid = false;
             } else {
                 $this->valid = true;
             }
             if ($this->valid && $_template->caching == Smarty::CACHING_LIFETIME_CURRENT && $_template->cache_lifetime >= 0 && time() > $this->timestamp + $_template->cache_lifetime) {
                 // lifetime expired
                 $this->valid = false;
             }
             if ($this->valid || !$_template->smarty->cache_locking) {
                 break;
             }
             if (!$this->handler->locked($_template->smarty, $this)) {
                 $this->handler->acquireLock($_template->smarty, $this);
                 break 2;
             }
         }
         if ($this->valid) {
             if (!$_template->smarty->cache_locking || $this->handler->locked($_template->smarty, $this) === null) {
                 // load cache file for the following checks
                 if ($smarty->debugging) {
                     Smarty_Internal_Debug::start_cache($_template);
                 }
                 if ($handler->process($_template, $this) === false) {
                     $this->valid = false;
                 } else {
                     $this->processed = true;
                 }
                 if ($smarty->debugging) {
                     Smarty_Internal_Debug::end_cache($_template);
                 }
             } else {
                 continue;
             }
         } else {
             return;
         }
         if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED && $_template->properties['cache_lifetime'] >= 0 && time() > $_template->cached->timestamp + $_template->properties['cache_lifetime']) {
             $this->valid = false;
         }
         if (!$this->valid && $_template->smarty->cache_locking) {
             $this->handler->acquireLock($_template->smarty, $this);
             return;
         } else {
             return;
         }
     }
 }
 /**
  * Opens a window for the Smarty Debugging Console and display the data
  *
  * @param Smarty_Internal_Template|Smarty $obj object to debug
  * @param bool                            $full
  */
 public static function display_debug($obj, $full = false)
 {
     if (!$full) {
         self::$offset++;
         $savedIndex = self::$index;
         self::$index = 9999;
     }
     // prepare information of assigned variables
     $ptr = self::get_debug_vars($obj);
     if ($obj instanceof Smarty) {
         $smarty = clone $obj;
     } else {
         $smarty = clone $obj->smarty;
     }
     $debugging = $smarty->debugging;
     $_assigned_vars = $ptr->tpl_vars;
     ksort($_assigned_vars);
     $_config_vars = $ptr->config_vars;
     ksort($_config_vars);
     $smarty->registered_filters = array();
     $smarty->autoload_filters = array();
     $smarty->default_modifiers = array();
     $smarty->force_compile = false;
     $smarty->left_delimiter = '{';
     $smarty->right_delimiter = '}';
     $smarty->debugging = false;
     $smarty->debugging_ctrl = 'NONE';
     $smarty->force_compile = false;
     $_template = new Smarty_Internal_Template($smarty->debug_tpl, $smarty);
     $_template->caching = false;
     $_template->smarty->disableSecurity();
     $_template->cache_id = null;
     $_template->compile_id = null;
     if ($obj instanceof Smarty_Internal_Template) {
         $_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
     }
     if ($obj instanceof Smarty || $full) {
         $_template->assign('template_data', self::$template_data[self::$index]);
     } else {
         $_template->assign('template_data', null);
     }
     $_template->assign('assigned_vars', $_assigned_vars);
     $_template->assign('config_vars', $_config_vars);
     $_template->assign('execution_time', microtime(true) - $smarty->start_time);
     $_template->assign('display_mode', $debugging == 2 || !$full);
     $_template->assign('offset', self::$offset * 50);
     echo $_template->fetch();
     if (isset($full)) {
         self::$index--;
     }
     if (!$full) {
         self::$index = $savedIndex;
     }
 }
Exemplo n.º 27
0
 /**
  * Returns the rendered HTML output 
  * 
  * If the cache is valid the cached content is used, otherwise
  * the output is rendered from the compiled template or PHP template source
  * 
  * @return string rendered HTML output
  */
 public function getRenderedTemplate()
 {
     // disable caching for evaluated code
     if ($this->resource_object->isEvaluated) {
         $this->caching = false;
     }
     // checks if template exists
     $this->isExisting(true);
     // read from cache or render
     if ($this->rendered_content === null) {
         if ($this->isCached) {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_cache($this);
             }
             $this->rendered_content = $this->cache_resource_object->getCachedContents($this, false);
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_cache($this);
             }
         }
         if ($this->isCached === null) {
             $this->isCached(false);
         }
         if (!$this->isCached) {
             // render template (not loaded and not in cache)
             $this->renderTemplate();
         }
     }
     $this->updateParentVariables();
     $this->isCached = null;
     return $this->rendered_content;
 }
Exemplo n.º 28
0
 /**
  * displays a Smarty template
  * 
  * @param string $ |object $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
  */
 public function display($template, $cache_id = null, $compile_id = null, $parent = null)
 {
     // display template
     echo $this->fetch($template, $cache_id, $compile_id, $parent);
     // debug output
     if ($this->debugging) {
         Smarty_Internal_Debug::display_debug($this);
     }
     return true;
 }
Exemplo n.º 29
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;
     }
 }
Exemplo n.º 30
0
 /**
  * Check if cache is valid, lock cache if required
  *
  * @param \Smarty_Internal_Template $_template
  *
  * @return bool flag true if cache is valid
  */
 public function isCached(Smarty_Internal_Template $_template)
 {
     if ($this->valid !== null) {
         return $this->valid;
     }
     while (true) {
         while (true) {
             if ($this->exists === false || $_template->smarty->force_compile || $_template->smarty->force_cache) {
                 $this->valid = false;
             } else {
                 $this->valid = true;
             }
             if ($this->valid && $_template->caching == Smarty::CACHING_LIFETIME_CURRENT && $_template->cache_lifetime >= 0 && time() > $this->timestamp + $_template->cache_lifetime) {
                 // lifetime expired
                 $this->valid = false;
             }
             if ($this->valid && $_template->source->timestamp > $this->timestamp) {
                 $this->valid = false;
             }
             if ($this->valid || !$_template->smarty->cache_locking) {
                 break;
             }
             if (!$this->handler->locked($_template->smarty, $this)) {
                 $this->handler->acquireLock($_template->smarty, $this);
                 break 2;
             }
             $this->handler->populate($this, $_template);
         }
         if ($this->valid) {
             if (!$_template->smarty->cache_locking || $this->handler->locked($_template->smarty, $this) === null) {
                 // load cache file for the following checks
                 if ($_template->smarty->debugging) {
                     Smarty_Internal_Debug::start_cache($_template);
                 }
                 if ($this->handler->process($_template, $this) === false) {
                     $this->valid = false;
                 } else {
                     $this->processed = true;
                 }
                 if ($_template->smarty->debugging) {
                     Smarty_Internal_Debug::end_cache($_template);
                 }
             } else {
                 $this->is_locked = true;
                 continue;
             }
         } else {
             return $this->valid;
         }
         if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED && $_template->properties['cache_lifetime'] >= 0 && time() > $_template->cached->timestamp + $_template->properties['cache_lifetime']) {
             $this->valid = false;
         }
         if ($_template->smarty->cache_locking) {
             if (!$this->valid) {
                 $this->handler->acquireLock($_template->smarty, $this);
             } elseif ($this->is_locked) {
                 $this->handler->releaseLock($_template->smarty, $this);
             }
         }
         return $this->valid;
     }
     return $this->valid;
 }