<?php
// ------------------------------------------------------------------------- //
//                XOOPS - PHP Content Management System                      //
//                       <http://www.xoops.org/>                             //
// ------------------------------------------------------------------------- //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
// ------------------------------------------------------------------------- //
function install_header(){
?>
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
	<html>
	<head>
	<title>XOOPS Upgrade RC2.0.2 -> RC3.0.0</title>
	<meta http-equiv="Content-Type" content="text/html; charset=">
	<meta name="AUTHOR" content="XOOPS">
	<meta name="GENERATOR" content="XOOPS-- http://xoops.sourceforge.net/">
	</head>
	<body>
	<div style='text-align:center'><img src='images/logo.gif' /><h3>XOOPS Upgrade RC2.0.2 -> RC3.0.0</h3><br />
<?php
}

function install_footer(){
?>
	<br /><br /><a href='http://www.xoops.org/' target='_blank'><img src='images/s_poweredby.gif' alt='XOOPS' border='0' /></a></div>
	</body>
	</html>
<?php
}

if ( !isset($action) || $action == "" ) {
	$action = "message";
}

if ( $action == "message" ) {
	install_header();
	echo "
	<table width='90%' border='0'><tr><td colspan='2'>This script will upgrade from XOOPS RC2.0.2 to XOOPS RC3.0. Before upgrading, make sure that you have:</td></tr>
	<tr><td>-</td><td>Edited database/site settings in mainfile.php</b></td></tr>
	<tr><td>-</td><td>Uploaded all new files included in the new package.</td></tr>
	<tr><td>-</td><td><span style='color:#ff0000;font-weight:bold;'>Back-up your database.</span></td></tr>
	</table>
	";
	echo "<p>Press the button below to start the upgrade process.</p>";
	echo "<form action='".$PHP_SELF."' method='post'><input type='submit' value='Start Upgrade' /><input type='hidden' value='upgrade' name='action' /></form>";
	install_footer();
	exit();
}

if ( $action == "upgrade" ) {
include("mainfile.php");
install_header();
echo "<h4>Update from RC2.0.2 to RC3.0 start.</h4>\n";
$error = array();

$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("comments")." CHANGE `tid` `comment_id` INT(8) UNSIGNED NOT NULL AUTO_INCREMENT, CHANGE `storyid` `item_id` INT(8) UNSIGNED DEFAULT '0' NOT NULL, CHANGE `uid` `user_id` INT(5) UNSIGNED DEFAULT '0' NOT NULL, CHANGE `host_name` `ip` CHAR(15) NOT NULL, ADD `noxcode` TINYINT(1) DEFAULT '0' NOT NULL AFTER `nosmiley`"); 
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("comments")."";
}
$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("pollcomments")." CHANGE `tid` `comment_id` INT(8) UNSIGNED NOT NULL AUTO_INCREMENT, CHANGE `pollID` `item_id` INT(8) UNSIGNED DEFAULT '0' NOT NULL, CHANGE `uid` `user_id` INT(5) UNSIGNED DEFAULT '0' NOT NULL, CHANGE `host_name` `ip` CHAR(15) NOT NULL, ADD `noxcode` TINYINT(1) DEFAULT '0' NOT NULL AFTER `nosmiley`"); 
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("pollcomments")."";
}
$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("modules")." ADD isactive TINYINT(1) DEFAULT '0' NOT NULL AFTER last_update, ADD weight int(3) DEFAULT '0' NOT NULL AFTER last_update"); 
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("modules")."";
}
$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("newblocks")." ADD isactive TINYINT(1) DEFAULT '0' NOT NULL"); 
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("newblocks")."";
}
$result = $xoopsDB->queryF("UPDATE ".$xoopsDB->prefix("modules")." SET isactive=1"); 
if (!$result) {
	$error[] = "Failed UPDATE ".$xoopsDB->prefix("modules")."";
}
$result = $xoopsDB->queryF("UPDATE ".$xoopsDB->prefix("newblocks")." SET isactive=1"); 
if (!$result) {
	$error[] = "Failed UPDATE ".$xoopsDB->prefix("newblocks")."";
}


$sql = "SELECT mid FROM ".$xoopsDB->prefix("modules")." WHERE dirname='lastseen'";
list($mid) = $xoopsDB->fetchRow($xoopsDB->query($sql));
if ( !empty($mid) ) {
	$sql = "DELETE FROM ".$xoopsDB->prefix("modules")." WHERE mid=".$mid."";
	if (!$xoopsDB->queryF($sql)) {
		$error[] = "Failed deactivating 'lastseen' module";
	} else {
		$sql = "DELETE FROM ".$xoopsDB->prefix("newblocks")." WHERE mid=".$mid."";
		$xoopsDB->queryF($sql);
	}
}
unset($mid);
$sql = "SELECT mid FROM ".$xoopsDB->prefix("modules")." WHERE dirname='emptyblock'";
list($mid) = $xoopsDB->fetchRow($xoopsDB->query($sql));
if ( !empty($mid) ) {
	$sql = "DELETE FROM ".$xoopsDB->prefix("modules")." WHERE mid=".$mid."";
	if (!$xoopsDB->queryF($sql)) {
		$error[] = "Failed deactivating 'emptyblock' module";
	} else {
		$sql = "DELETE FROM ".$xoopsDB->prefix("newblocks")." WHERE mid=".$mid."";
		$xoopsDB->queryF($sql);
	}
}
unset($mid);
$sql = "SELECT mid FROM ".$xoopsDB->prefix("modules")." WHERE dirname='polls'";
list($mid) = $xoopsDB->fetchRow($xoopsDB->query($sql));
if ( !empty($mid) ) {
	$sql = "DELETE FROM ".$xoopsDB->prefix("modules")." WHERE mid=".$mid."";
	if (!$xoopsDB->queryF($sql)) {
		$error[] = "Failed deactivating 'polls' module";
	} else {
		$sql = "DELETE FROM ".$xoopsDB->prefix("newblocks")." WHERE mid=".$mid."";
		$xoopsDB->queryF($sql);
	}
}
unset($mid);
$sql = "SELECT mid FROM ".$xoopsDB->prefix("modules")." WHERE dirname='memberslist'";
list($mid) = $xoopsDB->fetchRow($xoopsDB->query($sql));
if ( !empty($mid) ) {
	$sql = "DELETE FROM ".$xoopsDB->prefix("modules")." WHERE mid=".$mid."";
	if (!$xoopsDB->queryF($sql)) {
		$error[] = "Failed deactivating 'memberslist' module";
	}
}

$official_mods = array("contact", "ephemerides", "faq", "headlines", "mydownloads", "mylinks", "newbb", "news", "partners", "quotes", "sections", "visitors2", "whosonline", "xoopsmembers", "system", "xoopspoll");
$rc3mods = array("buddy"=>"http://www.frxoops.org/fichiers/rc3/buddy-1-rc3.zip", "glossaire"=>"http://www.frxoops.org/fichiers/rc3/glossaire-1-6-rc3.zip", "UserPoints"=>"http://www.frxoops.org/fichiers/rc3/UserPoints-rc3(1).zip", "Guestbook"=>"http://www.frxoops.org/fichiers/rc3/Guestbook.zip", "freecontent"=>"http://xoops.sourceforge.net/downloads/freecontent.zip", "babe"=>"http://files.farsus.dk/xoops/rc3/modules/baberc3.zip", "hunk"=>"http://files.farsus.dk/xoops/rc3/modules/hunkrc3.zip ", "guestbook"=>"http://www.myxoops.org/rc3module/guestbook.zip", "sitemap"=>"http://www.myxoops.org/rc3module/sitemap.zip", "topics"=>"http://www.myxoops.org/rc3module/topics.zip", "MySql_Tool"=>"http://www.myxoops.org/", "eCal"=>"http://www.frxoops.org/fichiers/rc3/ecal-2-2-rc3.zip", "meta-generator"=>"http://www.gametoolbox.com/home/modules/mydownloads/viewcat.php?cid=7", "nsections"=>"http://www.gametoolbox.com/home/modules/mydownloads/viewcat.php?cid=7", "gamequery"=>"http://www.gametoolbox.com/home/modules/mydownloads/viewcat.php?cid=7");
$unofficial_mods = array();
$installed_mods = XoopsModule::getInstalledModules();
$listed_mods = array();
foreach ( $installed_mods as $module ) {
	$listed_mods[] = trim($module->dirname());
}
$modules_dir = XOOPS_ROOT_PATH."/modules";
$handle = opendir($modules_dir);
while ($file = trim(readdir($handle))) {
	clearstatcache();
	if ( !ereg("^[.]{1,2}$",$file) && is_dir($modules_dir."/".$file) ) {
		if ( !in_array($file, $listed_mods) ) {
			if ( in_array($file, $official_mods) ) {
				$module = new XoopsModule();
				$module->loadModInfo($file);
				// xoopspoll tables must be created
				if ( $file == "xoopspoll" ) {
					$newmid = $module->install();
				} else {
					// others are already created, so not now
					$newmid = $module->install(false);
				}
				if ( !$newmid ) {
					$error[] = "Failed changing status of $file module";
				} else {
					$xoopsDB->queryF("UPDATE ".$xoopsDB->prefix("modules")." SET isactive=0 WHERE mid=".$newmid.""); 
					$xoopsDB->queryF("UPDATE ".$xoopsDB->prefix("newblocks")." SET isactive=0 WHERE mid=".$newmid.""); 
				}
			} else {
				if ( $file != "lastseen" && $file != "memberslist" && $file != "polls" && $file != "emptyblock" ) {
					$unofficial_mods[] = $file;
				}
			}
		}
	}
}



$result = $xoopsDB->queryF("CREATE TABLE ".$xoopsDB->prefix("groups_blocks_link")." (groupid int(5) NOT NULL default '0', block_id int(5) NOT NULL default '0', type char(1) NOT NULL default '')");
if (!$result) {
	$error[] = "Failed CREATE TABLE ".$xoopsDB->prefix("groups_blocks_link")."";
} else {
	$result = $xoopsDB->queryF("SELECT groupid FROM ".$xoopsDB->prefix("groups")."");
	if ( !$result ) {
		$error[] = "Failed SELECT groupid FROM ".$xoopsDB->prefix("groups")."";
	} else {
		$groups = array();
		while ( $myrow = $xoopsDB->fetchArray($result)) {
			$groups[] = $myrow['groupid'];
		}
		$result = $xoopsDB->queryF("SELECT bid FROM ".$xoopsDB->prefix("newblocks")."");
		if (!$result) {
			$error[] = "Failed SELECT bid FROM ".$xoopsDB->prefix("newblocks")."";
		} else {
			$blocks = array();
			while ( $myrow = $xoopsDB->fetchArray($result)) {
				$blocks[] = $myrow['bid'];
			}
			foreach ( $groups as $g ) {
				foreach ( $blocks as $b ) {
					$xoopsDB->query("INSERT INTO ".$xoopsDB->prefix("groups_blocks_link")." VALUES ($g, $b, 'R')");
				}
			}
		}
	}
}

$result = $xoopsDB->queryF("CREATE TABLE ".$xoopsDB->prefix("tempusers")." (
  `uid` int(5) unsigned default '0' NOT NULL,
  `name` varchar(60) NOT NULL default '',
  `uname` varchar(25) NOT NULL default '',
  `email` varchar(60) NOT NULL default '',
  `url` varchar(100) NOT NULL default '',
  `user_avatar` varchar(30) default NULL,
  `user_regdate` int(10) NOT NULL default '',
  `user_icq` varchar(15) default NULL,
  `user_from` varchar(100) default NULL,
  `user_sig` text,
  `user_viewemail` tinyint(1) NOT NULL default '0',
  `actkey` varchar(8) default NULL,
  `user_aim` varchar(18) default NULL,
  `user_yim` varchar(25) default NULL,
  `user_msnm` varchar(25) default NULL,
  `pass` varchar(32) NOT NULL default '',
  `posts` int(8) default '0',
  `attachsig` TINYINT(1) default '0',
  `rank` int(5) NOT NULL default '0',
  `level` int(5) NOT NULL default '1',
  `theme` varchar(100) NOT NULL default '',
  `timezone_offset` float(3,1) NOT NULL default '0.0',
  last_login INT(10) DEFAULT '0' NOT NULL,
  `umode` varchar(10) NOT NULL default '',
  `uorder` tinyint(1) NOT NULL default '0',
  `user_occ` varchar(100) default NULL,
  `bio` tinytext NOT NULL,
  `user_intrest` varchar(150) default NULL,
  KEY `idxusersuname` (`uname`),
  KEY `idxusersemail` (`email`),
  KEY `idxusersuiduname` (`uid`,`uname`),
  KEY `idxusersunamepass` (`uname`,`pass`)
)");

if(!$result){
	$error[] = "Failed CREATE TABLE ".$xoopsDB->prefix("tempusers")."";
}else{

	$result = $xoopsDB->queryF("INSERT INTO ".$xoopsDB->prefix("tempusers")." (uid, name, uname, email, url, user_avatar, user_regdate, user_icq, user_from, user_sig,  user_viewemail, actkey, user_aim, user_yim, user_msnm, pass, posts, attachsig, rank, level, theme, timezone_offset, umode, uorder, user_occ, bio, user_intrest) SELECT u.uid, u.name, u.uname, u.email, u.url, u.user_avatar, u.user_regdate, u.user_icq, u.user_from, u.user_sig,  u.user_viewemail, u.actkey, u.user_aim, u.user_yim, u.user_msnm, u.pass, u.posts, u.attachsig, u.rank, u.level, u.theme, u.timezone_offset, s.umode, s.uorder, s.user_occ, s.bio, s.user_intrest FROM ".$xoopsDB->prefix("users")." AS u, ".$xoopsDB->prefix("users_status")." AS s WHERE s.uid=u.uid");
	if(!$result){
		$error[] = "Unable to import data into ".$xoopsDB->prefix("tempusers")."";
	} else {
		$result = $xoopsDB->queryF("DROP TABLE ".$xoopsDB->prefix("users_status")."");
		if ( !$result ) {
			$error[] = "Failed DROP TABLE ".$xoopsDB->prefix("users_status")."";
		}
		$result = $xoopsDB->queryF("DROP TABLE ".$xoopsDB->prefix("users")."");
		if ( !$result ) {
			$error[] = "Failed DROP TABLE ".$xoopsDB->prefix("users_status")."";
		}
		$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("tempusers")." RENAME ".$xoopsDB->prefix("users")." ");
		if ( !$result ) {
			$error[] = "Failed RENAME ".$xoopsDB->prefix("tempusers")."";
		} else {
			$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("users")." CHANGE uid uid INT(5) UNSIGNED DEFAULT '0' NOT NULL AUTO_INCREMENT ");
			if ( !$result ) {
				$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("users")."";
			} 
		}
	}
}

$result = $xoopsDB->queryF("DROP TABLE ".$xoopsDB->prefix("bad_words")); 
if (!$result) {
	$error[] = "Failed DROP TABLE ".$xoopsDB->prefix("bad_words")."";
}
$result = $xoopsDB->queryF("DROP TABLE ".$xoopsDB->prefix("user_banlist")); 
if (!$result) {
	$error[] = "Failed DROP TABLE ".$xoopsDB->prefix("user_banlist")."";
}

$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("bb_forums")." ADD `allow_html` TINYINT(1) DEFAULT '0' NOT NULL, ADD `allow_sig` TINYINT(1) DEFAULT '0' NOT NULL, ADD `posts_per_page` TINYINT(3) UNSIGNED DEFAULT '20' NOT NULL, ADD `hot_threshold` TINYINT(3) UNSIGNED DEFAULT '10' NOT NULL, ADD `topics_per_page` TINYINT(3) UNSIGNED DEFAULT '20' NOT NULL");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("bb_forums")."";
}
$result = $xoopsDB->queryF("DROP TABLE ".$xoopsDB->prefix("bb_config")); 
if (!$result) {
	$error[] = "Failed DROP TABLE ".$xoopsDB->prefix("bb_config")."";
}
$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("bb_categories")." CHANGE cat_id cat_id smallint(3) unsigned NOT NULL auto_increment");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("bb_categories")."";
}
$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("bb_forum_access")." CHANGE forum_id forum_id int(4) unsigned NOT NULL default '0', CHANGE user_id user_id int(5) unsigned NOT NULL default '0' ");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("bb_forum_access")."";
}

$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("bb_forum_mods")." CHANGE forum_id forum_id int(4) unsigned NOT NULL default '0', CHANGE user_id user_id int(5) unsigned NOT NULL default '0' ");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("bb_forum_mods")."";
}

$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("bb_forums")." CHANGE forum_id forum_id int(4) unsigned NOT NULL auto_increment, CHANGE forum_access forum_access TINYINT(2) NOT NULL default '1'");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("bb_forums")."";
}
$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("bb_posts")." DROP INDEX forum_id, DROP INDEX topic_id, ADD INDEX forumid_uid (forum_id, uid), ADD INDEX topicid_uid (topic_id, uid), ADD INDEX topicid_postid_pid (topic_id, post_id, pid)");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("bb_posts")."";
}

$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("bb_posts_text")." CHANGE post_id post_id int(8) unsigned NOT NULL auto_increment");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("bb_posts_text")."";
}
$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("bb_topics")." ADD topic_sticky tinyint(1) NOT NULL default '0', ADD INDEX topic_sticky (topic_sticky)");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("bb_topics")."";
}

$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("modules")." ADD INDEX name (name(15))");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("modules")."";
}

$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("newblocks")." ADD INDEX mid_funcnum (mid, func_num)");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("newblocks")."";
}

$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("stories")." CHANGE  storyid storyid int(8) unsigned NOT NULL auto_increment, CHANGE uid uid int(5) unsigned NOT NULL default '0', CHANGE counter counter int(8) unsigned NOT NULL default '0', CHANGE topicid topicid int(8) unsigned NOT NULL default '1', CHANGE ihome ihome tinyint(1) NOT NULL default '0', DROP INDEX published, ADD INDEX created (created)");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("stories")."";
}
$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("headlines")." CHANGE hid hid int(4) unsigned NOT NULL auto_increment");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("headlines")."";
}

$result = $xoopsDB->queryF("ALTER TABLE ".$xoopsDB->prefix("lastseen")." CHANGE ip ip varchar(15) NOT NULL default ''");
if (!$result) {
	$error[] = "Failed ALTER TABLE ".$xoopsDB->prefix("lastseen")."";
}

echo "<p>...Updating</p>\n";
if ( count($error) ) {
	echo "<p><span style='color:#ff0000;font-weight:bold'>There was an error while updating MySQL database tables. <br />Please contact the support team at <a href='http://www.xoops.org/'>xoops.org</a>.</span></p>\n";
	foreach( $error as $err ) {
		echo $err."<br>";
	}
} else {
	echo "<div style='text-align:center;'><h4>Upgrade from RC2.0.2 to RC3.0 end.</h4>\n";
	echo "<table width='70%' border='0'><tr><td>";
	if (is_dir(XOOPS_ROOT_PATH."/modules/memberslist/")) {
		echo "The '<b>memberslist</b>' module is now replaced with the new '<b>xoopsmembers</b>' module. You can delete ".XOOPS_ROOT_PATH."/modules/memberslist/ directory and all files under the directory.<br /><br />";
	}
	if (is_dir(XOOPS_ROOT_PATH."/modules/lastseen/")) {
		echo "The '<b>lastseen</b>' module has been integrated with the '<b>whosonline</b>' module. You can delete ".XOOPS_ROOT_PATH."/modules/lastseen/ directory and all files under the directory.<br /><br />";
	}
	if (is_dir(XOOPS_ROOT_PATH."/modules/emptyblock/")) {
		echo "The '<b>emptyblock</b>' module has been integrated with the new blocks system. You can delete ".XOOPS_ROOT_PATH."/modules/emptyblock/ directory and all files under the directory.<br /><br />";
	}
	if (is_dir(XOOPS_ROOT_PATH."/modules/polls/")) {
		echo "The '<b>polls</b>' module is now replaced with the new '<b>xoopspoll</b>' module. You can delete ".XOOPS_ROOT_PATH."/modules/polls/ directory and all files under the directory.<br /><br />";
	}
	if (!mkdir(XOOPS_ROOT_PATH."/images/avatar/users/", 0777)) {
		echo "In order to allow users to use custom avatars, ".XOOPS_ROOT_PATH."/images/avatar/users/ directory must be created with the write permission by the server. (i.e. chmod 777 on a UNIX/LINUX server) <br /><br />";
	}
	
	$unofficial_mods_installed = array();
	foreach ( $listed_mods as $lm ) {
		if ( !in_array($lm, $official_mods) && $lm != "polls" ) {
			$unofficial_mods_installed[] = $lm;
		}
	}
	if ( count($unofficial_mods_installed) > 0 || count($unofficial_mods) > 0 ) {
		echo "<span style='color:#ff0000;font-weight:bold'>The following directories contain a module that is not officially released by XOOPS.ORG. The module(s) may not be compatible with RC3. Please contact the module developer and update the files where necessary.</span><br /><ul>";
		if ( count($unofficial_mods_installed) > 0 ) {
			echo "<li><b>Installed</b></li><ul>";
			foreach ( $unofficial_mods_installed as $umi ) {
				echo "<li>".XOOPS_ROOT_PATH."/modules/".$umi."/";
				if (in_array($umi, array_keys($rc3mods))) {
					echo "<br />  (You can download the RC3 version at <a href='".$rc3mods[$umi]."' target='_blank'>".$rc3mods[$umi]."</a>)";
				}
				echo "</li>";
			}
			echo "</ul>";
		}
		if ( count($unofficial_mods) > 0 ) {
			echo "<li><b>Not Installed</b></li><ul>";
			foreach ( $unofficial_mods as $um ) {
				echo "<li>".XOOPS_ROOT_PATH."/modules/".$um."/";
				if (in_array($um, array_keys($rc3mods))) {
					echo "<br /> (You can download the RC3 version at <a href='".$rc3mods[$um]."' target='_blank'>".$rc3mods[$um]."</a>)";
				}
				echo "</li>";
			}
			echo "</ul>";
		}
		echo "</ul>";
	}
	echo "</td></tr></table><br /><br /><a href='".XOOPS_URL."/'>Home</a>";
}
install_footer();
}
?>