<?

error_reporting (E_ALL ^ E_NOTICE);

// read the database settings from the file
include_once('./settings.php');

// DB Connection Info read from settings file
Global $DBServer, $DBUser, $DBPass, $DBDatabase;
			
//establish a connection to database (server, database, password)
mysql_connect($DBServer, $DBUser, $DBPass) or die ("Could not connect to database");
	
//select database
mysql_select_db($DBDatabase) or die ("Could not select database");


$Settings['DBPrefix'] = $DBPrefix;


	
	$PreviousColorsString = '';



	$query = "select * from `".$Settings['DBPrefix']."core-Settings` where Name='EditorPreviousColors' limit 1";
	$result = mysql_query($query) or die (mysql_error());
	$row = mysql_fetch_array($result);


	if ($row['Value'] != '') {
	
		$ColorsArray = explode('$$', $row['Value']);
		
	}

		
	for ($i = 0; $i < 20; $i++) {
		
		if ($i == 10) {
			$PreviousColorsString = '</tr><tr>' . $PreviousColorsString;
		}
		
		if ($ColorsArray[$i] == '') {
			$PreviousColorsString = '<td><table width="16" height="16" border="0" cellpadding="1" cellspacing="0"><tr><td bgcolor="#000000"><table width="11" height="11" border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="#ffffff"><img src="spacer.gif" width="15" height="15" alt="" border="0"></td></tr></table></td></tr></table></td>' . $PreviousColorsString;
		}
		else {
			$PreviousColorsString = '<td><table width="16" height="16" border="0" cellpadding="1" cellspacing="0"><tr><td bgcolor="#000000"><table width="11" height="11" border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="#'.strtoupper($ColorsArray[$i]).'"><a href="javascript:SetPreviousColor(\\\'#'.strtoupper($ColorsArray[$i]).'\\\');"><img src="spacer.gif" width="15" height="15" alt="#'.strtoupper($ColorsArray[$i]).'" border="0"></a></td></tr></table></td></tr></table></td>' . $PreviousColorsString;	
		}	
	

	}
				
	$PreviousColorsString = '<table border="0" cellpadding="2" cellspacing="0"><tr>' . $PreviousColorsString . '</tr></table>';
		
	print 'document.write(\''.$PreviousColorsString.'\');';
		
		

?>
