How to change the thinkphp sign-in code

Source: Internet
Author: User
{Code ...}
        $residueHour=24+24-date('H',$lastSignDay);        $formatHour=strtotime(date('Y-m-d H',$lastSignDay).':00:00');        $lastSignDate=strtotime("+{$residueHour}hour",$formatHour);

Reply content:
        $residueHour=24+24-date('H',$lastSignDay);        $formatHour=strtotime(date('Y-m-d H',$lastSignDay).':00:00');        $lastSignDate=strtotime("+{$residueHour}hour",$formatHour);

Public function sign () {// sign in every day $ this-> check_login (); $ data = array ('userid' => $ this-> memberID, 'SC _ score' => 1, 'SC _ detail' => 'sign in + 1',' SC _ type' => 1 ); $ dao = M ('sign'); // instantiate the sign object $ current = date ('Y-m-d H: I: s', time ()); $ hasSign = $ dao-> where ("userId = {$ this-> memberID}")-> find (); $ count = $ hasSign ['si _ count']; if ($ hasSign) {$ lastSignDay = strtotime ("{$ hasSign ['si _ time']}"); $ lastSign = date ('Y-m-d ', $ lastSignDay); $ Todd Ay = date ('Y-m-d', time (); if ($ lastSign = $ today) {echo "you have signed in today, you have signed in for {$ count} consecutive days. You have signed in for 5 consecutive days, plus 5 yuan coupons each day! "; Exit () ;}$ residueHour = 24 + 24-date ('h', $ lastSignDay ); // valid sign-in time (the remaining hours + the time of one day on the day of sign-in) $ formatHour = strtotime (date ('Y-m-d H', $ lastSignDay ). ': 00: 00'); // 18:00:00 $ lastSignDate = strtotime ("+ {$ residueHour} hour", $ formatHour ); // on the basis of 18:00:00 + valid sign-in time if (time ()> $ lastSignDate) {// current time> last sign-in time $ count = 1 ;} else {$ count = $ count + 1;} $ sign = $ dao-> where ("userId = {$ this-> memberID}")-> save (arr Ay ('Si _ time' => $ current, 'si _ count' => $ count )); // sign-In table} else {$ sign = $ dao-> add (array ('userid' => $ this-> memberID, 'si _ count' => 1 )); // sign-In table $ count = 1;} if ($ sign) {// sign in on the first day + 1 sign in on the second day + 2 sign in on the third day + 3 sign in on the fourth day + 4 sign in on the fifth day + 5 consecutive 5 days + 5 switches ($ count) per day) {case 1: $ SC _score = 1; break; case 2: $ SC _score = 2; break; case 3: $ SC _score = 3; break; case 4: $ SC _score = 4; break; default: $ SC _score = 5;} $ dao-> where ("userId = {$ this-> memberID}")-> setIn C ('coin ', $ SC _score); // the sign-in amount is accumulated $ coin = $ dao-> where ("userId = {$ this-> memberID }") -> field ('coin ')-> find (); if ($ coin ['coin']> = 20) {$ dao-> where ("userId = {$ this-> memberID}")-> setDec ('coin ', 20 ); // if the sum is 20, a 20 voucher $ this-> insertCoupon ('Member sign-In coupon ', 20, $ this-> memberID) will be generated );} $ data = array ('userid' =>$ this-> memberID, 'SC _ score' =>$ SC _score,' SC _ detail' => 'sign-In + '. $ SC _score, 'SC _ type' => 1); M ('score2')-> add ($ data); // if ($ co Unt> 0) {echo "you have successfully signed in today and successfully received the {$ SC _score} yuan coupon, of which {$ count} days of continuous sign-in ";} else {echo "sign-in successful" ;}} else {echo 'sign-In failed. Please try again later! ';}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.