PHP新中原信用盤口自動開獎,自動開盤代碼寫法教程

聲明:代碼僅供參考,學習的主要是邏輯思路,請勿用於非法違規經營網站的操作。

1、先看一下未使用開獎代碼的情況: 

2、 開獎代碼我已經寫好,現在我們點擊 “❈自動開獎❈” 按鈕,調用開獎程序

                                     點擊按鈕之後,會彈出自動開獎程序的頁面,如下圖所示:

3、我們再回到之前的頁面刷新,可以看到已經有數據了

  

4、下面貼出自動開盤開獎的代碼,程序不一樣,不能直接複用

<?php
/*
 * 註明:開獎數據採集來源於七彩網(gocp.me)
 * 訪問www.gocp.me申請到接口後,把token填寫
 * 到下方的define('TOKEN',"您的token")即可
*/
///////////////API設置/////////////////
define('HOST', "http://api.gocp.me");//
define('TOKEN', "七彩網賬號的token"); //
///////////////////////////////////////

define('Copyright', 'Copyright 2019 HK6 All Rights Reserved.');
define('ROOT_PATH', $_SERVER["DOCUMENT_ROOT"].'/');
require ("curl_http.php");
include_once ROOT_PATH.'/foot/check.php';

//獲取七彩網(gocp.me)API數據
function getDataByApi(){
	$curl = &new Curl_HTTP_Client();
	$curl->set_referrer("");
	$curl->set_user_agent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Maxthon/4.4.3.4000 Chrome/30.0.1599.101");
	$html = $curl->fetch_url(HOST."/api?token=".TOKEN."&code=hk6&format=json&rows=1&t=".time());
	$json=json_decode($html,true);
	$data=$json['data'];
	
	$result=array();	
	//期號
	$result['expect'] = $data[0]['expect'];
	//號碼
	$result['opencode'] = $data[0]['opencode'];
	//時間
	$result['opentime'] = $data[0]['opentime'];
	return $result;
}

function auto_up($data){	
	if(empty($data['expect'])){
		echo "獲取APi數據失敗!";
		exit;
	}
	$expect=$data['expect'];
	$opencode=$data['opencode'];
	$opentime=$data['opentime'];

	$arr=explode(",",$opencode);
	$num=array();
	$num['qishu']=$expect;
	$num['date']=$opentime;
	$num['n1']=$arr[0];
	$num['n2']=$arr[1];
	$num['n3']=$arr[2];
	$num['n4']=$arr[3];
	$num['n5']=$arr[4];
	$num['n6']=$arr[5];
	$num['na']=$arr[6];
	
	//第一期
	$num['nq']=$expect+1;
	$w= date("w", strtotime($opentime));//取得一週的第幾天,星期天開始0-6
	if($w==6){
		$num['kaijiang']=date('Y-m-d H:i:s',strtotime("$opentime +3 day"));
	}else{
		$num['kaijiang']=date('Y-m-d H:i:s',strtotime("$opentime +2 day"));
	}
	$firstDay=date('Y-m-d H:i:s',strtotime($num['kaijiang']));
	$num['kaipan']=date('Y-m-d H:i:s',strtotime("$firstDay -13 hour"));
	$num['fengpan']=date('Y-m-d H:i:s',strtotime("$firstDay -5 minute"));
	//第二期
	$num['nq2']=$expect+2;
	$w2= date("w", strtotime($num['kaijiang']));
	if($w2==6){
		$num['kaijiang2']=date('Y-m-d H:i:s',strtotime("$firstDay +3 day"));
	}else{
		$num['kaijiang2']=date('Y-m-d H:i:s',strtotime("$firstDay +2 day"));
	}
	$secondDay=date('Y-m-d H:i:s',strtotime($num['kaijiang2']));
	$num['kaipan2']=date('Y-m-d H:i:s',strtotime("$secondDay -13 hour"));
	$num['fengpan2']=date('Y-m-d H:i:s',strtotime("$secondDay -5 minute"));
	//第三期
	$num['nq3']=$expect+3;
	$w3= date("w", strtotime($num['kaijiang2']));
	if($w3==6){
		$num['kaijiang3']=date('Y-m-d H:i:s',strtotime("$secondDay +3 day"));
	}else{
		$num['kaijiang3']=date('Y-m-d H:i:s',strtotime("$secondDay +2 day"));
	}
	$thirdDay=date('Y-m-d H:i:s',strtotime($num['kaijiang3']));
	$num['kaipan3']=date('Y-m-d H:i:s',strtotime("$thirdDay -13 hour"));
	$num['fengpan3']=date('Y-m-d H:i:s',strtotime("$thirdDay -5 minute"));
	/*
	echo "<br>第1期開獎時間:".$num['kaijiang'];
	echo "<br>第1期開盤時間:".$num['kaipan'];
	echo "<br>第1期封盤時間:".$num['fengpan'];
	echo "<br>";
	echo "<br>第2期開獎時間:".$num['kaijiang2'];
	echo "<br>第2期開盤時間:".$num['kaipan2'];
	echo "<br>第2期封盤時間:".$num['fengpan2'];
	echo "<br>";
	echo "<br>第3期開獎時間:".$num['kaijiang3'];
	echo "<br>第3期開盤時間:".$num['kaipan3'];
	echo "<br>第3期封盤時間:".$num['fengpan3'];
	die;
	*/
	return $num;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD html 4.0 Transitional//EN">
<html>
 <head>
 <title>自動開獎頁面</title>
 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
 <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
 <link rel="stylesheet" type="text/css" href="images/dommon.css">
 <link rel="stylesheet" type="text/css" href="css/<?php global $g_stylss; echo $g_stylss;?>.css"/>
</head>
<body class="normalBody" oncontextmenu="window.event.returnValue=false">
 <div class="wrapper">
    <div class="route">
      <div>
        <span>自動開獎頁面----請不要關閉</span>
      </div>
    </div><!-- route end -->
<table class="listDetailTable">
<tr>
<td width=100% align=left><b>
<?php   
$result=getDataByApi();
if(empty($result['expect'])){
	echo "獲取APi數據失敗!";
	exit;
}
$newQi=$result['expect'];	
$autos = $db->query("SELECT `nn`,`date`,`n1`,`n2`,`n3`,`n4`,`n5`,`n6`,`na` FROM `cn_kithe` WHERE `nn` = '{$newQi}'", 1);
if($autos[0]['na']==0){
	//添加新的盤口
	$start=auto_up($result);
	//第一期
	$id = $db->query(" select * from `ya_kithe` where id='1'", 1);
	if(empty($id)){
		$db->query("INSERT INTO `ya_kithe` (`id`,`nn`,`nd`,`na`,`n1`,`n2`,`n3`,`n4`,`n5`,`n6`,`kitm`,`kitm1`,`kizm`,`kizm1`,`zfb`,`zfbdate`, `zfbdate1`,`best`,`lx`) VALUES (1,'{$start['nq']}','{$start['kaijiang']}',0,0,0,0,0,0,0,1,'{$start['fengpan']}',1,'{$start['fengpan']}',0,'{$start['fengpan']}','{$start['kaipan']}',1,0)" , 2);			
		echo "<br>【預設開獎】成功添加第".$start['nq']."期";
	}else{
		$db->query("update `ya_kithe` SET `nn`='{$start['nq']}',`nd`='{$start['kaijiang']}',`kitm1`='{$start['fengpan']}',`kizm1`='{$start['fengpan']}',`zfbdate`='{$start['fengpan']}',`zfbdate1`='{$start['kaipan']}',`kitm`=1,`kizm`=1 where id=1 ", 2); 
		echo "<br>【預設開獎】成功修改第".$start['nq']."期";
	}
	//第二期
	$id2 = $db->query(" select * from `ya_kithe` where id='2'", 1);
	if(empty($id2)){
		$db->query("INSERT INTO `ya_kithe` (`id`,`nn`,`nd`,`na`,`n1`,`n2`,`n3`,`n4`,`n5`,`n6`,`kitm`,`kitm1`,`kizm`,`kizm1`,`zfb`,`zfbdate`, `zfbdate1`,`best`,`lx`) VALUES (2,'{$start['nq2']}','{$start['kaijiang2']}',0,0,0,0,0,0,0,1,'{$start['fengpan2']}',1,'{$start['fengpan2']}',0,'{$start['fengpan2']}','{$start['kaipan2']}',1,0)" , 2);			
		echo "<br>【預設開獎】成功添加第".$start['nq2']."期";
	}else{
		$db->query("update `ya_kithe` SET `nn`='{$start['nq2']}',`nd`='{$start['kaijiang2']}',`kitm1`='{$start['fengpan2']}',`kizm1`='{$start['fengpan2']}',`zfbdate`='{$start['fengpan2']}',`zfbdate1`='{$start['kaipan2']}',`kitm`=1,`kizm`=1 where id=2 ", 2); 
		echo "<br>【預設開獎】成功修改第".$start['nq2']."期";
	}
	//第三期
	$id3 = $db->query(" select * from `ya_kithe` where id='3'", 1);
	if(empty($id3)){
		$db->query("INSERT INTO `ya_kithe` (`id`,`nn`,`nd`,`na`,`n1`,`n2`,`n3`,`n4`,`n5`,`n6`,`kitm`,`kitm1`,`kizm`,`kizm1`,`zfb`,`zfbdate`, `zfbdate1`,`best`,`lx`) VALUES (3,'{$start['nq3']}','{$start['kaijiang3']}',0,0,0,0,0,0,0,1,'{$start['fengpan3']}',1,'{$start['fengpan3']}',0,'{$start['fengpan3']}','{$start['kaipan3']}',1,0)" , 2);			
		echo "<br>【預設開獎】成功添加第".$start['nq3']."期";
	}else{
		$db->query("update `ya_kithe` SET `nn`='{$start['nq3']}',`nd`='{$start['kaijiang3']}',`kitm1`='{$start['fengpan3']}',`kizm1`='{$start['fengpan3']}',`zfbdate`='{$start['fengpan3']}',`zfbdate1`='{$start['kaipan3']}',`kitm`=1,`kizm`=1 where id=3 ", 2); 
		echo "<br>【預設開獎】成功修改第".$start['nq3']."期";
	}
	echo "獲得結果</br>";
    echo $start['qishu']."期:".$start['n1']."-".$start['n2']."-".$start['n3']."-".$start['n4']."-".$start['n5']."-".$start['n6']."-特:".$start['na'];
    echo "</br>開獎時間:".$start['date'];
	//更新開獎
	if($autos[0]['nn']==$start['qishu']){	
		//開獎第一球
		if (!empty($start['n1']) && $start['n1']!=0){
			$db->query("update `cn_kithe` SET `n1` = '{$start['n1']}' WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);
			$db->query("update `cn_kithe` SET `kitm` =0,`kizm` =0,`zfb` =0 WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);
		}

		if (!empty($start['n2']) && $start['n2']!=0){
			$db->query("update `cn_kithe` SET `n2` = '{$start['n2']}' WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);
			$db->query("update `cn_kithe` SET `kitm` =0,`kizm` =0,`zfb` =0 WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);
		}

		if (!empty($start['n3']) && $start['n3']!=0){
			$db->query("update `cn_kithe` SET `n3` = '{$start['n3']}' WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);
			$db->query("update `cn_kithe` SET `kitm` =0,`kizm` =0,`zfb` =0 WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);
		}

		if (!empty($start['n4']) && $start['n4']!=0){
			$db->query("update `cn_kithe` SET `n4` = '{$start['n4']}' WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);
			$db->query("update `cn_kithe` SET `kitm` =0,`kizm` =0,`zfb` =0 WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);

		}
		if (!empty($start['n5']) && $start['n5']!=0){
			$db->query("update `cn_kithe` SET `n5` = '{$start['n5']}' WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);
			$db->query("update `cn_kithe` SET `kitm` =0,`kizm` =0,`zfb` =0 WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);
		}

		if (!empty($start['n6']) && $start['n6']!=0){
			$db->query("update `cn_kithe` SET `n6` = '{$start['n6']}' WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);
			$db->query("update `cn_kithe` SET `kitm` =0,`kizm` =0,`zfb` =0 WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);
		}
		if (!empty($start['na']) && $start['na']!=0){
			$fa=$start['na'];
			$fb=(int)$fa;
			if ($fb<10) {
				$vv="0".$fb;
			}else{
				$vv=$fb;
			}
			$sx=Get_sx_Color($vv);

			if($start[0]['na']==0){
				$db->query("update `cn_kithe` SET `na` = '{$start['na']}', `sx` = '{$sx}' WHERE `nn` = '{$autos[0]['nn']}' LIMIT 1 ", 2);
				$sql = "SELECT * FROM ya_kithe  order by nn LIMIT 1";
				$result = $db->query($sql, 1);
				$ykithe=$result[0];
				//添加新盤口
				$db->query("INSERT INTO `cn_kithe` (`best`, `nn`, `nd`, `kitm`, `kizm`, `zfbdate`, `kitm1`, `kizm1`, `zfbdate1`, `date`, `n1`, `n2`, `n3`, `n4`, `n5`, `n6`, `na`, `lx`) VALUES (1,'{$ykithe['nn']}','{$ykithe['nd']}','{$ykithe['kitm']}','{$ykithe['kizm']}','{$ykithe['zfbdate']}','{$ykithe['kitm1']}','{$ykithe['kizm1']}','{$ykithe['zfbdate1']}','{$ykithe['nd']}',0,0,0,0,0,0,0, 0) ", 2);	
				echo "<br>【新盤口】成功添加第".$ykithe['nn']."期";
				$autok = $db->query("SELECT `nn` FROM cn_kithe WHERE `n1` = '0' and `n2` = '0' and `n3` = '0' and `na` = '0'  LIMIT 1", 1);
				if($start['nq']==$autok[0]['nn']){
					$nyr=date("Y-m-d",strtotime($start['kaijiang']));//年月日
					$db->query("UPDATE `cn_kithe` SET `nd` = '{$start['kaijiang']}',`kitm` = 1,`kizm` = 1,`zfbdate` = '{$start['fengpan']}',`kitm1` = '{$start['fengpan']}',`kizm1` = '{$start['fengpan']}',`zfbdate1` = '{$start['kaipan']}',`date` = '{$nyr}',`best` = 1 WHERE `nn` = '{$start['nq']}' LIMIT 1 ", 2);		
					echo "<br>【新盤口】成功修改第".$start['nq']."期";
				}
			}
		}
	}else{
		//如果沒有盤口,就添加開盤信息
		$date=$start['date'];				//開獎時間
		$nyr=date("Y-m-d",strtotime($date));//年月日
		$kitm1=$nyr.' 21:25:30';			//特碼封盤時間
		$kizm1=$nyr.' 21:25:30';			//正碼封盤時間
		$zfbdate=$nyr.' 21:25:30';			//總封盤時間
		$zfbdate1=$nyr.' 08:00:00';			//總開盤時間
		$db->query("INSERT INTO `cn_kithe` (`best`, `nn`, `nd`, `kitm`, `kizm`, `zfbdate`, `kitm1`, `kizm1`, `zfbdate1`, `date`, `n1`, `n2`, `n3`, `n4`, `n5`, `n6`, `na`, `lx`) VALUES (1,'{$start['qishu']}','{$start['date']}',1,1,'{$zfbdate}','{$kitm1}','{$kizm1}','{$zfbdate1}','{$date}',0,0,0,0,0,0,0, 0) ", 2);		
		echo "<br>【新盤口】成功添加第".$start['qishu']."期";
	}
}else{
	echo "等待最新開獎信息...";
}  
?>
</b></td>
</tr>
</table>
  <div class="footer">
      <div class="pageTitle"><input type=button name=button value="刷新" onClick="window.location.reload()"></div>
   </div>
  </div><!-- wrapper end -->
 </body>
</html>
<script> 
<!-- 
var limit="00:10" 
if (document.images){ 
	var parselimit=limit.split(":") 
	parselimit=parselimit[0]*60+parselimit[1]*1 
} 
function beginrefresh(){ 
	if (!document.images) 
	return 
	if (parselimit==1) 
		window.location.reload() 
	else{ 
		parselimit-=1 
		curmin=Math.floor(parselimit/60) 
		cursec=parselimit%60 
		if (curmin!=0) 
			curtime=curmin+"分"+cursec+"秒後自動本頁獲取最新數據!" 
		else 
			curtime=cursec+"秒後自動本頁獲取最新數據!" 
			timeinfo.innerText=curtime 
			setTimeout("beginrefresh()",5000) 
	} 
} 
window.onload=beginrefresh 
--> 
</script>
<span id="timeinfo"></span>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章