<%
function loadtempletfile(byval path)
	on error resume next
	dim objstream
	set objstream = server.createobject("adodb.stream")
	with objstream
		.type = 2
		.mode = 3
		.open
		.loadfromfile server.mappath(path)
		if err.number <> 0 then
			err.clear
 			response.write("预加载的模板[" & path & "]不存在!")
			response.end()
		end if
		.charset = "" & chrset & ""
		.position = 2
			loadtempletfile = .readtext
		.close
	end with
	set objstream = nothing
end function

function movefiles(sFolder,dFolder)
	on error resume next
	dim fso
	set fso = server.createobject("scripting.filesystemobject")
	if fso.folderexists(server.mappath(sFolder)) and fso.folderexists(server.mappath(dFolder)) then
		fso.copyfolder server.mappath(sFolder),server.mappath(dFolder)
		movefiles = true
	else
		movefiles = false
		set fso = nothing
		call alertbox("系统没有找到指定的路径[" & sFolder & "]!",2)
	end if
	set fso = nothing
end function

function renamefolder(sFolder,dFolder)
	on error resume next
	dim fso
	set fso = server.createobject("scripting.filesystemobject")
	if fso.folderexists(server.mappath(sFolder)) then
		fso.movefolder server.mappath(sFolder),server.mappath(dFolder)
		renamefolder = true
	else
		renamefolder = false
		set fso = nothing
		call alertbox("系统没有找到指定的路径[" & sFolder & "]!",2)
	end if
	set fso = nothing
end function

function checkfolder(sPATH)
	'on error resume next
	dim fso
	set fso = server.createobject("scripting.filesystemobject")
	if fso.folderexists(server.mappath(sPATH)) then
		checkfolder = true
	else
		checkfolder = false
	end if
	set fso = nothing
end function

function checkfile(sPATH)
	on error resume next
	dim fso
	set fso = server.createobject("scripting.filesystemobject")
	if fso.fileexists(server.mappath(sPATH)) then
		checkfile = true
	else
		checkfile = false
	end if
	set fso = nothing
end function

function createdir(sPATH)
	dim fso,pathArr,i,path_Level,pathTmp,cPATH
	on error resume next
	sPATH = replace(sPATH,"\","/")
	set fso = server.createobject("scripting.filesystemobject")
		pathArr = split(sPATH,"/")
		path_Level = ubound(pathArr)
		for i = 0 to path_Level
			if i = 0 then pathTmp = pathArr(0) & "/" else pathTmp = pathTmp&pathArr(i) & "/"
			cPATH = left(pathTmp,len(pathTmp)-1)
			if not fso.folderexists(cPATH) then fso.createfolder(cPATH)
		next
	set fso = nothing
	if err.number <> 0 then
		err.clear
		createdir = false
	else
		createdir = true
	end if
end function

function DelClassFolder(sPATH)
	on error resume next
	dim fso
	set fso = server.createobject("scripting.filesystemobject")
	if fso.folderexists(server.mappath(sPATH)) then
		fso.deletefolder(server.mappath(sPATH))
	end if
	set fso = nothing
end function

function DelFile(sPATH,id)
	on error resume next
	dim rs,sql,tempArr,cPATH,ePATH,i,j:j = 0
	set rs = server.createobject("adodb.recordset")
	sql = "select filename from DH654_URL where id=" & id
	rs.open sql,conn,1,1
	if not rs.eof then
		dim fso
		set fso = server.createobject("scripting.filesystemobject")
		sPATH = sPATH & rs(0) & site_extname
		if fso.fileexists(server.mappath(sPATH)) then
			fso.deletefile(server.mappath(sPATH))
		end if
	else
		rs.close:set rs = nothing
		exit function
	end if
end function

function CreateClass(id)
	dim Temp:Temp = ""
		Temp = processcustomtag(loadtempletfile("../templets/" & getclassdemo(id,"DH654_Class") & ""))
	dim charclass
	set charclass = new stringclass
	dim PatrnStr
		PatrnStr = "<title>.*?</title>"
		Temp = charclass.replacestr(PatrnStr,Temp,"<title>" & charclass.getstr(getclassname(id,"DH654_Class")) & " - " & site_name & "</title>")
		PatrnStr = "\{\$id\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,cstr(id))
		PatrnStr = "\{\$path\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_root)
	    PatrnStr = "\{\$guide\$\}"      '导航条（包括分类名和连接）
		Temp = charclass.replacestr(PatrnStr,Temp,guide(id))
		PatrnStr = "\{\$classname\$\}"  '分类名
		Temp = charclass.replacestr(PatrnStr,Temp,getclassname(id,"DH654_Class"))
		PatrnStr = "\{\$classpath\$\}"  '分类全路径
		Temp = charclass.replacestr(PatrnStr,Temp,getclasspath(id,"DH654_Class"))
		PatrnStr = "\{\$keywords\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,keywords(id,"DH654_Class"))
		PatrnStr = "\{\$ZZLink654cN\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,ZZLink654cN(id,48))
		PatrnStr = "\{\$nowtime\$\}"		
		Temp = charclass.replacestr(PatrnStr,Temp,dateformat(now(),7))
		PatrnStr = "\{\$tree\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,tree(id))
		PatrnStr = "\{\$urllist\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,urllist(id))
		PatrnStr = "\{\$root\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_root)		
	dim sPATH,cPATH:cPATH = ".." & site_html & getclasspath(id,"DH654_Class") & "/"
		createdir(server.mappath(cPATH))
		sPATH = "" & cPATH & "index" & site_extname & ""
	dim objstream
	set objstream = server.createobject("adodb.stream")
	with objstream
		.open
		.charset = "" & chrset & ""
		.position = objstream.size
		.writetext = Temp
		.savetofile server.mappath(sPATH),2
		.close
	end with
	set objstream = nothing
	if err.number <> 0 then
		err.clear
		CreateClass = false
	else
		CreateClass = true
	end if
end function

function creatsitefile(id)  '创建终极网址
	dim rs,sql
	set rs = server.createobject("adodb.recordset")
	sql = "select id,classid,title,type,url,keywords,author,content,elite,error,hide,filename,addtime from DH654_URL where id=" & id
	rs.open sql,conn,1,1
	dim databox:databox = rs.getrows()
	rs.close:set rs = nothing
	dim Temp:Temp = loadtempletfile("../templets/" & site_url_temp & "")
	dim charclass
	set charclass = new stringclass
	dim PatrnStr
		PatrnStr = "<title>.*?</title>"
		Temp = charclass.replacestr(PatrnStr,Temp,"<title>" & charclass.getstr(databox(2,0)) & " - " & site_name & "</title>")
		PatrnStr = "\{\$id\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(0,0))
		PatrnStr = "\{\$path\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_root)
		PatrnStr = "\{\$title\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(2,0))
		PatrnStr = "\{\$url\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(4,0))
		PatrnStr = "\{\$keywords\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(5,0))
		PatrnStr = "\{\$clickin\$\}" '点入
		Temp = charclass.replacestr(PatrnStr,Temp,clickin(databox(0,0)))
		PatrnStr = "\{\$content\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(7,0))
		PatrnStr = "\{\$guide\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,guide(databox(1,0)))
		PatrnStr = "\{\$guidepath\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_url&site_html & getclasspath(databox(1,0),"DH654_Class") &"/"& databox(11,0) & site_extname)
		PatrnStr = "\{\$sitemore\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,sitemore(databox(1,0)))
	dim tempArr,n,sPATH,ePATH,cPATH:cPATH = ".." & site_html & getclasspath(databox(1,0),"DH654_Class") & "/"
	if instr(databox(11,0),"/") = 0 then
		createdir(server.mappath(cPATH))
	else
		tempArr = split(databox(11,0),"/")
		for n = 0 to ubound(tempArr)
			ePATH = replace(databox(11,0),tempArr(n),"")
		next
		createdir(server.mappath(cPATH & ePATH))
	end if
	sPATH = "" & cPATH & databox(11,0) & site_extname & ""
	dim objstream
	set objstream = server.createobject("adodb.stream")
	with objstream
		.open
		.charset = "" & chrset & ""
		.position = objstream.size
		.writetext = Temp
		.savetofile server.mappath(sPATH),2
		.close
	end with
	set objstream = nothing
	if err.number <> 0 then
		err.clear
		creatsitefile = false
	else
		conn.execute("update DH654_URL set created=1 where id=" & databox(0,0))
		creatsitefile = true
		databox = ""
	end if
end function

function CreatLinkfile(id)  '创建终极网址自助链
	dim rs,sql
	set rs = server.createobject("adodb.recordset")
	sql = "select id,classid,CName,ESite,keywords,error,hide,filename,atime,HitOut,HitIn,out1,in1,out0,in0 from ZZ654_Link where id=" & id
	rs.open sql,conn,1,1
	dim databox:databox = rs.getrows()
	rs.close:set rs = nothing
	dim Temp:Temp = loadtempletfile("../templets/" & site_url_temp & "")
	dim charclass
	set charclass = new stringclass
	dim PatrnStr
		PatrnStr = "<title>.*?</title>"
		Temp = charclass.replacestr(PatrnStr,Temp,"<title>" & charclass.getstr(databox(2,0)) & " - " & site_name & "</title>")
		PatrnStr = "\{\$id\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(0,0))
		PatrnStr = "\{\$path\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_root)
		PatrnStr = "\{\$title\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(2,0))
		PatrnStr = "\{\$url\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(3,0))
		PatrnStr = "\{\$keywords\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(4,0))
		PatrnStr = "\{\$clickin\$\}" '点入
		Temp = charclass.replacestr(PatrnStr,Temp,clickin(databox(0,0)))
		PatrnStr = "\{\$content\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(4,0))
		PatrnStr = "\{\$guide\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,guide(databox(1,0)))
		PatrnStr = "\{\$guidepath\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_url&site_html & getclasspath(databox(1,0),"DH654_Class") &"/"& databox(11,0) & site_extname)
		PatrnStr = "\{\$sitemore\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,sitemore(databox(1,0)))
	dim tempArr,n,sPATH,ePATH,cPATH:cPATH = ".." & site_html & getclasspath(databox(1,0),"DH654_Class") & "/"
	if instr(databox(7,0),"/") = 0 then
		createdir(server.mappath(cPATH))
	else
		tempArr = split(databox(7,0),"/")
		for n = 0 to ubound(tempArr)
			ePATH = replace(databox(7,0),tempArr(n),"")
		next
		createdir(server.mappath(cPATH & ePATH))
	end if
	sPATH = "" & cPATH & databox(7,0) & site_extname & ""
	dim objstream
	set objstream = server.createobject("adodb.stream")
	with objstream
		.open
		.charset = "" & chrset & ""
		.position = objstream.size
		.writetext = Temp
		.savetofile server.mappath(sPATH),2
		.close
	end with
	set objstream = nothing
	if err.number <> 0 then
		err.clear
		creatlinkfile = false
	else
		conn.execute("update ZZ654_Link set created=1 where id=" & databox(0,0))
		creatlinkfile = true
		databox = ""
	end if
end function

function creatWebSitefile(id)  '登陆网址库
	dim rs,sql
	set rs = server.createobject("adodb.recordset")
	sql = "select id,type,classid,title,url,filename,keywords,author,e_mail,hide,effect,click,addtime from DH654_WebSite where id=" & id
	rs.open sql,conn,1,1
	dim databox:databox = rs.getrows()
	rs.close:set rs = nothing
	dim Temp:Temp = loadtempletfile("../templets/" & site_url_temp & "")
	dim charclass
	set charclass = new stringclass
	dim PatrnStr
		PatrnStr = "<title>.*?</title>"
		Temp = charclass.replacestr(PatrnStr,Temp,"<title>" & charclass.getstr(databox(3,0)) & " - 刚加入网址</title>")
		PatrnStr = "\{\$id\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(0,0))
		PatrnStr = "\{\$path\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_root)
		PatrnStr = "\{\$title\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(3,0))
		PatrnStr = "\{\$url\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(4,0))
		PatrnStr = "\{\$keywords\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(5,0))
		PatrnStr = "\{\$clickin\$\}" '点入
		PatrnStr = "\{\$sitemore\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,sitemore(databox(2,0)))
		Temp = charclass.replacestr(PatrnStr,Temp,clickin(databox(0,0)))
		PatrnStr = "\{\$guide\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,"登陆列队中")
	dim sPATH,cPATH:cPATH = ".." & site_html & "/add/"
	sPATH = "" & cPATH & databox(5,0) & site_extname & ""
	dim objstream
	set objstream = server.createobject("adodb.stream")
	with objstream
		.open
		.charset = "" & chrset & ""
		.position = objstream.size
		.writetext = Temp
		.savetofile server.mappath(sPATH),2
		.close
	end with
	set objstream = nothing
	if err.number <> 0 then
		err.clear
		creatWebSitefile = false
	else
		creatWebSitefile = true
		databox = ""
	end if
end function

function CreatAdsfile(Adfile,AdContent)  '创建广告
	dim Temp:Temp =AdContent
	dim sPATH,ePATH,cPATH:cPATH = ".." & site_html &"/ads/"
	if checkfolder(cPATH)=false then 
	   createdir(server.mappath(cPATH))
	end if
	sPATH = ".." & site_html &"/ads/" & Adfile
	dim objstream
	set objstream = server.createobject(G_654_STREAM)
	with objstream
		.open
		.charset = "" & chrset & ""
		.position = objstream.size
		.writetext = Temp
		.savetofile server.mappath(sPATH),2
		.close
	end with
	set objstream = nothing
	if err.number <> 0 then
		err.clear
		creatAdsfile = false
	else
		creatAdsfile = true
	end if
end function
function delAdsfile(Adfile)
	on error resume next
		dim fso
		Adfile=".." & site_html &"/ads/" & Adfile
		set fso = server.createobject("scripting.filesystemobject")
		if fso.fileexists(server.mappath(Adfile)) then
			fso.deletefile(server.mappath(Adfile))
		end if
end function

function Creathotjs(id)  '创建本类最热门网站排行(id)	    
	dim rs,sql,Temp,n:n=1
	set rs = server.createobject(G_654_RS)
	sql = "select top 10 * from TJ654_Track where u like '%"&getclasspath(id,"DH654_Class")&"%' order by click DESC"
	rs.open sql,conn,1,1
	Temp ="var hot = new Array("
	do while not rs.eof
	  n=n+1
	  if n<=10 and n<=rs.recordcount then
  	     Temp=Temp&"new Array("""&rs("u")&""","""&rs("t")&"""),"
      else
  	     Temp=Temp&"new Array("""&rs("u")&""","""&rs("t")&""")"
		 exit do
	  end if	  
	  rs.movenext	  
    loop
	Temp=Temp&");"
	Temp=Temp&"showUrl(hot);"
    rs.close:set rs=nothing	
	dim sPATH,cPATH:cPATH = ".." & site_html &"/js/"
	if checkfolder(cPATH)=false then 
	   createdir(server.mappath(cPATH))
	end if
	sPATH = ".." & site_html &"/js/"&id&".js"
	dim objstream
	set objstream = server.createobject(G_654_STREAM)
	with objstream
		.open
		.charset = "" & chrset & ""
		.position = objstream.size
		.writetext = Temp
		.savetofile server.mappath(sPATH),2
		.close
	end with
	set objstream = nothing
	if err.number <> 0 then
		err.clear
		Creathotjs = false
	else
		Creathotjs = true
	end if
end function

function Creatlivejs()  '创建网友正在查看的网站    
	dim rs,sql,Temp,n:n=1
	set rs = server.createobject(G_654_RS)
	sql = "select top 10 * from TJ654_Track"
	rs.open sql,conn,1,1
	Temp ="var hot = new Array("
	do while not rs.eof
	  n=n+1
	  if n<=10 and n<=rs.recordcount then
  	     Temp=Temp&"new Array("""&rs("u")&""","""&rs("t")&"""),"
      else
  	     Temp=Temp&"new Array("""&rs("u")&""","""&rs("t")&""")"
		 exit do
	  end if	  
	  rs.movenext	  
    loop
	Temp=Temp&");"
	Temp=Temp&"showUrl(hot);"
    rs.close:set rs=nothing	
	dim sPATH,cPATH:cPATH = ".." & site_html 
	if checkfolder(cPATH)=false then 
	   createdir(server.mappath(cPATH))
	end if
	sPATH = ".." & site_html &"/live.js"
	dim objstream
	set objstream = server.createobject(G_654_STREAM)
	with objstream
		.open
		.charset = "" & chrset & ""
		.position = objstream.size
		.writetext = Temp
		.savetofile server.mappath(sPATH),2
		.close
	end with
	set objstream = nothing
	if err.number <> 0 then
		err.clear
		Creatlivejs = false
	else
		Creatlivejs = true
	end if
end function


function CreateCityIndex(id)
	dim rs,sql
	set rs = server.createobject(G_654_RS)
	sql = "select id,parent,orders,cname,titlecolor,ename,ctemp,keywords,URLNum,addtime,elite,weather,rss1,rss2 from CT654_class where parent=0 and id=" & id
	'sql = "select top 1 * from CT654_class where id=" & id
	rs.open sql,conn,1,1
	if not rs.eof then
		dim databox:databox = rs.getrows()
		rs.close:set rs = nothing
	else
		rs.close:set rs = nothing
		call alertbox("没有数据记录!",2)
	end if	
	dim Temp:Temp = ""
		'Temp = processcustomtag(loadtempletfile("../templets/" & getclassdemo(id,"CT654_Class") & ""))
		Temp = processcustomtag(loadtempletfile("../templets/CityIndex.htm"))
	dim charclass
	set charclass = new stringclass
	dim PatrnStr
		'PatrnStr = "<title>.*?</title>"
		'Temp = charclass.replacestr(PatrnStr,Temp,"<title>" & charclass.getstr(getclassname(id,"CT654_Class")) & " - " & site_name & "</title>")
	    PatrnStr = "\{\$cityename\$\}"     
		Temp = charclass.replacestr(PatrnStr,Temp,databox(5,0))
	    PatrnStr = "\{\$citycname\$\}"     
		Temp = charclass.replacestr(PatrnStr,Temp,databox(3,0))
		PatrnStr = "\{\$MingZhan\$\}"     
		Temp = charclass.replacestr(PatrnStr,Temp,CityMingZhan(id))
		PatrnStr = "\{\$KuZhan\$\}"     
		Temp = charclass.replacestr(PatrnStr,Temp,CityKuZhan(id))

		PatrnStr = "\{\$weather\$\}"     
		Temp = charclass.replacestr(PatrnStr,Temp,databox(11,0))
	    PatrnStr = "\{\$rss1\$\}"     
		Temp = charclass.replacestr(PatrnStr,Temp,Readrss(databox(12,0)))
	    PatrnStr = "\{\$rss2\$\}"     
		Temp = charclass.replacestr(PatrnStr,Temp,Readrss(databox(13,0)))
		
		PatrnStr = "\{\$keywords\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(7,0))
		PatrnStr = "\{\$nowtime\$\}"		
		Temp = charclass.replacestr(PatrnStr,Temp,dateformat(now(),7))
		PatrnStr = "\{\$id\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,cstr(id))
		PatrnStr = "\{\$path\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_root)
		PatrnStr = "\{\$root\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_root)		
	dim sPATH,cPATH:cPATH = ".." & site_html & getclasspath(id,"CT654_Class") & "/"
		createdir(server.mappath(cPATH))
		sPATH = "" & cPATH & "index" & site_extname & ""
	dim objstream
	set objstream = server.createobject("adodb.stream")
	with objstream
		.open
		.charset = "" & chrset & ""
		.position = objstream.size
		.writetext = Temp
		.savetofile server.mappath(sPATH),2
		.close
	end with
	set objstream = nothing
	if err.number <> 0 then
		err.clear
		CreateCityindex = false
	else
		CreateCityindex = true
		databox=""
	end if
end function

function CreateCityClass(id)
	dim rs,sql
	set rs = server.createobject(G_654_RS)
	sql = "select id,parent,orders,cname,titlecolor,ename,ctemp,keywords,URLNum,addtime,elite from CT654_class where id=" & id
	rs.open sql,conn,1,1
	if not rs.eof then
		dim databox:databox = rs.getrows()
		rs.close:set rs = nothing
	else
		rs.close:set rs = nothing
		call alertbox("没有数据记录!",2)
	end if	
	dim Temp:Temp = ""
		'Temp = processcustomtag(loadtempletfile("../templets/" & getclassdemo(id,"CT654_Class") & ""))
		Temp = processcustomtag(loadtempletfile("../templets/CityClass.htm"))
	dim charclass
	set charclass = new stringclass
	dim PatrnStr
		'PatrnStr = "<title>.*?</title>"
		'Temp = charclass.replacestr(PatrnStr,Temp,"<title>" & charclass.getstr(getclassname(id,"CT654_Class")) & " - " & site_name & "</title>")
		PatrnStr = "\{\$CityWebList\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,CityWebList(id))
		PatrnStr = "\{\$CityTree\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,CityTree(id))
	    PatrnStr = "\{\$guide\$\}"      '导航条（包括分类名和连接）
		Temp = charclass.replacestr(PatrnStr,Temp,cityguide(id))
	    PatrnStr = "\{\$cityename\$\}"     
		Temp = charclass.replacestr(PatrnStr,Temp,GetAtoBforT("ename","CT654_Class","id",databox(1,0)))
	    PatrnStr = "\{\$citycname\$\}"     
		Temp = charclass.replacestr(PatrnStr,Temp,getclassname(databox(1,0),"CT654_Class"))
	    PatrnStr = "\{\$ename\$\}"     
		Temp = charclass.replacestr(PatrnStr,Temp,databox(5,0))
	    PatrnStr = "\{\$cname\$\}"     
		Temp = charclass.replacestr(PatrnStr,Temp,databox(3,0))
		PatrnStr = "\{\$keywords\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(7,0))
		PatrnStr = "\{\$nowtime\$\}"		
		Temp = charclass.replacestr(PatrnStr,Temp,dateformat(now(),7))
		PatrnStr = "\{\$id\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,cstr(id))
		PatrnStr = "\{\$path\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_root)
		PatrnStr = "\{\$root\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_root)		
	dim sPATH,cPATH:cPATH = ".." & site_html & getclasspath(id,"CT654_Class") & "/"
		createdir(server.mappath(cPATH))
		sPATH = "" & cPATH & "index" & site_extname & ""
	dim objstream
	set objstream = server.createobject("adodb.stream")
	with objstream
		.open
		.charset = "" & chrset & ""
		.position = objstream.size
		.writetext = Temp
		.savetofile server.mappath(sPATH),2
		.close
	end with
	set objstream = nothing
	if err.number <> 0 then
		err.clear
		CreateCityClass = false
	else
		CreateCityClass = true
		databox=""
	end if
end function

function CreateCityWeb(id)  '创建终极网址
	dim rs,sql
	set rs = server.createobject("adodb.recordset")
      sql = "select id,classid,title,titlecolor,url,keywords,elite,error,hide,filename,addtime from CT654_URL where id=" & id
	rs.open sql,conn,1,1
	dim databox:databox = rs.getrows()
	rs.close:set rs = nothing
	dim Temp:Temp = loadtempletfile("../templets/CityWeb.htm")
	dim charclass
	set charclass = new stringclass
	dim PatrnStr
		'PatrnStr = "<title>.*?</title>"
		'Temp = charclass.replacestr(PatrnStr,Temp,"<title>" & charclass.getstr(databox(2,0)) & " - " & site_name & "</title>")
		PatrnStr = "\{\$id\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(0,0))
	    PatrnStr = "\{\$path\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_root)
		PatrnStr = "\{\$title\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(2,0))
		PatrnStr = "\{\$url\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(4,0))
		PatrnStr = "\{\$keywords\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,databox(5,0))
		'PatrnStr = "\{\$clickin\$\}" '点入
		'Temp = charclass.replacestr(PatrnStr,Temp,clickin(databox(0,0)))
		PatrnStr = "\{\$guide\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,Cityguide(databox(1,0)))
		PatrnStr = "\{\$guidepath\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,site_url&site_html & getclasspath(databox(1,0),"CT654_Class") &"/"& databox(9,0) & site_extname)
		PatrnStr = "\{\$sitemore\$\}"
		Temp = charclass.replacestr(PatrnStr,Temp,CitySiteMore(databox(1,0)))
	dim sPATH,cPATH:cPATH = ".." & site_html & getclasspath(databox(1,0),"CT654_Class") & "/"
	createdir(server.mappath(cPATH))
	sPATH = "" & cPATH & databox(9,0) & site_extname & ""
	dim objstream
	set objstream = server.createobject("adodb.stream")
	with objstream
		.open
		.charset = "" & chrset & ""
		.position = objstream.size
		.writetext = Temp
		.savetofile server.mappath(sPATH),2
		.close
	end with
	set objstream = nothing
	if err.number <> 0 then
		err.clear
		CreateCityWeb = false
	else
		conn.execute("update CT654_URL set created=1 where id=" & databox(0,0))
		CreateCityWeb = true
		databox = ""
	end if
end function

%>