<%
Function ReplaceConstChar(strChar)
  If strChar = "" Or IsNull(strChar) Then
     ReplaceConstChar = ""
     Exit Function
  End If
  Dim strBadChar, arrBadChar, tempChar, i
  strBadChar = "+,',%,^,&,?,(,),<,>,[,],{,},,"&Chr(0)&","&Chr(10)&","&Chr(13)&""
  arrBadChar = Split(strBadChar, ",")
  tempChar = strChar
  For i = 0 To UBound(arrBadChar)
      tempChar = Replace(tempChar, arrBadChar(i), "")
  Next
  tempChar = Replace(tempChar, "@@", "@")
  tempChar=  Replace(tempChar,"""", "&#34;") 
  ReplaceConstChar = tempChar
End Function

Function ReplaceQQ(strChar)
  If strChar = "" Or IsNull(strChar) Then
     ReplaceConstChar = ""
     Exit Function
  End If
  Dim strBadChar, arrBadChar, tempChar, i
  strBadChar = "+,',^,"&Chr(0)&","&Chr(34)&","&Chr(13)&","&Chr(10)&""
  arrBadChar = Split(strBadChar, ",")
  tempChar = strChar
  For i = 0 To UBound(arrBadChar)
      tempChar = Replace(tempChar, arrBadChar(i), "")
  Next
  tempChar = Replace(tempChar, "@@", "@")
  tempChar=  Replace(tempChar,"""", "") 
  ReplaceQQ = tempChar
End Function

'request
function SaveRequest(ParaName,ParaType) 
 Dim ParaValue 
 'ParaType:参数类型-数字型(1数字，0字符)
 ParaValue=Request(ParaName) 
  If ParaType=1 then 
    If not isNumeric(ParaValue) then 
       Response.write "参数" & ParaName & "必须为数字型！" 
       Response.end 
    End if 
  Else 
  ParaValue=replace(ParaValue,"'","''") 
  End if 
  SaveRequest=ParaValue 
end function

'生产静态页面==============
function Htmlcall()
response.Write "<table width=100% border=0 cellspacing=0 cellpadding=0><tr>"
response.Write "<td width=60>正在生成</td>"
response.Write "<td width=208 style='background:url(Images/Survey_bg.gif) 0px 5px no-repeat;'><table border=0 cellspacing=0 cellpadding=0><tr>"
response.Write "<td width=4><img src='images/Survey_1.gif' align=absmiddle></td>"
response.Write "<td><img src='Images/Survey_2.gif' width=0 height=14 id='bar_img' name='bar_img' align='absmiddle'></td>"
response.Write "<td width=4><img src='images/Survey_3.gif' align=absmiddle></td>"
response.Write "</tr></table></td>"   
response.Write "<td >&nbsp;&nbsp;<span id='bar_txt1' name='bar_txt1'>0</span>%</td>"  
response.Write "</tr></table>"  
response.Write "</td></tr></table>"     
end function

'点击修改函数==============
function editbook(b_name,table)
id=request("id")
conn.execute("update "&table&" set "&b_name&" where id="&id)
End Function

'无限级分类树===========================
sub ListSort(id,menu,sortpath,ListType,tid)
if sortpath<>"" then
Set rss=server.CreateObject("adodb.recordset")
sql="Select * From com_class where Instr(sortpath,'"&sortpath&"')>0  order by pid,id"
rss.open sql,conn,1,1
sortid=rss("id")
rss.close
set rss=nothing
end if

  Set rslist=server.CreateObject("adodb.recordset")
  sql="Select * From com_class where type="&tid&" and ParentID="&id&" order by pid,id"
  rslist.open sql,conn,1,1
  if id=0 and rslist.recordcount=0 then
    response.write "<option value=''>暂无分类</option>"
    response.end
  end if  
  i=1
while not rslist.eof
    ChildCount=conn.execute("select count(*) from com_class where type="&tid&" and ParentID="&rslist("id"))(0)

    if ChildCount=0 then
	  FolderType="- "
	  FolderName=rslist("classnamecn")
    else
	  FolderType="+ "
	  FolderName=rslist("classnamecn")
    end if

    if menu="yes" then
    response.Write "<option value='?sortpath="&rslist("SortPath")&"&"&canshu1&"' "
	else
    response.Write "<option value='"&rslist("id")&"|"&rslist("SortPath")&"' "
	end if
	
	if sortid=rslist("id") then
	response.Write "selected"
	end if
	response.Write " >"&ListType&FolderType&FolderName&"</option>"	

	if ChildCount>0 then
	call ListSort(rslist("id"),menu,sortpath,"&nbsp;&nbsp;&nbsp;&nbsp;"&ListType,tid)
	end if
rslist.movenext
i=i+1
wend
rslist.close
set rslist=nothing
end sub

'随机产生函数
function rando(sumstr)
f_Randchar="0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z" 
f_Randchararr=split(f_Randchar,",") 
f_RandLen=sumstr '定义长度或者是位数 
for f_iR=1 to f_RandLen 
Randomize()  
f_Randomizecode=f_Randomizecode&f_Randchararr((35*Rnd)) 
next
rando = f_Randomizecode
end function


'*************************************
'创建随机字符[参数：字符长度]
'*************************************
Function randomStr(strType,intLength)
    Dim strSeed,seedLength,pos,Str,i
	Select Case strType
		Case 0
            strSeed = "abcdefghijklmnopqrstuvwxyz"
		Case 1
            strSeed = "0123456789"
		Case 2
            strSeed = "0abc1def2ghi3jkl4mno5pqr6stu7vwx8yz9"
		Case 3
            strSeed = "asqb#@cdefghij&^klm59854%^#21aa843j(^&%o15841abu09yz"
	End Select
    seedLength = Len(strSeed)
    Str = ""
    Randomize
    For i = 1 To intLength
        Str = Str + Mid(strSeed, Int(seedLength * Rnd) + 1, 1)
    Next
    randomStr = Str
End Function


'分割
Function Split_scj(FileName,SplitType)
FileNameS=split(FileName,SplitType)
'response.write(FileNameS(0)&"_thumb."&FileNameS(1))
Split_scj = FileNameS(0)&"_thumb."&FileNameS(1)
end Function
Function Splitm_scj(FileName,SplitType)
FileNameS=split(FileName,SplitType)
'response.write(FileNameS(0)&"_thumbm."&FileNameS(1))
Splitm_scj = FileNameS(0)&"_thumbm."&FileNameS(1)
end Function

'查询是否已经添加库存规格
sub selPCR(selid)
if selid<>"" then
Set rss=server.CreateObject("adodb.recordset")
sql="Select * From com_PCR where proid="&selid&" order by pid,id"
rss.open sql,conn,1,1
	if rss.bof or rss.eof then
    response.write "<span style='color:red;'>未添加</span>"
	else
	response.write "<span style='color:green;'>已添加</span>(<span  style='color:red;'>"&rss.recordcount&"</span>)"
  end if  
rss.close
set rss=nothing
end if
end sub

'查询地名
sub showAddName(swid)
if swid<>"" then
Set rss=server.CreateObject("adodb.recordset")
sql="Select * From com_china where id="&swid
rss.open sql,conn,1,1
	if rss.bof or rss.eof then
    response.write ""
	else
	response.write rss("name")
  end if  
rss.close
set rss=nothing
end if
end sub
%>