Home Private Messages Search
CPG Dragonfly™ CMS stopsoftwarepatents.eu petition banner
Toggle Content
 
Forums ⇒ DragonflyCMS ⇒ Problems AFTER Install/Upgrade ⇒ PHP BBcode not working - PHP version issues?


PHP BBcode not working - PHP version issues?
Issues that happen after DragonflyCMS upgrade/install.
DO NOT post module installation issues here!

Post new topic    Reply to topic    Printer Friendly Page     Forum Index ⇒  Problems AFTER Install/Upgrade

View previous topic :: View next topic  
Author Message
Bedevere
Nice poster
Nice poster

Offline Offline
Joined: Jul 06, 2006
Posts: 83
Location: New York City
PostPosted: Sun Jan 11, 2009 1:46 am
Post subject: PHP BBcode not working - PHP version issues?

I migrated from version 9.0.6.1 to 9.2.1. I read up on what to expect and everything went failry smoothly. A few mods I had forgotton though did cathc up to me and I sifted through what were mostly cosmetic issues. What plagues me now is that the bbcode for PHP stopped working...well properly.

I can display this:
PHP:
$text = preg_replace($patterns, $replacements, $text);

but I can't display this:
PHP:
<?php
function decode_php($text)
{
global $bb_codes;
$text = str_replace("\r\n", "\n", substr($text, 5, -6)); # Windows
$text = str_replace("\r", "\n", $text); # Mac
$text = str_replace("\t", ' ', $text); # Temporary tab fix
$text = htmlunprepare($text, true);
$added = FALSE;
if (preg_match('/^<\?.*/', $text) <= 0) {
$text = "<?php\n$text";
$added = TRUE;
}
if (PHPVERS < 42) {
ob_start();
highlight_string($text);
$text = ob_get_contents();
ob_end_clean();
} else {
$text = highlight_string($text, TRUE);
}
if (PHPVERS < 50) {
$text = preg_replace('/<font color="(.*?)">/si', '<span style="color: \\1;">', $text);
$text = str_replace('</font>', '</span>', $text);
}
if ($added == TRUE) {
if (PHPVERS < 50) {
$text = preg_replace('/^(.*)\n.*?<\/span>(.*)php<br \/>/i', "\\1\n\\2?php<br />", $text, 1);
}
$text = preg_replace('/^(.*)\n.*php<br \/><\/span>/i', "\\1\n", $text, 1);
$text = preg_replace('/^(.*)\n(.*)>.*php<br \/>/i', "\\1\n\\2>", $text, 1);
}
$text = str_replace('[', '&#91;', $text);
$text = str_replace("\n", '', $text);
$text = str_replace('&nbsp;', ' ', $text);
$text = str_replace(' ', "\t", $text);
$text = preg_replace('#<span style="color: \#[A-F0-9]{6}">([\t]+)</span>#', '\\1', $text);
return $bb_codes['php_start']."<pre>$text</pre>".$bb_codes['php_end'];
}



Well look at that...neither can you guys. But it does work as code:

Code::
	function decode_php($text)
	{
		global $bb_codes;
		$text = str_replace("\r\n", "\n", substr($text, 5, -6)); # Windows
		$text = str_replace("\r", "\n", $text);   # Mac
		$text = str_replace("\t", '/*t*/', $text); # Temporary tab fix
		$text = htmlunprepare($text, true);
		$added = FALSE;
		if (preg_match('/^<\?.*/', $text) <= 0) {
			$text = "<?php\n$text";
			$added = TRUE;
		}
		if (PHPVERS < 42) {
			ob_start();
			highlight_string($text);
			$text = ob_get_contents();
			ob_end_clean();
		} else {
			$text = highlight_string($text, TRUE);
		}
		if (PHPVERS < 50) {
			$text = preg_replace('/<font color="(.*?)">/si', '<span style="color: \\1;">', $text);
			$text = str_replace('</font>', '</span>', $text);
		}
		if ($added == TRUE) {
			if (PHPVERS < 50) {
				$text = preg_replace('/^(.*)\n.*?<\/span>(.*)php<br \/>/i', "\\1\n\\2?php<br />", $text, 1);
			}
			$text = preg_replace('/^(.*)\n.*php<br \/><\/span>/i', "\\1\n", $text, 1);
			$text = preg_replace('/^(.*)\n(.*)>.*php<br \/>/i', "\\1\n\\2>", $text, 1);
		}
		$text = str_replace('[', '&#91;', $text);
		$text = str_replace("\n", '', $text);
		$text = str_replace('&nbsp;', ' ', $text);
		$text = str_replace('/*t*/', "\t", $text);
		$text = preg_replace('#<span style="color: \#[A-F0-9]{6}">([\t]+)</span>#', '\\1', $text);
		return $bb_codes['php_start']."<pre>$text</pre>".$bb_codes['php_end'];
	}

At first I thought my theme was the issue, as I had modified it for 9.2.1 and it is a pretty involved set of files. I switched back to default and the dragonfly themes and no dice. So I copied the entire site to a test machine, but did not copy the mySQL data, I installed fresh and tried it and it works fine. The only differences seems to be the version of php and mySQL.

The working one uses...
CMS Version 9.2.1
PHP Version 5.1.2
MySQL Version 5.0.26 (client: 5.0.26)


The non-working one uses...
CMS Version 9.2.1
PHP Version 5.2.6
MySQL Version 5.0.51a (client: 5.0.51a)

I dug around in the nbbcode.php and found the function decode_php (as you can see above) and I noticed there was a lot of options based on the version of PHP installed. I did read elswhere that the nl2br had changed and was "not so smart" (not my words).

I assume they mean this reference:
PHP:

nl2br
(htmlspecialchars($part['text']));
Once I got here I figured it was time to see the professionals and so here I am. And lo and behold you are having the same issue!

I am guessing you are using a newer version of PHP for the site and so having similar issues? Searching things like php and bbcode on the forums here is a bit overwhelming so I am just posting this here hoping soemone else has seen this and is working on it.


Bedevere's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website AIM Address Yahoo Messenger
Phoenix
• Many Posts •
• Many Posts •

Offline Offline
Joined: Apr 19, 2004
Posts: 8799
Location: Netizen
PostPosted: Sun Jan 11, 2009 2:01 am
Post subject: Re: PHP BBcode not working - PHP version issues?

It's been raised before and works fine, see my edit - it's a php5 issue - just ensure you start with <?php


Phoenix's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website Photo Gallery
Bedevere
Nice poster
Nice poster

Offline Offline
Joined: Jul 06, 2006
Posts: 83
Location: New York City
PostPosted: Sun Jan 11, 2009 3:12 am
Post subject: Re: PHP BBcode not working - PHP version issues?

Testing:

PHP:
<?php	function decode_php($text)	{		global $bb_codes;		$text = str_replace("\r\n", "\n", substr($text, 5, -6)); # Windows		$text = str_replace("\r", "\n", $text);   # Mac		$text = str_replace("\t", '	', $text); # Temporary tab fix		$text = htmlunprepare($text, true);		$added = FALSE;		if (preg_match('/^<\?.*/', $text) <= 0) {			$text = "<?php\n$text";			$added = TRUE;		}		if (PHPVERS < 42) {			ob_start();			highlight_string($text);			$text = ob_get_contents();			ob_end_clean();		} else {			$text = highlight_string($text, TRUE);		}		if (PHPVERS < 50) {			$text = preg_replace('/<font color="(.*?)">/si', '<span style="color: \\1;">', $text);			$text = str_replace('</font>', '</span>', $text);		}		if ($added == TRUE) {			if (PHPVERS < 50) {				$text = preg_replace('/^(.*)\n.*?<\/span>(.*)php<br \/>/i', "\\1\n\\2?php<br />", $text, 1);			}			$text = preg_replace('/^(.*)\n.*php<br \/><\/span>/i', "\\1\n", $text, 1);			$text = preg_replace('/^(.*)\n(.*)>.*php<br \/>/i', "\\1\n\\2>", $text, 1);		}		$text = str_replace('[', '&#91;', $text);		$text = str_replace("\n", '', $text);		$text = str_replace('&nbsp;', ' ', $text);		$text = str_replace('	', "\t", $text);		$text = preg_replace('#<span style="color: \#[A-F0-9]{6}">([\t]+)</span>#', '\\1', $text);		return $bb_codes['php_start']."<pre>$text</pre>".$bb_codes['php_end'];	}
?>


Well thanks for the fix! Is this a big pain in the ass to fix for php 5 or is this considered working as intended?


Bedevere's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:   
Post new topic    Reply to topic    Printer Friendly Page    Forum Index ⇒  Problems AFTER Install/Upgrade
Page 1 of 1
All times are GMT



Jump to:  


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


 
   Toggle Content User Info

Welcome Anonymous

Nickname
Password
(Register)

   Toggle Content Last CVS commits
· Fixed .ico Expires header.
· Removed domain name from cookies so subdomains wont access them anymore.
· CSS and JS, case insensitives.
· CSS and JS, send correct HTTP 1.1 headers and fixed issues where themes and...
· Further security class improvements.
· 301 redirects on LEO changes
· Option to force 3xx http status codes
· Validate googlebot.com and google.com crawlers.
· CCBot
· Rss with etag and atom.

Číta ďalej...

   Toggle Content Community

Support for DragonflyCMS in a other languages:

Deutsch
Español

   Toggle Content X-links
UltraEdit Browse Happy logo Firefox MySQL PostgreSQL Valid CSS! Valid XHTML 1.0! Unicode Encoded Badge NukeBiz Resources Raven DragonflyCMS Dedicated Now InsideSupport Lampe Berger

You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
Interactive software released under GNU GPL, Code Credits, Privacy Policy