Home >php教程 >php手册 >基于TP的每日签到代码

基于TP的每日签到代码

WBOY
WBOYOriginal
2016-06-07 11:42:441183browse

自己写的基于TP的每日签到代码。需要的带走,大牛勿喷
// 每日签到<br>         public function dailySign(){<br>             // 获取用户签到信息<br>             $merArr = M('merchant') -> where("MerID = '$this->UserId'") -> find();<br>             // 判断是否为注册后第一次签到<br>             if($merArr['totalTime'] == 0 && $merArr['totalnum'] == 0){<br>                 // 获取签到设置<br>                 $signArr = M('sign') -> where("num = 1") -> find();<br>                 $Yunbi = $signArr['yun'];<br>                 $score['Mertotal'] = array('exp',"Mertotal + $Yunbi");<br>                 $score['totalnum'] = 1;<br>                 $score['totalTime'] = time();<br>                 $result = M('merchant') -> where("MerID = '$this->UserId'") -> save($score);<br>                 if($result > 0){<br>                     echo "签到成功";<br>                 }else{<br>                     echo "签到失败";<br>                 }<br>             }else{<br>                 // 获取登录用户签到信息<br>                 $totalTime = $merArr['totalTime']; // 签到时间<br>                 $totalnum = $merArr['totalnum']; // 签到次数<br>                 $signTime = date('y-m-d',$totalTime); // 格式化签到时间<br>                 // 判断今天是否已经签到<br>                 if($signTime == date('y-m-d',time())){<br>                     echo "已签到";<br>                     exit;<br>                 }else{<br>                     // 判断是否错过连续签到时间<br>                     if(time() - $totalTime > 60*60*24){<br>                         // 获取签到设置<br>                         $signArr = M('sign') -> where("num = 1") -> find();<br>                         $Yunbi = $signArr['yun'];<br>                         $score['Mertotal'] = array('exp',"Mertotal + $Yunbi");<br>                         $score['totalnum'] = 1;<br>                         $score['totalTime'] = time();<br>                         $result = M('merchant') -> where("MerID = '$this->UserId'") -> save($score);<br>                         if($result > 0){<br>                             echo "签到成功";<br>                         }else{<br>                             echo "签到失败";<br>                         }<br>                     }else{<br>                         // 获取签到设置<br>                         $signArr = M('sign') -> where("num = $totalnum + 1") -> find();<br>                         if($signArr != null){<br>                             $Yunbi = $signArr['yun'];<br>                         }else{<br>                             $maxYun = M('sign') -> Max('num');<br>                             $signArr = M('sign') -> where("num = $maxYun") -> find();<br>                             $Yunbi = $signArr['yun'];<br>                         }<br>                         $score['Mertotal'] = array('exp',"Mertotal + $Yunbi");<br>                         $score['totalnum'] = $totalnum + 1;<br>                         $score['totalTime'] = time();<br>                         $result = M('merchant') -> where("MerID = '$this->UserId'") -> save($score);<br>                         if($result > 0){<br>                             echo "签到成功";<br>                         }else{<br>                             echo "签到失败";<br>                         }<br>                     }    <br>                 }<br>             }<br>         }--<br> -- 表的结构 `web_sign`<br> --<br> <br> CREATE TABLE IF NOT EXISTS `web_sign` (<br>   `id` int(11) NOT NULL AUTO_INCREMENT,<br>   `num` tinyint(4) NOT NULL,<br>   `yun` int(11) NOT NULL,<br>   PRIMARY KEY (`id`)<br> ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='签到表' AUTO_INCREMENT=3 ;<br> <br> --<br> -- 转存表中的数据 `web_sign`<br> --<br> <br> INSERT INTO `web_sign` (`id`, `num`, `yun`) VALUES<br> (1, 1, 20),<br> (2, 2, 40);

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP FTP操作类Next article:六、电影排行榜