Xml_Restor.asp
上传用户:saigedz
上传日期:2019-10-14
资源大小:997k
文件大小:16k
源码类别:

中间件编程

开发平台:

HTML/CSS

  1. <%@ CODEPAGE=65001 %>
  2. <%
  3. '///////////////////////////////////////////////////////////////////////////////
  4. '// 插件应用:    1.8 Pre Terminator 及以上版本, 其它版本的Z-blog未知
  5. '// 插件制作:    haphic(http://haphic.com/)
  6. '// 备    注:    主题管理插件
  7. '// 最后修改:   2008-6-28
  8. '// 最后版本:    1.2
  9. '///////////////////////////////////////////////////////////////////////////////
  10. %>
  11. <% Option Explicit %>
  12. <% On Error Resume Next %>
  13. <% Response.Charset="UTF-8" %>
  14. <% Response.Buffer=True %>
  15. <% Server.ScriptTimeout=99999999 %>
  16. <!-- #include file="../../c_option.asp" -->
  17. <!-- #include file="../../function/c_function.asp" -->
  18. <!-- #include file="../../function/c_system_lib.asp" -->
  19. <!-- #include file="../../function/c_system_base.asp" -->
  20. <!-- #include file="../../function/c_system_plugin.asp" -->
  21. <!-- #include file="c_sapper.asp" -->
  22. <!-- #include file="../p_config.asp" -->
  23. <%
  24. Call System_Initialize()
  25. '检查非法链接
  26. Call CheckReference("")
  27. '检查权限
  28. If BlogUser.Level>1 Then Call ShowError(6)
  29. If CheckPluginState("ThemeSapper")=False Then Call ShowError(48)
  30. BlogTitle = "从本地导入主题"
  31. %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  32. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=ZC_BLOG_LANGUAGE%>" lang="<%=ZC_BLOG_LANGUAGE%>">
  33. <head>
  34. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  35. <meta http-equiv="Content-Language" content="<%=ZC_BLOG_LANGUAGE%>" />
  36. <meta name="robots" content="noindex,nofollow"/>
  37. <link rel="stylesheet" rev="stylesheet" href="../../CSS/admin.css" type="text/css" media="screen" />
  38. <link rel="stylesheet" rev="stylesheet" href="images/style.css" type="text/css" media="screen" />
  39. <title><%=BlogTitle%></title>
  40. </head>
  41. <body>
  42. <div id="divMain">
  43. <div class="Header">Theme Sapper - 管理保存在主机上的 ZTI 文件. <a href="help.asp#restorzti" title="如何管理主机上的 ZTI 文件">[页面帮助]</a></div>
  44. <%Call SapperMenu("4")%>
  45. <div id="divMain2">
  46. <%
  47. '*********************************************************
  48. %>
  49. <!--以下是显示页面-->
  50. <%
  51. Action=Request.QueryString("act")
  52. SelectedTheme=Request.QueryString("theme")
  53. SelectedThemeName=Request.QueryString("themename")
  54. If SelectedThemeName = "" Then SelectedThemeName = SelectedTheme
  55. If Action="" Then
  56. Call GetBlogHint()
  57. Response.Write "<div>"
  58. Response.Write "<p id=""loading"">正在载入中, 请稍候... 如果长时间停止响应, 请 <a href=""javascript:window.location.reload();"" title=""点此重试"">[点此重试]</a></p>"
  59. Response.Flush
  60. Response.Write "<table border=""1"" width=""100%"" cellspacing=""1"" cellpadding=""1"" class=""ztiMng"">"
  61. Dim FileList,l,c
  62. FileList=LoadIncludeFiles("PLUGIN/ThemeSapper/Export/")
  63. For Each l In FileList
  64. c=c & l
  65. Next
  66. If (InStr(LCase(c),".xml")>0) Or (InStr(LCase(c),".zti")>0) Then
  67. Response.Write "<tr><td colspan=5 width='100%'>下面列出了您主机上的保存的 ZTI 主题安装包文件, 您可以下载, 删除这些 ZTI 文件, 或从这些 ZTI 文件恢复主题.</td></tr>"
  68. Else
  69. Response.Write "<tr><td colspan=5 width='100%'>对不起, 您的主机上没有保存任何 ZTI 文件! (即 TS 插件中的 Export 目录为空!)</td></tr>"
  70. End If
  71. Dim objXmlFile,strXmlFile
  72. Dim fso, f, f1, fc, s
  73. Set fso = CreateObject("Scripting.FileSystemObject")
  74. Set f = fso.GetFolder(BlogPath & "PLUGIN/ThemeSapper/Export/")
  75. Set fc = f.Files
  76. For Each f1 in fc
  77. If GetFileExt(f1.name)="zti" Or GetFileExt(f1.name)="xml" Then
  78. Response.Write "<tr>"
  79. strXmlFile =BlogPath & "PLUGIN/ThemeSapper/Export/" & f1.name
  80. Set objXmlFile=Server.CreateObject("Microsoft.XMLDOM")
  81. objXmlFile.async = False
  82. objXmlFile.ValidateOnParse=False
  83. objXmlFile.load(strXmlFile)
  84. If objXmlFile.readyState=4 Then
  85. If objXmlFile.parseError.errorCode <> 0 Then
  86. Else
  87. ThemeAuthor_Name=objXmlFile.documentElement.selectSingleNode("author/name").text
  88. ThemeAuthor_Url=objXmlFile.documentElement.selectSingleNode("author/url").text
  89. ThemeAuthor_Email=objXmlFile.documentElement.selectSingleNode("author/email").text
  90. ThemeID=objXmlFile.documentElement.selectSingleNode("id").text
  91. ThemeName=objXmlFile.documentElement.selectSingleNode("name").text
  92. ThemeUrl=objXmlFile.documentElement.selectSingleNode("url").text
  93. ThemeNote=objXmlFile.documentElement.selectSingleNode("note").text
  94. ThemePubDate=objXmlFile.documentElement.selectSingleNode("pubdate").text
  95. ThemeModified=objXmlFile.documentElement.selectSingleNode("modified").text
  96. ThemeNote=TransferHTML(ThemeNote,"[nohtml]")
  97. If Len(ThemeNote)>42 then ThemeNote=Left(ThemeNote,42-3) & "..."
  98. End If
  99. End If
  100. Set objXmlFile=Nothing
  101. Response.Write "<td>"& f1.name & "</td>"
  102. Response.Write "<td align='center'><span class=""rsticon""><a href=""Xml_Restor.asp?act=Restore&amp;id="& Server.URLEncode(ThemeID) &"&amp;theme=" & Server.URLEncode(f1.name) & "&amp;themename=" & Server.URLEncode(ThemeName) & """ title=""从此 ZTI 文件恢复主题到 Blog"">←</a></span></td>"
  103. If InStr(UCase(Request.ServerVariables("HTTP_USER_AGENT")),UCase("Opera"))>0 Then '如果是Opera浏览器
  104. Response.Write "<td align='center'><span class=""dowicon""><a href=""Export/"& f1.name & """ title=""右键另存为下载此 ZTI 文件"">↓</a></span></td>"
  105. Else
  106. Response.Write "<td align='center'><span class=""dowicon""><a href=""Xml_Download.asp?theme="& Server.URLEncode(f1.name) &""" title=""左键点击下载此 ZTI 文件"">↓</a></span></td>"
  107. End If
  108. Response.Write "<td align='center'><span class=""delicon""><a href=""Xml_Restor.asp?act=del&amp;theme=" & Server.URLEncode(f1.name) & "&amp;themename=" & Server.URLEncode(ThemeName) & """ onclick=""return window.confirm('确定删除含有 "& ThemeName &" 的主题数据包 "& f1.name &"?');"" title=""删除此 ZTI 文件"">×</a></span></td><td>"
  109. 'Response.Write "<span>ID:" & ThemeID & "</span> | "
  110. If ThemeUrl=Empty Then
  111. Response.Write "<span>" & ThemeName & "</span> "
  112. Else
  113. Response.Write "<span><a href=""" & ThemeUrl & """ target=""_blank"">" & ThemeName & "</a></span> "
  114. End If
  115. If ThemeAuthor_Url=Empty Then
  116. Response.Write "<span>by " & ThemeAuthor_Name & "</span> "
  117. Else
  118. Response.Write "<span>by " & ThemeAuthor_Name & "</span> "
  119. End If
  120. Response.Write "<span>on " & ThemeModified & "</span>"
  121. Response.Write "<span> | " & ThemeNote & "</span>"
  122. Response.Write "</td>"
  123. End If
  124. Response.Write "</tr>"
  125. Next
  126. Set fso = nothing
  127. Err.Clear
  128. Response.Write "</table>"
  129. Response.Write "<p><form id=""edit"" name=""edit"" method=""get"" action=""#"">"
  130. Response.Write "<p><input onclick=""self.location.href='ThemeList.asp';"" type=""button"" class=""button"" value=""返回主题管理"" title=""返回主题管理页"" /> <input onclick=""window.scrollTo(0,0);"" type=""button"" class=""button"" value=""TOP"" title=""返回页面顶部"" /></p>"
  131. Response.Write "</form></p>"
  132. Response.Write "<script language=""JavaScript"" type=""text/javascript"">try{document.getElementById('loading').style.display = 'none';}catch(e){};</script>"
  133. Response.Write "</div>"
  134. End If
  135. Dim Install_Error
  136. Install_Error=0
  137. Dim Install_Pack,Install_Path
  138. Install_Pack = BlogPath & "THEMES/Install.zti"
  139. Install_Path = BlogPath & "THEMES/"
  140. '从主机删除
  141. If Action="del" Then
  142. Dim DelError
  143. DelError = 0
  144. If SelectedTheme<>"" Then
  145. Response.Write "<p class=""status-box"">正在处理您的请求...</p>"
  146. Response.Flush
  147. Response.Write "<p>"
  148. DelError = DelError + DeleteFile(BlogPath & "/PLUGIN/ThemeSapper/Export/"& SelectedTheme)
  149. Response.Write "</p>"
  150. Else
  151. Response.Write "<p class=""status-box notice"">请求的参数错误, 正在退出...</p>"
  152. Response.Flush
  153. DelError = 13
  154. End If
  155. If DelError = 0 Then
  156. Response.Write "<p><font color=""green""> √ 主题安装包 - " & SelectedThemeName & "  删除成功!</font><p>"
  157. Else
  158. Response.Write "<p><font color=""red""> × 主题安装包 - " & SelectedThemeName & "  删除失败! 请手动删除之.</font><p>"
  159. End If
  160. Response.Write "<p class=""status-box""> 如果您的浏览器没能自动跳转, 请 <a href=""Xml_Restor.asp"">[点击这里]</a>.</p>"
  161. Response.Write "<script>setTimeout(""self.location.href='Xml_Restor.asp'"",1500);</script>"
  162. End If
  163. '从主机恢复
  164. If Action="Restore" Then
  165. Call Check_Install()
  166. Response.Write "<p id=""loading"">正在恢复主题, 请稍候... 如果长时间停止响应, 请 <a href=""javascript:window.location.reload();"" title=""点此重试"">[点此重试]</a></p>"
  167. Response.Flush
  168. Response.Write "<p class=""status-box"">正在复制 ZTI 主题安装包文件 "& SelectedThemeName &"...<p>"
  169. Response.Flush
  170. Install_Error=Install_Error + CopyFile(BlogPath & "/PLUGIN/ThemeSapper/Export/"& SelectedTheme,Install_Pack)
  171. Response.Flush
  172. Call Install_Theme()
  173. Response.Write "<script language=""JavaScript"" type=""text/javascript"">try{document.getElementById('loading').style.display = 'none';}catch(e){};</script>"
  174. End If
  175. '*********************************************************
  176. Sub Check_Install()
  177. On Error Resume Next
  178. Dim Confirm,Restor_ID,Alert
  179. Confirm=Request.QueryString("confirm")
  180. Restor_ID=Request.QueryString("id")
  181. Alert=False
  182. If Confirm<>"yes" Then
  183. Response.Write "<p id=""loading"">正在校验主题, 请稍候... 如果长时间停止响应, 请 <a href=""javascript:window.location.reload();"" title=""点此重试"">[点此重试]</a></p>"
  184. Response.Flush
  185. Set objXmlVerChk=New ThemeSapper_CheckVersionViaXML
  186. objXmlVerChk.XmlDataWeb=(LoadFromFile(BlogPath & "/PLUGIN/ThemeSapper/Export/" & SelectedTheme,"utf-8"))
  187. objXmlVerChk.XmlDataLocal=(LoadFromFile(BlogPath & "/THEMES/"& Restor_ID &"/Theme.xml","utf-8"))
  188. If LCase(objXmlVerChk.Item_ID_Web)=LCase(objXmlVerChk.Item_ID_Local) Then
  189. Response.Write "<p class=""status-box"">您已安装了这个主题 <b>("& objXmlVerChk.Item_Name_Local &")</b>, 是否用 ZTI 文件里的主题 <b>("& objXmlVerChk.Item_Name_Web &")</b> <b>完全覆盖</b>已安装的主题?<br/><br/>"
  190. Response.Write "您当前主题版本为: <b>"& objXmlVerChk.Item_Version_Local &"</b>. 发布日期为: <b>"& objXmlVerChk.Item_PubDate_Local &"</b>. 最后修改日期为: <b>"& objXmlVerChk.Item_Modified_Local &"</b>.<br/>"
  191. Response.Write "将要覆盖的版本为: <b>"& objXmlVerChk.Item_Version_Web &"</b>. 发布日期为: <b>"& objXmlVerChk.Item_PubDate_Web &"</b>. 最后修改日期为: <b>"& objXmlVerChk.Item_Modified_Web &"</b><br/><br/>"
  192. If objXmlVerChk.Item_Url_Web<>Empty Then
  193. Response.Write "<a href="""& objXmlVerChk.Item_Url_Web &""" target=""_blank"" title=""查看主题的发布页面"">点此查看主题的发布信息!</a><br/><br/>"
  194. End If
  195. Response.Write objXmlVerChk.OutputResults & "<br/><br/>"
  196. Response.Write "<a href=""Xml_Restor.asp?confirm=yes&amp;act=Restore&amp;theme=" & Server.URLEncode(SelectedTheme) & "&amp;themename=" & Server.URLEncode(SelectedThemeName) & """ title=""确认安装"">[确认覆盖]</a> 或 <a href=""javascript:history.back(1);"" title=""返回上一页面"">[取消]</a><p>"
  197. Alert=True
  198. End If
  199. Response.Write "<script language=""JavaScript"" type=""text/javascript"">try{document.getElementById('loading').style.display = 'none';}catch(e){};</script>"
  200. Set objXmlVerChk=Nothing
  201. If Alert=True Then Response.End
  202. End If
  203. End Sub
  204. Sub Install_Theme()
  205. On Error Resume Next
  206. Response.Write "<p class=""status-box"">ZTI 文件 ""THEMES/Install.zti"" 正在解包安装...<p>"
  207. Response.Flush
  208. Dim objXmlFile
  209. Dim objNodeList
  210. Dim objFSO
  211. Dim objStream
  212. Dim i,j
  213. Set objXmlFile = Server.CreateObject("Microsoft.XMLDOM")
  214. objXmlFile.async = False
  215. objXmlFile.ValidateOnParse=False
  216. objXmlFile.load(Install_Pack)
  217. If objXmlFile.readyState<>4 Then
  218. Response.Write "<p><font color=""red""> × ZTI 文件未准备就绪, 无法解包.</font></p>"
  219. Install_Error=Install_Error+1
  220. Else
  221. If objXmlFile.parseError.errorCode <> 0 Then
  222. Response.Write "<p><font color=""red""> × ZTI 文件有错误, 无法解包.</font></p>"
  223. Install_Error=Install_Error+1
  224. Else
  225. Dim Pack_ver,Pack_Type,Pack_For,Pack_ID,Pack_Name
  226. Pack_Ver = objXmlFile.documentElement.SelectSingleNode("//root").getAttributeNode("version").value
  227. Pack_Type = objXmlFile.documentElement.selectSingleNode("//root").getAttributeNode("type").value
  228. Pack_For = objXmlFile.documentElement.selectSingleNode("//root").getAttributeNode("for").value
  229. Pack_ID = objXmlFile.documentElement.selectSingleNode("id").text
  230. Pack_Name = objXmlFile.documentElement.selectSingleNode("name").text
  231. If (CDbl(Pack_Ver) > CDbl(XML_Pack_Ver)) Then
  232. Response.Write "<p><font color=""red""> × ZTI 文件的 XML 版本为 "& Pack_Ver &", 而你的解包器版本为 "& XML_Pack_Ver &", 请升级您的 ThemeSapper, 安装被中止.</font></p>"
  233. Install_Error=Install_Error+1
  234. ElseIf (LCase(Pack_Type) <> LCase(XML_Pack_Type)) Then
  235. Response.Write "<p><font color=""red""> × 不是 ZTI 文件, 而可能是 "& Pack_Type &", 安装被中止.</font></p>"
  236. Install_Error=Install_Error+1
  237. ElseIf (LCase(Pack_For) <> LCase(XML_Pack_Version)) Then
  238. Response.Write "<p><font color=""red""> × ZTI 文件版本不符合, 该版本可能是 "& Pack_For &", 安装被中止.</font></p>"
  239. Install_Error=Install_Error+1
  240. Else
  241. Response.Write "<blockquote><font color=""Teal"">"
  242. Set objNodeList = objXmlFile.documentElement.selectNodes("//folder/path")
  243. Set objFSO = CreateObject("Scripting.FileSystemObject")
  244. j=objNodeList.length-1
  245. For i=0 To j
  246. If objFSO.FolderExists(Install_Path & objNodeList(i).text)=False Then
  247. objFSO.CreateFolder(Install_Path & objNodeList(i).text)
  248. End If
  249. Response.Write "创建目录" & objNodeList(i).text & "<br/>"
  250. Response.Flush
  251. Next
  252. Set objFSO = Nothing
  253. Set objNodeList = Nothing
  254. Set objNodeList = objXmlFile.documentElement.selectNodes("//file/path")
  255. j=objNodeList.length-1
  256. For i=0 To j
  257. Set objStream = CreateObject("ADODB.Stream")
  258. With objStream
  259. .Type = 1
  260. .Open
  261. .Write objNodeList(i).nextSibling.nodeTypedvalue
  262. .SaveToFile Install_Path & objNodeList(i).text,2
  263. Response.Write "释放文件" & objNodeList(i).text & "<br/>"
  264. Response.Flush
  265. .Close
  266. End With
  267. Set objStream = Nothing
  268. Next
  269. Set objNodeList = Nothing
  270. Response.Write "</font></blockquote>"
  271. End If
  272. End If
  273. End If
  274. Set objXmlFile = Nothing
  275. If Err.Number<>0 Then Install_Error=Install_Error+1
  276. Err.Clear
  277. Response.Write "<p>"
  278. Install_Error = Install_Error + DeleteFile(BlogPath & "THEMES/" & "Install.zti")
  279. Response.Write "</p>"
  280. If Install_Error = 0 Then 
  281. Response.Write "<p>"
  282. Install_Error = Install_Error + DeleteFile(BlogPath & "THEMES/" & Pack_ID & "/verchk.xml")
  283. Response.Write "</p>"
  284. End If
  285. Response.Flush
  286. If Install_Error = 0 Then
  287. Response.Write "<p class=""status-box""> √ 主题恢复完成. 如果您的浏览器没能自动跳转, 请 <a href=""ThemeDetail.asp?theme=" & Server.URLEncode(Pack_ID) & "&amp;themename=" & Server.URLEncode(Pack_Name) & """>[点击这里]</a>.</p>"
  288. Response.Write "<script>setTimeout(""self.location.href='ThemeDetail.asp?theme=" & Server.URLEncode(Pack_ID) & "&themename=" & Server.URLEncode(Pack_Name) & "'"",3000);</script>"
  289. Else
  290. Response.Write "<p class=""status-box""><font color=""red""> × 主题恢复失败. "
  291. Response.Write "请 <a href=""javascript:window.location.reload();"" title=""刷新此页""><span>[点此重试]</span></a> 或 <a href=""Xml_Restor.asp"" title=""重新上传""><span>[重新上传]</span></a></font></p>"
  292. End If
  293. End Sub
  294. '*********************************************************
  295. %>
  296. </div>
  297. <script>
  298. //斑马线
  299. var tables=document.getElementsByTagName("table");
  300. var b=false;
  301. for (var j = 0; j < tables.length; j++){
  302. var cells = tables[j].getElementsByTagName("tr");
  303. cells[0].className="color1";
  304. for (var i = 1; i < cells.length; i++){
  305. if(b){
  306. cells[i].className="color2";
  307. b=false;
  308. }
  309. else{
  310. cells[i].className="color3";
  311. b=true;
  312. };
  313. };
  314. }
  315. </script>
  316. </body>
  317. </html>
  318. <%
  319. Call System_Terminate()
  320. If Err.Number<>0 then
  321.   Call ShowError(0)
  322. End If
  323. %>