예제 #1
0
 private function _Logout()
 {
     // Get the current cookies
     $loginSession = isset($_COOKIE["gLOGINSESSION"]) ? $_COOKIE["gLOGINSESSION"] : "";
     $remoteLoginSession = isset($_COOKIE["gREMOTELOGINSESSION"]) ? $_COOKIE["gREMOTELOGINSESSION"] : "";
     // Delete the local session info database entry.
     if ($loginSession) {
         $sessionModel = new cModel("UserSessions");
         $sessionModel->Delete(array("Identifier" => $loginSession));
     }
     // Delete the remote session info database entry.
     if ($remoteLoginSession) {
         $sessionModel = new cModel("RemoteSessions");
         $sessionModel->Delete(array("Identifier" => $remoteLoginSession));
     }
     // Delete the cookies.
     setcookie("gLOGINSESSION", "", time() - 3600, "/");
     setcookie("gREMOTELOGINSESSION", "", time() - 3600, "/");
     $loginSession = isset($_COOKIE["gLOGINSESSION"]) ? $_COOKIE["gLOGINSESSION"] : "";
     $remoteLoginSession = isset($_COOKIE["gREMOTELOGINSESSION"]) ? $_COOKIE["gREMOTELOGINSESSION"] : "";
     return true;
 }
예제 #2
0
 private function _SetLogin($pUserID, $pRemember = false)
 {
     $sessionModel = new cModel("UserSessions");
     // Delete current session id's.
     $criteria = array("Account_FK" => $pUserID);
     $sessionModel->Delete($criteria);
     // Create a unique session identifier.
     $identifier = md5(uniqid(rand(), true));
     // Set the session database information.
     $sessionModel->Protect("Session_PK");
     $sessionModel->Set("Account_FK", $pUserID);
     $sessionModel->Set("Identifier", $identifier);
     $sessionModel->Set("Stamp", NOW());
     $sessionModel->Set("Address", $_SERVER['REMOTE_ADDR']);
     $sessionModel->Set("Host", $_SERVER['REMOTE_HOST']);
     $sessionModel->Save();
     // If "Remember" is selected, set a faux-permanent cookie (1 year).
     if ($pRemember) {
         $time = time() + 60 * 60 * 24 * 365;
     } else {
         $time = 0;
     }
     // Set the cookie
     if (!setcookie("gLOGINSESSION", $identifier, $time, '/')) {
         // @todo Set error that we couldn't set the cookie.
         return false;
     }
     return true;
 }
예제 #3
0
 public function _FriendRemove($pAccount, $pRequest)
 {
     $userModel = new cModel('UserAccounts');
     $userModel->Structure();
     $friendModel = new cModel('FriendInformation');
     $friendModel->Structure();
     list($requestUsername, $requestDomain) = explode('@', $pRequest);
     list($accountUsername, $accountDomain) = explode('@', $pAccount);
     $userModel->Retrieve(array('Username' => $requestUsername));
     $userModel->Fetch();
     $requestUsername_uID = $userModel->Get('Account_PK');
     if (!$requestUsername_uID) {
         return false;
     }
     $friendModel->Retrieve(array('Owner_FK' => $requestUsername_uID, 'Username' => $accountUsername, 'Domain' => $accountDomain));
     if ($friendModel->Get('Total') > 0) {
         // Record found, so approve it.
         $friendModel->Fetch();
         $friendModel->Delete();
         return true;
     } else {
         // Record doesn't exist, so just return true;
         return true;
     }
 }