<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('display_errors', 'on');
@set_time_limit(999);
ini_set('memory_limit', '256M');
define('ROOT', dirname(__FILE__));
set_include_path(ROOT.PATH_SEPARATOR.ROOT.'/Library'.PATH_SEPARATOR.
ROOT.'/Application/Controllers'.PATH_SEPARATOR.
ROOT.'/Application/Models/'.PATH_SEPARATOR.get_include_path());
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>数据升级</title>
<style type="text/css">
<!--
body,td,th {
	font-size: 14px;
}
body {
	background-color: #F3F3F3;
}
.STYLE1 {color: #FFFFFF}
-->
</style>
<script language="javascript">
function check(){
	var frm = document.form1;
	if (frm.dbhost.value == ''){
		alert('请填写数据库主机地址');
		frm.dbhost.focus();
		return false;
	}
	if (frm.dbuser.value == ''){
		alert('请填写数据库登陆帐户');
		frm.dbuser.focus();
		return false;
	}
	if (frm.dbpass.value == ''){
		alert('请填写数据库登陆密码');
		frm.dbpass.focus();
		return false;
	}
	if (frm.dbname.value == ''){
		alert('请填写数据库名');
		frm.dbname.focus();
		return false;
	}
	if (frm.tblpre.value == ''){
		alert('请填写表前缀');
		frm.tblpre.focus();
		return false;
	}
	return true;
}
</script>
</head>
<?php
if ($_GET['action'] == 'go'){
	require_once(ROOT.'/Application/global.func.php');
	require_once(ROOT.'/Config/database.inc.php');
	require_once(ROOT.'/Config/license.php');
	TableModel::setTableName($database['tblpre'], $database['dbname']);
	if ($_REQUEST['version'] == 1){
		require_once ROOT.'/upgrade/vodcms4.class.php';
	}elseif($_REQUEST['version'] == 2){
		require_once ROOT.'/upgrade/vodcms5.class.php';
	}else{
		exit('错误的版本号');
	}
	@set_time_limit(999);
	$grade = new upgrade();
	$grade->start();
	$VODCMS = new VodcmsModel();
	$VODCMS->clean();
	echo '数据升级成功!,请移除或者改名升级文件';
}?>
<body>
<table width="600" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
  <form id="form1" name="form1" method="post" action="upgrade.php?action=go" onsubmit="return check()">
    <tr bgcolor="#CCCCCC">
      <td colspan="2" align="center" bgcolor="#9A9A9A"><p class="STYLE1">秀影6.0数据升迁插件</p>
      <p class="STYLE1">各项参数请在旧版本config.inc.php文件查看</p></td>
    </tr>
    <tr>
    <td width="120" bgcolor="#FFFFFF"><div align="right">秀影源版本</div></td>
    <td width="457" bgcolor="#FFFFFF">
      
        <div align="left">
            <select name="version">
              <option value="1" <?php if($_REQUEST['version'] == 1) echo 'selected';?> >4.2.x</option>
              <option value="2" <?php if($_REQUEST['version'] == 2) echo 'selected';?>>5.0.x</option>
            </select>
          </div></td></tr>
  <tr>
    <td bgcolor="#FFFFFF"><div align="right">数据库地址：</div></td>
    <td bgcolor="#FFFFFF"><div align="left">
      <input name="dbhost" type="text" id="dbhost" value="<?php echo $_POST['dbhost'];?>" />
    *数据库主机的地址</div></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF"><div align="right">数据库帐户</div></td>
    <td bgcolor="#FFFFFF"><div align="left">
      <input name="dbuser" type="text" id="dbuser" value="<?php echo $_POST['dbuser'];?>" />
    *登陆数据库的用户名</div></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF"><div align="right">数据库密码：</div></td>
    <td bgcolor="#FFFFFF"><div align="left">
      <input name="dbpass" type="text" id="dbpass" value="<?php echo $_POST['dbpass'];?>" />
    *登陆与会的密码</div></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF"><div align="right">数据库名：</div></td>
    <td bgcolor="#FFFFFF"><div align="left">
      <input name="dbname" type="text" id="dbname" value="<?php echo $_POST['dbname'];?>" />
    *数据库的名称</div></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">数据库表前缀：</td>
    <td bgcolor="#FFFFFF"><input name="tblpre" type="text" id="tblpre" value="<?php echo $_POST['tblpre'] ? $_POST['tblpre'] : 'vodcms_';?>" />
      *4.2.2默认是jdzcnnet_。5.0x是vodcms_</td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF"><div align="right">字符集：</div></td>
    <td bgcolor="#FFFFFF"><div align="left">
      <select name="charset" id="charset">
        <option value="GBK" <?php if($_REQUEST['charset'] == 'GBK') echo 'selected';?>>GBK</option>
        <option value="UTF8" <?php if($_REQUEST['charset'] == 'UTF-8') echo 'selected';?> >UTF-8</option>
      </select>
      </div></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF"><input type="submit" name="Submit" value="提交" /></td>
  </tr>
  </form>
</table>
</body>
</html>
