<!-- #include file="Conn.asp" -->
<%
Session.CodePage=65001
%>
<!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" lang="UTF-8">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="Content-Language" content="UTF-8" />
	<title>Wodig4 Updater</title>
	<style>
	 body{font-size:12px;font-family:verdana;text-align:center;background:#e9f1f8;}
	 .tBody{margin:auto;width:604px;padding:4px;border:2px solid #45749e;background:#c8dbec url(bg.png);}
	 .ins{height:200px;border:1px solid #000;padding:3px;margin:3px;overflow:auto;background:#fff;text-align:left;line-height:160%}
	 .ins div{margin:0px;padding:2px;font-size:12px;text-align:left}
	 .info{padding:4px;padding-left:0px;margin:3px;text-align:left;background:url(logo.gif) no-repeat right}
	 .more{height:20px;padding:4px;padding-left:0px;margin:3px;text-align:left;}
	 .per{height:20px;border:1px solid #000;padding:1px;margin:3px;text-align:left;background:#fff}
	 .copyRight{border:1px solid #000;padding:4px;padding-left:0px;margin:3px;text-align:left}
	 h4{margin:0px;margin-bottom:6px;font-size:18px}
	 #per{height:20px;overflow:hidden;background:#0080ff url(per.png);text-align:left;}
	 #per span{color:#fff;font-weight:bold;margin:3px;display:block}
	 #ListF{height:24px;overflow:hidden}
	 .alert{color:#f00}
	 
	</style>
</head>
<body>
<script language="javascript">
AddProcessbar();
var bwidth=0;
var swidth = document.all.waiting.clientWidth;

function CheckIsProcessBar(obj)
{
if (obj.IsShowProcessBar=="True") 
{
return false;
} 
else
{
return true;
}
}

function CheckClick(e)
{
if (e == 1)
{
if (bwidth<swidth*0.98){
bwidth += (swidth - bwidth) * 0.025;
if (document.all)document.sbar.width = bwidth;
else document.rating.clip.width = bwidth;
setTimeout('CheckClick(1);',150);

}
}
else
{
if(document.all)
{
if(document.all.waiting.style.visibility == 'visible')
{document.all.waiting.style.visibility = 'hidden';
bwidth = 1;}
whichIt = event.srcElement;

while (CheckIsProcessBar(whichIt))
{
whichIt = whichIt.parentElement;
if (whichIt == null)return true;
}


document.all.waiting.style.pixelTop = (document.body.offsetHeight - document.all.waiting.clientHeight) / 2 + document.body.scrollTop;
document.all.waiting.style.pixelLeft = (document.body.offsetWidth - document.all.waiting.clientWidth) / 2 + document.body.scrollLeft;
document.all.waiting.style.visibility = 'visible';
if(!bwidth)CheckClick(1);
bwidth = 1;

}

else
{

if(document.waiting.visibility == 'show')
{document.waiting.visibility = 'hide';
document.rating.visibility = 'hide';
bwidth = 1;}
if(e.target.href.toString() != '')
{
document.waiting.top = (window.innerHeight - document.waiting.clip.height) / 2 + self.pageYOffset;
document.waiting.left = (window.innerWidth - document.waiting.clip.width) / 2 + self.pageXOffset;
document.waiting.visibility = 'show';
document.rating.top = (window.innerHeight - document.waiting.clip.height) / 2 + self.pageYOffset+document.waiting.clip.height-10;
document.rating.left = (window.innerWidth - document.waiting.clip.width) / 2 + self.pageXOffset;
document.rating.visibility = 'show';
if(!bwidth)CheckClick(1);
bwidth = 1;
}
}
return true;
}
}

function AddProcessbar()
{

var Str=""
Str+= "<div id=waiting style=position:absolute;top:50px;left:100px;z-index:1;visibility:hidden >";
Str+= "<layer name=waiting visibility=visible zIndex=2 >"
Str+= "<table border=2 cellspacing=1 cellpadding=0 bordercolorlight=#FFFFFF bordercolordark=#C0C0C0 bgcolor=#E0E0E0>"
Str+= " <tr>"
Str+= " <td bgcolor=#E0E0E0 height=30px width=300px align=center>"
Str+= " <font color=black>系統正在處理中...</font>"
Str+= " </td>"
Str+= " </tr>"
Str+= " <tr>"
Str+= " <td bgcolor=#E0E0E0>"
Str+= " <img width=1 height=10 name=sbar style=background-color:#6699cc>"
Str+= " </td>"
Str+= " </tr>"
Str+= "</table> "
Str+= "</layer>"
Str+= "</div>"
document.write(Str)

if(document.all)document.onclick = CheckClick; 
}
</script>

<br/>
<div id="tBody" class="tBody">
<div class="info">
	<h4>Wodig4.1.4 Updater</h4>
	<div id="ListF"><b>执行升级 SQL 语句</b> <span id="FileN"><font color="#FF0000">技术开发&维护：水妖精(QQ:307165065)</font></span>
	</div>
	</div>

<br /><br />
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#339900">
  <form name="form1" action="" method="post">
  <tr>
    <td height="50" colspan="2" align="center" bgcolor="#FFFFFF"><strong>Wodig4.1.4(免费版)升级数据库</strong>
	<br />
	(<font color="#FF0000">请在Wodig4.1.2基础上进行数据库更新</font>)
	</td>
  </tr>
  <tr>
    <td height="30" align="center" bgcolor="#FFFFFF">用户组设置更新</td>
    <td align="center" bgcolor="#FFFFFF"><a href="?menu=upDB4" title="增加用户组设置" IsShowProcessBar="True">增加用户组设置</a></td>
  </tr>
  <tr>
    <td height="30" align="center" bgcolor="#FFFFFF">网站设置更新</td>
    <td align="center" bgcolor="#FFFFFF"><a href="?menu=raDB4" title="升级更新网站设置" IsShowProcessBar="True">升级更新网站设置</a></td>
  </tr>
<!---    <tr>
    <td width="50%" height="30" align="center" bgcolor="#FFFFFF">第一步</td>
    <td width="50%" align="center" bgcolor="#FFFFFF"><a href="?menu=upgradeDB" title="如果您的网站是Wodig4.0.1，请从这里开始" IsShowProcessBar="True">如果您的网站是Wodig4.0.1，请点击</a></td>
  </tr>
  <tr>
    <td height="30" align="center" bgcolor="#FFFFFF">第二步</td>
    <td align="center" bgcolor="#FFFFFF"><a href="?menu=InitializeDB" title="增加评论审核功能" IsShowProcessBar="True">升级评论审核功能</a></td>
  </tr>
  <tr>
    <td height="30" align="center" bgcolor="#FFFFFF">第三步</td>
    <td align="center" bgcolor="#FFFFFF"><a href="?menu=FavCount" title="个人数据功能增强" IsShowProcessBar="True">个人数据功能增强</a></td>
  </tr>
  <tr>
    <td height="30" align="center" bgcolor="#FFFFFF">第四步</td>
    <td align="center" bgcolor="#FFFFFF"><a href="?menu=DigCount" title="增加网站全局分类自定义功能，以后再也不用修改代码了！" IsShowProcessBar="True">增加分类功能</a></td>
  </tr>
  <tr>
    <td height="30" align="center" bgcolor="#FFFFFF">第五步</td>
    <td align="center" bgcolor="#FFFFFF"><a href="?menu=focus" title="增加网站焦点图设置功能，以后更新焦点图再也不用修改代码了！" IsShowProcessBar="True">增加焦点图功能</a></td>
  </tr>--->
  <tr>
    <td height="30" align="center" bgcolor="#FFFFFF">最后一步</td>
    <td align="center" bgcolor="#FFFFFF"><a href="?menu=del" title="为了确保您的网站安全，请在升级成功后务必执行此项！" IsShowProcessBar="True">删除升级文件自身</a></td>
  </tr>  
  </form>
</table>
<div id="fileList" class="ins">
<%
menu=trim(request("menu"))
select case menu
	case "upDB4"
		'增加用户组设置
		conn.execute("alter table [Wo_Roles] add RoleMaxFileSize LONG DEFAULT 0,RoleMaxPostAttachmentsSize LONG DEFAULT 0")
		response.Write("<span style=""color:#0000a0"">增加用户组设置完成</span><br><br>")
		response.Write("<a href='upgrade.asp'>>>返回<<</a></div>")
	case "raDB4"
		'增加数据库版本信息，定义版本号4.1.4
		conn.execute("alter table [Wo_SiteSettings] add [WoVersion] TEXT(255)")
		conn.execute("update [Wo_SiteSettings] set WoVersion='4.1.4'")
		response.Write("<span style=""color:#0000a0"">更新数据库结构完成，数据库版本升级为4.1.4</span><br><br>")
		response.Write("<a href='upgrade.asp'>>>返回<<</a></div>")	
	case "upgradeDB"
		'友情链接 Wo_links 增加Show 布尔型， Color Text
		conn.execute("alter table [WO_Links] add [Show] BIT NOT NULL,[Color] text;")
		response.Write("<span style=""color:#0000a0"">更新数据库结构完成，数据库升级到4.0.3</span><br><br>")
		response.Write("<a href='upgrade.asp'>>>返回<<</a></div>")
	case "InitializeDB"
		'个人评论审核——Wo_SrcRevert 增加 Re_IsOver 是/否
		conn.execute("alter table [Wo_SrcRevert] add  [Re_IsOver] BIT NOT NULL DEFAULT TRUE;")
		response.Write("<span style=""color:#0000a0"">更新数据库结构完成</span><br><br>")
		response.Write("<a href='upgrade.asp'>>>返回<<</a></div>")
	case "FavCount"
		'个人主页自定义功能 Wo_Users 增加 WebCSS 备注 银行功能
		conn.execute("alter table [Wo_Users] add [WebCSS] MEMO,[SaveMoney] LONG DEFAULT 0,[SaveMoneyTime] DATETIME DEFAULT Now();")
		response.Write("<span style=""color:#0000a0"">更新数据库结构完成</span><br><br>")
		response.Write("<a href='upgrade.asp'>>>返回<<</a></div>")
	case "DigCount"
		'增加网站分类功能
		conn.execute("CREATE TABLE [Wo_Category]([cateID] LONG, [icon] TEXT(255), [ID] COUNTER NOT NULL, [Intro] TEXT(255), [local] BIT NOT NULL DEFAULT false, [Name] TEXT(255), [OutLink] BIT NOT NULL DEFAULT false, [Secret] BIT NOT NULL DEFAULT false, [URL] TEXT(255));")
		conn.execute("CREATE INDEX [PrimaryKey] ON [Wo_Category]([ID]) WITH PRIMARY;")
		response.Write("<span style=""color:#0000a0"">增加网站分类功能完成</span><br><br>")
		response.Write("<a href='upgrade.asp'>>>返回<<</a></div>")
	case "focus"
		'增加网站焦点图设置功能
		conn.execute("alter table [WO_Menus] add [ImgURL] MEMO;")
		conn.execute("CREATE INDEX [PrimaryKey] ON [WO_Menus]([MenuID]) WITH PRIMARY;")
		response.Write("<span style=""color:#0000a0"">增加网站焦点图功能完成</span><br><br>")
		response.Write("<a href='upgrade.asp'>>>返回<<</a></div>")
	case "del"
		DeleteFiles(Server.MapPath("upgrade.asp"))
		response.Write("<a href='default.asp'>>>安装完成... 自动删除安装文件. 返回主页<<</a></div>")
	case else

end select
function UpdateSQL(SQLString)
 On Error Resume Next
  Conn.execute SQLString
 if err then 
   response.write "<span style=""color:#004000""><b></b> "&err.description&"</span><br/>"
  else
   response.write "<span style=""color:#0000a0""><b>执行:</b> "&SQLString&"</span><br/>"
 end if
end function

Function DeleteFiles(fileName)
	  dim upl
 	  set upl=Server.CreateObject("Scripting.FileSystemObject")
      IF upl.FileExists(fileName) Then
      	upl.DeleteFile fileName,True
      	DeleteFiles = True
      Else
      	DeleteFiles = false
      End IF
    End Function
%>
</div>