<!--#include file="../inc.asp"-->
<!--#include file="../ydzq1.asp"-->
<!--#include file="conn.asp"-->
<%
'=============================
call head()


On Error Resume Next
dim applename,hello,paynum,appletimes,paylu
  set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select applename,hello,paynum,appletimes,paylu,pcent from appleadmin where id=1",ydzqconn,1,1
if not rs.eof then
applename=rs("applename")
hello=rs("hello")
paynum=rs("paynum")
appletimes=rs("appletimes")
paylu=rs("paylu")
pcent=rs("pcent")
end if
rs.close
set rs=nothing%>
<%Call cardgame(""&applename&"","yanse5")

dim chat
chat=request("chat")
if chat="2"  then
Session("chat")=""
end if

dim appleID
  appleID=0
  set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select ID,pg,mg,xg,mag,sx,jz,sq,yb,appletime from apple order by id desc",ydzqconn,1,1
if not rs.eof then
appleID=rs(0)
pg=rs(1)
mg=rs(2)
xg=rs(3)
mag=rs(4)
sx=rs(5)
jz=rs(6)
sq=rs(7)
yb=rs(8)
appletime=rs(9)
end if
rs.close
set rs=nothing


'检查有几条新留言
dim newguest
newguest = 0
IF myid > 0 THEN
  newguest = ForNewGuest(myid)
END IF
if myid<>0 then
if newguest > 0 then
Response.write "<a href='../msgview.asp?sid="&sid&"&amp;saytk="&saytk&"'>您有"&newguest&"条新消息</a><br/>"& chr(13)
end if
response.write"欢迎您：<a href='../show.asp?sid="&sid&"&amp;saytk="&saytk&"'>"&myni&"</a>您有"&myjb&getcent&"!<br/>"&chr(13)
else
Response.write "欢迎您:<a href='/bbs/login.asp?saytk="&saytk&"&amp;sid="&sid&"'>登陆/注册</a><br/>"& chr(13)
end if
response.write ubb(hello)&"<br/>"
'-----------------------
if myid<>0 then
mz="[url=/bbs/uinfo.asp?id="&myid&"&amp;sid=[sid]&saytk=[saytk]]"&myni&"[/url]"
else
mz="游客"
end if
conn.execute("insert into sqdt(shijian,dz)values('"&now&"','"&mz&"去了:(url=/bbs/apple/index.asp?sid=[sid]&saytk=[saytk])疯狂苹果机(/url)')")
'取上期记录
 dim appleid2,V_appletext
 appleid2=abs(appleid-1)

 Set rs = Server.CreateObject("ADODB.Recordset")
 rs.open"Select appletext from apple Where  id = "&appleid2&" ORDER BY ID",ydzqconn,1,1

  if not rs.eof then
 V_appletext=rs(0)
 end if
 rs.close
 set rs=nothing
dim m_appletext:m_appletext=left(V_appletext,2)
set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select pg,mg,xg,mag,sx,jz,sq,yb,payusid from myapple where appleid="&appleid2&" order by "&TApple(m_appletext)&" desc",ydzqconn,1,1
if not rs.eof then
if TApple(m_appletext)="pg" and rs("pg")>0 then
response.write uname(rs("payusid"))&"压"&m_appletext&rs("pg")&"注,获得"&LuApple(V_appletext)*pcent*rs("pg")&getcent&"<br/>"
elseif TApple(m_appletext)="mg"  and rs("mg")>0 then
response.write uname(rs("payusid"))&"压"&m_appletext&rs("mg")&"注,获得"&LuApple(V_appletext)*pcent*rs("mg")&getcent&"<br/>"
elseif TApple(m_appletext)="xg"  and rs("xg")>0 then
response.write uname(rs("payusid"))&"压"&m_appletext&rs("xg")&"注,获得"&LuApple(V_appletext)*pcent*rs("xg")&getcent&"<br/>"
elseif TApple(m_appletext)="mag"  and rs("mag")>0 then
response.write uname(rs("payusid"))&"压"&m_appletext&rs("mag")&"注,获得"&LuApple(V_appletext)*pcent*rs("mag")&getcent&"<br/>"
elseif TApple(m_appletext)="sx" and rs("sx")>0 then
response.write uname(rs("payusid"))&"压"&m_appletext&rs("sx")&"注,获得"&LuApple(V_appletext)*pcent*rs("sx")&getcent&"<br/>"
elseif TApple(m_appletext)="jz"  and rs("jz")>0 then
response.write uname(rs("payusid"))&"压"&m_appletext&rs("jz")&"注,获得"&LuApple(V_appletext)*pcent*rs("jz")&getcent&"<br/>"
elseif TApple(m_appletext)="sq" and rs("sq")>0 then
response.write uname(rs("payusid"))&"压"&m_appletext&rs("sq")&"注,获得"&LuApple(V_appletext)*pcent*rs("sq")&getcent&"<br/>"
elseif TApple(m_appletext)="yb"  and rs("yb")>0 then
response.write uname(rs("payusid"))&"压"&m_appletext&rs("yb")&"注,获得"&LuApple(V_appletext)*pcent*rs("yb")&getcent&"<br/>"
end if
end if
rs.close
set rs=nothing

response.write "第"&appleID&"期开始下注啦<br/>"


if appletime<=Now() then
  Application.Lock
dim newTimee,appletext
appletext=winApple()
newTimee = DateAdd("n", appletimes, Now())
ydzqconn.execute("update apple set appletext='"&appletext&"',comeover=1 where ID="&appleID)

dim lutype
 lutype=LuApple(appletext)

  call jjapple(appletext,lutype,appleID,paylu) 
  ydzqconn.execute("update applelist set comeover=1 where appleID="&appleID)
ydzqconn.execute("insert into apple(appletime)  values('"&newTimee&"')")
 Application.Unlock
end if
'-----------------------
if DateDiff("s", Now(), appletime)<=10 then
response.write"苹果机正在转动...<a href=""index.asp?sid="&sid&"&amp;num="&int(timer())&"&amp;chat="&chat&"&amp;saytk="&saytk&""">刷新</a><br/>"
else
response.write date_apple(appletime)&"开盅,各位客官赶快下注啦!<a href=""index.asp?sid="&sid&"&amp;num="&int(timer())&"&amp;chat="&chat&"&amp;saytk="&saytk&""">刷新</a><br/>"
end if
if DateDiff("s", Now(), appletime)>10 then
response.write"<a href=""apple.asp?ID="&appleID&"&amp;paytype=1&amp;sid="&sid&"&amp;num="&int(timer())&"&amp;saytk="&saytk&""">下注</a>"
end if
response.write"苹果×5 ("&pg&"注)<br/>"
if DateDiff("s", Now(), appletime)>10 then
response.write"<a href=""apple.asp?ID="&appleID&"&amp;paytype=2&amp;sid="&sid&"&amp;num="&int(timer())&"&amp;saytk="&saytk&""">下注</a>"
end if
response.write"木瓜×10|小木×2 ("&mg&"注)<br/>"
if DateDiff("s", Now(), appletime)>10 then
response.write"<a href=""apple.asp?ID="&appleID&"&amp;paytype=3&amp;sid="&sid&"&amp;num="&int(timer())&"&amp;saytk="&saytk&""">下注</a>"
end if
response.write"西瓜×15|小西×2 ("&xg&"注)<br/>"
if DateDiff("s", Now(), appletime)>10 then
response.write"<a href=""apple.asp?ID="&appleID&"&amp;paytype=4&amp;sid="&sid&"&amp;num="&int(timer())&"&amp;saytk="&saytk&""">下注</a>"
end if
response.write"芒果×20|小芒×2 ("&mag&"注)<br/>"
if DateDiff("s", Now(), appletime)>10 then
response.write"<a href=""apple.asp?ID="&appleID&"&amp;paytype=5&amp;sid="&sid&"&amp;num="&int(timer())&"&amp;saytk="&saytk&""">下注</a>"
end if
response.write"双星×20|小星×2 ("&sx&"注)<br/>"
if DateDiff("s", Now(), appletime)>10 then
response.write"<a href=""apple.asp?ID="&appleID&"&amp;paytype=6&amp;sid="&sid&"&amp;num="&int(timer())&"&amp;saytk="&saytk&""">下注</a>"
end if
response.write"金钟×30|小钟×2 ("&jz&"注)<br/>"
if DateDiff("s", Now(), appletime)>10 then
response.write"<a href=""apple.asp?ID="&appleID&"&amp;paytype=7&amp;sid="&sid&"&amp;num="&int(timer())&"&amp;saytk="&saytk&""">下注</a>"
end if
response.write"双七×40|小七×2 ("&sq&"注)<br/>"
if DateDiff("s", Now(), appletime)>10 then
response.write"<a href=""apple.asp?ID="&appleID&"&amp;paytype=8&amp;sid="&sid&"&amp;num="&int(timer())&"&amp;saytk="&saytk&""">下注</a>"
end if
response.write"元宝×100 ("&yb&"注)<br/>"
dim Isvote
Isvote=0
set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select pg,mg,xg,mag,sx,jz,sq,yb from myapple where appleid="&appleID&" and payusid="&myid,ydzqconn,1,1
  if rs.recordcount	> 0 then
  Isvote=1
  response.write"本局您已下注"
  if rs("pg")>0 then
  response.write",苹果"&rs("pg")&"注"
  end if
  if rs("mg")>0 then
  response.write",木瓜"&rs("mg")&"注"
  end if
  if rs("xg")>0 then
  response.write",西瓜"&rs("xg")&"注"
  end if
  if rs("mag")>0 then
  response.write",芒果"&rs("mag")&"注"
  end if
  if rs("sx")>0 then
  response.write",双星"&rs("sx")&"注"
  end if
  if rs("jz")>0 then
  response.write",金钟"&rs("jz")&"注"
  end if
  if rs("sq")>0 then
  response.write",双七"&rs("sq")&"注"
  end if
  if rs("yb")>0 then
  response.write",元宝"&rs("yb")&"注"
  end if
  else
  response.write"本局您还没有下注哦！"
  end if
rs.close
set  rs=nothing
if Isvote=0 then
set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select id from myapple where appleid="&appleID-1&" and payusid="&myid,ydzqconn,1,1
if not rs.eof then
response.write"<br/><a href='appleput.asp?ID="&appleID&"&amp;sid="&sid&"&amp;saytk="&saytk&"'>重压上局投注</a>"
end if
rs.close
set rs=nothing
end if
response.write"<br/>----------<br/>"
if chat<>"1" and Session("chat")<>"1" then
response.write"<a href='index.asp?chat=1&amp;sid="&sid&"&amp;saytk="&saytk&"'>打开聊天窗口</a><br/>"
end if

 dim rCount:rCount=0
set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select payusid from applelist where appleid="&appleID2&" and winer=1  group by payusid",ydzqconn,1,1
  if not rs.eof then
  rCount=rs.recordcount
  end if 
  rs.close
  set rs=nothing
  dim doapplecount
  doapplecount="0"
  set rs=ydzqconn.execute("Select sum(paycent) as applecount from applelist where winer=1 and appleid="&appleid2)
  if not rs.eof then
  doapplecount=rs("applecount")
  end if
  rs.close
  set rs=nothing
dim lutype2,doapplecounts
 lutype2=LuApple(V_appletext)
 if IsNumeric(doapplecount)=False then doapplecount=0
 doapplecounts=abs(int(doapplecount*lutype2))
response.write"上"&appleid2&"期开"&V_appletext&",<a href=""applewinlist.asp?ID="&appleid2&"&amp;sid="&sid&"&amp;saytk="&saytk&""">赢家"&rCount&"人</a>获"&doapplecounts&getcent&"<br/>"


if chat="1"  or Session("chat")="1" then
Session("chat")="1"
if saytk<>1 then
Response.write "<form name=""form"" method=""post"" action=""winbbs.asp?sid="&sid&"&amp;saytk="&saytk&"&amp;tp=ok"">"
end if
response.write"<input type=""text"" name=""winText"" maxlength=""50""/>"
if saytk<>1 then
response.write "<input type=""submit"" name=""Submit"" value=""发言""></form><br/>"
else
response.write"<anchor> 发言"
response.write"<go method=""post"" href=""winbbs.asp?sid="&sid&"&amp;saytk="&saytk&""">"
response.write"<postfield name=""winText"" value=""$(winText)""/>"
response.write"<postfield name=""TP"" value=""ok""/>"
response.write"</go></anchor>|"
end if
response.write"<a href=""index.asp?chat=2&amp;sid="&sid&""">关闭</a><br/>"
  set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select top 3 winText,usid,writeTime from winbbs order by id desc",ydzqconn,1,1
  if not rs.eof then
  while not rs.eof
  response.write"<a href=""../uinfo.asp?ID="&rs("usid")&"&amp;sid="&sid&"&amp;saytk="&saytk&""">"&uname(rs("usid"))&"</a>:"&ubb(rs("winText"))&"("&fordateapple(rs("writeTime"))&")<br/>"
  rs.movenext
  wend
  else
    Response.write "暂无聊天记录...<br/>"
  end if
  rs.close
  set rs=nothing
response.write"<a href=""winbbs.asp?sid="&sid&"&amp;saytk="&saytk&""">更多聊天记录&gt;&gt;</a><br/>"
end if
Response.write "--------------"
response.write"<br/><a href=""applelist.asp?sid="&sid&"&amp;saytk="&saytk&""">历史查询</a>|"
response.write"<a href=""applemylist.asp?sid="&sid&"&amp;saytk="&saytk&""">投注记录</a>"
response.write"<br/><a href=""index.asp?sid="&sid&"&amp;saytk="&saytk&""">苹果图</a>|"
response.write"<a href=""applehelp.asp?sid="&sid&"&amp;saytk="&saytk&""">游戏规则</a>"
ydzqconn.close
set ydzqconn=nothing
conn.close
set conn=nothing
if keys=1 then
response.write"<br/><a href=""appleset.asp?sid="&sid&"&amp;saytk="&saytk&""">苹果机管理</a>"
end If
Response.write "<br/><a href=""/bbs/game/?sid="&sid&"&amp;saytk="&saytk&""">返回游戏中心</a>"
Response.write "<br/><a href=""../show.asp?sid="&sid&"&amp;saytk="&saytk&""">地盘</a>&gt;<a href=""/bbs/index.asp?sid="&sid&"&amp;saytk="&saytk&""">社区首页</a><br/>(c)"&Request.ServerVariables("SERVER_NAME")&"["&String(2-Len(hour(now)),"0") & hour(now) &":"&String(2-len(minute(now)),"0") & minute(now)&"]"
call headsay()
%>