<?php 
header("Content-Type: text/html; charset=gb2312");
if(is_file('./lock.lock')){
	exit('已经升级过了，如果想强制升级，请删除update/lock.lock文件然后再次刷新');
}
include("../include/conn.php");
//echo str_repeat(' ' ,1000);
$updateSql = file_get_contents('./update.sql');
$arraySql = explode(';', $updateSql);
$countSql = count($arraySql);
for($i=0;$i<$countSql;$i++) {
	if($i==0){
		include 'setup_2_1.php';
	}
	$db->query($arraySql[$i]);
	echo '<script type="text/javascript">showmsg(\'第'.($i+1).'条升级语句执行成功\');</script>';
	ob_flush();
	flush();
	sleep(1);
}
if (file_put_contents('./lock.lock', 'OK')) {
	echo '<script type="text/javascript">showmsg(\'恭喜，全部执行完毕\');</script>';	
} else {
	echo '<script type="text/javascript">showmsg(\'恭喜，全部执行完毕，请自行删除update目录\');</script>';
}
ob_flush();
flush();
sleep(1);
?>