<!--#include file="../../../inc/cms_admin.asp" -->
<%
dim act,filename,pctempath,waptempath,filepath,filetext
dim fileListArray,i,fileAttr,folderListArray,folderAttr,parentPath,newname,str
pctempath=sitePath&"Template/pc/"
waptempath=sitePath&"Template/wap/"
act=getForm("act","get")
filename=getForm("filename","get")
filepath=getForm("filepath","get")
newname=getForm("newname","get")
str=getform("str","both")
if right(str,1)<>"/" then str=str&"/"
parentPath=getform("parentPath","both")
if isnul(parentPath) then parentPath=sitePath&"Template/"
select case act
	case "add" : addFile
	case "upload": upload
	case "rename" : rename
	case "edit" : edithtmlFile
	case "del" : delhtmlFile	
	case "setTemplate" : setTemplate	
	case "Crefolder"	: CreateFolder parentPath&newname	
	case "delfolder"	: delfolder parentPath		
	case "edithtmlfilepath" : editHtmlFilePath
	case "savepchtmlpath" : dbconn "update [dbpre]Language set pchtmlpath='"&str&"' where LID="&zset.LID		:	echo str
	case "savewaphtmlpath" : dbconn "update [dbpre]Language set waphtmlpath='"&str&"' where LID="&zset.LID		:	echo str
end select


Sub rename()
	dim newfilepath
	if not IfStrIn(newname,".") then newname=newname&"."&cRight(filename,".")
	newfilepath=replacestr(filepath,filename,newname)
	editfile filepath,newfilepath
	'echo replacestr(filepath,filename,newname)
	'echo "filepath:"&filepath&"filename:"&filename&"newname:"&newname
End Sub

Sub getFile()
	dim flag,mExt,t,tafe
	flag = false	
	mExt = LCase(Mid(filepath,InStrRev(filepath, ".")+1))	
	if IfStrIn(filepath,";") then  back "错误的文件名1！"
	if IfStrIn(filepath,"..") then  back "错误的文件名1！"
	filetext=loadFile(filepath)
End Sub

Sub edithtmlFile()
	filepath=getForm("filepath","post")
	filetext=decode(request.form("filetext"))	
	SaveFile filepath,filetext
	alertgo "保存成功","-2"
End Sub

Sub addFile()
	filename=getForm("filename","post")
	parentPath=getForm("parentPath","post")
	filetext=decode(request.form("filetext"))	
	if not ifstrin(filename,".") then back "错误的文件类型！"	
	if not ifstrin("htmljscss,",cRight(filename,".")) then back "只能创建html,js,css文件"&cRight(filename,".")
	SaveFile parentPath&filename,filetext
	alertgo "保存成功","template_list.asp?parentPath="&parentPath
End Sub


Sub delhtmlFile
	filepath=getForm("filepath","get")
	if isFile(filepath) then 
	delFile filepath
	echo "删除成功"
	else
	echo "文件不存在"
	end if
End Sub

Sub setTemplate
	dim thisTemplate : thisTemplate=getForm("style","get")
	dim	Stype:	Stype=getForm("Stype","get")
	dbconn "update [dbpre]Language set "&Stype&"='"&thisTemplate&"/' where LID="&zset.LID	
	alertgo "选择模板成功","template.asp"
End Sub
 
%>