<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================
	// view recent messages
	// ========================================================================================
	
	
	
	ReadPermissions();
	Global $Permissions;
	

	$Arguments3 = intval($Arguments3);
	
	if ($Arguments3 < 1) {
		$Arguments3 = 1;
	}
	if ($Arguments3 > 100) {
		$Arguments3 = 1;
	}
		
		
			$PageTitle = '<div align="'.$AlignmentCodes[$mbSettings['TitleAlignment']].'">'.$mbSettings['PageTitle'].'</div>';
			$BrowserTitle = $mbSettings['PageTitle'] . ' - '.$MsgText[2][88];
			$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="'.$MainURL.'/forum.html">'.$mbSettings['PageTitle'].'</a> > '.$MsgText[2][88];


			
			for ($i = 33; $i <= 126; $i++) {
				$HTMLCodes[chr($i)] = $i;
			}
					
			
			
			$CharsToReplaceArray[';'] = 1;
			
			$SearchChars[] = '[';
			$ReplacementChars[] = '&#'.$HTMLCodes['['].';';
			$CharsToReplaceArray['['] = 1;
			
			$SearchChars[] = '/';
			$ReplacementChars[] = '&#'.$HTMLCodes['/'].';';
			$CharsToReplaceArray['/'] = 1;
			
			$SearchChars[] = ']';
			$ReplacementChars[] = '&#'.$HTMLCodes[']'].';';
			$CharsToReplaceArray[']'] = 1;
			
			
			$CharsToReplaceArray['&'] = 1;
			
			$CharsToReplaceArray['#'] = 1;
			
			$CharsToReplaceArray['l'] = 1;
			$CharsToReplaceArray['t'] = 1;
			
			
			for ($w = 0; $w <= 9; $w++) {
				$CharsToReplaceArray[$w] = 1;			
			}
			
			
			

				// smilies setup
				$query8 = "select * from `".$Settings['DBPrefix']."core-Smilies` where Enabled=1";
				$result8 = mysql_query($query8) or die (mysql_error());
				while ($row8 = mysql_fetch_array($result8)) {
				
					if ($row8['InsertCode'] != '') {
						$SmiliesCount++;
						$SmilieCodes[] = $row8['InsertCode'];
						$SmilieFiles[$row8['InsertCode']] = $row8['ImageLink'];
						$SmilieDescriptions[$row8['InsertCode']] = $row8['Description'];
					}
					if ($row8['InsertCode2'] != '') {
						$SmiliesCount++;
						$SmilieCodes[] = $row8['InsertCode2'];
						$SmilieFiles[$row8['InsertCode2']] = $row8['ImageLink'];
						$SmilieDescriptions[$row8['InsertCode2']] = $row8['Description'];
					}
					if ($row8['InsertCode3'] != '') {
						$SmiliesCount++;
						$SmilieCodes[] = $row8['InsertCode3'];
						$SmilieFiles[$row8['InsertCode3']] = $row8['ImageLink'];
						$SmilieDescriptions[$row8['InsertCode3']] = $row8['Description'];
					}
					if ($row8['InsertCode4'] != '') {
						$SmiliesCount++;
						$SmilieCodes[] = $row8['InsertCode4'];
						$SmilieFiles[$row8['InsertCode4']] = $row8['ImageLink'];
						$SmilieDescriptions[$row8['InsertCode4']] = $row8['Description'];
					}
					if ($row8['InsertCode5'] != '') {
						$SmiliesCount++;
						$SmilieCodes[] = $row8['InsertCode5'];
						$SmilieFiles[$row8['InsertCode5']] = $row8['ImageLink'];
						$SmilieDescriptions[$row8['InsertCode5']] = $row8['Description'];
					}
									
				}
				
				if ($SmiliesCount > 0) {
				
					for ($i = 0; $i < $SmiliesCount; $i++) {
						for ($h = 0; $h < ($SmiliesCount-1); $h++) {
						
							if (strlen($SmilieCodes[$h]) < strlen($SmilieCodes[$h+1])) {
									
								$Swap1 = $SmilieCodes[$h+1];
																	
								$SmilieCodes[$h+1] = $SmilieCodes[$h];
																
								$SmilieCodes[$h] = $Swap1;
									
							}
									
						}
					}
				
				
				
					for ($i = 0; $i < $SmiliesCount; $i++) {
									
						for ($x = 0; $x < strlen($SmilieCodes[$i]); $x++) {
						
							$CurrentChar = substr($SmilieCodes[$i], $x, 1);
		
							if ($CharsToReplaceArray[$CurrentChar] != 1) {
							
								$SearchChars[] = $CurrentChar;
								$ReplacementChars[] = '&#'.$HTMLCodes[$CurrentChar].';';
							
							}
						
						}
					
					}
				
				
				
					for ($i = 0; $i < $SmiliesCount; $i++) {
					
							
						$SmiliesSearchArray[] = ' ' . $SmilieCodes[$i];
						
						if (substr($SmilieFiles[$SmilieCodes[$i]],0,4) != 'http') {
							$SmilieFiles[$SmilieCodes[$i]] = $ImagesURL . '/smilies/' . $SmilieFiles[$SmilieCodes[$i]]; 
						}
						
						$SmiliesReplaceArray[] = '<img src="'.$SmilieFiles[$SmilieCodes[$i]].'" alt="'.$SmilieDescriptions[$SmilieCodes[$i]].'">';
												
					
					}
				
				}

						
			
			
						
			
			
			$MessagesList .= '<table width="100%" border="0" cellspacing="1" cellpadding="0">';
			
				
			$MessagesList .= '<tr><td><table width="100%" border="0" cellspacing="0" cellpadding="1"><tr><td bgcolor="'.$Colors['MBBorder'].'"><table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="'.$Colors['BG'].'"><table width="100%" border="0" cellspacing="0" cellpadding="0">';
			
			
			
			
			// read in boards...
			$query = "select Title,Category,RecordNumber from `".$Settings['DBPrefix']."mb-Boards`";
			$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
				$BoardTitles[$row['RecordNumber']] = $row['Title'];
				$BoardCategories[$row['RecordNumber']] = $row['Category'];
			}
			
			// ...and categories
			$query = "select Title,RecordNumber from `".$Settings['DBPrefix']."mb-Categories`";
			$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
				$CategoryTitles[$row['RecordNumber']] = $row['Title'];
			}
		
		
			// run through the threads in reverse date order limited by the page number in arguments3
			$query = "select ThreadID,Poster,Subject,Message,DateCode from `".$Settings['DBPrefix']."mb-Messages` left join `".$Settings['DBPrefix']."mb-Threads` on `".$Settings['DBPrefix']."mb-Threads`.RecordNumber=`".$Settings['DBPrefix']."mb-Messages`.ThreadID left join `".$Settings['DBPrefix']."mb-Boards` on `".$Settings['DBPrefix']."mb-Boards`.RecordNumber=`".$Settings['DBPrefix']."mb-Threads`.BoardID left join `".$Settings['DBPrefix']."mb-Categories` on `".$Settings['DBPrefix']."mb-Categories`.RecordNumber=`".$Settings['DBPrefix']."mb-Boards`.Category where `".$Settings['DBPrefix']."mb-Boards`.MinLevel<=".$UserLevel." and `".$Settings['DBPrefix']."mb-Categories`.MinLevel<=".$UserLevel." order by DateCode desc limit ".(($Arguments3*10)+1);
			$result = mysql_query($query) or die (mysql_error());
			
			if (mysql_num_rows($result) == (($Arguments3*10)+1)) {
				$NextPage = 'y';
				$MessagesThisPage = 10;
			}
			else {
				$MessagesThisPage = (mysql_num_rows($result)-(($Arguments3-1)*10));
			}
			
			$BGColor = $Colors['MBBG'];
			
			while ($row = mysql_fetch_array($result)) {
				
				$Counter++;
			
				$BackwardsThreadCount[$row['ThreadID']]++;
				
								
				
				
				
				if ($Counter > (($Arguments3-1)*10) && $Counter < (($Arguments3*10)+1)) {
				
					$Counter2++;
					
		
					$ThreadID = $row['ThreadID'];
					$MessageID = $row['RecordNumber'];
			
						
					$query34 = "select * from `".$Settings['DBPrefix']."mb-Threads` where RecordNumber=".$ThreadID." limit 1";
					$result34 = mysql_query($query34) or die (mysql_error());
					$row34 = mysql_fetch_array($result34);
					
					$MessagesCount = ($row34['Replies'] + 1);
					$ThreadTitle = $row34['Title'];
					$BoardID = $row34['BoardID'];
					
					
					$MessagesCount = $MessagesCount - $BackwardsThreadCount[$ThreadID];
					
					$MessagePage = intval($MessagesCount / $mbSettings['MessagesPerPage']);
					if (($MessagesCount / $mbSettings['MessagesPerPage']) != intval($MessagesCount / $mbSettings['MessagesPerPage'])) {
						$MessagePage++;
					}
					
					if ($MessagePage == 0) {
						$MessagePage = 1;
					}
					
					$ThreadMessageNumber = (($MessagesCount+1)-(($MessagePage-1)*$mbSettings['MessagesPerPage']));
					//$ThreadMessageNumber = ($MessagesCount+1);
					
					
					
					// set up the posting user display (just the name for guests, link to profile for members)
				if ($LoggedIn == 'y' && $row['Poster'] > 0) {
					$PosterLink = '<a href="'.$MainURL.'/profile/'.$Usernames[$row['Poster']].'.html"><font color="'.$Colors['MBText'].'">'.$DisplayNames[$row['Poster']].'</font></a>';
				}
				else {
					$PosterLink = $DisplayNames[$row['Poster']];
				}
				
				// set up the date display ("today", "yesterday", or the actual date, followed by the time)
				if (date("j/n/Y", GetTimestamp()) == date("j/n/Y", $row['DateCode'])) {
					$PostDate = $MsgText[2][66].' @ '.date("g:ia", $row['DateCode']);
				}
				else if (date("j/n/Y", (GetTimestamp()-(60*60*24))) == date("j/n/Y", $row['DateCode'])) {
					$PostDate = $MsgText[2][67].' @ '.date("g:ia", $row['DateCode']);
				}
				else {
					$PostDate = $MsgText[0][33+date("n",$row['DateCode'])].' '.date("j, Y @ g:ia", $row['DateCode']);
				}
				
	
				$row['Message'] = str_replace('<', '&lt;', $row['Message']);
				//$row['Message'] = str_replace("\n", '<br>', $row['Message']);
				//$row['Message'] = str_replace("\r", '', $row['Message']);
				
								
				$LowerCaseMessage = strtolower($row['Message']);
				
				
				// code -- do first
										
				// if [code] exists in message
				if (strpos($LowerCaseMessage,'[code]',0) !== false) {
				
					$Subject = $LowerCaseMessage;
					
					$OpenTags = '';
					$OpenTagsCount = 0;
					$CloseTags = '';
					$CloseTagsCount = 0;
					$AllTags = '';
					$AllTagsPos = '';
					$TotalTagsCount = 0;
					$AllTagsLevels = '';
					
					
					$Position = 0;
					$CurrentPos = 0;
										
					while (strpos($Subject,'[code]',$CurrentPos) !== false) {
						
						$Position = strpos($Subject,'[code]',$CurrentPos);
					
						$OpenTags[] = $Position;
						$OpenTagsCount++;
						$CurrentPos = $Position+strlen('[code]');
					
					}
					
		
					
					$Position = 0;
					$CurrentPos = 0;
					$Subject = strtolower($row['Message']);
					
					while (strpos($Subject,'[/code]',$CurrentPos) !== false) {
						
						$Position = strpos($Subject,'[/code]',$CurrentPos);
					
						$CloseTags[] = $Position;
						$CloseTagsCount++;
						$CurrentPos = $Position+strlen('[/code]');				
					}
					
					
					for ($i = 1; $i <= $OpenTagsCount; $i++) {
						$AllTags[] = 'open';
						$AllTagsPos[] = $OpenTags[$i-1];
					}
					for ($i = 1; $i <= $CloseTagsCount; $i++) {
						$AllTags[] = 'close';
						$AllTagsPos[] = $CloseTags[$i-1];
					}
									
					$TotalTagsCount = ($OpenTagsCount+$CloseTagsCount);
					
					
					for ($g = 0; $g < $TotalTagsCount; $g++) {
						for ($h = 0; $h < ($TotalTagsCount-1); $h++) {
	
							if ($AllTagsPos[$h] > $AllTagsPos[$h+1]) {
										
								$Swap1 = $AllTagsPos[$h+1];
								$Swap2 = $AllTags[$h+1];
																	
								$AllTagsPos[$h+1] = $AllTagsPos[$h];
								$AllTags[$h+1] = $AllTags[$h];
																	
								$AllTagsPos[$h] = $Swap1;
								$AllTags[$h] = $Swap2;
								
										
							}
						
						}
					}
				
					
					$Level = 1;
					for ($g = 0; $g < $TotalTagsCount; $g++) {
					
						if ($g > 0) {
						
							if ($AllTags[$g] == 'open' && $AllTags[$g-1] == 'open') {
								$Level++;
							}
							if ($AllTags[$g] == 'close' && $AllTags[$g-1] == 'close') {
								$Level--;
							}
						
						}
						
						$AllTagsLevels[$g] = $Level;
					
					}	
					
					
					
					
					for ($g = 0; $g < $TotalTagsCount; $g++) {
						for ($h = 0; $h < ($TotalTagsCount-1); $h++) {
	
							if ($AllTagsLevels[$h] > $AllTagsLevels[$h+1]) {
										
								$Swap1 = $AllTagsPos[$h+1];
								$Swap2 = $AllTags[$h+1];
								$Swap3 = $AllTagsLevels[$h+1];
																	
								$AllTagsPos[$h+1] = $AllTagsPos[$h];
								$AllTags[$h+1] = $AllTags[$h];
								$AllTagsLevels[$h+1] = $AllTagsLevels[$h];
																	
								$AllTagsPos[$h] = $Swap1;
								$AllTags[$h] = $Swap2;
								$AllTagsLevels[$h] = $Swap3;
								
										
							}
						
						}
					}
					
					
					
					// using the real version now, not the one converted to lower case for pattern matching:
					$Subject = $row['Message'];
												
					
					for ($g = 0; $g < $TotalTagsCount; $g=$g+2) {
										
						$FirstHalfBefore = substr($Subject,0,($AllTagsPos[$g]+6));
						$SecondHalfBefore = substr($Subject,$AllTagsPos[$g+1]);
						
						$LengthBefore = strlen($Subject);
						
						$Subject = $FirstHalfBefore . str_replace($SearchChars, $ReplacementChars, substr($Subject,($AllTagsPos[$g]+6), (($AllTagsPos[$g+1])-($AllTagsPos[$g]+6)) ) ) . $SecondHalfBefore;

						$LengthAfter = strlen($Subject);
					
						
						$AdditionalLength = ($LengthAfter-$LengthBefore);
					
						
						for ($h = ($g+2); $h < $TotalTagsCount; $h++) {
							$AllTagsPos[$h] = ($AllTagsPos[$h] + $AdditionalLength);			
						}
					
					}	
				
				
					$row['Message'] = $Subject;
								
				
					$row['Message'] = preg_replace("/(\[code\])(.*?)(\[\/code\])/sie", "'<img src=\"'.\$TemplateImagesURL.'/admin/spacer.gif\" border=\"0\" width=\"1\" height=\"10\" alt=\"\"><br><table width=\"90%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBorder'].'\"><table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBG'].'\"><font face=\"'.\$FontFace.'\" size=\"'.\$FontSize.'\" color=\"'.\$Colors['MBQCText'].'\"><b>Code</b><br><br>'.stripslashes('\\2').'</font></td></tr></table></td></tr></table>'", $row['Message']);


				} // end if [code] found in message
				
				
				
				// smilies
				//if ($DoSmilies != false) {		
					$row['Message'] = str_replace($SmiliesSearchArray, $SmiliesReplaceArray, $row['Message']);
				//}
				
				
				$row['Message'] = str_replace("\n", '[br]', $row['Message']);
				$row['Message'] = str_replace("\r", '', $row['Message']);
				
				
				// horizontal rule (hr)
				$row['Message'] = str_replace('[hr]', '<hr>', $row['Message']);
				
				
				// font faces and sizes
				$row['Message'] = preg_replace("/(\[font=)(.*?)(\])/i", "<font face=\"\\2\">", $row['Message']);
				$row['Message'] = preg_replace("/(\[size=)(.*?)(\])/i", "<font size=\"\\2\">", $row['Message']);
				
				$row['Message'] = str_replace('[/font]', '</font>', $row['Message']);
				$row['Message'] = str_replace('[/size]', '</font>', $row['Message']);
				
				
				// bold
				$row['Message'] = preg_replace("/(\[b\])(.*?)(\[\/b\])/i", "<b>\\2</b>", $row['Message']);
				//$row['Message'] = str_replace('[b]', '<b>', $row['Message']);
				//$row['Message'] = str_replace('[/b]', '</b>', $row['Message']);
				//$row['Message'] = preg_replace("/\[b\]/i", "<b>", $row['Message']); 
				//$row['Message'] = preg_replace("/\[\/b\]/i", "</b>", $row['Message']); 
				
				// italics
				$row['Message'] = preg_replace("/(\[i\])(.*?)(\[\/i\])/i", "<i>\\2</i>", $row['Message']);
				//$row['Message'] = str_replace('[i]', '<i>', $row['Message']);
				//$row['Message'] = str_replace('[/i]', '</i>', $row['Message']);
				//$row['Message'] = preg_replace("/\[i\]/i", "<i>", $row['Message']); 
				//$row['Message'] = preg_replace("/\[\/i\]/i", "</i>", $row['Message']);
				
				// underline
				$row['Message'] = preg_replace("/(\[u\])(.*?)(\[\/u\])/i", "<u>\\2</u>", $row['Message']);
				//$row['Message'] = str_replace('[u]', '<u>', $row['Message']);
				//$row['Message'] = str_replace('[/u]', '</u>', $row['Message']); 
				//$row['Message'] = preg_replace("/\[\/u\]/i", "</u>", $row['Message']);
				
				
				// colors
				$ColorCodes['black'] = '#000000';
				$ColorCodes['white'] = '#ffffff';
				$ColorCodes['red'] = '#ff0000';
				$ColorCodes['yellow'] = '#ffff00';
				$ColorCodes['green'] = '#008000';
				$ColorCodes['grey'] = '#888888';
				$ColorCodes['burgundy'] = '#990000';
				$ColorCodes['orange'] = '#ff9900';
				$ColorCodes['purple'] = '#9900ff';
				$ColorCodes['cream'] = '#ffffcc';
				$ColorCodes['teal'] = '#008080';
				$ColorCodes['salmon'] = '#ffcccc';
				$ColorCodes['blue'] = '#0000ff';
				$ColorCodes['pink'] = '#ff33cc';
				$ColorCodes['navy'] = '#003399';
				$ColorCodes['lightblue'] = '#33ccff';
				$ColorCodes['mauve'] = '#666699';
				$ColorCodes['limegreen'] = '#00ff00';
				
				//$row['Message'] = preg_replace("/(\[color\=)([a-zA-Z]+)(\])/i", "<font color=\"\\2\">", $row['Message']);
				$StringMatches = substr_count($row['Message'],'[color=');
				for ($i = 1; $i <= $StringMatches; $i++) {				
					$row['Message'] = preg_replace("/(\[color\=)(.*?)(\])(.*?)(\[\/color\])/ie", "'<font color=\"'.\$ColorCodes['\\2'].'\">'.stripslashes('\\4').'</font>'", $row['Message']);
				}
				 
				//$row['Message'] = preg_replace("/(\[\/color\])/", "</font>", $row['Message']); 
				  
				
				// urls
				$row['Message'] = preg_replace("/(\[url=)(.*?)(\])(.*?)(\[\/url\])/ie", "'<a href=\"\\2\" target=\"_blank\"><font color=\"'.\$Colors['MBText'].'\">\\4</font></a>'", $row['Message']);
				$row['Message'] = preg_replace("/(\[url\])(.*?)(\[\/url\])/ie", "'<a href=\"\\2\" target=\"_blank\"><font color=\"'.\$Colors['MBText'].'\">\\2</font></a>'", $row['Message']);
				
					
				// images
				$row['Message'] = preg_replace("/(\[img\])(.*?)(\[\/img\])/i", "<img src=\"\\2\" border=\"0\" alt=\"\">", $row['Message']);
				
				
				
				// convert URLs in text to clickable tags
				$row['Message'] = preg_replace("/(?<!\"|\>)(http:\/\/)([\w\.\-\/]+)/e", "'<a href=\"\\0\" target=\"_blank\"><font color=\"'.\$Colors['MBText'].'\">\\0</font></a>'", $row['Message']);
				
				
				
				$row['Message'] = str_replace('[br]', '<br>', $row['Message']);
				
				
				
				// emails
				
				// if [email] exists in the message
				if (strpos($LowerCaseMessage,'[email]',0) !== false) {
				
					$StringLength1 = rand(8, 14);
					$StringLength2 = rand(6, 15);
					$CharactersArray = array ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9','0');								
					$Random1 = 'a';
					$Random2 = 'b';
					for ($i = 1; $i <= $StringLength1; $i++) {
						$RandomNum = rand(1, 62);
						$Random1 .= $CharactersArray[$RandomNum];
					}
					for ($i = 1; $i <= $StringLength2; $i++) {
						$RandomNum = rand(1, 62);
						$Random2 .= $CharactersArray[$RandomNum];
					}
				
				
					$row['Message'] = preg_replace("/(\[email\])(.*?)(@)(.*?)(\[\/email\])/ie", "'<script language=\"JavaScript\">var '.\$Random1.' = \'\\2\'; var '.\$Random2.' = \'\\4\'; document.write(\'<a href=\"mai\'+\'lto:\'+'.\$Random1.'+String.fromCharCode(64)+'.\$Random2.'+\'\"><font color=\"'.\$Colors['MBText'].'\">\'+'.\$Random1.'+String.fromCharCode(64)+'.\$Random2.'+\'</font></a>\');</script>'", $row['Message']);			
				
				} // end if [email] found in message
				
				
				// alignment
				/*
				$row['Message'] = str_replace('[left]', '<div align="left">', $row['Message']);
				$row['Message'] = str_replace('[/left]', '</div>', $row['Message']);
				$row['Message'] = str_replace('[center]', '<div align="center">', $row['Message']);
				$row['Message'] = str_replace('[/center]', '</div>', $row['Message']);
				$row['Message'] = str_replace('[right]', '<div align="right">', $row['Message']);
				$row['Message'] = str_replace('[/right]', '</div>', $row['Message']);
				*/
				$row['Message'] = preg_replace("/(\[left\])(.*?)(\[\/left\])/i", "<div align=\"left\">\\2</div>", $row['Message']);
				$row['Message'] = preg_replace("/(\[center\])(.*?)(\[\/center\])/i", "<div align=\"center\">\\2</div>", $row['Message']);
				$row['Message'] = preg_replace("/(\[right\])(.*?)(\[\/right\])/i", "<div align=\"right\">\\2</div>", $row['Message']);
				
				
				
				// quotes -- do last
				
				// if [quote exists in the message
				if (strpos($LowerCaseMessage,'[quote',0) !== false) {
				
					// quotes with a user
					$StringMatches = substr_count($row['Message'],'[quote=');
					for ($i = 1; $i <= $StringMatches; $i++) {				
						$row['Message'] = preg_replace("/(\[quote=)(.*?)(\])(.*?)(\[\/quote\])/ie", "'<img src=\"'.\$TemplateImagesURL.'/admin/spacer.gif\" border=\"0\" width=\"1\" height=\"10\" alt=\"\"><br><table width=\"90%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBorder'].'\"><table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBG'].'\"><font face=\"'.\$FontFace.'\" size=\"'.\$FontSize.'\" color=\"'.\$Colors['MBQCText'].'\"><b>Quote ('.stripslashes(\$DisplayNames[\\2]).')</b><br><br>'.stripslashes('\\4').'</font></td></tr></table></td></tr></table>'", stripslashes($row['Message']));
					}
					// quotes without a user
					$StringMatches = substr_count($row['Message'],'[quote]');
					for ($i = 1; $i <= $StringMatches; $i++) {				
						$row['Message'] = preg_replace("/(\[quote\])(.*?)(\[\/quote\])/ie", "'<img src=\"'.\$TemplateImagesURL.'/admin/spacer.gif\" border=\"0\" width=\"1\" height=\"10\" alt=\"\"><br><table width=\"90%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBorder'].'\"><table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBG'].'\"><font face=\"'.\$FontFace.'\" size=\"'.\$FontSize.'\" color=\"'.\$Colors['MBQCText'].'\"><b>Quote</b><br><br>'.stripslashes('\\2').'</font></td></tr></table></td></tr></table>'", $row['Message']);
					}
				
				
				} // end if [quote exists in the message
				
				
				
				// smilies				
				//$row['Message'] = str_replace($SmiliesSearchArray, $SmiliesReplaceArray, $row['Message']);
				
				
				
				
				
				
				// end of pattern matching
				
							
				$MessagesList .= '
				<tr><td width="100%" colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="'.$BGColor.'"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>

				<td bgcolor="'.$Colors['MBHeadingBG'].'" height="100%"><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="4"><tr><td valign="middle"><font face="'.$FontFace.'" size="'.$FontSize.'" color="'.$Colors['MBHeadingText'].'"><a href="'.$MainURL.'/forum#'.$BoardCategories[$BoardID].'.html"><font color="'.$Colors['MBHeadingText'].'">'.$CategoryTitles[$BoardCategories[$BoardID]].'</font></a> > <a href="'.$MainURL.'/forum/'.$BoardID.'.html"><font color="'.$Colors['MBHeadingText'].'">'.$BoardTitles[$BoardID].'</font></a> > <a href="'.$MainURL.'/forum/thread/'.$ThreadID.'.html"><font color="'.$Colors['MBHeadingText'].'"><b>'.$ThreadTitle.'</b></font></a> (<a href="'.$MainURL.'/forum/thread/'.$ThreadID.'/'.$MessagePage.'.html#'.$ThreadMessageNumber.'"><font color="'.$Colors['MBHeadingText'].'">'.$MsgText[2][90].'</font></a>)</font></td></tr></table></td>


				</tr></table></td></tr></table></td>

				</tr>

				<tr><td colspan="3" height="2" bgcolor="'.$Colors['MBBorder'].'"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="2" alt=""></td></tr>
				
				<tr>
						
				<td width="19%" height="100%"><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="4"><tr><td valign="top" bgcolor="'.$BGColor.'"><font face="'.$FontFace.'" size="'.$FontSize.'" color="'.$Colors['MBText'].'">'.$PosterLink.'</font></font></td></tr></table></td>

				<td width="1%" height="100%" bgcolor="'.$BGColor.'"><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="4"><tr><td align="center" valign="middle">&nbsp;</td></tr></table></td>

				<td width="80%" height="100%" bgcolor="'.$BGColor.'"><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="4"><tr><td valign="top"><font face="'.$FontFace.'" size="'.$FontSize.'" color="'.$Colors['MBText'].'"><b>'.$row['Subject'].'</b></td><td valign="top" align="right"><font face="'.$FontFace.'" size="'.$FontSize.'" color="'.$Colors['MBText'].'">'.$PostDate.'</td></tr><tr><td colspan="2" valign="top"><font face="'.$FontFace.'" size="'.$FontSize.'" color="'.$Colors['MBText'].'">'.$row['Message'].'</font></td></tr></table></td>
								
				</tr>';
				
								
									
				if ($Counter2 < $MessagesThisPage) {
						$MessagesList .= '</table></td></tr></table></td></tr></table></td></tr><tr><td height="1" align="center"><table width="98%" border="0" cellpadding="0" cellspacing="0"><tr><td height="1" bgcolor="'.$Colors['MBSpacerLine'].'"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table></td></tr><tr><td><table width="100%" border="0" cellspacing="0" cellpadding="1"><tr><td bgcolor="'.$Colors['MBBorder'].'"><table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="'.$Colors['MBBG'].'"><table width="100%" border="0" cellspacing="0" cellpadding="0">';
				}		
				
						
					if ($BGColor == $Colors['MBBG']) {
						$BGColor = $Colors['MBAlternateBG'];
					}
					else {
						$BGColor = $Colors['MBBG'];
					}
				
				
				
				} // end if displaying this message
					
			} // end while rows loop
			
			
			
			$MessagesList .= '</table></td></tr></table></td></tr></table></td></tr>';
				
				
			$MessagesList .= '</table>';
			
			
			if ($NextPage == 'y' && $Arguments3 < 99) {
				$NextPageLink = '<a href="'.$MainURL.'/forum/recent/'.($Arguments3+1).'.html">'.$MsgText[2][91].'</a>';
			}
			if ($Arguments3 > 1) {
				$PreviousPageLink = '<a href="'.$MainURL.'/forum/recent/'.($Arguments3-1).'.html">'.$MsgText[2][92].'</a>';
			}
			
			
			
			$PageContents = '<b>'.$MsgText[2][88].'</b><br><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="10" alt=""><br><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><font face="'.$FontFace.'" size="'.$FontSize.'">'.$PreviousPageLink.' </font></td><td align="right"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$NextPageLink.'</font></td></tr></table><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="10" alt=""><br>'.$MessagesList.'<img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="10" alt=""><br><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><font face="'.$FontFace.'" size="'.$FontSize.'">'.$PreviousPageLink.' </font></td><td align="right"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$NextPageLink.'</font></td></tr></table><br>';
			
			
		
		
	
?>
