function user_logged_in() { if (isset($GLOBALS['cook']) and trim($GLOBALS['cook']) != '') { $c = explode('|', $GLOBALS['cook']); } else { $c = getMyCookie(); } $username = $c[0]; $userpassword = $c[1]; $exptime = $c[2] + 0; $returned = FALSE; $resetCookie = FALSE; if ($username == '') { $returned = FALSE; return; } $GLOBALS['user_usr'] = $username; $pasttime = $exptime - time(); if (strlen($GLOBALS['admin_pwd']) == 32) { $user_pwd_cmp = $GLOBALS['admin_pwd']; } else { $user_pwd_cmp = writeUserPwd($GLOBALS['admin_pwd']); } if (isset($GLOBALS['loginsCase']) and $GLOBALS['loginsCase']) { $caseComp1 = $GLOBALS['caseComp'] . '('; $caseComp2 = ')'; $usernameSql = strtolower($username); } else { $caseComp1 = ''; $caseComp2 = ''; $usernameSql = $username; } if (($username == $GLOBALS['admin_usr'] or isset($GLOBALS['loginsCase']) and $GLOBALS['loginsCase'] and strtolower($username) == strtolower($GLOBALS['admin_usr'])) and $userpassword == $user_pwd_cmp) { //if ($username==$GLOBALS['admin_usr'] and $userpassword==$GLOBALS['admin_pwd']) { $returned = TRUE; $GLOBALS['logged_user'] = 0; $GLOBALS['logged_admin'] = 1; $GLOBALS['user_id'] = 1; if ($row = db_simpleSelect(0, $GLOBALS['Tu'], $GLOBALS['dbUserSheme']['user_sorttopics'][1] . ',' . $GLOBALS['dbUserSheme']['language'][1] . ', ' . $GLOBALS['dbUserSheme']['num_posts'][1], $GLOBALS['dbUserId'], '=', 1)) { $GLOBALS['user_sort'] = $row[0]; } $GLOBALS['langu'] = $row[1]; $GLOBALS['user_num_posts'] = $row[2]; $username = $GLOBALS['admin_usr']; if ($pasttime <= $GLOBALS['cookie_renew']) { // if expiration time of cookie is less than defined in setup, we redefine it below $resetCookie = TRUE; } } elseif ($row = db_simpleSelect(0, $GLOBALS['Tu'], $GLOBALS['dbUserId'] . ',' . $GLOBALS['dbUserSheme']['user_sorttopics'][1] . ',' . $GLOBALS['dbUserSheme']['language'][1] . ',' . $GLOBALS['dbUserAct'] . ',' . $GLOBALS['dbUserSheme']['user_password'][1] . ', ' . $GLOBALS['dbUserSheme']['username'][1] . ', ' . $GLOBALS['dbUserSheme']['num_posts'][1], $caseComp1 . $GLOBALS['dbUserSheme']['username'][1] . $caseComp2, '=', $usernameSql, '', 1)) { if ($row[4] == $userpassword) { $returned = TRUE; $GLOBALS['user_id'] = $row[0]; $GLOBALS['user_sort'] = $row[1]; $GLOBALS['logged_user'] = 1; $GLOBALS['logged_admin'] = 0; $GLOBALS['langu'] = $row[2]; $GLOBALS['user_activity'] = $row[3]; $username = $row[5]; $GLOBALS['user_num_posts'] = $row[6]; if ($pasttime <= $GLOBALS['cookie_renew']) { $resetCookie = TRUE; } } else { /* Preventing hijack */ $username = ''; $GLOBALS['user_usr'] = $username; } } else { $returned = FALSE; if ($pasttime <= $GLOBALS['cookie_renew']) { $userpassword = ''; $resetCookie = TRUE; } } if ($resetCookie) { deleteMyCookie(); setMyCookie($username, $userpassword, $GLOBALS['cookieexptime']); } return $returned; }
function user_logged_in() { if (isset($GLOBALS['cook']) and trim($GLOBALS['cook']) != '') { $c = explode('|', $GLOBALS['cook']); } elseif (isset($_SESSION['minimalistBBSession'])) { $c = explode('|', $_SESSION['minimalistBBSession']); } else { $c = getMyCookie(); } $username = $c[0]; $userpassword = $c[1]; $exptime = $c[2]; $returned = FALSE; $resetCookie = FALSE; if ($username == '') { $returned = FALSE; return; } $GLOBALS['user_usr'] = $username; $pasttime = $exptime - time(); if ($username == $GLOBALS['admin_usr'] and $userpassword == md5($GLOBALS['admin_pwd'])) { $returned = TRUE; $GLOBALS['logged_user'] = 0; $GLOBALS['logged_admin'] = 1; $GLOBALS['user_id'] = 1; if ($row = db_simpleSelect(0, $GLOBALS['Tu'], $GLOBALS['dbUserSheme']['user_sorttopics'][1] . ',' . $GLOBALS['dbUserSheme']['language'][1], $GLOBALS['dbUserId'], '=', 1)) { $GLOBALS['user_sort'] = $row[0]; } $GLOBALS['langu'] = $row[1]; if ($pasttime <= $GLOBALS['cookie_renew']) { // if expiration time of cookie is less than defined in setup, we redefine it below $resetCookie = TRUE; } } elseif ($userpassword != '' and $row = db_simpleSelect(0, $GLOBALS['Tu'], $GLOBALS['dbUserId'] . ',' . $GLOBALS['dbUserSheme']['user_sorttopics'][1] . ',' . $GLOBALS['dbUserSheme']['language'][1] . ',' . $GLOBALS['dbUserAct'], $GLOBALS['dbUserId'], '=', $GLOBALS['USER']->user_id, '', 1)) { $returned = TRUE; $GLOBALS['user_id'] = $row[0]; $GLOBALS['user_sort'] = $row[1]; $GLOBALS['logged_user'] = 1; $GLOBALS['logged_admin'] = 0; $GLOBALS['langu'] = $row[2]; $GLOBALS['user_activity'] = $row[3]; //modify based on geograph user status global $USER; if ($USER->hasPerm('admin')) { $GLOBALS['logged_user'] = 0; $GLOBALS['logged_admin'] = 1; } if ($pasttime <= $GLOBALS['cookie_renew']) { $resetCookie = TRUE; } } else { $returned = FALSE; if ($pasttime <= $GLOBALS['cookie_renew']) { $userpassword = ''; $resetCookie = TRUE; } } if ($resetCookie) { deleteMyCookie(); setMyCookie($username, $userpassword, $GLOBALS['cookieexptime']); } return $returned; }