Previous Thread
Next Thread
Print Thread
Rate Thread
#237891 02/24/2003 8:56 AM
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Small mod to add [flash] [/flash] markup. Beware that it is very possible to add malicious flash files, you really shouldn't use this. By the way, these instructions are untested, but the first part is reported to work.

Find these lines in ubbt.inc.php:
Code
 <br />    // ---------------------------- <br />    // Convert email markup -> html <br />       $Body = preg_replace("/\[{$ubbt_lang['TEXT_EMAIL']}\]([^\[]*)\[\/{$ubbt_lang['TEXT_EMAIL']}\]/i","<a href=\"mailto:\\1\">\\1</a>",$Body); <br />


Add this below:
Code
 <br />$Body = preg_replace("/\[flash\]([^\[]*)\[\/flash\]/i","<embed src=\"\\1\" width=\"300\" height=\"60\" type=application/x-shockwave-flash></embed>",$Body); <br /> <br />$Body = preg_replace("/\[flash:(\d+?),(\d+?)\]([^\[]*)\[\/flash\]/i","<embed src=\"\\3\" width=\"\\1\" height=\"\\2\" type=\"application/x-shockwave-flash\"></embed>",$Body); <br />



And for the undo_markup() function:

Find these lines:
Code
 <br />    // ---------------------------- <br />    // Convert email markup -> html <br />       $Body = preg_replace("/<a href=(\"|")mailto:([^\[]*)(\"|")>(.*?)<\/a>/i","[{$ubbt_lang['TEXT_EMAIL']}]\\2[/{$ubbt_lang['TEXT_EMAIL']}]",$Body); <br />


And add this below:
Code
 <br />       $Body = preg_replace("/<embed src=(\"|")([^\"\[]*)(\"|") width=\"(\d+)\" height=\"(\d+)\" type=\"application\/x-shockwave-flash\"><\/embed>/i","[flash:\\4,\\5]\\2[/flash]",$Body); <br />



The above creates a markup which changes this:

[flash]https://ubbdev.com/flash.sfw[/flash]

or this:
[flash:300,60]https://ubbdev.com/flash.sfw[/flash]

Into this:
<embed src="https://ubbdev.com/flash.sfw" width=300 height=60 type="application/x-shockwave-flash"></embed>


Last edited by Gardener; 03/15/2003 3:41 PM.
Sponsored Links
c0bra #237892 02/27/2003 4:28 PM
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Just another part to this is you want to add the flash button to UBBCODE.

In ubbt_instant_ubbcode.tmpl

Find this:

if (action == "image") {
var thisImage = prompt("{$ubbt_lang['ENTERIMAGE']}", "http://");
if (thisImage == null){return;}

insertAtCaret(document.replier.Body, ' ' + "[{$ubbt_lang['TEXT_IMAGE']}]" + thisImage + "[/{$ubbt_lang['TEXT_IMAGE']}]" + ' ' );
document.replier.Body.focus();
return;
}

ADD UNDER:

if (action == "flash") {
var thisImage = prompt("ENTER FLASH FILE", "http://");
if (thisImage == null){return;}

insertAtCaret(document.replier.Body, ' ' + "[FLASH]" + thisImage + "[/FLASH]" + ' ' );
document.replier.Body.focus();
return;
}

FIND THIS:

<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('quote');">{$ubbt_lang['J_QUOTE']}</a>
</td>
</tr>
<tr>
<td class="darktable">

ADD UNDER:

<a href="javascript: x()" onclick="DoPrompt('flash');">Flash</a> 

sf49rminer #237893 02/27/2003 6:42 PM
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Thanks for that addition.

c0bra #237894 02/27/2003 7:43 PM
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
It is a quick enough addition for those that may be interested if they want to change the security issue of flash.

However the chances of anything happening to the server are nill unless your running a corrupt flash from there. Not too much of a security risk if they arent hosted.

sf49rminer #237895 02/27/2003 7:47 PM
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Hmm. Maybe the regexp should require that the src starts with http:// so that they can't attach the flash to a post if they are allowed. Of course, it would be just as easy to just disallow flash files. Don't know how the browsers handle them if the are renamed to .txt though, could be an issue.

Sponsored Links
c0bra #237896 02/27/2003 7:53 PM
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Could be an issue. I don't think we want to figure out the chance of such things


c0bra #237897 02/28/2003 12:32 PM
Joined: Jan 2000
Posts: 796
MTO Offline
Addict
Addict
Offline
Joined: Jan 2000
Posts: 796
Instead of:
width="300" height="60"
it would probably be better to indicate 100%, so that they are viewed proportionally. It doesnt always look good with 100%, but at least the flash file shows proportionally.

D_Wolfwood #237898 02/28/2003 12:45 PM
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
They can enter their own width and height if that's the case. The unmarkup has to be changed a bit as well if width is set to 100% otherwise that'll break.

c0bra #237899 03/14/2003 9:30 AM
Joined: Oct 2000
Posts: 9
Newbie
Newbie
Offline
Joined: Oct 2000
Posts: 9
this hack not working in version 6.2.2 !!
What is The problem ?

Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
It does for me and I just copied the text from my post. Please make sure that you haven't done any mistakes.

If it still doesn't work you will have to be more precise, what is not working? Do you get an error? If so, what is it?

Sponsored Links
c0bra #237901 03/14/2003 9:02 PM
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Works for me as well.

99 percent of errors are in hacking mistakes. The other 1 percent is bugs.

sf49rminer #237902 03/15/2003 7:58 AM
Joined: Oct 2000
Posts: 9
Newbie
Newbie
Offline
Joined: Oct 2000
Posts: 9
sorry , I'm not talking English

I'm add this code : [flash]http://www.yourdomain.com/test.swf[/flash] in my post . The code showing in post .but when editing I see this message


Warning: Unknown modifier '-' in c:\httpd\htdocs\aaaa\ubbt.inc.php on line 852


in line 852 this code:
Code
<br />       $Body = preg_replace("/<embed src=(\"|&quot;)([^\"\[]*)(\"|&quot;) width=\"\d\" height=\"\d\" type=\"application/x-shockwave-flash\"></embed>/i","[flash:\\4,\\5]\\2[/flash]",$Body);<br />


?????????????????

maulkorbzwang #237903 03/15/2003 10:29 AM
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
There are a couple of unescaped forward slashes in the preg pattern. Also, \d only matches a single digit, so it should be \d+ to match one or more digits. I would do it like this:

Code
'~<embed src=(\"|&quot;)([^\"\[]*)(\"|&quot;) width=\"\d+\" height=\"\d+\" type=\"application/x-shockwave-flash\"></embed>~i'



joeuser #237904 03/15/2003 12:56 PM
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Thanks Dave, that should fix it when editing posts, I knew I should have tested that one.

But it doesn't explain why the flash markup isn't translated into html when writing the post. alotiabi, do you have ubbcode turned on? Could you show us the code you have added for the flash markup in the do_markup() function?

c0bra #237905 03/15/2003 3:04 PM
Joined: Oct 2000
Posts: 9
Newbie
Newbie
Offline
Joined: Oct 2000
Posts: 9
Thanks Dave_L
good . but when The post editing I showing The code:
[:"red"][flash: , ][/]http://www.yourdomain.com/test.swf[/flash] .
??
he do not show The width and The height !

Gardener ,
this flash markup in do_markup() function :
Code
 <br />$Body = preg_replace("/\[flash\]([^\[]*)\[\/flash\]/i","<embed src=\"\\1\" width=\"300\" height=\"60\" type=\"application/x-shockwave-flash\"></embed>",$Body); <br />$Body = preg_replace("/\[flash:(\d+?),(\d+?)\]([^\[]*)\[\/flash\]/i","<embed src=\"\\3\" width=\"\\1\" height=\"\\2\" type=\"application/x-shockwave-flash\"></embed>",$Body); <br />


and This code flash in undo_markup()function :
Code
 <br />       $Body = preg_replace("~<embed src=(\"|")([^\"\[]*)(\"|") width=\"\d+\" height=\"\d+\" type=\"application/x-shockwave-flash\"></embed>~i","[flash:\\4,\\5]\\2[/flash]",$Body); <br />

Last edited by alotiabi; 03/15/2003 3:16 PM.
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Ok, seems that I missed one more thing, use this for the undo_markup(), I've tried it and it works:

Code
<br />       $Body = preg_replace("/<embed src=(\"|&quot;)([^\"\[]*)(\"|&quot;) width=\"(\d+)\" height=\"(\d+)\" type=\"application\/x-shockwave-flash\"><\/embed>/i","[flash:\\4,\\5]\\2[/flash]",$Body);<br />


As for when writing posts, the code is correct, I pasted the bit you posted into my code and it works perfectly. Are you sure UBBCode is turned on for the board and that you have selected "using UBBCode" when posting?

Where did you place the code? Is it in the correct place in the do_markup() function?

c0bra #237907 03/15/2003 8:11 PM
Joined: Oct 2000
Posts: 9
Newbie
Newbie
Offline
Joined: Oct 2000
Posts: 9
Very Thanks, Gardener
This code works:

Yes, I have selected "using UBBCode" when posting .
I'm added the code below:
Code
<br />    // ----------------------------<br />    // Convert email markup -> html<br />       $Body = preg_replace("/\[{$ubbt_lang['TEXT_EMAIL']}\]([^\[]*)\[\/{$ubbt_lang['TEXT_EMAIL']}\]/i","<a href=\"mailto:\\1\">\\1</a>",$Body);<br />


This code Good Working now .


Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Ah, so it works both when writing posts as well as editing now? Or was it always only the editing that didn't work?

c0bra #237909 03/16/2003 3:59 AM
Joined: Oct 2000
Posts: 9
Newbie
Newbie
Offline
Joined: Oct 2000
Posts: 9
It work now when writing as well as editing .
he in olden not working when only editing post .


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
hatter
hatter
USA
Posts: 69
Joined: January 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)