4images Forum & Community
4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: NoBob on June 10, 2003, 12:38:44 AM
-
Thought I'd pass on some info about solving an UNEXPECTED T-STRING ERROR message I got on my gallery home page.
The story:
I set up the templates and changed the look of the site, added the categories and then ftd'd the images into the numbered folders. Then I started to 'check new images' and add them. While I began by hitting the 'Go to the gallery home page' each time I added them, after a while I just added them and moved onto the next category. To my horror I got an 'UNEXPECTED T-STRING ERROR in...template.php(133)...when I next checked the home page. Luckily I still had a previous gallery window open that showed the categories and I could move around the site - but not the home page. Eventually I found that the last pictures I'd added to a category called 'Nice's old port' were giving the T-STRING ERROR as well. So I deleted the category and tried again. Still the same problem. So, I changed the name of the category to 'Nice old port' and everything worked - works - okay. To cut an already long story short, it seems as if an 's was the problem. Hope this helps someone. My advice - don't close an old gallery window until the updated one appears okay. And back up soon and often.
Best, NoBob.
-
Just to check your theory, I created new category with name 'Nice's old port', uploaded new images, went to index.php and....nothing happend, no error messages. Not sure why u got that error.
-
I just changed the category name back to 'Nice's old port' and got 'Parse error: parse error, unexpected T_STRING in /usr/local/psa/home/vhosts/rtwtravel.com/httpdocs/gallery/includes/template.php(133) : eval()'d code on line 190' on the home page. Got rid of the 's again and everything is fine. The results: www.rtwtravel.com/gallery/index.php
Best, NoBob.
-
The actual cause of this error is having a ' in the name. The php code does not know how to handle the ' and it tra-la-las it up. I have this same issue anytime someone uploads a image and puts a ' in the title of the image. Only mod iv'e installed is the user upload limit/time limit mod.
-
Hi omp,
Yeah, I thought of going back and trying different variations - with just an apostrophe, just a space and an s, etc - to see if it was really both the ' and the s that were causing the problem, but didn't get time. You've answered that for me. Thanks.
NoBob.
-
did u guys remove htmlspecialchars(...); from the code? if u didnt then this error just shouldt happend, 4images uses this function that convers all quotes into " - into HTML codes.
personaly I've never had this problem, even though I have categorie, images and users with single quotes in the name.
And the only problem I had was when I installed first version of Slide show mod. but that's different story.
-
Nope, not me - well, don't think so, anyway. Could you tell me where htmlspecialchars(...); is?
Best, NoBob.
-
Nope, not me - well, don't think so, anyway. Could you tell me where htmlspecialchars(...); is?
Best, NoBob.
everywhere ;)
-
Okay, I give up. I've just looked for htmlspecialchars in three templates (header, home and details) and the index.php file. If it's everywhere, then it's cloaked somehow.
Best, NoBob.
-
It's mostly used in the php files found in the includes directories. There are many more php files than index.php
-
I'm certain I haven't deleted that code - not knowingly anyway. I've carefully changed bits of code in header, home, details, searchbox, index, click_incl, just to change the look, but that's it.
Best, NoBob.
words&pictures (http://www.rtwtravel.com)
-
I just got this error a few minutes ago for the first time. I had a ' in 2 album's descriptions. Got rid of them, and it works now. I've ALWAYS had the ' in there with no problem, so why is it all the sudden messing up?
I've never touched php templates, and the htmlspecialchar is all there.
-
bump
-
Just my .02 where it don't belong.
I've noticed some templates (template writers) change up code, including htmlspecialchars(...); (i.e. removing it)
I have a feeling this is where this problem originated.
-
I was careful not to put an apostrophe in a category's name, but then this morning I put one in the description, and got the same parse error. Will I never be able to use an apostrophe again? I haven't touched any special characters code. Would really like to find the solution to this problem.
www.girls-on-bikes.com, would you mind explaining what you mean about code writers? Which templates have you noticed getting affected?
Thanks.
Best, NoBob.
words&pictures (http://www.rtwtravel.com)
-
maybe for now, untill someone figures this out, try use ' instead of '
-
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 (http://www.rtwtravel.com)
-
You missed the semicolon. Try:
didn't do it
-
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 (http://www.rtwtravel.com)
-
I've noticed that the template I use from www.vierstra.com has slightly different code that from the original.
-
Me too. 4bare.
NoBob.
words&pictures (http://www.rtwtravel.com)
-
Yeah, I'm using his 4_no_rand template for my design. But I searched the default templates and I cant find htmlspecialchars either.
-
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.
-
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."/",
"/$([0-9])/",
"/\([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.
-
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:
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."/",
"/$([0-9])/",
"/\([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
-
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 (http://www.rtwtravel.com)
-
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):
//-----------------------------------------------------
//--- 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&".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);
-
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.
-
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() ?
-
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
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.
-
V@no,
I've got
magic_quotes_gpc On On
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
NoBob.
-
magic_quotes changes anything...just tryed myself..
but if u use default template, do u get same error message? (lets go from here ;))
-
Just tried the default template and everything works okay.
I get these errors when using 4bare.
"Nice's old port" as category name. Error on home page:
Parse error: parse error, unexpected T_STRING in /usr/local/psa/home/vhosts/rtwtravel.com/httpdocs/gallery/includes/template.php(133) : eval()'d code on line 208
"Nice's old port" is in the description. When arrive at the category page through clickstream from home page, this is the error:
Parse error: parse error, unexpected T_STRING in /usr/local/psa/home/vhosts/rtwtravel.com/httpdocs/gallery/includes/template.php(133) : eval()'d code on line 95
When the apostrphe is in both the category name and the description, the error is:
Parse error: parse error, unexpected T_STRING in /usr/local/psa/home/vhosts/rtwtravel.com/httpdocs/gallery/includes/template.php(133) : eval()'d code on line 208
NoBob.
-
That pretty much proves it right there, a lot of these templates are modified, and as you can see, they don't deal with special characters well.
Kind of a bummer :(
-
There must be a solution.
NoBob.
-
There is, pinpoint exactly which file is causing the error, and re-write the way that file deals with htmlspecialchars.
It's not easy if you don't know PHP well, but that is the basic solution.
-
Just tried the default template and everything works okay.
if there is something wrong with the template, then I'd first compare it with default, for {...} tags, and maybe syntaxis.
-
Does it matter that there are a mix of single and double quotes in 4bare's categories.html template?
<?php
$cl = '{clickstream}';
$uti = "{url_top_images}";
$lti = "{lang_top_images}";
$uni = "{url_new_images}";
$lni = "{lang_new_images}";
require "{template_url}/incl/click_incl.php";
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php
$cn = '{cat_name}';
$cd = '{cat_description}';
$ch = '{cat_hits}';
require "{template_url}/incl/cat_incl.php";
NoBob
-
I think so, because when {...} tags get replaced by its value, its also strip slashes, so in your case u'll get:
$cd = 'Nice's old port';
and that gives error message.
-
I tried replacing the single quotes around {cat_name} and {cat_description} with doubles, but that just generated error messages too. Anyway to re-write it?
NoBob
-
first off all, this is not a right way to do anything in the templates...
but anyway, then try find something like:"cat_description" => $some_variable_name
and replace it with:"cat_description" => htmlspecialchars($some_variable_name)
-
Good, good, good, we're halfway there...In categories.php, I made the changes to cat_description and now I can use an apostrophe in the description. But htmlspecialchars has always been there after cat_name, and I still get an error if I use an apostrophe in the category name. How's that work for you JoePCFX? You were having problems with descriptions.
Code now:
"cat_name" => htmlspecialchars($cat_cache[$cat_id]['cat_name']),
"cat_description" => htmlspecialchars($cat_cache[$cat_id]['cat_description']),
NoBob.
-
bump
-
Nothing works here, using 4_no_rand yet. Maybe Im just appying the code wrong though.
-
This may be a shot in the dark, but what if you try putting the HTML code version of the apostrophy where you enter in the category name, for example:
Blah Blah Don't
May be worth a try, but it doesn't solve the underlying problem.
-
That's clever! It works. Thank you.
Used "Nice's old port" in the category description and it comes up on the public page as "Nice's old port", with no error message.
(http://www.rtwtravel.com/gallery) When you go back to Edit Categories, though, you have to remember to put in ' again, otherwise you'll get another error. It also seems to have an adverse effect on css no text decoration script on the page. Best to have a separate style sheet uploaded.
http://www.rtwtravel.com/gallery/
Thanks. But you're right, it still doesn't solve the underlying problem.
Best, NoBob
-
Too bad. Vierstra.com has some nice templates. I even use one on one of my sites. But another site I have needs to have apostrophes in the Category names.
Any other template makers have this problem or is it just the ones at Vierstra.com?
Terry