<!--#include file="user_top.asp"-->
</head>
<body  style="overflow:hidden;" class="user_iframe">
<script language="javascript">
	function CopyIt(_sTxt){
		try{
			clipboardData.setData('Text',_sTxt);
			alert('验证码 ' + _sTxt +' 已复制到剪贴板!');
			}
		catch(e)
		{}
		}
</script>
<%
If oblog.CacheConfig(17)=0 Then
	%>
	<table  class="win_user_team_table" align="center" border="0" cellpadding="0" cellspacing="1">
			  <tr>
				<td class="win_user_team_table_top" colspan="2">说明</td>
			  </tr>
			  <tr>
			   <td>
		    	系统未启用邀请机制
		    </td>
		</tr>
		</table>
	<%
	Response.End
End If
If oblog.l_Group(8,0)=0 Then
	%>
		<table  class="win_user_team_table" align="center" border="0" cellpadding="0" cellspacing="1">
			  <tr>
				<td class="win_user_team_table_top" colspan="2">说明</td>
			  </tr>
			  <tr>
			   <td>
		    	您所在的分组还不允许邀请他人加入，加油哦
		    </td>
		</tr>
		</table>
		<%
		Response.End
End If

Dim rs,Sql
Set rs=Server.CreateObject("Adodb.Recordset")
G_P_FileName="user_codes.asp?page="
Call List
Set rs=Nothing
%>

</body>
</html>

<%

Sub List()
Dim bTrue,i,lPage,lAll,lPages,iPage
bTrue=false
	'规则,每天可用的GUID数目
	'首先判断当天是否已经生成过了
	Sql="Select lastCode From oblog_user Where userid=" & oblog.l_uid
	Set rs=oblog.Execute(Sql)
	If rs(0)="" Or IsNull(rs(0)) Then
		bTrue=true
	Else
		If datediff("d",rs(0),date)=0 Then
			bTrue=false
		Else
			bTrue=true
		End If
	End If
	rs.Close
	If bTrue Then
		For i=1 To oblog.l_Group(8,0)
			Sql="Insert into oblog_obcodes(obcode,creatuser,createtime,creatip,itype,istate) Values('"
			Sql=Sql & GetGUID & "'," & oblog.l_uid&",'" & Date & "','" & oblog.userip & "',0,0)"
			oblog.execute Sql
		Next
		oblog.Execute "Update oblog_user Set lastcode='" & Date &"' Where userid=" & oblog.l_uid
	End If
	rs.Open "Select obcode,createtime From oblog_obcodes  Where creatuser=" & oblog.l_uid & " And iState=0 And iType=0 Order By createtime",conn,1,3	
lAll=INT(rs.recordcount)
    If lAll=0 Then    	
    	rs.Close
    	Set rs=Nothing
    	%>
    	<table  class="win_user_team_table" align="center" border="0" cellpadding="0" cellspacing="1">
			  <tr>
				<td class="win_user_team_table_top" colspan="2">说明</td>
			  </tr>
			  <tr>
			   <td>
		    	您目前无可用邀请码
		    </td>
		</tr>
		</table>
    	<%
    	Exit Sub
    End If
    i=0
    iPage=10
	'分页
	If Request("page") = "" Or Request("page") ="0" then
		lPage = 1
	Else
		lPage = Int(Request("page"))
	End If
	
	'设置缓存大小 = 每页需显示的记录数目
	rs.CacheSize = iPage
	rs.PageSize = iPage
	rs.movefirst		
	lPages = rs.PageCount
	If lPage>lPages Then lPage=lPages
	rs.AbsolutePage = lPage
	i=0
	%>
	<ul id="user_page_top">
		可用邀请码
	</ul>
	<div id="showpage">
	  <%=MakeMiniPageBar(lAll,iPage,lPage,G_P_FileName)%>
	</div>
	<div id="dTab13" class="Box">
	<br/>
	<table  width=400 class="win_user_team_table" align="center" border="0" cellpadding="0" cellspacing="1">
	  <tr>
		<td class="win_user_team_table_top" colspan="2">说明</td>
	  </tr>
	  <tr>
	   <td colspan=2>
    	&nbsp;&nbsp;您每天可获得 <%=oblog.l_Group(8,0)%> 个可用邀请码
    	<br/>
  		&nbsp;&nbsp;系统每天自动回收 15 天前创建且未被使用的邀请码
    </td>
</tr>
	  <form name="form1">
	  <tr>
		<td width=30>序号</td>
		<td>邀请码</td>
	  </tr>
	<%
	do while not rs.eof
		i = i + 1
		%>
		 <tr>
		<td width=30><%=Right("00"&i,3)%> </td>
		<td><input type="text" value="<%=rs(0)%>" size=50% name="code<%=i%>"  id="code<%=i%>"  onclick="CopyIt('<%=rs(0)%>')"/></td>
	  </tr>
<%

    If i >= iPage Then Exit Do
    rs.Movenext
Loop
%>
</form>
</table>
</div>
	<%
	rs.Close
	Set rs=Nothing	
End Sub

%>