|
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: <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: <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: <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: <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.
|
|
|
|
Joined: Apr 2001
Posts: 3,266
Member
|
Member
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>
|
|
|
|
Joined: May 1999
Posts: 1,715
Addict
|
Addict
Joined: May 1999
Posts: 1,715 |
Thanks for that addition.
|
|
|
|
Joined: Apr 2001
Posts: 3,266
Member
|
Member
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.
|
|
|
|
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.
|
|
|
|
Joined: Apr 2001
Posts: 3,266
Member
|
Member
Joined: Apr 2001
Posts: 3,266 |
Could be an issue. I don't think we want to figure out the chance of such things 
|
|
|
|
Joined: Jan 2000
Posts: 796
Addict
|
Addict
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.
|
|
|
|
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.
|
|
|
|
Joined: Oct 2000
Posts: 9
Newbie
|
Newbie
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?
|
|
|
|
Joined: Apr 2001
Posts: 3,266
Member
|
Member
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.
|
|
|
|
Joined: Oct 2000
Posts: 9
Newbie
|
Newbie
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: <br /> $Body = preg_replace("/<embed src=(\"|")([^\"\[]*)(\"|") width=\"\d\" height=\"\d\" type=\"application/x-shockwave-flash\"></embed>/i","[flash:\\4,\\5]\\2[/flash]",$Body);<br /> ?????????????????
|
|
|
|
Joined: Apr 2002
Posts: 1,768
Addict
|
Addict
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: '~<embed src=(\"|")([^\"\[]*)(\"|") width=\"\d+\" height=\"\d+\" type=\"application/x-shockwave-flash\"></embed>~i'
|
|
|
|
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?
|
|
|
|
Joined: Oct 2000
Posts: 9
Newbie
|
Newbie
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 : <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 : <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: <br /> $Body = preg_replace("/<embed src=(\"|")([^\"\[]*)(\"|") 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?
|
|
|
|
Joined: Oct 2000
Posts: 9
Newbie
|
Newbie
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: <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?
|
|
|
|
Joined: Oct 2000
Posts: 9
Newbie
|
Newbie
Joined: Oct 2000
Posts: 9 |
It work now when writing as well as editing . he in olden not working when only editing post .
|
|
|
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.
|
|
Posts: 1,157
Joined: July 2001
|
|
Forums63
Topics37,575
Posts293,931
Members13,823
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|