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

if($_GET["act"]=="insert"){
	$kcjy=array(100,50,10);
	$query=$db->query("Select * from {$web_dbtop}gamebox where id=1 Order by id asc");
	if($rs=$db->fetch_array($query)){
		$Rand["box_".intval($_POST["boxType"])."_1_j"]=1;
		$Rand["box_".intval($_POST["boxType"])."_2_j"]=3;
		$Rand["box_".intval($_POST["boxType"])."_3_j"]=6;
		$Rand["box_".intval($_POST["boxType"])."_4_j"]=10;
		$Rand["box_".intval($_POST["boxType"])."_5_j"]=30;
		$Rand["box_".intval($_POST["boxType"])."_6_j"]=60;
		$Rand["box_".intval($_POST["boxType"])."_7_j"]=100;
		$Rand["box_".intval($_POST["boxType"])."_8_j"]=99790;
	}
	if(showcontent("users","experience",intval($_COOKIE["usersid"]))<($kcjy[intval($_POST["boxType"]-1)]*$_POST["openTimes"])){
		echo "<script>alert('对不起，您的经验值不足".$kcjy[intval($_POST["boxType"])-1]*$_POST["openTimes"]."!');location.href='box.php';</script>";
		exit;
	}
	$query=$db->query("Select * from {$web_dbtop}gamebox where id=1 Order by id asc");
	if($rs=$db->fetch_array($query)){
		pro_rand($Rand,$event,intval($_POST["openTimes"]));
		foreach ($event as $hjtile){
			$hjdd=$hjdd+$rs[$hjtile];
			if($hjtile!="box_1_8_j" && $hjtile!="box_2_8_j" && $hjtile!="box_3_8_j"){
				$db->query("INSERT INTO {$web_dbtop}gamebox_log (time,boxtype,kjy,hjpp,uid) VALUES ('".date("Y-m-d H:i:s")."',".intval($_POST["boxType"]).",".$kcjy[intval($_POST["boxType"]-1)].",".$rs[$hjtile].",".intval($_COOKIE["usersid"]).")");
	   		}
	   }
   	}
   	$db->query("update {$web_dbtop}users set points=points+".$hjdd.",experience=experience-".intval($kcjy[intval($_POST["boxType"]-1)]*$_POST["openTimes"])." where id=".intval($_COOKIE["usersid"]));
	$db->query("update {$web_dbtop}game_log set gamebox_hd=gamebox_hd+".intval($hjdd)." where uid=".intval($_COOKIE["usersid"]));
	$db->query("update {$web_dbtop}webtj set boxpoints=boxpoints+$hjdd where time='".date("Y-m-d")."'");
	echo "<script>alert('恭喜您，您的中奖信息：您获得了".$hjdd.$web_moneyname."！');location.href='box.php';</script>";
	exit;
}
?>
<!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>开宝箱-游戏中心-<?=$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" type=text/css rel=stylesheet>
</head>
<?php include_once("top.php");?>
<script language="javascript">
qiehuan(2);
document.getElementById("qh_con2").getElementsByTagName('li')[8].className="current";
</script>
<DIV class="wrapper">
	<DIV class="page_content">
		<DIV class="webgame-info-title">
		  <UL>
			<LI class="current"><A href="box.php">开宝箱首页</A> </LI>
			<LI><A href="boxinsert.php">我的开宝箱记录</A></LI>
			<LI><A href="bbs/index.php">玩家交流</A></LI>
		  </UL>
		</DIV>
		<DIV class="webgame-info">
			<DIV class="webgame-info-tabs">
			  <table width="940" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="15"></td>
                </tr>
              </table>
                <table width="99%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="33%"><table width="197" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td align="center" bgcolor="#FDF7F2" class="bk-kbx"><table width="80" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                          <td height="170"><img src="images/game-kbx_13.gif" width="160" height="141" /></td>
                        </tr>
                        <tr>
                          <td height="20"><img src="images/game-kbx_27.gif" width="168" height="20" /></td>
                        </tr>
                        <tr>
                          <td height="75"><a href="javascript:insert(1);" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image36','','images/game-kbx_38.gif',1)"><img src="images/game-kbx_37.gif" name="Image36" width="142" height="54" border="0" id="Image36" /></a></td>
                        </tr>
                      </table></td>
                    </tr>
                    <tr>
                      <td><img src="images/game-kbx_42.gif" width="197" height="34" /></td>
                    </tr>
                  </table></td>
                  <td width="34%"><table width="197" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td align="center" bgcolor="#FDF7F2" class="bk-kbx"><table width="80" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td height="170"><img src="images/game-kbx_15.gif" width="160" height="141" /></td>
                          </tr>
                          <tr>
                            <td height="20"><img src="images/game-kbx_29.gif" width="160" height="20" /></td>
                          </tr>
                          <tr>
                            <td height="75"><a href="javascript:insert(2);" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image361','','images/game-kbx_38.gif',1)"><img src="images/game-kbx_37.gif" name="Image361" width="142" height="54" border="0" id="Image361" /></a></td>
                          </tr>
                      </table></td>
                    </tr>
                    <tr>
                      <td><img src="images/game-kbx_42.gif" width="197" height="34" /></td>
                    </tr>
                  </table></td>
                  <td width="33%"><table width="197" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td align="center" bgcolor="#FDF7F2" class="bk-kbx"><table width="80" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td height="170"><img src="images/game-kbx_17.gif" width="162" height="141" /></td>
                          </tr>
                          <tr>
                            <td height="20"><img src="images/game-kbx_31.gif" width="158" height="20" /></td>
                          </tr>
                          <tr>
                            <td height="75"><a href="javascript:insert(3);" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image362','','images/game-kbx_38.gif',1)"><img src="images/game-kbx_37.gif" name="Image362" width="142" height="54" border="0" id="Image362" /></a></td>
                          </tr>
                      </table></td>
                    </tr>
                    <tr>
                      <td><img src="images/game-kbx_42.gif" width="197" height="34" /></td>
                    </tr>
                  </table></td>
                </tr>
              </table>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="10"></td>
                  </tr>
                </table>
				<?
				$query=$db->query("Select * from {$web_dbtop}gamebox where id=1 Order by id asc");
				if($rs=$db->fetch_array($query)){
				?>
                <table width="99%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="33%"><table width="197" border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr>
                        <td height="40" align="center" bgcolor="#FAE0A4"><img src="images/game-kbx_50.gif" width="131" height="25" /></td>
                      </tr>
                      <tr>
                        <td bgcolor="#FAE0A4"><table width="177" border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td height="14" background="images/game-kbx_62.gif"></td>
                          </tr>
                          <tr>
                            <td align="center" valign="top" background="images/game-kbx_79.gif"><table width="70%" border="0" align="center" cellpadding="3" cellspacing="0">
                              <tr>
                                <td width="20%" class="font-b">1、</td>
                                <td align="left" class="font-b"><?=$rs["box_1_1_j"]?><?=$web_moneyname?></td>
                              </tr>
                              <tr>
                                <td class="font-b">2、</td>
                                <td align="left" class="font-b"><?=$rs["box_1_2_j"]?><?=$web_moneyname?></td>
                              </tr>
                              <tr>
                                <td class="font-b">3、</td>
                                <td align="left" class="font-b"><?=$rs["box_1_3_j"]?><?=$web_moneyname?></td>
                              </tr>
                              <tr>
                                <td class="font-b">4、</td>
                                <td align="left" class="font-b"><?=$rs["box_1_4_j"]?><?=$web_moneyname?></td>
                              </tr>
                              <tr>
                                <td class="font-b">5、</td>
                                <td align="left" class="font-b"><?=$rs["box_1_5_j"]?><?=$web_moneyname?></td>
                              </tr>
                              <tr>
                                <td class="font-b">6、</td>
                                <td align="left" class="font-b"><?=$rs["box_1_6_j"]?><?=$web_moneyname?></td>
                              </tr>
                              <tr>
                                <td class="font-b">7、</td>
                                <td align="left" class="font-b"><?=$rs["box_1_7_j"]?><?=$web_moneyname?></td>
                              </tr>
                              <tr>
                                <td class="font-b">8、</td>
                                <td align="left" class="font-b"><?=$rs["box_1_8_j"]?><?=$web_moneyname?></td>
                              </tr>
                            </table></td>
                          </tr>
                          <tr>
                            <td><img src="images/game-kbx_81.gif" width="177" height="8" /></td>
                          </tr>
                        </table></td>
                      </tr>
                    </table></td>
                    <td width="34%"><table width="197" border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr>
                        <td height="40" align="center" bgcolor="#FAE0A4"><img src="images/game-kbx_53.gif" width="130" height="25" /></td>
                      </tr>
                      <tr>
                        <td bgcolor="#FAE0A4"><table width="177" border="0" align="center" cellpadding="0" cellspacing="0">
                            <tr>
                              <td height="14" background="images/game-kbx_62.gif"></td>
                            </tr>
                            <tr>
                              <td align="center" valign="top" background="images/game-kbx_79.gif"><table width="70%" border="0" align="center" cellpadding="3" cellspacing="0">
                                <tr>
                                  <td width="20%" class="font-b">1、</td>
                                  <td align="left" class="font-b"><?=$rs["box_2_1_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">2、</td>
                                  <td align="left" class="font-b"><?=$rs["box_2_2_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">3、</td>
                                  <td align="left" class="font-b"><?=$rs["box_2_3_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">4、</td>
                                  <td align="left" class="font-b"><?=$rs["box_2_4_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">5、</td>
                                  <td align="left" class="font-b"><?=$rs["box_2_5_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">6、</td>
                                  <td align="left" class="font-b"><?=$rs["box_2_6_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">7、</td>
                                  <td align="left" class="font-b"><?=$rs["box_2_7_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">8、</td>
                                  <td align="left" class="font-b"><?=$rs["box_2_8_j"]?><?=$web_moneyname?></td>
                                </tr>
                              </table></td>
                            </tr>
                            <tr>
                              <td><img src="images/game-kbx_81.gif" width="177" height="8" /></td>
                            </tr>
                        </table></td>
                      </tr>
                    </table></td>
                    <td width="33%"><table width="197" border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr>
                        <td height="40" align="center" bgcolor="#FAE0A4"><img src="images/game-kbx_56.gif" width="131" height="25" /></td>
                      </tr>
                      <tr>
                        <td bgcolor="#FAE0A4"><table width="177" border="0" align="center" cellpadding="0" cellspacing="0">
                            <tr>
                              <td height="14" background="images/game-kbx_62.gif"></td>
                            </tr>
                            <tr>
                              <td align="center" valign="top" background="images/game-kbx_79.gif"><table width="70%" border="0" align="center" cellpadding="3" cellspacing="0">
                                <tr>
                                  <td width="20%" class="font-b">1、</td>
                                  <td align="left" class="font-b"><?=$rs["box_3_1_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">2、</td>
                                  <td align="left" class="font-b"><?=$rs["box_3_2_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">3、</td>
                                  <td align="left" class="font-b"><?=$rs["box_3_3_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">4、</td>
                                  <td align="left" class="font-b"><?=$rs["box_3_4_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">5、</td>
                                  <td align="left" class="font-b"><?=$rs["box_3_5_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">6、</td>
                                  <td align="left" class="font-b"><?=$rs["box_3_6_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">7、</td>
                                  <td align="left" class="font-b"><?=$rs["box_3_7_j"]?><?=$web_moneyname?></td>
                                </tr>
                                <tr>
                                  <td class="font-b">8、</td>
                                  <td align="left" class="font-b"><?=$rs["box_3_8_j"]?><?=$web_moneyname?></td>
                                </tr>
                              </table></td>
                            </tr>
                            <tr>
                              <td><img src="images/game-kbx_81.gif" width="177" height="8" /></td>
                            </tr>
                        </table></td>
                      </tr>
                    </table></td>
                  </tr>
                </table>
				<?
				}
				?>
			  </td>
              <td width="215" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td><img src="images/game-kbx_10.gif" width="215" height="43" /></td>
                </tr>
                <tr>
                  <td background="images/game-kbx_11.gif"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="bj-kbx">
                    <tr>
                      <td><table width="80%" border="0" align="center" cellpadding="2" cellspacing="2">
                        <tr>
                          <td><img src="images/game-kbx_21.gif" width="124" height="16" /></td>
                        </tr>
                        <tr>
                          <td class="font-red2"><span class="rf">1、使用<?=$web_moneyname?>广告体验卡可按道具价值1:10奖励经验值。如使用11元广告卡奖励110经验值。</span><br />
                            2、幸运28每期投注可获得2个经验值。<br />
                            3、开心16每期投注可获得2个经验值。<br />
                            (投注金额都必须大于100<?=$web_moneyname?>)</td>
                        </tr>
                        <tr>
                          <td height="30">&nbsp;</td>
                        </tr>
                      </table></td>
                    </tr>
                  </table></td>
                </tr>
              </table>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="8"> </td>
                  </tr>
                </table>
                <table width="211" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><img src="images/game-kbx_47.gif" width="211" height="40" /></td>
                  </tr>
                  <tr>
                    <td background="images/game-kbx_78.gif"><table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="40%" class="font-red2"><strong>用户ID</strong></td>
                        <td class="font-red2"><strong>奖品</strong></td>
                      </tr>
					  <?
					   $query=$db->query("Select * from {$web_dbtop}gamebox_log Order by id desc limit 8");
				  	   while($rs=$db->fetch_array($query)){
					  ?>
					  <tr>
                        <td class="font-red2"><?=$rs["uid"]?></td>
                        <td class="font-red2"><?=$rs["hjpp"]?><?=$web_moneyname?></td>
                      </tr>
					 <?
					 }
					 ?>
					</table></td>
                  </tr>
                  <tr>
                    <td><img src="images/game-kbx_80.gif" width="211" height="21" /></td>
                  </tr>
                </table></td>
            </tr>
          </table>
		  <!--弹出div对话代码-->
			<div id="opentimes" style="position:relative;display:none;top:20px;left:30px;background-color:#ffffff;text-align:center;border:solid 1px;padding:10px;z-index:1;">
			<div>
			<form id="a" action="?act=insert" method="post">
				<input type="hidden" id="hidBoxType" name="boxType" value="1" />
			<table width="385" border="0" align="center" cellpadding="0" cellspacing="0">
			  <tr>
				<td width="14"><img src="images/kbx-yy_03.gif" width="14" height="209" /></td>
				<td valign="top" background="images/kbx-yy_04.gif" ><table border="0" align="center" cellpadding="0" cellspacing="0">
				  <tr>
					<td colspan="2" align="center"><img src="images/kbx-yy_06.gif" width="178" height="95" /></td>
					</tr>
				  <tr>
					<td height="50" style="font-size:14px;">请输入开箱次数:</td>
					<td><input  style=" height:20px; width:100px;"type="text" name="openTimes"  value="1" /></td>
				  </tr>
				  <tr>
					<td align="center"><input type="image" src="images/kbx-yy_02.gif" width="76" height="30" border="0" /></td>
					<td align="center"><a href="javascript:close();"><img src="images/kbx-yy_01.gif" width="76" height="30" border="0" /></a></td>
				  </tr>
				</table></td>
				<td width="13"><img src="images/kbx-yy_05.gif" width="13" height="209" /></td>
			  </tr>
			</table>
			</form>
			</div>
			</div>
		  <script  type="text/javascript">
			function insert(v){
				document.getElementById('hidBoxType').value = v;
				var vip = "<?=intval(showcontent("users","vip",intval($_COOKIE["usersid"])))?>";
				if(vip=='0'){
					document.getElementById('a').submit();
					return;
				}
				open();
			}
			var W = screen.width;
			var H = screen.height;
			function M(id){
				return document.getElementById(id);
			}
			function MC(t){
			   return document.createElement(t);
			}
			function isIE(){
				  return (document.all && window.ActiveXObject && !window.opera) ? true : false;
			}
			function getBodySize(){
			   var bodySize = [];
			   with(document.documentElement) {
				bodySize[0] = (scrollWidth>clientWidth)?scrollWidth:clientWidth;
				bodySize[1] = (scrollHeight>clientHeight)?scrollHeight:clientHeight;
			   }
			   return bodySize;
			}
			function popCoverDiv(){
			   if (M("cover_div")) {
				M("cover_div").style.display = 'block';
			   } else {
				var coverDiv = MC('div');
				document.body.appendChild(coverDiv);
				coverDiv.id = 'cover_div';
				with(coverDiv.style) {
				 position = 'absolute';
				 background = '#CCCCCC';
				 left = '0px';
				 top = '0px';
				 var bodySize = getBodySize();
				 width = bodySize[0] + 'px'
				 height = bodySize[1] + 'px';
				 zIndex = 0;
				 if (isIE()) {
				  filter = "Alpha(Opacity=60)";
				 } else {
				  opacity = 0.6;
				 }
				}
			   }
			}
			function showLogin(){
				var login=M("opentimes");
				login.style.display = "block";
			}
			function change(){
				var login = M("opentimes");
				login.style.position = "absolute";
				login.style.border = "0px solid #CCCCCC";
				login.style.background ="#CCCCCC";
				var bodySize = getBodySize();
				login.style.left = (bodySize[0]-385)/2+"px";
				login.style.top = (bodySize[1]-600)/2+"px";
				login.style.width = 0 + "px";
				login.style.height =0 + "px";
			}
			function open(){
				change();
				showLogin();
				popCoverDiv()
				void(0);
			}
			function close(){
				M('opentimes').style.display = 'none';
				M("cover_div").style.display = 'none';
				void(0);
			}
			function MM_preloadImages() { //v3.0
			  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
				var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
				if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
			}
			
			function MM_swapImgRestore() { //v3.0
			  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
			}
			
			function MM_findObj(n, d) { //v4.01
			  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
				d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
			  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
			  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
			  if(!x && d.getElementById) x=d.getElementById(n); return x;
			}
			
			function MM_swapImage() { //v3.0
			  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
			   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
			}
			</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>