File: /www/备份的/www.luckcjtw.com/game.php
<?PHP
//set_time_limit(0);
header('Content-Type: text/html; charset=UTF-8');
#加载系统配置文件 该文件只包含各种系统配置项
require "./include/config.h";
#加载公共函数 主要是一些工具函数
require "./include/functions.php";
#开启数据库连接
$db = tools::get_db();
$db_ = $db;tools::db();
//获取活动ID
$nGameId = (int)$_REQUEST["game_id"];
//若无活动ID,则跳转到默认活动ID
if ( $nGameId <= 0 ) {
#获取 活动信息
$sSql = "SELECT * FROM gift_game WHERE status = 1 AND is_default = 1 ORDER BY game_id DESC LIMIT 1";
$db->query( $sSql );
$row = $db->next_row();
if ( (int)$row["game_id"] > 0 ) {
header("Location: game.php?game_id=".(int)$row["game_id"]);
exit;
}
//有活动ID,则判断活动是否结束
} else {
#获取 活动信息
$sSql = "SELECT * FROM gift_game WHERE status = 1 AND game_id = ".$nGameId;
$db->query( $sSql );
$aGameInfo = $row = $db->next_row();
if ( (int)$row["game_id"] <= 0 ) {
exit("活動已結束");
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html style="height: 100%;">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?PHP echo $aGameInfo["game_name"]; ?></title>
<style>
body {
margin:0px;text-align:center;
font-family:微软雅黑;font-size:35px;font-weight:bold;color:white;
background:url(<?php echo $aGameInfo[game_bgimg]; ?>?001);
background-repeat: no-repeat;
background-size:100% 100%;
}
table, td{ border:0px solid #CCC; padding-top:4px; padding-bottom:4px;}
table{
border-collapse:collapse;
}
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
cursor: pointer;
}
.btn1 {
padding: 5px 5px;
font-size: 12px;
}
h2{line-height:30px; font-size:20px;}
a,a:hover{ text-decoration:none;}
pre{font-family:'微软雅黑'}
.box{width:100px; padding:10px 20px; background-color:#fff; margin:10px auto;}
.box a{padding-right:20px;}
.border1 {
text-align: center;
vertical-align: middle;
width:90%;
height:100%;
border-radius:30px;
background-color: #F7BE15;
box-shadow: 5px 5px 5px #888888;
}
.border2 {
display:inline-block;
text-align: center;
vertical-align: middle;
width:90%;
height:90%;
border-radius:30px;
background-color: white;
margin-top:30px;
box-shadow: 5px 5px 5px #888888;
}
.border22 {
display:inline-block;
text-align: center;
vertical-align: middle;
width:90%;
height:90%;
background-color: white;
margin-top:20px;
margin-left:20px;
//border:1px solid red;
}
.border3 {
display: -webkit-box;
-webkit-box-orient: horizontal;
-webkit-box-pack: center;
-webkit-box-align: center;
text-align: center;
vertical-align: middle;
width:29%;
height:29%;
border-radius:10px;
background-color: #E82545;
float:left;
margin:10px;
box-shadow: 4px 4px 4px #888888;
border:2px solid red;
}
.border33 {
background-color: #F7BE15;
box-shadow: 5px 5px 5px #888888;
font-size:40px;
color:#AC121C;
border:2px solid #000;
}
</style>
<script src="js/jquery-3.5.1.min.js"></script>
<script type='text/javascript'>
window.alert = function(name){
var iframe = document.createElement("IFRAME");
iframe.style.display="none";
iframe.setAttribute("src", 'data:text/plain,');
document.documentElement.appendChild(iframe);
window.frames[0].window.alert(name);
iframe.parentNode.removeChild(iframe);
}
$(document).ready(function(){
$("#startdraw").click(function(data){
var confirm = prompt("請輸入手機4位尾數或抽獎碼:", "");
if (confirm) {
//获取抽奖结果
$.post("./draw.php",
{
game_id:<?PHP echo $nGameId; ?>,
usercode:confirm,
},
function(data,status){
if ( status != "success" )
{
return false;
}
//console.log(data);
//console.log(status);
var parsedJson = jQuery.parseJSON(data);
if (parsedJson.status <= 0)
{
alert(parsedJson.msg);
return false;
}
//执行抽奖动作
var timeSetInterval = 100;
var number = 1;
//console.log(parsedJson.msg);
var oTime = setInterval(function() {
var result = (8 * 5) + parseInt(parsedJson.msg);
//console.log(result);
if ( number > result) {
alert("恭喜您抽到獎品【" + parsedJson.desc + "】一份!");
clearInterval(oTime);
//return false;
} else {
for (i=1; i<=8;i++ )
{
$("#item"+i).css("background-color","red");
}
//取余
var roundnumber = number%8 > 0 ? number%8 : 8;
$("#item"+roundnumber).css("background-color","orange");
//console.log("timeSetInterval : " + timeSetInterval + ", number : " + number + ", roundnumber : " + roundnumber);
number = number + 1;
}
}, timeSetInterval);
});
} else if (confirm == "") {
alert("抽獎碼不能為空!");
return false;
} else {
return false;
}
});
});
</script>
</head>
<body style="height: 100%;" >
<?PHP
#获取 奖品信息
$sSql = "SELECT * FROM gift_items WHERE game_id = '".$nGameId."' ORDER BY orderby ASC,item_id ASC";
$db->query( $sSql );
$aGift = array(0 => 0);
while( $row = $db->next_row() ) {
$aGift[ $row["orderby"] ] = $row;
}
$sHtml = "<table width=100% height=100% align=center>";
$sHtml .= "<tr><td height=55%></td></tr>";
$sHtml .= "<tr><td height=36% align=center>";
$sHtml .= "<div class=border1>";
//$sHtml .= "<div class=border2>";
$sHtml .= "<div class=border2><div class=border22>";
$sHtml .= "<div class=border3 id=item1>".$aGift[1]["item_name"]."</div>";
$sHtml .= "<div class=border3 id=item2>".$aGift[2]["item_name"]."</div>";
$sHtml .= "<div class=border3 id=item3>".$aGift[3]["item_name"]."</div>";
$sHtml .= "<div class=border3 id=item8>".$aGift[8]["item_name"]."</div>";
$sHtml .= "<div class='border3 border33' id=startdraw>立即抽獎</div>";
$sHtml .= "<div class=border3 id=item4>".$aGift[4]["item_name"]."</div>";
$sHtml .= "<div class=border3 id=item7>".$aGift[7]["item_name"]."</div>";
$sHtml .= "<div class=border3 id=item6>".$aGift[6]["item_name"]."</div>";
$sHtml .= "<div class=border3 id=item5>".$aGift[5]["item_name"]."</div>";
$sHtml .= "</div></div>";
//$sHtml .= "</div>";
$sHtml .= "</div>";
$sHtml .= "</td></tr>";
$sHtml .= "<tr><td></td></tr>";
$sHtml .= "</table>";
echo $sHtml;
?>
</body>
</html>