Author Topic: 1.7.2 - html in image description  (Read 14864 times)

0 Members and 1 Guest are viewing this topic.

Offline max.cady

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
1.7.2 - html in image description
« on: March 09, 2006, 06:47:41 AM »
Hi,
in version 1.7.1 I could use keywords which consist of two words by linking them together with the html code for non-breaking space " " .. then both words counted as one keyword.

Now it looks as if 1.7.2 does not accept this html sign anymore. It doesn't accept the unicode either.

Can I change it in a way that I can use the html code for non breaking space again?

Thanks in advance  :mrgreen:

« Last Edit: June 26, 2006, 05:26:43 PM by kai »

Offline max.cady

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Re: 4.7.2 - html in image description
« Reply #1 on: March 09, 2006, 11:02:00 PM »
Nobody any idea?

I know I could use the underline to make a space between two keywords that belong together but then the search in keywords would not work properly.

If I have the keyword "Alfred_Hitchcock" and somebody would do an advanced search for Hitchcock in keywords no results would show up if I use the underline between first name and second name.

In version 4.7.1 I could use   and first and second name would stick together. This is not possible in 4.7.2 any more.

Any way to change it back?

Thanks for any tips in advance ...

Offline max.cady

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Re: 4.7.2 - html in image description
« Reply #2 on: March 10, 2006, 06:56:52 AM »
Have solved the problem by my own ...  :mrgreen:

I have installed the extended checknewimages.php from veno's galery as well as the advanced images.php

http://gallery.vano.org/en/file28dl   (update checknewimages.php)

http://gallery.vano.org/en/file41dl   (update images.php including batch copy/move/edit)

Now the keywords are no problem anymore.

Just a suggestion ... why not including those updated images.php / checknewimages.php in the new 4images-release?

And while we are at it ...  why not including the updated paging.php as well? (especially since this new paging.php is a requirement for many mods)

http://gallery.vano.org/en/file18dl (updted paging.php)




Offline yerpo

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: 1.7.2 - html in image description
« Reply #3 on: March 11, 2006, 03:56:25 PM »
I have another related problem: category and image names in my gallery are latin, so I want them to be in italic. There was an issue with this in 1.7.1 too, but I applied a fix ( http://www.4homepages.de/forum/index.php?topic=2560.0 ) to files details.php, top.php, postcards.php & categories.php and it worked perfectly.

Then I upgraded to 1.7.2 and now some names are displayed correctly, where in some the tags for Italic are printed. It's difficult to explain without knowing how the code is organised, but it looks like only subcategory names are displayed correctly. You can check it yourself here: http://foto.biologija.org/4images/index.php . The aforementioned fix doesn't work, because there's no htmlspecialchars occurence in those files anymore.

Please, help quick, as my gallery is supposed to be released in public next week.

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
Re: 4.7.2 - html in image description
« Reply #4 on: March 11, 2006, 06:04:20 PM »
in includes functions.php find:
Code: [Select]
      "cat_name" => format_text($cat_cache[$category_id]['cat_name'], 0), replace with:
Code: [Select]
      "cat_name" => format_text($cat_cache[$category_id]['cat_name'], 1),
P.S. next time, please attach a screenshot of the page. That way once you fixed it, people reading your post will still have an idea what you were talking about ;)
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 yerpo

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: 4.7.2 - html in image description
« Reply #5 on: March 11, 2006, 06:28:12 PM »
Thanks for the prompt response!

Here's the screenshot:


I did what you said, but it only solved the issue of subcategories. Then I did the same in corresponding lines for Image name so it now reads:

Code: [Select]
"image_name" => format_text($image_row['image_name'], 1),
But I can't find the line that would fix the top level category name (the one that says <i>Plantae</i> rastline on the screenshot). Where would that be?
« Last Edit: June 22, 2006, 05:31:10 PM by yerpo »

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
Re: 4.7.2 - html in image description
« Reply #6 on: March 11, 2006, 06:41:23 PM »
Its in categories.php
Code: [Select]
  "cat_name" => format_text($cat_cache[$cat_id]['cat_name'], 0),
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 yerpo

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: 4.7.2 - html in image description
« Reply #7 on: March 11, 2006, 06:53:42 PM »
Ah, ok, I thought that code in those files was more sensitive to changes. Anyway, to get rid of all HTML tags I also made the following changes in details.php

Code: [Select]
  OLD
  $prev_image_name = format_text($next_prev_cache[$prev_image_id]['image_name']);
  NEW
  $prev_image_name = format_text($next_prev_cache[$prev_image_id]['image_name'], 1);
 
  OLD
  $next_image_name = format_text($next_prev_cache[$prev_image_id]['image_name']);
  NEW
  $next_image_name = format_text($next_prev_cache[$prev_image_id]['image_name'], 1);
 
  OLD
  $image_name = format_text($image_row['image_name']);
  NEW
  $image_name = format_text($image_row['image_name'], 1);

I think that should be all. Please warn me if I did something I shouldn't and thanks again for help.

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
Re: 4.7.2 - html in image description
« Reply #8 on: March 11, 2006, 07:02:11 PM »
If you allow other people upload images to your site, then I would advise NOT TO ALLOW using HTML in the names.
Use BBCode instead ( [i][/i] )
and then add foth parameter in the function call:[qcode]$prev_image_name = format_text($next_prev_cache[$prev_image_id]['image_name'], 0, 0, 1);[/qcode]
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 yerpo

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: 4.7.2 - html in image description
« Reply #9 on: March 11, 2006, 07:18:59 PM »
Ah, so there is an issue. Silly me, didn't think of the security risks even with all those recent hack reports. :oops: My gallery doesn't allow people registering & uploading photos at this stage, and it will be very tightly controlled after it does. But anyway, BBCode is much more elegant solution.

Offline yerpo

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: 4.7.2 - html in image description
« Reply #10 on: June 22, 2006, 05:40:25 PM »
Sorry for reviving this thread from the dead, but I finally got around to replacing HTML in names with BBCode, and I'm stuck again. This time the problem is opposite to the one on the previous picture, meaning that I can't get subcategory names to display correctly.

Here's what I'm talking about:


I modified all the format_text occurences as in previous example, but can't find anything subcategory related. Is it possible at all to have BBCode in subcategory names?

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
Re: 4.7.2 - html in image description
« Reply #11 on: June 23, 2006, 01:11:36 AM »
the dropdown - no, you can not use neither HTML nor BBCode

as of subcategories, in includes/functions.php find:
Code: [Select]
      $sub_cat_list .= "<a href=\"".$sub_url."\" class=\"subcat\">".$cat_cache[$subcat_id]['cat_name']."</a>";
Replace with:
Code: [Select]
      $sub_cat_list .= "<a href=\"".$sub_url."\" class=\"subcat\">".format_text($cat_cache[$subcat_id]['cat_name'], 0, 0, 1)."</a>";

For the clickstream find:
Code: [Select]
        $path = "<a href=\"".$site_sess->url($cat_url)."\" class=\"clickstream\">".$cat_cache[$cat_id]['cat_name']."</a>";
      }
      else  {
        $path = $cat_cache[$cat_id]['cat_name'];
      }
    }
    else {
      $path = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id)."\" class=\"clickstream\">".format_text($cat_cache[$cat_id]['cat_name'], 0, 0, 1)."</a>".$config['category_separator'].$path;
Replace with:
Code: [Select]
        $path = "<a href=\"".$site_sess->url($cat_url)."\" class=\"clickstream\">".format_text($cat_cache[$cat_id]['cat_name'], 0, 0, 1)."</a>";
      }
      else  {
        $path = $cat_cache[$cat_id]['cat_name'];
      }
    }
    else {
      $path = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id)."\" class=\"clickstream\">".format_text($cat_cache[$cat_id]['cat_name'], 0, 0, 1)."</a>".$config['category_separator'].$path;


Now, lets try to remove any bbcode tags from text.
At the end of functions.php above closing ?> insert:
Code: [Select]
function remove_bbcode($text)
{
  $search_array = array(
    "/(\[)(list)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/list)(((=)(\\4)([^\"']*)(\\4]))|(\]))/siU",
    "/(\[)(list)(])(.*)(\[\/list\])/siU",
    "/(\[\*\])/siU",
    "/(\[\/\*\])/siU",
    "/(\[)(url)(=)(['\"]?)(www\.)([^\"']*)(\\4])(.*)(\[\/url\])/siU",
    "/(\[)(url)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/url\])/siU",
    "/(\[)(url)(])(www\.)([^\"]*)(\[\/url\])/siU",
    "/(\[)(url)(])([^\"]*)(\[\/url\])/siU",
    "/(\[)(code)(])(\r\n)*(.*)(\[\/code\])/siU",
    "/(\[)(img)(])(\r\n)*([^\"]*)(\[\/img\])/siU",
    "/(\[)(b|i|u)(])(\r\n)*([^\"]*)(\[\/\\2\])/siU",
  );
  $replace_array = array(
    "\\7",
    "\\4",
    "",
    "",
    "\\8",//[url=addr]text[/url] the addr will be lost only text will stay
    "\\7",
    "\\5",
    "\\4",
    "\\5",
    "\\5",
    "\\5",
  );
  $text = preg_replace($search_array, $replace_array, $text);
  return $text;
}
(this will only remove default bbcode)
And finaly find:
Code: [Select]
        $category_list .= ">".str_repeat("--", $depth - 1)." ".$cat_cache[$category_id]['cat_name']."</option>\n";
      }
      else {
        $category_list .= ">".$cat_cache[$category_id]['cat_name']."</option>\n";
Replace with:
Code: [Select]
        $category_list .= ">".str_repeat("--", $depth - 1)." ".remove_bbcode($cat_cache[$category_id]['cat_name'])."</option>\n";
      }
      else {
        $category_list .= ">".remove_bbcode($cat_cache[$category_id]['cat_name'])."</option>\n";


P.S. all this I typed in the browser and did not test it...might not work...
« Last Edit: June 25, 2006, 08:34:19 PM by V@no »
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 yerpo

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: 4.7.2 - html in image description
« Reply #12 on: June 25, 2006, 08:07:51 PM »
The BBcode removal works perfect, but the solutions for the clickstream and subcategories don't. I thought maybe the subcategory change doesn't work because you forgot to add a space before the first zero, but that's not the case.

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
Re: 4.7.2 - html in image description
« Reply #13 on: June 25, 2006, 08:38:04 PM »
It should work (exept for the clickstream, which is fixed now, code above edited)
But you can try to search for 'cat_name' (included single quotes) and make sure they are being sent though format_text function.
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 yerpo

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: 4.7.2 - html in image description
« Reply #14 on: June 25, 2006, 10:36:17 PM »
Allright, that did the trick. Found another two, under function get_category_path($cat_id = 0, $detail_path = 0) (line 1123), and  under $site_template->register_vars(array( (line 300). There's only one minor issue, namely the function adds a space at the beginning and the end of the category name in the clickstream. But that's nothing I couldn't live with. Thanks again, V@no.