News:

Wondering if this will always be free?  See why free is better.

Main Menu

How to enable iframe tag with the custom bb code mod??

Started by 123gotoandplay, May 13, 2007, 03:07:57 AM

Previous topic - Next topic

123gotoandplay

Hi all,

How should i configure custom bb code  mod to enable an iframe tag??

metallica48423

You'd have to create a new BBCode to do this with the custom bbcode mod.

http://custom.simplemachines.org/mods/index.php?mod=621

Do please keep in mind that allowing people to do so is a substantial security risk.  Just wanted to get that out there.
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

123gotoandplay

@blackmage,

I installed the custom bb code mode, but i don't know how to use it :)

I am aware of the security risk. So i want to accomplish something like

[iframe-tag]1234abcd[/iframe-tag]


will be replace with

<iframe src="http://www.mydomain.com/framefile/1234abcd" frameborder="0" width="650" height="450"/>


but in edit mode it looks like

[iframe-tag]1234abcd[/iframe-tag]


again.

So i short only http://www.mydomain.com/framefile/ can be the frame source, is this possible??

I don't mind hardcoding this.

123gotoandplay

ok i am a bit further
I came up with these functions and tested it

function replaceIFrame($str) {
$var = extractBetweenDelimeters($str,'[iframe-tag]', '[/iframe-tag]');
$search = '[iframe-tag]'.$var.'[/iframe-tag]';
$replace = '
<iframe src="http://www.mydomain.com/framefile/'.$var.'" frameborder="0" width="650" height="450"/>';
$return = str_replace($search,$replace,$str);
return $return;
}

if (!function_exists("stripos")) {
  function stripos($str,$needle) {
   return strpos(strtolower($str),strtolower($needle));
  }
}
function extractBetweenDelimeters($inputstr,$delimeterLeft,$delimeterRight) {
   $posLeft  = stripos($inputstr,$delimeterLeft)+strlen($delimeterLeft);
   $posRight = stripos($inputstr,$delimeterRight,$posLeft+1);
   return  substr($inputstr,$posLeft,$posRight-$posLeft);
}


echo replaceIFrame($str);

Now $str would be the message.

A/ I like to use replaceIFrame, but which SMF file handle the message???
B/ Just for one specific board if possible

123gotoandplay

#4
would prepareDisplayContext() in Display.php be the one???

ok i made it work by
$message['body'] = replaceIFrame($message['body']);

now I need to set this only for two specific boards, does SMF provide a global board id (ID_BOARD)??

123gotoandplay

ok even the board issue has been resolved by using


global $board;
if(($board == '15') || ($board == '24'))
{
$message['body'] = replaceIFrame($message['body']);
}


I am almost there, just one more thing. In the situation where i have text after
[iframe-tag]120507vWnW[/iframe-tag] the text would show up. However if i hit the modify button i do see the text???

123gotoandplay

#6
hmm, i overlooked something crucial.

Every code after function replaceIFrame isn't being parsed :(
Need to fix this

Fixed this by adding a closing </iframe> and not <iframe .../>

metallica48423

i've never used the mod (and not for this purpose, let alone :P)

You might have to ask in the topic for the mod, as i'm not familiar with how the mod works or bbcode itself works. 

Or did you resolve this by switching iframe / with </iframe>?
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

123gotoandplay

@blackmage, yes i resolved this by using </iframe>.
tx for thinking along.

Now the iframe security risk isn't there or at least i have reduce the risk to a minimum

metallica48423

depends.

A member could still load a malicious file. 

Just be careful :P
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Advertisement: