<!-- #include file="include/config.asp" -->
<%
tit="影院充值"

call web_head(2,0,0,0,0)
'----------------------------左边 开始----------------------------
call video_sort()
call video_search()
call video_tool()
'----------------------------左边 结束----------------------------
call web_center(0)
'----------------------------中间 开始----------------------------
call video_buy_main()
call video_remark()
call video_end()
'----------------------------中间 结束----------------------------
call web_end(0,0)

sub video_remark()
  video_skin.HtmlNums(18)
  video_skin.HtmlRcod "web_unit",joekoe_cms.web_unit
  video_skin.HtmlRcod "video_dim(0)",web_dim(36)
  video_skin.HtmlRcod "video_dim(1)",web_dim(37)
  video_skin.HtmlRcod "video_dim(2)",web_dim(38)
  video_skin.HtmlView(1)
end sub

sub video_buy_main()
  dim buytype,buytim,buyip,buyusername,lasttim,view_buytype,us_ip
  if video_skin.free_ip or video_skin.free_mode or video_skin.free_username then
    video_skin.HtmlNums(20)
    video_skin.HtmlView(1)
    exit sub
  end if
  sql="select top 1 * from video_free where username='"&login_username&"' or userip='"&user_ip&"'"
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof and rs.bof then
    rs.close
    call video_buy()
    exit sub
  end if
  buytype=int(rs("freetype"))
  buytim=rs("tim")
  buyip=rs("userip")
  buyusername=rs("username")
  rs.close
  if buyip="" or isnull(buyip) then
    us_ip="<font class=red>您未绑定IP！</font>"
  else
    us_ip="<font class=red>您绑定的IP为：</font>"&buyip
  end if
  view_buytype=video_skin.buy_types(buytype)
  if video_skin.fc_tim(buytim,buytype) then
    call joekoe_cms.exec("delete from video_free where username='"&login_username&"' or userip='"&user_ip&"'",0)
    call web_js_msg(1,view_buytype&" 已经到期！请重新购买！","buy.asp")
    exit sub
  end if
  lasttim=video_skin.last_tim(buytim,buytype)
  lasttim=joekoe_cms.time_type(lasttim,1)
  buytim=joekoe_cms.time_type(buytim,1)
  video_skin.HtmlNums(21)
  video_skin.HtmlRcod "buyusername",buyusername
  video_skin.HtmlRcod "us_ip",us_ip
  video_skin.HtmlRcod "view_buytype",view_buytype
  video_skin.HtmlRcod "buytim",buytim
  video_skin.HtmlRcod "lasttim",lasttim
  video_skin.HtmlView(1)
end sub

sub video_buy()
  if joekoe_cms.chk() then
    dim emoney_1,buymoney,buytype,viewtype
    buytype=trim(request.form("types"))
    buytype=int(buytype)
    sql="select top 1 emoney from user_data where username='"&login_username&"' order by id"
    set rs=joekoe_cms.exec(sql,1)
    if rs.eof and rs.bof then
      rs.close
      call web_js_msg(1,"没有找您的注册帐号！","buy.asp")
      exit sub
    end if
    emoney_1=rs("emoney")
    rs.close
    buymoney=video_skin.buy_money(buytype)
    if emoney_1<buymoney then
      call web_js_msg(1,"您的只有 "&emoney_1&"个"&web_dim(9)&"，不够支付费用！","buy.asp")
      exit sub
    end if
    emoney_1=emoney_1-buymoney
    viewtype=video_skin.buy_types(buytype)
    call joekoe_cms.exec("update user_data set emoney="&emoney_1&" where username='"&login_username&"'",0)
    if trim(request.form("userip"))="yes" then
      call joekoe_cms.exec("insert into video_free(username,userip,tim,freetype) values('"&login_username&"','"&user_ip&"','"&joekoe_cms.now_time&"',"&buytype&")",0)
    else
      call joekoe_cms.exec("insert into video_free(username,tim,freetype) values('"&login_username&"','"&joekoe_cms.now_time&"',"&buytype&")",0)
    end if
    call web_js_msg(1,"您已经支付 "&viewtype&" 费用，"&buymoney&"个"&web_dim(9)&"！","buy.asp")
  end if

  video_skin.HtmlNums(19)
  video_skin.HtmlRcod "login_username",login_username
  video_skin.HtmlRcod "user_ip",user_ip
  video_skin.HtmlRcod "buy_money(1)",video_skin.buy_money(1)
  video_skin.HtmlRcod "buy_money(2)",video_skin.buy_money(2)
  video_skin.HtmlRcod "buy_money(3)",video_skin.buy_money(3)
  video_skin.HtmlView(1)
end sub
%>