<?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('site')." ADD `breaksuff` VARCHAR( 200 ) NOT NULL ;";
	$sql[]="ALTER TABLE ".tname('site')." ADD `limitcity` VARCHAR( 200 ) NOT NULL ;";
	$sql[]="ALTER TABLE ".tname('site')." ADD `limitnum` TINYINT( 5 ) NOT NULL ;";
	$sql[]="ALTER TABLE ".tname('site')." ADD `localapi` VARCHAR( 200 ) NULL AFTER `siteapi` ;";
	$sql[]='ALTER TABLE '.tname('groups').' ADD `temporder` INT NOT NULL;';
	$sql[]='ALTER TABLE '.tname('site').' CHANGE `level` `level` SMALLINT( 5 ) NOT NULL;';
	$sql[]='ALTER TABLE '.tname('othersite').' CHANGE `url` `url` VARCHAR( 200 );';
	$sql[]='CREATE TABLE IF NOT EXISTS '.tname('plugins').' (  `id` tinyint(4) NOT NULL AUTO_INCREMENT,  `pluginsname` varchar(300) NOT NULL,  `isok` tinyint(1) NOT NULL,  PRIMARY KEY (`id`)) ENGINE=MyISAM  DEFAULT CHARSET='.$dbcharset;

	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>";
}

?>
