
<%
class fun_class
function format_menu(web_menu,mvars)
  dim i,mdim,mvar: mvar=trim(mvars): format_menu=""
  mdim=split(web_menu,"|")
  for i=0 to ubound(mdim)
    if mvar=left(mdim(i),instr(mdim(i),":") - 1) then format_menu=right(mdim(i),len(mdim(i)) - instr(mdim(i),":")): exit for
  next
  erase mdim
end function
function sql_key(keyes,fields,kt)
  if len(keyes)<1 then sql_key="":exit function
  dim ddim,dnum,di
  keyes=replace(keyes,"'","")
  ddim=split(keyes,",")
  dnum=ubound(ddim)
  sql_key="("&fields&" like '%"&ddim(0)&"%'"
  for di=1 to dnum
    sql_key=sql_key&" or "&fields&" like '%"&ddim(di)&"%'"
  next
  erase ddim
  sql_key=sql_key&")"
end function
function web_var(wvar,wn)
  dim wdim,wnum:wnum=wn:wnum=wnum-1:wdim=split(wvar,"|")
  if wnum>ubound(wdim) then web_var="":erase wdim:exit function
  web_var=wdim(wnum)
  erase wdim
end function
function web_varn(wvar,wn)
  dim wdim,wnum:wnum=wn:wnum=wnum-1:wdim=split(wvar,"|")
  if wnum>ubound(wdim) then web_varn=1:erase wdim:exit function
  web_varn=wdim(wnum)
  erase wdim
  if not (isnumeric(web_varn)) then web_varn=1
end function
function web_var_num(vvar,vnum,vn)
  if vnum>len(vvar) then web_var_num=0:exit function
  web_var_num=mid(vvar,vnum,vn)
  if not (isnumeric(web_var_num)) then web_var_num=0
end function
function format_end(ft,fvar)
  if ft=0 then
    format_end="&nbsp;(" & fvar & ")"
  else
    format_end="&nbsp;<font class=tims>(" & fvar & ")</font>"
  end if
end function
function popedom_format(popedom_var,popedom_n)
  dim poptemp:poptemp=0
  if len(popedom_var)=50 then poptemp=int(mid(popedom_var,popedom_n,1))
  popedom_format=poptemp
end function
function format_power(user_power,pvar,pt)
  dim i,pdim:pvar=trim(pvar)
  if pt=2 then
    format_power=0
  else
    format_power=""
  end if
  pdim=split(user_power,"|")
  for i=0 to ubound(pdim)
    if pvar=left(pdim(i),instr(pdim(i),":") - 1) then
      select case pt
      case 1
        format_power=right(pdim(i),len(pdim(i)) - instr(pdim(i),":")): exit for
      case 2
        format_power=i + 1: exit for
      case else
        format_power=pvar: exit for
      end select
    end if
  next
  erase pdim
end function
function format_power2(user_power,pnn,pt)
  dim i,pdim,pn: format_power2="": pn=pnn - 1
  pdim=split(user_power,"|")
  if pn <= ubound(pdim) then
    if pt=1 then
      format_power2=left(pdim(pn),instr(pdim(pn),":") - 1)
    else
      format_power2=right(pdim(pn),len(pdim(pn)) - instr(pdim(pn),":"))
    end if
  end if
  erase pdim
end function
function pagecute_fun(viewpage,thepages,pagecuteurl)
  dim pf0,pf1,pf2,pf3,pf4,pf5:pf0="已是第一页":pf1="第一页":pf2="上一页":pf3="下一页":pf4="最后一页":pf5="已是最后一页"
  pagecute_fun=VbCrLf & "<table border=0 cellspacing=0 cellpadding=0><tr><form action='"&pagecuteurl&"' method=post><td>"
  if cint(viewpage)=1 then
    pagecute_fun=pagecute_fun & VbCrLf & "<font class=gray>"&pf0&"</font>&nbsp;"
  else
    pagecute_fun=pagecute_fun & VbCrLf & "<a href='"&pagecuteurl&"page=1' alt='"&pf1&"'>"&pf1&"</a>┋<a href='"&pagecuteurl&"page="&cint(viewpage)-1&"' alt='"&pf2&"'>"&pf2&"</a>&nbsp;"
  end if
  if cint(viewpage)=cint(thepages) or cint(thepages)=0 then
    pagecute_fun=pagecute_fun & VbCrLf & "<font class=gray>"&pf5&"</font>"
  else
    pagecute_fun=pagecute_fun & VbCrLf & "<a href='"&pagecuteurl&"page="&cint(viewpage)+1&"' alt='"&pf3&"'>"&pf3&"</a>┋<a href='"&pagecuteurl&"page="&cint(thepages)&"' clases=706501 alt='"&pf4&"'>"&pf4&"</a>"
  end if
  if cint(thepages)<>1 then
    pagecute_fun=pagecute_fun & VbCrLf & "&nbsp;<input type=text name=page value='"&viewpage&"' size=2>&nbsp;<input type=submit value='GO'>"
  end if
  pagecute_fun=pagecute_fun & VbCrLf & "</td></form></tr></table>"
end function
function jk_pagecute(maxpage,thepages,viewpage,pageurl,pp,font_color)
  if int(thepages)=0 then jk_pagecute="<font color=" & font_color & ">[1]</font>":exit function
  dim pn,pi,page_num,ppp,pl,pr:pi=1:ppp=pp\2
  if pp mod 2 = 0 then ppp=ppp-1
  pl=viewpage-ppp:pr=pl+pp-1
  if pl<1 then
    pr=pr-pl+1:pl=1
    if pr>thepages then pr=thepages
  end if
  if pr>int(thepages) then
    pl=pl+thepages-pr:pr=thepages
    if pl<1 then pl=1
  end if
  if pl>1 then
    jk_pagecute=jk_pagecute&" <a href='"& pageurl &"' title='第一页'>[|<]</a>  <a href='"& pageurl &"page="&pl-1&"' clases=706501 title='上一页'>[<]</a> "
  end if
  for pi=pl to pr
    if cint(viewpage)=cint(pi) then
      jk_pagecute=jk_pagecute&" <font color=" & font_color & ">[" & pi & "]</font> "
    else
      jk_pagecute=jk_pagecute&" <a href='"& pageurl &"page="& pi &"' title='第 " & pi & " 页'>[" & pi & "]</a> "
    end if
  next
  if pr<thepages then
    jk_pagecute=jk_pagecute&" <a href='"& pageurl &"page="&pi&"' title='后一页'>[>]</a>  <a href='"& pageurl &"page="& thepages &"' clases=706501 title='最后一页'>[>|]</a> "
  end if
end function
function url_true(puu,pus)
  dim puuu,pu:puuu=puu:pu=pus
  if instr(1,pu,"://")<>0 then
    url_true=pu
  else
    if right(puuu,1)<>"/" then puuu=puuu&"/"
    url_true=puuu&pu
  end if
end function
function time_type(tvar,tt)
  dim ttt:ttt=tvar
  if not(isdate(ttt)) then time_type="":exit function
  select case tt
  case 1	'10-10
    time_type=month(ttt)&"-"&day(ttt)
  case 11	'月-日
    time_type=month(ttt)&"月"&day(ttt)&"日"
  case 2	'年(2)-月-日 00-10-10
    time_type=right(year(ttt),2)&"-"&month(ttt)&"-"&day(ttt)
  case 3	'2000-10-10
    time_type=year(ttt)&"-"&month(ttt)&"-"&day(ttt)
  case 33	'年(4)-月-日
    time_type=year(ttt)&"年"&month(ttt)&"月"&day(ttt)&"日"
  case 4	'23:45
    time_type=hour(ttt)&":"&minute(ttt)
  case 44	'时:分
    time_type=hour(ttt)&"时"&minute(ttt)&"分"
  case 5	'23:45:36
    time_type=hour(ttt)&":"&minute(ttt)&":"&second(ttt)
  case 55	'时:分:秒
    time_type=hour(ttt)&"时"&minute(ttt)&"分"&second(ttt)&"秒"
  case 6	'10-10 23:45
    time_type=month(ttt)&"-"&day(ttt)&" "&hour(ttt)&":"&minute(ttt)
  case 66	'月-日 时:分
    time_type=month(ttt)&"月"&day(ttt)&"日 "&hour(ttt)&"时"&minute(ttt)&"分"
  case 7	'年(2)-月-日 时:分  00-10-10 23:45
    time_type=right(year(ttt),2)&"-"&month(ttt)&"-"&day(ttt)&" "&hour(ttt)&":"&minute(ttt)
  case 8	'2000-10-10 23:45
    time_type=year(ttt)&"-"&month(ttt)&"-"&day(ttt)&" "&hour(ttt)&":"&minute(ttt)
  case 88	'年(4)-月-日 时:分
    time_type=year(ttt)&"年"&month(ttt)&"月"&day(ttt)&"日 "&hour(ttt)&"时"&minute(ttt)&"分"
  case 9	'2000-10-10 23:45:45
    time_type=year(ttt)&"-"&month(ttt)&"-"&day(ttt)&" "&hour(ttt)&":"&minute(ttt)&":"&second(ttt)
    time_type=formatdatetime(time_type)
  case 99	'年(4)-月-日 时:分:秒
    time_type=year(ttt)&"年"&month(ttt)&"月"&day(ttt)&"日 "&hour(ttt)&"时"&minute(ttt)&"分"&second(ttt)&"秒"
  case else
    time_type=ttt
  end select
end function
function upload_time(tt)
  dim ttt:ttt=tt
  ttt=replace(ttt,":",""):ttt=replace(ttt,"-","")
  ttt=replace(ttt," ",""):ttt=replace(ttt,"/","")
  ttt=replace(ttt,"PM",""):ttt=replace(ttt,"AM","")
  ttt=replace(ttt,"上午",""):ttt=replace(ttt,"下午","")
  upload_time=ttt
end function
function code_form(strers)
  dim strer:strer=trim(strers)
  If isNull(strer) or strer="" Then code_form="":exit function
  strer=replace(strer,"'","""")
  code_form=strer
end function
function code_word(strers)
  dim strer:strer=trim(strers)
  If isNull(strer) or strer="" Then code_word="":exit function
  strer=replace(strer,"'","&#39;")
  code_word=strer
end function
function code_name(strers)
  dim strer:strer=trim(strers)
  if isnull(strer) or strer="" then code_name="":exit function
  strer=lcase(strer)
  code_name=strer
end function
function code_html(strers,chtype,cutenum)
  dim strer:strer=strers
  if isnull(strer) or strer="" then code_html="":exit function
  strer=health_var(strer,1)
  if cutenum>0 then strer=cuted(strer,cutenum)
  strer=replace(strer,"<","&lt;")
  strer=replace(strer,">","&gt;")
  strer=replace(strer,chr(39),"&#39;")		'单引号
  strer=replace(strer,chr(34),"&quot;")		'双引号
  strer=replace(strer,chr(32),"&nbsp;")		'空格
  select case chtype
  case 1
    strer=replace(strer,chr(9),"&nbsp;")	'table
    strer=replace(strer,vbcrlf,"")		'回车
  case 2
    strer=replace(strer,chr(9),"&nbsp;　&nbsp;")'table
    strer=replace(strer,vbcrlf,"<br>")		'回车
  end select
  code_html=strer
end function
function cuted(types,num)
  dim ctypes,cnum,ci,tt,tc,cc,cmod
  cmod=3
  ctypes=types:cnum=int(num):cuted="":tc=0:cc=0
  for ci=1 to len(ctypes)
    if cnum<0 then cuted=cuted&"...":exit for
    tt=mid(ctypes,ci,1)
    if int(asc(tt))>=0 then
      cuted=cuted&tt:tc=tc+1:cc=cc+1
      if tc=2 then tc=0:cnum=cnum-1
      if cc>cmod then cnum=cnum-1:cc=0
    else
      cnum=cnum-1
      if cnum<=0 then cuted=cuted&"...":exit for
      cuted=cuted&tt
    end if
  next
end function
function code_len(strers,ln)
  dim strer:strer=trim(strers):code_len="no"
  if isnull(strer) or strer="" then exit function
  if len(strers)>ln then exit function
  code_len="yes"
end function
function lens(types)
  dim ctypes,i,tc,cc,tt
  ctypes=types:cc=len(ctypes)
  for i=1 to len(ctypes)
    tt=mid(ctypes,i,1)
    if int(asc(tt))<0 then cc=cc+1
  next
  lens=cc
end function
function cuter(typess,nummers)
  dim types:types=typess
  if len(types)>nummers then
    cuter=left(types,nummers) & "..."
  else
    cuter=types
  end if
end function
function rand_num(rnum)
  dim ri,rmax,rmin:rmax=1:rmin=1
  for ri=1 to rnum+1
    rmax=rmax*10
  next
  rmax=rmax-1
  for ri=1 to rnum
    rmin=rmin*10
  next
  randomize
  rand_num=int((rand_num-rmin+1)*rnd)+rmin
  if len(rand_num)=3 then rand_num=rand_num&"0"
end function
function post_chk()
  dim server_v1,server_v2
  post_chk="no"
  server_v1=request.servervariables("http_referer")
  server_v2=request.servervariables("server_name")
  if mid(server_v1,8,len(server_v2))=server_v2 then post_chk="yes":exit function
end function
function email_ok(email)
  dim names,name,i,c
  email_ok="yes":names=split(email,"@")
  if ubound(names) <> 1 then email_ok="no":exit function
  for each name in names
    if len(name) <= 0 then email_ok="no":exit function
    for i=1 to len(name)
      c=lcase(mid(name,i,1))
      if instr("abcdefghijklmnopqrstuvwxyz-_.",c) <= 0 and not isnumeric(c) then email_ok="no":exit function
    next
    if left(name,1)="." or right(name,1)="." then email_ok="no":exit function
  next
  if instr(names(1),".") <= 0 then email_ok="no":exit function
  i=len(names(1)) - instrrev(names(1),".")
  if i <> 2 and i <> 3 then email_ok="no":exit function
  if instr(email,"..")>0 then email_ok="no"
end function
function ip_sys(isu,iun)	'0,*=ip_sys  1,0=ip  1,1=ip:port  2,*=port  3,*=sys
  dim userip,userip2
  select case isu
  case 2
    ip_sys=request.servervariables("remote_port")
  case 3
    ip_sys=request.servervariables("http_user_agent")
  case else
    userip=request.servervariables("http_x_forwarded_for")
    userip2=request.servervariables("remote_addr")
    if instr(userip,",")>0 then userip=left(userip,instr(userip,",")-1)
    if instr(userip2,",")>0 then userip2=left(userip2,instr(userip2,",")-1)
    if userip="" then
      ip_sys=userip2
    else
      ip_sys=userip
    end if
    if isu=0 then ip_sys="您的真实ＩＰ是：" & ip_sys & ":" & request.servervariables("remote_port") & "  " & view_sys(request.servervariables("http_user_agent")):exit function
    if iun=1 then ip_sys=ip_sys&":"&request.servervariables("remote_port")
  end select
end function
function view_sys(vss)
  dim vs,ver,strUserAgentArr,strTempUserInfo1,strTempUserInfo2,Mozilla,Agent,BcType,Browser,sSystem,strSystem,strBrowser
  on error resume next
  vs=trim(vss):strUserAgentArr=Split(vs,"; "):strTempUserInfo1=strUserAgentArr(1)
  if Instr(strTempUserInfo1,"MSIE")>0 then strTempUserInfo1=Replace(strTempUserInfo1,"MSIE","Internet Explorer")
  strTempUserInfo2=trim(Left(strUserAgentArr(2),Len(strUserAgentArr(2))-1))
  if InStr(vs,"Mozilla/4.0 (compatible;")>0 and strTempUserInfo2="Windows NT 5.0" then strTempUserInfo2="Windows 2000"
  Mozilla=vs:Agent=Split(Mozilla,"; "):BcType=0
  If Instr(Agent(1),"U") Or Instr(Agent(1),"I") Then BcType=1
  If InStr(Agent(1),"MSIE") Then BcType=2
  Select Case BcType
  Case 0
    Browser="其它":sSystem="其它"
  Case 1
    Ver=Mid(Agent(0),InStr(Agent(0),"/")+1)
    Ver=Mid(Ver,1,InStr(Ver," ")-1)
    Browser="Netscape" & Ver
    sSystem=Mid(Agent(0),InStr(Agent(0),"(")+1)
    sSystem=Replace(sSystem,"Windows","Win")
  case 2
    Browser=Agent(1):sSystem=Replace(Agent(2),")",""):sSystem=Replace(sSystem,"Windows","Win")
  End Select
  strSystem=Replace(sSystem,"Win","Windows")
  if InStr(strSystem,"98")>0 and InStr(Mozilla,"Win 9x")>0 then strSystem=Replace(strSystem,"98","Me")
  strSystem=Replace(strSystem,"NT 5.2","2003")
  strSystem=Replace(strSystem,"NT5.2","2003")
  strSystem=Replace(strSystem,"NT 5.1","XP")
  strSystem=Replace(strSystem,"NT5.1","XP")
  strSystem=Replace(strSystem,"NT 5.0","2000")
  strSystem=Replace(strSystem,"NT5.0","2000")
  strSystem=Replace(strSystem,"NT 5.1","XP")
  strSystem=Replace(strSystem,"NT5.1","XP")
  strBrowser=Replace(Browser,"MSIE","Internet Explorer")
  set Browser=Nothing:set sSystem=Nothing
  view_sys="操作系统：" & trim(strSystem) & " ，浏览器：" & trim(strBrowser)
  if err then err.clear:view_sys="未知的操作系统和浏览器"
end function
function ip_true(tips)
  dim tip,iptemp,iptemp1,iptemp2:tip=tips:ip_true="no":tip=trim(tip)
  iptemp=tip:iptemp=replace(replace(iptemp,".",""),":","")
  iptemp1=tip:iptemp1=len(tip)-len(replace(iptemp1,".",""))
  iptemp2=tip:iptemp2=len(tip)-len(replace(iptemp2,":",""))
  if isnumeric(iptemp) and cint(iptemp1)=3 and (cint(iptemp2)=1 or cint(iptemp2)=0) then ip_true="yes"
end function
function ip_ip(tips)
  dim ipn,tip:tip=tips:tip=trim(tip)
  if ip_true(tip)="no" then ip_ip="no":exit function
  ipn=Instr(tip,":")
  if ipn>0 then ip_ip=left(tip,ipn-1):exit function
  ip_ip=tip
end function
sub web_load()
  space_mod=web_var(web_num,12):now_time=time_type(now(),9):web_edition="c"&""&"s"&""&"k"&""&"3"&""&"0"&""&"0"&""&"0"&""&"8"&""&"."&""&"1"&""&"版":timer_start=timer()
  m_unit=web_var(web_config,8):web_label="<a href='http://www.csk3000.com/' target=_blank>Power by <b><font face=Arial color=#CC3300>csk3000</font><font face=Arial>.com</font></b></a>"
end sub
function ip_types(tips,tu,tt)
  dim ipn,tip2,wip,ip_type:tip2=tips:tip2=trim(tip2):ip_types="error"
  if ip_true(tip2)="no" then ip_types="no":exit function
  wip=int(mid(web_setup,5,1))
  if login_mode=format_power2(user_power,1,1) then wip=2
  select case wip
  case 0
    ip_types="*.*.*.*":ip_types=tu&" 的IP是："&ip_types
    if tt<>0 then ip_types="<img src='images/small/ip.gif' align=absMiddle title='"&ip_types&"' border=0>"
  case 1
    ipn=Instr(tip2,":")
    if ipn>0 then
      ip_types=left(tip2,ipn-1)
    else
      ip_types=tip2
    end if
    ip_type=split(ip_types,"."):ip_types=ip_type(0)&"."&ip_type(1)&".*.*"
    erase ip_type:ip_types=tu&" 的IP是："&ip_types
    if tt<>0 then ip_types="<img src='images/small/ip.gif' align=absMiddle title='"&ip_types&"' border=0>"
  case else
    ip_types=tu&" 的IP是："&tip2
    if tt<>0 then ip_types="<a href='ip_address.asp?ip="&tip2&"'><img src='images/small/ip.gif' align=absMiddle clases=706501 title='"&ip_types&"' border=0></a>"
  end select
end function
function ip_port(pips)
  dim ipnn,iptemp,pip:pip=pips
  pip=trim(pip)
  if ip_true(pip)="no" then ip_port="no":exit function
  ipnn=Instr(pip,":")
  if ipnn>0 then ip_port=right(pip,len(pip)-ipnn):exit function
  ip_port="yes"
end function
function ip_address(sips)
  dim str1,str2,str3,str4,num,country,city,irs,sip:sip=sips
  if not(isnumeric(left(sip,2))) then ip_address="未知":exit function
  if sip="127.0.0.1" then sip="192.168.0.1"
  str1=left(sip,instr(sip,".")-1):sip=mid(sip,instr(sip,".")+1)
  str2=left(sip,instr(sip,".")-1):sip=mid(sip,instr(sip,".")+1)
  str3=left(sip,instr(sip,".")-1):str4=mid(sip,instr(sip,".")+1)
  if not(isNumeric(str1)=0 or isNumeric(str2)=0 or isNumeric(str3)=0 or isNumeric(str4)=0) then
    num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
    sql="select Top 1 country,city from ip_address where ip1 <="&num&" and ip2 >="&num&""
    set irs=server.createobject("adodb.recordset")
    irs.open sql,conn,1,1
    if irs.eof and irs.bof then 
      country="亚洲":city=""
    else
      country=irs(0):city=irs(1)
    end if
    irs.close:set irs=nothing
  end if
  ip_address=country&city
end function
function ver_true(vt,vert)
  dim vi,va:ver_true=false
  if not(isnumeric(vt)) then exit function
  for vi=1 to len(vert)
    va=mid(vert,vi,1)
    if isnumeric(va) then
      if vt=int(va) then ver_true=true:exit function
    end if
  next
end function
end class
%>