<!--#include file="conn.asp"-->
<!-- #include file="inc/const.asp" -->
<!-- #include file="chkuser.asp" -->
<!--#include file=inc/theme.asp -->
<!--#include file="inc/char.asp"-->
<!--#include file="footer.asp"-->
<%

	stats="保存积分"
	call nav()
	call headline(1)

dim msgtext

if membername="" then
msgtext="<br><br><br>谁叫你来的？<BR><BR>"
call message()

else
call main()
end if

call endline()

'下面是主程序
sub main()
 dim username
 username=membername
 dim stat,online
 dim Srs
 set rs=server.createobject("adodb.recordset")
 sql="select * from [User] where username='"&username&"'"
 rs.open sql,conn,1,1
 if err.number<>0 then 
 msgtext="<br><br><br>数据库操作失败："&err.description&"<BR><BR><BR>"
call message()
  exit sub
 end if

 if rs.eof and rs.bof then
msgtext="<br><br><br>用户不存在! <BR><BR><BR><BR><BR>"
call message()
 exit sub
 else

dim srss,Q,W,C,T
 set Srs=conn.execute("select stats,startime from online where username='"&username&"'")
 online=datediff("n",Srs(1),Now()) '读取在线时间

'online=在线时间（分）

Q=Int(online / 10) '财产值=在现时间/10
W=Int(online / 60) '经验值=在现时间/60
C=1                '增加魅力值
t=30               '在线时间（分）后开始计算

dim rsl,sqll
sqll="select * from [User] where  username='"&username&"'"
    set rsl=server.createobject("adodb.recordset")
 rsl.open sqll,conn,1,3

'userCP     '魅力值
'userEP     '经验值
'userWealth '财产值

if online>T then
 sqll="update [user] set userWealth=userWealth+"&Q&",userEP=userEP+"&W&",userCP=userCP+"&C&" where username='"&username&"'"
    conn.execute(sqll)
    rsl.close
    set rsl=nothing
'保存当前时间
 set Srss=conn.execute("update [online] set startime=Now() where username='"&username&"'") 
 Srs.close
 set Srs=nothing
 rs.close
 set rs=nothing
msgtext="<br>恭喜你~~!<BR>"
msgtext=msgtext&"增加了  "&Q&" 个金币 <br>"
msgtext=msgtext&"增加了  "&w&" 经验值 <br>"
msgtext=msgtext&"增加了  "&c&" 魅力值 <br>"
call message()
else
msgtext="<br><br><br>这么快就想来拿工资？？时间还没有到阿~！<BR><BR><BR>"
call message()
exit sub

end if 
end if
end sub

sub message()
%>
<BR><br><br>
<table cellspacing=0 cellpadding=0 width=350 align=center border=0>
  <tbody>
  <tr> 
    <td valign=bottom align=right width=347 rowspan=2> 
      <table cellspacing=0 cellpadding=0 width="100%" border=0 style="BORDER-RIGHT: #333333 1px solid; BORDER-TOP: #333333 1px solid; BORDER-LEFT: #333333 1px solid; BORDER-BOTTOM: #333333 1px solid;">
        <tbody> 
        <tr align="middle" bgcolor="<%=Tablebackcolor%>">
          <td colspan=4 height=35 style="BORDER-BOTTOM: #333333 1px solid;"><b><font 
            color=#ffffff>保存积分</font></b></td>
        </tr>
        <tr bgcolor="<%=Tabletitlecolor%>">
          <td colspan="4" height="20">&nbsp;</td>
        </tr>
        <tr bgcolor="<%=Tabletitlecolor%>">
		<td colspan="4" nowrap align="center" height="30" >
			<%=msgtext%>
          </td>
        </tr>
        <tr bgcolor="<%=Tabletitlecolor%>">
          <td colspan="4" nowrap align="center" height="50">
<input type="submit" name="Submit2" value="返回" onClick=history.go(-1)> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          </td>
       </tr>
         </tbody>
      </table>
    </td>
    <td width=1 bgcolor=#ffffff height=5></td>
    <td width=1 bgcolor=#ffffff height=5></td>
    <td width=1 bgcolor=#ffffff height=5></td>
  </tr>
  <tr> 
    <td width=1 bgcolor=#333333 height=120></td>
    <td width=1 bgcolor=#666666 height=120></td>
    <td width=1 bgcolor=#999999 height=120></td>
  </tr>
  <tr valign=top align=right> 
    <td colspan=4> 
      <table cellspacing=0 cellpadding=0 width="345" border=0>
        <tbody> 
        <tr> 
          <td bgcolor=#333333 height=1></td>
        </tr>
        <tr> 
          <td bgcolor=#666666 height=1></td>
        </tr>
        <tr> 
          <td bgcolor=#999999 height=1></td>
        </tr>
        </tbody>
      </table>
    </td>
  </tr>
  <tr valign=center align=right> 
    <td colspan=4 height=25>&nbsp;</td>
  </tr>
  <tr valign=top align=right> 
    <td colspan=4 height=25> 
      <div align=center></div>
    </td>
  </tr>
  </tbody>
</table>
</body>
</html>
<%end sub%>
