<!-- #include file=../inc/BBSsetup.asp -->
<!-- #include file=../inc/Board_Popfun.asp -->
<!-- #include file=../inc/Limit_Fun.asp -->
<!-- #include file=inc/UserTopic.asp -->
<%
'Time Stamp Begin
'0.2_2_10_1117766_20040711090800
'Time Stamp End

'LeadBBS Vip v0.2
'http://ashi.cn
'Copyright(C) ashi oNet, All rights reserved.
'----------
'禁止任何人以任何形式在未经过ashi本人同意的情况下对此插件进行转载。

Response.Expires = 0
Response.ExpiresAbsolute = DEF_Now - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private" 
Response.CacheControl = "no-cache"

DEF_BBS_HomeUrl = "../"

Dim Rs,SQL
Dim UserPoints,UserLevel,UserCharmPoint,UserAnnounceNum,UserOnlineTime,UserCount
Dim NeedPoints,NeedLevel,NeedCharmPoint,NeedAnnounceNum,NeedOnlineTime,NeedCount
Dim ApplyDay,UserApplyDay,ApplyDayNum
Dim Vip_Msg_Str,IsVip,VipUntil,VipUserNum,VipRegEn
Dim SubmitFlag,SuperUserFlag

Vip_Msg_Str = ""
GBL_CHK_TempStr = ""
VipRegEn = ""														'此变量为空时，VIP申请开启

SubmitFlag = Request("SubmitFlag")
SuperUserFlag = CheckSupervisorUserName

NeedCount		 = 2												'定义需要满足的条件共几条

ApplyDay		 = Array(1,5,10,30,90,365,0)						'定义可申请的天数选择，必须为数组，0 为永久
NeedPoints		 = Array(10,500,800,1500,3000,10000,1000000)		'定义手续费用 最低为0，和上边的相对应，必须为数组
NeedLevel		 = Array(1,3,5,7,10,12,18)							'定义需求等级 最低为0，和上边的相对应，必须为数组
NeedCharmPoint	 = Array(0,5,10,20,40,100,120)						'定义需求魅力 最低为0，和上边的相对应，必须为数组
NeedAnnounceNum	 = Array(2,10,80,100,400,800,1000)					'定以需求发帖 最低为0，和上边的相对应，必须为数组
NeedOnlineTime	 = Array(0,40,400,1000,5000,10000,20000)			'定义需求经验 最低为0，和上边的相对应，必须为数组

ApplyDayNum = Ubound(ApplyDay,1)

UserApplyDay = Request("Ad")
If isNumeric(UserApplyDay) = False or inStr(UserApplyDay,".") > 0 Then UserApplyDay = 0
UserApplyDay = cCur(UserApplyDay)
If UserApplyDay > ApplyDayNum Then UserApplyDay = ApplyDayNum

initDatabase

SiteHead(DEF_SiteNameString & " - 用户会员区")
UpdateOnlineUserAtInfo GBL_board_ID,"社区VIP申请"
UserTopicTopInfo
DisplayUserNavigate("社区VIP申请")

If GBL_CHK_Flag = 1 Then

	Response.Write "<table width=96% ><tr><td><br>"
	If VipRegEn = "" or SuperUserFlag = 1 Then
		If GetUserData = 1 Then
			Select Case SubmitFlag
				Case "VipApply": ApplyVip
				Case "Clear": ClearAllVip
			End Select
			If GBL_CHK_TempStr <> "" Then
				Response.Write "<p align=left><font color=ff0000 class=RedFont><b>" & GBL_CHK_TempStr & "</b></font><br>"
			End If
			If Vip_Msg_Str = "" Then
				VIP
			Else
				Response.Write "<table cellspacing=0 cellpadding=0 width=100% border=0 height=5><tr><td colspan=2 height=0><img src=../images/BLANK.GIF width=1 height=1></td></tr></table>"
				Response.Write "<br><table width=100% border=0 cellspacing=1 cellpadding=2 bgcolor=" & DEF_BBS_LightColor & " class=TBBG1><tbody>"
				Response.Write "<tr height=19 bgcolor=" & DEF_BBS_TableHeadColor & " class=TBfour>"
				Response.Write "<td align=center><img src=../images/BLANK.GIF width=1 height=3><br>社区VIP申请操作反馈</td></tr>"
				Response.Write "<tr height=19 bgcolor=" & DEF_BBS_TableHeadColor & " class=TBBG9>"
				Response.Write "<td><table width=100% border=0 cellspacing=0 cellpadding=5><tr><td><img src=../images/BLANK.GIF width=1 height=3><br>"
				Response.Write Vip_Msg_Str
				Response.Write "<br>系统将于10秒后返回，如果您的浏览器没有自动跳转请<a href=uservip.asp>点击这里</a>。</td></tr></table></td></tr></table>"
				Response.Write "<meta http-equiv=""refresh"" content=""10;url=UserVip.asp"">"
			End If
		Else
			Response.Write "<b>" & GBL_CHK_TempStr & "</b>"
		End If
	Else
		Response.Write "<p align=left><b>" & VipRegEn & "</b><br>"
	End If
	Response.Write "</td></tr></table>"
Else
	GBL_CHK_TempStr = GBL_CHK_TempStr & "<font color=ff0000 class=RedFont><b>你没有登录</b></font><br>" & VbCrLf
	Response.Write "<p align=left>" & GBL_CHK_TempStr & "</p>"
End If

UserTopicBottomInfo
closeDataBase
SiteBottom
If GBL_ShowBottomSure = 1 Then Response.Write GBL_SiteBottomString

Function GetUserData

	If GBL_CHK_OnlineTime < DEF_NeedOnlineTime and DEF_NeedOnlineTime > 0 and SuperUserFlag = 0 Then
		GBL_CHK_TempStr = "论坛限制在线时间(经验)" & Fix(DEF_NeedOnlineTime/60) & "分以上用户才能使用此功能。<br>" & VbCrLf
		GetUserData = 0
		Exit Function
	End If

	Set Rs = Con.ExeCute("Select Top 1 UserLevel,AnnounceNum2 From LeadBBS_User Where id=" & GBL_UserID)
	GBL_DBNum = GBL_DBNum + 1
	
	If Rs.Eof Then
		Rs.Close
		Set Rs = Nothing
		GBL_CHK_TempStr = GBL_CHK_TempStr & "发生意外错误<br>" & VbCrLf
		GetUserData = 0
		Exit Function
	Else
		GetUserData = 1
	End If
	
	UserLevel = Rs(0)
	UserAnnounceNum = Rs(1)
	UserPoints = GBL_CHK_Points
	UserCharmPoint = GBL_CHK_CharmPoint
	UserOnlineTime = Fix(GBL_CHK_OnlineTime / 60)
	
	UserCount = 0
	If NeedAnnounceNum(UserApplyDay) <= UserAnnounceNum Then UserCount = UserCount +1
	If NeedCharmPoint(UserApplyDay) <= UserCharmPoint Then UserCount = UserCount +1
	If NeedLevel(UserApplyDay) <= UserLevel Then UserCount = UserCount +1
	If NeedOnlineTime(UserApplyDay) <= UserOnlineTime Then UserCount = UserCount +1
	
	Rs.Close
	Set Rs = Nothing
	
	If GetBinarybit(GBL_CHK_UserLimit,15) = 1 Then
	
		Dim ExpiresTime
		Set Rs = Con.ExeCute("Select TOP 1 ExpiresTime from LeadBBS_SpecialUser Where Assort=8 and UserID=" & GBL_UserID)
		GBL_DBNum = GBL_DBNum + 1
		If Rs.Eof Then
			CancelVip
			IsVip = 0
		Else
			IsVip = 1
			ExpiresTime = cCur(Rs(0))
			If ExpiresTime> 0 Then
				ExpiresTime = RestoreTime(ExpiresTime)
				VipUntil = Fix(datediff("h",DEF_Now,ExpiresTime)/24)
				If VipUntil <= 0 Then
					CancelVip
					IsVip = 0
				End If
			Else
				VipUntil = -1
			End If
		End If
		Rs.Close
		Set Rs = Nothing
		
	End If
	
	Set Rs = Con.ExeCute("Select Count(*) from LeadBBS_SpecialUser Where Assort=8")
	GBL_DBNum = GBL_DBNum + 1
	VipUserNum = Rs(0)
	If isNumeric(VipUserNum) = False or VipUserNum < 0 Then VipUserNum = 0
	Rs.Close
	Set Rs = Nothing
			
End Function

Function ApplyVip
	
	Dim ExpiresTime
	If IsVip = 1 Then
		GBL_CHK_TempStr = GBL_CHK_TempStr & "您已经是VIP，请不要重复申请!<br>"
		Exit Function
	End If
	If DEF_EnableAttestNumber > 2 Then
		If CheckRndNumber = 0 Then
			GBL_CHK_TempStr = GBL_CHK_TempStr & "验证码填写错误!<br>"
			Exit Function
		End If
	End If
	If NeedPoints(UserApplyDay) > UserPoints Then
		GBL_CHK_TempStr = GBL_CHK_TempStr & "您没有足够的金钱!<br>"
		Exit Function
	End If
	If NeedCount > UserCount Then
		GBL_CHK_TempStr = GBL_CHK_TempStr & "您没有足够的属性!<br>"
		Exit Function
	End If
	ExpiresTime = ApplyDay(UserApplyDay)
	If ExpiresTime > 0 Then ExpiresTime = GetTimeValue(DEF_Now + ApplyDay(UserApplyDay))
	Con.ExeCute("Update LeadBBS_User Set Points=Points-" & NeedPoints(UserApplyDay) & ",UserLimit=" & SetBinaryBit(GBL_CHK_UserLimit,15,1) & UpdateUserLaseWriteTime & " Where ID=" & GBL_UserID)
	GBL_DBNum = GBL_DBNum + 1
	Con.ExeCute("Insert Into LeadBBS_SpecialUser(UserID,UserName,BoardID,Assort,ndatetime,ExpiresTime,WhyString) Values(" & GBL_UserID & ",'" & Replace(GBL_CHK_User,"'","''") & "',0,8," & GetTimeValue(DEF_Now) & "," & ExpiresTime & ",'前台申请')")
	GBL_DBNum = GBL_DBNum + 1
	UpdateSessionValue 2,SetBinaryBit(GBL_CHK_UserLimit,15,1),0
	UpdateSessionValue 4,0-NeedPoints(UserApplyDay),1
	
	Vip_Msg_Str = Vip_Msg_Str & "<font color=Green class=GreenFont><b>操作成功，此次操作：</b></font>"
	Vip_Msg_Str = Vip_Msg_Str & "<br><br>"
	Vip_Msg_Str = Vip_Msg_Str & "<li>" & "您共消费：" & NeedPoints(UserApplyDay) & " " & DEF_PointsName & "</li>"
	Vip_Msg_Str = Vip_Msg_Str & "<li>" & "您已经成功申请成为VIP会员</li>"
	Vip_Msg_Str = Vip_Msg_Str & "<br><br>"

End Function

Function CancelVip
	
	Con.ExeCute("Update LeadBBS_User Set UserLimit=" & SetBinaryBit(GBL_CHK_UserLimit,15,0) & " Where ID=" & GBL_UserID)
	GBL_DBNum = GBL_DBNum + 1
	Con.ExeCute("Delete From LeadBBS_SpecialUser Where Assort=8 And UserID=" & GBL_UserID)
	GBL_DBNum = GBL_DBNum + 1
	UpdateSessionValue 2,SetBinaryBit(GBL_CHK_UserLimit,15,0),0

End Function

Function ClearAllVip

	Dim Tmp,GetData,N
	If SuperUserFlag = 0 Then Exit Function
	Set Tmp = Con.ExeCute("Select T1.UserID,T2.UserLimit,T2.UserName From LeadBBS_SpecialUser as T1 left join LeadBBS_User as T2 on T2.Id=T1.Userid Where T1.Assort=8 And T1.WhyString='前台申请'")
	If Not Tmp.Eof Then
		GetData = Tmp.GetRows(-1)
	Else
		Tmp.Close
		Set Tmp = Nothing
		GBL_CHK_TempStr = GBL_CHK_TempStr & "没有需要清除的VIP用户!<br>"
		Exit Function
	End If
	Tmp.Close
	Set Tmp = Nothing
	For N = 0 to Ubound(GetData,2)
		Con.ExeCute("Update LeadBBS_User Set UserLimit=" & SetBinaryBit(GetData(1,N),15,0) & " Where ID=" & GetData(0,N))
		GBL_DBNum = GBL_DBNum + 1
		Con.ExeCute("Delete From LeadBBS_SpecialUser Where Assort=8 And UserID=" & GetData(0,N))
		GBL_DBNum = GBL_DBNum + 1
		GBL_CHK_TempStr = GBL_CHK_TempStr & "您已经成功清除" & GetData(2,N) & "!<br>"
	Next
	GBL_CHK_TempStr = GBL_CHK_TempStr & "您已经成功清除" & N & "位VIP用户!<br>"

End Function

Function UpdateUserLaseWriteTime

	If SuperUserFlag = 1 Then Exit Function
	UpdateSessionValue 13,GetTimeValue(DEF_Now),0
	UpdateUserLaseWriteTime = ",LastWriteTime=" & GetTimeValue(DEF_Now)

End Function

Function CheckRndNumber

	Dim RndNumber
	RndNumber = Left(Session(DEF_MasterCookies & "RndNum") & "",4)
	If RndNumber = "" or isNumeric(RndNumber) = 0 Then
		'RndNumber = 0
		Randomize
		RndNumber = Fix(Rnd*9999)+1
		Session(DEF_MasterCookies & "RndNum") = RndNumber
	End If
	RndNumber = cCur(RndNumber)
	
	Dim ForumNumber
	ForumNumber = Left(Request.Form("ForumNumber"),4)
	If isNumeric(ForumNumber) = False Then ForumNumber = 0
	ForumNumber = Fix(cCur(ForumNumber))
	If RndNumber = ForumNumber and RndNumber > 0 Then
		CheckRndNumber = 1
	Else
		CheckRndNumber = 0
	End If
	Randomize
	Session(DEF_MasterCookies & "RndNum") = Fix(Rnd*9999)+1

End Function

Function VIP

	Dim Could,N
	%>
	<table cellspacing=0 cellpadding=0 width=100% border=0 height=5><tr><td>
	<img src=../images/Blank.GIF width=1 height=1></td></tr></table>
	<b title="<%=DEF_SiteNameString%> 社区银行">欢迎光临 <%=DEF_SiteNameString%> 社区VIP申请办事处</b>
	<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="<%=DEF_BBS_LightColor%>" class="TBBG1">
		<tr height="19" bgcolor="<%=DEF_BBS_TableHeadColor%>" class="TBfour">
			<td align="center" colspan="4">
			<img src="../images/BLANK.GIF" width="1" height="3"><br>
			您的信息</td>
		</tr>
		<tr class="TBBG9" height="19">
			<td width="22%" align="right">您的姓名为：</td>
			<td colspan="3">&nbsp;<%=GBL_CHK_User%></td>
		</tr>
		<tr class="TBBG9" height="19">
			<td width="22%" align="right">您当前的现金为：</td>
			<td width="28%">&nbsp;<b><%=UserPoints%></b> <%=DEF_PointsName%></td>
			<td width="22%" align="right">需要的手续费为：</td>
			<td width="28%">&nbsp;<b><%
		If IsVip = 0 Then
			If NeedPoints(UserApplyDay) > UserPoints Then
				Response.Write "<font color=red class=redfont>" & NeedPoints(UserApplyDay) & "</font>"
			Else
				Response.Write NeedPoints(UserApplyDay)
			End If
		Else
			Response.Write "0"
		End If
		Response.Write "</b> " & DEF_PointsName
			%></td>
		</tr>
		<tr class="TBBG9" height="19">
			<td width="22%" align="right">您的帖子数为：</td>
			<td width="28%">&nbsp;<%=UserAnnounceNum%> 贴</td>
			<td width="22%" align="right">需要的帖子数为：</td>
			<td width="28%">&nbsp;<%
		If NeedAnnounceNum(UserApplyDay) > UserAnnounceNum Then
			Response.Write "<font color=red class=redfont>" & NeedAnnounceNum(UserApplyDay) & "</font>"
		Else
			Response.Write NeedAnnounceNum(UserApplyDay)
		End If
		Response.Write " 贴"
			%></td>
		</tr>
		<tr class="TBBG9" height="19">
			<td width="22%" align="right">您当前的魅力为：</td>
			<td width="28%">&nbsp;<%=UserCharmPoint%></td>
			<td width="22%" align="right">需要的魅力为：</td>
			<td width="28%">&nbsp;<%
		If NeedCharmPoint(UserApplyDay) > UserCharmPoint Then
			Response.Write "<font color=red class=redfont>" & NeedCharmPoint(UserApplyDay) & "</font>"
		Else
			Response.Write NeedCharmPoint(UserApplyDay)
		End If
			%></td>
		</tr>
		<tr class="TBBG9" height="19">
			<td width="22%" align="right">您当前的经验为：</td>
			<td width="28%">&nbsp;<%=UserOnlineTime%></td>
			<td width="22%" align="right">需要的经验为：</td>
			<td width="28%">&nbsp;<%
		If NeedOnlineTime(UserApplyDay) > UserOnlineTime Then
			Response.Write "<font color=red class=redfont>" & NeedOnlineTime(UserApplyDay) & "</font>"
		Else
			Response.Write NeedOnlineTime(UserApplyDay)
		End If
			%></td>
		</tr>
		<tr class="TBBG9" height="19">
			<td width="22%" align="right">您当前的等级为：</td>
			<td width="28%">&nbsp;<%="<img src=" & DEF_BBS_HomeUrl & "images/" & GBL_DefineImage & "lvstar/level" & UserLevel & ".gif align=absmiddle width=110 height=11>"%></td>
			<td width="22%" align="right">需要的等级为：</td>
			<td width="28%">&nbsp;<%
		If NeedLevel(UserApplyDay) > UserLevel Then
			Response.Write "<img src=" & DEF_BBS_HomeUrl & "images/" & GBL_DefineImage & "lvstar/level" & NeedLevel(UserApplyDay) & ".gif style=Filter:Gray align=absmiddle width=110 height=11>"
		Else
			Response.Write "<img src=" & DEF_BBS_HomeUrl & "images/" & GBL_DefineImage & "lvstar/level" & NeedLevel(UserApplyDay) & ".gif align=absmiddle width=110 height=11>"
		End If
			%></td>
		</tr>
	</table>
	<br>
	<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="<%=DEF_BBS_LightColor%>" class="TBBG1">
		<tr height="19" bgcolor="<%=DEF_BBS_TableHeadColor%>" class="TBfour">
			<td align="center" colspan="4">
			<img src="../images/BLANK.GIF" width="1" height="3"><br>
			论坛信息</td>
		</tr>
		<tr class="TBBG9" height="19">
			<td width="22%" align="right">共有VIP用户：</td>
			<td colspan="3">&nbsp;<%=VipUserNum%> 人</td>
		</tr>
	</table>
	<br>
	<%If IsVip = 0 Then%>
	<table width="100%" border="0" cellspacing="1" cellpadding="2" bordercolor="#000000" bgcolor="<%=DEF_BBS_LightColor%>" class="TBBG1">
		<tr height="19" bgcolor="<%=DEF_BBS_TableHeadColor%>" class="TBfour">
			<td align="center" colspan="2">
			<img src="../images/BLANK.GIF" width="1" height="3"><br>
			VIP申请服务</td>
		</tr>
		<%If DEF_EnableAttestNumber > 2 Then%>
		<script language="javascript">
		function Check(obj)
		{
			ValidationPassed = true;
			if(obj.ForumNumber.value=="")
			{
				alert("请输入验证码!\n");
				ValidationPassed = false;
				obj.ForumNumber.focus();
				return;
			}
		}
		</script>
		<form action=UserVip.asp?Ad=<%=UserApplyDay%> method=post name=LeadBBSVipApply onsubmit="Check(this); return ValidationPassed">
		<tr class="TBBG9" height="30">
			<td width="12%" align="right">验证：</td>
			<td>
			<table cellpadding="1" cellspacing="3" border="0" width="100%">
				<tr>
					<td>
					<input name="ForumNumber" maxlength="4" size="4" class="fminpt">
					<font color="blue" class="bluefont">请在框中输入</font>
					<img src="<%=DEF_BBS_HomeUrl%>User/number.asp?n=<%=timer%>" align="absmiddle" width="32" height="12">
					</td>
				</tr>
			</table>
			</td>
		</tr><%
		Else
			Response.Write "<form action=UserVip.asp?Ad=" & UserApplyDay & " method=post name=LeadBBSVipApply>"
		End If%>
		<tr class="TBBG9" height="30">
			<td width="12%" align="right">天数：</td>
			<td>
			<table cellpadding="1" cellspacing="3" border="0" width="100%">
				<tr>
					<td><%
					Response.Write "<select name=Form_ApplyDay onchange=""document.location.href='?Ad='+this.selectedIndex"" class=TBBG9>"
					For N = 0 To ApplyDayNum
						Response.Write "<option"
						If N = UserApplyDay Then Response.Write " selected"
						Response.Write ">"
						If ApplyDay(N) > 0 Then
							Response.Write ApplyDay(N) & " 天"
						ElseIf ApplyDay(N) = 0 Then
							Response.Write "永久"
						End If
						Response.Write "</option>"
					Next
					Response.Write "</select>"
					%></td>
				</tr>
			</table>
			</td>
		</tr>
		<tr class="TBBG9" height="30">
			<td width="12%" align="right">申请：</td>
			<td>
			<input type="hidden" name="SubmitFlag" value="VipApply">
			<table cellpadding="1" cellspacing="3" border="0" width="100%">
				<tr>
					<td width="82%"><%
					If NeedPoints(UserApplyDay) > UserPoints Then
						Response.Write "<font color=red class=redfont>您的钱不够啊..."
					Else
						If UserCount >= NeedCount Then
							Response.Write "<font color=blue class=bluefont>您有足够的金钱缴纳申请手续费，而且您也符合其他的要求。"
							Could = 1
						Else
							Response.Write "<font color=red class=redfont>您有足够的金钱缴纳申请手续费，但是您不符合其他的要求..."
						End If
					End If
					Response.Write "</font>"
					%></td>
					<td align="right" width="18%"><%
					Response.Write "<input name=submit type=submit value="" 申 请 "" class=fmbtn"
					If Could <> 1 Then Response.Write " disabled"
					Response.Write ">"
					%></td>
				</tr>
			</table>
			</td>
		</tr>
		</form>
	</table>
	<%Else%>
	<table width="100%" border="0" cellspacing="1" cellpadding="2" bordercolor="#000000" bgcolor="<%=DEF_BBS_LightColor%>" class="TBBG1">
		<tr height="19" bgcolor="<%=DEF_BBS_TableHeadColor%>" class="TBfour">
			<td align="center" colspan="2">
			<img src="../images/BLANK.GIF" width="1" height="3"><br>
			VIP服务</td>
		</tr>
		<tr class="TBBG9" height="30">
			<td width="12%" align="right">到期：</td>
			<td>
			<input type="hidden" name="SubmitFlag" value="Go">
			<table cellpadding="1" cellspacing="3" border="0" width="100%">
				<tr>
					<td><%
					Response.Write "<font color=blue class=bluefont>"
					If VipUntil = -1 Then
						Response.Write "永久有效"
					Else
						Response.Write VipUntil & " 天后到期..."
					End If
					Response.Write "</font>"
					%></td>
				</tr>
			</table>
			</td>
		</tr>
	</table>
	<%
	End If
	Response.Write "<p><b>说明：</b></p><p>"
	Response.Write "1.<font color=red class=redfont>必须缴纳手续费，并且其他项目必须满足" & NeedCount & "项，才可以申请VIP。</font><br>"
	Response.Write "2.申请VIP后可以享受社区中的相关服务，具体请查看<a href=help/help.asp#lmt>系统帮助</a>。<br>"
	Response.Write "3.申请VIP后，您可以到这里察看您还有多少的时间服务到期。<br>"
	Response.Write "4.申请VIP后，直道到期不能返回普通用户，并且不退还申请费。<br>"
	If SuperUserFlag = 1 Then
		Response.Write "5.<font color=red class=redfont>您是管理员，点击<a href=UserVip.asp?SubmitFlag=Clear><font color=red class=redfont>这里</font></a>清除所有前台申请的VIP用户。</font><br>"
	End If
	Response.Write "</p>"
	Response.Write "<p>LeadBBS VIP v0.2 - LeadBBS 3.14 Plus! Powered By ashi</p>"
	
End Function
%>