
<%
'On Error Resume Next '遇有错误仍继续执行 

Dim strUserName,strUserID,strWebSiteID,strHome,fs,FolderHTML
Dim strWebLogo,strWebCompany,strWebBanner,strWebTitle,strWebFootNote,strWebCounter,strWebTemplet,strWebICP
call CreateWebSite

'
'set objSenty=Server.CreateObject("Jndiy.EasyDiy")
'Call objSenty.CreateWebSite(strSQLServer, strDataBase, strSQLUser, strSQLPassword, strScriptFileSystem)
	
'===============================================
'函数功能：根据当前用户的资料，生成一个用户网站
'作者：盛天
'创建时间：2003-11-23
'修改时间：2004-3-31
'===============================================
sub CreateWebSite()
	
		'=============================================================================
		'第一步，初始化变量
		'=============================================================================
			strUserName=Session("UserName")
			strUserID=Session("UserID")
			strWebSiteID=Session("WebSiteID")
			strHome="home/" & strUserName
			
			strSQL="Select * From website Where m_id=" & strUserID
			set rsWebSite=Server.CreateObject("ADODB.RecordSet")
			rsWebSite.open strSQL,conn,1,1
			
			'网站LOGO
			if trim(rsWebSite("w_LogoHref"))<>"" then
				strWebLogo="<a href='" & trim(rsWebSite("w_LogoHref")) & "' title='" & trim(rsWebSite("w_LogoTitle")) & "'><img src='" & trim(rsWebSite("w_Logo")) & "' border=0></a>"
			else
				strWebLogo="<img src='" & trim(rsWebSite("w_Logo")) & "' border=0>"
			end if
			
			'网站名称
			if rsWebSite("w_UserComText")=1 then
				strWebCompany=trim(rsWebSite("w_CompanyText"))
			else
				strWebCompany="<img src='" & trim(rsWebSite("w_Company")) & "'>"
			end if
			
			'网站横幅
			strWebBanner=trim(rsWebSite("w_Banner"))
			if Lcase(Right(strWebBanner,4))=".swf" then
				Dim strFlass
				strFlass="<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0>" & chr(13)
				strFlass=strFlass & "<param name=movie value=" & strBanner & ">" & chr(13)
				strFlass=strFlass & "	<param name=quality value=high>" & chr(13)
				strFlass=strFlass & "	<embed src=" & strWebBanner & " quality=high pluginspage=http://www.macromedia.com/go/getflashplayer type=application/x-shockwave-flash></embed>" & chr(13)
				strFlass=strFlass & "  </object>" & chr(13)
				strWebBanner=strFlass
			else
				strWebBanner="<img src=" & strWebBanner & " >"
			end if
			
			
			'网站标题
			strWebTitle=trim(rsWebSite("w_Title"))
			
			'网站脚注
			strWebFootNote=trim(rsWebSite("w_FootNote"))
			
			'网站ICP
			if trim(rsWebSite("w_ICPHref"))<>"" then
				strWebICP="<a href='" & trim(rsWebSite("w_ICPHref")) & "' target=_blank>" & trim(rsWebSite("w_ICP")) & "</a>"
			else
				strWebICP=trim(rsWebSite("w_ICP"))
			end if


			'网站模板
			strWebTemplet=rsWebSite("w_templet")
			

			rsWebSite.close()
			set rsWebSite=Nothing
			
			Set fs = Server.CreateObject( Const_ScriptFileSystem )
			
			'如果是更换了模板，检查栏目可用性
			if isChangeTemplet then
				Call ChangeTemplet()
			End if
				
		'=============================================================================
		'第二步，生成网站，包括COPY内容，生成配置文件
		'=============================================================================
		
		
			'1、创建用户文件夹,及COPY相应文件
			
				CreateFolderName = "home/" & strUserName
				CreateFolderName = Server.MapPath( CreateFolderName )
				OldFolderName = Server.MapPath( "Templet/" & strWebTemplet)
				commonFolderName=Server.MapPath( "Templet_common" )
				
				'如果是生成网站，则先删除旧数据
				if request.QueryString("cp")="1" then
					
					if fs.FolderExists(CreateFolderName & "\images") then
						fs.DeleteFolder CreateFolderName & "\images",true
						fs.DeleteFile CreateFolderName & "\*.*",true
					end if
				End if
				
				'如果文件夹不存在，则创建，并从模板从拷所有文件
				if Not (fs.FolderExists(CreateFolderName) And fs.FolderExists(CreateFolderName & "/admin") And fs.FolderExists(CreateFolderName & "/images")) or request.QueryString("cp")="1" then
					if request.QueryString("f")="1" then
						'第一次生成网站全部内容
						fs.CopyFolder OldFolderName ,CreateFolderName,True
						fs.CopyFolder commonFolderName,CreateFolderName,True
						fs.CopyFile commonFolderName& "\*.*",CreateFolderName& "\",True
						'生成一个管理员用户
					else
						'从对应模板的位置拷贝文件夹
						fs.CopyFolder commonFolderName & "\admin",CreateFolderName & "\admin",True
						fs.CopyFolder commonFolderName & "\common",CreateFolderName & "\common",True
						fs.CopyFile commonFolderName& "\*.*",CreateFolderName& "\",True
						fs.CopyFolder OldFolderName & "\images",CreateFolderName & "\images",True
						fs.CopyFile OldFolderName & "\*.*",CreateFolderName & "\",True
						'fs.CopyFile OldFolderName & "\*.htm",CreateFolderName & "\",True
					end if
					
				end if

				
			'2、生成用户网站JS配置文件，包括菜单配置，语言配置等
				Dim strStarText,strEndText,strAllText
				strStarText=""
				JsFile=Server.MapPath( "home/" & strUserName  & "/common/templet.js" )
				set objTextFile=fs.OpenTextFile(JsFile,1)
				strEndText=objTextFile.ReadAll
				objTextFile.close
				
				
	'2004-4-9　盛天　为了第三次提速，将要跳过此步骤				
	'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	'判断跳过的条件
	if request.QueryString("c")="1" then
	
				'生成后台管理目录,admin/folder.asp
				FolderHTML=""
				'会员管理
				Folder_Member=""
				isMember=GetKey("w_member",strUserID,"website")
				if isMember="Yes" then
					'启动会员管理功能
					Folder_Member=Folder_Member & "        <li id=foldheader>会员管理</li>" & vbCrLf
					Folder_Member=Folder_Member & "        <ul id=foldinglist style=display:none>" & vbCrLf
					Folder_Member=Folder_Member & "          <li><a href= target=main>会员管理</a></li>" & vbCrLf
					Folder_Member=Folder_Member & "          <li><a href= target=main>会员日记</a></li>" & vbCrLf
					Folder_Member=Folder_Member & "        </ul>" & vbCrLf
				end if
				'FolderHTML=FolderHTML & Folder_Member		'会员功能由模板决定
				

		
				
			'2、从数据库中取菜单数据
				strJsText=""
				strJsText=strJsText & "//ASP程序生成菜单开始" & vbCrLf
				strJsText=strJsText & "var Menu_Text=new Array();" & vbCrLf
				strJsText=strJsText & "var Menu_Target=new Array();" & vbCrLf
				strJsText=strJsText & "var Menu_Href=new Array();" & vbCrLf
				strJsText=strJsText & "var Menu_Class=new Array();" & vbCrLf & vbCrLf & vbCrLf
				strSQL="Select * From menu Where m_id=" & Session("UserID") & " And mn_enable>0 And mn_parent=0 Order by mn_index"
				set rsMenu=Server.CreateObject("ADODB.RecordSet")
				
				'要更新的栏目
				Dim strMenuID, strSubMenuID
				strMenuID=request.QueryString("menu")
				strSubMenuID=request.QueryString("submenu")
				rsMenu.open strSQL,conn,1,1
				for i=0 to rsMenu.recordcount-1
					
					'如果地址是一个网址，则表示只是一个链接，不需要生成
					strSQL="Select tm_href,l_code From Templet_Menu Where id=" & rsMenu("tm_id") & ""
					set rsMenu_tm=Server.CreateObject("ADODB.RecordSet")
					rsMenu_tm.open strSQL,conn,1,1
					if not rsMenu_tm.eof then
						
						'检查是不是要更新的栏目
						if  strMenuID="" or Instr(strMenuID,Trim(rsMenu("id")) & ",")>0 then
							'借用这个遍历机会生成各栏目文件
							Call CreateLanMu(trim(rsMenu_tm("tm_href")),trim(rsMenu("mn_href")))
							
							'借用这个遍历机会替换各栏目中的⑨content⑨符号
							if trim(rsMenu("mn_content"))<>"" then
								dim strOld,strReplace
								strOld="⑨content⑨"
								strReplace=trim(rsMenu("mn_content"))
								strFileHTML=Server.MapPath( "home/" & strUserName & "/" & trim(rsMenu("mn_href")))
								Call ReplaceSymbol(strFileHTML,strOld,strReplace)
							end if
							
							'借用这个遍历机会替换各栏目中的⑨thispage⑨符号
							strFileHTML=Server.MapPath( "home/" & strUserName & "/" & trim(rsMenu("mn_href")))
							Call ReplaceSymbol(strFileHTML,"⑨thispage⑨",trim(rsMenu("mn_name")))
							
							'借用这个遍历机会替换各栏目中的⑨menuid⑨符号
							Call ReplaceSymbol(strFileHTML,"⑨menuid⑨",trim(rsMenu("id")))
						end if
						
						'借用这个遍历机会生成后台管理的Folder.asp  
						Select Case trim(rsMenu_tm("l_code"))
					  
							case "03"
								'产品展示
								FolderHTML=FolderHTML & "        <li id=foldheader>" & trim(rsMenu("mn_name")) & "</li>" & vbCrLf
								FolderHTML=FolderHTML & "        <ul id=foldinglist style=display:none>" & vbCrLf
								FolderHTML=FolderHTML & "          <li><a href='class/main.asp?mnid=" & trim(rsMenu("id")) & "&TableName=web_product_class&WindowName=" & trim(rsMenu("mn_name")) & "' target=main>产品分类</a></li>" & vbCrLf
								FolderHTML=FolderHTML & "          <li><a href='product/main.asp?mnid=" & trim(rsMenu("id")) & "&WindowName=" & trim(rsMenu("mn_name")) & "' target=main>产品管理</a></li>" & vbCrLf
								FolderHTML=FolderHTML & "          <li><a href='product/order_list.asp?mnid=" & trim(rsMenu("id")) & "&WindowName=" & trim(rsMenu("mn_name")) & "' target=main>订单管理</a></li>" & vbCrLf
								FolderHTML=FolderHTML & "        </ul>" & vbCrLf
							
							case "04"
								'公司新闻
								FolderHTML=FolderHTML & "        <li id=foldheader>" & trim(rsMenu("mn_name")) & "</li>" & vbCrLf
								FolderHTML=FolderHTML & "        <ul id=foldinglist style=display:none>" & vbCrLf
								FolderHTML=FolderHTML & "          <li><a href='class/main.asp?mnid=" & trim(rsMenu("id")) & "&TableName=web_news_class&WindowName=" & trim(rsMenu("mn_name")) & "' target=main>新闻分类</a></li>" & vbCrLf
								FolderHTML=FolderHTML & "          <li><a href='news/main.asp?mnid=" & trim(rsMenu("id")) & "&WindowName=" & trim(rsMenu("mn_name")) & "' target=main>新闻管理</a></li>" & vbCrLf
								FolderHTML=FolderHTML & "        </ul>" & vbCrLf
							case "05"
								'公司招聘
								FolderHTML=FolderHTML & "        <li id=foldheader><a href='job/main.asp?mnid=" & trim(rsMenu("id")) & "&WindowName=" & trim(rsMenu("mn_name")) & "' target='main'>" & trim(rsMenu("mn_name")) & "</a></li>" & vbCrLf
							case "06"
								'留言板
								FolderHTML=FolderHTML & "        <li id=foldheader><a href='guestbook/guestbook.asp?mnid=" & trim(rsMenu("id")) & "&WindowName=" & trim(rsMenu("mn_name")) & "' target='main'>" & trim(rsMenu("mn_name")) & "</a></li>" & vbCrLf
	
						end Select
						
					End if
					rsMenu_tm.close
					set rsMenu_tm=nothing
						
							
						'生成一级菜单
						if i=0 then
							strHomePage=trim(rsMenu("mn_href"))
							strHomeId=trim(rsMenu("id"))
						end if
						strJsText=strJsText & "Menu_Text[" & i & "]='" & trim(rsMenu("mn_name")) & "';" & vbCrLf
						strJsText=strJsText & "Menu_Target[" & i & "]='" & trim(rsMenu("mn_target")) & "';" & vbCrLf
						strJsText=strJsText & "Menu_Href[" & i & "]='" & trim(rsMenu("mn_href")) & "';" & vbCrLf
						strJsText=strJsText & "Menu_Class[" & i & "]='" & trim(rsMenu("mn_class")) & "';" & vbCrLf & vbCrLf
									
						
						'如果有二级菜单，则生成二级菜单
						strSQL="Select * From menu Where m_id=" & Session("UserID") & " And mn_enable>0 And mn_parent=" & rsMenu("id") & " Order by mn_index"
						Set rsSub=Server.CreateObject("ADODB.RecordSet")
						rSub.open strSQL,conn,1,1
						strJsText=strJsText & "//生成‘" & trim(rsMenu("mn_name")) & "’二级菜单" & vbCrLf
						if rSub.recordcount>0 then
							'生成二级菜单
							strJsText=strJsText & "var SubMenu" & i & "_Text=new Array();" & vbCrLf
							strJsText=strJsText & "var SubMenu" & i & "_Target=new Array();" & vbCrLf
							strJsText=strJsText & "var SubMenu" & i & "_Href=new Array();" & vbCrLf
							strJsText=strJsText & "var SubMenu" & i & "_Class=new Array();" & vbCrLf
						else
							strJsText=strJsText & "var SubMenu" & i & "_Text=null;" & vbCrLf & vbCrLf
						end if
						for j=0 to rSub.recordcount-1
							
	
							strJsText=strJsText & "SubMenu" & i & "_Text[" & j & "]='" & trim(rSub("mn_name")) & "';" & vbCrLf
							strJsText=strJsText & "SubMenu" & i & "_Target[" & j & "]='" & trim(rSub("mn_target")) & "';" & vbCrLf
							strJsText=strJsText & "SubMenu" & i & "_Href[" & j & "]='" & trim(rSub("mn_href")) & "';" & vbCrLf
							strJsText=strJsText & "SubMenu" & i & "_Class[" & j & "]='" & trim(rSub("mn_class")) & "';" & vbCrLf
							strJsText=strJsText & vbCrLf
							
							strSQL="Select tm_href,l_code From Templet_Menu Where id=" & rSub("tm_id") & ""
							set rSub_tm=Server.CreateObject("ADODB.RecordSet")
							rSub_tm.open strSQL,conn,1,1
							'检查是不是要更新的栏目
							if not rSub_tm.eof then
								if strMenuID="" or Instr(strMenuID,Trim(rsMenu("id")) & ",")>0 then
								
									'检查是不是要更新子栏目
									if strSubMenuID="" or Instr(strSubMenuID,Trim(rSub("id")) & ",")>0 then
										'生成各子栏目文件
										Call CreateLanMu(trim(rSub_tm("tm_href")),trim(rSub("mn_href")))
										
										'各子栏目中的⑨content⑨符号
										if trim(rSub("mn_content"))<>"" then
											'dim strOld,strReplace
											strOld="⑨content⑨"
											strReplace=trim(rSub("mn_content"))
											strFileHTML=Server.MapPath( "home/" & strUserName & "/" & trim(rSub("mn_href")))
											Call ReplaceSymbol(strFileHTML,strOld,strReplace)
										end if
										
										'子栏目中的⑨thispage⑨符号
										strFileHTML=Server.MapPath( "home/" & strUserName & "/" & trim(rSub("mn_href")))
										Call ReplaceSymbol(strFileHTML,"⑨thispage⑨",trim(rSub("mn_name")))
										
										'子栏目中的⑨menuid⑨符号
										Call ReplaceSymbol(strFileHTML,"⑨menuid⑨",trim(rSub("id")))
									end if
								end if
			
								'借用这个遍历机会生成后台管理的Folder.asp  
								Select Case trim(rSub_tm("l_code"))
							  
									case "03"
										'产品展示
										FolderHTML=FolderHTML & "        <li id=foldheader>-" & trim(rSub("mn_name")) & "</li>" & vbCrLf
										FolderHTML=FolderHTML & "        <ul id=foldinglist style=display:none>" & vbCrLf
										FolderHTML=FolderHTML & "          <li><a href='class/main.asp?mnid=" & trim(rSub("id")) & "&TableName=web_product_class&WindowName=" & trim(rSub("mn_name")) & "' target=main>产品分类</a></li>" & vbCrLf
										FolderHTML=FolderHTML & "          <li><a href='product/main.asp?mnid=" & trim(rSub("id")) & "&WindowName=" & trim(rSub("mn_name")) & "' target=main>产品管理</a></li>" & vbCrLf
										FolderHTML=FolderHTML & "          <li><a href='product/order_list.asp?mnid=" & trim(rSub("id")) & "&WindowName=" & trim(rSub("mn_name")) & "' target=main>订单管理</a></li>" & vbCrLf
										FolderHTML=FolderHTML & "        </ul>" & vbCrLf
									'====================
									
									case "04"
										'公司新闻
										FolderHTML=FolderHTML & "        <li id=foldheader>-" & trim(rSub("mn_name")) & "</li>" & vbCrLf
										FolderHTML=FolderHTML & "        <ul id=foldinglist style=display:none>" & vbCrLf
										FolderHTML=FolderHTML & "          <li><a href='class/main.asp?mnid=" & trim(rSub("id")) & "&TableName=web_news_class&WindowName=" & trim(rSub("mn_name")) & "' target=main>新闻分类</a></li>" & vbCrLf
										FolderHTML=FolderHTML & "          <li><a href='news/main.asp?mnid=" & trim(rSub("id")) & "&WindowName=" & trim(rSub("mn_name")) & "' target=main>新闻管理</a></li>" & vbCrLf
										FolderHTML=FolderHTML & "        </ul>" & vbCrLf
									case "05"
										'公司招聘
										FolderHTML=FolderHTML & "        <li id=foldheader><a href='job/main.asp?mnid=" & trim(rSub("id")) & "&WindowName=" & trim(rSub("mn_name")) & "' target='main'>-" & trim(rSub("mn_name")) & "</a></li>" & vbCrLf
									case "06"
										'留言板
										FolderHTML=FolderHTML & "        <li id=foldheader><a href='guestbook/guestbook.asp?mnid=" & trim(rSub("id")) & "&WindowName=" & trim(rSub("mn_name")) & "' target='main'>-" & trim(rSub("mn_name")) & "</a></li>" & vbCrLf
										'公司介绍
										FolderHTML=FolderHTML & "        <li id=foldheader><a href='aboutme/aboutme.asp?mnid=" & trim(rSub("id")) & "&WindowName=" & trim(rSub("mn_name")) & "' target='main'>-" & trim(rSub("mn_name")) & "</a></li>" & vbCrLf
								end Select
							
							end if
							rSub_tm.close
							set rSub_tm=nothing
							
							rSub.movenext
						next
						rSub.close
						
						'-----------------------------------------------------------------
						
					rsMenu.movenext

				next
		

				rsMenu.close
				set rsMenu=nothing
				
			 '3、写文件admin/folder.asp,
				JsFile=Server.MapPath( "home/" & strUserName  & "/admin/folder.asp" )
				set objTextFile=fs.OpenTextFile(JsFile,2)
				objTextFile.WriteLine FolderHTML
				objTextFile.close
				Set objTextFile = nothing
		
			 '4、生成用户站点配置文件Config.asp
				strCode="<" & chr(37) & vbCrLf
				strCode=strCode & "'用户网站常量表" & vbCrLf
				'strCode=strCode & "Const WebUserID=" & strUserID &  "			'网站用户ID号，对应于member表中的ID字段
				strCode=strCode & "Const WebUserID=0" & vbCrLf
				strCode=strCode & "Const WebUserName=""" & strUserName & """" & vbCrLf
				strCode=strCode & "Const WebSiteID=0" & vbCrLf							'网站ID号，对应于website表的ID字段
				strCode=strCode & "Const HomePage=""" & strHomePage & """" & vbCrLf			'网站首页URL"
				strCode=strCode & "Const HomeId=""" & strHomeId & """" & vbCrLf			'网站首页id"
				
				
				'记录用户网站所属的WEB服务器，调用编辑器时用到
				MyWebUrl=request.ServerVariables("SERVER_NAME")
				if request.ServerVariables("SERVER_PORT")<>"" And request.ServerVariables("SERVER_PORT")<>"80" then
					MyWebUrl=MyWebUrl & ":" & request.ServerVariables("SERVER_PORT")
				end if
				MyWebUrl="http://" & MyWebUrl
				strCode=strCode & "Const WebServer=""" & MyWebUrl & """" & vbCrLf			'网站所使用的服务器"
				
				strCode=strCode & "'-----------------网站属性------------------------" & vbCrLf
				strSQL="Select * From attrib Where m_id=" & strUserID
				set rSub=Server.CreateObject("ADODB.RecordSet")
				rSub.open strSQL,conn,1,1
				for n=1 to rSub.recordcount
					strCode=strCode &  rSub("k_type") & "_" & rSub("k_name") & "=""" & rSub("k_value") & """" & vbCrLf
					rSub.movenext
				Next
				rSub.close
				
				
				strCode=strCode & "'-----------------可编辑菜单数组------------------------" & vbCrLf
				strCode=strCode & "Dim arrMenu()" & vbCrLf
				strCode=strCode & "Dim arrMenu_id()" & vbCrLf
				strCode=strCode & "Dim arrMenu_code()" & vbCrLf
				strCode=strCode & "Dim arrMenu_href()" & vbCrLf
				strSQL="Select * From v_menu Where m_id=" & strUserID & " And mn_enable<>0 And l_editor<>'NO'"
				set rSub=Server.CreateObject("ADODB.RecordSet")
'				response.Write(strSQL)
				rSub.open strSQL,conn,1,1
				strCode=strCode & "ReDim arrMenu(" & rSub.recordcount & ")" & vbCrLf			
				strCode=strCode & "ReDim arrMenu_id(" & rSub.recordcount & ")" & vbCrLf			
				strCode=strCode & "ReDim arrMenu_code(" & rSub.recordcount & ")" & vbCrLf			
				strCode=strCode & "ReDim arrMenu_href(" & rSub.recordcount & ")" & vbCrLf			
				for i=1 to rSub.recordcount
                        strCode=strCode & " arrMenu(" & i & ")=""" & trim(rSub("mn_name")) & """" & vbCrLf
                        strCode=strCode & " arrMenu_id(" & i & ")=""" & trim(rSub("id")) & """" & vbCrLf
                        strCode=strCode & " arrMenu_code(" & i & ")=""" & trim(rSub("l_code")) & """" & vbCrLf
                        strCode=strCode & " arrMenu_href(" & i & ")=""" & trim(rSub("mn_href")) & """" & vbCrLf
					rSub.movenext
				next
				rSub.close

				
				strCode=strCode & chr(37) & ">" & vbCrLf
				
				set objTextFile=fs.OpenTextFile(Server.MapPath( "home/" & strUserName & "/const.asp" ),2)
				objTextFile.WriteLine strCode
				objTextFile.close



				'Top.asp要单独处理
				if fs.FileExists(OldFolderName & "/top.asp") then
					fs.CopyFile OldFolderName & "/top.asp",CreateFolderName & "/top.asp",True
				End if
								
	Else
				'把init.JS菜单配置部份取出，下面和语言配置一起写到init.js
				JsFile=Server.MapPath( "home/" & strUserName  & "/common/init.js" )
				set objTextFile=fs.OpenTextFile(JsFile,1)
				strAllText=objTextFile.ReadAll
				objTextFile.close
				pn=instr(strAllText,"//处理多语言问题")
				strStarText=left(strAllText,pn-1)
			
	End if
	'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	
		'判断生成语言菜单配置文件init.js的条件
		if request.QueryString("js")="1" then
									
				'处理多语言问题
				pn=instr(strUserName,"_")
				if pn>0 then
					strGBName=left(strUserName,pn-1)
				else
					strGBName=strUserName
				end if
				
				strJsText=strJsText & vbCrLf & "//处理多语言问题"  & vbCrLf
				strDoMain=request.ServerVariables("SERVER_NAME")
				if request.ServerVariables("SERVER_PORT")<>"" then
					strDoMain=strDoMain & ":" & request.ServerVariables("SERVER_PORT")
				end if
				strDoMain="http://" & strDoMain & "/Home/" & strGBName
				
				'中文简体
				strSQL="Select w_domain From v_website Where m_name='" & strGBName & "'"
				Set rsSub=Server.CreateObject("ADODB.RecordSet")
				rsSub.open strSQL,conn,1,1
				if rsSub.RecordCount>0 then
					if Trim(rsSub("w_domain"))="" then
						strJsText=strJsText & "	lgGB2312=""" & strDoMain & """;" & vbCrLf
					else
						strJsText=strJsText & "	lgGB2312=""" & Trim(rsSub("w_domain")) & """;" & vbCrLf
					end if
				else
					strJsText=strJsText & "	lgGB2312=null;" & vbCrLf
				end if
				rsSub.Close
				
				'中文繁体
				strSQL="Select w_domain From v_website Where m_name='" & strGBName & "_Big5'"
				Set rsSub=Server.CreateObject("ADODB.RecordSet")
				rsSub.open strSQL,conn,1,1
				if rsSub.RecordCount>0 then
					if Trim(rsSub("w_domain"))="" then
						strJsText=strJsText & "	lgBig5=""" & strDoMain & "_Big5"";" & vbCrLf
					else
						strJsText=strJsText & "	lgBig5=""" & Trim(rsSub("w_domain")) & """;" & vbCrLf
					end if
				else
					strJsText=strJsText & "	lgBig5=null;" & vbCrLf
				end if
				rsSub.Close
				
				strSQL="Select w_domain From v_website Where m_name='" & strGBName & "_Eng'"
				Set rsSub=Server.CreateObject("ADODB.RecordSet")
				rsSub.open strSQL,conn,1,1
				if rsSub.RecordCount>0 then
					if Trim(rsSub("w_domain"))="" then
						strJsText=strJsText & "	lgEnglish=""" & strDoMain & "_Eng"";" & vbCrLf
					else
						strJsText=strJsText & "	lgEnglish=""" & Trim(rsSub("w_domain")) & """;" & vbCrLf
					end if
				else
					strJsText=strJsText & "	lgEnglish=null;" & vbCrLf
				end if
				rsSub.Close
				
				strSQL="Select w_domain From v_website Where m_name='" & strGBName & "_Kor'"
				Set rsSub=Server.CreateObject("ADODB.RecordSet")
				rsSub.open strSQL,conn,1,1
				if rsSub.RecordCount>0 then
					if Trim(rsSub("w_domain"))="" then
						strJsText=strJsText & "	lgKorean=""" & strDoMain & "_Kor"";" & vbCrLf
					else
						strJsText=strJsText & "	lgKorean=""" & Trim(rsSub("w_domain")) & """;" & vbCrLf
					end if
				else
					strJsText=strJsText & "	lgKorean=null;" & vbCrLf
				end if
				rsSub.Close
				
				strSQL="Select w_domain From v_website Where m_name='" & strGBName & "_Jap'"
				Set rsSub=Server.CreateObject("ADODB.RecordSet")
				rsSub.open strSQL,conn,1,1
				if rsSub.RecordCount>0 then
					if Trim(rsSub("w_domain"))="" then
						strJsText=strJsText & "	lgJapanese=""" & strDoMain & "_Jap"";" & vbCrLf
					else
						strJsText=strJsText & "	lgJapanese=""" & Trim(rsSub("w_domain")) & """;" & vbCrLf
					end if
				else
					strJsText=strJsText & "	lgJapanese=null;" & vbCrLf
				end if
				rsSub.Close
				
				
			 '5、写文件Init.js
				JsFile=Server.MapPath( "home/" & strUserName  & "/common/init.js" )
				set objTextFile=fs.OpenTextFile(JsFile,2)
				objTextFile.WriteLine strStarText & strJsText & strEndText
				objTextFile.close
		End if		
			
		'=============================================================================
		'第三步，根据网页符号替换真实的内容
		'=============================================================================
		
		
			Set UserFolder=fs.GetFolder(Server.MapPath( "home/" & strUserName))
			For Each objTextFile In UserFolder.Files
				if Right(objTextFile.Name,4)=".htm" Or Right(objTextFile.Name,4)=".asp" then
					'执行替换
					Call ReplaceAllSymbol(objTextFile.Path)
				end if
			next
			
		'=============================================================================
		'第四步，复制计数器图片
		'=============================================================================
			strcounterType=GetKey("Type",strUserID,"counter")
			if strcounterType<>"Null" then
				dPicFolder="home/" & strUserName & "/admin/count"
				dPicFolder = Server.MapPath( dPicFolder )
				sPicFolder = Server.MapPath( "Templet/pic/counter/" & strcounterType )
				response.write sPicFolder&"<br>"
				response.write dPicFolder
				fs.CopyFolder  sPicFolder ,  dPicFolder
			end if
			
		'=============================================================================
		'万大欢喜，完成网站的生成，庆祝一下^0^^0^！
		'=============================================================================
			Set fs = nothing
end sub

		
'根据模板中的栏目文件生成用户网站中的文件
sub CreateLanMu(strSource,strDestination)
		if instr(strDestination,"/")>0 then
			exit sub 
		end if
		SrcFileName = Server.MapPath( "Templet/" & strWebTemplet & "/" & strSource )
		DestFileName = Server.MapPath( "home/" & strUserName & "/" & strDestination )
		
		if fs.FileExists(SrcFileName) then
			fs.CopyFile SrcFileName,DestFileName,True
		end if
end sub

'替换网页中的内容conntent
sub ReplaceSymbol(fileHTML,strOld,strReplace)
	if Not fs.FileExists(fileHTML) then
		Exit Sub
	end if
	
	'打开文件，并取得网页HTML代码
	set objTextFile=fs.OpenTextFile(fileHTML,1)
		strHTMLText=objTextFile.ReadAll

	objTextFile.close
	
	'循环替换符号
	strHTMLText= Replace(strHTMLText, strOld, strReplace) 
	
	'替换完毕，写回文件
	set objTextFile=fs.OpenTextFile(fileHTML,2)
		objTextFile.WriteLine strHTMLText
		objTextFile.close
	Set objTextFile = nothing
end sub


'替换网页中的特定符号,如LOGO，BANNER等
'参数说明:fileHTML--将要进行替换的文件名称
sub ReplaceAllSymbol(fileHTML)
	if Not fs.FileExists(fileHTML) then
		Exit Sub
	end if
	'打开文件，并取得网页HTML代码
	set objTextFile=fs.OpenTextFile(fileHTML,1)
	strHTMLText=objTextFile.ReadAll
	objTextFile.close
	
	'替换LOGO
	strHTMLText= Replace(strHTMLText, "⑨logo⑨", strWebLogo)
		
	strHTMLText= Replace(strHTMLText, "⑨company⑨", strWebCompany)
	
	strHTMLText= Replace(strHTMLText, "⑨banner⑨", strWebBanner)
	
	'替换网站标题
	strHTMLText= Replace(strHTMLText, "⑨title⑨", strWebTitle)
	
	'替换网站脚注
	strHTMLText= Replace(strHTMLText, "⑨footnote⑨", strWebFootNote)
		
	'替换ICP
	strHTMLText= Replace(strHTMLText, "⑨ICP⑨", strWebICP)

	'替换完毕，写回文件
	set objTextFile=fs.OpenTextFile(fileHTML,2)
	objTextFile.WriteLine strHTMLText
	objTextFile.close
	Set objTextFile = nothing
end sub

'更换模板后，检查栏目可用性
Sub ChangeTemplet()
	'模板没有栏目设置为禁用
	strSQL="Select tm_href,mn_enable From v_menu_templet Where m_id=" & strUserID & " Order by mn_index"
	set rsMenu=Server.CreateObject("ADODB.RecordSet")
	rsMenu.open strSQL,conn,1,3
	for i=1 to rsMenu.recordcount
		strFileHTML=Server.MapPath( "templet/" & strWebTemplet & "/" & trim(rsMenu("tm_href")))
		if fs.FileExists(strFileHTML) then
			rsMenu("mn_enable")=1
		Else
			rsMenu("mn_enable")=0
		end if
		rsMenu.update
		'response.Write(strFileHTML & "|")
		rsMenu.movenext
	Next
	rsMenu.close
End Sub

%>