<%
Response.Addheader "Content-Type","text/html; charset=gb2312"
%><!--#include file="inc/SF_Sql.asp"-->
<%
dim cnmaips,bqz
cnmaips="cnmai784512":bqz="MX_":jiam=0
set conn=server.createobject("adodb.connection")
mypath="/data/sunzom_mcs.mdb"
'conn.open "provider=microsoft.jet.oledb.4.0;data source=" & mypath
conn.open "dbq="+server.mappath(mypath)+";defaultdir=;driver={microsoft access driver (*.mdb)};uid=;password="&cnmaips&";"


sub chksun1()
if request.Cookies("sunzom_username")="" then
  response.redirect "index.asp"
  response.end
end if
end sub

sub chksunzom()
if (request.Cookies("sunzom_username")="" or  request.Cookies("sunzom_id")="") then
Response.Write "<script language='javascript'>alert('登录超时或用户不存在！');window.location.href='/';</script>":Response.end
end if
end sub

sub chkout()
Response.Cookies("sunzom_userhao")="":Response.Cookies("sunzom_username")="":Response.Cookies("sunzom_id")="":Response.Cookies("sunzom_zu")=""
Session("sunzom_key0")="":Session("sunzom_key1")="":Session("sunzom_key2")=""
end sub

sql="select * from config"
set rs_config=conn.execute(sql)
dianming=rs_config("dianming"):gsname=rs_config("gsname"):gszhang=rs_config("gszhang"):gonggao=rs_config("gonggao"):maxrecord=rs_config("maxrecord"):cdjg=rs_config("cdjg")
allsx=rs_config("allsx"):xtmrmx=rs_config("xtmrmx"):regma=rs_config("regma"):syssj=rs_config("syssj"):xtuser=rs_config("xtuser")
smsxx=split(rs_config("smsxx")&"|||","|"):smsuser=smsxx(0):smskey=smsxx(1)
webtit=rs_config("webtit"):webkeys=rs_config("webkeys"):webdes=rs_config("webdes")

if syssj="" or isnull(syssj) then syssj=date()
mrcmg=split(rs_config("mrcmg")&"||||","|")
rs_config.Close
Set rs_config = Nothing
mrchang=chk0(mrcmg(0)):mrgao=chk0(mrcmg(1)):mrmaxzi=chk0(mrcmg(2))
if mrchang=0 then mrchang=60
if mrgao=0 then mrgao=40
if mrmaxzi=0 then mrmaxzi=255

nowid_login=request.Cookies("sunzom_username")
nowuserhao=request.Cookies("sunzom_userhao")
nowid_loginid=request.Cookies("sunzom_id")
webabc=Request.ServerVariables("Server_Name")
webwj=Request.ServerVariables("URL")

if nowid_login<>"" and nowid_loginid<>"" then
sql="select * from login where username='"&nowid_login&"' and id="&nowid_loginid&""
set rs_login=conn.execute(sql)
nowuserid=rs_login("id")
quanxs=rs_login("quanxian")
if nowuserid=1 then quanxs=quanxs&",cxtk,zxtj,sxtc,xxtg,sxth,x0t,x1t,x2t,x3t,x4t,x5t,x6t,x7t,x8t,x9t,qxtx"
nowqx=quanxs
nowuserhao=rs_login("bianhao")
nowuser=rs_login("username")
if chk0(rs_login("id_zu"))>0 and nowuserid<>1 then nowzu=cdatx("zu","zu_login","where id="&rs_login("id_zu")&"") else nowzu="系统账号"
nowzw=rs_login("zuzw"):nowxs=rs_login("xsuser"):myrcwork=rs_login("rcwork")
nowusertel=rs_login("tel"):nowusersfz=rs_login("sfz"):nowuserqq=rs_login("qq"):nowuseremail=rs_login("email")
nowcomtel=rs_login("comtel"):nowcomname=rs_login("comname"):nowcomdizhi=rs_login("comadr")
rs_login.close:set rs_login=nothing
end if

usershu=conn.execute("select count(id) from login where id>1")(0)

'随机数-digits位数
function gen_key(digits)
dim rndnum,num
Randomize
Do while Len(rndnum)<digits
num = Cstr(Chr((57-48)*rnd+48))
rndnum = rndnum & num
Loop
gen_key = rndnum
End function

nowbianhao=replace(replace(replace(replace(replace(replace(FormatDateTime(now(),0),":","")," ",""),"-",""),"/",""),"上午",""),"下午","")
nowbianhao=nowbianhao&""&gen_key(4)&""  '按时间生成流水号

''Request过滤
Function RequestA(strRequest)
'if isnaw(strRequest) then
RequestA = trim(Request(strRequest))
'else
'RequestA = trim(utf2gb(Request(strRequest)))
'end if

'	if RequestA="" or isnull(RequestA) then  RequestA=0
	dim Lstring,BadWord,BadWords,HaveBadWord,UserWord
	If Not isNumeric(Requesta) and Requesta<>"" Then
		Lstring=Lcase(Requesta)
		BadWord="exec master,net user,cmd.exe,insert ,xp_cmdshell, mid,update ,select ,',delete ,drop "
		BadWord=BadWord & ", char, unicode, asc, left, and, or,where ,backup , chr,nchar(,nchar ("
		BadWord=BadWord & ", substring"
		BadWords=split(BadWord,",")
		HaveBadWord=false
		for each UserWord In BadWords
			if inStr(Lstring,UserWord)>0 then
				HaveBadWord=True
				Exit For
			end if
		next
		if HaveBadWord then
			Requesta=Lstring
			for each UserWord in BadWords
			  if inStr(Lstring,UserWord)>0 then
				Requesta=Replace(Requesta,UserWord,vbNullString)
			  end if
			next
		end if
	   Requesta=Trim(Requesta)
	End If
End Function

Function utf2gb(Body)
Dim Objstream
Set Objstream = Server.CreateObject("adodb.stream")
objstream.Charset = "utf-8"
objstream.Type = 2
objstream.Mode =3
objstream.Open
objstream.WriteText body
objstream.Position = 0
objstream.Charset = "gb2312"
objstream.Type = 2
utf2gb = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

function  isnaw(str) 
for  i=1  to  len(str) 
str1=mid(str,i,1) 
if  isnumeric(str1)   then   isn=1 
if  (Asc(str1)> Asc( "a ") and  Asc(str1) <Asc( "z ")) or (Asc(str1)> Asc( "A ") and Asc(str1) <Asc( "Z ")) then isw=1 
next 
if isn=1 and isw=1 then 
isnaw=true 
else 
isnaw=false 
end if 
end function 

'去除HTML代码,去除空格,
function nohtml(str) 
dim re 
'str=replace(replace(str,"<br>",vbcrlf),"<BR>",vbcrlf)'就是把它换成vbscript的换行就行了 
str=Replace(str,"&nbsp;","")
str=Replace(str," ","")
Set re=new RegExp 
re.IgnoreCase =true 
re.Global=True 
re.Pattern="(\<.[^\<]*\>)" 
str=re.replace(str," ") 
re.Pattern="(\<\/[^\<]*\>)" 
str=re.replace(str," ")
nohtml=str 
set re=nothing 
end function 

function HTMLEncode(fString)
if not isnull(fString) then
fString = replace(fString, ">", "&gt;")
fString = replace(fString, "<", "&lt;")
fString = Replace(fString, CHR(32), "&nbsp;")
fString = Replace(fString, CHR(9), "&nbsp;")
fString = Replace(fString, CHR(34), "&quot;")
fString = Replace(fString, CHR(39), "&#39;")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
fString = Replace(fString, CHR(10), "<BR> ")
HTMLEncode = fString
end if
end function

   Function CheckStr(Strer,Num)
        Dim Shield,w
	    If Strer = "" Or IsNull(Strer) Then Exit Function
	    Select Case Num
		  Case 0
			Strer = Trim(Strer)
			Strer = Replace(Strer,CHR(39),"&#39;")     '单引号
            Strer = Replace(Strer,CHR(34),"&quot;")    '双引号
            Strer = Replace(Strer,CHR(32),"&nbsp;")    '空格
           Strer = Replace(Strer,CHR(13),"<br>")    '回车
'            Strer = Replace(Strer,"<br>","")    '回车
            Strer = Replace(Strer,CHR(60),"&lt;")      '<
            Strer = Replace(Strer,CHR(62),"&gt;")      '>
            Strer = Replace(Strer,vbCrLf,"<br>")       
		  Case 1
	        If IsNumeric(Strer) = 0 Then
	          Response.Write "操作错误"
	          response.write "<meta http-equiv=refresh content=""2;URL=/index.asp"">"
		      Response.End
	        End If
			Strer = Int(Strer)
		  Case 2 '文本域提交
'			Strer = Replace(Strer,CHR(39),"&#39;")     '单引号
'            Strer = Replace(Strer,CHR(34),"&quot;")    '双引号
'            Strer = Replace(Strer,CHR(32),"&nbsp;")    '空格
            Strer = Replace(Strer,CHR(13),"<br>")    '回车
'            Strer = Replace(Strer,CHR(60),"&lt;")      '<
'            Strer = Replace(Strer,CHR(62),"&gt;")      '>
'            Strer = Replace(Strer,vbCrLf,"<br>")       
		  Case 3 '文本域显示
'			Strer = Replace(Strer,"&#39;",CHR(39))     '单引号
'            Strer = Replace(Strer,"&quot;",CHR(34))    '双引号
'            Strer = Replace(Strer,"&nbsp;",CHR(32))    '空格
            Strer = Replace(Strer,"<br>",CHR(13))    '回车
'            Strer = Replace(Strer,"&lt;",CHR(60))      '<
'            Strer = Replace(Strer,"&gt;",CHR(62))      '>
          Case 4
'            Strer = Replace(Strer,"<br>",",")
            Strer = Replace(Strer,"&nbsp;","")    '空格
            Strer = Replace(Strer," ","")    '空格    
            Strer = Replace(Strer,CHR(32)," ")    '空格    
            Strer = Replace(Strer,CHR(10)," ")    '空格    
            Strer = Replace(Strer,CHR(13)," ")    '空格
    
		  Case 5
			Strer = Trim(Strer)
			Strer = Replace(Strer,CHR(39),"&#39;")     '单引号
            Strer = Replace(Strer,CHR(34),"&quot;")    '双引号
            Strer = Replace(Strer,CHR(32),"&nbsp;")    '空格
            Strer = Replace(Strer,CHR(13),"<br>")    '回车
            Strer = Replace(Strer,CHR(60),"&lt;")      '<
            Strer = Replace(Strer,CHR(62),"&gt;")      '>
            Strer = Replace(Strer,vbCrLf,"<br>")   

		End Select

	    CheckStr = Strer
   End Function


''检测空值返回0
Function chk0(dd)
if dd="" or isnull(dd) then  chk0=0 else chk0=dd
End Function

''检测审核显示
Function chksh(dd)
if dd="" or isnull(dd) then  chksh="未审" else chksh="通过"
End Function

''检测管理权限返回1
Function chkqx1(id,qx) '管理权限
if id="" or isnull(id) then  
chkqx1=0 
else 
chkqx1=qx
if request.Cookies("sunzom_id")="1" then chkqx1=1
end if
End Function

''是否结账返回数值
Function jieok(jj)
if jj="" or isnull(jj) or jj=0 then  
jieok="未结"
else 
jieok="已结"
end if
End Function

''============================
''涵数名：CheckTable                        
''参　数：myTable 要判断的表
''作　用：判断数据库中是否存在指定的表
''============================
Function CheckTable (myTable)
'列出数据库中的所有表
dim rs,getTableName
set rs=conn.openSchema(20) 
rs.movefirst 
do Until rs.EOF 
if rs("TABLE_TYPE")="TABLE" then 
   'response.write rs("TABLE_NAME") & ","
   getTableName=getTableName+rs("TABLE_NAME")&","
end if 
rs.movenext
loop
rs.close
set rs=nothing


'判断数据库中是否存在此表(下面两行代码使待比较表和指定表前后都加上豆号，以精确比较)
dim getTableName2,myTable2
getTableName2=","&getTableName '此字符串后面已经有豆号
myTable2=","&myTable&","
If instr(getTableName2,myTable2)<>0 Then
   CheckTable=1 '存在
else
   CheckTable=0 '不存在
end if

End Function


''============================
''涵数名：CheckFields     
''参　数：myTable 要判断的表   
''参　数：myFields 要判断的字段 
''作　用：判断表中是否存在指定的字段
''============================
Function CheckFields (myTable,myFields)

'如果表存在继续执行，否则跳过
if CheckTable (myTable)=1 then
   dim rs,i,getFieldsName
   '列出表中的所有字段
   set rs=conn.execute("select * from "&myTable&"")
   for i=0   to rs.fields.count-1   
    'response.write (rs.fields(i).name & ",")
    getFieldsName=getFieldsName+rs.fields(i).name & ","
   next
   rs.close
   set rs=nothing
   'response.write(getFieldsName)
end if

'判断表中是否存在此字段(下面两行代码使待比较字段和指定字段前后都加上豆号，以精确比较)
dim getFieldsName2,myFields2
getFieldsName2=","&getFieldsName '此字符串后面已经有豆号
myFields2=","&myFields&","
if instr(getFieldsName2,myFields2)<>0 Then
   CheckFields=1 '存在
else
   CheckFields=0 '不存在
end if
End function

 '调取数据库某项数据
Function cdatx(xiang,biao,whe)
if xiang="" then xiang="*" 
sql="select "&xiang&" from "&biao&" "&whe&" " 
set rs1 =server.createobject("ADODB.RecordSet")	
rs1.open sql,conn,1,1
if rs1.recordcount>0 then
if instr(xiang,",")>0 then
ttss=split(xiang,",")
for tt=0 to Cntshu(xiang,",")
cdatx=cdatx&"/"&rs1(""&ttss(tt)&"")
next
cdatx=right(cdatx,len(cdatx)-1)
else
cdatx=rs1(0)
end if
else 
cdatx=""
end if
rs1.close:set rs1=nothing
'cdatx=Conn.Execute("select "&xiang&" from "&biao&" "&whe&" ")(0)
End Function

 '查询数据库某数据是否存在
Function chadat(xiang,biao,whe)
if xiang="" then xiang="*"
sql="select "&xiang&" from "&biao&" "&whe&" " 
set rs1 =server.createobject("ADODB.RecordSet")	
rs1.open sql,conn,1,1
if rs1.recordcount>0 then chadat=1 else chadat=0
rs1.close:set rs1=nothing
End Function

'菜单选择分类
Function cdxuan(cdid,cdcla)
dim id1,id2
temp=temp&"<select name=""cdcla"">"
temp=temp&"<option value=""0"">初始一级分类</option>"

sql="select * from SZ_cd  where cla1=0 order by cdpx desc,id asc"
set rsc1=conn.execute(sql)
if not rsc1.bof then
do while not rsc1.eof
id1=chk0(rsc1("id"))
temp=temp&"<option value="""&id1&""""
if int(id1)=int(chk0(cdcla)) then temp=temp&" selected=""selected"" "
temp=temp&">┣"&rsc1("cdname")&"</option>"

sql="select * from SZ_cd where cla1="&id1&" order by cdpx desc,id asc"
set rsc2=conn.execute(sql)
if not rsc2.bof then
do while not rsc2.eof
id2=chk0(rsc2("id"))

temp=temp&"<option value="""&rsc2("id")&""""
if int(id2)=int(chk0(cdcla)) then temp=temp&" selected=""selected"" "
temp=temp&">  --"&rsc2("cdname")&"</option>"
rsc2.movenext
loop
end if
rsc2.close:set rsc2=nothing


rsc1.movenext
loop
end if
rsc1.close:set rsc1=nothing

temp=temp&"</select>"
cdxuan=temp  
end Function


'模型选择
Function mxxuan(mxid,sttj)
dim id1
'if mxid<>"" and mxid<>0 then mxtj="id="&mxid&" and"
temp=temp&"<select name=""mxid1"" "&sttj&">"
temp=temp&"<option value=""0"">选择模型</option>"
sql="select * from SZ_mx  where "&mxtj&" mxzt=1 and bid=0 order by mxpx desc,id desc"
set rsc1=conn.execute(sql)
if not rsc1.bof then
do while not rsc1.eof
id1=chk0(rsc1("id"))
temp=temp&"<option value="""&id1&""""
if int(id1)=int(chk0(mxid)) then temp=temp&" selected=""selected"" "
temp=temp&">┣"&rsc1("mxname")&"</option>"

sql="select * from SZ_mx  where mxzt=1 and bid="&id1&" order by  mxpx desc,id desc"
set rsc4=conn.execute(sql)
if not rsc4.bof then
do while not rsc4.eof
id2=chk0(rsc4("id"))
temp=temp&"<option value="""&id2&""""
if int(id2)=int(chk0(mxid)) then temp=temp&" selected=""selected"" "
temp=temp&">├-"&rsc4("mxname")&"</option>"

sql="select * from SZ_mx  where mxzt=1 and bid="&chk0(rsc4("id"))&" order by  mxpx desc,id desc"
set rsc5=conn.execute(sql)
if not rsc5.bof then
do while not rsc5.eof
id2=chk0(rsc5("id"))
temp=temp&"<option value="""&id2&""""
if int(id2)=int(chk0(mxid)) then temp=temp&" selected=""selected"" "
temp=temp&">&nbsp;---"&rsc5("mxname")&"</option>"
rsc5.movenext
loop
end if
rsc5.close:set rsc5=nothing



rsc4.movenext
loop
end if
rsc4.close:set rsc4=nothing

rsc1.movenext
loop
end if
rsc1.close:set rsc1=nothing
temp=temp&"</select>"
mxxuan=temp  
end Function


'报表选择
Function bbxuan(bbid,sttj,leix)
sql="select * from SZ_bb order by id desc"
set rsc1=conn.execute(sql)
if not rsc1.bof then

if leix="lianj" then
do while not rsc1.eof
if instr(bbid,""&rsc1("bbma")&"")>0  then temp=temp&"<a target=""_blank""  href="""&rsc1("bburla")&""&sttj&""">"&rsc1("bbname")&"</a>"
rsc1.movenext
loop

elseif  leix="fuxuan" then
do while not rsc1.eof
temp=temp&"<input type=""checkbox"" name="""&sttj&""" value="""&rsc1("bbma")&""""
if instr(bbid,""&rsc1("bbma")&"")>0  then temp=temp&" checked "
temp=temp&" >"&rsc1("bbname")&" &nbsp;"
rsc1.movenext
loop

elseif  leix="xiala" then
temp=temp&"<select name=""bbid1"" "&sttj&">"
temp=temp&"<option value=""0"">选择报表</option>"
do while not rsc1.eof
id1=chk0(rsc1("id"))
temp=temp&"<option value="""&id1&""""
if int(id1)=int(chk0(bbid)) then temp=temp&" selected=""selected"" "
temp=temp&">"&rsc1("bbname")&"</option>"
rsc1.movenext
loop
end if
temp=temp&"</select>"
end if


rsc1.close:set rsc1=nothing
bbxuan=temp  
end Function

'部门选择
Function zuxuan(zuid,sttj)
dim id1
'if mxid<>"" and mxid<>0 then mxtj="id="&mxid&" and"
temp=temp&"<select name=""zuid"" "&sttj&">"
temp=temp&"<option value=""0"">选择分类(顶级)</option>"
sql="select * from zu_login  where bid=0 and zuzt=1 order by zupx desc,id asc"
set rsc1=conn.execute(sql)
if not rsc1.bof then
do while not rsc1.eof
id1=chk0(rsc1("id"))
temp=temp&"<option value="""&id1&""""
if int(id1)=int(chk0(zuid)) then temp=temp&" selected=""selected"" "
temp=temp&">┣"&rsc1("zu")&"</option>"

sql="select * from zu_login  where bid="&id1&" and zuzt=1 order by zupx desc,id asc"
set rsc4=conn.execute(sql)
if not rsc4.bof then
do while not rsc4.eof
id2=chk0(rsc4("id"))
temp=temp&"<option value="""&id2&""""
if int(id2)=int(chk0(zuid)) then temp=temp&" selected=""selected"" "
temp=temp&"> --"&rsc4("zu")&"</option>"
rsc4.movenext
loop
end if
rsc4.close:set rsc4=nothing
rsc1.movenext
loop
end if
rsc1.close:set rsc1=nothing
temp=temp&"</select>"
zuxuan=temp  
end Function


Function zuxuan1(zuid,sttj)
sql="select * from zu_login where zuzt=1 order by zupx desc,id asc"
set rsc2=conn.execute(sql)
if not rsc2.bof then
do while not rsc2.eof
id2=chk0(rsc2("id"))
temp=temp&"<input type=""checkbox"" name=""zuid"" value="""&id2&""""
if instr(zuid,id2)>0 then temp=temp&" checked "
temp=temp&">"&rsc2("zu")&"("&id2&")&nbsp; "
rsc2.movenext
loop
else
temp=temp&"请先添加默认职位数据！"
end if
rsc2.close:set rsc2=nothing
zuxuan1=temp  
end Function

'部门职位选择
Function zwxuan(zuzw,zwname,xzlx)
if zwname="" then zwname="zuzw"
if xzlx="duo" then 
xzlx1="checkbox"
elseif xzlx="dan"  then
xzlx1="radio"
else
xzlx1="checkbox"
end if

sql="select * from SZ_zw where zwzt=1 order by zwpx desc,id asc"
set rsc2=conn.execute(sql)
if not rsc2.bof then
do while not rsc2.eof
id2=chk0(rsc2("id"))
temp=temp&"<input type="""&xzlx1&""" name="""&zwname&""" value="""&rsc2("zwname")&""""
if instr(zuzw,rsc2("zwname"))>0 then temp=temp&" checked "
temp=temp&">"&rsc2("zwname")&"&nbsp; "
rsc2.movenext
loop
else
temp=temp&"请先添加默认职位数据！"
end if
rsc2.close:set rsc2=nothing
zwxuan=temp  
end Function

'员工选择
Function userxuan(nowuser,xsuser,zwname,xzlx)
if zwname="" then zwname="xsuser"
if xzlx="duo" then 
xzlx1="checkbox"
elseif xzlx="dan"  then
xzlx1="radio"
else
xzlx1="checkbox"
end if

sql="select * from login where userzt=1 and bianhao<>'"&nowuser&"' and id<>1 order by bianhao desc,id asc"
set rsc2=conn.execute(sql)
if xzlx="xuan" then
temp=temp&"<select name="""&zwname&""" "&xsuser&">"
if not rsc2.bof then
temp=temp&"<option value="""">请选择</option>"
do while not rsc2.eof
if xtuser=0 then usersuns=rsc2("username") else  usersuns=rsc2("bianhao")
temp=temp&"<option value="""&usersuns&""""
if instr(xsuser,usersuns&",")>0 then temp=temp&" selected=""selected"" "
temp=temp&">"&usersuns&"</option>"
rsc2.movenext
loop
else
temp=temp&"<option value="""">暂无员工</option>"
end if
temp=temp&"</select>"

else

if not rsc2.bof then
do while not rsc2.eof
if xtuser=0 then usersuns=rsc2("username") else  usersuns=rsc2("bianhao")
temp=temp&"<input type="""&xzlx1&""" name="""&zwname&""" value="""&usersuns&""""
if instr(xsuser,usersuns&",")>0 then temp=temp&" checked "
temp=temp&">"&usersuns&"&nbsp; "
rsc2.movenext
loop
else
temp=temp&"请先添加员工数据！"
end if
end if

rsc2.close:set rsc2=nothing
userxuan=temp  
end Function

'汇总菜单
Function bbcd(mxid,m1id,lx) 'lx=1下拉,lx=2横排
if lx=1 then
temp=temp&"<select name=""mxid1"" onchange=""location.href=this.options.value;"">"
temp=temp&"<option value=""?mxid="&mxid&"&m1id="&m1id&""">选择报表</option>"
sql="select * from SZ_bb  where bbzt=1 and mxid="&mxid&" order by bbpx desc,id desc"
set rsc1=conn.execute(sql)
if not rsc1.bof then
do while not rsc1.eof
id1=chk0(rsc1("id"))
temp=temp&"<option value=""/szurl.asp?bid="&id1&"&mxid="&chk0(rsc1("mxid"))&""""
if int(id1)=int(chk0(mxid)) then temp=temp&" selected=""selected"" "
temp=temp&">"&rsc1("bbname")&"</option>"
rsc1.movenext
loop
end if
rsc1.close:set rsc1=nothing
temp=temp&"</select>"
end if

if lx=2 then
sql="select * from SZ_bb  where bbzt=1 and mxid="&mxid&" order by bbpx desc,id desc"
set rsc1=conn.execute(sql)
if not rsc1.bof then
do while not rsc1.eof
id1=chk0(rsc1("id"))
if int(id1)=int(chk0(mxid)) then css1=" class=""bb"" "
temp=temp&"<input onclick=""location.href='/szurl.asp?bid="&id1&"&mxid="&chk0(rsc1("mxid"))&"'"" "&css1&" value="""&rsc1("bbname")&"""  type=button>&nbsp;"
rsc1.movenext
loop
end if
rsc1.close:set rsc1=nothing
end if
bbcd=temp  
end Function

'跟单菜单
Function gdcd(mxid,xxid,lx,bbal,xurl,m1id,m2id,cdid,x1id) 'lx=1下拉,lx=2横排
sql="select * from SZ_mx  where mxzt=1 and bid="&mxid&" and instr(bbal,'"&bbal&"')>0 order by mxpx desc,id asc"
set rsc1=conn.execute(sql)

if lx=1 then
temp=temp&"<select name=""mxid1"" onchange=""location.href=this.options.value;"">"
temp=temp&"<option value=""?mxid="&mxid&"&xxid="&xxid&""">选择报表</option>"
if not rsc1.bof then
do while not rsc1.eof
id1=chk0(rsc1("id"))
cdlx=chk0(rsc1("cdlx"))
temp=temp&"<option value=""/szurl.asp?mxid="&id1&"&xxid="&xxid&"&x1id="&x1id&""""
if int(id1)=int(chk0(mxid)) then temp=temp&" selected=""selected"" "
temp=temp&">"&rsc1("xmname")&"</option>"
rsc1.movenext
loop
end if
temp=temp&"</select>"
end if

if lx=2 then
if chk0(m1id)>0  then m0id=m1id else m0id=mxid

if chk0(m1id)>0  then

 '此处写死后续修改
'if chk0(mxid)=45 then m11id=45 else m11id=m1id
sql="select * from SZ_mx  where mxzt=1 and bid="&m1id&" and instr(bbal,'"&bbal&"')>0 order by mxpx desc,id asc"
set rsc1=conn.execute(sql)
end if
'temp=temp&sql

if not rsc1.bof then
if chk0(xxid)>0 and chk0(m1id)>0 and instr(bbal,"ao")<=0 then 
gxname=cdatx("xmname","SZ_mx","where id="&m0id&"")
temp=temp&"<a href=""/set/yw.asp?chk=edit&cdid="&cdid&"&xxid="&xxid&"&x1id="&x1id&"&mxid="&m0id&"&m1id="&m1id&"&sid="&sid&""" class=""buttona""><span>"&gxname&"修改</span></a>"
end if

do while not rsc1.eof
id1=chk0(rsc1("id")):cdlx=chk0(rsc1("cdlx")):bbala=rsc1("bbal")
if int(id1)=int(chk0(mxid)) then clab=" class=""bb"" "

mxdat0=cdatx("mxdat","SZ_mx","where id="&m0id&"")

if chadat("id",mxdat0,"order by id desc")=0  then
temp=temp&"<a onclick=""window.alert('请先录入并保存基本数据再操作此项"&xxid&"！\n\n或通过[修改或管理]再进行相关录入操作！')"" class=""buttona""><span "&clab&">"&rsc1("xmname")&"</span></a>"
else
if chadat("id",mxdat0,"order by id desc")=1 and chk0(xxid)=0 then x0id=cdatx("id",mxdat0,"order by id desc") else x0id=xxid
'if chk0(x1id)>0 then x10id=x1id else x10id=x0id
if xurl="hz" then
temp=temp&"<a href=""hz.asp?cdid="&cdid&"&mxid="&id1&"&m1id="&m0id&"&m2id="&m2id&"&xxid="&x0id&"&x1id="&x1id&"&sid="&sid&""" class=""buttona""><span "&clab&">"&rsc1("xmname")&"</span></a>"
else
temp=temp&"<a href=""/szurl.asp?cdid="&cdid&"&mxid="&id1&"&m1id="&m0id&"&m2id="&m2id&"&xxid="&x0id&"&x1id="&x1id&"&sid="&sid&"""  class=""buttona""><span "&clab&" >"&rsc1("xmname")&"</span></a>"
end if
end if
clab=""
rsc1.movenext
loop
end if
end if
rsc1.close:set rsc1=nothing
gdcd=temp
end Function


'表单类型选择
Function bdlxxuan(mxlx)
temp=temp&"<select name=""cdlx"">"
temp=temp&"<option value=""0"">选择表单类型</option>"
temp=temp&"<option value=""1"""
if int(chk0(mxlx))=1 then temp=temp&" selected=""selected"" "
temp=temp&">表单登记</option>"
temp=temp&"<option value=""2"""
if int(chk0(mxlx))=2 then temp=temp&" selected=""selected"" "
temp=temp&">数据汇总</option>"
temp=temp&"<option value=""3"""
if int(chk0(mxlx))=3 then temp=temp&" selected=""selected"" "
temp=temp&">汇总+登记(分离上)</option>"
temp=temp&"<option value=""7"""
if int(chk0(mxlx))=7 then temp=temp&" selected=""selected"" "
temp=temp&">汇总+登记(分离下)</option>"
temp=temp&"<option value=""4"""
if int(chk0(mxlx))=4 then temp=temp&" selected=""selected"" "
temp=temp&">汇总+登记(横版)</option>"
temp=temp&"<option value=""5"""
if int(chk0(mxlx))=5 then temp=temp&" selected=""selected"" "
temp=temp&">打印报表</option>"
temp=temp&"<option value=""6"""
if int(chk0(mxlx))=6 then temp=temp&" selected=""selected"" "
temp=temp&">利润统计(报表)</option>"
temp=temp&"</select>"
bdlxxuan=temp  
end Function

'默认模型,lei:fu-复选框，xia-下拉,dan-单选框
Function xzmormx(mrmxid,lei) 
select case lei
case "xia"
temp=temp&"<select name=""mormx"">"
temp=temp&"<option value=""0"">选择默认模型</option>"
sql="select * from SZ_mo"
set rsc3=conn.execute(sql)
if not rsc3.bof then
do while not rsc3.eof
temp=temp&"<option value="""&rsc3("id")&""""
if rsc3("id")=mrmxid then temp=temp&" selected "
temp=temp&">"&rsc3("moname")&"</option>"
rsc3.movenext
loop
end if
rsc3.close:set rsc3=nothing
temp=temp&"</select>"
case "fu"
sql="select * from SZ_mo"
set rsc3=conn.execute(sql)
if not rsc3.bof then
do while not rsc3.eof
id3=rsc3("id")
temp=temp&"<input type=""checkbox"" name=""mormx"" value="""&id3&""""
if instr(mrmxid,id3)>0 then temp=temp&" checked "
temp=temp&">"&rsc3("moname")&"("&id3&")&nbsp; "
rsc3.movenext
loop
end if
rsc3.close:set rsc3=nothing

case "dan"
end select
xzmormx=temp  
end Function


'菜单选择模型
Function cdmx(cdlx,cdurl,mxid,m1id,m2id,xxid,bbid,bbzq,sid,cdid,x1id,webcd)
if len(cdurl)>2 then 
cdmx=cdurl
else
select case chk0(cdlx)
case 1
if webcd=1 then
cdmx= "/web/fa.asp?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&xxid="&xxid&"&x1id="&x1id&"&sid="&sid&"" 
else
cdmx= "/set/yw.asp?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&xxid="&xxid&"&x1id="&x1id&"&sid="&sid&"" 
end if
case 2
if webcd=1 then
cdmx= "/web/info.asp?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&xxid="&xxid&"&x1id="&x1id&"&sid="&sid&"" 
else
cdmx= "/set/hz.asp?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&xxid="&xxid&"&x1id="&x1id&"&sid="&sid&"" 
end if
case 3
cdmx= "/set/hzyw.asp?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&xxid="&xxid&"&x1id="&x1id&"&sid="&sid&"" 
case 4
cdmx= "/set/hzyw1.asp?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&xxid="&xxid&"&x1id="&x1id&"&sid="&sid&"" 
case 5
cdmx= "/set/bb1.asp?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&xxid="&xxid&"&x1id="&x1id&"&sid="&sid&""
case 6
cdmx= "/set/bb2.asp?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&xxid="&xxid&"&x1id="&x1id&"&sid="&sid&""
case 7
cdmx= "/set/hzyw2.asp?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&xxid="&xxid&"&x1id="&x1id&"&sid="&sid&"" 
case else
cdmx= "/set/yw.asp?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&xxid="&xxid&"&x1id="&x1id&"&sid="&sid&"" 
end select

if chk0(bbid)>0 then
if len(bbzq)<3 then bbzq="yue"
if len(cdatx("bburla","SZ_bb","where id="&bbid&""))>3 then cdmx= ""&cdatx("bburla","SZ_bb","where id="&bbid&"")&"?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&xxid="&xxid&"&startdate="&bbzq&"&sid="&sid&"" 
end if

end if
end Function

Function dayin()
dayin="<input type=""button"" value=""打印"" onclick=""javascript:window.print();"" class=""NoPrint""/>"
end Function


''表单字段库
Function bdxuan(bdTitle,bdname,bdmoren,bdTips,bdlx,bdbjqlx,bdscok,bdscdx,bdOptions,bdShowUnit,bdUnitOptions,bdbt,bdWidth,bdMaxLength,bdHeight,zdkd,chk,edx,shux,zdhz,xxid,cusz,fuzhi)
if bdlx="" then bdlx=1
if chk0(bdWidth)=0 then bdWidth=200
if chk0(bdHeight)=0  then bdHeight=50
if chk0(zdkd)=1 then kdqk=" readonly "  'disabled不传值
if chk0(bdbt)=1 then bdTips="*"&bdTips&""   'kdqk=kdqk&" class=""required"" ":claxx="required"
if instr(bdTips,"[BX1]")>0 then 
bxxxs=split(bdTips,"==")(1)
if bxxxs="[ncomtel]" then bxxxs=replace(replace(nowcomtel,"|","§"),",","§")
if instr(bxxxs,"§")>0 then 
bxxxs1=split(bxxxs,"§")
for bs=0 to Cntshu(bxxxs,"§")
bxxxs2=bxxxs2&"<a href=""javascript:"" title=""选择填充"" onClick=""document.form1."&bdname&".value+='"&bxxxs1(bs)&",'"">"&bxxxs1(bs)&"</a> &nbsp; "
next
bdTips="←请选择："&bxxxs2&""
else
bdTips=""
end if
end if

if instr(bdTips,"[BX2]")>0 then 
bxxxs=split(bdTips,"==")(1)
if bxxxs="[ncomtel]" then bxxxs=replace(replace(nowcomtel,"|","§"),",","§")
bxxxs1=split(bxxxs,"§")
if instr(bxxxs,"§")>0 then 
for bs=0 to Cntshu(bxxxs,"§")
bxxxs2=bxxxs2&"<input href=""javascript:"" title=""选择填充"" onClick=""document.form1."&bdname&".value+='"&bxxxs1(bs)&",'""  type=""button"" value="""&bxxxs1(bs)&"""> "
next
bdTips="<br><div class=""sunbx1"">"&bxxxs2&"</div>"
else
bdTips=""
end if
end if

if instr(bdOptions,chr(13))>0 and len(bdOptions)>3 then bdOptions=replace(replace(bdOptions,chr(10),""),chr(13),"[$]")
bdmoren=morenzhi(bdmoren)

if chk="edit" then bdmr1=edx else bdmr1=bdmoren
bdTips=replace(bdTips,"**","*")

select case bdlx
case 1
'if instr(bdmoren,"|")>0 and instr(zdhz,"mohe")<=0 then xck="style=""cursor:hand;"" class=""bxm"" onClick=""JavaScript:window.open('../set/bx.asp?form=form1&field="&bdname&"&bx="&bdmoren&"&oldDate='+"&bdname&".value,'','directorys=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,width=250,height=170,top=150,left=590');""":bdmr1=edx
if instr(bdmoren,"|")>0 and instr(zdhz,"mohe")<=0 then xck="style=""cursor:hand;"" class=""bso"" onpropertychange=""fun"&bdname&"()"" onclick="""&bdname&"lst.style.display=''"" ":bdTips="<span id="""&bdname&"lst"" style=""border:solid 1px #FFB468; position:absolute;z-index:1001; padding:4px; background-color: #FFEFD7;"" style=""display:none""  onmouseover="""&bdname&"lst.style.display=''"" onmouseout="""&bdname&"lst.style.display='none'"">请输入关键词</span><script id="""&bdname&"so"" src=""""></script>"&bdTips:bdmr1=edx

if instr(bdmoren,"[diqu]")>0 then xck="style=""cursor:hand;"" class=""bso"" onclick=""city1(this);"" ":bdmr1=edx

if instr(bdmoren,"|")>0 and instr(zdhz,"mohe")>0 then
xck=" title=""系统自动汇总"""
if chk0(xxid)>0 then
bxs1=split(bdmoren,"|")
bdmr1=Conn.Execute("select sum("&bxs1(1)&") from "&bxs1(0)&" where gid="&xxid&"")(0)
else
bdmr1=0
end if 
end if 
temp="<input type=""text"" name="""&bdname&""" onFocus=""this.select();"" id="""&bdname&""" "&shux&" style=""width:"&bdWidth&"px"" value="""&bdmr1&""" "&xck&" maxlength="""&bdMaxLength&""" "&kdqk&">"&bdTips&""
case 14
temp="<input type=""password"" name="""&bdname&""" onFocus=""this.select();"" id="""&bdname&""" "&shux&" style=""width:"&bdWidth&"px"" value="""&bdmr1&""" "&xck&" maxlength="""&bdMaxLength&""" "&kdqk&">"&bdTips&""
case 2
temp="<textarea rows=""5""  cols=""42"" name="""&bdname&""" style=""width: "&bdWidth&"px; height: "&bdHeight&"px"" "&kdqk&">"&bdmr1&"</textarea>"&bdTips&""
case 3 '下拉框
temp="<select size=""1""  name="""&bdname&""" style=""width: "&bdWidth&"px"" "&kdqk&">"  'class=""combox""
if instr(bdmoren,"|")>0 then
bxs=split(bdmoren,"|")
set rsc3 = server.CreateObject ("Adodb.recordset")
sql="select * from "&bxs(0)&""
rsc3.open sql,conn,1,1
'set rsc3=conn.execute(sql)
jlshu = rsc3.RecordCount

if jlshu>1 then temp=temp&"<option>请选择</option>"

if not rsc3.bof then
do while not rsc3.eof
temp=temp&"<option value="""&rsc3(bxs(1))&""""
if rsc3(bxs(1))=bdmr1 then temp=temp&" selected "
temp=temp&">"&rsc3(bxs(1))&"</option>"
rsc3.movenext
loop
end if
rsc3.close:set rsc3=nothing
else
if bdOptions="" then bdOptions="[$]"
bdOptions=replace(bdOptions,",","[$]")
baoxz=split(bdOptions,"[$]")
for s=0 to Cntshu(bdOptions,"[$]")
if instr(baoxz(s),"|")>0 then bdxxs=split(baoxz(s),"|"):bdxx1=bdxxs(0):bdxx2=bdxxs(1) else bdxx1=baoxz(s):bdxx2=baoxz(s)
temp=temp&"<option "
if bdxx1=bdmr1 or bdxx2=bdmr1 then temp=temp&" selected "
if instr(bdxx1,"选择")>0 then bdxx1=replace(bdxx1,bdxx1,"")
temp=temp&" value="""&bdxx1&""">"&bdxx2&"</option>"
next
end if
temp=temp&"</select>"&bdTips&""
case 4
temp="<input type=""text"" name="""&bdname&""" onFocus=""this.select();"" id="""&bdname&"""  "&shux&" style=""width:"&bdWidth&"px"" value="""&bdmr1&""" maxlength="""&bdMaxLength&""" onkeydown=""if(event.keyCode==13)event.keyCode=9"" onKeyPress=""if ((event.keyCode<48 || event.keyCode>57)) event.returnValue=false""  "&kdqk&">"&bdTips&""
case 5
kdqk=""
temp="<input type=""text"" name="""&bdname&""" class=""date "&claxx&""" value="""&bdmr1&""" style=""cursor:hand;width:"&bdWidth&"px""  "&kdqk&">"&bdTips&""
case 13
kdqk=""
temp="<input type=""text"" name="""&bdname&""" class=""date "&claxx&""" format=""yyyy-MM-dd HH:mm"" value="""&bdmr1&""" style=""cursor:hand;width:"&bdWidth&"px""  "&kdqk&">"&bdTips&""
case 6  '单选框
if instr(bdmoren,"|")>0 then
bxs=split(bdmoren,"|")
sql="select * from "&bxs(0)&""
set rsc3=conn.execute(sql)
if not rsc3.bof then
do while not rsc3.eof
temp=temp&"<input type=""radio"" value="""&rsc3(bxs(1))&""" name="""&bdname&""""
if instr(bdmr1,rsc3(bxs(1)))>0 then temp=temp&" checked "
temp=temp&">"&rsc3(bxs(1))&"&nbsp;"
rsc3.movenext
loop
end if
rsc3.close:set rsc3=nothing
else
if bdOptions="" then bdOptions="[$]"
baoxz=split(bdOptions,"[$]")
for s=0 to Cntshu(bdOptions,"[$]")
if instr(baoxz(s),"|")>0 then bdxxs=split(baoxz(s),"|"):bdxx1=bdxxs(0):bdxx2=bdxxs(1) else bdxx1=baoxz(s):bdxx2=baoxz(s)
temp=temp&"<input type=""radio"" value="""&bdxx1&""" name="""&bdname&""""
if bdxx1=bdmr1 or bdxx2=bdmr1 then temp=temp&" checked "
temp=temp&">"&bdxx2&"&nbsp;"
next
end if
case 7  '复选框
if instr(bdmoren,"|")>0 then
bxs=split(bdmoren,"|")
sql="select * from "&bxs(0)&""
set rsc3=conn.execute(sql)
if not rsc3.bof then
do while not rsc3.eof
temp=temp&"<input type=""checkbox"" value="""&rsc3(bxs(1))&""" name="""&bdname&""""
if instr(bdmr1,rsc3(bxs(1)))>0 then temp=temp&" checked "
temp=temp&">"&rsc3(bxs(1))&"&nbsp;"
rsc3.movenext
loop
end if
rsc3.close:set rsc3=nothing
else
if bdOptions="" then bdOptions="[$]"
baoxz=split(bdOptions,"[$]")
for s=0 to Cntshu(bdOptions,"[$]")
if instr(baoxz(s),"|")>0 then bdxxs=split(baoxz(s),"|"):bdxx1=bdxxs(0):bdxx2=bdxxs(1) else bdxx1=baoxz(s):bdxx2=baoxz(s)
temp=temp&"<input type=""checkbox"" value="""&bdxx1&""" name="""&bdname&""""
if instr(bdmr1,bdxx1)>0 or instr(bdmr1,bdxx2)>0 then temp=temp&" checked "
temp=temp&">"&bdxx2&"&nbsp;"
next
end if
case 8  '电子邮件
temp="<input type=""text"" name="""&bdname&""" style=""width:"&bdWidth&"px"" value="""&bdmr1&""" maxlength="""&bdMaxLength&"""  "&kdqk&">"&bdTips&""
case 9  '文件上传
'temp="<input type=""file"" name="""&bdname&""" style=""width:"&bdWidth&"px"">"&bdTips&""
temp="<input name="""&bdname&""" type=""text"" value="""&bdmr1&""" id="""&bdname&""" style=""width:"&bdWidth&"px""><input type=""button"" name=""Submit11"" value=""上传"" onClick=""window.open('/upfile.asp?formname=form1&editname="&bdname&"&uppath=/upload&filelx="&bdscok&"&filemax="&bdscdx&"','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')"">"&bdTips&""
case 10 'html文本
if bdbjqlx="shangc" then
temp="<textarea id=""elm1"" name="""&bdname&""" rows=""12"" cols=""80"" style=""width:"&bdWidth&"px;height:"&bdHeight&"px;"">"&bdmr1&"</textarea>"
else
temp="<textarea id="""&bdname&""" name="""&bdname&""" class=""xheditor-simple"" rows=""12"" cols=""80"" style=""width:"&bdWidth&"px;height:"&bdHeight&"px;"">"&bdmr1&"</textarea>"
end if
case 11 
temp="<input type=""text"" name="""&bdname&""" id="""&bdname&"""  "&shux&" style=""width:"&bdWidth&"px"" value="""&bdmr1&""" maxlength="""&bdMaxLength&"""  "&kdqk&">"&bdTips&""
case 12
temp="<input type=""text"" name="""&bdname&""" id="""&bdname&"""  "&shux&" style=""width:"&bdWidth&"px"" value="""&bdmr1&""" maxlength="""&bdMaxLength&"""  "&kdqk&" onKeyPress=""if (event.keyCode!=46 && event.keyCode!=45 && (event.keyCode<48 || event.keyCode>57)) event.returnValue=false"">"&bdTips&""
case else
temp="<input type=""text"" name="""&bdname&""" id="""&bdname&"""  "&shux&" style=""width:"&bdWidth&"px"" value="""&bdmr1&""" maxlength="""&bdMaxLength&"""  "&kdqk&">"&bdTips&""
end select
bdxuan=temp
End Function

sub addzd(ChannelID,FieldName,Title,Tips,FieldType,DefaultValue,Options,MustFillTF,ShowOnForm,ShowOnUserForm,OrderID,AllowFileExt,kuan,gao,MaxFileSize,EditorType,ShowUnit,UnitOptions,ParentFieldName,MaxLength,zdkd,zdbbxs,zdhz)
sql="insert into sz_zd(ChannelID,FieldName,Title,Tips,FieldType,DefaultValue,Options,MustFillTF,ShowOnForm,ShowOnUserForm,OrderID,AllowFileExt,Width,Height,MaxFileSize,EditorType,ShowUnit,UnitOptions,ParentFieldName,MaxLength,zdkd,zdbbxs,zdhz) values("&ChannelID&",'"&FieldName&"','"&Title&"','"&Tips&"',"&FieldType&",'"&DefaultValue&"','"&Options&"',"&MustFillTF&","&ShowOnForm&","&ShowOnUserForm&","&OrderID&",'"&AllowFileExt&"',"&kuan&","&gao&","&MaxFileSize&","&EditorType&","&ShowUnit&",'"&UnitOptions&"','"&ParentFieldName&"',"&MaxLength&","&zdkd&","&zdbbxs&",'"&zdhz&"')"
conn.execute(sql)
End sub

Function mulu(muurl)
temp=temp&"height=""30"" align=""center"" background=""images/left_bg01.gif"" style=""cursor:hand""  onclick=""javascript:parent.right.location.href='"&muurl&"';"""
mulu=temp  
end Function


sub sunzomqx()
response.write"<br><center><img src=""../images/note.gif"" align=""absmiddle"">&nbsp;<font color=""#FF0000"">你不具备此权限，请与管理员联系！</font></center>":response.end
end sub

Function userall(nowuserid,nowuser)
		  if nowuserid=1 then
			sql="select * from login where userzt=1 order by id_zu,id"
			set rs_login=conn.execute(sql)
		  else
			sql="select * from login where userzt=1 and id="&nowuserid&""
			set rs_login=conn.execute(sql)	  
		  end if
		  if rs_login.eof then
temp="<script language=""javascript"">alert(""请先添加员工！"");window.location.href=""../system/user_add.asp"";</script>"
		  response.end
		  else
temp=temp&"<select name=""id_login"">"
do while not rs_login.eof
temp=temp&"<option value="""&rs_login("id")&""""
if rs_login("username")=nowuser then temp=temp&" selected=""selected"" "
temp=temp&">"&rs_login("username")&"("&rs_login("bianhao")&")</option>"
rs_login.movenext
loop
temp=temp&"</select>"
end if
userall=temp  
end Function

''某字段中含有某字符的数量
private function Cntshu(s1,s2)
cntshu=0
xt=1
xt=instr(xt,s1,s2)
do until xt=0
cntshu=cntshu+1
xt=xt+1
xt=instr(xt,s1,s2)
loop
end function
'response.Write Cntshu("1,2,0,1,1,2,0","2")  '结果是:  2

''默认值返回
Function morenzhi(mrz)
select case mrz
case "now"
morenzhi=now()
case "[yue]"
dd=date()
morenzhi=year(dd)&"-"&month(dd)
case "[year]"
morenzhi=Year(now())
case "[nusertel]"
morenzhi=nowusertel
case "[sysname]"
morenzhi=gsname
case "date"
morenzhi=date()
case "sjshu"
morenzhi=gen_key(12)
case "sjsjs"
morenzhi=nowbianhao
case "nowuser"
morenzhi=nowuser
case "nowzwname"
morenzhi=nowuserhao
case "nowzu"
morenzhi=nowzu
case else
morenzhi=mrz
end select
End Function

Function fenge(fgxxs)  '分割统一成“|”
if instr(fgxxs,",")>0 then  fgxxs=replace(fgxxs,",","|")
if instr(fgxxs,"，")>0 then fgxxs=replace(fgxxs,"，","|")
if instr(fgxxs,chr(13))>0 then fgxxs=replace(replace(fgxxs,chr(10),""),chr(13),"|")
fenge=array_no(fgxxs,",",0)
end function

Function fenye(shownum,maxpage,totalrecord,pgxx)  '分页
if shownum>4 then
if requestpage-1 mod 10=0 then
p=(requestpage-1) \ 10
else
p=(requestpage-1) \ 10
end if

yestr=yestr&"    共"&maxpage&"页   "&totalrecord&"个记录   每页"&shownum&"个 | " 

if requestpage=1 then
yestr=yestr&"首页"
else
yestr=yestr&"<a href=?p=1"&pgxx&" title=首页>首页</a> "
end if
if p*10>0 then yestr=yestr&"<a href=?p="&p*10&""&pgxx&" title=上十页>上十页</a> "
yestr=yestr&"<b>"
for ii=p*10+1 to P*10+10
if ii=requestpage then
yestr=yestr&"<font color=""#FF0000"">"&ii&"</font> "
else
yestr=yestr&"<a href=?p="&ii&""&pgxx&">"&ii&"</a>   "
end if
if ii=maxpage then exit for
next
yestr=yestr&"</b>"
if ii<maxpage then yestr=yestr&"<a href=?p="&ii&""&pgxx&" title=下十页>下十页</a> "
if requestpage=maxpage then
yestr=yestr&"尾页"
else
yestr=yestr&"<a href=?p="&maxpage&""&pgxx&" title=尾页>尾页</a>"
end if
end if
fenye=yestr
end function

function int2chn(n) 
dim i,j,k,strlen,retval,x,y,z,str 
z=array("零","壹","贰","参","肆","伍","陆","柒","捌","玖") 
y=array("","拾","佰","仟") 
x=Array("","万","亿","万万亿") 
strlen=len(n) 
str1=n 
for i= 1 to strlen 
j=mid(str1,i,1) 
retval=retval&z(j) 
if j>0 then retval=retval&y((strlen-i) mod 4)'如果大于零，加入十进位字符 
retval=replace(retval,z(0)&z(0),z(0))'出现两个零后只留一个 
if ((strlen-i) mod 4)=0 and right(retval,1)=z(0) then retval=left(retval,len(retval)-1)'每四位加入进阶 
if ((strlen-i) mod 4)=0 then retval=retval&x(int((strlen-i)/4))'把最后的零去掉 
next 
int2chn=retval 
end function


function tsmsm(tswz,tslx,tsurl) 
if tslx=0 then
tsmsm="<script language='javascript'>alert('"&tswz&"');window.location.href='"&tsurl&"';</script>"
else
tsmsm="<br><br><br><h2 align=""center"">"&tswz&"</h2><meta http-equiv=refresh content=""2;URL="&tsurl&""">"  
end if


end function

'if  webadb<>"192.167.2.8" and webadb<>"127.0.0.1" then  response.write "文件已经被删除！":response.end
if jiam=1 then
'加密狗
set s_simnew1=CreateObject("syunew3A.s_simnew3")
If s_simnew1.LastError<>0 Then response.write "未安装锁的驱动。请安装锁的驱动后再进行操作！<a href=""/"">[刷新]</a>":chkout():response.end

DevicePath = s_simnew1.FindPort(0)
If s_simnew1.LastError <> 0 Then   response.write "未找到SUN盾1,请插入SUN盾后再进行操作。<a href=""/"">[刷新]</a>":chkout():response.end
sunz1=s_simnew1.EncString("sunzomsoft", DevicePath)
if sunz1<>"007FF756FA14DFA4667400" then response.write "<script language=JavaScript>" & "alert('"&sunz1&"非匹配的SUN盾，请联系软件开发商！');window.close()</script>":response.end
sunz2 = s_simnew1.YReadString(0,100, "ZHAOBAOS", "SHAN1210", DevicePath)
sunz3 = s_simnew1.DecString(sunz2,"SUNZOMZHAOBAOSHENG13115149000OKL")&"||||||||"
sunzs=split(sunz3,"|")
if len(sunzs(1))>5 then sundd=datediff("d",date,sunzs(1)) else sundd=0

if webwj<>"/reg.asp" then
if sunzs(0)<>"三众科技" then response.write "<script language=JavaScript>" & "alert('非匹配的SUN盾2，请联系软件开发商！');window.close()</script>":response.end
if instr(dianming,sunzs(2))<=0  then response.write "<script language=JavaScript>" & "alert('非匹配的客户资料，请联系软件开发商！');" & "history.back()" & "</script>":response.end
if datediff("d",date,sunzs(1))<0 then response.write "<script language=JavaScript>" & "alert('软件注册期限已到期"&datediff("d",date,sunzs(1))&"，请联系软件开发商重新获取注册码！');window.location.href='/reg.asp'</script>":response.end
if datediff("d",date,syssj)>0 then response.write "<script language=JavaScript>" & "alert('软件注册时间不符，请联系软件开发商！');" & "history.back()" & "</script>":response.end
if usershu>=int(chk0(sunzs(3)))+1  then response.write "<script language=JavaScript>" & "alert('您的注册用户端已超出，请联系软件开发商！！');" & "history.back()" & "</script>":response.end
regmashu=len(regma)
if left(sunz2,regmashu)<>regma then response.write "<script language=JavaScript>" & "alert('系统注册码不匹配，请联系软件开发商或重新注册！');window.location.href='/reg.asp'</script>":response.end
end if

if nowuserid>1 and instr(allsx,"userkey")>0 then
if Session("sunzom_key0")="" or  Session("sunzom_key1")="" or  Session("sunzom_key2")="" then  response.write "<script language=JavaScript>" & "alert('系统出错请联系系统管理员！');window.location.href='/'</script>":response.end
end if

else
sunzs=split("|||50|","|")
end if

userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then
userip = Request.ServerVariables("REMOTE_ADDR")
end if


sub zwqxxx()
if (instr(zwzd1,nowzw)>0  or isnull(zwzd1) or len(trim(zwzd1))<2) then
Response.Write ""&bdxuan(bdTitle,bdname,bdmoren,bdTips,bdlx,bdbjqlx,bdscok,bdscdx,bdOptions,bdShowUnit,bdUnitOptions,bdbt,bdWidth,bdMaxLength,bdHeight,zdkd,chk,edx,shux,zdhz,xxid,cusz,fuzhi)&""
else
if len(edx)<1 then edx="无授权权限"
Response.Write ""&edx&""
end if
end sub 

function citys(fString)
if not isnull(fString) then
    fString=Replace(fString,"&nbsp;","")
    fString=Replace(fString," ","")
    if len(fString)>2 then
    fString = replace(fString, "省", "")
    fString = replace(fString, "市", "")
    fString = replace(fString, "新区", "")
    fString = replace(fString, "地区", "")
    fString = replace(fString, "区", "")
    fString = replace(fString, "县", "")
    end if
    citys = fString
end if
end function
%>