<%
dim music_se
set music_se=new class_music
class class_music
	function music_free()
	  music_free=true
	  if buy_true then exit function
	  if free_ip then exit function
	  if free_mode then exit function
	  if free_username then exit function
	  music_free=false
	end function
	
	function free_ip()
	  free_ip=false
	  if web_dim(29)<>"" and not isnull(web_dim(29)) then
	    if instr("|"&web_dim(29)&"|","|"&user_ip&"|")<>0 then free_ip=true
	  end if
	end function
	
	function free_username()
	  free_username=false
	  if login_username="" and login_mode="" then exit function
	  if web_dim(30)<>"" and not isnull(web_dim(30)) then
	    if instr("|"&web_dim(30)&"|","|"&login_username&"|")<>0 then free_username=true
	  end if
	end function
	
	function free_mode()
	  free_mode=false
	  if web_dim(27)<>"" and not isnull(web_dim(27)) then
	    if instr("."&web_dim(27)&".","."&login_modep&".")<>0 then free_mode=true
	  end if
	end function

	function buy_true()
	  dim buytim,buytype
	  sql="select top 1 tim,freetype from music_free where username='"&login_username&"' or userip='"&user_ip&"'"
	  set rs=joekoe_cms.exec(sql,1)
	  if rs.eof then
	    rs.close
	    buy_true=false
	    exit function
	  end if
	  buytype=int(rs("freetype"))
	  buytim=rs("tim")
	  rs.close
	  if fc_tim(buytim,buytype) then
 	    call joekoe_cms.exec("delete from music_free where username='"&login_username&"' or userip='"&user_ip&"'",0)
	    response.write joekoe_cms.js_type("alert(""提示：\n\n您的 "&buy_types(buytype)&" 已经到期！请注意重新购买！"");",3)
	    buy_true=false
	    exit function
	  end if
	  buy_true=true
	end function

	function buy_money(bt)
	  dim tmpmoney
	  select case bt
	  case 1
	    tmpmoney=int(web_dim(23))
	  case 2
	    tmpmoney=int(web_dim(24))
	  case else
	    tmpmoney=int(web_dim(25))
	  end select
	  buy_money=int(tmpmoney)
	end function

	function buy_types(bt)
	  select case bt
	  case 1
	    buy_types="月卡"
	  case 2
	    buy_types="季卡"
	  case else
	    buy_types="年卡"
	  end select
	end function

	function fc_tim(btim,bt)
	  dim timusic_dim,tmptim
	  fc_tim=false
	  select case bt
	  case 1
	    tmptim=DATEADD("m",1,btim)
	  case 2
	    tmptim=DATEADD("m",3,btim)
	  case else
	    tmptim=DATEADD("yyyy",1,btim)
	  end select
	  timusic_dim=DateDiff("s",tmptim,joekoe_cms.now_time)
	  if int(timusic_dim)>=0 then fc_tim=true
	end function

	function last_tim(btim,bt)
	  select case bt
	  case 1
	    last_tim=DATEADD("m",1,btim)
	  case 2
	    last_tim=DATEADD("m",3,btim)
	  case else
	    last_tim=DATEADD("yyyy",1,btim)
	  end select
	end function
	
	function music_server(snum,vtype,vurl)
	  dim vdim,vnum,vserver
	  if left(vurl,1)="/" then vurl=left(vurl,len(vurl)-1)
	  if snum=0 then
	    music_server=vurl
	    exit function
	  end if
	  vdim=split(web_dim(28),"$")
	  vnum=ubound(vdim)
	  snum=int(snum-1)
	  if snum>vnum then
	    erase vdim
	    call music_error("错误的音频服务器地址！")
	    exit function
	  end if
	  vserver=vdim(snum)
	  erase vdim
	  vdim=split(vserver,"|")
	  music_server=vdim(vtype)
	  if right(music_server,1)<>"/" then music_server=music_server&"/"
	  music_server=music_server&vurl
	  erase vdim
	end function
end class
%>