1
fatbmx
Javascript in news items
  • 2005/1/20 10:19

  • fatbmx

  • Just popping in

  • Posts: 12

  • Since: 2003/3/31


Since 01.01.05 we are using XOOPS for our bmx news site (http://www.fatbmx.com) and we simply love it! In order to simply include some pictures in our news I installed the Bluemooninc Fileup_News hack.

I've changed some of the code to fit our requirements and one of the last options I wanted to add is that the large (original) photo opens in a pop-up window instead of the browser window.

For that purpose I am using a javascript, which I also used in our 'old' htlm setup. To include the correct code, I have changed the original code in the fileup.inc.php file from $addimg = " to $addimg = ".

Actial code when I edit the story is exactly as I wanted it:

But the link itself is:
"http://www.fatbmx.com/modules/news/java%20script:picturepop( ...

Question 1 - Why does XOOPS automatically change "javascript" into "java script"?

Question 2 - Why is the link "http://www.fatbmx.com/modules/news/java%20script:picturepop(" instead of "javascript:picturepop("? This way I get a 404 error (of course).

Here's the original article link:
http://www.fatbmx.com/modules/news/article.php?storyid=98

Any help in any way is highly appreciated!!!

2
Curtism
Re: Javascript in news items
  • 2005/1/20 11:38

  • Curtism

  • Just popping in

  • Posts: 1

  • Since: 2005/1/20


Hey, sorry I can't help you, I just wanted to tell you I love your site and I visit it a lot. I also bmx, and I also have xoops.

Good luck.

3
rowdie
Re: Javascript in news items
  • 2005/1/20 11:48

  • rowdie

  • Just can't stay away

  • Posts: 846

  • Since: 2004/7/21


Did you know of the XOOPS javascript function called openWithSelfMain ? Here's a FAQ about it.

It takes the parameters : url, name, width, height

You could use that, or change it to suit your needs. It's in the xoops_root/include/xoops.js file. You could even put your own function in the xoops.js file, and it should become available in your news submissions. - in theory then, since I've never tested this myself

Hope that helps,

Rowd

4
fatbmx
Re: Javascript in news items
  • 2005/1/20 12:10

  • fatbmx

  • Just popping in

  • Posts: 12

  • Since: 2003/3/31


I tried to use that function also, but it´s not the javascript itself that seems to be the problem...

At first I also included the javascript in the xoops.js, but to make sure that that is not causing the problem I added the function straight into the theme template.

One way or the other, XOOPS translates the hyperlink into the http://www.fatbmx.com/... /java script... instead of pointing it straight to the javascript itself.

Maybe it has got something to do with the way XOOPS treats the news items?

5
rowdie
Re: Javascript in news items
  • 2005/1/20 12:32

  • rowdie

  • Just can't stay away

  • Posts: 846

  • Since: 2004/7/21


I just had a look at the files and you're right. But it's not just the news module, all text gets passed to a function that cleans out javascript by separating javascript into two words.

I believe javascript can be used maliciously, so I can sort of understand why this has been done. But if I'm reading this right, it looks like all javascript functions within text fields have been disabled for at least a year... and no-one has complained yet?

There must be a way of getting around this problem, but I'm afraid I don't know of it... unless you comment out the lines in the module.textsanitizer.php class, but that leaves your site open to possible malicious attacks if users are allowed to post on your site... so sorry, I can't help with this. Hopefully a core developer can give a better solution...

Rowd

6
fatbmx
Re: Javascript in news items
  • 2005/1/20 13:01

  • fatbmx

  • Just popping in

  • Posts: 12

  • Since: 2003/3/31


Rowdie, you don't even know how happy you made me. Because it was as simple as that! I changed the text sanitizer "java script" back to "javascript" and now it works... Great, since my visitors are not allowed to post news messages anyway.

I also saw that the links module has an extra seperate sanitizer for this "java script". Since I am using a guestbook where anonymous users can post "malicious" javascript code, I will also add this sanitizer part to my guestbook php script.

I may also add a re-sanitizer part to the news pages to "re-sanitize" "java script" back to "javascript". I'll look into it...

-Jos

7
rowdie
Re: Javascript in news items
  • 2005/1/20 13:19

  • rowdie

  • Just can't stay away

  • Posts: 846

  • Since: 2004/7/21


A better solution would be to add a parameter to the xoopsCodeDecode function , something like this:

xoopsCodeDecode(&$text$allowimage 1$allowjs 0)


then have a condition on the javascript replacement code, so it's only replaced if not allowed. Since the default is 0 it shouldn't have any impact on existing modules, and you can just change your news one to pass a $allowjs = 1 parameter. Unfortunately xoopsCodeDecode isn't called directly from the modules, so you'll also have to change the calling functions to pass the parameter

Anyway, it's just an idea...

And I'm happy to hear that my last post helped you, thanks for telling me

Rowd

8
fatbmx
Re: Javascript in news items
  • 2005/1/20 13:31

  • fatbmx

  • Just popping in

  • Posts: 12

  • Since: 2003/3/31


Thanks Rowdie. You have been very helpfull. How should I implement this change? I am not really that far into PHP and XOOPS (remember that we opened our site 01.01.05).

Do you have a simple PHP snippet to replace "-" with spaces for a certain variable? We upload the pictures as, for example: "Jos-doing-an-air.jpg". The javascript unfortunately cannot handle "Jos doing an air.jpg", but I want to add a title and alt to the tab without the "-"...

-Jos

9
rowdie
Re: Javascript in news items
  • 2005/1/20 13:48

  • rowdie

  • Just can't stay away

  • Posts: 846

  • Since: 2004/7/21


Actually, if I were you I wouldn't implement the changes I mentioned - it will make upgrading your XOOPS very difficult. I'll suggest it as a feature request to the XOOPS core developers.

For you second point, I don't quite understand what you mean. Are you using javascript then with this html tag? Or do you mean the bbcode [img], which passes through the text sanitizer?

Either way, I don't know the answer... I'd have to look it up, best wait until a real php programmer comes along and sees your question

Rowd

10
fatbmx
Re: Javascript in news items
  • 2005/1/20 20:39

  • fatbmx

  • Just popping in

  • Posts: 12

  • Since: 2003/3/31


Already found the answer at php.net. Using the preg_replace($pattern, $replacement, $orgName) to replace the $pattern in the $orgName with $replacement. Thanks.

Login

Who's Online

307 user(s) are online (50 user(s) are browsing Support Forums)


Members: 0


Guests: 307


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits