⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 importstyle.asp

📁 一个叫做雪人的论坛源码
💻 ASP
字号:
<%
if not session("sfadmin") then response.redirect("welcome.asp")
%>
<!--#INCLUDE FILE="../inc/db_inc.asp"-->
<!--#INCLUDE FILE="../inc/md5_inc.asp"-->
<!--#INCLUDE FILE="../inc/char_inc.asp"-->

<HTML>
<HEAD>
<TITLE>Untitled Document</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK rel="stylesheet" href="admin.css" type="text/css">
</HEAD>

<BODY bgcolor="#FFFFFF" text="#000000" leftmargin="10" topmargin="10">

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open StrConn
%>
<!--#INCLUDE FILE="checkadmin.asp"-->
<%

if request("step") = "2" then

	errstr = ""
	
	if request("insertmode") = "no" then
		if not IsNumeric(request("styleid")) then
			errstr = errstr & "<LI>模板名必须为数字<BR>"
			styleid = 0
		else
			styleid = clng(request("styleid"))
		end if
	end if
	if request("mdbfilename") = "" then errstr = errstr & "<LI>导入文件名不能为空<BR>"
	
	if errstr = "" then
		on error resume next
		err = 0
		Set mdbConn = Server.CreateObject("ADODB.Connection")
		mdbConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath(request("mdbfilename"))
		if err > 0 then errstr = "<LI>无法连接mdb数据库文件,可能是因为服务器不支持使用access数据库,或者您指定的access数据库文件不存在!<BR>"
	end if
	if errstr = "" then
		on error resume next
		err = 0
		Set rs = mdbConn.execute("select title, template from template")
		if err > 0 then errstr = "<LI>您指定的access数据库文件不存在, 或者它不是SF模板交换文件格式!<BR>"
	end if
	if errstr = "" then
		on error resume next
		err = 0
		if rs.bof or rs.eof then errstr = "<LI>您指定的SF模板交换文件不存在内容!<BR>"
		if err > 0 then errstr = "<LI>您指定的SF模板交换文件不存在内容!<BR>"
	end if
	if errstr = "" then
%>
<TABLE width="100%" border="0" cellspacing="1" cellpadding="4" align="center">
  <TR> 
    <TD bgcolor="#D1E3BF" align="center">开始从指定access数据库文件导入样式数据...</TD>
  </TR>
</TABLE>
<%
		if styleid = 0 then
			Conn.execute("insert into sf_style(title, path) values('title', 'path')")
			Set rs = Conn.execute("select styleid from sf_style order by styleid DESC")
			styleid = rs("styleid")
		end if
		Set rs = mdbConn.Execute("SELECT title, template FROM template")
		if not(rs.bof or rs.eof) then
			on error resume next
			err = 0
			do until rs.eof
				template = Replace(rs("template"), "'", "''")
				response.write "<LI>正在导入 - " & rs("title") & "...<BR>"
				Conn.execute("update sf_style set " & rs("title") & " = '" & template & "' where styleid = " & styleid)
				if err > 0 then
					response.write "<LI><font color=""red"">发生错误: 无法将数据导入SF数据库!</font><BR>"
					exit do
				end if
				rs.movenext
			loop
		end if

%>
<TABLE width="100%" border="0" cellspacing="1" cellpadding="4" align="center">
  <TR> 
    <TD bgcolor="#D1E3BF" align="center">模板导入完毕</TD>
  </TR>
</TABLE>
<%
	else
%>
<TABLE width="100%" border="0" cellspacing="1" cellpadding="4" align="center">
  <TR> 
    <TD bgcolor="#D1E3BF">错误:<BR><%= errstr %></TD>
  </TR>
</TABLE>
<%
	end if

else
%>
<FORM name="form1" method="post" action="importstyle.asp?step=2">
  <TABLE width="100%" border="0" cellspacing="1" cellpadding="4" align="center">
    <TR> 
      <TD bgcolor="#D1E3BF" align="center" colspan="2"><B>导入样式</B></TD>
    </TR>
    <TR>
      <TD width="40%">要导入的SF样式文件:</TD>
      <TD><INPUT type="text" name="mdbfilename" value="template.mdb" size="30">(此文件必须在当前目录下)</TD>
    </TR>
    <TR bgcolor="#F5F5F5"> 
<%
	strsql = "select styleid, title from sf_style where styleid > 1"
	Set rs = Conn.Execute(strsql)
	if not(rs.bof or rs.eof) then
		response.write "<TD><input type=""radio"" name=""insertmode"" value=""no"">覆盖已存在的自定义模板:</TD><TD><select name=""styleid"">"
		do until rs.eof
			response.write "<option value=""" & rs("styleid") & """>" & rs("title") & "</option>"
			rs.movenext
		loop
		response.write "</select>"
	else
		response.write "<TD></TD><TD><font color=""red"">当前无任何自定义模板</font>"
	end if
%>
      <br>(为了应付可能出现的意外情况,系统不允许覆盖SF原始模板)</TD>
    </TR>
    <TR>
      <TD colspan="2"><input type="radio" name="insertmode" value="yes" checked>新建一种模板样式并将模板数据导入进来</TD>
    </TR>
    <TR>
      <TD colspan="2" bgcolor="#DDDDDD" height="3"></TD>
    </TR>
    <TR>
      <TD colspan="2" align="center"><INPUT type="submit" name="submit" value=" 确定 "></TD>
    </TR>
  </TABLE>
</FORM>
<%
	
end if

%>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -