Author Topic: UNEXPECTED T-STRING error resolved  (Read 44252 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
UNEXPECTED T-STRING error resolved
« Reply #15 on: June 13, 2003, 02:41:58 PM »
maybe for now, untill someone figures this out, try use ' instead of '
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline NoBob

  • Newbie
  • *
  • Posts: 47
    • View Profile
UNEXPECTED T-STRING error resolved
« Reply #16 on: June 13, 2003, 05:29:17 PM »
Don't get it. If I put &apos, for example, "didn&apost do it", then it appears as just that on the public page. Sorry, I've missed something I think. Could you explain, please?

Best, NoBob.
words&pictures

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
UNEXPECTED T-STRING error resolved
« Reply #17 on: June 13, 2003, 05:39:17 PM »
You missed the semicolon.  Try:
Code: [Select]
didn't do it

Offline NoBob

  • Newbie
  • *
  • Posts: 47
    • View Profile
UNEXPECTED T-STRING error resolved
« Reply #18 on: June 13, 2003, 06:04:55 PM »
Oops. But tried that too now. On the public page it just says "didn't do it".

I'm putting this in the Edit categories section, where it says "Description
HTML allowed." I'm changing this in the right place, yeah?

Best, NoBob.

words&pictures

Offline www.girls-on-bikes.com

  • Full Member
  • ***
  • Posts: 145
    • View Profile
    • http://www.girls-on-bikes.com/
UNEXPECTED T-STRING error resolved
« Reply #19 on: June 13, 2003, 06:27:22 PM »
I've noticed that the template I use from www.vierstra.com has slightly different code that from the original.

Offline NoBob

  • Newbie
  • *
  • Posts: 47
    • View Profile
UNEXPECTED T-STRING error resolved
« Reply #20 on: June 13, 2003, 06:32:52 PM »
Me too. 4bare.

NoBob.
words&pictures

Offline JoePCFX

  • Pre-Newbie
  • Posts: 9
    • View Profile
    • http://joe.pcfx.cc
UNEXPECTED T-STRING error resolved
« Reply #21 on: June 13, 2003, 10:11:59 PM »
Yeah, I'm using his 4_no_rand template for my design. But I searched the default templates and I cant find htmlspecialchars either.

Offline www.girls-on-bikes.com

  • Full Member
  • ***
  • Posts: 145
    • View Profile
    • http://www.girls-on-bikes.com/
UNEXPECTED T-STRING error resolved
« Reply #22 on: June 13, 2003, 10:14:32 PM »
The php command htmlspecialchars would be located in the php files, not the html template files.  I'm at work so I can't check to give you an example of where they are located, but I know it's in a lot of the php files.

Offline NoBob

  • Newbie
  • *
  • Posts: 47
    • View Profile
UNEXPECTED T-STRING error resolved
« Reply #23 on: June 14, 2003, 12:42:56 AM »
Well,

The error I got mentions this code, which starts at line 133 in includes/template.php:  

   eval($code);
    }
    else {
      $code = preg_replace("/<\[\?|%](php|=)+( \r\n)*(.*)[\?|%]>/siU", "", $template);
      echo $code;
    }
  }

  function exec_php_code($code) {
    $code = str_replace('\\', '\\\\', $code);
    $code = str_replace('\'', '\\\'', $code);
    $new_lines = array();
    $is_code = 0;
    $lines = explode("\n", $code);
    foreach ($lines as $line) {
      //$line = trim($line);
      if (preg_match('/<[\?|%](php|=)+/', $line, $regs)) {
        $line = preg_replace('/<[\?|%](php|=)?/i', '', $line);
        $line = ((!empty($regs[1]) && $regs[1] == "=") ? "echo " : "").$line;
        $is_code = 1;
      }
      if ($is_code) {
        $line = str_replace ('\\\'', '\'', $line);
        $line = str_replace ('\\\\', '\\', $line);
        if (preg_match('/[\?|%]>/', $line)) {
          $line = preg_replace('/[\?|%]>/', '', $line);
          $is_code = 0;
        }
      }
      else {
        $line = 'echo \''.$line.'\'."\\n";';
      }
      $new_lines[] = $line;
    }
    return implode("\n", $new_lines);
  }

  function clean_template($template) {
    $search_array = array(
      "/".$this->start."[^ \t\r\n".$this->end."]+".$this->end."/",
      "/".$this->start."if[ \t\r\n]+[^ \t\r\n".$this->end."]+".$this->end."/",
      "/".$this->start."endif[ \t\r\n]+[^ \t\r\n".$this->end."]+".$this->end."/",
      "/&#36;([0-9])/",
      "/&#92;([0-9])/"
    );
    $replace_array = array(
      "",
      "",
      "",
      '$\1',
      '\\\1'
    );
    $template = preg_replace($search_array, $replace_array, $template);
    return $template;
  }

  function error($errmsg, $halt = 0) {
    if (!$this->no_error) {
      echo "<br /><font color='#FF0000'><b>Template Error</b></font>: ".$errmsg."<br />";
      if ($halt) {
        exit;
      }
    }
  }
} // end of class
?>

This is just semi-colons and curly brackets to me, but maybe someone can see something. I found htmlspecialchars in other php files, but it's not in this php file.

NoBob.

Offline www.girls-on-bikes.com

  • Full Member
  • ***
  • Posts: 145
    • View Profile
    • http://www.girls-on-bikes.com/
UNEXPECTED T-STRING error resolved
« Reply #24 on: June 14, 2003, 03:19:39 AM »
The error your getting isn't in "that" file, it's in the file that's being passed to template, which is a .html file, which has an apostrophe.

Just so you can compare, here is my template.php from 133 on:
Code: [Select]
eval($code);
    }
    else {
      $code = preg_replace("/<\[\?|%](php|=)+( \r\n)*(.*)[\?|%]>/siU", "", $template);
      echo $code;
    }
  }

  function exec_php_code($code) {
    $code = str_replace('\\', '\\\\', $code);
    $code = str_replace('\'', '\\\'', $code);
    $new_lines = array();
    $is_code = 0;
    $lines = explode("\n", $code);
    foreach ($lines as $line) {
      //$line = trim($line);
      if (preg_match('/<[\?|%](php|=)+/', $line, $regs)) {
        $line = preg_replace('/<[\?|%](php|=)?/i', '', $line);
        $line = ((!empty($regs[1]) && $regs[1] == "=") ? "echo " : "").$line;
        $is_code = 1;
      }
      if ($is_code) {
        $line = str_replace ('\\\'', '\'', $line);
        $line = str_replace ('\\\\', '\\', $line);
        if (preg_match('/[\?|%]>/', $line)) {
          $line = preg_replace('/[\?|%]>/', '', $line);
          $is_code = 0;
        }
      }
      else {
        $line = 'echo \''.$line.'\'."\\n";';
      }
      $new_lines[] = $line;
    }
    return implode("\n", $new_lines);
  }

  function clean_template($template) {
    $search_array = array(
      "/".$this->start."[^ \t\r\n".$this->end."]+".$this->end."/",
      "/".$this->start."if[ \t\r\n]+[^ \t\r\n".$this->end."]+".$this->end."/",
      "/".$this->start."endif[ \t\r\n]+[^ \t\r\n".$this->end."]+".$this->end."/",
      "/&#36;([0-9])/",
      "/&#92;([0-9])/"
    );
    $replace_array = array(
      "",
      "",
      "",
      '$\1',
      '\\\1'
    );
    $template = preg_replace($search_array, $replace_array, $template);
    return $template;
  }

  function error($errmsg, $halt = 0) {
    if (!$this->no_error) {
      echo "<br /><font color='#FF0000'><b>Template Error</b></font>: ".$errmsg."<br />";
      if ($halt) {
        exit;
      }
    }
  }
} // end of class

Offline NoBob

  • Newbie
  • *
  • Posts: 47
    • View Profile
UNEXPECTED T-STRING error resolved
« Reply #25 on: June 14, 2003, 09:30:41 AM »
Just to check, the wrong code is in the html file that's being passed to template.php?

I see this
 $site_template->register_vars(array(
  "categories" => get_categories($cat_id),
  "cat_name" => htmlspecialchars($cat_cache[$cat_id]['cat_name']),
  "cat_description" => $cat_cache[$cat_id]['cat_description'],

in categories.php.

Anyone who wrote this gallery have any more ideas?

NoBob.
words&pictures

Offline www.girls-on-bikes.com

  • Full Member
  • ***
  • Posts: 145
    • View Profile
    • http://www.girls-on-bikes.com/
UNEXPECTED T-STRING error resolved
« Reply #26 on: June 14, 2003, 08:21:20 PM »
Here is my entire show categories section in categories.php (that's what you were having trouble with, right?  When it displays the category text):

Code: [Select]
//-----------------------------------------------------
//--- Show Categories ---------------------------------
//-----------------------------------------------------
if (!check_permission("auth_upload", $cat_id)) {
  $upload_url = "";
  $upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
}
else {
  $upload_url = $site_sess->url(ROOT_PATH."member.php?action=uploadform&amp;".URL_CAT_ID."=".$cat_id);
  $upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
}

$random_cat_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" : get_random_image($cat_id);
$site_template->register_vars(array(
  "categories" => get_categories($cat_id),
  "cat_name" => htmlspecialchars($cat_cache[$cat_id]['cat_name']),
  "cat_description" => $cat_cache[$cat_id]['cat_description'],
  "cat_hits" => $cat_cache[$cat_id]['cat_hits'],
  "upload_url" => $upload_url,
  "upload_button" => $upload_button,
  "random_cat_image" => $random_cat_image
));

unset($random_cat_image);

Offline NoBob

  • Newbie
  • *
  • Posts: 47
    • View Profile
UNEXPECTED T-STRING error resolved
« Reply #27 on: June 16, 2003, 05:32:53 PM »
I've reached a dead end here. I was hoping that someone in the know would see something in the code we've posted. It seems like we're now the only ones interested in solving this problem.

NoBob.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
UNEXPECTED T-STRING error resolved
« Reply #28 on: June 16, 2003, 09:59:52 PM »
Quote from: NoBob
It seems like we're now the only ones interested in solving this problem.

not many people have this problem, maybe u are the only people who actualy have this problem...
it might be related to PHP configuration (just curious, is "Magick quotes" turned on at your host? can u see it in phpinfo() ?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline JoePCFX

  • Pre-Newbie
  • Posts: 9
    • View Profile
    • http://joe.pcfx.cc
UNEXPECTED T-STRING error resolved
« Reply #29 on: June 16, 2003, 11:43:41 PM »
For me magic quotes are enabled: I get this in phpinfo:

magic_quotes_gpc On On
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off

Quote
The php command htmlspecialchars would be located in the php files, not the html template files. I'm at work so I can't check to give you an example of where they are located, but I know it's in a lot of the php files.


So if thats the case, why are we getting this error if we havent modified (well I havent) the .php files if they arent in the templates? If the templates dont have anything to do with this issue how is it messing up for some of us?

Looks like I gotta work on a whole new template if I cant fix it because I really worked hard on the style I based off 4_no_rand.