Is there a problem with this sign-in code?

Source: Internet
Author: User
{Code ...}

  Check_login (); $ m_time = $ this-> getMillisecond (); $ con ['si _ time'] = array ('gt ', date ('Y-m-d'); $ ranking = M ('sign')-> where ($ con)-> count (); if ($ ranking) {$ haha = intval ($ ranking); switch ($ haha) {case 1: $ pm = 5; // give 5 blocks $ row = 2; $ ch = "runner-up"; break; case 2: $ pm = 3; // give two $ row = 2; $ ch = "Runner-up"; break; default: $ pm = 0 ;}} else {$ pm = 10; // give 10 coupons $ row = 1; $ ch = "champion ";} if ($ pm> 0) {$ this-> insertGiveCoupon ($ this-> memberID, $ pm); $ memo ="
You signed in to {$ ch} today and successfully received the {$ pm} coupon ";}$ 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']; // find the member name $ member = M ('members '); $ where ['id'] = $ this-> memberID; $ memberName = $ member-> where ($ where)-> field ('name')-> find (); // $ this-> membername = $ memberName ['name']; $ this-> uid = $ this-> memberID; // if the execution is successful if ($ hasSign) {$ lastSign Day = strtotime ("{$ hasSign ['si _ time']}"); $ lastSign = date ('Y-m-d', $ lastSignDay ); $ today = 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! "; $ This-> ajaxReturn ('', "you have signed in today! ", 0); 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 (Array ('Si _ time' => $ current, 'si _ count' => $ count,'m _ second' => $ m_time )); // sign-In table} else {$ sign = $ dao-> add (array ('userid' => $ this-> memberID, 'si _ count' => 1, 'Si _ time' => $ current,'m _ second '=> $ m_time); // 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}")-> setInc ('coin ', $ SC _score ); // accumulate the sign-in amount $ 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 will be generated ('Membership sign-In coupon ', 20, $ this-> memberID );} $ data = array ('userid' =>$ this-> memberID, 'SC _ score' =>$ SC _score,' SC _ detail' => 'sign-In + '. $ SC _score, 'SC _ type' => 1); M ('score')-> add ($ data); // if ($ count> 0) {$ this-> ajaxReturn (''," sign-in successful! You have signed in. You have successfully received the {$ SC _score} yuan coupon! {$ Memo} ", 1); exit ();} else {$ this-> ajaxReturn ('', "you have signed in! ", 1); exit () ;}} else {$ this-> ajaxReturn ('', "failed to sign in. Please try again later! ", 0); exit () ;}// private method to generate the coupon private function insertCoupon ($ name, $ amount, $ mid) {$ data ['name'] = trim ($ name); $ data ['amount'] = $ amount; $ data ['coupon'] = array (); $ data ['coupon'] = md5 (uniqid (md5 (microtime (true), true); $ data ['start _ time'] = time (); $ data ['expire _ time'] = strtotime ("+ 2 year"); $ data ['dateline '] = time (); $ data ['status'] = 1; $ data ['user _ id'] = $ mid; M ('coupon')-> add ($ data );} // private method, generate coupon private function insertGiveCoupon ($ mid, $ amount) {$ map ['user _ id'] = $ mid; $ map ['status'] = 1; $ res = M ('givecoupon')-> where ($ map)-> find (); if ($ res) {M ('giveupon')-> where ($ map)-> setInc ('amount', $ amount );} else {$ data ['name'] = 'coupon '; $ data ['amount'] = $ amount; $ data ['coupon'] = array (); $ data ['coupon'] = md5 (uniqid (md5 (microtime (true), true); $ data ['start _ time'] = time (); $ data ['expire _ time'] = strtotime ("next year"); $ data ['dateline '] = time (); $ data ['status'] = 1; $ data ['user _ id'] = $ mid; M ('givecoupon')-> add ($ data );}}

Reply content:

  Check_login (); $ m_time = $ this-> getMillisecond (); $ con ['si _ time'] = array ('gt ', date ('Y-m-d'); $ ranking = M ('sign')-> where ($ con)-> count (); if ($ ranking) {$ haha = intval ($ ranking); switch ($ haha) {case 1: $ pm = 5; // give 5 blocks $ row = 2; $ ch = "runner-up"; break; case 2: $ pm = 3; // give two $ row = 2; $ ch = "Runner-up"; break; default: $ pm = 0 ;}} else {$ pm = 10; // give 10 coupons $ row = 1; $ ch = "champion ";} if ($ pm> 0) {$ this-> insertGiveCoupon ($ this-> memberID, $ pm); $ memo ="
You signed in to {$ ch} today and successfully received the {$ pm} coupon ";}$ 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']; // find the member name $ member = M ('members '); $ where ['id'] = $ this-> memberID; $ memberName = $ member-> where ($ where)-> field ('name')-> find (); // $ this-> membername = $ memberName ['name']; $ this-> uid = $ this-> memberID; // if the execution is successful if ($ hasSign) {$ lastSign Day = strtotime ("{$ hasSign ['si _ time']}"); $ lastSign = date ('Y-m-d', $ lastSignDay ); $ today = 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! "; $ This-> ajaxReturn ('', "you have signed in today! ", 0); 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 (Array ('Si _ time' => $ current, 'si _ count' => $ count,'m _ second' => $ m_time )); // sign-In table} else {$ sign = $ dao-> add (array ('userid' => $ this-> memberID, 'si _ count' => 1, 'Si _ time' => $ current,'m _ second '=> $ m_time); // 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}")-> setInc ('coin ', $ SC _score ); // accumulate the sign-in amount $ 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 will be generated ('Membership sign-In coupon ', 20, $ this-> memberID );} $ data = array ('userid' =>$ this-> memberID, 'SC _ score' =>$ SC _score,' SC _ detail' => 'sign-In + '. $ SC _score, 'SC _ type' => 1); M ('score')-> add ($ data); // if ($ count> 0) {$ this-> ajaxReturn (''," sign-in successful! You have signed in. You have successfully received the {$ SC _score} yuan coupon! {$ Memo} ", 1); exit ();} else {$ this-> ajaxReturn ('', "you have signed in! ", 1); exit () ;}} else {$ this-> ajaxReturn ('', "failed to sign in. Please try again later! ", 0); exit () ;}// private method to generate the coupon private function insertCoupon ($ name, $ amount, $ mid) {$ data ['name'] = trim ($ name); $ data ['amount'] = $ amount; $ data ['coupon'] = array (); $ data ['coupon'] = md5 (uniqid (md5 (microtime (true), true); $ data ['start _ time'] = time (); $ data ['expire _ time'] = strtotime ("+ 2 year"); $ data ['dateline '] = time (); $ data ['status'] = 1; $ data ['user _ id'] = $ mid; M ('coupon')-> add ($ data );} // private method, generate coupon private function insertGiveCoupon ($ mid, $ amount) {$ map ['user _ id'] = $ mid; $ map ['status'] = 1; $ res = M ('givecoupon')-> where ($ map)-> find (); if ($ res) {M ('giveupon')-> where ($ map)-> setInc ('amount', $ amount );} else {$ data ['name'] = 'coupon '; $ data ['amount'] = $ amount; $ data ['coupon'] = array (); $ data ['coupon'] = md5 (uniqid (md5 (microtime (true), true); $ data ['start _ time'] = time (); $ data ['expire _ time'] = strtotime ("next year"); $ data ['dateline '] = time (); $ data ['status'] = 1; $ data ['user _ id'] = $ mid; M ('givecoupon')-> add ($ data );}}

The landlord code is not fully pasted!
And even if it is fully pasted, youVariable nameIt is estimated that everyone is too lazy to read it!

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.