<!-- #include file="config.asp" -->
<!-- #include file="functions.asp" -->
<!-- #include file="../style/joekoe_menu.asp" -->
<%
dim web_width,user_ip,user_sys,cookies_true,head_js,skin_dir,iframe,page_load,login_is_abate,is_refur_true,d_name,forum_online
dim lefter,righter,web_left_wid,web_center_height,m_channel,web_img_m,web_img_e,web_img_h,pic_w,pic_h,max_w,max_h,img_emoney,m_hei
dim online_num,login_msg,num_topic,num_data,num_reg,new_username,total_counter,max_online,max_tim,start_tim,new_num,today_tim,stamp_num,bbs_lday,num_video
'-----------------------------------常用变量设置--------------------------------------
web_left_wid=185
web_center_height=300
pic_w=dim_num(15)
pic_h=dim_num(16)
max_w=dim_num(17)
m_hei=dim_num(6)
img_emoney="<img border=0 src='"&joekoe_cms.web_dir_skin&"small/emoney.gif' alt='"&joekoe_cms.web_unit&"' align=absmiddle>"

web_width=""
user_ip=joekoe_cms.ip_sys(0)
user_sys=joekoe_cms.code_form(left(joekoe_cms.ip_sys(1),250))
skin_dir=joekoe_cms.web_dir_skin
iframe=false
page_load=false
is_refur_true=true
cookies_true=true
if trim(request.cookies(joekoe_cms.web_cookies)("cookies_true"))<>"yes" then
  response.cookies(joekoe_cms.web_cookies).path=joekoe_cms.web_dir
  response.cookies(joekoe_cms.web_cookies)("cookies_true")="yes"
  cookies_true=false
end if

call web_is_open()
call web_ip_shield()

dim dim_menu
dim_menu=split(web_dim(20),"|")
'--------------------------------用户在线时间统计---------------------------------
if login_mode<>"" then 
dim tim_login,tim_temp,lentimt 
sql="select top 1 l_tim_login from user_login where l_username='"&login_username&"'" 
set rs=joekoe_cms.exec(sql,1) 
if not rs.eof then tim_login=rs(0) 
rs.close 
tim_temp=DateDiff("n",tim_login,now()) 
if symbol_name(login_username) and tim_temp>4 then 
 call joekoe_cms.exec("update user_login set l_tim_login='"&joekoe_cms.now_time&"' where l_username='"&login_username&"'",0) 
 if tim_temp<30 then 
   call joekoe_cms.exec("update user_data set lentim=lentim+"&tim_temp&" where username='"&login_username&"'",0) 
   call joekoe_cms.exec("update user_data set lentimt=lentimt+"&tim_temp&" where username='"&login_username&"'",0) 
 end if 
end if 
end if

'修改说明：其中数字4和30可自己改，意思是在线时间累积达到5分钟且不活动的时间小于30分钟时，浏览任意一个页面就会更新你的数据，可按服务器承载能力及在线人数权衡。
'-----------------------------------网站标识--------------------------------------
sub web_head_tit()
  tit=joekoe_cms.code_form(tit)
  tit_fir=joekoe_cms.code_form(tit_fir)
  call skin_load()
  call web_head_title()
  if iframe then
    response.write vbcrlf&"<iframe width=0 height=0 src=''id=hiddenframe name=hiddenframe></iframe>"
  end if
end sub

'================================================
'作    用：站内广告模块
'参    数：
'  ads_sort：广告名称
'  ads_t   ：判断在广告下部是否留空
'================================================
sub web_ads(ads_sort,ads_t)
  if var_null(ads_sort)="" then exit sub
  response.write vbcrlf&"<script language=javascript src='ads/ads_"&ads_sort&".js'></script>"
  if ads_t=1 then
    response.write ukong
  end if
end sub

'================================================
'作    用：每日更新
'参    数：
'  today_tim：当前时期
'================================================
sub day_initialize(today_tim)
  dim price_head,last_num
  price_head="#"
  if joekoe_cms.web_vt=1 then
    price_head="'"
  	sql="select count(tim) from bbs_data where tim<CONVERT(VARCHAR(10),getdate(),20) and tim>CONVERT(VARCHAR(10),getdate()-1,20)"
  else
    dim tmp_tim:tmp_tim=DATEADD("d",-1,DATE)
  	sql="select count(tim) from bbs_data where tim like '"&tmp_tim&"%'" 
  end if
  set rs=joekoe_cms.exec(sql,1)
  last_num=rs(0)
  rs.close
  if joekoe_cms.web_vt=1 then
  sql="execute joekoe_init_today '"&today_tim&"'"
  call joekoe_cms.exec(sql,0)
  else
  call joekoe_cms.exec("update configs set num_new=0,today_tim='"&today_tim&"',bbs_lday="&last_num,0)
  call joekoe_cms.exec("update bbs_forum set forum_new_num=0",0)
  call joekoe_cms.exec("update user_data set lentimt=0",0)
  sql="update user_data set abate=1 where estate=1 and otim<"&price_head&today_tim&price_head
  call joekoe_cms.exec(sql,0)
  end if
  application.contents.removeall()
end sub

'================================================
'作    用：网站头部功能模块,设置页面头部信息及显示形式,浏览权限等
'参    数：
'	   var1 : 可选三个参数：0，1，2
'               0，表示不要登陆即可进行浏览该页面；
'               1，表示在后台设置要登陆浏览时，表示有权限用户（请查看下面的说明）登陆后才可浏览该页面；
'               2，表示强制有权限用户登陆后才可浏览该项页面；
'	   var2 : 可选两个参数：0，1
'               0，表示不论是否锁定用户可浏览该页面；
'               1，表示已被锁定的用户不可以浏览该页面；
'	   var3 : 可选三个参数：0，1，2，3，4，5
'               0，表示以左小右大形式的方式显示页面，输出页头JS和头部和底部信息，如“article.asp”一样，需配合“call   '                  web_center(0)、call web_end(0,0)”一起使用；
'               1，此参数值保留；
'               2，表示以满屏方式显示，输出页头JS和头部和底部信息，不分左右，如“article_view.asp”一样，配合“call
'                  web_end(0,0)”一起使用，当设置此值时该页面请勿再使用“call web_center(0)”；
'               3，此参数值保留；
'               4，表示只输出页头JS，不包含头部和底部信息，如“commend.asp”一样，配合“call 
'                  web_end(0,1)”一起使用，当设置此值时该页面请勿再使用“call web_center(0)”；
'               5，表示只进行权限处理，不输出页头JS和头部和底部信息，如“forum_loadonline.asp”一样，配合“call
'                  web_end(0,1)”一起使用，当设置此值时该页面请勿再使用“call web_center(0)”；
'	   var4 : 此参数值保留
'	   var5 : 此参数值保留
'================================================
sub web_head(var1,var2,var3,var4,var5)
  if page_load then
    call format_redirect("page_load.asp")
  end if
  call web_head_tit()  
  dim temp1,ttt
  num_topic=0
  num_data=0
  num_reg=0
  num_video=0
  new_username=""
  total_counter=0
  max_online=0
  max_tim=joekoe_cms.now_time
  start_tim=joekoe_cms.time_type(joekoe_cms.now_time,5)
  online_num=0
  new_num=0
  today_tim=joekoe_cms.time_type(joekoe_cms.now_time,4)
  stamp_num=format_mid_num(1)  
'-------------------------------------------------------------------------
  web_config=application(joekoe_cms.web_cookies&"_web_config")
  if not isarray(web_config) then
    if joekoe_cms.web_vt=1 then
    sql="execute joekoe_init_config"
	else
    sql="select top 1 id,num_topic,num_data,num_reg,new_username,num_news,num_article,num_down,num_product,counter,max_online,max_tim,start_tim,num_new,today_tim,bbs_lday,num_video,num_pris,num_music,num_dmain_product,num_host_product,num_email_product,num_job,num_person from configs"
    end if
    set rs=joekoe_cms.exec(sql,1)
    if rs.eof then
      rs.close
      call joekoe_cms.exec("insert into configs(id,num_topic,num_data,num_reg,new_username,num_news,num_article,num_down,num_product,counter,max_online,max_tim,start_tim,num_new,today_tim,bbs_lday,num_video,num_pris,num_music,num_dmain_product,num_host_product,num_email_product,num_job,num_person) values(1,"&num_topic&","&num_data&","&num_reg&",'"&new_username&"',0,0,0,0,"&total_counter&","&max_online&",'"&max_tim&"','"&start_tim&"',0,'"&today_tim&"',0)",0)
      set rs=joekoe_cms.exec(sql,1)
    end if
    application(joekoe_cms.web_cookies&"_configs_counter")=rs(9)
    web_config=rs.getrows()
    rs.close
    application(joekoe_cms.web_cookies&"_web_config")=web_config
  end if
  num_topic=web_config(1,0)
  num_data=web_config(2,0)
  num_reg=web_config(3,0)
  new_username=web_config(4,0)
  total_counter=application(joekoe_cms.web_cookies&"_configs_counter")
  max_online=web_config(10,0)
  max_tim=web_config(11,0)
  start_tim=web_config(12,0)
  new_num=web_config(13,0)
  bbs_lday=web_config(15,0)
  num_video=web_config(16,0)

  if cstr(joekoe_cms.time_type(web_config(14,0),4))<>cstr(joekoe_cms.time_type(today_tim,4)) then
    call day_initialize(today_tim)
    total_counter=total_counter+1
    new_num=0
  end if

  if cookies_true then
    dim tmpnum
    forum_online=int(request.querystring("forum_id"))
    if datediff("s",application(joekoe_cms.web_cookies&"_web_new_time"),joekoe_cms.now_time)>dim_num(38)*60 then
      application(joekoe_cms.web_cookies&"_web_new_time")=joekoe_cms.now_time
      if joekoe_cms.web_vt=1 then
        sql="delete from user_login where datediff(mi,l_tim_end,'"&joekoe_cms.now_time&"')>"&dim_num(2)
      else
        sql="delete from user_login where datediff('s',l_tim_end,'"&joekoe_cms.now_time&"')>"&dim_num(2)&"*60"
      end if
        call joekoe_cms.exec("",-1)
        conn.execute sql,tmpnum
    end if
    if tmpnum>0 then call web_online()
    login_password=jk_decrypt(login_password)
    if symbol_name(login_username)=false or symbol_ok(login_password)=false then
      call cookies_clear(0)
    else
     if datediff("s",session("user_time"),joekoe_cms.now_time)>dim_num(38)*60 then
	   session("user_data")=empty
	   session("user_on")=""
	 end if 
     if NOT isarray(session("user_data")) then
       if joekoe_cms.web_vt=1 then
	   dim userid:userid=joekoe_cms.userid(login_username,login_password)
       sql="execute joekoe_init_user_login "&userid
'	   sql="execute joekoe_init_user_login '"&login_username&"','"&login_password&"'"
	   else 
       sql="select top 1 id,username,power,popedom,emoney,integral,last_tim,face,face_w,face_h,estate,otim,bbs_counter,lentim,lentimt,isper,sex from user_data where hidden=1 and abate=0 and username='"&login_username&"' and password='"&login_password&"'"
       end if
       call joekoe_cms.exec("",-1)
       rs.open sql,conn,1,3
       if rs.eof then 
         call cookies_clear(0)
       else
         rs(6)=joekoe_cms.now_time
         rs.update
         session("user_data")=rs.getrows()
       end if
       rs.close
       session("user_time")=joekoe_cms.now_time
      end if
      dim user_datas:user_datas=session("user_data")
        login_id=user_datas(0,0)
        login_username=user_datas(1,0)
        login_mode=user_datas(2,0)
        login_popedom=user_datas(3,0)
        login_emoney=user_datas(4,0)
        login_integral=user_datas(5,0)
        login_faces=user_datas(7,0)&"|"&user_datas(8,0)&"|"&user_datas(9,0)
        login_is_abate=user_datas(10,0)
        login_bbs_counter=user_datas(12,0)
		login_lentim=user_datas(13,0)
        login_lentimt=user_datas(14,0)
	    login_isper=user_datas(15,0)
        login_sex=user_datas(16,0)
        if int(login_is_abate)>0 then
          if int(dateDiff("d",today_tim,user_datas(11,0)))<1 then login_is_abate=0
        end if
        erase user_datas
        login_modep=format_power(login_mode,2)
        response.cookies(joekoe_cms.web_cookies)("login_id")=login_id
        response.cookies(joekoe_cms.web_cookies)("login_password")=jk_encrypt(login_password)
    end if
    if is_refur_true=true then call time_load()
'---------------------------------完整型,用户和游客都进行识别,这里识别游客-------------------------------------
    if int(stamp_num)>1 and login_mode="" and cookies_true=true then
      if datediff("s",session("guest_time"),joekoe_cms.now_time)>dim_num(38)*60 then session("guest")=""
      if var_null(session("guest"))="" then
        if request.cookies(joekoe_cms.web_cookies)("guest_name")="" then
          ttt="游客"&Session.SessionID
        else
          ttt=request.cookies(joekoe_cms.web_cookies)("guest_name")
          ttt=joekoe_cms.code_html(ttt,1,0)
        end if
        session("guest")=ttt
        session("guest_time")=joekoe_cms.now_time
        response.cookies(joekoe_cms.web_cookies)("guest_name")=ttt
        sql="select top 1 l_id from user_login where l_username='"&ttt&"'"
        set rs=joekoe_cms.exec(sql,1)
        if rs.eof then
          call joekoe_cms.exec("insert into user_login(l_username,l_type,l_where,l_tim_login,l_tim_end,l_ip,l_sys,l_forum_online) values('"&ttt&"',1,'"&left(tit,50)&"','"&joekoe_cms.now_time&"','"&joekoe_cms.now_time&"','"&user_ip&"','"&user_sys&"',"&forum_online&")",0)
          total_counter=total_counter+1
          call joekoe_cms.exec("update configs set counter=counter+1",0)
        end if
        rs.close
	    call web_online()
      else
        ttt=session("guest")
      end if
      call joekoe_cms.exec("update user_login set l_where='"&left(tit,50)&"',l_tim_end='"&joekoe_cms.now_time&"',l_forum_online="&forum_online&" where l_username='"&ttt&"'",0)
      if format_mid_num(9)=1 then
        total_counter=total_counter+1
        call joekoe_cms.exec("update configs set counter=counter+1",0)
      end if
    end if
'---------------------------------功能型,用户识别-------------------------------------
      if int(stamp_num)>0 and login_mode<>"" and cookies_true=true then
        login_msg=session("login_msg")
        if var_null(login_msg)="" or login_msg>0 or application(joekoe_cms.web_cookies&"_"&login_id)=login_id then
          application.contents.remove(joekoe_cms.web_cookies&"_"&login_id)
          sql="select count(id) from user_mail where accept_u='"&login_username&"' and types=1 and isread=0"
          set rs=joekoe_cms.exec(sql,1)
          login_msg=rs(0)
          rs.close
          session("login_msg")=login_msg
        end if
        if login_msg>0 then
           dim msg_id,msg_name,msg_topic
	       sql="select top 1 id,send_u,topic from user_mail where accept_u='"&login_username&"' and types=1 and isread=0"
	       set rs=joekoe_cms.exec(sql,1)
	       msg_id=int(rs(0))
	       msg_name=rs(1)
	       msg_topic=rs(2)
	       rs.close
	    else
           login_msg=0
        end if
	if login_isper=true then
          set rs=conn.execute("select iname from person where username='"&login_username&"'")
            if not(rs.eof and rs.bof) then login_cname=rs(0)
          rs.close
        else
          set rs=conn.execute("select cname from company where username='"&login_username&"'")
            if not(rs.eof and rs.bof) then login_cname=rs(0)
          rs.close
        end if
        if var_null(session("user_on"))="" then
         sql="select top 1 l_id from user_login where l_username='"&login_username&"'"
         set rs=joekoe_cms.exec(sql,1)
         if rs.eof then
           call joekoe_cms.exec("insert into user_login(l_username,l_type,l_where,l_tim_login,l_tim_end,l_ip,l_sys,l_forum_online) values('"&login_username&"',0,'"&left(tit,50)&"','"&joekoe_cms.now_time&"','"&joekoe_cms.now_time&"','"&user_ip&"','"&user_sys&"',"&forum_online&")",0)
           total_counter=total_counter+1
           call joekoe_cms.exec("update configs set counter=counter+1",0)
         end if
         rs.close
         session("user_on")=login_username
		 call web_online()
       end if      
       if format_mid_num(9)=1 then
         total_counter=total_counter+1
         call joekoe_cms.exec("update configs set counter=counter+1",0)
       end if
       if var_null(trim(request.querystring("uppath")))="" then call joekoe_cms.exec("update user_login set l_where='"&left(tit,50)&"',l_tim_end='"&joekoe_cms.now_time&"',l_forum_online="&forum_online&" where l_username='"&login_username&"'",0)
     end if
   end if
  online_num=int(application(joekoe_cms.web_cookies&"_web_online"))
  if int(online_num)>web_config(10,0) then
    call joekoe_cms.exec("update configs set max_online="&online_num&",max_tim='"&joekoe_cms.now_time&"'",0)
  end if
  if int(total_counter)>int(application(joekoe_cms.web_cookies&"_configs_counter")) then
    application(joekoe_cms.web_cookies&"_configs_counter")=total_counter
    call joekoe_cms.exec("update configs set counter="&total_counter,0)
  end if
  if page_power<>"" and instr("."&page_power&".","."&login_modep&".")<1 then call web_error("power")
  select case var1
  case 1
    if int(format_mid_num(8))=1 and login_mode="" then call my_login()
  case 2
    if login_mode="" then call my_login()
  end select
  if var2=1 and login_mode<>"" then
    if popedom_p(41)=1 then call web_error("locked")
  end if
  if var3=5 then exit sub
  if var3=4 then exit sub
  CMS_Skin.sktitle=Replace(CMS_Skin.sktitle,"{$lefter}",CMS_Skin.skmod_lefter)
  CMS_Skin.sktitle=Replace(CMS_Skin.sktitle,"{$web_skin}",joekoe_cms.web_dir_skin)
  CMS_Skin.sktitle=Replace(CMS_Skin.sktitle,"{$web_name}",joekoe_cms.web_name)
  CMS_Skin.sktitle=Replace(CMS_Skin.sktitle,"{$web_url}",joekoe_cms.web_url)
  CMS_Skin.sktitle=Replace(CMS_Skin.sktitle,"{$menu}",web_menu())
  CMS_Skin.sktitle=Replace(CMS_Skin.sktitle,"{$today_now}",joekoe_cms.time_type("",5))
  CMS_Skin.sktitle=Replace(CMS_Skin.sktitle,"{$today_week}",weekdayname(weekday(joekoe_cms.today_time)))
  if tit_fir="" then
    CMS_Skin.sktitle=Replace(CMS_Skin.sktitle,"{$tit_now}","<font title='"&joekoe_cms.code_html(tit,1,0)&"'>"&joekoe_cms.code_html(tit,1,30)&"</font>")
  else
    CMS_Skin.sktitle=Replace(CMS_Skin.sktitle,"{$tit_now}","<a href='"&index_url&".asp'><font color=#000000>"&tit_fir&"</font></a>&nbsp;→&nbsp;<font title='"&joekoe_cms.code_html(tit,1,0)&"'>"&joekoe_cms.code_html(tit,1,12)&"</font>")
  end if
  scroll_head="<marquee scrolldelay=100 scrollamount=3 onMouseOut='if (document.all!=null){this.start()}' onMouseOver='if (document.all!=null){this.stop()}'> "&scroll_head&" </marquee>"
  if login_msg>0 then  scroll_head="<bgsound src='"&joekoe_cms.web_dir_skin&"mail/message.wav'><a href='user_mail.asp'><img src='"&joekoe_cms.web_dir_skin&"mail/new.gif' align=absmiddle border=0>&nbsp;我的短信箱（<font class=red>"&login_msg&"&nbsp;新</font>）</a>"&joekoe_cms.js_put("document.write(msg_go('"&joekoe_cms.web_dir&"',"&login_msg&",'"&msg_topic&"',"&msg_id&",'"&msg_name&"'));",1)
  CMS_Skin.sktitle=Replace(CMS_Skin.sktitle,"{$tit_scroll}",scroll_head)
  CMS_Skin.sktitle=Replace(CMS_Skin.sktitle,"{$righter}",CMS_Skin.skmod_righter)
  Response.Write(CMS_Skin.sktitle)
  response.write web_left(var3)
end sub

'================================================
'作    用：网站底部信息功能模块
'参    数：
'	   var1 : 此参数值保留
'	   var2 : 判断是否显示底部信息
'================================================
sub web_end(var1,var2)
  if var2=0 then
  dim tmp_exec_tim
  tmp_exec_tim=FormatNumber((timer()-joekoe_cms.timer_start),3)
  if left(tmp_exec_tim,1)="." then tmp_exec_tim="0"&tmp_exec_tim
  Response.Write web_right
  CMS_Skin.skend=Replace(CMS_Skin.skend,"{$lefter}",CMS_Skin.skmod_lefter)
  CMS_Skin.skend=Replace(CMS_Skin.skend,"{$web_url}",joekoe_cms.web_url)
  CMS_Skin.skend=Replace(CMS_Skin.skend,"{$web_name}",joekoe_cms.web_name)
  CMS_Skin.skend=Replace(CMS_Skin.skend,"{$skin}",CMS_Skin.skname)
  CMS_Skin.skend=Replace(CMS_Skin.skend,"{$exec_tim}",tmp_exec_tim)
  CMS_Skin.skend=Replace(CMS_Skin.skend,"{$exec_num}",joekoe_cms.num_rs)
  CMS_Skin.skend=Replace(CMS_Skin.skend,"{$online_num}",online_num)
  CMS_Skin.skend=Replace(CMS_Skin.skend,"{$cache_num}",Application.Contents.count)
  CMS_Skin.skend=Replace(CMS_Skin.skend,"{$righter}",CMS_Skin.skmod_righter)
  Response.Write(vbcrlf&CMS_Skin.skend)
  end if
  call web_clears(1)
end sub
'================================================
'作    用：网站名称、关键字、样式设置
'================================================
sub web_head_title()
  CMS_Skin.skhead=Replace(CMS_Skin.skhead,"{$web_name}",joekoe_cms.web_name)
  CMS_Skin.skhead=Replace(CMS_Skin.skhead,"{$tit}",tit)
  CMS_Skin.skhead=Replace(CMS_Skin.skhead,"{$css}",CMS_Skin.skcss)
  Response.Write(CMS_Skin.skhead)
end sub

'================================================
'作    用：等级设置
'================================================
function popedom_p(popedom_n)
  if cint(popedom_n)>len(login_popedom) or len(login_popedom)<>50 then
    popedom_p=0
    exit function
  end if
  popedom_p=int(mid(login_popedom,popedom_n,1))
end function

'================================================
'作    用：网站左边部分设置
'================================================
function web_left(lt)
  select case cint(lt)
  case 2
    web_left=CMS_Skin.skmod_lefter&"<table border=0 width='100%' cellspacing=0 cellpadding=0><tr><td align=center class=bg_1>"
  case else
    web_left=CMS_Skin.skmod_lefter&CMS_Skin.sktable_lefter
  end select
end function

'================================================
'作    用：网站中间部分设置
'================================================
sub web_center(ct)
  Response.Write vbcrlf&CMS_Skin.sktable_center
end sub

'================================================
'作    用：网站右边部分设置
'================================================
function web_right()
  web_right=vbcrlf&CMS_Skin.sktable_righter&CMS_Skin.skmod_righter
end function

'================================================
'作    用：一般在论坛部分使用
'================================================
sub web_branch(jst)
  response.write web_right()
  response.write web_left(2)
  response.buffer
end sub

'================================================
'作    用：弹出对话框
'参    数：
'	   msg_type : 判断弹出方式
'	   msg_var  : 提示内容
'      msg_url  : 跳转路径
'================================================
sub web_js_msg(msg_type,msg_var,msg_url)
  call cookies_load()
  if msg_type=0 then
    response.write "alert("""&msg_var&""");location.href="""&msg_url&""";"
    exit sub
  end if
  response.write joekoe_cms.js_put("alert("""&msg_var&""");location.href="""&msg_url&""";",1)
end sub

'================================================
'作    用：cookies有效期
'================================================
sub cookies_load()
  response.cookies(joekoe_cms.web_cookies)("time_load")=dateadd("s",-5,joekoe_cms.now_time)
end sub

'================================================
'作    用：处理cookies
'参    数：
'	   t1 : 判断cookies有效期
'================================================
sub cookies_clear(tl)
  if tl=1 then call cookies_load()
  response.cookies(joekoe_cms.web_cookies)("login_username")=""
  response.cookies(joekoe_cms.web_cookies)("login_password")=""
  response.cookies(joekoe_cms.web_cookies)("login_id")=""
  login_mode=""
  login_username=""
  login_password=""
end sub

'================================================
'作    用：处理登陆后用户信息
'================================================
sub my_login()
  if login_mode<>"" then exit sub
  dim temp1
  temp1=trim(request.serverVariables("url"))&"?"&trim(request.serverVariables("QUERY_STRING"))
  temp1=server.urlencode(temp1)
  response.cookies(joekoe_cms.web_cookies)("time_load")=DateAdd("s",-5,joekoe_cms.now_time)
  response.cookies(joekoe_cms.web_cookies)("login_username")=""
  response.cookies(joekoe_cms.web_cookies)("login_password")=""
  response.cookies(joekoe_cms.web_cookies)("login_id")=""
  response.cookies(joekoe_cms.web_cookies)("iscookies")=""
  call format_redirect("login.asp?old_url="&temp1)
end sub

'================================================
'作    用：导航菜单相关
'================================================
function format_menu(mvar)
  dim i
  format_menu=""
  for i=0 to ubound(dim_menu)
    if mvar=left(dim_menu(i),instr(dim_menu(i),":")-1) then
      format_menu=right(dim_menu(i),len(dim_menu(i))-instr(dim_menu(i),":"))
      exit for
    end if
  next
end function

'================================================
'作    用：网站风格相关
'================================================
sub skin_load()
  dim n_skin
  n_skin=trim(request.cookies(joekoe_cms.web_cookies)("skin_var"))
  if n_skin<>"" then
    joekoe_cms.web_skin=n_skin
    skin_dir=joekoe_cms.web_dir&"skin/"&n_skin&"/"
    joekoe_cms.web_dir_skin=skin_dir
  end if
end sub

'================================================
'作    用：页面转跳
'参    数：
'	   r_url : 页面转跳路径
'================================================
sub format_redirect(r_url)
  call web_clears(0)
  response.clear
  response.redirect r_url
  response.end
end sub

'================================================
'作    用：清除所有全局数组等
'================================================
sub web_clears(c_end)
  erase dim_menu
  call web_clear(c_end)
end sub

'================================================
'作    用：网站是否开启
'================================================
sub web_is_open()
  if web_dim(0)=0 then
    response.clear
    call web_head_tit()
    call web_no_open()
    call web_clear(1)
  end if
end sub

'================================================
'作    用：网站IP限制
'================================================
sub web_ip_shield()
  dim tmp
  tmp=true
  if web_dim(22)="" or user_ip="" then exit sub
  dim sdim,snum
  sdim=split(web_dim(22),"|")
  snum=ubound(sdim)
  for i=0 to snum
    if instr("$"&user_ip&".","$"&sdim(i)&".")>0 then
      erase sdim
      response.clear
      call web_head_tit()
      call web_no_ip()
      call web_clear(1)
    end if
  next
  erase sdim
end sub
'================================================
'作    用：网站错误信息
'参    数：
'	   etype : 判断错误类型
'================================================
sub web_error(etype)
  response.clear
  response.cookies(joekoe_cms.web_cookies)("time_load")=DateAdd("s",-5,joekoe_cms.now_time)
  response.cookies(joekoe_cms.web_cookies)("old_url")=request.servervariables("http_referer")
  response.cookies(joekoe_cms.web_cookies)("error_action")=etype
  call format_redirect("error.asp")
end sub

'================================================
'作    用：用户登陆模块
'================================================
function user_login()
 if login_mode="" then
   user_login=vbcrlf&CMS_Skin.GetDB("login_left1")
    exit function
  end if
  dim tmp
  tmp=CMS_Skin.GetDB("login_left2")
  tmp=Replace(tmp,"{$login_username}",login_username)
  tmp=Replace(tmp,"{$login_mode_var}",format_power(login_mode,1))
  tmp=Replace(tmp,"{$login_emoney}",login_emoney)
  tmp=Replace(tmp,"{$web_unit}",joekoe_cms.web_unit)
  tmp=Replace(tmp,"{$login_integral}",login_integral)
  tmp=Replace(tmp,"{$login_msg}",login_msg)
user_login=tmp
end function

'================================================
'作    用：网站刷新时间相关
'================================================
sub time_load()
  dim tim_s,var_s
  tim_s=int(dim_num(3))
  if int(tim_s)<1 then exit sub
  if login_mode=format_power2(1,1) then exit sub
  var_s=request.cookies(joekoe_cms.web_cookies)("time_load")
  if isdate(var_s) then
    if int(datediff("s",var_s,joekoe_cms.now_time))<=int(tim_s) then
      call web_error("time_load")
      exit sub
    end if
  end if
  response.cookies(joekoe_cms.web_cookies)("time_load")=joekoe_cms.now_time
end sub

'================================================
'作    用：网站开放时间限制功能模块
'================================================
sub time_lock()
  if web_dim(10)=0 then exit sub
  dim nh,tt
  nh=int(hour(joekoe_cms.now_time))
  for i=1 to len(web_dim(10))
    if i=1 then
  if int(mid(web_dim(10),i,1))=0 then
  tt=i
  end if
  else
  if int(mid(web_dim(10),i,1))=1 then tt=i-1
  end if
  if nh=tt then call web_error("time_lock")
  next
end sub


function frm_chk()
  frm_chk=false
  if trim(request.form("chk"))="yes" then
    frm_chk=joekoe_cms.post_chk()
  end if
end function

'================================================
'作    用：网站发表时间间隔限制功能模块
'================================================
function post_tim()
  dim pt_var,pt_num
  post_tim=true
  pt_var=session("post_tim")
  if isdate(pt_var) then
    pt_num=datediff("s",pt_var,joekoe_cms.now_time)
    if int(dim_num(28))>0 and int(pt_num)<=int(dim_num(28)) then
      post_tim=false
    end if
  end if
  session("post_tim")=joekoe_cms.now_time
end function

'================================================
'作    用：图片路径处理
'参    数：
'	   pvar : 判别图片路径
'	   pt   : 判别图片大小
'================================================
function pic_url(pvar,pt)
  dim temp1,pic_var
  pic_var=pvar
  if pic_var="" then
    pic_var=joekoe_cms.web_upload&"no_pic.gif"
  else
    if instr(pic_var,"://")<1 then
      pic_var=joekoe_cms.web_upload&pic_var
    end if
  end if
  select case int(pt)
  case 1
    temp1="<img border=0 width="&pic_w&" height="&pic_h&" src='" & pic_var & "'>"
  case 2
    temp1="<img border=0 width="&(pic_w*1.5)&" height="&(pic_h*1.5)&" src='" & pic_var & "'>"
  case 3
    temp1="<img border=0 src='" & pic_var & "'>"
  case 4
     temp1="<img border=0 width="&(pic_w*0.7)&" height="&(pic_h*0.7)&" src='" & pic_var & "'>"
  case 5
     temp1="<img border=0 width="&(pic_w*0.5)&" height="&(pic_h*0.5)&" src='" & pic_var & "'>"
  case 6
     temp1="<img border=0 width="&(pic_w*0.65)&" height="&(pic_h*1.1)&" src='" & pic_var & "'>"
  case 7
     temp1="<img border=0 width="&(pic_w*0.42)&" height="&(pic_h*0.73)&" src='" & pic_var & "'>"
  case 8
    temp1="<img border=0 width="&(pic_w*1.2)&" height="&(pic_h*1.2)&" src='" & pic_var & "'>"
  case 9
    temp1="<img border=0 width="&(pic_w*1.7)&" height="&(pic_h*3)&" src='" & pic_var & "'>"
  case 10
    temp1="<img border=0 width="&(pic_w*0.91)&" height="&(pic_h*1.58)&" src='" & pic_var & "'>"
  case 11
    temp1="<img border=0 width="&(pic_w*1.2)&" height="&(pic_h*2.16)&" src='" & pic_var & "'>"
  case 12
    temp1="<img border=0 width="&(pic_w*2.0)&" height="&(pic_h*2.7)&" src='" & pic_var & "'>"
  case 13
    temp1="<img border=0 width="&(pic_w*1.2)&" height="&(pic_h*0.7)&" src='" & pic_var & "'>"
  case 14
    temp1="<img border=0 width="&(pic_w*1.4)&" height="&(pic_h*0.9)&" src='" & pic_var & "'>"
  case else
    temp1=pic_var
  end select
  pic_url=temp1
end function

'================================================
'作    用：图片边框处理
'参    数：
'	   pvar : 判别图片路径
'	   pt   : 判别图片大小
'	   purl : 判断图片路径
'================================================
function pic_fk(pvar,pt,purl)
  dim burl,picurl
  burl="images/fk/"
  picurl=pic_url(pvar,pt)
  if purl<>"" and var_null(purl)<>"" then picurl="<a href='"&purl&"' target=_blank>"&picurl&"</a>"
  pic_fk=Replace(CMS_Skin.GetDB("format_fk"),"{$pics}",picurl)
end function

'================================================
'作    用：标题模块
'参    数：
'	   b_jt         : 标题前小图片
'	   b_username   : 发布人
'	   b_topic      : 标题
'	   b_c_num      : 标题显示字数
'	   b_url        : 连接地址
'	   b_tim        : 发布时间
'	   b_counter    : 浏览的次数
'	   b_ispic      : 缩略图
'	   b_tit        : 标签
'	   b_count      : 回复、浏览等
'	   b_tim_type   : 发布时间
'================================================
function format_topic_type(b_jt,b_username,b_topic,b_c_num,b_url,b_tim,b_counter,b_ispic,b_tit,b_count,b_tim_type)
  dim n_img,tim_type,n_c_num,temp1
  n_c_num=b_c_num
  if b_ispic=true then
    n_img="&nbsp;<img src='"&joekoe_cms.web_dir_skin&"small/img.gif' border=0>"
    n_c_num=n_c_num-2
  end if
  if int(b_tim_type)>0 then
    if int(b_tim_type)=2 then tim_type=tim_type&"</td><td align=right>"
    tim_type=tim_type&"&nbsp;<font class=tims>"&mid(b_tim,6,5)&"</font>"
  end if
  temp1=CMS_Skin.GetDB("down_list")
  temp1=Replace(temp1,"{$t_height}",m_hei)
  temp1=Replace(temp1,"{$t_jt}",b_jt)
  temp1=Replace(temp1,"{$t_url}",b_url)
  temp1=Replace(temp1,"{$t_tit}",b_tit)
  temp1=Replace(temp1,"{$t_topic}",joekoe_cms.code_html(b_topic,1,b_c_num))
  temp1=Replace(temp1,"{$t_topics}",joekoe_cms.code_html(b_topic,1,0))
  temp1=Replace(temp1,"{$t_username}",b_username)
  temp1=Replace(temp1,"{$t_count}",b_count)
  temp1=Replace(temp1,"{$t_counter}",b_counter)
  temp1=Replace(temp1,"{$t_tim}",b_tim)
  temp1=Replace(temp1,"{$web_var_br}","<br>")
  temp1=Replace(temp1,"{$t_img}",n_img)
  temp1=Replace(temp1,"{$t_tim_type}",tim_type)
  format_topic_type=temp1
end function

'================================================
'作    用：图片模块
'参    数：
'	   b_pic        : 图片地址
'	   b_topic      : 图片标题
'	   b_c_num      : 标题显示字数
'	   b_url        : 图片连接地址
'================================================
function format_pic_type(b_pic,b_topic,b_c_num,b_url)
  dim temp1
  temp1=CMS_Skin.GetDB("format_pic")
  temp1=Replace(temp1,"{$pic_fk}",pic_fk(b_pic,1,b_url))
  temp1=Replace(temp1,"{$t_url}",b_url)
  temp1=Replace(temp1,"{$t_topics}",joekoe_cms.code_html(b_topic,1,0))
  temp1=Replace(temp1,"{$t_topic}",joekoe_cms.code_html(b_topic,1,b_c_num))
  format_pic_type=temp1
end function

'================================================
'作    用：网站版权信息模块
'================================================
sub cms_copyright()
  dim tmp
  tmp=CMS_Skin.GetDB("copyright")
  tmp=Replace(tmp,"{$web_url}",joekoe_cms.web_url) 
  tmp=Replace(tmp,"{$web_name}",joekoe_cms.web_name)
  tmp=Replace(tmp,"{$pro_editon}",joekoe_cms.pro_edition)
  Response.Write(vbcrlf&tmp)
end sub

'================================================
'作    用：网站是否开放功能模块
'================================================
sub web_no_open()
  dim tmp
  tmp=CMS_Skin.GetDB("no_open")
  tmp=Replace(tmp,"{$web_url}",joekoe_cms.web_url) 
  tmp=Replace(tmp,"{$web_name}",joekoe_cms.web_name)
  tmp=Replace(tmp,"{$web_email}",joekoe_cms.web_email)
  Response.Write(vbcrlf&tmp)
end sub

'================================================
'作    用：网站IP限制功能模块
'================================================
sub web_no_ip()
  dim tmp
  tmp=CMS_Skin.GetDB("no_ip")
  tmp=Replace(tmp,"{$web_url}",joekoe_cms.web_url) 
  tmp=Replace(tmp,"{$web_name}",joekoe_cms.web_name)
  tmp=Replace(tmp,"{$web_email}",joekoe_cms.web_email)
  Response.Write(vbcrlf&tmp)
end sub

'================================================
'作    用：网站当前在线人数
'================================================
sub web_online()
  sql="select count(l_id) from user_login"
  set rs=joekoe_cms.exec(sql,1)
  application(joekoe_cms.web_cookies&"_web_online")=rs(0)
  rs.close
end sub

function format_add_frame(afvar)
  format_add_frame=vbcrlf&"<table border=0 cellspacing=0 cellpadding=2 width='100%'>"&afvar&vbcrlf&"</table>"
end function

'================================================
'作    用：域名查询
'================================================
sub dmain_searchs()
dim tmp
tmp=CMS_Skin.GetDB("dmain_cxun")
tmp=Replace(tmp,"{$web_skin}",joekoe_cms.web_dir_skin)
Response.Write(vbcrlf&tmp)
end sub

'================================================
'作    用：内页左表格模板
'================================================
sub main_left_table(tit,body,tt,ttype)
  dim w_wid,tmp
  w_wid="70"
  if len(tit)>8 then w_wid="240"
  if len(tit)>20 then w_wid="400"
  if tt=1 then body="<table border=0 width='100%'>"&body&"</table>"
  tmp=CMS_Skin.GetDB("format_lefter")
  tmp=Replace(tmp,"{$wid}",w_wid)
  tmp=Replace(tmp,"{$web_skin}",joekoe_cms.web_dir_skin)
  tmp=Replace(tmp,"{$img}",img_skin(web_img_m))
  tmp=Replace(tmp,"{$tit}",tit)
  tmp=Replace(tmp,"{$body}",body)
  tmp=Replace(tmp,"{$type}",ttype)
  tmp=Replace(tmp,"{$mores}","")
  tmp=Replace(tmp,"{$ends}","")
  tmp=Replace(tmp,"{$ukong}",CMS_Skin.skukong)
  Response.Write(vbcrlf&tmp)
end sub

'================================================
'作    用：内页右表格模板
'================================================
sub main_center_table(tit,body,tt,ttype)
  dim w_wid,tmp
  w_wid="70"
  if len(tit)>8 then w_wid="240"
  if len(tit)>20 then w_wid="400"
  if tt=1 then body="<table border=0 width='100%'>"&body&"</table>"
  tmp=CMS_Skin.GetDB("format_center")
  tmp=Replace(tmp,"{$wid}",w_wid)
  tmp=Replace(tmp,"{$web_skin}",joekoe_cms.web_dir_skin)
  tmp=Replace(tmp,"{$img}",img_skin(web_img_m))
  tmp=Replace(tmp,"{$tit}",tit)
  tmp=Replace(tmp,"{$type}",ttype)
  tmp=Replace(tmp,"{$body}",body)
  tmp=Replace(tmp,"{$mores}","")
  tmp=Replace(tmp,"{$ends}","")
  tmp=Replace(tmp,"{$ukong}",CMS_Skin.skukong)
  Response.Write(vbcrlf&tmp)
end sub

'================================================
'作    用：首页显示模板
'================================================
sub main_center_index(tit,body,tt,ttype)
  dim w_wid,tmp
  w_wid="70"
  if len(tit)>8 then w_wid="240"
  if len(tit)>20 then w_wid="400"
  if tt=1 then body="<table border=0 width='50%'>"&body&"</table>"
  tmp=CMS_Skin.GetDB("format_index")
  tmp=Replace(tmp,"{$wid}",w_wid)
  tmp=Replace(tmp,"{$web_skin}",joekoe_cms.web_dir_skin)
  tmp=Replace(tmp,"{$img}",img_skin(web_img_m))
  tmp=Replace(tmp,"{$article}",main_center_zonghea("article",8,25,0))
  tmp=Replace(tmp,"{$down}",main_center_zonghea("down",8,25,0))
  tmp=Replace(tmp,"{$forum}",main_center_zonghea("forum",8,15,0))
  tmp=Replace(tmp,"{$shop}",main_center_lift("shop",5,10,0))
  tmp=Replace(tmp,"{$pris}",main_center_zonghea("pris",8,25,0))
  tmp=Replace(tmp,"{$flea}",main_center_zonghea("flea",8,25,0))
  tmp=Replace(tmp,"{$job}",main_center_zonghea("job",8,25,0))
  tmp=Replace(tmp,"{$person}",main_center_zonghea("job_person",8,25,0))
  tmp=Replace(tmp,"{$host}",main_center_zonghea("host",8,25,0))
  tmp=Replace(tmp,"{$email}",main_center_zonghea("email",8,25,0))
  tmp=Replace(tmp,"{$vouch}",main_center_lift("gallery",4,10,0))
  tmp=Replace(tmp,"{$video}",main_center_lift("video",4,10,0))
  tmp=Replace(tmp,"{$music_disk}",main_center_lift("music_disk",4,10,0))
  tmp=Replace(tmp,"{$news}",main_news_pic())
  tmp=Replace(tmp,"{$search}",main_search())
  tmp=Replace(tmp,"{$data}",main_left_data())
  tmp=Replace(tmp,"{$linkes}",main_left_linkes())
  tmp=Replace(tmp,"{$gongg}",main_left_update())
  tmp=Replace(tmp,"{$login}",user_login())
  tmp=Replace(tmp,"{$tit}",tit)
  tmp=Replace(tmp,"{$type}",ttype)
  tmp=Replace(tmp,"{$body}",body)
  tmp=Replace(tmp,"{$mores}","")
  tmp=Replace(tmp,"{$ends}","")
  tmp=Replace(tmp,"{$ukong}",CMS_Skin.skukong)
  Response.Write(vbcrlf&tmp)
end sub
%>

