<?php
session_start();
include_once("inc/conn.php");
include_once("inc/function.php");
login_check();
if($_GET["act"]=="almsgiving"){
	if(strtolower($_SESSION["yan"])!=strtolower($_POST["tbSafeCode"])){
		echo "<script language=javascript>alert('验证码错误!');history.go(-1);</script>";
		exit;
	}
	$query=$db->query("Select * from {$web_dbtop}gamedodge where uid=".intval($_COOKIE["usersid"])." and zt=0 Order by id desc");
	if($rs=$db->fetch_array($query)){
		echo "<script language=javascript>alert('对不起，猜拳摆擂中无法领取!');history.go(-1);</script>";
		exit;
	}
	$query=$db->query("Select * from {$web_dbtop}game28_kg_users_tz where uid=".intval($_COOKIE["usersid"])." Order by id desc");
	while($db->fetch_array($query)){
		echo "<script language=javascript>alert('对不起，幸运28投注中无法领取!');history.go(-1);</script>";
		exit;
	}
	$query=$db->query("Select * from {$web_dbtop}game16_kg_users_tz where uid=".intval($_COOKIE["usersid"])." Order by id desc");
	while($db->fetch_array($query)){
		echo "<script language=javascript>alert('对不起，开心16投注中无法领取!');history.go(-1);</script>";
		exit;
	}
	$query=$db->query("Select * from {$web_dbtop}game11_kg_users_tz where uid=".intval($_COOKIE["usersid"])." Order by id desc");
	while($db->fetch_array($query)){
		echo "<script language=javascript>alert('对不起，欢乐11投注中无法领取!');history.go(-1);</script>";
		exit;
	}
	$query=$db->query("Select id from {$web_dbtop}exchange where mode!=1 and uid=".intval($_COOKIE["usersid"]));
	if($rs=$db->fetch_array($query)){
		echo "<script language=javascript>alert('对不起，奖品兑换中无法领取!');history.go(-1);</script>";
		exit;
	}
	$query=$db->query("Select points,back,vip from {$web_dbtop}users where id=".intval($_COOKIE["usersid"]));
	if($rs=$db->fetch_array($query)){
		$userspoints=$rs["points"]+$rs["back"];
		$vip=$rs["vip"];
	}
	if($vip!=1){
		echo "<script language=javascript>alert('对不起，您不是VIP用户无法领取!');history.go(-1);</script>";
		exit;
	}
	if(intval($userspoints)>=500){
		echo "<script language=javascript>alert('对不起，您的".$web_moneyname."大于500无法领取!');history.go(-1);</script>";
		exit;
	}
	$db->query("delete from {$web_dbtop}adip where type=5 and STR_TO_DATE(time,'%Y-%m-%d')<'".date('Y-m-d')."'");
	$query=$db->query("Select id from {$web_dbtop}adip where uid=".intval($_COOKIE["usersid"])." and type=5 and adid=1");
	if($rs=$db->fetch_array($query)){
		$num=$db->num_rows($query);
	}
	if($num>=10){
		echo "<script language=javascript>alert('对不起，您今天已经领取过10次了,请明天在来吧!');history.go(-1);</script>";
		exit;
	}
	$db->query("insert into {$web_dbtop}adip (uid,ip,time,type,adid) values (".intval($_COOKIE["usersid"]).",'".usersip()."','".date("Y-m-d H:i:s")."',5,1)");
	$db->query("update {$web_dbtop}users set points=points+500 where id=".intval($_COOKIE["usersid"]));
	$db->query("update {$web_dbtop}game_log set jj_hd=jj_hd+500 where uid=".intval($_COOKIE["usersid"]));
	$db->query("update {$web_dbtop}webtj set jjpoints=jjpoints+500 where time='".date("Y-m-d")."'");
	userslog(5,"领取救济",500,0);
	echo "<script language=javascript>alert('领取成功');location.href='profit.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" rel="stylesheet" type="text/css" />
</head>
<?php include_once("top.php");?>
<script language="javascript">
qiehuan(1);
document.getElementById("qh_con1").getElementsByTagName('li')[0].className="current";
</script>
<DIV class="wrapper">
	<DIV class="page_content">
		<DIV class="webgame-info-title">
			<H3>领取救济</H3>
		</DIV>
			<UL class="webgame-info">
			  <table width="60%" border="0" align="center" cellpadding="5" cellspacing="10">
                <tr>
                  <td class="font14 rf"><p style="margin:5px;">1、VIP用户<?=$web_moneyname?>低于500，可以领取。</p>
                      <p style="margin:5px;">2、每天最多可以领取10次。</p>
                      <p style="margin:5px;">3、每次可领取500<?=$web_moneyname?>。</p>
                      <p style="margin:5px;">注意:每个ID只能体验5次!</p></td>
                </tr>
                <form action="?act=almsgiving" method="post">
                  <tr>
                    <td align="center"><table cellspacing="0" cellpadding="0" width="250" border="0"  class="login">
                        <tbody>
                          <tr>
                            <td width="70" align="right">验证码： </td>
                            <td><input name="tbSafeCode" type="text" class="inp_yz" id="tbSafeCode" style="text-transform: uppercase" maxlength="4" /></td>
                            <td width="100"><img id="vdimgck" src="inc/code.php" alt="看不清？点击更换" width="60" height="22" style="cursor:pointer" onclick="this.src=this.src+'?'" /></td>
                          </tr>
                        </tbody>
                    </table></td>
                  </tr>
                  <tr>
                    <td align="center"><input type="image" border="0" name="imageField" src="images/50_16.jpg" /></td>
                  </tr>
                </form>
		      </table>
			</UL>
		<div class="area960-b h5px"></div>
		<div class="blank10"></div>
	</div>
	<!--Flink End-->
	<DIV class=cl></DIV>
	<div class="blank10"></div>
	<!--Footer Start-->
<?php include_once("footer.php");?>
</DIV>