<!--#include file = "../inc/dbconn.asp"-->
<!--#include file = "CheckLogin.asp"-->
<!--#include file = "../inc/cache.asp"-->
<!--#include file = "../inc/function.asp"-->
<% LOADING_ADMIN_HEAD %>
<%
select case gqv("do")
	case "default":default
	case "list":list
    case "saveadd":saveadd
    case "saveedit":saveedit
    case "delete":delete
    case else call alertbox("没有指定任何操作!",2)
end select
' *** ***  www.654.cn  *** ***
sub default
	LINE "<form name=""form"" action=""?do=list"" method=""post"">"
	LINE "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1"" border=""0"">"
	LINE "<tr>"
	LINE "<td align=""center"" valign=""middle"">"
	LINE "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1""  class=""tbl"" id=tbl>"
	LINE "<tr>"
	LINE "<td align=""center"" height=""30"" colspan=""2"">模板管理</td>"
	LINE "</tr>"
	LINE "<tr>"
	LINE "<td bgcolor=""#ffffff"" width=""20%"" height=""30"" align=""left"" colspan=""2"">&nbsp;<font color=""red"">*</font>&nbsp;请正确填写模板存放的终极目录!例:""../templets/itmop/!例中的/<font color=""red"">itmop</font>/就是模板所在的终极目录!</td>"
	LINE "</tr>"
	LINE "<tr>"
	LINE "<td bgcolor=""#ffffff"" width=""20%"" height=""30"" align=""left"">&nbsp;<font color=""red"">*</font>&nbsp;模板目录路径:</td>"
	LINE "<td bgcolor=""#ffffff"" width=""80%"" height=""30"" align=""left""><input name=""path"" type=""text"" style=""width:300px;"" maxlength=""255"" value=""../templets/""></td>"
	LINE "</tr>"
	LINE "<tr>"
	LINE "<td bgcolor=""#ffffff"" align=""center"" height=""30"" colspan=""2"">"
	LINE "<input name=""submit1"" type=""button"" value=""提交路径"" onclick=""this.disabled=true;document.form.submit();"">&nbsp;"
	LINE "<input name=""submit2"" type=""reset"" value=""重新添写"">&nbsp;"
	LINE "<input name=""submit3"" type=""button"" value=""返回"" onclick=""window.history.back();"">"
	LINE "</td>"
	LINE "</tr>"
	LINE "</table>"
	LINE "</td>"
	LINE "</tr>"
	LINE "</table>"
	LINE "</form>"
end sub
' *** ***  www.654.cn  *** ***
sub list
	dim path:path = gfv("path")
	if path <> "" then
		if checkfolder(path) = true then
			LINE "" & showfolderlist(server.mappath("" & path & "")) & ""
			LINE "<form name=""form"" action=""?do=saveadd"" method=""post"">"
			LINE "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1"" border=""0"">"
			LINE "<tr>"
			LINE "<td align=""center"" valign=""middle"">"
			LINE "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1"" class=""tbl"" id=tbl>"
			LINE "<tr>"
			LINE "<td align=""center"" height=""30"" colspan=""3"">添加模板</td>"
			LINE "</tr>"
			LINE "<tr>"
			LINE "<td bgcolor=""#ffffff"" width=""15%"" height=""30"" align=""left"">&nbsp;<font color=""red"">*</font>&nbsp;模板路径:</td>"
			LINE "<td bgcolor=""#ffffff"" width=""85%"" height=""30"" align=""left"" valign=""top""><input name=""apath"" type=""text"" style=""width:300px;"" maxlength=""255"" value=""" & gfv("path") & """></td>"
			LINE "</tr>"
			LINE "<tr>"
			LINE "<td bgcolor=""#ffffff"" width=""15%"" height=""30"" align=""left"">&nbsp;<font color=""red"">*</font>&nbsp;编辑调整:</td>"
			LINE "<td bgcolor=""#ffffff"" width=""85%"" height=""30"" align=""left"" valign=""top""><span style=""cursor:hand"" onclick=""tdContent.style.height=1000;"">[加高]</span>&nbsp;<span style=""cursor:hand"" onclick=""tdContent.style.height=200;"">[默认]</span>&nbsp;<span style=""cursor:hand"" onclick=""tdContent.style.height=100;"">[减低]</span>&nbsp;<span style=""cursor:hand"" id=""ShowHiddenHtmlEdit"" onclick=""if(trContent.style.display==''){trContent.style.display='none';ShowHiddenHtmlEdit.innerHTML='[显示]'}else{trContent.style.display='';ShowHiddenHtmlEdit.innerHTML='[隐藏]'}"">[隐藏]</span></td>"
			LINE "</tr>"
			LINE "<tr id=""trContent"">"
			LINE "<td bgcolor=""#ffffff"" width=""15%"" align=""left"" valign=""top"">&nbsp;<font color=""red"">*</font>&nbsp;模板内容:</td>"
			LINE "<td bgcolor=""#ffffff"" width=""85%"" align=""left"" height=""200"" id=""tdContent"">"
			LINE "<textarea name=""content"" style=""width=100%;height=100%""></textarea>"
			LINE "</td>"
			LINE "</tr>"
			LINE "<tr>"
			LINE "<td bgcolor=""#ffffff"" align=""center"" height=""30"" colspan=""2"">"
			LINE "<input name=""submit1"" type=""submit"" value=""添加模板"" onclick=""this.disabled=true;document.form.submit();"">&nbsp;"
			LINE "<input name=""submit2"" type=""reset"" value=""重新添写"">&nbsp;"
			LINE "<input name=""submit3"" type=""button"" value=""返回"" onclick=""window.history.back();"">"
			LINE "</td>"
			LINE "</tr>"
			LINE "</table>"
			LINE "</td>"
			LINE "</tr>"
			LINE "</table>"
			LINE "</form>"
		else
			call alertbox("抱歉!模板目录路径错误!",2)
		end if
	else
		call alertbox("抱歉!模板目录路径必须填写!",2)
	end if
end sub
' *** ***  www.654.cn  *** ***
function showfolderlist(path)
	dim f1,f2,f,l,s,fc,content,i:i = 1
	set f1 = createobject("scripting.filesystemobject")
	set f2 = f1.getfolder(path)
	set l = f2.files
	for each f in l
		s = s & "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1"" border=""0"">"
		s = s & "<tr>"
		s = s & "<td align=""center"" valign=""middle"">"
		s = s & "<table align=""center"" width=""100%"" cellpadding=""2"" cellspacing=""1""  class=""tbl"" id=tbl>"
		s = s & "<form name=""eform" & i & """ action=""?do=saveedit"" method=""post"">"
		s = s & "<tr>"
		s = s & "<td  bgcolor=""#ffffff"" align=""left"" height=""*"">"
		s = s & "[文件名称]：" & f.name
		s = s & "<br>[文件大小]：" & f.size
		s = s & "<br>[文件类型]：" & f.type
		s = s & "<br>[详细路径]：" & f.path
		s = s & "<br>[创建时间]：" & f.datecreated
		s = s & "<br>[修改时间]：" & f.datelastmodified
		s = s & "<br>[文件内容]："
		s = s & "[<span style=""cursor:hand;"" onclick=""javascript:return document.all.box" & i & ".style.display='block'"">显示</span>]"
		s = s & "[<span style=""cursor:hand;"" onclick=""javascript:return document.all.box" & i & ".style.display='none'"">隐藏</span>]"
		s = s & "[<span style=""cursor:hand;"" onclick=""javascript:document.all.content" & i & ".select();document.execCommand('copy');alert('源代码复制成功!');"">复制</span>]<br>"
		set fc = createobject(G_654_STREAM)
		fc.open
		fc.type = 2
		fc.charset = "" & chrset & ""
		fc.loadfromfile(f.path)
		content = fc.readtext
		fc.close:set fc = nothing
		s = s & "<div id=""box" & i & """ style=""display:none;"">"
		s = s & "<input name=""i"" type=""hidden"" value=""" & i & """>"
		s = s & "<input name=""epath"" type=""hidden"" value=""" & f.path & """>"
		s = s & "<textarea id=""content" & i & """ name=""content" & i & """ style=""width:100%;height:300px;"">" & content & "</textarea><br>"
		s = s & "<input name=""submit1"" type=""button"" value=""保存模板"" onclick=""this.disabled=true;document.eform" & i & ".submit();"">&nbsp;"
		s = s & "<input name=""submit2"" type=""reset"" value=""原始数据"">&nbsp;"
		s = s & "</div>"
		s = s & "</td>"
		s = s & "</tr>"
		s = s & "</form>"
		s = s & "<form name=""dform" & i & """ action=""?do=delete"" method=""post"">"
		s = s & "<tr>"
		s = s & "<td align=""right"" height=""*"">"
		s = s & "<input name=""dpath"" type=""hidden"" value=""" & f.path & """>"
		s = s & "<input name=""submit3"" type=""button"" value=""删除模板"" onclick=""if(confirm('确定要删除此模板?')){this.disabled=true;document.dform" & i & ".submit();}"">"
		s = s & "</td>"
		s = s & "</tr>"
		s = s & "</form>"
		s = s & "</table>"
		s = s & "</td>"
		s = s & "</tr>"
		s = s & "</table>"
		i = i + 1
	next
	set f1 = nothing
	set f2 = nothing
	set l = nothing
	if s = "" then
		call alertbox("抱歉!模板目录路径错误!",2)
	else
		showfolderlist = s
	end if
end function
' *** ***  www.654.cn  *** ***
sub saveadd
    if not Check_Popedom("H503") then call alertbox("你没有权限操作",2)
	if instr(gfv("apath"),".") = 0 then
		call alertbox("抱歉!模板路径错误!",2)
	end if
	if checkfile(gfv("apath")) = true then
		call alertbox("抱歉!模板已经存在!",2)
	end if
	if gfv("content") = "" then
		call alertbox("抱歉!模板内容为空!",2)
	end if
	dim objstream
	set objstream = server.createobject(G_654_STREAM)
	with objstream
		.open
		.charset = "" & chrset & ""
		.position = objstream.size
		.writetext = gfv("content")
		.savetofile server.mappath(gfv("apath")),2
		.close
	end with
	set objstream = nothing
	if err.number <> 0 then
		err.clear
		call alertbox("抱歉!添加模板失败!",2)
	else
		call alertbox("恭喜!添加模板成功!",2)
	end if
end sub
' *** ***  www.654.cn  *** ***
sub saveedit
    if not Check_Popedom("H503") then call alertbox("你没有权限操作",2)
	dim objstream
	set objstream = server.createobject(G_654_STREAM)
	with objstream
		.open
		.charset = "" & chrset & ""
		.position = objstream.size
		.writetext = gfv("content" & gfv("i") & "")
		.savetofile gfv("epath"),2
		.close
	end with
	set objstream = nothing
	if err.number <> 0 then
		err.clear
		call alertbox("抱歉!添加模板失败!",2)
	else
		call alertbox("恭喜!添加模板成功!",2)
	end if
end sub
' *** ***  www.654.cn  *** ***
sub delete
    if not Check_Popedom("H503") then call alertbox("你没有权限操作",2)
	dim fso
	set fso = server.createobject("scripting.filesystemobject")
	if fso.fileexists(gfv("dpath")) then
		fso.deletefile(gfv("dpath"))
	end if
	set fso = nothing
	if err.number <> 0 then
		err.clear
		call alertbox("抱歉!删除模板失败!",2)
	else
		call alertbox("恭喜!删除模板成功!",2)
	end if
end sub
%>
<% LOADING_ADMIN_FOOT %>
