if ($_DSESSION = $db->fetch_array($query)) {
         $sessionexists = 1;
         if (!empty($_DSESSION['sessionuid'])) {
             $_DSESSION = array_merge($_DSESSION, $db->fetch_first("SELECT {$membertablefields}\r\n    \t\t\t\tFROM {$tablepre}members m WHERE uid='{$_DSESSION['sessionuid']}'"));
         }
     } else {
         if ($_DSESSION = $db->fetch_first("SELECT sid, groupid, groupid='6' AS ipbanned\r\n    \t\t\tFROM {$tablepre}sessions WHERE sid='{$sid}' AND CONCAT_WS('.',ip1,ip2,ip3,ip4)='{$onlineip}'")) {
             GlobalCore::clearcookies();
             $sessionexists = 1;
         }
     }
 }
 if (!$sessionexists) {
     if ($nw_uid) {
         if (!($_DSESSION = $db->fetch_first("SELECT {$membertablefields}\r\n    \t\t\tFROM {$tablepre}members m WHERE m.uid='{$nw_uid}' AND m.password='******'"))) {
             GlobalCore::clearcookies();
         }
     }
     if (GlobalCore::ipbanned($onlineip)) {
         $_DSESSION['ipbanned'] = 1;
     }
     $_DSESSION['sid'] = GlobalCore::random(6);
     $_DSESSION['seccode'] = GlobalCore::random(6, 1);
 }
 $_DSESSION['dateformat'] = empty($_DSESSION['dateformat']) ? $_CHOBITS['settings']['dateformat'] : $_DSESSION['dateformat'];
 $_DSESSION['timeformat'] = empty($_DSESSION['timeformat']) ? $_CHOBITS['settings']['timeformat'] : ($_DSESSION['timeformat'] == 1 ? 'h:i A' : 'H:i');
 $_DSESSION['timeoffset'] = isset($_DSESSION['timeoffset']) && $_DSESSION['timeoffset'] != 9999 ? $_DSESSION['timeoffset'] : $_CHOBITS['settings']['timeoffset'];
 $membertablefields = '';
 @extract($_DSESSION);
 $lastvisit = empty($lastvisit) ? $timestamp - 86400 : $lastvisit;
 $timenow = array('time' => gmdate("{$dateformat} {$timeformat}", $timestamp + 3600 * $timeoffset), 'offset' => $timeoffset >= 0 ? $timeoffset == 0 ? '' : '+' . $timeoffset : $timeoffset);