<!--#include file="Inc.asp"-->
<%

'================================
'当前版本号：3.0
'程序作者：杜杜
'杜杜 版权所有'http://www.ju4t.com
'================================

<!--主体程序调用开始-->
If Not BBS94KK.Founduser Then BBS94KK.GoToErr(10)
If int(SESSION(CacheName & "MyInfo")(7))<10 Then 	Response.Write ("<script type='text/javascript'>alert('您的钱太少了,游戏限定金钱100以上才能玩！');window.location.href='Index.asp';</script>"):Response.End

If Not IsObject(Conn) Then ConnectionDatabase
dim sql,rs,founderr,i,errmsg
Dim wcdb,rswc,connwc,SQLM
Dim player,score,sqlwc,game,per,addmoney,RSWCC,gameid,game2,score2,highscore,award1,award2,winmsg,connwcc,execc,execcc,usern,highname,gameurl,gamename
Dim istop,newtop,messagebox
Dim scriptstr,isplayed,scriptheadstr

founderr=false
wcdb="wc_game/wc_high-score.mdb"
connwc="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(wcdb)
set rswc=Server.CreateObject("ADODB.recordset")
set rswcc=Server.CreateObject("ADODB.recordset")
set connwcc=server.createobject("adodb.connection")
connwcc.open connwc

Dim plustitle,backasp
plustitle = "休闲屋"
backasp   = "wc_room.asp"

select case request("act")
case "games"
	call games()
case "script"
	call script
case "showhigh"
	call showhigh()
case "submitscore"
	call submitscore()
case "help"
  call help()
case else
	call main()
end select

sub script
isplayed=0
	usern=request.querystring("username")
		rswc.Source = "SELECT * FROM gamedb"
		rswc.ActiveConnection = connwc
		rswc.Open()
		scriptheadstr="<a href=""wc_rec-room.asp""><font style=""font-weight:bold; color: #000000; font-family: 黑体;"">猪婷家园游戏得分</font></a>"
			do until rswc.eof
				gameid=rswc("gameid")
				gamename=rswc("gamename")
				highname=rswc("highname")
				gameurl=rswc("gameurl")
				rswcc.Source = "SELECT top 1 score FROM scores WHERE player = '"&usern&"' and game='"&gameid&"'"
				rswcc.ActiveConnection = connwc
				rswcc.Open()
					if not rswcc.eof then
						isplayed=1
						score=rswcc("score")
						scriptstr=scriptstr+"<tr><td>&nbsp;<a href="""&gameurl&"""><font style=""color: #2266ee; font-family: 宋体;"">"&gamename&"</font></a></td><td>&nbsp;&nbsp;<font style=""color: #2266ee; font-family: 宋体;"">"&score&"</font> <br></td></tr>"
					end if
				rswcc.close
				rswc.movenext
			loop
		rswc.close
		
		if isplayed=1 then
			response.write("document.write('<div align=center><table width=100% border=0 cellpadding=0 cellspacing=0><tr><th colspan=2 align=center>"&scriptheadstr&"</th></tr>"&scriptstr&"</table></div>')")
		end if
end sub

sub submitscore()
Dim refchk
refchk=request.serverVariables("Http_REFERER")
if refchk<>"" then
'response.end
response.redirect "http://www.ju4t.com"
end if
		score=Request.Form("score")
		game=Request.Form("game")
		messagebox=messagebox+"score="&score
		
		sqlwc =  "INSERT INTO scores (game,player,score) VALUES ('"&game&"','"&BBS94KK.Myname&"','"&score&"')"
		connwcc.execute sqlwc
		
		rswc.Source = "SELECT * FROM gamedb where gameid='" & game &"'"
		rswc.ActiveConnection = connwc
		rswc.Open()
			highscore=rswc("highscore")
			award1=rswc("award1")
			award2=rswc("award2")
			messagebox=messagebox+"&award1="&award1
			messagebox=messagebox+"&award2="&award2
			per=rswc("percentt")
		rswc.close
		
		if (score-highscore)>0 then 
			istop =1
			if highscore<>0 then
			messagebox=messagebox+"&istop=1"
			messagebox=messagebox+"&newtop=0"
					if award1<>0 then
						BBS94KK.execute("Update [KK_user] Set Coin=Coin+"&award1&" where Name='"&BBS94KK.MyName&"'")
					end if
					
					if award2<>0 then
						BBS94KK.execute("Update [KK_user] Set GameCoin=GameCoin+"&award2&" where Name='"&BBS94KK.MyName&"'")
					end if
				sqlwc="UPDATE gamedb SET highscore="&score&",highname='"&BBS94KK.Myname&"' WHERE gameid='"&game&"'"
				connwcc.execute sqlwc
			else
				messagebox=messagebox+"&istop=1"
				messagebox=messagebox+"&newtop=1"
				sqlwc="UPDATE gamedb SET highscore="&score&",highname='"&BBS94KK.Myname&"' WHERE gameid='"&game&"'"
				connwcc.execute sqlwc
			end if
		else
			messagebox=messagebox+"&istop=0"
			messagebox=messagebox+"&newtop=0"
		end if
		
		connwcc.close
		set connwcc=nothing
		
		addmoney=clng( per * score \ 1000 )
		SQLM = "UPDATE [KK_user] SET Coin=Coin+"&ADDmoney&" where Name='"&BBS94KK.MyName&"'"
		BBS94KK.execute(SQLM)
				messagebox=messagebox+"&ADDmoney="&ADDmoney
		
		response.write(messagebox)
end sub

sub help()
response.write "<table cellpadding=3 cellspacing=1 align=center width=""100%""><br><br><th>猪婷家园使用帮助http://www.ju4t.com</th>"
response.write "<tr><td valign=middle class=tablebody1><CENTER><table border=0 width=100% id=table1 cellspacing=0 cellpadding=0><tr><td><br>"
response.write "<p align=left><b style=font-size:12px>冒险游戏使用帮助http://www.ju4t.com</b></p><ol><li style=font-size:12px>灵动喷射<br>""W"" 向上、""A""向左、""D""向右、""S""向下,""J""开火、""k""重炮。<br><br><li style=font-size:12px>百事弹球<br>游戏中有说明。<br><br><li style=font-size:12px>淘金者<br>游戏中有说明。<br><br><li style=font-size:12px>冒险岛<br>游戏中有说明。<br><br></ol></td></tr>"
response.write "<tr><td><p align=left><b style=font-size:12px>益智游戏使用帮助http://www.ju4t.com</b></p><ol><li style=font-size:12px>连连看<br>点击相同的图案，连在一起。<br><br><li style=font-size:12px>连珠泡泡<br>游戏中有说明。<br><br><li style=font-size:12px>俄罗斯方块。<br>左、右、下方向键分别向各方向移动，向上的键是变换方块的角度。<br><br><li style=font-size:12px>松鼠推箱子<br>游戏中有说明。<br><br></ol></td></tr>"
response.write "<tr><td><p align=left><b style=font-size:12px>赌博游戏使用帮助</b></p><ol><li style=font-size:12px>黑杰克<br>先购买筹码，然后下注玩牌，最后别忘了将筹码兑换成金钱。<br><br><li style=font-size:12px>老虎机<br>先购买筹码，然后下注，可选下一枚、二枚、三枚，按拉杆，就看你的运气了，最后别忘了将筹码兑换成金钱。<br><br></ol></td></tr></table></td></tr></table>"
end sub

sub main()
response.write "<table cellpadding=3 cellspacing=1 align=center width=""100%"">"
response.write "<tr><td valign=middle class=tablebody1 height=100><CENTER><div id=divinner width=100% align=center>"
response.write "<table border=0 width=100% id=table1 cellspacing=0 cellpadding=0><tr><td valign=middle class=tablebody1 colspan=3 height=100><p align=center><b style=font-size:12px;text-decoration:none>猪婷家园~<a href=wc_rec-room.asp?act=help>使用帮助</a></b></p></td></tr><tr><td width=33% align=center><a href=?act=games&gametype=1&zhname=%C3%B0%CF%D5%C0%E0%D3%CE%CF%B7><img border=0 src=wc_game/pics/action.gif width=200 height=200></a></td><td width=33% align=center><a href=?act=games&gametype=2&zhname=%D2%E6%D6%C7%C0%E0%D3%CE%CF%B7><img border=0 src=wc_game/pics/puzzles.gif width=200 height=200></a></td><td width=33% align=center><a href=?act=games&gametype=3&zhname=%B6%C4%B2%A9%C0%E0%D3%CE%CF%B7><img border=0 src=wc_game/pics/luck_chance.gif width=200 height=200></a></td></tr></table></div></td></tr></table>"
end sub

sub games()
Dim zhname,gametype,iiii
zhname=request.querystring("zhname")
gametype=request.querystring("gametype")
BBS94KK.Stats=zhname
RSWc.CursorLocation=3 
RSWc.CursorType=3 
RSWc.PageSize="12"
rswc.Source = "SELECT * FROM gamedb where type=" & gametype & " ORDER BY id"
rswc.ActiveConnection = connwc
rswc.Open()
dim eoff
eoff=0
if rswc.eof then 
eoff = 1
end if
if eoff=0 then 
if Request.QueryString("pg")="" then
rswc.AbsolutePage=1
else
rswc.AbsolutePage=cint(Request.QueryString("pg"))
end if
end if
%>
<table cellpadding=3 cellspacing=1 align=center width=100%>
	<tr>
		<th valign=middle colspan=2 align=center height=25>
		<div id="divTitle">
		<b style=font-size:12px><%=zhname%></b>
		</div>
		</th>
	</tr>
	<tr>
		<td valign=middle class=tablebody1 height=100><CENTER>
<table id="table3" cellspacing="1" bordercolorlight="#000000" bordercolordark="#000000">
<tr>
<%
dim eof
eof=0
if rswc.eof then 
eof = 1
response.write ("<table width=200><tr><td align=center style=font-size:12px>本分类暂时没有游戏</td></tr></table>")
end if
if eof=0 then
do until rswc.eof or iiii=12
if iiii=4 or iiii=8 then response.write "</tr><tr>"
%>
<td align='center' width='180' height='140' valign=center>
	<table cellpadding=0 cellspacing=0 style='border: 1px #444444 dotted;' width=150 height=125>
		<tr>
			<th valign=middle align=center height=25 style='BORDER-BOTTOM: 1px #444444 solid;font-size:12px'><%=rswc("gamename")%>
			</th>
		</tr>
		<tr>
			<td class=tablebody1 height=100><a onclick="window.open('<%=rswc("gameurl")%>','myWin','toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=yes, scrollbars=yes, width=600, height=480');return false;"  <%if gametype<> 3 then%>onMouseOver="getScore('<%=rswc("gamename")%>','<%=rswc("gameid")%>');"<%end if%> title="游戏得分×<%=rswc("percentt")%>‰ = 奖金" style="cursor: hand;"><img border='0' src='<%=rswc("gameimg")%>' width='150' height='100'></a>
			</td>
		</tr>
	</table>
</td>
<%
iiii = iiii+1
rswc.movenext
loop
end if%>
</tr>
</table> 
</td>
</tr>
	<tr>
		<td bgcolor=#ffffff>
<%
if eof=0 then
Dim allpages,pageon,curpage,nowpage,iii
if Request.QueryString("pg")<>"" then pageon=rswc.AbsolutePage
if Request.QueryString("pg")="" then pageon=1

curpage = Request.QueryString("pg")
if curpage<>"" then nowpage = curpage
if curpage="" then nowpage = 1
allpages = rswc.PageCount
Response.Write "<table><tr>"
Response.Write "<td width='100%' align='right' style=''><div>"
Response.write  ("<font color=#ffff00 style='color: #333300; font-size: 13px; font-family: Arial,Helvetica,sans-serif'>" & nowpage & "</font><font style='color: #333333; font-size: 13px; font-family: Arial,Helvetica,sans-serif'>" & "/" & allpages &"</font><font style='color: #666611; font-size: 9px; font-family: Arial,Helvetica,sans-serif'>&nbsp;Page:&nbsp;</font>")
for iii=1 to rswc.PageCount
Response.Write "<a href=wc_rec-room.asp?act=games&gametype="&gametype&"&zhname="&zhname&"&pg=" & iii & "><font color=#555555 style='font-family: 黑体; font-color: #333333 ; font-size: 13px'>[" & iii & "]</a></font>"
next
Response.Write "</div></td></tr></table>"
end if
rswc.Close()
%>
		</td>
	</tr>
</table>
		</td>
	</tr>
</table>
<%
if int(gametype)<>3 then
%>
<table cellpadding=0 cellspacing=0 align=center width=100%>
	<tr>
	<th valign=middle colspan=0 align=center height=25>
	<div id="divTitle2" align=center style=font-size:12px>高分榜
	</div>
	</td>
	</tr>
	<tr>
	<td valign=middle align=center bgcolor=#ffffff>
	<div id="divBottem" align=center>
	</div>
	</td>
	</tr>
</table>
<%end if%>
<script>
function getScore(name,address){
	document.getElementById("divBottem").innerHTML="<iframe name=I1 src=./wc_rec-room.asp?act=showhigh&game="+address+" width=100% height='210' align='middle'>浏览器不支持嵌入式框架，或被配置为不显示嵌入式框架。</iframe>"
	document.getElementById("divTitle2").innerHTML="<b style=font-size:12px>"+name+"--高分榜</b>"
}
</script>
<%
end sub
%>
<%
sub showhigh
	DIM game2,number
	conn = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" + Server.MapPath("wc_game/wc_high-score.mdb")
	set rs=Server.CreateObject("ADODB.recordset")
	game2=Request.QueryString("game")
	rs.source = "SELECT * FROM scores where game='" + game2 + "' ORDER BY score DESC"
	rs.ActiveConnection = conn
	rs.Open()
	%>
	<html>
	<head>
	</head>
	<body topmargin="0" leftmargin="0" rightmargin="0">
	<table cellpadding=0 cellspacing=0 border="0" width="100%" id="table1">
		<tr valign="top">
			<td width="50%" valign="top">
	<div align="center">
	<table cellpadding=0 cellspacing=0 width="100%" id="table2">
		<tr>
			<th style='background-color: #4477ff;font-size: 12px;font-weight:bold;' valign=middle colspan=0 align=center width=15% height=25></th>
			<th style='background-color: #4477ff;font-size: 12px;font-weight:bold;' valign=middle colspan=0 align=center width=5% height=25>	 </th>
			<th style='background-color: #4477ff;font-size: 12px;font-weight:bold;' valign=middle colspan=0 align=left width=42% height=25>
			<font color="#FFFFFF">名字</font></th>
			<th style='background-color: #4477ff;font-size: 12px;font-weight:bold;' valign=middle colspan=0 align=center width=5% height=25>	 </th>
			<th style='background-color: #4477ff;font-size: 12px;font-weight:bold;' valign=middle colspan=0 align=center width=33% height=25>
			<font color="#FFFFFF">分数</font></th>
		</tr>
	<%
	Number=1
	Do until number = 11 or rs.eof
	response.write("<tr style='font-family: 黑体; font-size:11pt'>")
	response.write("<td width=15% align=right>")
	response.write("<img border=0 src=wc_game/pics/num/" & number &".gif width=14 height=14>")
	response.write("</td>")
	response.write("<td width=5% align=right>")
	response.write("&nbsp;&nbsp;&nbsp;")
	response.write("</td>")
	response.write("<td width=42% align=left>")
	response.write(rs.Fields.Item("player").value)
	response.write("</td>")
	response.write("<td width=5% align=center></td>")
	response.write("<td width=33% align=center>")
	response.write(rs.Fields.Item("score").value)
	response.write("</td>")
	response.write("</tr>")
	number = number + 1
	rs.MoveNext
	loop
	%>
	</table>
	</div>
	</td>
			<td width="50%" valign="top">
	<div align="center">
	<table cellpadding=0 cellspacing=0 width="100%" id="table3">
		<tr>
			<th style='background-color: #4477ff;font-size: 12px;font-weight:bold;' valign=middle colspan=0 align=center width=15% height=25></th>
			<th style='background-color: #4477ff;font-size: 12px;font-weight:bold;' valign=middle colspan=0 align=center width=5% height=25>	 </th>
			<th style='background-color: #4477ff;font-size: 12px;font-weight:bold;' valign=middle colspan=0 align=left width=42% height=25>
			<font color="#FFFFFF">名字</font></th>
			<th style='background-color: #4477ff;font-size: 12px;font-weight:bold;' valign=middle colspan=0 align=center width=5% height=25>	 </th>
			<th style='background-color: #4477ff;font-size: 12px;font-weight:bold;' valign=middle colspan=0 align=center width=33% height=25>
			<font color="#FFFFFF">分数</font></th>
		</tr>
	<%
	Number=11
	Do until number = 21 or rs.eof
	response.write("<tr style='font-family: 黑体; font-size:11pt'>")
	response.write("<td width=15% align=right>")
	response.write("<img border=0 src=wc_game/pics/num/" & number &".gif width=14 height=14>")
	response.write("</td>")
	response.write("<td width=5% align=right>")
	response.write("&nbsp;&nbsp;&nbsp;")
	response.write("</td>")
	response.write("<td width=42% align=left>")
	response.write(rs.Fields.Item("player").value)
	response.write("</td>")
	response.write("<td width=5% align=center></td>")
	response.write("<td width=33% align=center>")
	response.write(rs.Fields.Item("score").value)
	response.write("</td>")
	response.write("</tr>")
	number = number + 1
	rs.MoveNext
	loop
	%>	
	</table>
	</div>
	</td>
		</tr>
	</table>
	</body>
	</html>
<%
	rs.Close()
	Set conn = Nothing
end sub
%>