gaza165 Posted October 25, 2008 Share Posted October 25, 2008 Hi all http://www.thedesignmonkeys.co.uk I have just written a blog in php and was looking at this thing called PHPBB. Can someone explain to me what this is, does it mean that i can insert php code into my blog and it will change the colours accordingingly??? Thanks Garry Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/ Share on other sites More sharing options...
wildteen88 Posted October 25, 2008 Share Posted October 25, 2008 phpBB is forum software. Got to phpbb.com for more info. Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/#findComment-674254 Share on other sites More sharing options...
gaza165 Posted October 25, 2008 Author Share Posted October 25, 2008 I dont really understand it fully.. is it a long winded thing to install and configure etc?? does it edit the entire database?? Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/#findComment-674256 Share on other sites More sharing options...
wildteen88 Posted October 25, 2008 Share Posted October 25, 2008 PHPBB is a forum like this one here. Are you wanting to install a forum? PHPBB will install its own database. Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/#findComment-674261 Share on other sites More sharing options...
gaza165 Posted October 25, 2008 Author Share Posted October 25, 2008 No, what im trying to do is be able to insert php code into my blog then when it is outputted the colors - just like it is here - i wanna use the [ code ] tags just like here so it changes the colour of php text. Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/#findComment-674263 Share on other sites More sharing options...
wildteen88 Posted October 25, 2008 Share Posted October 25, 2008 Oh! You're after BBCodes. There are many tutorials for adding BBCodes to your site. Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/#findComment-674266 Share on other sites More sharing options...
gaza165 Posted October 25, 2008 Author Share Posted October 25, 2008 Can you point me in the right direction.... is their something i need to install onto my server or is it a simple thing to do?? Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/#findComment-674271 Share on other sites More sharing options...
wildteen88 Posted October 25, 2008 Share Posted October 25, 2008 No need to install anything. You just write the necessary code for your BBCode parser. In order to write your own you'll need to know some basic PHP syntax and have an understanding of regular expressions. Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/#findComment-674276 Share on other sites More sharing options...
steelmanronald06 Posted October 25, 2008 Share Posted October 25, 2008 http://www.sitepoint.com/article/highlight-source-code-php/ http://www.php.net/bbcode Took me 3 minutes to put in "Colour PHP Code" into google and those were the first two links, both of which will get you going in the right direction Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/#findComment-674392 Share on other sites More sharing options...
waynew Posted October 25, 2008 Share Posted October 25, 2008 Hi I made a class: Seems to work fine for most: <?php class Phpposter{ var $border; var $padding; var $width; var $margin_bottom; var $bg_color; var $font_size; function Phpposter(){ $this->border = "1px #CCCCCC solid"; $this->width = "500px"; $this->margin_bottom = "5px"; $this->padding="3px"; $this->bg_color="#FFFFFF"; $this->font_size="14px"; } function highlight_code($string){ //We're looking for [code] tags here. $pattern = "/\[code\](.*?)\[\/code\]/is"; preg_match_all($pattern, $string, $matches); //Find all matches $changes = array(); //This array will hold all the changes we made. These changes will replace the matches. if(sizeof($matches) < 1){ //If no code tags are found, return the string as it was return $string; } else{ foreach($matches[1] as $match){ array_push($changes,$this->style($match));//Fill up changes array } } $i=0;//counter while($i < sizeof($matches)){ $string = str_replace($matches[1][$i],$changes[$i],$string); $i++; } $string = str_replace("[code]","",$string); $string = str_replace(" ","",$string); return $string; } function style($string){ $div = '<div style="background-color:'.$this->bg_color.'; width:'.$this->width.'; padding:'.$this->padding.'; border:'.$this->border.'; margin-bottom:'.$this->margin_bottom.'; font-size:'.$this->font_size.'; white-space: pre; overflow: auto;">'; $string = str_replace("<br />","",$string); $string = str_replace("<br/>","",$string); $string = str_replace("\n","",$string); $string = '<br/>'.$div.highlight_string($string,true).'</div>'; //Place div around code to make it stand out return $string; } function set_width($width){ $this->width=$width; } function set_margin_bottom($margin_bottom){ $this->margin_bottom = $margin_bottom; } function set_border($border){ $this->border = $border; } function set_font_size($font){ $this->font_size = $font; } function set_bg_color($bg){ $this->bg_color = $bg; } function set_padding($padding){ $this->padding = $padding; } } ?> [/code] Basic gist of how to use: $phpposter = new Phpposter(); echo $phpposter->highlight_code($blogpost); Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/#findComment-674396 Share on other sites More sharing options...
waynew Posted October 25, 2008 Share Posted October 25, 2008 Took me 3 minutes to put in "Colour PHP Code" into google LOL are you a slow typer? Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/#findComment-674397 Share on other sites More sharing options...
Daniel0 Posted October 25, 2008 Share Posted October 25, 2008 In a moment someone will tell you that you shouldn't use PHP4-style OOP. They'll also tell you that you should use the setter methods you've created and that you should just set default values instead of doing it in the constructor. Moreover, you'll be told that instead of tracking "changes" you should just use preg_replace_callback() to replace matches. Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/#findComment-674398 Share on other sites More sharing options...
waynew Posted October 25, 2008 Share Posted October 25, 2008 Oh I know that the code is not without its fault. Oh and the PHP 4-style constructor is a habit I have from Java. The class was kind of rushed together. It works and I use it personally; so I wont lose any sleep over it. I'll keep what you said about what I didn't know in mind though. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/130044-blog-phpbb3/#findComment-674403 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.