Topic: Javascript in post

Hello punbb users.

I've put DailyMotion,Youtube,GoogleVidéo and SwfReader bbcodes in my Forum.A local site give the opportunity to user to take the link of their vidéos directly like this :

<script language="javascript" src="http://www............/video150.html"></script>

I've had a look at http://www............/video.html the vidéo inside have an Flv extension,no problem to read it inside SwfReader bbcode but to simplify manipulation for the users (open the link,view the source,localize the link of flv file) i would like to use directly the code listed above inside a new bbcode.

Is it possible ?

Any idea ?

Thanks for your answer.

2 (edited by deadram 2006-09-15 20:41)

Re: Javascript in post

Type this (with the url bbcode) on a forum

http://www............/video150.html

Press "preview"

Right click the link and select "save target as..." or the likes

Upload videoXXX.html to you webserver, or review the jscript and figure out how to do it with less work next time tongue

echo "deadram"; echo; fortune;

Re: Javascript in post

deadram wrote:

Type this (with the url bbcode) on a forum

http://www............/video150.html

Press "preview"

Right click the link and select "save target as..." or the likes

Upload videoXXX.html to you webserver, or review the jscript and figure out how to do it with less work next time tongue

Thanks for the answer but doesn't help so much

Less work ????

I was asking if it's possible to create a javascript bbcode to handle this king of link like this :

[js]<script language="javascript" src="http://www............/video150.html"></script>[/js]

I know that it's complicated and there will be probably a vulnerability problem but is there any way to do that.

Re: Javascript in post

Why would you allow JS in posts? >=/

Re: Javascript in post

Because if you see the first post the only way to have the vidéo if the site i was talkin about have this form

<script language="javascript" src="http://www............/video150.html"></script>

if the webmaster of this site gives the direct link in another way i would not ask for this ;-)
Inside the video150.html file there is the direct link for the flv file but too much manipulations to retrieve the link.
I was searching for a solution to directly input the code above inside a new bbcode.

Re: Javascript in post

You could always make a more safe BBCode:

[vid=video150.html]Video[/vid]

Or something like that.

Re: Javascript in post

elbekko wrote:

You could always make a more safe BBCode:

[vid=video150.html]Video[/vid]

Yes Elbekko would be better to not use javascript but how ?
If you could have a look to the code inside the videoxxx.html file i'm just discovering Punbb and Php (3months) here is the french site i was talking about :
http://www.ariegenews.com/index.html
and here is a link where there is a vidéo :
http://www.ariegenews.com/news/news-1-17-1359.html
The opportunity to retrieve the vidéo is given near footer under the line

Pour intégrer cette vidéo dans votre site internet ou votre blog, copiez/collez simplement le code ci-dessous:
<script language="javascript" src="http://www.ariegenews.com/data/rss/video-1359.html"></script>

Any advice ?

Re: Javascript in post

The Webmaster gives to me the solution :

[ariegenews]video-1375.html[/ariegenews]

But i have to include this function :

preg_replace(
  '/\[ariegenews\]([^\[]+)\[\/ariegenews\]/gi',
  '<script type="text/javascript"
src="http://www.ariegenews.com/data/rss/video-$1.html"></script>',
  $post
);

Where and how do i have to include this function ,including it in parser.php as is give me a lot of errors.

My first idea was to include it after the youtube bbcode  in parser.php here is the modifications already done :

#
#---------[ 1. OPEN ]---------------------------------------------------------
#
include/parser.php
#
#---------[ 2. FIND (line: 316) ]---------------------------------------------
#
                    '#\[u\](.*?)\[/u\]#s',

#
#---------[ 3. AFTER, ADD ]---------------------------------------------------
#
                     '#\[youtube\]http://www.youtube.com/watch\?v=(.*?)\[/youtube\]#s',

#
#---------[ 4. FIND (line: 326) ]---------------------------------------------
#
                     '<span class="bbu">$1</span>',

#
#---------[ 5. AFTER, ADD ]---------------------------------------------------
#
                     '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>',
#
#---------[ 6. SAVE/UPLOAD ]-------------------------------------------------
#

Any advice ?

Re: Javascript in post

In the function do_bbcode() in parser.php, add this code:

$text = preg_replace('/\[ariegenews\]([^\[]+)\[\/ariegenews\]/gi', '<script type="text/javascript" src="http://www.ariegenews.com/data/rss/video-$1.html"></script>', $text);

before this line

return $text;

Should work smile

10 (edited by glucarelli 2006-10-10 15:50)

Re: Javascript in post

I have this error :

Warning: preg_replace() [function.preg-replace]: Unknown modifier 'g' in /include/parser.php on line 394

Some lines before the line 394 in include/parser.php :

// This thing takes a while! :)
    $text = preg_replace($pattern, $replace, $text);
    $text = preg_replace('/\[ariegenews\]([^\[]+)\[\/ariegenews\]/gi', '<script type="text/javascript"
src="http://www.ariegenews.com/data/rss/video-$1.html"></script>', $text);
    return $text;
}

Re: Javascript in post

Replace [\/ariegenews\]/gi with [\/ariegenews\]/i then.

12 (edited by glucarelli 2006-10-10 21:00)

Re: Javascript in post

Ok removed the 'g' no error , but nothing appear in the post !

Fixed working great now.

Thank you very much master Elbekko