目錄
报名成功!
首頁 php教程 php手册 项目2:PHP抽奖程序 ,抽奖规则代码

项目2:PHP抽奖程序 ,抽奖规则代码

Jun 06, 2016 pm 07:41 PM
php 程式碼 抽獎 時間 程式 規則 專案

项目4 抽奖程序 分时间段(按时段设置的奖品数为概率)http://blog.csdn.net/wljk506/article/details/7174151 ================================= 项目3 抽奖程序 分时间段http://blog.csdn.net/wljk506/article/details/7105347 ===========================

项目4 抽奖程序 分时间段(按时段设置的奖品数为概率)http://blog.csdn.net/wljk506/article/details/7174151

=================================

项目3 抽奖程序 分时间段http://blog.csdn.net/wljk506/article/details/7105347

==========================================

项目2 抽奖程序

============================================

activity_lyq_lottery	奖品表
lotteryid	
name	礼品名称
sum	礼品总数
time_start	开始时间
time_end	结束时间
addtime	时间
probability	中奖概率
isdisable	是否开启
listorder	排序
time_1	时间段个数限制
time_2	
time_3	
time_4	
time_5	
time_6	
time_7	
msg	发送短信或显示信息
content	备注
angle	转盘角度
	
activity_lyq_lottery_log	抽奖日志
logid	ID
uid	用户ID
tel	手机号
addtime	抽奖时间
ip	抽奖IP
lotteryid	奖品ID
iswinning	是否抽中
result	返状态回值
hao	随机号
登入後複製

主程序:
<?php require_once (APP_ROOT . "./class/class_lib.php");
require_once libfile ( &#39;class/StoreProcs&#39; );
/**
 * 大转盘
 * @author Administrator
 *
 */
class lib_dzp_lottery extends app_lib {
	/**
	 * 奖品表
	 */
	public $lottery = &#39;activity_lyq_lottery&#39;;
	/**
	 * 奖品日志表
	 */
	public $lottery_log = &#39;activity_lyq_lottery_log&#39;;
	/**
	 * n等奖品
	 */
	private $level = array();
	/**
	 * 奖品信息
	 */
	private $lotteryArray = array();
	/***
	 * 随机数结束位数
	 */
	private $max = 30000;
	
	/**
	 * 读取配置
	 */
	public function load_setting() {
		$data=getcache(&#39;lyqdzp_setting&#39;);
		define(&#39;TIME&#39;, time());									//当前时间
		define(&#39;L_START&#39;, strtotime($data[&#39;l_start&#39;]));			//报名开始时间
		define(&#39;L_END&#39;, strtotime($data[&#39;l_end&#39;]));				//报名结束时间,-1意思昨天 23:59:59
		define(&#39;L_DAY_START&#39;,$data[&#39;l_day_start&#39;]);				//每天开始时间
		define(&#39;L_DAY_END&#39;, $data[&#39;l_day_end&#39;]);				//每天结束时间
		define(&#39;L_DAY_CISHU&#39;, $data[&#39;l_day_cishu&#39;]);			//每天获得奖品次数
		define(&#39;L_MIN&#39;, 20);									//最少来福币
		define(&#39;L_LFB&#39;, $data[&#39;l_lfb&#39;]);						//减少来福币
		define(&#39;L_ZY&#39;, $data[&#39;l_zy&#39;]);							//专业户
		define(&#39;L_QUANSHU&#39;, $data[&#39;l_quanshu&#39;]);				//圈数,大转盘开始圈数
		$host=&#39;www.*****.com&#39;;								//现网
		if($_SERVER[&#39;HTTP_HOST&#39;]==&#39;test.com&#39;){
			$host=&#39;test.com&#39;;						//测试机
		}elseif($_SERVER[&#39;HTTP_HOST&#39;]==&#39;125life.com&#39;){
			$host=&#39;125life.com&#39;;								//本地
		}
		define(&#39;L_SITE&#39;, &#39;http://&#39;.$host.&#39;/&#39;);					//域名最后加/
		define(&#39;L_URL&#39;, L_SITE.&#39;index.php&#39;);	//访问地址
	}
	/**
	 * 黑名单
	 */
	private $heimingdan = array();
	/**
	 * 读取奖品配置
	 */
	public function load() {
		$this->setlottery ();
		$this->heimingdan = getcache ( 'tel', 'blanklist' );
	}
	private function setlottery() {
		$sql = "select u.*";
		$sql .= ", (select COUNT(l.lotteryid)  from  " . DB::table ( $this->lottery_log ) . " AS l where u.lotteryid=l.lotteryid and l.iswinning='1')as num ";
		$sql .= " from " . DB::table ( $this->lottery ) . " AS u ";
		$sql .= " where 1 ";
		$sql .= " and u.isdisable='0' ";
		$sql .= " and u.time_start'" . TIME . "' ";
		$sql .= " ORDER BY u.listorder ";
		$d = DB::fetch_all ( $sql );
		//print_r($d);
		$sum = 0;
		foreach ( $d as $r ) {
			$r ['sum_over'] = intval ( $r ['sum'] ) - intval ( $r ['num'] );
			if ($r ['sum_over'] > 0) {
				$sum += $r ['sum_over'];
			}
			$r['msg']=str_replace('{name}', $r['name'],$r['msg']);
			$this->lotteryArray [$r ['lotteryid']] = $r;
		}
		$m = 1;
		$probability = 0;
		$newsum=0;
		$arr = array();
		//20%空奖+80%奖
		$this->max = $sum + $sum * 0.2 / 0.8;
		foreach ( $this->lotteryArray as $r ) {
			if ($r ['sum_over'] > 0) {
				$newsum=$r ['sum_over'];
				if($r['probability']>0){
					$probability=0;
					$probability=ceil($r ['sum']*100/$r['probability']);
					if($probability>0){
						$newsum=$probability;
					}
				}
				$this->level [$r ['lotteryid']] ['start'] = $m;
				$this->level [$r ['lotteryid']] ['end'] = $m + $newsum;
				$m = $m + $r ['sum_over'];
			}
		}
		unset ( $arr );
	}
	/**
	 * 检测用户是否中奖 0 谢谢参与,其他 返回奖品data数据
	 * @param array $user array(uid,tel,ip)
	 */
	public function check($user) {
		if (intval ( $user ['uid'] ) intval(L_END)){
			//已经过了活动时间,非常遗憾,谢谢!
			return -22;
		}
		$hour= date('H');
		if($hour<intval>intval(L_DAY_END)){
			//对不起,现在不是活动时间,活动时间为每天'.L_DAY_START.':00-'.L_DAY_END.':00'
			return -23;
		}
		$data = array(
				'uid' => $user ['uid'],
				'tel' => $user ['tel'],
				'ip' => $user ['ip'],
				'addtime' => time ()
		);
		$logid = DB::insert ( $this->lottery_log, $data, true );

		if ($this->get_user_lfb ( $user ['uid'] ) credit ( $user ['uid'], -11, $logid );
			return -11; //您的来福币余额不足
		}
		//检查用户已中奖品数
		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 );
			//很遗憾,你本次什么也没有抽到!
			return -12;
		}
		//检测黑名单,设置概率
		if ($this->checkhei ( $user ['tel'] ) > 0) {
			$this->credit ( $user ['uid'], -13, $logid );
			//很遗憾,你本次什么也没有抽到!
			return -13;
		}
		$lotteryid = $this->choujiang();
		$this->credit ( $user ['uid'], $lotteryidhao);
		if ($lotteryid > 0) {
			return $this->lotteryArray [$lotteryid];
		} else {
			return -4;
		}
		//-1奖品已发完
		//-2本时段奖品已玩
		//-3不发奖品
		//-4奖品有问题
		//-11您的来福币余额不足
		//-12很遗憾,你本次什么也没有抽到!
		//-13黑名单里面,很遗憾,你本次什么也没有抽到!
		//-21您来早了,活动还没有开始!
		//-22已经过了活动时间,非常遗憾,谢谢!
		//-23对不起,现在不是活动时间,活动时间为每天
	}
	/**
	 * 显示
	 * @param unknown_type $data
	 */
	public function show($data){
		$ok=0;//3中奖
		$zz=0;//转盘度数
		$result='';//奖品名称
		if(is_array($data)){
			$ok=3;
			$result=$data['msg'];
			$zz=$data['angle'];
		}else{
			$m='';
			switch($data){
				case 0:{
					$m= '请先登录!';
				}break;
				case -11:{
					$m= '您的来福币余额不足!';
				}break;
				case -12:{
					$m= '很遗憾,你本次什么也没有抽到!';
				}break;
				case -21:{
					$m= '您来早了,活动还没有开始!';
				}break;
				case -22:{
					$m= '已经过了活动时间,非常遗憾,谢谢!';
				}break;
				case -23:{
					$m= '对不起,现在不是活动时间,活动时间为每天'.L_DAY_START.':00-'.L_DAY_END.':00';
				}break;
				default:{
					$m= '很遗憾,你本次什么也没有抽到!';
				}break;
			}
			$result=$m;
			$ok=3;//3中奖
			//再接再厉
			$suiji=array(
					0=>120,
					1=>240,
					2=>360,
					3=>120,
					4=>240,
					5=>360
			);
			$zz=$suiji[intval(mt_rand ( 0,5))];//再接再厉
		}
		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");
		echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
		echo '<gift>'."\n";
		echo '<shift ok="'.$ok.'" zz="'.$zz.'" add="9" down="0" lid="0" result="'.$result.'"></shift>'."\n";
		echo '</gift>'."\n";
	}
	/**
	 * 抽奖的号
	 */
	private $hao=0;
	/**
	 * 抽奖开始
	 */
	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) {
				$lotteryid = $k;
				break;
			}
		}
		$d = array(
			1 => array(
				'time' => strtotime ( date ( 'Y-m-d 00:00:00', TIME ) ), 
				'time_end' => strtotime ( date ( 'Y-m-d 01:59:59' ) ) 
			), 
			2 => array(
				'time' => strtotime ( date ( 'Y-m-d 02:00:00', TIME ) ), 
				'time_end' => strtotime ( date ( 'Y-m-d 03:59:59' ) ) 
			), 
			3 => array(
				'time' => strtotime ( date ( 'Y-m-d 04:00:00', TIME ) ), 
				'time_end' => strtotime ( date ( 'Y-m-d 08:59:59' ) ) 
			), 
			4 => array(
				'time' => strtotime ( date ( 'Y-m-d 09:00:00', TIME ) ), 
				'time_end' => strtotime ( date ( 'Y-m-d 11:59:59' ) ) 
			), 
			5 => array(
				'time' => strtotime ( date ( 'Y-m-d 12:00:00', TIME ) ), 
				'time_end' => strtotime ( date ( 'Y-m-d 17:59:59' ) ) 
			), 
			6 => array(
				'time' => strtotime ( date ( 'Y-m-d 18:00:00', TIME ) ), 
				'time_end' => strtotime ( date ( 'Y-m-d 19:59:59' ) ) 
			), 
			7 => array(
				'time' => strtotime ( date ( 'Y-m-d 20:00:00', TIME ) ), 
				'time_end' => strtotime ( date ( 'Y-m-d 23:59:59' ) ) 
			) 
		);
		if($lotteryid>0){
			$l=$this->lotteryArray [$lotteryid];
			if($l['sum_over']>0){
				//本时段 奖品数
				$sum=0;
				foreach ($d as $k=>$r){
					if(TIME>=$r['time']&&TIME'.$k;
						if($l['time_'.$k]>0){//个数限制
							$sum=$this->get_lottery_id(0,$r['time'],$r['time_end']+1,$lotteryid);
							if($sum>=$l['time_'.$k]){
								//本时段奖品已玩
								$lotteryid=-2;
								break;
							}
						}elseif ($l['time_'.$k]==0){
							//不发奖品
							$lotteryid=-3;
							break;
						}else{
							//-1 不限制
						}
						
					}
				}
			}else{
				//奖品已发完
				$lotteryid=-1;
			}
		}else{
			//奖品有问题
			$lotteryid=-4;
		}
		return $lotteryid;
	
	}
	/**
	 * 检测黑名单和普通用户,概率
	 * @param string $tel
	 * @return 大于1 表示本次禁止抽
	 */
	private function checkhei($tel) {
		$n = mt_rand ( 1, 100 );
		if (in_array ( $tel, $this->heimingdan ['tel'] ) && L_ZY > 0) {
			if ($n > L_ZY) {
				return 1;
			}
		}else{
			if ($n lottery_log );
		$sql .= " where 1 ";
		if (intval ( $start ) > 0) {
			$sql .= " and addtime>='$start' ";
		}
		if (intval ( $end ) > 0) {
			$sql .= " and addtime0 ";
		}
		if (intval ( $uid ) > 0) {
			$sql .= " and uid='$uid' ";
		}
		return intval ( DB::result_first ( $sql ) );
	}
	/**
	 * 合计奖品数
	 * @param intval $uid
	 * @param intval $start
	 * @param intval $end
	 * @param intval $bool 奖品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=0) {
			$sql .= " and lotteryid='$lotteryid' ";
		}
		if (intval ( $uid ) > 0) {
			$sql .= " and uid='$uid' ";
		}
		return intval ( DB::result_first ( $sql ) );
	}
	/**
	 * 获取用户来福币
	 * @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 ) );
	}
	/**
	 * 记录日志和更新用户来福币
	 * @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;
		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, '积分清零活动' );
		}
	}
	/**
	 * 存储过程链接
	 */
	private $StoreProcs;
	/**
	 * 来福币日志 存储过程
	 * @param intval $uid
	 * @param string $op add增加  reduce 消耗
	 * @param intval $creditvalue 来福币
	 * @param intval $credittype 1来福币 2来福点
	 * @param string $oreason  说明
	 */
	private function credit_log($uid, $op, $creditvalue, $credittype, $oreason) {
		if (! $this->StoreProcs) {
			$this->StoreProcs = new StoreProcs ();
		}
		//调用存储过程
		$this->StoreProcs->query ( "call app_credit_log($uid,'$op','$credittype',1,$creditvalue,'$oreason')" );
	}

}</intval>
登入後複製





====================================================================

以下部分有点错误,项目1抽奖程序

===================================================================================================================


做了一个抽奖的小项目,是DX的模块,发出来做个备份

数据库先.

app_qiuxie_log	访问日志	
logid	ID	
uid	用户ID	
tel	手机号	
host	网址名称	
url	来源页地址	
addtime	时间	
ip	IP	
type	类型	0默认1.www.****.com/a/autumncrab/统计来源
		
app_qiuxie_lottery_log	抽奖日志	
logid	ID	
uid	用户ID	
tel	手机号	
addtime	抽奖时间	
ip	抽奖IP	
lotteryid	奖品ID	
iswinning	是否抽中	1抽中0无
isdisable	是否禁用	1禁用0允许
disablecontent	禁用理由	
isedit	是否已修改过	0无1已修改
orderid	订单ID号	用于充值订单号
money	金额	充值金额
recharge_time	充值时间	
isout	超时	0无1超时
ismenpiao	门票	0无1是
ispay	是否支付	0无1已经支付成功
		
		
app_qiuxie_lottery	奖项设置	
lotteryid	id	
name	名称	
minute	分钟	默认60分钟放出
num	数量	放出多少个
sum	总数	奖品总数
start_time	开始时间	
end_time	结束时间	
togetherlast	上次一起	上次如果没中,是否和本次一起放出,1一起,0否
probability	中奖概率	默认1%
isopen	开启	1开启0关闭
addtime	添加时间	
listorder	排序	正序
isrepeat	是否重复中奖	0是1否
ismenpiao	门票	0无1是
		
app_qiuxie_pay_log	支付日志表	
logid	ID	
notify_id	支付宝订单ID	
out_trade_no	支付订单ID	
trade_no		
total_fee	金额	
trade_status	成功标志	
sign	密钥	
query	查询字符串	
uid	用户ID	
tel	手机号	
ip	IP	
addtime	时间	
登入後複製

ctl_qiuxie_index.php 
登入後複製
<?php /*
* by 夜色紫宸風 2011-10-25
*/
include_once DISCUZ_ROOT.&#39;source/app/qiuxie/cache.class.php&#39;;
class qiuxie_index extends app_mod{
        function init(){
            $this->lib('lib_qiuxie');
            $this->lib('lib_qiuxie_lottery');
            $c=qgetcache('qiuxie_setting');
            define('QIUXIE_TIME', time());							//当前时间
            define('QIUXIE_BM_STAR', strtotime($c['bm_start']));	//报名开始时间
            define('QIUXIE_BM_END', strtotime($c['bm_end']));		//报名结束时间,-1意思昨天 23:59:59
            define('QIUXIE_CJ_STAR', strtotime($c['cj_start']));	//抽奖开始时间
            define('QIUXIE_CJ_END', strtotime($c['cj_end']));		//抽奖结束时间,-1意思昨天 23:59:59
            $host='www.*****.com';								//现网
            if($_SERVER['HTTP_HOST']=='http://test.com'){
            	$host='http://test.com';						//测试机
            }elseif($_SERVER['HTTP_HOST']=='125life.com'){
            	$host='125life.com';								//本地
            }
            define('QIUXIE_URL', 'http://'.$host.'/');				//域名最后加 /
            define('QIUXIE_LFB',$c['lfb']);							//赚取来福币数
            define('QIUXIE_CJ_CISHU', $c['cishu']);					//抽奖次数
            define('QIUXIE_CJ_Probability', 3);						//抽奖概率=报名人数*3倍数
            define('QIUXIE_RECHARGE', $c['recharge']);				//中奖后3小时内充值
            define('QIUXIE_MONEY', $c['money']);					//充值金额
            
        }
        /**
         * 主页
         * @see app_mod::on_index()
         */
        public function on_index(){
        	global $_G;
            $data=array();
            //第几栏
            $data['style']['1'] = 1;//2背景白色1背景咖啡
            $data['style']['2'] = 2;
            $data['style']['3'] = 2;
            $data['style']['4'] = 2;
            $data['style']['5'] = 2;
            //检测用户是否已登录
            if(intval($_G['uid'])>0){
            	//检测报名
            	$data['user']=$this->qiuxie->user($_G['uid']);
            }
            
            //获取用户来福币
            $data['user']['sum']=$this->qiuxie->user_lfb($_G['uid'],QIUXIE_BM_STAR,QIUXIE_BM_END);
            //时间规则判断设置进度
            if(QIUXIE_TIME<qiuxie_bm_star>QIUXIE_BM_STAR&&QIUXIE_TIME<qiuxie_bm_end if>QIUXIE_BM_END&&QIUXIE_TIME<qiuxie_cj_star>qiuxie_lottery->getuserwinningqiuxie($_G ['uid'],true);
            	
            }elseif(QIUXIE_TIME>QIUXIE_CJ_STAR&&QIUXIE_TIME<qiuxie_cj_end>qiuxie_lottery->getuserwinningqiuxie($_G ['uid'],true);
            	
            }else{															//step5参加蟹宴
            	$data['style']['1'] = 2;
            	$data['style']['2'] = 2;
            	$data['style']['5'] = 1;
            }
            //用户已抽奖次数
            $data['user']['lottery']=$this->qiuxie_lottery->getusercount(intval($_G['uid']));

            //用户剩余次数
            $data['user']['lottery_over']=QIUXIE_CJ_CISHU-$data['user']['lottery'];
            if($data['user']['lottery_over']qiuxie_lottery->getuserwinningqiuxie($_G ['uid'],true,2);
            //截止小时
            foreach ($data['winning'] as $k=>$r){
            	if($r['isout']==1){
            		continue;
            	}
            	if($r['ispay']qiuxie_lottery->alipay_url(date('YmdHis',QIUXIE_TIME).'-'.$r['logid'],
	            		$r['name'].'1张押金'.QIUXIE_MONEY.'元',
	            		$r['logid']);
	            	}
            	}
            	$data['winning'][$k]=$r;
            	break;
            }
			
			
            
            //访问日志
            $this->qiuxie->log(array('uid'=>$_G['uid'],'tel'=>$_G['tel'],'ip'=>$_G['clientip']));
            
            $this->view('qiuxie/index',$data);
        }
        public function on_chouzhong(){
        	global $_G;
        	print_r($_G);
        	
        	if ($_G ['uid']) {
        		$data=$this->qiuxie_lottery->getuserwinningqiuxie($_G ['uid'],true);
        		print_r($data);
        	}else{
        		$param=array ();
	        	$extra=array (
	        	'showmsg' => true ,
	        	'closetime'=>3,
	        	);
        		showmessage ( '请先登录!',$forward, $param,$extra);
        	}
        }
        /**
         * 报名
         */
        public function on_baoming(){
        	global $_G;
        	
        	$forward=QIUXIE_URL.'index.php?dir=qiuxie';

        	if ($_G ['uid']) {
        		
        		if(intval(QIUXIE_TIME)<intval>2, 
		        	'showmsg' => true ,
		        	'timeout'=>3,
		        	'refreshtime'=>3,
		        	);
					showmessage ( $msg,'', $param, $extra);
        		}
        		if(intval(QIUXIE_TIME)>intval(QIUXIE_BM_END)){
        			$msg= ' 已经过了报名时间,非常遗憾,谢谢!';
        			$param=array ();
		        	$extra=array ('msgtype' =>2, 
		        	'showmsg' => true ,
		        	'timeout'=>true,
		        	'refreshtime'=>3,
		        	);
					showmessage ( $msg,'', $param, $extra);
        		}
        		$user=$this->qiuxie->user($_G['uid']);
        		if(intval($user['uid'])>0){
        			$msg= '您已经报名过了!<br>';
        			$msg.='手机号为 '.$user['tel'];
        			$msg.=' 的用户<br>在 '.date('Y-m-d H:i:s',$user['addtime']);
        			$mag.=' 报名';
        			$param=array ('locationtime'=>3);
		        	$extra=array ('msgtype' =>2, 
		        	'showmsg' => true ,
		        	'timeout'=>3,
		        	'refreshtime'=>3,
		        	'locationtime'=>3,
		        	);
					showmessage ( $msg,'', $param, $extra);
        		}else{
					$this->qiuxie->user_add(array('uid'=>$_G['uid'],'tel'=>$_G['tel'],'ip'=>$_G['clientip']));
					$msg='提示信息:<br><h2 id="报名成功">报名成功!</h2>';
					$msg.='<script type="text/javascript">&#39;;
		        	$msg.=&#39;setTimeout("window.location.href=\&#39;&#39;.$forward.&#39;\&#39;", 3000);&#39;;
		        	//$msg.=&#39;setTimeout("hideWindow(\&#39;baoming\&#39;)", 4000);&#39;;
		        	$msg.=&#39;</script>';
        			showmessage ($msg,$forward, '','',1);
        		}
        	}else{
        		$param=array ();
	        	$extra=array (
	        	'showmsg' => true ,
	        	'closetime'=>3,
	        	);
        		showmessage ( '请先登录!',$forward, $param,$extra);
        	}
        	exit;
        }
        /**
         * 
         */
        public function on_choujiang(){
        	global $_G;
        	
        	$forward=QIUXIE_URL.'index.php?dir=qiuxie';
        	if ($_G ['uid']) {
        		
        		if(intval(QIUXIE_TIME)<intval>2, 
		        	'showmsg' => true ,
		        	'timeout'=>3,
		        	'refreshtime'=>3,
		        	);
					showmessage ( $msg,'', $param, $extra);
        		}
        		if(intval(QIUXIE_TIME)>intval(QIUXIE_CJ_END)){
        			$msg= ' 已经过了抽奖时间,非常遗憾,谢谢!';
        			$param=array ();
		        	$extra=array ('msgtype' =>2, 
		        	'showmsg' => true ,
		        	'timeout'=>true,
		        	'refreshtime'=>3,
		        	);
					showmessage ( $msg,'', $param, $extra);
        		}
        		$lfb=$this->qiuxie->user_lfb($_G['uid'],QIUXIE_BM_STAR,QIUXIE_BM_END);
        		if($lfb<intval>2, 
		        	'showmsg' => true ,
		        	'timeout'=>true,
		        	'refreshtime'=>3,
		        	);
					showmessage ( $msg,'', $param, $extra);
        		}
        		//用户已抽奖次数
            	$sum=$this->qiuxie_lottery->getusercount(intval($_G['uid']));
				if(QIUXIE_CJ_CISHU-$sum2, 
		        	'showmsg' => true ,
		        	'timeout'=>true,
		        	'refreshtime'=>3,
		        	);
					showmessage ( $msg,'', $param, $extra);
				}

        		$user=$this->qiuxie->user($_G['uid']);
        		if(intval($user['uid'])>0){
        			$this->qiuxie_lottery->setting(QIUXIE_TIME,QIUXIE_CJ_STAR,QIUXIE_CJ_END);
        			$data=$this->qiuxie_lottery->checklevel(array('uid'=>$_G['uid'],'tel'=>$_G['tel'],'ip'=>$_G['clientip']));
        			
        			$sum=QIUXIE_CJ_CISHU-$sum-1;
        			if($sum<h2 style="color:red;font-size:20px;">';
					if(is_array($data)){
						$msg.='恭喜您,中奖了,';
						$msg.=$data['name'].'1张 ,<br>';
						if(strpos($data['name'],'门票')){
							$msg.='不要忘记支付押金哦!';
						}
						$msg.='<br>您还有 '.$sum.'次抽奖机会!';
					}else{
						$msg.='您没有中奖,再接再厉!';
					}
					$msg.='</h2>';
					$msg.='<script type="text/javascript">&#39;;
		        	$msg.=&#39;setTimeout("window.location.href=\&#39;&#39;.$forward.&#39;\&#39;", 3000);&#39;;
		        	//$msg.=&#39;setTimeout("hideWindow(\&#39;baoming\&#39;)", 4000);&#39;;
		        	$msg.=&#39;</script>';
        			showmessage ($msg,$forward, '','',1);
        			
        		}else{
					$msg= '您还没报名!';
        			$param=array ('locationtime'=>3);
		        	$extra=array ('msgtype' =>2, 
		        	'showmsg' => true ,
		        	'timeout'=>3,
		        	'refreshtime'=>3,
		        	'locationtime'=>3,
		        	);
					showmessage ( $msg,'', $param, $extra);
        		}
        	}else{
        		$param=array ();
	        	$extra=array (
	        	'showmsg' => true ,
	        	'closetime'=>3,
	        	);
        		showmessage ( '请先登录!',$forward, $param,$extra);
        	}
        	exit;
        }
    	/**
         * 书签
         * 发送短信到书签
         */
        public function on_shuqian(){
        	global $_G;
        	
        	$forward=QIUXIE_URL.'index.php?dir=qiuxie';
        	$param=array ();
	        $extra=array (
	        	'showmsg' => true ,
	        	'closetime'=>3,
	        );
	        $msg='请先登录!';
        	if ($_G ['uid']) {
        		if($_G ['tel']){
        			
        			$content='G3手机免费送啦!即刻下载快捷书签访问****,天天免费送彩票,G3手机、肯德基现金券、话费等你拿!';
        			$content.='地址:http://wap.*****.cn/index?lanmu=00260009';
        			
        			app_ctl::fun('sms');
					send_sms_first(trim($_G ['tel']),$content,2);
					
        			$msg='信息已经发送,你将在1分钟内收到短信息!';
        		}else{
        			$msg='手机号错误,请联系管理员!';
        		}
        		
        	}else{
        		
        	}
        	showmessage ( $msg,$forward, $param,$extra);
        }
		/**
         * 规则
         * @see app_mod::on_guize()
         */
        public function on_guize(){
            $this->view('qiuxie/guize');
        }
        /**
         * 支付返回数据
         */
        public function on_zhifu(){
        	global $_G;

        	$forward=QIUXIE_URL.'index.php?dir=qiuxie';
        	//记录日志
        	$this->qiuxie_lottery->paylog(array('uid'=>intval($_G['uid']),'tel'=>trim($_G['tel']),'ip'=>$_G['clientip']));
        	//使用团购的支付类
        	include_once DISCUZ_ROOT.'./buy/include/library/AlipayNotify.class.php';
        	list($ec_contract, $ec_securitycode, $ec_partner, $ec_creditdirectpay) =
        	 explode("\t", authcode($_G['setting']['ec_contract'], 'DECODE', $_G['config']['security']['authkey']));
        	
			unset($_GET['dir'],$_GET['do']);
			$alipay = new AlipayNotify($ec_partner,$ec_securitycode,'MD5','utf-8');
			$verify_result = $alipay->return_verify();
			if ( $verify_result ) {
				if($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS') {
					$out_trade_no = trim($_GET['out_trade_no']);   //获取订单号
					$total_fee  = intval($_GET['total_fee']);      //获取总价格  
					$this->qiuxie_lottery->updatelotterylogpay($out_trade_no,$total_fee);
					if($_G['uid']>0){
						$this->qiuxie->updateusermoney($_G['uid'],$total_fee);
					}
					$msg='提示信息:<br><h2 style="color:red;font-size:20px;">';
					$msg.='支付成功!';
					$msg.='</h2>';
					$msg.='<br>3秒后跳转';
					$msg.='<script type="text/javascript">&#39;;
		        	$msg.=&#39;setTimeout("window.location.href=\&#39;&#39;.$forward.&#39;\&#39;", 3000);&#39;;
		        	//$msg.=&#39;setTimeout("hideWindow(\&#39;baoming\&#39;)", 4000);&#39;;
		        	$msg.=&#39;</script>';
        			showmessage ($msg,$forward, '','',1);
				}
			}
			
			$param=array ();
	        	$extra=array (
	        	'showmsg' => true ,
	        	'closetime'=>3,
	        	);
        	showmessage ( '错误!',$forward, $param,$extra);
        }
    }
	?></intval></intval></intval></qiuxie_cj_end></qiuxie_cj_star></qiuxie_bm_end></qiuxie_bm_star>
登入後複製

lib_qiuxie_lottery.php

<?php /*
* by 夜色紫宸風 2011-10-25
*/
require_once(APP_ROOT."./class/class_lib.php");
class lib_qiuxie_lottery extends app_lib{
	/**
	 * 抽奖次数
	 */
	private $num=0;
	/**
	 * n等奖品
	 */
	private $level=array();
	/**
	 * 奖品信息
	 */
	private $lottery=array();
	/**
	 * 抽奖开始时间
	 */
	private $lottery_star=&#39;2011-10-25&#39;;
	/**
	 * 抽奖结束时间
	 */
	private $lottery_end =&#39;2011-10-27&#39;;
	/**
	 * 现在时间
	 */
	private $time= 0;
	/**
	 * 奖项
	 */
	private $qx_lottery="app_qiuxie_lottery";
	/**
	 * 获奖日志
	 */
	private $qx_lottery_log="app_qiuxie_lottery_log";
	/**
    	 * 秋蟹报名表
    	 */
	public $qx_user=&#39;app_qiuxie_user&#39;;
	/**随机数开始数
	 */
	private $min=1;
	/***
	 * 随机数结束位数
	 */
	private $max=100;
	/**
	 * 本次发放奖品总数
	 */
	private $sum=0;

	function __construct(){
		$this->setout();
    }
	public function setting($time,$star,$end){
		$this->lottery_star =$star;
		$this->lottery_end =$end;
		$this->time=$time;
		$this->setout();
		$this->setlottery();
		$this->setlevel();
	}
	/**
	 * 读取奖品信息
	 */
	private function setlottery(){
		$sql="SELECT * ";
		$sql.=" ,(select ifnull(lotteryid,0) from ".DB::table($this->qx_lottery)." where isrepeat='0' and isopen='1' ORDER BY listorder limit 0,1 ) as repeatid";
		$sql.=" ,(select l.sum-ifnull(count(*),0) from ".DB::table($this->qx_lottery_log)." where 1 and addtimetime."' and isdisable='0' and lotteryid=l.lotteryid and isout='0'  ) as sum_over";
		$sql.=" FROM ".DB::table($this->qx_lottery)." as l ";
		$sql.=" WHERE isopen='1' ORDER BY listorder ";
		$data = DB::fetch_all($sql);
		foreach ($data as $r){
			$k=$r['lotteryid'];
			//总剩余
			//$r['sum_over']=$r['sum']-$this->getlotterycount(0,$this->time, $r['lotteryid']);
			if($r['sum_over']timetime>$r['end_time']){
				continue;
			}

			//存在自定义时间
			if($r['minute']>0){
				//算出间隔时间
				$r['interval_time']=$r['minute']*60;
				//几个 时间短内发放
				$r['interval_time_num']=floor(($r['end_time']-$r['start_time'])/$r['interval_time']);
			}else{
				//算出间隔时间
				$r['interval_time']=ceil(($r['end_time']-$r['start_time'])/$r['sum']);
				//几个 时间短内发放
				$r['interval_time_num']=floor(($r['end_time']-$r['start_time'])/$r['interval_time']);
			}
			//存在 自定义 数量
			if($r['num']>0){
				//每次间隔,发放几个
				$r['interval_num']=$r['num'];
				//发放几次
				$r['interval_count']=floor($r['sum']/$r['interval_num']);
			}else{
				//每次间隔,发放几个
				$r['interval_num']=floor($r['sum']/$r['interval_time_num']);
				//发放几次
				$r['interval_count']=$r['interval_time_num'];
			}
			
			//本次属于第几次
			$r['this_num']=1;
			for($i=0;$i$this->time){
					$r['this_num']=$i;
					break;
				}
			}
			
			//本次开始时间
			$r['this_time_star']=$r['start_time']+$r['this_num']*$r['interval_time']+1;
			//本次结束时间
			$r['this_time_end']=$r['start_time']+($r['this_num']+1)*$r['interval_time'];
			if($r['this_num']>1){
				//本次开始时间以前已经 获奖数 合计
				$r['this_time_star_lastcount']=$this->getlotterycount(0,$r['this_time_star'], $r['lotteryid']);
				//以前是否还有没有中奖的数
				$r['this_time_star_lastcount_over']=($r['this_num']-1)*$r['interval_num']-$r['this_time_star_lastcount'];
			}else{
				$r['this_time_star_lastcount']=0;
				$r['this_time_star_lastcount_over']=0;
			}

			//本次时间内已经获奖数
			$r['this_time_count']=$this->getlotterycount($r['this_time_star'],$r['this_time_end'], $r['lotteryid']);
			//本次时间内还有多少个
			$r['this_time_count_over']=$r['this_num']*$r['interval_num']-$r['this_time_count'];
		
			$this->lottery[$k]=$r;
			
			//本次奖品总数
			$this->sum +=$r['interval_num']>0?$r['interval_num']:0;
//			echo '间隔时间:'.ceil(($r['end_time']-$r['start_time'])/$r['sum']);
//			echo " 间隔时间次数:";
//			echo floor(($r['end_time']-$r['start_time'])/$r['interval_time']);
//			echo " 每次间隔时间发放个数:";
//			echo floor($r['sum']/$r['interval_time_num']);
//			echo "\n";
			
		}
		//计算出奖品概率,如果不存在,默认20%
		if(defined('QIUXIE_CJ_Probability')){
			$sum=$this->getbaoming();
			if($sumgetlottery();
			if($sum21) $sum3=1;
			$this->max=$this->sum/$sum3;
			
		}else{
			$this->max=$this->sum/0.2;
		}
	}
	/**
	 * 设置奖项标志位
	 */
	private function setlevel(){
		$max=$this->max;
		//上次如果没中,是否和本次一起放出,1一起,0否
		foreach ($this->lottery as $k=>$r){
			if($r['togetherlast']==1&&$r['this_time_star_lastcount_over']>0){
				$max+=$r['this_time_star_lastcount_over'];
			}
		}
		$min=$this->min;
		$this->max=$max;
		foreach ($this->lottery as $k=>$r){
			if($r['sum_over']level));
				$this->level[$k][]=$j;
			}
			//上次如果没中,是否和本次一起放出,1一起,0否
			if($r['togetherlast']==1&&$r['this_time_star_lastcount_over']>0){
				for($i=1;$ilevel));
					$this->level[$k][]=$j;
				}
			}
			
		}
	}
	/**
	 * 检测用户是否中奖 0 谢谢参与,其他 返回奖品data数据
	 * @param array $user array(uid,tel,ip)
	 */
	public  function checklevel($user){
		if(intval($user['uid'])getuserwinningqiuxie($user['uid'],true);
		foreach ($tmp as $r){
			$winning[]=$r['lotteryid'];
		}
		
    	$data=array(
    		'uid'=>$user['uid'],
    		'tel'=>$user['tel'],
    		'ip'=>$user['ip'],
    		'addtime'=>time(),
    	);
    	$j=0;
    	for($i=1;$imin, $this->max);
    	}
    	
    	$lotteryid=0;
    	foreach ($this->level as $k=>$r){
    		if(in_array($j, $r)){
    			if($this->lottery[$k]['isrepeat']==1&&in_array($k, $winning)){
    				$k=$this->lottery[$k]['repeatid'];
    			}
    			$lotteryid=$k;
    			break;
    		}
    	}
    	if($this->lottery[$lotteryid]['ismenpiao']==1){
    		$data['ismenpiao']=1;
    	}
    	$data['lotteryid']=$lotteryid;
    	$data['iswinning']=1;
    	DB::insert($this->qx_lottery_log,$data,true);
    	if($lotteryid>0){
    		return $this->lottery[$lotteryid];
    	}else{
    		return 0;
    	}
	}
	/**
	 * 已经获奖数
	 */
	public  function getlotterycount($start=0,$end=0,$lotteryid=0){
		
		$sql="select count(*) m from ".DB::table($this->qx_lottery_log);
		$sql .=" where 1 ";
		if(intval($start)>0){
			$sql .=" and addtime>='$start' ";
		}
		if(intval($end)>0){
			$sql .=" and addtimeqx_lottery_log);
		$sql .=" where 1 ";
		$start=QIUXIE_CJ_STAR;
		if(intval($start)>0){
			$sql .=" and addtime>='$start' ";
		}
		$end=QIUXIE_CJ_END;
		if(intval($end)>0){
			$sql .=" and addtimeqx_lottery_log);
		$sql .=" where 1 ";
		$sql .=" and isdisable='0' and iswinning='1' and uid='$uid'";
		$data = DB::fetch_all($sql);
		$return=array();
		foreach ($data as $r){
			$return[]=$r['lotteryid'];
		}
        return $return;
	}
	/**
	 * 报名用户总数
	 */
	public function getbaoming(){
		$sql="select count(*) m from ".DB::table($this->qx_user);
		$sql .=" where 1 ";
		if(defined('QIUXIE_BM_STAR')){
			$sql .=" and addtime>='".QIUXIE_BM_STAR."' ";
		}
		if(defined('QIUXIE_BM_END')){
			$sql .=" and addtimeqx_lottery);
		$sql .=" where isopen='1' ";
        return intval(DB::result_first($sql));
	}
	/**
	 * 输出用户抽中门票
	 * @param intval $uid
	 * @param bool $bool 是否是门票
	 * @param int $isout 0没有过期1过期2全部
	 */
	public function getuserwinningqiuxie($uid,$bool=false,$isout=0){
		$sql="select l.*,y.name ";
		$sql .=" from ".DB::table($this->qx_lottery)." AS y";
		$sql .=" LEFT JOIN ".DB::table($this->qx_lottery_log)." as l";
		$sql .=" ON l.lotteryid=y.lotteryid ";
		$sql .=" where 1 and l.iswinning='1' and l.isdisable='0' ";
		$sql .=" and l.uid='$uid'";
		if($isout==2){
		}elseif($isout==1){
			$sql .=" and l.isout='1' ";
		}else{
			$sql .=" and l.isout='0' ";
		}
		if($bool){
			$sql .=" and l.ismenpiao='1' ";
		}
        return DB::fetch_all($sql);
	}
	public function paylog($uer){
		$g=$_GET;
		$data=array('uid'=>$user['uid'],
    		'tel'=>$user['tel'],
    		'ip'=>$user['ip'],
    		'addtime'=>time(),
		'notify_id'=>$g['notify_id'],
		'out_trade_no'=>$g['out_trade_no'],
		'trade_no'=>$g['trade_no'],
		'total_fee'=>$g['total_fee'],
		'trade_status'=>$g['trade_status'],
		'sign'=>$g['sign'],
		'query'=>$_SERVER['QUERY_STRING']
		);
		DB::insert('app_qiuxie_pay_log',$data,true);
	}
	/**
	 * 设置超时
	 */
	private function setout(){
		$data=array('isout'=>1);
		$time=$this->time>0?$this->time:time();
		$time=$time-3*3600;
		DB::update($this->qx_lottery_log,$data," iswinning='1' and ismenpiao='1' and recharge_time$orderid,
		'money'=>$money);
		$logid=intval($logid);
		DB::update($this->qx_lottery_log,$data," logid='$logid' ");
	}
	/**
	 * 设置支付成功
	 */
	public  function updatelotterylogpay($orderid,$money){
		$data=array('money'=>$money,'ispay'=>1,'recharge_time'=>time());
		DB::update($this->qx_lottery_log,$data," orderid='$orderid' ");
	}
	public function alipay_url($orderid,$subject,$logid){
		global $_G;
		$this->qiuxie_lottery->updatelotterylog($orderid,QIUXIE_MONEY,$logid);
		list($ec_contract, $ec_securitycode, $ec_partner, $ec_creditdirectpay) =
        	 explode("\t", authcode($_G['setting']['ec_contract'], 'DECODE', $_G['config']['security']['authkey']));
		$parameter = array(
			"service"         => 'create_direct_pay_by_user',
			"partner"         => $ec_partner,  
			"return_url"      => QIUXIE_URL. 'index.php?dir=qiuxie&do=zhifu',  
			"notify_url"      => QIUXIE_URL. 'index.php?dir=qiuxie&do=zhifu', 
			"_input_charset"  => 'utf-8',
			"subject"         => $subject,
			"body"            => QIUXIE_URL . "index.php?dir=qiuxie",
			"out_trade_no"    => $orderid,
			"price"       => QIUXIE_MONEY,  
			'quantity' 		=> 1,
			"payment_type"    => 1,
			"show_url"        => QIUXIE_URL . "index.php?dir=qiuxie",
			"seller_email"    => '111111111@163.com',
		);
		
		return self::trade_returnurl($parameter,$ec_securitycode);
	}
	private function trade_returnurl($args,$code) {
		ksort($args);
		$urlstr = $sign = '';
		foreach($args as $key => $val) {
			$sign .= '&'.$key.'='.$val;
			$urlstr .= $key.'='.rawurlencode($val).'&';
		}
		$sign = substr($sign, 1);
		$sign = md5($sign.$code);
		return 'https://www.alipay.com/cooperate/gateway.do?'.$urlstr.'sign='.$sign.'&sign_type=MD5';
	}
}?>
登入後複製

cache.class.php
<?php /**
 * 写入缓存,默认为文件缓存,不加载缓存配置。
 * @param $name 缓存名称
 * @param $data 缓存数据
 * @param $filepath 数据路径   DISCUZ_ROOT.$filepath/
 */
function qsetcache($name, $data,$filepath=&#39;&#39;) {
	$cache= new cache_file(&#39;&#39;, $filepath);
	return $cache->set($name, $data);
}

/**
 * 读取缓存,默认为文件缓存,不加载缓存配置。
 * @param string $name 缓存名称
 * @param $filepath 数据路径   DISCUZ_ROOT.$filepath/
 */
function qgetcache($name, $filepath='') {
	$cache= new cache_file('',$filepath);
	return $cache->get($name);
}

/**
 * 删除缓存,默认为文件缓存,不加载缓存配置。
 * @param $name 缓存名称
 * @param $filepath 数据路径   DISCUZ_ROOT.$filepath/
 */
function qdelcache($name, $filepath='') {
	$cache= new cache_file('',$filepath);
	return $cache->delete($name);
}
class cache_file {
	
	/*缓存默认配置*/
	protected $_setting = array(
								'suf' => '.cache.php',	/*缓存文件后缀*/
								'type' => 'array',		/*缓存格式:array数组,serialize序列化,null字符串*/
							);
	
	/*缓存路径*/
	protected $filepath = '';

	/**
	 * 构造函数
	 * @param	array	$setting	缓存配置
	 * @return  void
	 */
	public function __construct($setting = '',$filepath='') {
		if(!defined('CACHE_PATH')){
			define('CACHE_PATH', DISCUZ_ROOT.'data/');
		}
		if(!empty($filepath)){
			$this->filepath=DISCUZ_ROOT.$filepath.'/';
		}
		$this->get_setting($setting);
	}
	
	/**
	 * 写入缓存
	 * @param	string	$name		缓存名称
	 * @param	mixed	$data		缓存数据
	 * @param	array	$setting	缓存配置
	 * @param	string	$module		所属模型
	 * @return  mixed				缓存路径/false
	 */

	public function set($name, $data, $setting = '', $module = 'qiuxie') {
		$this->get_setting($setting);
		$filepath = CACHE_PATH.'caches_'.$module.'/';
		if(!empty($this->filepath)){
			$filepath=$this->filepath;
		}
		$filename = $name.$this->_setting['suf'];
	    if(!is_dir($filepath)) {
			mkdir($filepath, 0777, true);
	    }
	    
	    if($this->_setting['type'] == 'array') {
	    	$data = "<?php \nreturn ".var_export($data, true).";\n?>";
	    } elseif($this->_setting['type'] == 'serialize') {
	    	$data = serialize($data);
	    }
	    
	    $file_size = file_put_contents($filepath.$filename, $data);
	    return $file_size ? $file_size : 'false';
	}
	
	/**
	 * 获取缓存
	 * @param	string	$name		缓存名称
	 * @param	array	$setting	缓存配置
	 * @param	string	$type		缓存类型
	 * @param	string	$module		所属模型
	 * @return  mixed	$data		缓存数据
	 */
	public function get($name, $setting = '', $module = 'qiuxie') {
		$this->get_setting($setting);
		$filepath = CACHE_PATH.'caches_'.$module.'/';
	if(!empty($this->filepath)){
			$filepath=$this->filepath;
		}
		$filename = $name.$this->_setting['suf'];
		if (!file_exists($filepath.$filename)) {
			return false;
		} else {
		    if($this->_setting['type'] == 'array') {
		    	$data = @require($filepath.$filename);
		    } elseif($this->_setting['type'] == 'serialize') {
		    	$data = unserialize(file_get_contents($filepath.$filename));
		    }
		    
		    return $data;
		}
	}
	
	/**
	 * 删除缓存
	 * @param	string	$name		缓存名称
	 * @param	array	$setting	缓存配置
	 * @param	string	$module		所属模型
	 * @return  bool
	 */
	public function delete($name, $setting = '', $module = 'qiuxie') {
		$this->get_setting($setting);
		$filepath = CACHE_PATH.'caches_'.$module.'/';
		if(!empty($this->filepath)){
			$filepath=$this->filepath;
		}
		$filename = $name.$this->_setting['suf'];
		if(file_exists($filepath.$filename)) {
			return @unlink($filepath.$filename) ? true : false;
		} else {
			return false;
		}
	}
	
	/**
	 * 和系统缓存配置对比获取自定义缓存配置
	 * @param	array	$setting	自定义缓存配置
	 * @return  array	$setting	缓存配置
	 */
	public function get_setting($setting = '') {
		if($setting) {
			$this->_setting = array_merge($this->_setting, $setting);
		}
	}

	public function cacheinfo($name, $setting = '', $module = 'qiuxie') {
		$this->get_setting($setting);
		$filepath = CACHE_PATH.'caches_'.$module.'/';
		if(!empty($this->filepath)){
			$filepath=$this->filepath;
		}
		$filename = $filepath.$name.$this->_setting['suf'];
		
		if(file_exists($filename)) {
			$res['filename'] = $name.$this->_setting['suf'];
			$res['filepath'] = $filepath;
			$res['filectime'] = filectime($filename);
			$res['filemtime'] = filemtime($filename);
			$res['filesize'] = filesize($filename);
			return $res;
		} else {
			return false;
		}
	}

}

?>
登入後複製

主程序都在这了。
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系統,解釋
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1664
14
CakePHP 教程
1423
52
Laravel 教程
1321
25
PHP教程
1269
29
C# 教程
1249
24
在PHP API中說明JSON Web令牌(JWT)及其用例。 在PHP API中說明JSON Web令牌(JWT)及其用例。 Apr 05, 2025 am 12:04 AM

JWT是一種基於JSON的開放標準,用於在各方之間安全地傳輸信息,主要用於身份驗證和信息交換。 1.JWT由Header、Payload和Signature三部分組成。 2.JWT的工作原理包括生成JWT、驗證JWT和解析Payload三個步驟。 3.在PHP中使用JWT進行身份驗證時,可以生成和驗證JWT,並在高級用法中包含用戶角色和權限信息。 4.常見錯誤包括簽名驗證失敗、令牌過期和Payload過大,調試技巧包括使用調試工具和日誌記錄。 5.性能優化和最佳實踐包括使用合適的簽名算法、合理設置有效期、

php程序在字符串中計數元音 php程序在字符串中計數元音 Feb 07, 2025 pm 12:12 PM

字符串是由字符組成的序列,包括字母、數字和符號。本教程將學習如何使用不同的方法在PHP中計算給定字符串中元音的數量。英語中的元音是a、e、i、o、u,它們可以是大寫或小寫。 什麼是元音? 元音是代表特定語音的字母字符。英語中共有五個元音,包括大寫和小寫: a, e, i, o, u 示例 1 輸入:字符串 = "Tutorialspoint" 輸出:6 解釋 字符串 "Tutorialspoint" 中的元音是 u、o、i、a、o、i。總共有 6 個元

什麼是PHP魔術方法(__ -construct,__destruct,__call,__get,__ set等)並提供用例? 什麼是PHP魔術方法(__ -construct,__destruct,__call,__get,__ set等)並提供用例? Apr 03, 2025 am 12:03 AM

PHP的魔法方法有哪些? PHP的魔法方法包括:1.\_\_construct,用於初始化對象;2.\_\_destruct,用於清理資源;3.\_\_call,處理不存在的方法調用;4.\_\_get,實現動態屬性訪問;5.\_\_set,實現動態屬性設置。這些方法在特定情況下自動調用,提升代碼的靈活性和效率。

解釋PHP中的晚期靜態綁定(靜態::)。 解釋PHP中的晚期靜態綁定(靜態::)。 Apr 03, 2025 am 12:04 AM

靜態綁定(static::)在PHP中實現晚期靜態綁定(LSB),允許在靜態上下文中引用調用類而非定義類。 1)解析過程在運行時進行,2)在繼承關係中向上查找調用類,3)可能帶來性能開銷。

PHP和Python:比較兩種流行的編程語言 PHP和Python:比較兩種流行的編程語言 Apr 14, 2025 am 12:13 AM

PHP和Python各有優勢,選擇依據項目需求。 1.PHP適合web開發,尤其快速開發和維護網站。 2.Python適用於數據科學、機器學習和人工智能,語法簡潔,適合初學者。

PHP行動:現實世界中的示例和應用程序 PHP行動:現實世界中的示例和應用程序 Apr 14, 2025 am 12:19 AM

PHP在電子商務、內容管理系統和API開發中廣泛應用。 1)電子商務:用於購物車功能和支付處理。 2)內容管理系統:用於動態內容生成和用戶管理。 3)API開發:用於RESTfulAPI開發和API安全性。通過性能優化和最佳實踐,PHP應用的效率和可維護性得以提升。

PHP:網絡開發的關鍵語言 PHP:網絡開發的關鍵語言 Apr 13, 2025 am 12:08 AM

PHP是一種廣泛應用於服務器端的腳本語言,特別適合web開發。 1.PHP可以嵌入HTML,處理HTTP請求和響應,支持多種數據庫。 2.PHP用於生成動態網頁內容,處理表單數據,訪問數據庫等,具有強大的社區支持和開源資源。 3.PHP是解釋型語言,執行過程包括詞法分析、語法分析、編譯和執行。 4.PHP可以與MySQL結合用於用戶註冊系統等高級應用。 5.調試PHP時,可使用error_reporting()和var_dump()等函數。 6.優化PHP代碼可通過緩存機制、優化數據庫查詢和使用內置函數。 7

PHP的持久相關性:它還活著嗎? PHP的持久相關性:它還活著嗎? Apr 14, 2025 am 12:12 AM

PHP仍然具有活力,其在現代編程領域中依然佔據重要地位。 1)PHP的簡單易學和強大社區支持使其在Web開發中廣泛應用;2)其靈活性和穩定性使其在處理Web表單、數據庫操作和文件處理等方面表現出色;3)PHP不斷進化和優化,適用於初學者和經驗豐富的開發者。

See all articles