日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > php >内容正文

php

PHP 每小时抽奖,php分时间段的抽奖程序代码

發(fā)布時(shí)間:2024/9/19 php 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PHP 每小时抽奖,php分时间段的抽奖程序代码 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

//您來(lái)早了,活動(dòng)還沒(méi)有開(kāi)始!

return -21;

}

if(intval(TIME)>intval(L_END)){

//已經(jīng)過(guò)了活動(dòng)時(shí)間,非常遺憾,謝謝!

return -22;

}

if ($this->get_user_lfb ( $user ['uid'] ) < L_MIN) {

//$this->credit ( $user ['uid'], -11, $logid );

return -11; //您的來(lái)福幣余額不足

}

$data = array(

'uid' => $user ['uid'],

'tel' => $user ['tel'],

'ip' => $user ['ip'],

'addtime' => time ()

);

$logid = DB::insert ( $this->lottery_log, $data, true );

//檢查用戶 每天 已中獎(jiǎng)品數(shù)

if ($this->get_lottery ( $user ['uid'], strtotime ( date ( 'Y-m-d', TIME ) ), strtotime ( "+1day", strtotime ( date ( 'Y-m-d', TIME ) ) ), true ) >= L_DAY_CISHU) {

$this->credit ( $user ['uid'], -12, $logid );

//很遺憾,你本次什么也沒(méi)有抽到!

return -12;

}

//檢查用戶 全部 已中獎(jiǎng)品數(shù)

if ($this->get_lottery ( $user ['uid'], 0, 0, true ) > L_CISHU&&L_CISHU>0) {

$this->credit ( $user ['uid'], -12, $logid );

//很遺憾,你本次什么也沒(méi)有抽到!

return -15;

}

//檢測(cè)黑名單,設(shè)置概率

if ($this->checkhei ( $user ['tel'] ) > 0) {

$this->credit ( $user ['uid'], -13, $logid );

//很遺憾,你本次什么也沒(méi)有抽到!

return -13;

}

$lotteryid = $this->choujiang();

$this->credit ( $user ['uid'], $lotteryid<1?$lotteryid:0, $logid, $lotteryid ,$this->hao);

if ($lotteryid > 0) {

return $this->lotteryArray [$lotteryid];

} else {

return -4;

}

//-1獎(jiǎng)品已發(fā)完

//-2本時(shí)段獎(jiǎng)品已玩

//-3不發(fā)獎(jiǎng)品

//-4獎(jiǎng)品有問(wèn)題

//-11您的來(lái)福幣余額不足

//-12很遺憾,你本次什么也沒(méi)有抽到!

//-13黑名單里面,很遺憾,你本次什么也沒(méi)有抽到!

//-14中獎(jiǎng)專業(yè)戶禁止中高講高獎(jiǎng)品

//-15已超過(guò)yizhong總獎(jiǎng)品數(shù)

//-16 掌蘇傳遞手機(jī) 號(hào)錯(cuò)誤

//-21您來(lái)早了,活動(dòng)還沒(méi)有開(kāi)始!

//-22已經(jīng)過(guò)了活動(dòng)時(shí)間,非常遺憾,謝謝!

//-23對(duì)不起,現(xiàn)在不是活動(dòng)時(shí)間,活動(dòng)時(shí)間為每天

}

/**

* 顯示

* @param unknown_type $data

*/

public function show($data){

$ok=0;//3中獎(jiǎng)

$zz=0;//轉(zhuǎn)盤度數(shù)

$result='';//獎(jiǎng)品名稱

$lotteryid=0;//獎(jiǎng)品ID

if(is_array($data)){

$ok=3;

$result=$data['msg'];

$zz=$data['angle']+L_QUANSHU*360;

$lotteryid=$data['lotteryid'];

}else{

$m='';

switch($data){

case 0:{

$m= '請(qǐng)先登錄!';

}break;

case -11:{

$m= '您的來(lái)福幣余額不足!';

}break;

case -12:{

$m= '很遺憾,你本次什么也沒(méi)有抽到!';

}break;

case -21:{

$m= '您來(lái)早了,活動(dòng)還沒(méi)有開(kāi)始!';

}break;

case -22:{

$m= '已經(jīng)過(guò)了活動(dòng)時(shí)間,非常遺憾,謝謝!';

}break;

case -23:{

$m= '對(duì)不起,現(xiàn)在不是活動(dòng)時(shí)間,活動(dòng)時(shí)間為每天'.L_DAY_START.':00-'.L_DAY_END.':00';

}break;

default:{

$m= '很遺憾,你本次什么也沒(méi)有抽到!';

}break;

}

$result=$m;

$ok=3;//3中獎(jiǎng)

$zz=360+L_QUANSHU*360;//再接再厲

}

header("Expires:Mon,26Jul199705:00:00GMT");

header("Cache-Control:no-cache,must-revalidate");

header("Pragma:no-cache");

header("Content-type:text/html;charset=utf-8");

if(!$this->type){

echo json_encode(array('return'=>$lotteryid,

'msg'=>$result));

}else{

echo ''."\n";

echo ''."\n";

echo ''."\n";

echo ''."\n";

}

exit;

}

/**

* 抽獎(jiǎng)的號(hào)

*/

private $hao=0;

/**

* 抽獎(jiǎng)開(kāi)始

*/

private function choujiang() {

$j = 0;

$lotteryid = 0;

$j = mt_rand ( 1, $this->max );

$this->hao=$j;

foreach ( $this->level as $k => $r ) {

if ($r ['start'] <= $j && $r ['end'] > $j) {

$lotteryid = $k;

break;

}

}

$d = array(

1 => array(

'time' => strtotime ( date ( 'Y-m-d 00:00:00', TIME ) ),

'time_end' => strtotime ( date ( 'Y-m-d 07:59:59', TIME ) )

)

);

for ($i=2;$i<=17;$i++){

$d[$i]=array(

'time' => strtotime ( date ( 'Y-m-d '.($i+6).':00:00', TIME ) ),

'time_end' => strtotime ( date ( 'Y-m-d '.($i+6).':59:59', TIME ) )

);

}

if($lotteryid>0){

$l=$this->lotteryArray [$lotteryid];

$sql = "select count(*) m from " . DB::table ( $this->lottery_log );

$sql .= " where lotteryid='$lotteryid' ";

$s= intval ( DB::result_first ( $sql ) );

$sum_over=$l['sum']-$s;

if($sum_over>0){

//本時(shí)段 獎(jiǎng)品數(shù)

$sum=0;

foreach ($d as $k=>$r){

if(TIME>=$r['time']&&TIME<=$r['time_end']){

if($l['time_'.$k]>0){//個(gè)數(shù)限制

$sum=$this->get_lottery_id(0,$r['time'],$r['time_end']+1,$lotteryid);

if($sum>=$l['time_'.$k]){

//本時(shí)段獎(jiǎng)品已玩

$lotteryid=-2;

break;

}

}elseif ($l['time_'.$k]==0){

//不發(fā)獎(jiǎng)品

$lotteryid=-3;

break;

}else{

//-1 不限制

}

}

}

if($this->tel_zy && $lotteryid>0&&$lotteryid<4){

$lotteryid=-14;

}

}else{

//獎(jiǎng)品已發(fā)完

$lotteryid=-1;

}

}else{

//獎(jiǎng)品有問(wèn)題

$lotteryid=-4;

}

return $lotteryid;

}

/**

* 檢測(cè)黑名單和普通用戶,概率

* @param string $tel

* @return 大于1 表示本次禁止抽

*/

private function checkhei($tel) {

$n = mt_rand ( 1, 100 );

if (in_array ( $tel, $this->heimingdan ['tel'] ) && L_ZY > 0) {

$this->tel_zy=true;

if ($n > L_ZY) {

return 1;

}

}else{

//號(hào)碼檢測(cè)

if (!self::check_tel($tel)) {

return 1;

}

}

return 0;

}

/**

* 合計(jì)獎(jiǎng)品數(shù)

* @param intval $uid

* @param intval $start

* @param intval $end

* @param bool $bool true 獲得獎(jiǎng)品數(shù) false 不統(tǒng)計(jì)

* @return number

*/

private function get_lottery($uid = 0, $start = 0, $end = 0, $bool = false) {

$sql = "select count(*) m from " . DB::table ( $this->lottery_log );

$sql .= " where 1 ";

if (intval ( $start ) > 0) {

$sql .= " and addtime>='$start' ";

}

if (intval ( $end ) > 0) {

$sql .= " and addtime}

if ($bool) {

$sql .= " and lotteryid>0 ";

}

if (intval ( $uid ) > 0) {

$sql .= " and uid='$uid' ";

}

return intval ( DB::result_first ( $sql ) );

}

/**

* 合計(jì)獎(jiǎng)品數(shù)

* @param intval $uid

* @param intval $start

* @param intval $end

* @param intval $bool 獎(jiǎng)品id

* @return number

*/

private function get_lottery_id($uid = 0, $start = 0, $end = 0, $lotteryid = 0) {

$sql = "select count(*) m from " . DB::table ( $this->lottery_log );

$sql .= " where 1 ";

if (intval ( $start ) > 0) {

$sql .= " and addtime>='$start' ";

}

if (intval ( $end ) > 0) {

$sql .= " and addtime}

if ($lotteryid>=0) {

$sql .= " and lotteryid='$lotteryid' ";

}

if (intval ( $uid ) > 0) {

$sql .= " and uid='$uid' ";

}

return intval ( DB::result_first ( $sql ) );

}

/**

* 獲取用戶來(lái)福幣

* @param intval $uid

* @return number

*/

public function get_user_lfb($uid) {

$sql = "select extcredits2 from sz_common_member_count ";

$sql .= " where 1 ";

$sql .= " and uid='$uid' ";

return intval ( DB::result_first ( $sql ) );

}

/**

* 記錄日志和更新用戶來(lái)福幣

* @param intval $uid

* @param intval $r 返回值

* @param intval $logid

* @param intval $lotteryid

*/

private function credit($uid, $result, $logid = 0, $lotteryid = 0,$hao=0) {

$data = array();

if ($lotteryid > 0) {

$data ['lotteryid'] = $lotteryid;

$data ['iswinning'] = 1;

}

$data ['result'] = $result;

$data ['hao'] = $hao;

$data ['HTTP_REFERER'] = $_SERVER['HTTP_REFERER'];

DB::Update ( $this->lottery_log, $data, " logid='$logid' " );

if (L_LFB > 0) {

$sql = 'UPDATE sz_common_member_count SET extcredits2=extcredits2-' . L_LFB . ' WHERE uid=' . $uid;

DB::query ( $sql );

$this->credit_log ( $uid, 'reduce', L_LFB, 1, '積分清零活動(dòng)' );

}

}

/**

*手機(jī)號(hào)檢查

*/

private function check_tel($tel){

$different_network=table_sub::get_different_network();

if (!preg_match("/$different_network/",$tel)) {

return false;

}

return true;

}

/**

* 存儲(chǔ)過(guò)程鏈接

*/

private $StoreProcs;

/**

* 來(lái)福幣日志 存儲(chǔ)過(guò)程

* @param intval $uid

* @param string $op add增加 reduce 消耗

* @param intval $creditvalue 來(lái)福幣

* @param intval $credittype 1來(lái)福幣 2來(lái)福點(diǎn)

* @param string $oreason 說(shuō)明

*/

private function credit_log($uid, $op, $creditvalue, $credittype, $oreason) {

if (! $this->StoreProcs) {

$this->StoreProcs = new StoreProcs ();

}

//調(diào)用存儲(chǔ)過(guò)程

$this->StoreProcs->query ( "call app_credit_log($uid,'$op','$credittype',1,$creditvalue,'$oreason')" );

}

}

總結(jié)

以上是生活随笔為你收集整理的PHP 每小时抽奖,php分时间段的抽奖程序代码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。