How to change the thinkphp sign-in code

Source: Internet
Author: User
        $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 () {//daily check-in $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);         $today =date (' y-m-d ', Time ());            if ($lastSign = = $today) {echo "Signed in today, you have been signed in {$count} days, consecutive check-in 5 days a day + 5 Yuan voucher!";        Exit (); } $residueHour =24+24-date (' H ', $lastSignDay); Valid check-in time (the remaining hours of the check-in Day + 1 days) $formatHour =strtotime (' y-m-d H ', $lastSignDay). ': 0 0:00 ')//sign-on day 2014-12-07 18:00:00 $lastSignDate =strtotime ("+{$residueHour}hour", $formatHour);//In 2014-12-07 18:00:0 0 on the basis + valid check-in times if (Time () > $lastSignDate) { Current time > Last sign-in time $count = 1;        }else{$count = $count +1; } $sign = $dao->where ("userid={$this->memberid}")->save (Array (' si_time ' = $current, ' Si_count ' =>$ count));     Check-in table}else{$sign = $dao->add (' userId ' = $this->memberid, ' Si_count ' =>1);//sign-in table $count = 1;              if ($sign) {//First day sign in +1 second day sign in +2 third day sign in +3 fourth day sign in +4 fifth day +5 consecutive 5 day +5 switch ($count) {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}")->setinc (' Coin ', $sc _score);            Registration Amount Cumulative $coin = $dao->where ("userid={$this->memberid}")->field (' coin ')->find ();               if ($coin [' coin ']>=20) { $dao->where ("userid={$this->memberid}")->setdec (' coin ', 20);//If full 20 will generate a 20 voucher $this->insertcou            Pon (' Member registration voucher ',->memberid, $this);                } $data =array (' userId ' = $this->memberid, ' Sc_score ' and $sc _score,                ' Sc_detail ' = ' sign In + '. $sc _score, ' Sc_type ' =>1); M (' Score2 ')->add ($data);        if ($count >0) {echo "You have successfully signed in today, you have successfully received {$SC _score} Dollar voucher with consecutive sign-in {$count} days";        }else{echo "sign-in Success"; }}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.