<?php
/*升级v2.0版数据库更新文件*/
define('IN_PHPUP',1);

//表前缀
function tname($table)
{
	global $dbname,$table_prefix;
	return '`'.$dbname.'`.`'.$table_prefix.$table.'`';
}
if(is_file("../data/config.inc.php"))
{
	
	include "../data/config.inc.php";

	$link=mysql_connect($dbhost,$dbuser,$dbpw);
	$error='';
	header("Content-type:text/html;charset=".$charset);
	mysql_query('use '.$dbname);
	mysql_query('set names '.$dbcharset);

	$sql[]="ALTER TABLE  ".tname('catelist')." ADD  `recommend` TINYINT( 1 ) NOT NULL;";
	$sql[]="ALTER TABLE  ".tname('catelist')." ADD  `css` VARCHAR( 50 ) NOT NULL ;";
	$sql[]="ALTER TABLE ".tname('site')." ADD `transkey` INT NOT NULL ;";
	$sql[]="ALTER TABLE ".tname('site')." ADD UNIQUE (`transkey` );";

	foreach($sql as $v)
	{
		if(!mysql_query($v))
		{
			
			$error.="<p>".mysql_error()."</p>";
			continue;
		}
	}

	echo '升级完毕';
}
else
{
	echo "<script language='javascript'>alert('安装完成后升级');window.location='../install/index.php';</script>";
}

?>
