<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================
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
	
	Public Function free_ip()
		dim ipdim,ipnum
		free_ip=0
		if Music_freeip="" and isnull(Music_freeip) then exit function
		ipdim=split(Music_freeip,"|")
		ipnum=ubound(ipdim)
		for i=0 to ipnum
			if Instr("$"&user_ip&".","$"&ipdim(i)&".")>0 then			
				free_ip=1
				erase ipdim
				exit function
			End If
		next
		erase ipdim
	End Function
	
	Public Function free_username()
		free_username=0
		if login_username="" and login_mode="" then exit function
		if Music_freename<>"" and not isnull(Music_freename) then
			if instr("|"&Music_freename&"|","|"&login_username&"|")<>0 then free_username=1
		End If
	End Function

	Public Function free_mode()
		free_mode=0
		if Music_freegroup<>"" and not isnull(Music_freegroup) then
			if instr("."&Music_freegroup&".","."&login_modep&".")<>0 then free_mode=1
		End If
	End Function

	Public Function buy_true()
		dim buytim,buytype
		sql="select top 1 tim,freetype from AsaiMHMusicFree where username='"&login_username&"' or userip='"&user_ip&"'"
		set rs=Cls.exec(sql,1)
		if rs.eof then
			rs.close
			buy_true=0
			exit function
		End If
		buytype=int(rs("freetype"))
		buytim=rs("tim")
		rs.close
		if fc_tim(buytim,buytype) then
			call Cls.exec("delete from AsaiMHMusicFree where username='"&login_username&"' or userip='"&user_ip&"'",0)
			Response.Write Cls.js_put("alert(""提示：\n\n您的 "&buy_types(buytype)&" 已经到期！请注意重新购买！"");",1)
			buy_true=0
			exit function
		End If
		buy_true=1
	End Function

	Public Function buy_money(bt)
		dim tmpmoney
		select case bt
		case 1
			tmpmoney=int(Music_Month)
		case 2
			tmpmoney=int(Music_Quarter)
		case else
			tmpmoney=int(Music_Year)
		end select
		buy_money=int(tmpmoney)
	End Function

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

	Public Function fc_tim(btim,bt)
		dim tim_dim,tmptim
		fc_tim=0
		tmptim=last_tim(btim,bt)
		tim_dim=DateDiff("s",tmptim,Cls.now_time)
		if int(tim_dim)>=0 then fc_tim=1
	End Function

	Public 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
%>