<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% 
' +----------------------------------------------------------------------
' | KCMS [ 启点在线网站管理系统 ]
' | Copyright (c) 2018 http://www.kelvinvt.com All rights reserved.
' | Licensed ( http://www.kelvinvt.com )
' | Author: kelvinvt <kelvinvt@qq.com>
' +----------------------------------------------------------------------
	option explicit
	Response.CodePage=65001
	session.codepage=65001
	response.charset="utf-8"
	server.scripttimeout=999999
	dim dbquery:dbquery=0
	dim startime:startime=timer()
	dim sqltime:sqltime=now()
	set fso=createobject("scripting.filesystemobject") 
	set stm=server.createobject("adodb.stream")
	dim ZReg,Run_time
	Set ZReg = new RegExp
	ZReg.IgnoreCase = True
	ZReg.Global = True
	Run_time = timer()
%>
<!--#include file="../config/cms_Config.asp"-->
<!--#include file="../gbook/gbook_config.asp"-->
<!--#include file="cms_db.asp"-->
<!--#include file="cms_cache.asp"-->
<!--#include file="cms_mian.asp"-->
<!--#include file="cms_json.asp"-->
<!--#include file="cms_md5.asp"-->
<!--#include file="cms_version.asp"-->
<%if ISINSTALL=0 and isfolder("install/") then alertgo "网站尚未安装，点击确定进入安装界面","install/"%>
<%
dim Zset : set Zset=new SettingClass
Class SettingClass
	Public Lid, LName, LPath, Alias, PcTemplate,WapTemplate, PchtmlPath,WaphtmlPath, siteTitle, additionTitle, SitePcLogo,SiteWapLogo, siteUrl,siteWapUrl, companyName, companyAddress, companyPostCode, companyMapPoint,companyContact, companyTel, companyMobile, companyFax, companyEmail, companyICP, statisticalCode, copyRight, SiteKeys, siteDesc, LOrder,errid,errdes,qq,weixin,Lwappath,IsDefault
	
	Private Sub Class_Initialize
		SettingInit		
	End Sub
	
	Public Sub SettingInit
		dim rs
		set rs=dbsql("select * from [dbpre]Language where IsDefault=1")
		if  not isfile(sitepath&dbpath&dbfile) and dbType=0 then die "未正确连接数据库，未找到数据库"&sitepath&dbpath&dbfile&"<br>请检查配置文件设置config/cms_Config.asp"		
		if not rs.eof then
			Lid=rs("LID")
			Lname=repnul(rs("L_Name"))
			LPath=repnul(rs("L_Path"))
			Lwappath=replacestr(LPath,"/","wap/")
			IsDefault=isnum(rs("IsDefault"))
			lOrder=repnul(rs("L_Order"))
			Alias=repnul(rs("L_Alias"))
			PcTemplate=repnul(rs("PcTemplate"))
			WapTemplate=repnul(rs("WapTemplate"))
			PchtmlPath=repnul(rs("PchtmlPath"))
			WaphtmlPath=repnul(rs("WaphtmlPath"))
			siteTitle=repnul(rs("siteTitle"))
			SiteKeys=repnul(rs("SiteKeys"))
			SiteDesc=repnul(rs("SiteDesc"))
			additionTitle=repnul(rs("additionTitle"))
			SitePcLogo=repnul(rs("SitePcLogo"))
			SiteWapLogo=repnul(rs("SiteWapLogo"))
			siteUrl=repnul(rs("siteUrl"))
			siteWapUrl=repnul(rs("siteWapUrl"))
			companyName=repnul(rs("companyName"))
			companyAddress=repnul(rs("companyAddress"))
			companyPostCode=repnul(rs("companyPostCode"))
			companyMapPoint=repnul(rs("companyMapPoint"))
			companycontact=repnul(rs("companyContact"))
			companyTel=repnul(rs("companyTel"))
			companyMobile=repnul(rs("companyMobile"))
			companyFax=repnul(rs("companyFax"))
			companyEmail=repnul(rs("companyEmail"))
			companyICP=repnul(rs("companyICP"))
			qq=repnul(rs("qq"))
			weixin=repnul(rs("weixin"))			
			statisticalCode=repnul(rs("statisticalCode"))
			copyRight=repnul(rs("copyRight"))	
		else
			echo "数据库连接错误"
		end if
	End Sub	
	Public Sub Class_Terminate	
	End Sub
End Class
'echop request.serverVariables("URL")&"act:"&act&"　Location:"&Location&"　SID:"&SID&"　id:"&id&"　page:"&page
sub toLocation(act,Location)
	dim data
	if not isnul(act) then  
		call selectact(act)
	elseif not isnul(Location) then  
		call selectLocation(Location)
	else
		Call Zhl.Run_index
	end if
end sub

sub selectact(str)
	Select Case str
		Case "login","reg","forget"							:	Run_usering
		Case "userinfo","useredit","userpwd","favorites"	:	Run_user
		Case "gbooking"	:	gbooking		
		Case "getcity"	: 	showaddress
		Case "editface"	:	editface
		Case "saveface"	:	saveface
		Case "logining"	:	logining
		Case "reging"	:	reging	
		Case "forgeting" : 	forgeting
		Case "edituser"	:	edituser
		Case "editpwd"	:	editpwd
		Case "loginout"	:	loginout
		case else :  call selectLocation(Location)
	End Select		
end sub
sub selectLocation(str)
	if Asc(left(CPageName,1))<91 and Asc(left(CPageName,1))>64 then
		if dbcount("[dbpre]sort","S_URL='"&CPageName&"' and S_onoff=1")>0 then
			dim data : data=dbload("[dbpre]sort","sid,S_type",1,"S_URL='"&CPageName&"' and S_onoff=1","")
			sid=data(0,0)	
			if ifstrin("product,news,photo,case,down,job,video",data(1,0)) then
				Location="list"
			else
				Location=data(1,0)
			end if
		end if
	end if
	if ifPageName(CPageName) then						
		data=dbload("[dbpre]content","C_sid,CID",1,"C_pagename='"&CPageName&"'","")
		sid=data(0,0)
		id=data(1,0)
	end if
	Select Case Location
		Case "about"	:	Call Zhl.Run_about(SID,Page)
		Case "brand"	:	Call Zhl.Run_brand(id,page)
		Case "list","screen","brandlist"	:	Call Zhl.Run_list(Location,SID,Page)
		Case "tag"		:	Call Zhl.Run_tag(Location,Page)		
		Case "product","news","photo","case","down","job","video","content"	:	Call Zhl.Run_content(Location,sid,id,page)	
		Case "search"	:	Call Zhl.Run_search(Location,SID,Page)		
		Case "comment"	:	Call Run_comment(Location,SID,Page)
		Case "submission"	:	Call Run_submission
		Case "user"		:	Call Run_user
		Case "shop"		:	Call Run_shop
		Case "gbook"	:	Call Zhl.Run_gbook
		Case "form"		:	Call Zhl.Run_form(id)
		Case "bbs"		:	Call Run_bbs		
		case replace(adminPath,"/","")	:	aspgo sitepath&adminPath&"login.asp"
		Case else	:	Call Zhl.Run_index
		'case else  : echop request.serverVariables("URL")&"act:"&act&"　Location:"&Location&"　SID:"&SID&"　id:"&id&"　page:"&page
	End Select
end sub
	
	dim siteUrl,linkmark,actmark
	if runMode>1 then  
	  linkmark=""
	  actmark=""
	 else 
	  linkmark="?"
	  actmark="?act="
	 end if
	siteUrl=zset.siteUrl
	if isnul(siteUrl) then	
		if not right(siteUrl,1)="/" then siteUrl=siteUrl&"/"
	end if
	if isnul(sitepath) then
	sitepath="/"
	else
		if not right(sitepath,1)="/" then sitepath=sitepath&"/"
	end if
	if isnul(upLoadPath) then
	upLoadPath="upload/"
	else
		if not right(upLoadPath,1)="/" then upLoadPath=upLoadPath&"/"
	end if
	if isnul(dbPath) then
	dbPath="upload/"
	else
		if not right(dbPath,1)="/" then dbPath=dbPath&"/"
	end if
	
%>

