gaza165 Posted October 27, 2008 Author Share Posted October 27, 2008 I am pulling my hair out over this i really have no idea what to do with this code... I have no idea what to do with it!!! Can i please have the code, just want to get this finished. Quote Link to comment https://forums.phpfreaks.com/topic/130247-help-to-create-a-forum-bbcodes/page/3/#findComment-675791 Share on other sites More sharing options...
nadeemshafi9 Posted October 27, 2008 Share Posted October 27, 2008 I am pulling my hair out over this i really have no idea what to do with this code... I have no idea what to do with it!!! Can i please have the code, just want to get this finished. it took me days of paper work to get lists within lists from bbcode (2 days) you need to map it out on paper there is no simple code m8, you need to split it up into an array then take the chucnks using p1 p2 and string chop or wotever. iv already put you half way there. Quote Link to comment https://forums.phpfreaks.com/topic/130247-help-to-create-a-forum-bbcodes/page/3/#findComment-675794 Share on other sites More sharing options...
wildteen88 Posted October 27, 2008 Share Posted October 27, 2008 To highlight PHP code with tags use the code attached below [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/130247-help-to-create-a-forum-bbcodes/page/3/#findComment-675952 Share on other sites More sharing options...
DeanWhitehouse Posted October 27, 2008 Share Posted October 27, 2008 You are a saviour ,lolz Quote Link to comment https://forums.phpfreaks.com/topic/130247-help-to-create-a-forum-bbcodes/page/3/#findComment-675965 Share on other sites More sharing options...
gaza165 Posted October 27, 2008 Author Share Posted October 27, 2008 OMG Thankyou so much... what a Legend!! nice one mate... Quote Link to comment https://forums.phpfreaks.com/topic/130247-help-to-create-a-forum-bbcodes/page/3/#findComment-675987 Share on other sites More sharing options...
gaza165 Posted October 27, 2008 Author Share Posted October 27, 2008 Wildteen, Does this code still work if htmlentities is on?? Garry Quote Link to comment https://forums.phpfreaks.com/topic/130247-help-to-create-a-forum-bbcodes/page/3/#findComment-675996 Share on other sites More sharing options...
wildteen88 Posted October 27, 2008 Share Posted October 27, 2008 You should not be using htmlentities() prior to parsing the code tags. Otherwise you may get strange results. Quote Link to comment https://forums.phpfreaks.com/topic/130247-help-to-create-a-forum-bbcodes/page/3/#findComment-676001 Share on other sites More sharing options...
gaza165 Posted October 27, 2008 Author Share Posted October 27, 2008 Well i need to use htmlentities to be able to have blogs submitted by users without them messing with the DB like XSS and stuff, so what can i do about that?? Quote Link to comment https://forums.phpfreaks.com/topic/130247-help-to-create-a-forum-bbcodes/page/3/#findComment-676002 Share on other sites More sharing options...
wildteen88 Posted October 27, 2008 Share Posted October 27, 2008 Use htmlspecialshars instead Change the highlight_php function to this function highlight_php($matches) { $code = preg_replace("#(\[code\]|\[/code\])#is", "", $matches[0]); $code = htmlspecialchars_decode($code); //highlight PHP Code $code = highlight_string($code, true); //Encode certain HTML chars into ASCII Code $html_chars = array("[", "]"); $html_ASCII = array("[", "]"); $code = str_replace($html_chars, $html_ASCII, $code); return '<div class="code">' . $code . '</div>'; } Now change echo docode($test); to $test = htmlspecialchars($test); echo docode($test); Quote Link to comment https://forums.phpfreaks.com/topic/130247-help-to-create-a-forum-bbcodes/page/3/#findComment-676011 Share on other sites More sharing options...
nadeemshafi9 Posted October 27, 2008 Share Posted October 27, 2008 Use htmlspecialshars instead Change the highlight_php function to this function highlight_php($matches) { $code = preg_replace("#(\[code\]|\[/code\])#is", "", $matches[0]); $code = htmlspecialchars_decode($code); //highlight PHP Code $code = highlight_string($code, true); //Encode certain HTML chars into ASCII Code $html_chars = array("[", "]"); $html_ASCII = array("[", "]"); $code = str_replace($html_chars, $html_ASCII, $code); return '<div class="code">' . $code . '</div>'; } Now change echo docode($test); to $test = htmlspecialchars($test); echo docode($test); regular expressions rule, i need to learn more Quote Link to comment https://forums.phpfreaks.com/topic/130247-help-to-create-a-forum-bbcodes/page/3/#findComment-676101 Share on other sites More sharing options...
nadeemshafi9 Posted October 27, 2008 Share Posted October 27, 2008 i couldent use this in my code becuase i have things like <LIST> dfgdr dfg dfg <LIST> tgretr retert <LIST> tgretr retert </LIST> </LIST> </LIST> </LIST> Quote Link to comment https://forums.phpfreaks.com/topic/130247-help-to-create-a-forum-bbcodes/page/3/#findComment-676104 Share on other sites More sharing options...
MadTechie Posted October 28, 2008 Share Posted October 28, 2008 i see no reason why you can't! just use your current parsa to do the list after the php parsa ie bb2html(docode($text)); Quote Link to comment https://forums.phpfreaks.com/topic/130247-help-to-create-a-forum-bbcodes/page/3/#findComment-676260 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.