예제 #1
0
 public static function setLastVisitCookie()
 {
     global $userdata;
     $guest_lastvisit = time() - 3600;
     $update_threads = false;
     $set_cookie = true;
     $cookie_exists = isset($_COOKIE[COOKIE_LASTVISIT]) && isnum($_COOKIE[COOKIE_LASTVISIT]) ? true : false;
     if (iMEMBER) {
         if ($cookie_exists) {
             if ($_COOKIE[COOKIE_LASTVISIT] > $userdata['user_lastvisit']) {
                 $update_threads = true;
                 $lastvisit = $userdata['user_lastvisit'];
             } else {
                 $set_cookie = false;
                 $lastvisit = $_COOKIE[COOKIE_LASTVISIT];
             }
         } else {
             $update_threads = true;
             $lastvisit = $userdata['user_lastvisit'];
         }
         if ($update_threads) {
             dbquery("UPDATE " . DB_USERS . " SET user_threads='' WHERE user_id='" . $userdata['user_id'] . "'");
         }
     } else {
         if ($cookie_exists) {
             if ($_COOKIE[COOKIE_LASTVISIT] > $guest_lastvisit) {
                 $lastvisit = $guest_lastvisit;
             } else {
                 $set_cookie = false;
                 $lastvisit = $_COOKIE[COOKIE_LASTVISIT];
             }
         } else {
             $lastvisit = $guest_lastvisit;
         }
     }
     if ($set_cookie) {
         Authenticate::_setCookie(COOKIE_LASTVISIT, $lastvisit, time() + 3600, COOKIE_PATH, COOKIE_DOMAIN, false, true);
     }
     return $lastvisit;
 }