Beispiel #1
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;
 }
 public function _FriendAdd($pAccount, $pRequest)
 {
     $userModel = new cModel('UserAccounts');
     $userModel->Structure();
     $profileModel = new cModel('UserProfile');
     $profileModel->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));
     $profileModel->Retrieve(array('Account_FK' => $requestUsername_uID));
     $profileModel->Fetch();
     $data = array('Email' => $userModel->Get('Email'), 'Recipient' => $pRequest, 'Sender' => $pAccount);
     $this->GetSys('Components')->Talk('Friends', 'NotifyAdd', $data);
     if ($friendModel->Get('Total') == 0) {
         // No record found, so create one.
         $friendModel->Protect('Friend_PK');
         $friendModel->Set('Owner_FK', $requestUsername_uID);
         $friendModel->Set('Username', $accountUsername);
         $friendModel->Set('Domain', $accountDomain);
         $friendModel->Set('Verification', 2);
         $friendModel->Set('Created', NOW());
         $friendModel->Set('Updated', NOW());
         $friendModel->Save();
         return true;
     } else {
         // Record already exists, so just return true;
         return true;
     }
 }