<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="Version.asp"-->

<% 
 '===========================================================================================
	'软件名称：126 cms 视频影视管理系统
	'程序版权：126电影               '咨询QQ：479025
	'开发作者：magicblack(479025)    '官方网站：http://www.126oo.com/
	'Copyright (C) 2009 - ... 126oo.com  All Rights Reserved.
	'郑重声明:
	'    1、免费版本请在程序首页保留版权信息，并做上本站LOGO友情连接,商业版本无此要求;
	'    2、任何个人或组织不得以盈利为目的发布,修改,本软件及其他副本上一切关于版权的信息；
	'    3、126电影保留此软件的法律追究权利；
'==========================================================================================
%>

<%
response.Charset="GBK"
dim action,updateserver
updateserver = "http://update.126oo.com/cms3/"
action = SafeData("RQ","action",0)

select case action

case "checkversion"
	call checkversion
case "updatefile"
	call updatefile
case "showupdatefilelist"
	call showupdatefilelist
case "showupdatefile"
	call showupdatefile
end select


sub checkversion
	dim verStr,checkversion,verarray1,vardec,randnum,serverversion
	On Error Resume Next
	randnum = getrnd()
	
	verStr = GetPage(updateserver& "index.asp?action=checkversion&rnd="&randnum,"gbk")

	verarray1 = split(verStr,"||")
	vardec = verarray1(0)
	serverversion = verarray1(1)
    
	checkversion = (version <> serverversion)
    
    'response.write verStr & "<br>"
  
	if Err.number <> 0 then
		writeend "False"
	else
		if checkversion then writeend vardec else writeend checkversion
	end if
end sub

sub updatefile
	dim verStr,checkversion,verarray1,vardec,i
	dim savefilepath,sourcefilepath,fileStr,randnum
	randnum = getrnd()
	verStr = GetPage(updateserver& "?action=getfilelist&version="&version&"&rnd="&randnum,"gbk")
	if verStr <> "" then
		verarray1 = split(verStr,"||")
		for i=0 to ubound(verarray1)
			sourcefilepath = verarray1(i)
			
			if instr(sourcefilepath,".txt")>0 then
				savefilepath = replace(sourcefilepath,"txt","asp")
			else
				savefilepath = sourcefilepath
			end if
			
			savefilepath=replace(savefilepath,chr(10),"")
			savefilepath=replace(savefilepath,chr(13),"")
			savefilepath = "../"&savefilepath
			
			fileStr = GetPage(updateserver&sourcefilepath,"gbk")
			FSOOBJ.createhtml savefilepath,fileStr
			writeflush "更新成功:" & savefilepath
		next
	end if
end sub

sub showupdatefile
	dim verStr,checkversion,verarray1,vardec,i
	dim savefilepath,sourcefilepath,fileStr,randnum
	randnum = getrnd()
	
	writeflush "<TABLE width=""96%"" border=""0"" align=""center"" cellpadding=""5"" cellSpacing=""1"" class=""tbtitle"" style=""BACKGROUND: #cad9ea;""><TBODY><TR bgColor=""#f5fafe""><TD width=""4%"" align=""center"" >&nbsp;</TD><TD align=""center"">升级文件</TD><TD width=""15%"" align=""center"">升级状态</TD></TR>"
	
	verStr = GetPage(updateserver& "?action=getfilelist&version="&version&"&rnd="&randnum,"gbk")
	if verStr <> "" then
	
		verarray1 = split(verStr,"||")
		for i=0 to ubound(verarray1)
		
			writeflush "<TR bgcolor=""#FFFFFF"">"
			sourcefilepath = verarray1(i)
			
			if instr(sourcefilepath,".txt")>0 then
				savefilepath = replace(sourcefilepath,"txt","asp")
			else
				savefilepath = sourcefilepath
			end if
			
			writeflush "<TD>" & i+1 & "</TD>"
			writeflush "<TD>" & savefilepath & "</TD>"
			
			savefilepath=replace(savefilepath,chr(10),"")
			savefilepath=replace(savefilepath,chr(13),"")
			savefilepath = "../"&savefilepath
			
			fileStr = GetPage(updateserver&sourcefilepath,"gbk")
			if fileStr <> False then
				FSOOBJ.createhtml savefilepath,fileStr
				writeflush "<TD>更新成功</TD>"
			else
				writeflush "<TD>更新失败</TD>" 
			end if
			writeflush "</TR>"
		next
	end if
	
	writeflush "</TBODY></Table>"
end sub

sub showupdatefilelist
	dim verStr,checkversion,verarray1,vardec,i
	dim savefilepath,sourcefilepath,fileStr,randnum
	randnum = getrnd()
	
	writeflush "<TABLE width=""96%"" border=""0"" align=""center"" cellpadding=""5"" cellSpacing=""1"" class=""tbtitle"" style=""BACKGROUND: #cad9ea;""><form action=""?action=showupdatefile"" method=""post"" name=""updateform""><TBODY><TR bgColor=""#f5fafe""><TD width=""4%"" align=""center"" >&nbsp;</TD><TD align=""center"">升级文件</TD></TR>"
	
	if checkversion then
	verStr = GetPage(updateserver& "?action=getfilelist&version="&version&"&rnd="&randnum,"gbk")
	if verStr <> "" then
	
		verarray1 = split(verStr,"||")
		for i=0 to ubound(verarray1)
		
			writeflush "<TR bgcolor=""#FFFFFF"">"
			sourcefilepath = verarray1(i)
			
			if instr(sourcefilepath,".txt")>0 then
				savefilepath = replace(sourcefilepath,"txt","asp")
			else
				savefilepath = sourcefilepath
			end if
			writeflush "<TD>" & i+1 & "</TD>"
			writeflush "<TD>" & savefilepath & "</TD>"
			writeflush "</TR>"
		next
	end if
	writeflush "<TR bgcolor=""#FFFFFF""><TD colspan=""2"">升级前最好备份数据，以免升级失败造成不必要的麻烦！</TD></TR><TR bgcolor=""#FFFFFF""><TD colspan=""2""><INPUT class=inputbut type=submit value=确认升级 name=Submit></TD></TR>"
	else
	writeflush "<TR bgcolor=""#FFFFFF""><TD colspan=""2"">已经是最新版本，无需升级，请随时关注 cms.126oo.com 官方信息！</TD></TR>"
	end if
	writeflush "</TBODY></form></Table>"
end sub
%>