<%@language=vbscript codepage=936 %>
<%
'********************************************************
'章采集系统


%>
<%
option explicit
response.buffer=true	
%>
<!--#include file="../include/Conn.jsp"-->
<!--#include file="admin_islogin.jsp"-->
<!--#include file="../Article/inc/function.jsp"-->
<%
dim Action,RsItem,SqlItem,ItemID,FoundErr,ErrMsg
Action=trim(request("Action"))
Dim ObjInstalled
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")
If Action="" Then
   Call Main
Else
   Call Updata
End If

call closeconn()
call closeconnitem()
%>      
<%Sub Main%>
<html>
<head>
<title>数据采集系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Images/Style.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<br>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
  <tr>
	<td colspan="2" align="center" class="topbg" height=22><b>采集系统For 4.03-1.0 To 1.01 数据库升级程序</b></td>
	</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
<form method="post" action="Admin_ItemUpdata1.01.jsp?Action=UpData">
   <tr class="tdbg">
      <td align="center" valign="middle" height="100">
        <br>
	数据库位置：
	<input name="LeadInMdb" type="text" id="LeadInMdb" size="23" value="Database/2009life.mdb">
      </td>
   </tr>
   <tr class="tdbg">
      <td align="center">
        <input name="submit" type=submit value=" 下&nbsp;一&nbsp;步 " style="cursor: hand;background-color: #cccccc;">
      </td>
   </tr>
</form>
</table>

</body>
</html>
<%End Sub%>

<%
Sub UpData()
   Dim LeadInMdb,ItemMdb,ItemMdbPath
   ItemMdb=DbItem
   LeadInMdb=trim(request.form("LeadInMdb"))
   If LeadInMdb="" Then
      FoundErr=True
      ErrMsg="<br><li>数据库地址不能为空！</li>"
   End If
   If FoundErr<>True Then  
      dim connstrLead,connLead,RsLead,SqlLead,RsF,SqlF,ItemIDTemp
      Set connLead = Server.CreateObject("ADODB.Connection")
      connstrLead="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(LeadInMdb)
      connLead.Open connstrLead
      If Err Then
         err.Clear
         ConnLead.Close
	 Set ConnLead = Nothing
         FoundErr=True
	 ErrMsg= ErrMsg & "<br><li>数据库连接出错，请确认数据库是否存在。</li>"
      End If
      If FoundErr<>True Then
         Set RsLead=server.createobject("adodb.recordset")         
         SqlLead="select * from Item order by ItemID ASC"         
         RsLead.open SqlLead,ConnLead,1,1
         If Not RsLead.Eof then
            Do While Not RsLead.Eof
               '升级项目信息
               Set RsItem=server.createobject("adodb.recordset")         
               SqlItem="select top 1 * from Item"
               RsItem.open SqlItem,ConnItem,1,3
               RsItem.AddNew
               RsItem("ItemName")=RsLead("ItemName")
               RsItem("ChannelID")=RsLead("ChannelID")
               RsItem("ChannelDir")=RsLead("ChannelDir")
               RsItem("ClassID")=RsLead("ClassID")
               RsItem("SpecialID")=RsLead("SpecialID")
               RsItem("WebName")=RsLead("WebName")
               RsItem("WebUrl")=RsLead("WebUrl")
               RsItem("ItemDemo")=RsLead("ItemDemo")
               RsItem("LoginType")=RsLead("LoginType")
               RsItem("LoginUrl")=RsLead("LoginUrl")
               RsItem("LoginPostUrl")=RsLead("LoginPostUrl")
               RsItem("LoginUser")=RsLead("LoginUser")
               RsItem("LoginPass")=RsLead("LoginPass")
               RsItem("LoginFalse")=RsLead("LoginFalse")
               RsItem("ListStr")=RsLead("ListStr")
               RsItem("LsString")=RsLead("LsString")
               RsItem("LoString")=RsLead("LoString")
               RsItem("ListPaingType")=RsLead("ListPaingType")
               RsItem("LPsString")=RsLead("LPsString")
               RsItem("LPoString")=RsLead("LPoString")
               RsItem("ListPaingStr1")=RsLead("ListPaingStr1")
               RsItem("ListPaingStr2")=RsLead("ListPaingStr2")
               RsItem("ListPaingID1")=RsLead("ListPaingID1")
               RsItem("ListPaingID2")=RsLead("ListPaingID2")
               RsItem("ListPaingStr3")=RsLead("ListPaingStr3")
               RsItem("HsString")=RsLead("HsString")
               RsItem("HoString")=RsLead("HoString")
               RsItem("HttpUrlType")=RsLead("HttpUrlType")
               RsItem("HttpUrlStr")=RsLead("HttpUrlStr")
               RsItem("TsString")=RsLead("TsString")
               RsItem("ToString")=RsLead("ToString")
               RsItem("CsString")=RsLead("CsString")
               RsItem("CoString")=RsLead("CoString")
               RsItem("DateType")=RsLead("DateType")
               RsItem("DsString")=RsLead("DsString")
               RsItem("DoString")=RsLead("DoString")
               RsItem("AuthorType")=RsLead("AuthorType")
               RsItem("AsString")=RsLead("AsString")
               RsItem("AoString")=RsLead("AoString")
               RsItem("AuthorStr")=RsLead("AuthorStr")
               RsItem("CopyFromType")=RsLead("CopyFromType")
               RsItem("FsString")=RsLead("FsString")
               RsItem("FoString")=RsLead("FoString")
               RsItem("CopyFromStr")=RsLead("CopyFromStr")
               RsItem("KeyType")=RsLead("KeyType")
               RsItem("KsString")=RsLead("KsString")
               RsItem("KoString")=RsLead("KoString")
               RsItem("KeyStr")=RsLead("KeyStr")
               RsItem("NewsPaingType")=RsLead("NewsPaingType")
               RsItem("NPsString")=RsLead("NPsString")
               RsItem("NPoString")=RsLead("NPoString")
               RsItem("NewsPaingStr")=RsLead("NewsPaingStr")
               RsItem("NewsPaingHtml")=RsLead("NewsPaingHtml")
               RsItem("PaginationType")=RsLead("PaginationType")
               RsItem("MaxCharPerPage")=RsLead("MaxCharPerPage")
               RsItem("ReadLevel")=RsLead("ReadLevel")
               RsItem("Stars")=RsLead("Stars")
               RsItem("ReadPoint")=RsLead("ReadPoint")
               RsItem("Hits")=RsLead("Hits")
               RsItem("UpDateType")=RsLead("UpDateType")
               RsItem("UpDateTime")=RsLead("UpDateTime")
               RsItem("IncludePicYn")=RsLead("IncludePicYn")
               RsItem("DefaultPicYn")=RsLead("DefaultPicYn")
               RsItem("OnTop")=RsLead("OnTop")
               RsItem("Elite")=RsLead("Elite")
               RsItem("Hot")=RsLead("Hot")
               RsItem("SkinID")=RsLead("SkinID")
               RsItem("TemplateID")=RsLead("TemplateID")
               RsItem("Script_Iframe")=RsLead("Script_Iframe")
               RsItem("Script_Object")=RsLead("Script_Object")
               RsItem("Script_Script")=RsLead("Script_Script")
               RsItem("Script_Div")=RsLead("Script_Div")
               RsItem("Script_Class")=RsLead("Script_Class")
               RsItem("Script_Span")=RsLead("Script_Span")
               RsItem("Script_Img")=RsLead("Script_Img")
               RsItem("Script_Font")=RsLead("Script_Font")
               RsItem("Script_A")=RsLead("Script_A")
               RsItem("Script_Html")=RsLead("Script_Html")
               RsItem("CollecListNum")=RsLead("CollecListNum")
               RsItem("CollecNewsNum")=RsLead("CollecNewsNum")
               RsItem("Passed")=RsLead("Passed")
               If ObjInstalled=True Then
                  RsItem("SaveFiles")=RsLead("SaveFiles")
               Else
                  RsItem("SaveFiles")=False
               End If
               RsItem("CollecOrder")=RsLead("CollecOrder")
               RsItem("LinkUrlYn")=RsLead("LinkUrlYn")
               RsItem("InputerType")=RsLead("InputerType")
               RsItem("Inputer")=RsLead("Inputer")
               RsItem("EditorType")=RsLead("EditorType")
               RsItem("Editor")=RsLead("Editor")
               RsItem("ShowCommentLink")=RsLead("ShowCommentLink")
               RsItem("Flag")=RsLead("Flag")
               ItemIDTemp=RsItem("ItemID")
               RsItem.Update
               RsItem.close
               set rsItem=nothing

               '升级过滤信息
               Set RsF=server.createobject("adodb.recordset")         
               SqlF="select * from Filters Where ItemID=" & RsLead("ItemID") & " order by FilterID ASC"         
               RsF.open SqlF,ConnLead,1,1              
               If Not RsF.Eof then
                  Do While Not RsF.Eof
                     Set RsItem=server.createobject("adodb.recordset")         
                     SqlItem="select top 1 * from Filters"         
                     RsItem.open SqlItem,ConnItem,1,3
                     RsItem.AddNew
                     RsItem("ItemID")=ItemIDTemp
                     RsItem("FilterName")=RsF("FilterName")
                     RsItem("FilterObject")=RsF("FilterObject")
                     RsItem("FilterType")=RsF("FilterType")
                     RsItem("FilterContent")=RsF("FilterContent")
                     RsItem("FisString")=RsF("FisString")
                     RsItem("FioString")=RsF("FioString")
                     RsItem("FilterRep")=RsF("FilterRep")
                     RsItem("Flag")=RsF("Flag")
                     RsItem("PublicTf")=False
                     RsItem.Update
                     RsItem.Close
                     Set RsItem=Nothing
                  RsF.MoveNext
                  Loop
               End If
               RsF.Close
               Set RsF=Nothing

               '升级历史记录
               Set RsH=server.createobject("adodb.recordset")         
               SqlH="select * from Histroly Where ItemID=" & RsLead("ItemID") & " order by HistrolyID ASC"         
               RsH.open SqlH,ConnLead,1,1              
               If Not RsH.Eof then
                  Do While Not RsH.Eof
                     Set RsItem=server.createobject("adodb.recordset")         
                     SqlItem="select Top 1 * from Histroly"         
                     RsItem.open SqlItem,ConnItem,1,3
                     RsItem.AddNew
                     RsItem("ItemID")=ItemIDTemp
                     RsItem("ChannelID")=RsH("ChannelID")
                     RsItem("ClassID")=RsH("ClassID")
                     RsItem("SpecialID")=RsH("SpecialID")
                     RsItem("ArticleID")=RsH("ArticleID")
                     RsItem("Title")=RsH("Title")
                     RsItem("CollecDate")=RsH("NewsCollecDate")
                     RsItem("NewsUrl")=RsH("NewsUrl")
                     RsItem("Result")=RsH("Result")
                     RsItem.Update
                     RsItem.Close
                     Set RsItem=Nothing
                  RsH.MoveNext
                  Loop
               End If
               RsH.Close
               Set RsH=Nothing
            RsLead.MoveNext
            Loop
         Else
            FoundErr=True
            ErrMsg=ErrMsg & "<br>无任何记录！"
         End If
         RsLead.Close
         Set RsLead=Nothing
      End If
      connlead.close
      set connlead=nothing
   End If
   If FoundErr<>True Then
      ErrMsg="<br>数据库升级成功"
      ErrMsg=ErrMsg & "<br>请及时删除 Admin_ItemUpdata1.01.jsp文件，防止被别人利用。"
      Call WriteSucced(ErrMsg)
   Else
      Call WriteErrMsg(ErrMsg)
   End If
End Sub
%>
