<!-- #include file="Conn.asp" -->
<%
if IsNumeric(Request.Cookies("UserID")) then
sql="select * from [BBSXP_Users] where ID="&Request.Cookies("UserID")&""
Set Rs=Conn.Execute(SQL)
if Rs.eof then
CleanCookies()
Response.Write "<script>window.setTimeout('window.location.reload();',2000)</script>"
Response.End
end if
if Request.Cookies("Userpass") <> Rs("Userpass") then
CleanCookies()
Response.Write "<script>window.setTimeout('window.location.reload();',2000)</script>"
Response.End
end if
CookieUserName=Rs("UserName")
rs.close
end if
Function CleanCookies()
DomainPath=Left(Request.ServerVariables("script_name"),inStrRev(Request.ServerVariables("script_name"),"/"))
For Each objCookie In Request.Cookies
Response.Cookies(objCookie)= ""
Response.Cookies(objCookie).Path = DomainPath
Next
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
UserMoney=Conn.Execute("Select UserMoney From [BBSXP_Users] where username='"&CookieUserName&"'")(0)
money=int(Request.Form("money"))
if money > UserMoney or money < 0 then Response.End


if request.Form("menu")="loading" then response.Write("&money="&UserMoney&"&"&"user="&CookieUserName)

if Request.Form("menu")="item0" then

	Randomize
	winNumBanker0=int(rnd*6)+1 
	winNumBanker1=int(rnd*6)+1 
	winNumBanker2=int(rnd*6)+1 
	winNumPlayer0=int(rnd*6)+1 
	winNumPlayer1=int(rnd*6)+1 
	winNumPlayer2=int(rnd*6)+1 
	winNumBanker=winNumBanker0+winNumBanker1+winNumBanker2
	winNumPlayer=winNumPlayer0+winNumPlayer1+winNumPlayer2
	winNumBankerStr=winNumBanker0&"^"&winNumBanker1&"^"&winNumBanker2
	winNumPlayerStr=winNumPlayer0&"^"&winNumPlayer1&"^"&winNumPlayer2
	if winNumPlayer > winNumBanker then
	  winMoney=money
	  else
	  winMoney=-money
	end if
	UserMoney=UserMoney+int(winMoney)
	conn.execute("update [BBSXP_Users] set [UserMoney]="&UserMoney&" where username='"&CookieUserName&"'")
	Response.Write("&winNumBanker="&winNumBankerStr&"&winNumPlayer="&winNumPlayerStr&"&userMoney="&UserMoney)
end if

if Request.Form("menu")="item1" then
	selectNum=int(Request.Form("select"))
	Randomize
	winNum=int(rnd*6)+1 
	if selectNum=winNum then
	  winMoney=money * 5
	  else
	  winMoney=-money
	end if
	UserMoney=UserMoney+int(winMoney)
	conn.execute("update [BBSXP_Users] set [UserMoney]="&UserMoney&" where username='"&CookieUserName&"'")
	Response.Write("&winNum="&winNum&"&userMoney="&UserMoney)
end if

if Request.Form("menu")="item2" then
	selectNum=int(Request.Form("select"))
	Randomize
	winNum0=int(rnd*6)+1
	winNum1=int(rnd*6)+1
	winNum2=int(rnd*6)+1
	winNumStr=winNum0 & "^" & winNum1 & "^" & winNum2
	if selectNum=winNum0 AND winNum0=winNum1 AND winNum1=winNum2 then
	  winMoney=money * 100
	  else
	  winMoney=-money
	end if
	UserMoney=UserMoney+int(winMoney)
	conn.execute("update [BBSXP_Users] set [UserMoney]="&UserMoney&" where username='"&CookieUserName&"'")
	Response.Write("&winNum="&winNumStr&"&userMoney="&UserMoney)
end if
%>