Page 1 of 14

[Tool] phpBB 2.0.19 to phpBB 2.0.20 Changes

Posted: Fri Apr 07, 2006 7:04 pm
by Extensions Robot
Classification: 48 phpBB Installation & Upgrade Tools

MOD Name: phpBB 2.0.19 to phpBB 2.0.20 Changes
Author: Graham
MOD Description: Code Changes from phpBB 2.0.19 to 2.0.20 in three formats (text/mod, html, bbcode prepared for posting the changes on phpBB forums).


MOD Version: 1.0.0
Installation Level: Intermediate
Installation Time: ~ 20 Minutes

Download File: phpBB-2.0.20-codechanges.zip (Preferred) phpBB-2.0.20-codechanges.zip (Alternate)
File Size: 24437 Bytes

Security Score: 0

Support for this MOD needs to be asked within this topic. The phpBB Teams are not responsible or required to give anyone support for this MOD. By installing this MOD, the phpBB Support Team or phpBB MODifications Team may not be able to provide support.

This MOD has only been tested by the phpBB MOD Team with the phpBB version in the topic title. It may not work in any other versions of phpBB.

Posted: Sat Apr 08, 2006 4:42 pm
by Graham
MOD Validated/Released

Notes:
The updated version of the code changes MOD as listed in the announcement

Posted: Sat Apr 08, 2006 4:45 pm
by aboyd
I note it was posted on the 7th, and it says it's version 1.0.0. However, there was a re-release on the 8th, with fixed code (I assume that would make it version 1.0.1). So does the original post contain the most up-to-date code?

-Tony

Posted: Sat Apr 08, 2006 5:35 pm
by stickerboy
I was a bit apprehensive about this update as I have aquite a few MODs and it's not the smallest of updates, but I'm glad to report it went fine :)
I'll keep looking for conflicts, but so far most of the big MODs - Cash, Attatchments and Attached Forums, have taken to it fine.

cheers :wink:

Posted: Sat Apr 08, 2006 5:39 pm
by Seraphic
Update went well.

Posted: Sat Apr 08, 2006 6:22 pm
by BigRed01
Used easy mod with no problems :D

Posted: Sat Apr 08, 2006 6:23 pm
by asinshesq
The following change in includes/functions_post.php kills the ability to recognize named quotes (quotes in the format [qoute="asinshesq"]...) on my board:

Code: Select all

# 
#-----[ OPEN ]--------------------------------------------- 
# 
includes/functions_post.php

#
#-----[ FIND ]---------------------------------------------
# Line 44
		$allowed_html_tags = split(',', $board_config['allow_html_tags']);

		$end_html = 0;
		$start_html = 1;
		$tmp_message = '';
		$message = ' ' . $message . ' ';

		while ($start_html = strpos($message, '<', $start_html))
		{
			$tmp_message .= preg_replace($html_entities_match, $html_entities_replace, substr($message, $end_html + 1, ($start_html - $end_html - 1)));

			if ($end_html = strpos($message, '>', $start_html))
			{
				$length = $end_html - $start_html + 1;
				$hold_string = substr($message, $start_html, $length);

				if (($unclosed_open = strrpos(' ' . $hold_string, '<')) != 1)
				{
					$tmp_message .= preg_replace($html_entities_match, $html_entities_replace, substr($hold_string, 0, $unclosed_open - 1));
					$hold_string = substr($hold_string, $unclosed_open - 1);
				}

				$tagallowed = false;
				for ($i = 0; $i < sizeof($allowed_html_tags); $i++)
				{
					$match_tag = trim($allowed_html_tags[$i]);
					if (preg_match('#^<\/?' . $match_tag . '[> ]#i', $hold_string))
					{
						$tagallowed = (preg_match('#^<\/?' . $match_tag . ' .*?(style[\t ]*?=|on[\w]+[\t ]*?=)#i', $hold_string)) ? false : true;
					}
				}

				$tmp_message .= ($length && !$tagallowed) ? preg_replace($html_entities_match, $html_entities_replace, $hold_string) : $hold_string;

				$start_html += $length;
			}
			else
			{
				$tmp_message .= preg_replace($html_entities_match, $html_entities_replace, substr($message, $start_html, strlen($message)));

				$start_html = strlen($message);
				$end_html = $start_html;
			}
		}

		if (!$end_html || ($end_html != strlen($message) && $tmp_message != ''))
		{
			$tmp_message .= preg_replace($html_entities_match, $html_entities_replace, substr($message, $end_html + 1));
		}

		$message = ($tmp_message != '') ? trim($tmp_message) : trim($message);

#
#-----[ REPLACE WITH ]---------------------------------------------
#
		// If HTML is on, we try to make it safe
		// This approach is quite agressive and anything that does not look like a valid tag
		// is going to get converted to HTML entities
		$message = stripslashes($message);
		$html_match = '#<[^\w<]*(\w+)((?:"[^"]*"|\'[^\']*\'|[^<>\'"])+)?>#';
		$matches = array();

		$message_split = preg_split($html_match, $message);
		preg_match_all($html_match, $message, $matches);

		$message = '';

		foreach ($message_split as $part)
		{
			$tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2]));
			$message .= htmlspecialchars($part) . clean_html($tag);
		}

		$message = addslashes($message);
When I leave that change out all is fine. This is probably a problem on my end (I have my board very heavily modded and have fooled around with html before). I'll try to track this down over the weekend and report back (and I'll test it on a plain vaniall phpbb2.0.19 upgrade to 2.0.20 to see whether all is fine there) but in the meantime I figured I'd mention it here in case anyone else runs into this problem. (And actually, I would appreciate it if anyone who has this problem replies to this post so I can confirm it's not solely my setup.)

Posted: Sat Apr 08, 2006 6:34 pm
by abramelin
lastvisit hack conflicts with the new phpbb 2.0.20 search.php
here is the code changes in 2.0.20's search.php

Code: Select all

# 
#-----[ FIND ]--------------------------------------------- 
# Line 646 
      // Finish building query (for all combinations) 
      // and run it ... 
      // 
      $sql = "SELECT session_id 
         FROM " . SESSIONS_TABLE; 
      if ( $result = $db->sql_query($sql) ) 
      { 
         $delete_search_ids = array(); 
         while( $row = $db->sql_fetchrow($result) ) 
         { 
            $delete_search_ids[] = "'" . $row['session_id'] . "'"; 
         } 

         if ( count($delete_search_ids) ) 
         { 
            $sql = "DELETE FROM " . SEARCH_TABLE . " 
               WHERE session_id NOT IN (" . implode(", ", $delete_search_ids) . ")"; 
            if ( !$result = $db->sql_query($sql) ) 
            { 
               message_die(GENERAL_ERROR, 'Could not delete old search id sessions', '', __LINE__, __FILE__, $sql); 
            } 
         } 

# 
#-----[ REPLACE WITH ]--------------------------------------------- 
# 
      // Delete old data from the search result table 
      // 
      $sql = 'DELETE FROM ' . SEARCH_TABLE . ' 
         WHERE search_time < ' . ($current_time - (int) $board_config['session_length']); 
      if ( !$result = $db->sql_query($sql) ) 
      { 
         message_die(GENERAL_ERROR, 'Could not delete old search id sessions', '', __LINE__, __FILE__, $sql);
and these are the lines i got in my seach.php(2.0.19) (with the modification of lastvisit)

Code: Select all

// Finish building query (for all combinations) 
      // and run it ... 
      // 
      // Start replacement - Last visit MOD 
   $expiry_time = $current_time - $board_config['session_length']; 
      $sql = "SELECT session_id 
         FROM " . SESSIONS_TABLE ." WHERE session_time>$expiry_time"; 
// Start replacement - Last visit MOD 
      if ( $result = $db->sql_query($sql) ) 
      { 
         $delete_search_ids = array(); 
         while( $row = $db->sql_fetchrow($result) ) 
         { 
            $delete_search_ids[] = "'" . $row['session_id'] . "'"; 
         } 

         if ( count($delete_search_ids) ) 
         { 
            $sql = "DELETE FROM " . SEARCH_TABLE . " 
               WHERE session_id NOT IN (" . implode(", ", $delete_search_ids) . ")"; 
            if ( !$result = $db->sql_query($sql) ) 
            { 
               message_die(GENERAL_ERROR, 'Could not delete old search id sessions', '', __LINE__, __FILE__, $sql); 
            } 
         } 
what must i do?

Posted: Sat Apr 08, 2006 6:40 pm
by Seraphic
abramelin wrote: what must i do?

Code: Select all

		// Delete old data from the search result table
		//

// Start replacement - Last visit MOD
    	$expiry_time = $current_time - $board_config['session_length'];
		$sql = "SELECT session_id
			FROM " . SESSIONS_TABLE ." WHERE session_time>$expiry_time";
// Start replacement - Last visit MOD

		$sql = 'DELETE FROM ' . SEARCH_TABLE . '
			WHERE search_time < ' . ($current_time - (int) $board_config['session_length']);
		if ( !$result = $db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, 'Could not delete old search id sessions', '', __LINE__, __FILE__, $sql);

Posted: Sat Apr 08, 2006 6:41 pm
by Seraphic
asinshesq wrote: The following change in includes/functions_post.php kills the ability to recognize named quotes (quotes in the format [qoute="asinshesq"]...) on my board:


It looks like a lot of people are having this problem. But on my forum at least, I didn't have this problem.

Posted: Sat Apr 08, 2006 7:07 pm
by asinshesq
Seraphic wrote: ...It looks like a lot of people are having this problem. But on my forum at least, I didn't have this problem.


I didn't see any posts on this...are other people reporting that problem somewhere?

I remember a prior upgrade created some problems when html was enabled and there was a workaround...I'm guessing this problem is tied to that same problem. Hopefully I'll have a chance to track this down over the weekend but in the meantime leaving out that one change fixes things (or alternatively you can disable html on your board since that part of the code does not get executed unless you have html enabled).

By teh way, Seraphic, do you have html enabled? If not, could you turn it on temproarily to see if you suddenly start having that problem?

Posted: Sat Apr 08, 2006 7:16 pm
by Seraphic
There are a few posts about the issue you're talking about in the main phpbb support forum. http://www.phpbb.com/phpBB/viewforum.php?f=1

Also, I turned on html and tried a test quote. It still works fine.

Posted: Sat Apr 08, 2006 8:52 pm
by asinshesq
The support team beat me to it. If you are having a problem with quotes iwth names in them when you have html turned on, see this post for a fix: http://www.phpbb.com/phpBB/viewtopic.ph ... 63#2079863

Posted: Sat Apr 08, 2006 9:26 pm
by delicata
I made these upgrade changes today and all seemed well...until I pressed 'quote' in a private message and got this:

Warning: preg_replace(): Empty regular expression in /home/maltbyonliuk/public_html/community/privmsg.php on line 1524

Warning: Cannot modify header information - headers already sent by (output started at /home/maltbyonliuk/public_html/community/privmsg.php:1524) in /home/maltbyonliuk/public_html/community/includes/page_header.php on line 501

Warning: Cannot modify header information - headers already sent by (output started at /home/maltbyonliuk/public_html/community/privmsg.php:1524) in /home/maltbyonliuk/public_html/community/includes/page_header.php on line 503

Warning: Cannot modify header information - headers already sent by (output started at /home/maltbyonliuk/public_html/community/privmsg.php:1524) in /home/maltbyonliuk/public_html/community/includes/page_header.php on line 504

Any ideas anyone?

Cheers

Posted: Sat Apr 08, 2006 9:38 pm
by amoun
I think the code has an error :

the bit

"$html_match = '#<[^\w<]*(\w+)((?:"[^"]*"|\'[^\']*\'|[^<>\'"])+)?>#';" shouldn't have the '?>' bit as it ends the php script ???


I think. There's screwed hightlighting in my editor. Remove the ?> and it all looks fine.

Can someone confirm that it is an error please.


Amoun
asinshesq wrote: The following change in includes/functions_post.php kills the ability to recognize named quotes (quotes in the format [qoute="asinshesq"]...) on my board:

Code: Select all

# 
#-----[ OPEN ]--------------------------------------------- 
# 
includes/functions_post.php

#
#-----[ FIND ]---------------------------------------------
# Line 44
		$allowed_html_tags = split(',', $board_config['allow_html_tags']);

		$end_html = 0;
		$start_html = 1;
		$tmp_message = '';
		$message = ' ' . $message . ' ';

		while ($start_html = strpos($message, '<', $start_html))
		{
			$tmp_message .= preg_replace($html_entities_match, $html_entities_replace, substr($message, $end_html + 1, ($start_html - $end_html - 1)));

			if ($end_html = strpos($message, '>', $start_html))
			{
				$length = $end_html - $start_html + 1;
				$hold_string = substr($message, $start_html, $length);

				if (($unclosed_open = strrpos(' ' . $hold_string, '<')) != 1)
				{
					$tmp_message .= preg_replace($html_entities_match, $html_entities_replace, substr($hold_string, 0, $unclosed_open - 1));
					$hold_string = substr($hold_string, $unclosed_open - 1);
				}

				$tagallowed = false;
				for ($i = 0; $i < sizeof($allowed_html_tags); $i++)
				{
					$match_tag = trim($allowed_html_tags[$i]);
					if (preg_match('#^<\/?' . $match_tag . '[> ]#i', $hold_string))
					{
						$tagallowed = (preg_match('#^<\/?' . $match_tag . ' .*?(style[\t ]*?=|on[\w]+[\t ]*?=)#i', $hold_string)) ? false : true;
					}
				}

				$tmp_message .= ($length && !$tagallowed) ? preg_replace($html_entities_match, $html_entities_replace, $hold_string) : $hold_string;

				$start_html += $length;
			}
			else
			{
				$tmp_message .= preg_replace($html_entities_match, $html_entities_replace, substr($message, $start_html, strlen($message)));

				$start_html = strlen($message);
				$end_html = $start_html;
			}
		}

		if (!$end_html || ($end_html != strlen($message) && $tmp_message != ''))
		{
			$tmp_message .= preg_replace($html_entities_match, $html_entities_replace, substr($message, $end_html + 1));
		}

		$message = ($tmp_message != '') ? trim($tmp_message) : trim($message);

#
#-----[ REPLACE WITH ]---------------------------------------------
#
		// If HTML is on, we try to make it safe
		// This approach is quite agressive and anything that does not look like a valid tag
		// is going to get converted to HTML entities
		$message = stripslashes($message);
		$html_match = '#<[^\w<]*(\w+)((?:"[^"]*"|\'[^\']*\'|[^<>\'"])+)?>#';
		$matches = array();

		$message_split = preg_split($html_match, $message);
		preg_match_all($html_match, $message, $matches);

		$message = '';

		foreach ($message_split as $part)
		{
			$tag = array(array_shift($matches[0]), array_shift($matches[1]), array_shift($matches[2]));
			$message .= htmlspecialchars($part) . clean_html($tag);
		}

		$message = addslashes($message);
When I leave that change out all is fine. This is probably a problem on my end (I have my board very heavily modded and have fooled around with html before). I'll try to track this down over the weekend and report back (and I'll test it on a plain vaniall phpbb2.0.19 upgrade to 2.0.20 to see whether all is fine there) but in the meantime I figured I'd mention it here in case anyone else runs into this problem. (And actually, I would appreciate it if anyone who has this problem replies to this post so I can confirm it's not solely my setup.)