<?php
include_once("inc/conn.php");
include_once("inc/function.php");

$query=$db->query("Select id,kgtime from {$web_dbtop}game28 where kj=0 Order by id asc");
if($rs=$db->fetch_array($query)){
	$kgqh=$rs["id"];
	$kgtime=DateDiff($rs["kgtime"],date("Y-m-d H:i:s"),"s")+25;
}

$query=$db->query("Select gfid,kgjg,kgwh from {$web_dbtop}game28 where kj=1 Order by id desc");
if($rs=$db->fetch_array($query)){
	$gfid=$rs["gfid"];
	$kgwh=$rs["kgwh"];
	$kgjg=explode("|",$rs["kgjg"]);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>幸运28-游戏中心-<?=$web_name;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="<?=$web_keywords;?>" />
<meta name="description" content="<?=$web_description;?>" />
<META http-equiv=X-UA-Compatible content=IE=EmulateIE7>
<link href="style/default.css" rel="stylesheet" type="text/css" />
</head>
<?php include_once("top.php");?>
<script language="javascript">
qiehuan(2);
document.getElementById("qh_con2").getElementsByTagName('li')[0].className="current";
</script>
<DIV class="wrapper">
	<DIV class="page_content">
		<DIV class="webgame-info-title">
		  <UL>
			<LI class="current"><A href="luck.php">幸运28首页</A></LI>
			<LI><A href="luckhelp.php">幸运28规则</A></LI>
			<LI><A href="luckmylist.php">我的投注记录</A></LI>
			<LI><A href="luckmodel.php">投注模式编辑</A></LI>
			<LI><A href="luckautoset.php">自动投注</A></LI>
			<LI><A href="luckdirection.php">幸运28走势图</A></LI>
		  </UL>
		</DIV>
		<DIV class="webgame-info">
			<DIV class="webgame-info-tabs">
			  <table width="100%" border="0" cellspacing="2" cellpadding="2">
                <tr>
                  <td colspan="2" align="center"><span id="fSound"></span><font id="fLuck" style="font-size:14px;color:#FF0000;font-weight:bold;"></font></td>
                </tr>
              </table>

					<table width="940" border="0" align="center" cellpadding="2" cellspacing="2">
                      <tr>
                        <td width="100">&nbsp;</td>
                        <td align="center"><? if($gfid){?>
                            <a href="http://bjfcdt.gov.cn/Happy8/v1/affiche.aspx" target="_blank" class="red">第三方
                            <?=$gfid?>
                            期</a>&nbsp;&nbsp;加入随机号：<? echo "<span class=\"rbf\">".$kgwh."</span>"; }else{?>本地数据
                            <? }?>
                      &nbsp;&nbsp;一区和值：
                            <?=substr($kgjg[0],0,strlen($kgjg[0])-1)?>
                            <font style='color:#FF0000;font-weight:bold;font-size:14px'>
                            <?=substr($kgjg[0],-1)?>
                            </font> 　二区和值：
                            <?=substr($kgjg[1],0,strlen($kgjg[1])-1)?>
                            <font style='color:#FF0000;font-weight:bold;font-size:14px'>
                            <?=substr($kgjg[1],-1)?>
                            </font> 　三区和值：
                            <?=substr($kgjg[2],0,strlen($kgjg[2])-1)?>
                            <font style='color:#FF0000;font-weight:bold;font-size:14px'>
                            <?=substr($kgjg[2],-1)?>
                          </font></td>
                        <td width="120"><a href="bbs/forum.php?forumsid=3" target="_blank"><img src="images/bbs_jl.gif" border="0" /></a></td>
                      </tr>
                    </table>
					<table width="940" border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td bgcolor="#248301"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="1">
                                <tr>
                                  <td width="68" height="28" align="center" background="images/310-bj.jpg" bgcolor="#FFFFFF" class="wf">期号</td>
                                  <td width="123" height="28" align="center" background="images/310-bj.jpg" bgcolor="#FFFFFF" class="wf">开奖时间</td>
                                  <td width="134" align="center" background="images/310-bj.jpg" bgcolor="#FFFFFF" class="wf">开奖结果</td>
                                  <td width="72" align="center" background="images/310-bj.jpg" bgcolor="#FFFFFF" class="wf">已投注数</td>
                                  <td width="127" align="center" background="images/310-bj.jpg" bgcolor="#FFFFFF" class="wf"><?=$web_moneyname?>总数</td>
                                  <td width="85" align="center" background="images/310-bj.jpg" bgcolor="#FFFFFF" class="wf">中奖人数</td>
                                  <td width="118" align="center" background="images/310-bj.jpg" bgcolor="#FFFFFF" class="wf">投注额/中奖额</td>
                                  <td width="70" align="center" background="images/310-bj.jpg" bgcolor="#FFFFFF" class="wf">参与</td>
                                </tr>
                <?php
				$i=0;
				$intpage = 30;
				if (isset($_GET['page'])) {
					$rsnum = (intval($_GET['page']) -1)*$intpage;
				}
				else {
					$rsnum = 0;
				}
				$sql="Select * from {$web_dbtop}game28 Order by id desc";
				$query=$db->query($sql);
				if($db->fetch_array($query)) 
				$intnum=$db->num_rows($query);
				$query=$db->query($sql." limit $rsnum,$intpage");
				while($rs=$db->fetch_array($query)){
					$kgh=explode("|",$rs["kgjg"]);
					$hdpoints=0;
					$sumnumtzpoints=0;
					if($rs["kj"]!=1){
						$query_f=$db->query("Select sum(tzpoints) as points,sum(hdpoints) as hdpoints from {$web_dbtop}game28_kg_users_tz where NO=".$rs["id"]." and uid=".intval($_COOKIE["usersid"])." Order by id desc");
					}else{
						$query_f=$db->query("Select points,hdpoints from {$web_dbtop}game28_users_tz where NO=".$rs["id"]." and uid=".intval($_COOKIE["usersid"])." Order by id desc");
					}
					if($rs_f=$db->fetch_array($query_f)){
						$sumnumtzpoints=$rs_f["points"];
						$hdpoints=$rs_f["hdpoints"];
					}
				$bgcolor=($i%2==0?"#FFFFFF":"#F8F8F8");
				?>
                                <tr>
                                  <td height="32" align="center" bgcolor="#E6F7E0" class="font12game"><?=$rs["id"];?></td>
                                  <td align="center" bgcolor="<?=$bgcolor;?>" class="font12game"><?=date("m-d H:i",strtotime($rs["kgtime"]));?></td>
                                  <td align="center" bgcolor="<?=$bgcolor;?>" class="font12game"><?
					if($rs["kgjg"]){
					?>
                                      <?=substr($kgh[0],-1);?> + <?=substr($kgh[1],-1);?> + <?=substr($kgh[2],-1);?>＝<img align="absmiddle" src="images/luck/number_<?=$kgh[3];?>.gif" />
                                      <?
					 }else{
					 	echo"-";
					 }
					 ?>
                                  </td>
                                  <td align="center" bgcolor="<?=$bgcolor;?>" class="font12game"><?=$rs["tznum"];?></td>
                                  <td align="center" bgcolor="<?=$bgcolor;?>" class="font12game"><?=number_format($rs["tzpoints"]);?><img src="<?=$web_moneypic?>" align="absmiddle" /></td>
                                  <td align="center" bgcolor="<?=$bgcolor;?>" class="font12game"><? if($rs["kj"]==1){ echo"<a href=\"luckwinlist.php?luckno=".$rs["id"]."\" class=\"b\">".$rs["zjrnum"]."</a>";}else{echo"-";}?></td>
                                  <td align="center" bgcolor="<?=$bgcolor;?>" class="font12game"><? 
					if($rs["kj"]==1){
						if($sumnumtzpoints) {
							echo "<a href=\"luckmydetail.php?luckno=".$rs["id"]."\"><font color=\"".($sumnumtzpoints>$hdpoints?"#006600":"#FF0000")."\">".number_format($sumnumtzpoints)." / ".number_format($hdpoints)."</font></a>";
						}else{
							echo "0 / 0";
						}
					}else{
						if($sumnumtzpoints){
							echo"<a href=\"luckmydetail.php?luckno=".$rs["id"]."\"><font color=\"#FF0000\">".number_format($sumnumtzpoints)." / 0</font>";
						}else{
							echo "0 / 0";
						}
					}
					?></td>
                                  <td align="center" bgcolor="<?=$bgcolor;?>"><? if($rs["kj"]==0){ echo"<a href=\"luckinsert.php?luckno=".$rs["id"]."\" class=\"b\">投注</a>";}else{echo"<a href=\"luckmyinsert.php?luckno=".$rs["id"]."\">已开奖</a>";}?></td>
                                </tr>
                <?
				$i++;
				}
				?>
                            </table></td>
                          </tr>
              </table>
						<table width="806" border="0" align="center" cellpadding="2" cellspacing="4">
                          <tr>
                            <td align="center"><?php
		  include_once("inc/page_class.php");
		  $page=new page(array('total'=>$intnum,'perpage'=>$intpage));
		  echo $page->show(5,"","");?></td>
                          </tr>
              </table>
						<script type="text/javascript">
						<!--
						var luckno = "<?=$kgqh;?>";
						if(readCookie('cSound')=='1'){
							imgSound = '<img src="images/sound1.gif" onclick="setSound(this,0)" align="absmiddle" style="cursor:pointer" title="关闭开奖声音">';
						}
						else{
							imgSound = '<img src="images/sound0.gif" onclick="setSound(this,1)" align="absmiddle" style="cursor:pointer" title="打开开奖声音">';
						}
						document.getElementById("fSound").innerHTML = imgSound;
						function ShowSecond(cDate){
							if(luckno != ""){
								if(cDate > 1){
									document.getElementById("fLuck").innerHTML = "离第"+luckno+"期开奖时间还有"+(--cDate)+"秒";
									setTimeout("ShowSecond("+cDate+")",1000);
								}
								else{
									wavSound = '';
									if(readCookie('cSound')=='1'){
										wavSound = '<embed src="images/sound/security.wav" autostart=true hidden=true loop=false>';
									}
									document.getElementById("fLuck").innerHTML = "第"+luckno+"期正在开奖，请刷新页面查看开奖号码。"+wavSound;
								}
							}
						}
						ShowSecond(parseInt("<?=$kgtime;?>"));
						function setSound(obj,v){
							if(v=='1'){
								obj.src='images/sound1.gif';
								obj.title='关闭开奖声音';
								obj.onclick=function (){setSound(this,0);}
							}
							else{
								obj.src='images/sound0.gif';
								obj.title='打开开奖声音';
								obj.onclick=function (){setSound(this,1);}
							}
							setCookie('cSound',v);
						}
						function setCookie(cookieName,cookieValue){
							var date = new Date();
							date.setTime(date.getTime() + 24*60*60*1000000);
							document.cookie = cookieName + "=" + cookieValue + ";expires=" + date.toGMTString() + ";path=/";
						}
						function readCookie(cookieName){
							var aCookie = document.cookie.split("; ");
							for (var i=0; i < aCookie.length; i++){
							var aCrumb = aCookie[i].split("=");
							if(cookieName == aCrumb[0])
								return unescape(aCrumb[1]);
							}
							return null;
						}
						-->
						</script>
		  </DIV>
		  <DIV class=cl></DIV>
		</DIV>
		<DIV class="area960-b h5px"></DIV>
	<!--Flink End-->
	<div class="blank10"></div>
	<!--Footer Start-->
<?php include_once("footer.php");?>
</DIV>