Location: PHPKode > projects > SiteX > setup/upgrade.php
<?PHP

$sxUpgradeVersion = array(
	'0.6.2' => FALSE,
	'0.6.3' => FALSE,
	'0.6.4' => FALSE,
	'0.7.1' => FALSE,
	'0.7.2' => FALSE,
	'0.7.3' => FALSE,
	'0.7.4' => FALSE,
	'0.8.0' => FALSE
	);

$Link = @mysql_connect($HOST, $USER, $PASS);
if( @mysql_select_db($DATABASE, $Link))
{
	$query = "SELECT * FROM $DB_Setup WHERE setup_key='version' or setup_key='Version'";
	$result = @mysql_query($query, $Link);
	$ROW = @mysql_fetch_object($result);
	
	$sxUpgradeSubsequent = FALSE;
	
	foreach($sxUpgradeVersion as $version => $upgrade_flag)
	{
		if($version == $ROW->setup_value)
			$sxUpgradeSubsequent = TRUE;
		
		elseif($sxUpgradeSubsequent)
			$sxUpgradeVersion[$version] = TRUE;
	}
}

if($sxUpgradeVersion['0.6.2'])
{
	$Link = @mysql_connect($HOST, $USER, $PASS) or $error = mysql_error();
	if(!$error) @mysql_select_db($DATABASE, $Link) or $error = mysql_error();	
	
	if(!$error)
	{
		$query = "ALTER TABLE `$DB_Pages` ADD `formatted` tinyint(1) NOT NULL default '0'";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "ALTER TABLE `$DB_Pages` ADD `meta_description` text NOT NULL";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "ALTER TABLE `$DB_Pages` ADD `meta_keywords` text NOT NULL";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "UPDATE `$DB_Pages` SET formatted='1'";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "UPDATE `$DB_Setup` SET setup_value='0.6.2' WHERE setup_key='version'";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('show_login', '1')";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('link_truncation', '10')";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('meta_sitewide', '1')";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('date_format', 'mm/dd/yy')";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('imaging_mode', 'auto')";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('photo_purchase', '0')";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "ALTER TABLE `$DB_Themes` ADD `title_width` int(5) NOT NULL default '0' AFTER `scheme_management`";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "ALTER TABLE `$DB_Themes` ADD `title_height` int(5) NOT NULL default '0' AFTER `title_width`";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "UPDATE `$DB_Themes` SET title_width='250', title_height='189' WHERE folder='Structure'";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "ALTER TABLE `$DB_Themes_Setup` ADD `color_background` varchar(7) NOT NULL default '' AFTER `color_secondary`";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "ALTER TABLE `$DB_Themes_Setup` ADD `color_table` varchar(7) NOT NULL default '' AFTER `color_background`";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "ALTER TABLE `$DB_Themes_Setup` ADD `color_table_row` varchar(7) NOT NULL default '' AFTER `color_table`";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "ALTER TABLE `$DB_Themes_Setup` ADD `color_text_table` varchar(7) NOT NULL default '' AFTER `color_text_secondary`";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "UPDATE `$DB_Themes_Setup` SET color_background='#FFFFFF', color_table='#000099', color_table_row='#EEEEEE', color_text_table='#FFFFFF' WHERE name='Ocean Spray'";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "UPDATE `$DB_Themes_Setup` SET color_background='#FFFFFF', color_table='#000000', color_table_row='#EEEEEE', color_text_table='#FFFF00' WHERE name='Yellow Jacket'";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "UPDATE `$DB_Themes_Setup` SET color_background='#FFFFFF', color_table='#FFEEDD', color_table_row='#EEEEEE', color_text_table='#990000' WHERE name='Passion Fruit'";
		$result = mysql_query($query, $Link) or die(mysql_error());
				
		$query = "ALTER TABLE `$DB_Files` ADD `name` varchar(255) NOT NULL default '' AFTER `id`";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "ALTER TABLE `$DB_Files` ADD `hits` bigint(10) NOT NULL default '0' AFTER `userid`";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "SELECT * FROM $DB_Files";
		$result = @mysql_query($query, $Link);
		while($ROW = @mysql_fetch_object($result)){
			$query2 = "UPDATE `$DB_Files` SET name='$ROW->filename' WHERE id='$ROW->id'";
			$result2 = mysql_query($query2, $Link) or die(mysql_error());
		}
		
		$query = "ALTER TABLE `$DB_Title_Pictures` ADD `themeid` int(5) NOT NULL default '0' AFTER `filesize`";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "SELECT * FROM $DB_Title_Pictures";
		$result = @mysql_query($query, $Link);
		while($ROW = @mysql_fetch_object($result)){
			$query2 = "UPDATE `$DB_Title_Pictures` SET themeid='1' WHERE id='$ROW->id'";
			$result2 = mysql_query($query2, $Link) or die(mysql_error());
		}
				
	}
}

if($sxUpgradeVersion['0.6.3']){
		
	$Link = @mysql_connect($HOST, $USER, $PASS) or $error = mysql_error();
	if(!$error) @mysql_select_db($DATABASE, $Link) or $error = mysql_error();	
	
	if(!$error){
		
		// Underscore page links
		$query = "SELECT * FROM $DB_Navigation";
		$result = @mysql_query($query, $Link);
		while($ROW = @mysql_fetch_object($result)){
			if(substr($ROW->url, 0, 14) == 'page.php?page='){
				$new_url = str_replace(' ', '_', $ROW->url);
				$query2 = "UPDATE `$DB_Navigation` SET url='$new_url' WHERE id='$ROW->id'";
				$result2 = mysql_query($query2, $Link) or die(mysql_error());
			}
		}
		
		// Add album positions and initialize		
		$query = "ALTER TABLE `$DB_Photos_Albums` ADD `position` bigint(10) NOT NULL default '0'";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$counter = 0;
		$query = "SELECT * FROM $DB_Photos_Albums ORDER BY timestamp ASC";
		$result = @mysql_query($query, $Link);
		while($ROW = @mysql_fetch_object($result)){
			$counter = $counter + 1;
			$query2 = "UPDATE `$DB_Photos_Albums` SET position='$counter' WHERE id='$ROW->id'";
			$result2 = mysql_query($query2, $Link) or die(mysql_error());
		}
		
		/// Photo positions
		$query = "ALTER TABLE `$DB_Photos_Assoc` ADD `position` bigint(10) NOT NULL default '0'";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "SELECT * FROM $DB_Photos_Albums";
		$result = @mysql_query($query, $Link);
		while($ROW = @mysql_fetch_object($result)){
		
			$counter = 0;
			$query2 = "SELECT * FROM $DB_Photos_Assoc WHERE albumid='$ROW->id' ORDER BY photoid ASC";
			$result2 = @mysql_query($query2, $Link);
			while($ROW2 = @mysql_fetch_object($result2)){
				$counter = $counter + 1;
				$query3 = "UPDATE `$DB_Photos_Assoc` SET position='$counter' WHERE id='$ROW2->id'";
				$result3 = mysql_query($query3, $Link) or die(mysql_error());
			}
		}
		
		// Journal user id
		$query = "ALTER TABLE `$DB_Journal` ADD `userid` bigint(10) NOT NULL default '0' AFTER entry";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "SELECT * FROM $DB_Users, $DB_Users_Assoc 
				  WHERE $DB_Users.id=$DB_Users_Assoc.userid AND
						$DB_Users_Assoc.typeid='1'
				  ORDER BY $DB_Users.id
				  LIMIT 0,1";
		$result = @mysql_query($query, $Link);
		$ROW = @mysql_fetch_object($result);
		$admin_id = $ROW->userid;
		
		$query = "SELECT * FROM $DB_Journal";
		$result = @mysql_query($query, $Link);
		while($ROW = @mysql_fetch_object($result)){
			$query2 = "UPDATE `$DB_Journal` SET userid='$admin_id' WHERE id='$ROW->id'";
			$result2 = mysql_query($query2, $Link) or die(mysql_error());
		}
		
		// Theme updates
		
		$query = "INSERT INTO `$DB_Themes` VALUES (2, 'Streamline', 'Streamline', 'BJ Sintay', '0.6', 1, 250, 35, 0)";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "INSERT INTO `$DB_Themes_Setup` (name, themeid, color_primary, color_secondary, color_background, color_table, color_table_row, color_text, color_text_secondary, color_text_table, color_links, color_links_visited, color_sitename, show_sitename, selected) VALUES ('Rustic', 2, '#333333', '#CC6600', '#CCCCCC', '#333333', '#EEEEEE', '#000000', '#FFFFFF', '#FFFFFF', '#CC6600', '#CC6600', '#FFFFFF', 1, 1)";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "INSERT INTO `$DB_Themes_Setup` (name, themeid, color_primary, color_secondary, color_background, color_table, color_table_row, color_text, color_text_secondary, color_text_table, color_links, color_links_visited, color_sitename, show_sitename, selected) VALUES ('Greenway', 2, '#009900', '#006600', '#FFFF99', '#006600', '#FFFFFF', '#212121', '#FFFFFF', '#FFFFFF', '#003300', '#003300', '#FFFFFF', 1, 0)";
		$result = mysql_query($query, $Link) or die(mysql_error());
		$query = "INSERT INTO `$DB_Themes_Setup` (name, themeid, color_primary, color_secondary, color_background, color_table, color_table_row, color_text, color_text_secondary, color_text_table, color_links, color_links_visited, color_sitename, show_sitename, selected) VALUES ('Acid Wash', 2, '#212121', '#990000', '#000000', '#990000', '#212121', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#616161', '#616161', '#FFFFFF', 1, 0)";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "INSERT INTO `$DB_Title_Pictures` (name, filename, filesize, themeid, active) VALUES ('Streamline Title (Rustic)', 'streamline_title.jpg', '2320', '2', '0')";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "UPDATE `$DB_Setup` SET setup_value='0.6.3' WHERE setup_key='version'";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
	}
}

if($sxUpgradeVersion['0.6.4'])
{
	$Link = @mysql_connect($HOST, $USER, $PASS) or $error = mysql_error();
	if(!$error) @mysql_select_db($DATABASE, $Link) or $error = mysql_error();	
	
	if(!$error)
	{
		$query = "UPDATE `$DB_Setup` SET setup_value='0.6.4' WHERE setup_key='version'";
		$result = mysql_query($query, $Link) or die(mysql_error());
	}
}

if($sxUpgradeVersion['0.7.1'])
{
	$Link = @mysql_connect($HOST, $USER, $PASS) or $error = mysql_error();
	if(!$error) @mysql_select_db($DATABASE, $Link) or $error = mysql_error();	
	
	if(!$error)
	{
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('comments_approval', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #1 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('guestbook_approval', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #2 In 0.7.1 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Guestbook` ADD `approved` tinyint(1) NOT NULL default '0'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #3 In 0.7.1 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Comments` ADD `approved` tinyint(1) NOT NULL default '0'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #4 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Components` (name, active, page_url) VALUES ('Contact Form', 0, 'contact.php')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #5 In 0.7.1 update... " . mysql_error());
		
		$query = "SELECT * FROM $DB_Components WHERE page_url='contact.php'";
		$result = @mysql_query($query, $Link) or die("MySQL Upgrade Error: #11 In 0.7.1 update... " . mysql_error());
		$ROW = @mysql_fetch_object($result);
		
		$query = "INSERT INTO `$DB_Components_Rename` (compid, new_name) VALUES ($ROW->id, 'Contact')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #6 In 0.7.1 update... " . mysql_error());
		
		$query = "SELECT * FROM $DB_Setup WHERE setup_key='admin_email'";
		$result = @mysql_query($query, $Link);
		$ROW = @mysql_fetch_object($result);
		$admin_email = $ROW->setup_value;
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('contact_form_email', '$admin_email')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #7 In 0.7.1 update... " . mysql_error());

		$query = "ALTER TABLE `$DB_Users` ADD `lastlogin` bigint(15) NOT NULL default '0' AFTER website";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #8 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('comments_enabled', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #9 In 0.7.1 update... " . mysql_error());		
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('comments_auth', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #10 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('forum_anonymous', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #11 In 0.7.1 update... " . mysql_error());		
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('forum_hide_private', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #12 In 0.7.1 update... " . mysql_error());

		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('forum_width', '600')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #13 In 0.7.1 update... " . mysql_error());

		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('forum_edit_timeout', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #14 In 0.7.1 update... " . mysql_error());

		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('forum_edit_timeout_seconds', '900')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #15 In 0.7.1 update... " . mysql_error());

		$query = "ALTER TABLE `$DB_Users` 
					ADD `avatar` VARCHAR( 255 ) NOT NULL AFTER `website` , 
					ADD `signature` MEDIUMTEXT NOT NULL AFTER `avatar`";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #16 In 0.7.1 update... " . mysql_error());
		
		$query = "SELECT * FROM $DB_Setup WHERE setup_key='link_truncation'";
		$result = @mysql_query($query, $Link) or die("MySQL Upgrade Error: #17 In 0.7.1 update... " . mysql_error());
		$ROW = @mysql_fetch_object($result);
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('link_truncation_length', '$ROW->setup_value')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #18 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('maintenance', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #19 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('user_cleaner', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #20 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('user_cleaner_warn', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #21 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('user_cleaner_delete', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #22 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('user_avatar', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #23 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('user_avatar_max_width', '125')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #24 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('user_avatar_max_height', '150')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #25 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('user_signature', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #26 In 0.7.1 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Users` ADD `timezone` varchar(3) NOT NULL default '0' AFTER lastlogin";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #27 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('server_timezone', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #28 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Components` (name, active, page_url) VALUES ('Calendar', '0', 'calendar.php')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #29 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Components_Rename` (compid, new_name) VALUES ('8', 'Calendar')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #30 In 0.7.1 update... " . mysql_error());
		
		$query = "CREATE TABLE `$DB_Events` (
		  `id` bigint(15) NOT NULL auto_increment,
		  `longname` varchar(255) NOT NULL default '',
		  `shortname` varchar(15) NOT NULL default '',
		  `userid` bigint(10) NOT NULL default '0',
		  `start_timestamp` bigint(15) NOT NULL default '0',
		  `end_timestamp` bigint(15) NOT NULL default '0',
		  `description` mediumtext NOT NULL,
		  `allday` tinyint(1) NOT NULL default '0',
		  `active` tinyint(1) NOT NULL default '0',
		  PRIMARY KEY  (`id`)
		) TYPE=MyISAM AUTO_INCREMENT=1";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #31 In 0.7.1 update... " . mysql_error());
		
		$query = "CREATE TABLE `$DB_Events_Private` (
		  `id` bigint(15) NOT NULL auto_increment,
		  `eventid` bigint(15) NOT NULL default '0',
		  `typeid` bigint(15) NOT NULL default '0',
		  PRIMARY KEY  (`id`)
		) TYPE=MyISAM AUTO_INCREMENT=1";
		$result = mysql_query($query, $Link) or die(mysql_error());
		
		$query = "ALTER TABLE `$DB_Users` ADD `newsletter` tinyint(1) NOT NULL default '0' AFTER timezone";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #28 In 0.7.1 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Users` ADD `showemail` tinyint(1) NOT NULL default '0' AFTER newsletter";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #29 In 0.7.1 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Users` ADD `validated` tinyint(1) NOT NULL default '1' AFTER showemail";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #30 In 0.7.1 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Users` ADD `membersince` bigint(15) NOT NULL default '$NOW' AFTER lastlogin";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #31 In 0.7.1 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Users` ADD `validation_code` varchar(255) NOT NULL default '' AFTER validated";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #31 In 0.7.1 update... " . mysql_error());

		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('user_approval', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #32 In 0.7.1 update... " . mysql_error());

		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('user_validation', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #33 In 0.7.1 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Users` ADD `warned` tinyint(1) NOT NULL default '0' AFTER validation_code";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #34 In 0.7.1 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('language', 'English')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #35 In 0.7.1 update... " . mysql_error());
		
		// Update setup variable names
		$query = "SELECT * FROM $DB_Setup";
		$result = @mysql_query($query, $Link) or die("MySQL Upgrade Error: #36 In 0.7.1 update... " . mysql_error());
		while($ROW = @mysql_fetch_object($result)){
			
			$sxUpgradeNewName = str_replace(" ", "", ucwords(str_replace("_"," ",$ROW->setup_key)));			
			$query2 = "UPDATE `$DB_Setup` SET setup_key='$sxUpgradeNewName' WHERE setup_key='$ROW->setup_key'";
			$result2 = mysql_query($query2, $Link) or die("MySQL Upgrade Error: #37 In 0.7.1 update... " . mysql_error());
		}
		
		$query = "UPDATE `$DB_Setup` SET setup_value='0.7.1' WHERE setup_key='Version'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #VER In 0.7.1 update... " . mysql_error());
	}
	
}

if($sxUpgradeVersion['0.7.2'])
{
	$Link = @mysql_connect($HOST, $USER, $PASS) or $error = mysql_error();
	if(!$error) @mysql_select_db($DATABASE, $Link) or $error = mysql_error();	
	
	if(!$error)
	{
		$query = "UPDATE `$DB_Setup` SET setup_value='0.7.2' WHERE setup_key='Version'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #VER In 0.7.2 update... " . mysql_error());		
	}
}

if($sxUpgradeVersion['0.7.3'])
{
	$Link = @mysql_connect($HOST, $USER, $PASS) or $error = mysql_error();
	if(!$error) @mysql_select_db($DATABASE, $Link) or $error = mysql_error();	
	
	if(!$error)
	{
		$query = "ALTER TABLE `$DB_Photos` ADD `views` bigint(15) NOT NULL default '0' AFTER original";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #1 In 0.7.3 update... " . mysql_error());

		$query = "ALTER TABLE `$DB_Photos` ADD `userid` int(5) NOT NULL default '0' AFTER views";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #2 In 0.7.3 update... " . mysql_error());

		$query = "ALTER TABLE `$DB_Photos_Albums` ADD `userid` int(5) NOT NULL default '0' AFTER position";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #3 In 0.7.3 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Title_Pictures` ADD `width` int(10) NOT NULL default '0' AFTER active";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #4 In 0.7.3 update... " . mysql_error());

		$query = "ALTER TABLE `$DB_Title_Pictures` ADD `height` int(10) NOT NULL default '0' AFTER width";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #5 In 0.7.3 update... " . mysql_error());

		$query = "ALTER TABLE `$DB_Themes_Setup` ADD `color_links_hover` varchar(7) NOT NULL default '' AFTER color_links";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #6 In 0.7.3 update... " . mysql_error());

		$query = "SELECT * FROM $DB_Themes_Setup";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #7 In 0.7.3 update... " . mysql_error());
		while($ROW = mysql_fetch_object($result))
		{
			$query2 = "UPDATE `$DB_Themes_Setup` SET color_links_hover='$ROW->color_links' WHERE id='$ROW->id'";
			$result2 = mysql_query($query2, $Link) or die("MySQL Upgrade Error: #8 In 0.7.3 update... " . mysql_error());
		}
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryShowPhotoCount', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #9 In 0.7.3 update... " . mysql_error());

		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryShowDescription', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #10 In 0.7.3 update... " . mysql_error());

		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryDescriptionTrunc', '100')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #11 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('AlbumShowPhotoDescription', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #12 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('AlbumPhotoDescriptionTrunc', '100')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #13 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryShowCreated', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #14 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('AlbumShowPhotoCreated', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #15 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('AlbumShowNumPhotos', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #16 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryNumColumns', '2')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #17 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('AlbumNumColumns', '3')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #18 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryMaxDimensionThumb', '150')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #19 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryMaxDimensionPhoto', '600')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #20 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryCompressionThumb', '90')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #21 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryCompressionPhoto', '90')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #22 In 0.7.3 update... " . mysql_error());
				
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryStoreFullsize', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #23 In 0.7.3 update... " . mysql_error());
				
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryUseKeywords', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #25 In 0.7.3 update... " . mysql_error());
				
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GallerySelectSize', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #26 In 0.7.3 update... " . mysql_error());
				
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryWatermarking', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #27 In 0.7.3 update... " . mysql_error());
		
		// # 28 removed

		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryWatermarkingType', 'txt')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #29 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryWatermarkingPosition', 'lowright')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #30 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryWatermarkingText', '')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #31 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryWatermarkingTextSize', '3')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #32 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryWatermarkingTextColor', '#FFFFF')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #33 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryWatermarkingTextTrans', '30')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #34 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('HomepageRandomPhotos', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #35 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('HomepageRandomPhotosVert', '0')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #36 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('HomepageRandomPhotosHoriz', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #37 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('HomepageRandomPhotosNum', '8')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #38 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('HomepageRandomPhotosPerLine', '4')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #39 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('AlbumShowPhotoName', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #40 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GalleryWatermarkingImage', '')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #41 In 0.7.3 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Photos` ADD `watermark` tinyint(1) NOT NULL default '0' AFTER userid";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #42 In 0.7.3 update... " . mysql_error());
		
		$query = "CREATE TABLE `$DB_Security_Image` (
		  `id` bigint(10) NOT NULL auto_increment,
		  `code` varchar(50) NOT NULL default '',
		  `filename` varchar(50) NOT NULL,
		  `timestamp` bigint(15) NOT NULL,
		  PRIMARY KEY  (`id`)
		) TYPE=MyISAM AUTO_INCREMENT=1";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #43 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('FormSecurity', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #44 In 0.7.3 update... " . mysql_error());
		
		$query = "CREATE TABLE `$DB_Forums_Notify` (
			`id` BIGINT(10) NOT NULL auto_increment ,
			`userid` BIGINT(10) NOT NULL default '0',
			`notified` TINYINT(1) NOT NULL default '0',
			`id_type` ENUM('forum', 'topic') NOT NULL default 'topic',
			`id_num` BIGINT(10) NOT NULL default '0',
			PRIMARY KEY (`id`) 
		) TYPE = MYISAM AUTO_INCREMENT=1";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #45 In 0.7.3 update... " . mysql_error());

		$query = "DELETE FROM `$DB_Setup` WHERE setup_key='AdvancedPhotoMode'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #46 In 0.7.3 update... " . mysql_error());		
		
		$query = "ALTER TABLE `$DB_Files` ADD `folderid` INT( 5 ) DEFAULT '0' NOT NULL AFTER `hits`";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #47 In 0.7.3 update... " . mysql_error());		

		$query = "CREATE TABLE `$DB_Files_Folders` (
			`id` INT(10) NOT NULL auto_increment ,
			`name` VARCHAR(255) NOT NULL,
			PRIMARY KEY (`id`) 
		) TYPE = MYISAM AUTO_INCREMENT=1";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #48 In 0.7.3 update... " . mysql_error());

		$query = "ALTER TABLE `$DB_Photos` CHANGE `original` `fullsize` TINYINT( 1 ) NOT NULL DEFAULT '0'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #49 In 0.7.3 update... " . mysql_error());		

		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('WYSIWYG', 'fck')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #50 In 0.7.3 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Themes` ADD `sitex_username` varchar(255) NOT NULL AFTER creator";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #50-A In 0.7.1 update... " . mysql_error());

		$query = "UPDATE $DB_Themes SET sitex_username='bjsintay'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #50-C In 0.7.3 update... " . mysql_error());

		$query = "ALTER TABLE `$DB_Themes` ADD `notes` text NOT NULL AFTER title_height";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #50-B In 0.7.1 update... " . mysql_error());
		
		$query = "UPDATE $DB_Themes SET notes='<li>Forum options > Forum width: <b>500px</b>\n<li>Photo options > Gallery Appearance > Number of Columns (Gallery): <b>2</b>\n<li>Photo options > Gallery Appearance > Number of Columns (Album): <b>2</b>\n<li>Photo options > Gallery Appearance > Albums Per Page: <b>6</b>\n<li>Photo options > Gallery Appearance > Pictures Per Page: <b>8</b>\n<li>Photo options > Image Processing > Max Scaled Photo Dimension: <b>500</b>\n<li>Photo options > Random Photos > Total Photos: <b>4</b>\n<li>Photo options > Random Photos > Photos Per Line: <b>1</b>\n<li>User Options > maximum avatar height and width: <b>80</b>\n<li><b>Theme description:</b></br>\nStructure is the SiteX default theme. It features a vertical main menu in the banner area, making it best suited to simple sites with fewer menu items. Structure is the most compact theme, optimised for 800x600 screen resolution. Like an experienced marathon runner this theme is really lasting the distance!' WHERE folder='Structure'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #50-C In 0.7.3 update... " . mysql_error());

		$query = "UPDATE $DB_Themes SET notes='<li>Forum options > Forum width: <b>650px</b>\n<li>Photo options > Gallery Appearance > Number of Columns (Gallery): <b>3</b>\n<li>Photo options > Gallery Appearance > Number of Columns (Album): <b>3</b>\n<li>Photo options > Gallery Appearance > Albums Per Page: <b>9</b>\n<li>Photo options > Gallery Appearance > Pictures Per Page: <b>12</b>\n<li>Photo options > Image Processing > Max Scaled Photo Dimension: <b>650</b>\n<li>Photo options > Random Photos > Total Photos: <b>4</b>\n<li>Photo options > Random Photos > Photos Per Line: <b>1</b>\n<li>User Options > maximum avatar height and width: <b>120</b>\n<li><b>Theme description:</b></br>\nStreamline is one of the earliest SiteX themes, its also one of the simplest and that makes it an ideal place to start if you want to customise a theme. Streamline stretches to fit the full size of your browser window.' WHERE folder='Streamline'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #50-C In 0.7.3 update... " . mysql_error());
		
		// Install Fusion theme
		
		$query = "SELECT id FROM $DB_Themes ORDER BY id DESC LIMIT 0,1";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #51 In 0.7.3 update... " . mysql_error());
		$ROW = mysql_fetch_object($result);
		$theme_count = 1 + $ROW->id;
		
		$query = "SELECT * FROM $DB_Themes_Setup ORDER BY id DESC LIMIT 0,1";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #52 In 0.7.3 update... " . mysql_error());
		$ROW = mysql_fetch_object($result);
		$scheme_count = 1 + $ROW->id;
		
		$query = "SELECT * FROM $DB_Title_Pictures ORDER BY id DESC LIMIT 0,1";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #53 In 0.7.3 update... " . mysql_error());
		$ROW = mysql_fetch_object($result);
		$title_count = 1 + $ROW->id;

		$query = "INSERT INTO `$DB_Themes` VALUES ('$theme_count', 'Fusion', 'Fusion', 'Phil Mills', 'pmills', '0.7.3', 1, 760, 125, '<li>Forum options > Forum width: <b>650px</b>\n<li>Photo options > Gallery Appearance > Number of Columns (Gallery): <b>2</b>\n<li>Photo options > Gallery Appearance > Number of Columns (Album): <b>3</b>\n<li>Photo options > Gallery Appearance > Albums Per Page: <b>6</b>\n<li>Photo options > Gallery Appearance > Pictures Per Page: <b>20</b>\n<li>Photo options > Image Processing > Max Scaled Photo Dimension: <b>650</b>\n<li>Photo options > Random Photos > Total Photos: <b>5</b>\n<li>Photo options > Random Photos > Photos Per Line: <b>5</b>\n<li>User Options > maximum avatar height and width: <b>120</b>\n<li><b>Theme description:</b></br>\nFusion is a minimalist theme which provides a good foundation for many types of sites. It features menu hover text, horizontal login arrangement outside the site border, homepage RSS feed link and overprinted sitename. Fully featured without feeling cluttered!  For additional configuration options, open themes/Fusion/config.php.inc', 0)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #54 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Themes_Setup` VALUES ('$scheme_count', 'Cool Down', $theme_count, '#BCCDD5', '#404040', '#FFFFFF', '#BFBFBF', '#E0E0E0', '#616161', '#FFFFFF', '#336699', '#000000', '#A1A1A1', '#000000', '#404040', 1, 1)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #55 In 0.7.3 update... " . mysql_error());

		$query = "INSERT INTO `$DB_Title_Pictures` VALUES ('$title_count', 'Fusion', 'fusion.jpg', '8270', '$theme_count', '1','760', '165')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #56 In 0.7.3 update... " . mysql_error());

		$query = "ALTER TABLE `$DB_Forums_Posts` ADD `sticky` TINYINT(1) DEFAULT '0' NOT NULL AFTER `censored`";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #57 In 0.7.3 update... " . mysql_error());		

		// Install Corporate theme
		
		$theme_count += 1;
		$query = "INSERT INTO `$DB_Themes` VALUES ('$theme_count', 'Corporate', 'Corporate', 'Phil Mills', 'pmills', '0.7.3', 1, 760, 100, '<li>Forum options > Forum width: <b>650px</b>\n<li>Photo options > Gallery Appearance > Number of Columns (Gallery): <b>2</b>\n<li>Photo options > Gallery Appearance > Number of Columns (Album): <b>2</b>\n<li>Photo options > Gallery Appearance > Albums Per Page: <b>6</b>\n<li>Photo options > Gallery Appearance > Pictures Per Page: <b>8</b>\n<li>Photo options > Image Processing > Max Scaled Photo Dimension: <b>600</b>\n<li>Photo options > Random Photos > Total Photos: <b>5</b>\n<li>Photo options > Random Photos > Photos Per Line: <b>5</b>\n<li>Photo options > Random Photos > Use Portrait Photos: <b>no</b>\n<li>Photo options > Random Photos > Use Landscape Photos: <b>yes</b>\n<li>User Options > maximum avatar height and width: <b>100</b>\n<li><b>Theme description:</b></br>\nThere are 3 preset colorschemes for this theme; marine, bronze, blue pearl. Corporate also includes menu mouseover images, and not only that! There is also a specific set to match each of the 3 colourschemes. These are loaded automatically as you select the colourscheme you want to use. There are also 2, yes 2!  preinstalled title images per colourscheme, so you can see the title image rotation script in action. To enable them, go to Administration Panel > Manage title pictures. Make active the ones which share the same name as your coloursheme. e.g for bluepearl, select bluepearl1 & bluepearl2. Be sure to deselect any which relate to other colour schemes for this theme. You can have a lot of fun with this one!  For additional configuration options, open themes/Corporate/config.php.inc', 0)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #58 In 0.7.3 update... " . mysql_error());		

		$scheme_count += 1;
		$query = "INSERT INTO `$DB_Themes_Setup` VALUES ('$scheme_count', 'Bluepearl', '$theme_count', '#96A8CE', '#FFFFFF', '#FFFFFF', '#96A8CE', '#E0E0E0', '#616161', '#404040', '#FFFFFF', '#000000', '#000000', '#000000','#000000', 1, 1)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #59 In 0.7.3 update... " . mysql_error());		
		
		$scheme_count += 1;
		$query = "INSERT INTO `$DB_Themes_Setup` VALUES ('$scheme_count', 'Bronze', '$theme_count', '#BB7D4E', '#FFFFFF', '#FFFFFF', '#BB7D4E', '#E0E0E0', '#616161', '#FFFFFF', '#FFFFFF', '#000000', '#000000', '#000000', '#000000', 1, 0)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #60 In 0.7.3 update... " . mysql_error());		
		
		$scheme_count += 1;
		$query = "INSERT INTO `$DB_Themes_Setup` VALUES ('$scheme_count', 'Marine', '$theme_count', '#66CCCC', '#FFFFFF','#FFFFFF', '#A1A1A1', '#E0E0E0', '#404040', '#FFFFFF', '#FFFFFF', '#000000', '#000000', '#000000', '#000000', 1, 0)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #61 In 0.7.3 update... " . mysql_error());		
		
		$title_count += 1;
		$query = "INSERT INTO `$DB_Title_Pictures` VALUES ('$title_count', 'Bluepearl1', 'corporate_bluepearl_1.jpg', '3270', '$theme_count', '0','760', '100')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #62 In 0.7.3 update... " . mysql_error());		
		
		$title_count += 1;
		$query = "INSERT INTO `$DB_Title_Pictures` VALUES ('$title_count', 'Bluepearl2', 'corporate_bluepearl_2.jpg', '5710', '$theme_count', '1','760', '100')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #63 In 0.7.3 update... " . mysql_error());		
		
		$title_count += 1;
		$query = "INSERT INTO `$DB_Title_Pictures` VALUES ('$title_count', 'Bronze1', 'corporate_bronze_1.jpg', '3110', '$theme_count', '0','760', '100')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #64 In 0.7.3 update... " . mysql_error());		
		
		$title_count += 1;
		$query = "INSERT INTO `$DB_Title_Pictures` VALUES ('$title_count', 'Bronze2', 'corporate_bronze_2.jpg', '5730', '$theme_count', '0','760', '100')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #65 In 0.7.3 update... " . mysql_error());		
		
		$title_count += 1;
		$query = "INSERT INTO `$DB_Title_Pictures` VALUES ('$title_count', 'Marine1', 'corporate_marine_1.jpg', '3400', '$theme_count', '0','760', '100')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #66 In 0.7.3 update... " . mysql_error());		
		
		$title_count += 1;
		$query = "INSERT INTO `$DB_Title_Pictures` VALUES ('$title_count', 'Marine2', 'corporate_marine_2.jpg', '5810', '$theme_count', '0','760', '100')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #67 In 0.7.3 update... " . mysql_error());		
		
		$query = "ALTER TABLE `$DB_Polls` ADD `currentpoll` tinyint(1) NOT NULL default '0'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #68 In 0.7.1 update... " . mysql_error());
		
		$query = "UPDATE $DB_Polls SET currentpoll='1' WHERE active='1'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #69 In 0.7.3 update... " . mysql_error());
		
		$query = "UPDATE $DB_Polls SET active='1' WHERE active='0'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #70 In 0.7.3 update... " . mysql_error());
		
		// Install Joombo theme
		
		$theme_count += 1;
		$query = "INSERT INTO `$DB_Themes` VALUES ('$theme_count', 'Joombo', 'Joombo', 'Phil Mills', 'pmills', '0.7.3', 1, 600, 150, '<li>Admin Panel > Site Preferences > Additional Options > Show Search</li><li>Forum options > Forum width: <b>600px</b>\n<li>Photo options > Gallery Appearance > Number of Columns (Gallery): <b>2</b>\n<li>Photo options > Gallery Appearance > Number of Columns (Album): <b>2</b>\n<li>Photo options > Gallery Appearance > Albums Per Page: <b>8</b>\n<li>Photo options > Gallery Appearance > Pictures Per Page: <b>8</b>\n<li>Photo options > Image Processing > Max Scaled Photo Dimension: <b>600</b>\n<li>Photo options > Random Photos > Total Photos: <b>6</b>\n<li>Photo options > Random Photos > Photos Per Line: <b>6</b>\n<li>User Options > maximum avatar height and width: <b>100</b>\n<li><b>Theme description:</b></br>\nJoombo is a very attractive modern theme featuring clean lines, mouseover image swaps, advanced styles, site statistics, integrated login/user menu, customised site search, multiple menus and best of all, a scrollable blog! Just look and see what can be done with SiteX!  For additional configuration options, open themes/joombo/config.php.inc', 0)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #71 In 0.7.3 update... " . mysql_error());		
		
		$scheme_count += 1;
		$query = "INSERT INTO `$DB_Themes_Setup` VALUES ('$scheme_count', 'Charcoal', '$theme_count', '#B02E32', '#7E7B86', '#F7F7F7', '#7E7B86', '#F1F1F1', '#393939', '#FFFFFF', '#FFFFFF', '#D34444', '#D34444', '#B02E32', '#000000', 1, 1)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #72A In 0.7.3 update... " . mysql_error());		
				
		$scheme_count += 1;
		$query = "INSERT INTO `$DB_Themes_Setup` VALUES ('$scheme_count', 'Forest', '$theme_count', '#8C332B', '#608D76', '#F1EEED', '#608D76', '#E0E0E0', '#404040', '#FFFFFF', '#404040', '#8C332B', '#8C332B', '#608D76', '#404040', 1, 0)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #72B In 0.7.3 update... " . mysql_error());		
				
		$title_count += 1;
		$query = "INSERT INTO `$DB_Title_Pictures` VALUES ('$title_count',  'Joombo Charcoal', 'joombo_charcoal.png', 2020, '$theme_count', 1, 600, 150)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #73A In 0.7.3 update... " . mysql_error());		
		
		$title_count += 1;
		$query = "INSERT INTO `$DB_Title_Pictures` VALUES ('$title_count',  'Joombo Forest', 'joombo_forest.png', 2020, '$theme_count', 0, 600, 150)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #73B In 0.7.3 update... " . mysql_error());		
		
		$query = "ALTER TABLE `$DB_Forums_Posts` ADD `lastedit` bigint(15) NOT NULL AFTER updated";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #74 In 0.7.3 update... " . mysql_error());

		$query = "SELECT * FROM $DB_Forums_Posts";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #75 In 0.7.3 update... " . mysql_error());
		while ($ROW = mysql_fetch_object($result))
		{
			$query = "UPDATE $DB_Forums_Posts SET lastedit='$ROW->timestamp' WHERE id='$ROW->id'";
			$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #76 In 0.7.3 update... " . mysql_error());
		}

		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('HomepageRecentComments', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #77 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('HomepageRecentTopics', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #78 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('HomepageUpcomingEvents', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #79 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('HomepageCurrentPoll', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #80 In 0.7.3 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('HomepageMiniCalendar', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #81 In 0.7.3 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Photos` ADD `hide_random` tinyint(1) NOT NULL default '0' AFTER watermark";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #82 In 0.7.3 update... " . mysql_error());

		$query = "UPDATE `$DB_Setup` SET setup_value='0.7.3' WHERE setup_key='Version'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #VER In 0.7.3 update... " . mysql_error());		
		
		// Update content dir image
		sxUpdateContentDirectories();
		
		// Relocate raw photos
		$dir = 'content/photos/';
		if($current_dir = @opendir($dir))
		{
			while($entryname = @readdir($current_dir))
			{
				if(@is_dir("$dir/$entryname") and ($entryname != "." and $entryname!=".."))
				{
					// do nothing
				}
				elseif($entryname != "." and $entryname!="..")
				{
					@copy("${dir}${entryname}", "${dir}/fullsize/${entryname}");
					@unlink("${dir}${entryname}");
				}
			}
			@closedir($current_dir);
		}
	}
}

if($sxUpgradeVersion['0.7.4'])
{
	$Link = @mysql_connect($HOST, $USER, $PASS) or $error = mysql_error();
	if(!$error) @mysql_select_db($DATABASE, $Link) or $error = mysql_error();	
	
	if(!$error)
	{
		$query = "UPDATE `$DB_Setup` SET setup_value='0.7.4' WHERE setup_key='Version'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #VER In 0.7.4 update... " . mysql_error());		
	}
}

if($sxUpgradeVersion['0.8.0'])
{
	$Link = @mysql_connect($HOST, $USER, $PASS) or $error = mysql_error();
	if(!$error) @mysql_select_db($DATABASE, $Link) or $error = mysql_error();	
	
	if(!$error)
	{
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('ContactFormInfo', '<p><b>My name</b></p>\r\n<p>My address<br />\r\nMy town<br />\r\nMy county<br />\r\nMy zipcode<br />\r\nMy Country</p>\r\n<p>Tel:<br />\r\nFax:<br />\r\nEmail: </p>')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #83 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('GoogleAnalytics', '')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #84 In 0.8.0 update... " . mysql_error());

		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('AlbumUseLightbox', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #85 In 0.8.0 update... " . mysql_error());

		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('UserSkype', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #86 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('UserMSN', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #87 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('UserBio', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #88 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('Sitemap', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #89 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('HTMLEmail', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #90 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('JournalHomeCount', '4')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #91 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('JournalRSSCount', '10')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #92 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('MemberFiles', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #93 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('FirstDayOfWeek', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #94 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsAlbumsAdd', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #95 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsAlbumsManage', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #96 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsCommentsManager', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #97 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsContactManage', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #98 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsVisitorStats', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #99 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsEventsAdd', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #100 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsEventsManage', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #101 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsFilesManage', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #102 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsForumsOptions', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #103 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsForumsManage', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #104 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsForumsAdd', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #105 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsGuestbookEdit', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #106 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsHomepageOptions', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #107 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsJournalAdd', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #108 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsJournalEdit', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #109 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsJournalManage', '1')";	
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #110 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsLinksAdd', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #111 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsLinksEdit', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #112 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsNavigation', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #113 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsOnline', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #114 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsPagesAdd', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #115 In 0.8.0 update... " . mysql_error());	
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsPagesEdit', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #116 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsPagesDelete', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #117 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsPhotoAdd', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #118 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsPhotoBatchAdd', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #119 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsPhotoEdit', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #120 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsPollsEdit', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #121 In 0.8.0 update... " . mysql_error());	
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsUsersAdd', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #122 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsUsersEdit', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #123 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsUsersEmail', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #124 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsUserOptions', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #125 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('EditorRightsUserTypes', '1')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #126 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Setup` (setup_key, setup_value) VALUES ('METATitleExt', '')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #127 In 0.8.0 update... " . mysql_error());		
		
		$query = "ALTER TABLE `$DB_Navigation` ADD `target` VARCHAR( 255 ) DEFAULT '_self' NOT NULL AFTER `url`";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #128 In 0.8.0 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Pages` ADD `meta_title_ext` TEXT NOT NULL AFTER `meta_keywords`";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #129 In 0.8.0 update... " . mysql_error());		

		$query = "ALTER TABLE `$DB_Files` ADD `hide` tinyint( 4 ) DEFAULT '0' NOT NULL AFTER `folderid`";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #130 In 0.8.0 update... " . mysql_error());	
		
		$query = "ALTER TABLE `$DB_Files_Folders` ADD `hide` tinyint( 4 ) DEFAULT '0' NOT NULL AFTER `name`";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #131 In 0.8.0 update... " . mysql_error());			

		$query = "INSERT INTO `$DB_Components` VALUES (9, 'Filelist', 1, 'files.php')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #132 In 0.8.0 update... " . mysql_error());	

		$query = "INSERT INTO `$DB_Components_Rename` VALUES (9, 9, 'Downloads')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #133 In 0.8.0 update... " . mysql_error());

		$query = "INSERT INTO `$DB_Navigation` VALUES (11, '".$sxLang['SetupNavFilelist']."', 'files.php', '_self', 11)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #134 In 0.8.0 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Users` ADD `skypeid` VARCHAR( 255 ) NOT NULL AFTER `website`";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #135 In 0.8.0 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Users` ADD `msnid` VARCHAR( 255 ) NOT NULL AFTER `skypeid`";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #136 In 0.8.0 update... " . mysql_error());
		
		$query = "ALTER TABLE `$DB_Users` ADD `bio` MEDIUMTEXT NOT NULL AFTER `msnid`";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #137 In 0.8.0 update... " . mysql_error());
		
		// Install Harmony theme
		
		$query = "SELECT id FROM $DB_Themes ORDER BY id DESC LIMIT 0,1";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #138 In 0.8.0 update... " . mysql_error());
		$ROW = mysql_fetch_object($result);
		$theme_count = 1 + $ROW->id;
		
		$query = "SELECT * FROM $DB_Themes_Setup ORDER BY id DESC LIMIT 0,1";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #139 In 0.8.0 update... " . mysql_error());
		$ROW = mysql_fetch_object($result);
		$scheme_count = 1 + $ROW->id;
		
		$query = "SELECT * FROM $DB_Title_Pictures ORDER BY id DESC LIMIT 0,1";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #140 In 0.8.0 update... " . mysql_error());
		$ROW = mysql_fetch_object($result);
		$title_count = 1 + $ROW->id;
		
		$theme_count += 1;
		$query = "INSERT INTO `$DB_Themes` VALUES ('$theme_count', 'Harmony', 'Harmony', 'Annika Mai Purje', 'annikamai', '0.8.0', 1, 300, 80, '<li>Forum options > Forum width: <b>650px</b>\r\n<li>Photo options > Gallery Appearance > Number of Columns (Gallery): <b>3</b>\r\n<li>Photo options > Gallery Appearance > Number of Columns (Album): <b>3</b>\r\n<li>Photo options > Gallery Appearance > Albums Per Page: <b>6</b>\r\n<li>Photo options > Gallery Appearance > Pictures Per Page: <b>20</b>\r\n<li>Photo options > Image Processing > Max Scaled Photo Dimension: <b>650</b>\r\n<li>Photo options > Random Photos > Total Photos: <b>5</b>\r\n<li>Photo options > Random Photos > Photos Per Line: <b>5</b>\r\n<li>User Options > maximum avatar height and width: <b>120</b>\r\n<li><b>Theme description:</b></br>\r\nHarmony is a minimalist theme with clean lines and empasis on simplicity. It features menu hover text, horizontal login arrangement outside the site border and overprinted sitename. For additional configuration options, open themes/Harmony/config.php.inc', 1)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #141 In 0.8.0 update... " . mysql_error());

		$scheme_count += 1;
		$query = "INSERT INTO `$DB_Themes_Setup` VALUES ('$scheme_count', 'Springfield', '$theme_count', '#CCCC33', '#CCCC33', '#FFFFFF', '#999933', '#E0DFB9', '#010101', '#999933', '#404040', '#C4261D', '#010101', '#C4261D', '#999933', 1, 1)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #142 In 0.8.0 update... " . mysql_error());		
				
		$title_count += 1;
		$query = "INSERT INTO `$DB_Title_Pictures` VALUES ('$title_count', 'Harmony springfield', 'harmony_springfield.gif', 0, '$theme_count', 1, 300, 82)";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #143 In 0.8.0 update... " . mysql_error());		

		// end themes install		

	
		// OK this is a potential nightmare...
		
		// renumber existing users typeID 4
		$query = "SELECT * FROM $DB_Users_Types ORDER BY id DESC LIMIT 0,1";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #144 In 0.8.0 update... " . mysql_error());
		$ROW = mysql_fetch_object($result);
		$usertype_count = 1 + $ROW->id;
	    
		$query = "UPDATE $DB_Users_Assoc SET typeid='$usertype_count' WHERE typeid='4'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #145 In 0.8.0 update renumbering ID 4 in Users Assoc ... " . mysql_error());
	    
		$query = "UPDATE $DB_Events_Private SET typeid='$usertype_count' WHERE typeid='4'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #146 In 0.8.0 update renumbering ID 4 in Events_Private ... " . mysql_error());
		
		$query = "UPDATE $DB_Forums_Private SET typeid='$usertype_count' WHERE typeid='4'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #147 In 0.8.0 update renumbering ID 4 in Forums_Private ... " . mysql_error());
	    
		$query = "UPDATE $DB_Pages_Private SET typeid='$usertype_count' WHERE typeid='4'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #148 In 0.8.0 update renumbering ID 4 in Pages_Private ... " . mysql_error());
		
		$query = "UPDATE $DB_Photos_Albums_Private SET typeid='$usertype_count' WHERE typeid='4'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #149 In 0.8.0 update renumbering ID 4 in Photos_Albums_Private ... " . mysql_error());
		  
		$query = "UPDATE $DB_Users_Types SET id='$usertype_count' WHERE id='4'";
		$result = mysql_query($query, $Link) or queryError("240", mysql_error());  
	    
	    // renumber existing users typeID 5
		$query = "SELECT * FROM $DB_Users_Types ORDER BY id DESC LIMIT 0,1";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #150 In 0.8.0 update... " . mysql_error());
		$ROW = mysql_fetch_object($result);
		    $usertype_count = 1 + $ROW->id;
	    
		$query = "UPDATE $DB_Users_Assoc SET typeid='$usertype_count' WHERE typeid='5'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #151 In 0.8.0 update renumbering ID 5 in Users Assoc ... " . mysql_error());
	    
		$query = "UPDATE $DB_Events_Private SET typeid='$usertype_count' WHERE typeid='5'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #152 In 0.8.0 update renumbering ID 5 in Events_Private ... " . mysql_error());
		
		$query = "UPDATE $DB_Forums_Private SET typeid='$usertype_count' WHERE typeid='5'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #153 In 0.8.0 update renumbering ID 5 in Forums_Private ... " . mysql_error());
	    
		$query = "UPDATE $DB_Pages_Private SET typeid='$usertype_count' WHERE typeid='5'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #154 In 0.8.0 update renumbering ID 5 in Pages_Private ... " . mysql_error());
		
		$query = "UPDATE $DB_Photos_Albums_Private SET typeid='$usertype_count' WHERE typeid='5'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #155 In 0.8.0 update renumbering ID 5 in Photos_Albums_Private ... " . mysql_error());
		  
		$query = "UPDATE $DB_Users_Types SET id='$usertype_count' WHERE id='5'";
		$result = mysql_query($query, $Link) or queryError("240", mysql_error());
	    
	    // add the new user types
		$query = "INSERT INTO `$DB_Users_Types` (id, name) VALUES (4, 'Site Editor')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #156 In 0.8.0 update... " . mysql_error());
		
		$query = "INSERT INTO `$DB_Users_Types` (id, name) VALUES (5, 'Forum Manager')";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #157 In 0.8.0 update... " . mysql_error());
		
	// Add version # and finish
		$query = "UPDATE `$DB_Setup` SET setup_value='0.8.0' WHERE setup_key='Version'";
		$result = mysql_query($query, $Link) or die("MySQL Upgrade Error: #VER In 0.8.0 update... " . mysql_error());
		
	}
}
?>
Return current item: SiteX