function LogIn($username, $password, $must_be_admin = false) { LogOut(); if (($user_info = CheckCredentials($username, $password, $must_be_admin)) !== false) { $session_id = CreateSession($user_info['user_id']); setcookie(SESSION_COOKIE_NAME, $session_id); $_COOKIE[SESSION_COOKIE_NAME] = $session_id; } return $user_info; }
function RefreshOrCreateSession($dataConnection, $userId) { try { $sessionId = GetSessionFromUserId($dataConnection, $userId); RefreshSession($dataConnection, $sessionId); } catch (Exception $e) { $sessionId = CreateSession($dataConnection, $userId); } return $sessionId; }
function ValidateLogin() { if (isset($_POST['send'])) { $data['username'] = strip_tags(trim($_POST['username'])); $data['password'] = strip_tags(trim($_POST['password'])); $username = $data['username']; $password = $data['password']; if (empty($data['username'])) { echo 'Preencha o campo Usuário!'; } else { if (empty($data['password'])) { echo 'Preencha o campo Senha!'; } else { if (!UserVerify($username, $password)) { echo 'Nome de Usuario ou Senha Incorretors!'; } else { CreateSession($username, $password); } } } } }
<?php require_once 'system/system.php'; AcessPublic(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Degub</title> </head> <body> <?php $username = '******'; $password = '******'; $password = CryptPassword($password); var_dump(CreateSession($username, $password)); ?> </body> </html>
function ProcessLocation() { global $UserID; global $SessionID; global $LanguageID; global $Response; if (isset($_POST['Coords'])) { $Lat = 0; $Lng = 0; $Ctry = 0; if (ValidCoords($_POST['Coords'], $Ctry, $Lat, $Lng)) { if ($UserID > 0 && $SessionID > 0) { list($QR, $DR, $T) = QuerySingle("SELECT COALESCE(COUNT(UserLocationID),0) AS Locs FROM 1100_User_Locations WHERE UserID = " . $UserID . ";"); if ($QR < 0) { SysLogIt('Error counting user locations for user with ID of ' . $UserID . '.', StatusError, ActionSelect); } elseif ($QR == 0 || $DR['Locs'] < 5) { if (ExecCommand("UPDATE 0700_Sessions SET Latitude = " . $Lat . ", Longitude = " . $Lng . ", Country = " . $Ctry . " WHERE SessionID = " . $SessionID . ";")) { $Response->S = true; $Response->J = 'NamLoc();'; $Response->Send(); } else { SysLogIt('Error updating session with new location coordinates.', StatusError, ActionUpdate); } } } elseif (CreateSession(0, $LanguageID, 1, $Lat, $Lng, $Ctry)) { $Response->S = true; $Response->J = 'F5();'; //$Response->J = ((stripos($_SERVER['HTTP_USER_AGENT'], 'msie') === false)?"F5();":"top.location = 'http://".SiteAddress."';"); $Response->Send(); } } } ReturnResponse(false, 'An error occured. Please try again later.', 'errmsg', "Foc('InLoc');"); }
if (strlen($loginusername) and strlen($loginpassword)) { $vvckey = ForceIncomingString('vvckey'); if (ForceIncomingCookie('safecookieF' . $vvckey . COOKIE_KEY) != md5($_CFG['cKillRobotCode'] . $vvckey)) { exit; } setcookie('safecookieF' . $vvckey . COOKIE_KEY, '', 0, '/'); if (!IsName($loginusername) or !IsPass($loginpassword)) { $logininfo = $lang['login_error1']; LogIn(); } else { $userid = LoginUser($loginusername, $loginpassword); if (!$userid) { $logininfo = $lang['login_error2']; LogIn(); } else { CreateSession($userid); header("Location: ./"); exit; } } } else { if (ForceIncomingInt('logout') == 1) { $sessionid = ForceIncomingCookie(COOKIE_NAME); if ($sessionid and IsPass($sessionid)) { $user = $DB->getOne("SELECT u.userid, u.usergroupid FROM " . TABLE_PREFIX . "session s \r\n\t\tLEFT JOIN " . TABLE_PREFIX . "user u ON u.userid = s.userid\r\n\t\tWHERE sessionid = '{$sessionid}'"); $DB->exe("UPDATE " . TABLE_PREFIX . "user SET isonline = 0 WHERE userid = '{$user['userid']}' "); $DB->exe("DELETE FROM " . TABLE_PREFIX . "session WHERE sessionid = '{$sessionid}' "); $DB->exe("DELETE FROM " . TABLE_PREFIX . "vvc WHERE date < " . ($realtime - 3600 * 8)); $DB->exe("DELETE FROM " . TABLE_PREFIX . "session WHERE created < " . ($realtime - 3600 * 48)); if ($user['usergroupid'] != 1) { refreshCache($user['userid'], 'isonline', '0');