Example #1
0
 function create(&$user_info, $username)
 {
     global $dataDir, $langmessage;
     //update the session files to .php files
     //changes to $userinfo will be saved by UpdateAttempts() below
     $user_info = gpsession::SetSessionFileName($user_info, $username);
     $user_file_name = $user_info['file_name'];
     $user_file = $dataDir . '/data/_sessions/' . $user_file_name;
     //use an existing session_id if the new login matches an existing session (uid and file_name)
     $sessions = gpsession::GetSessionIds();
     $uid = gpsession::auth_browseruid();
     $session_id = false;
     foreach ($sessions as $sess_temp_id => $sess_temp_info) {
         if (isset($sess_temp_info['uid']) && $sess_temp_info['uid'] == $uid && $sess_temp_info['file_name'] == $user_file_name) {
             $session_id = $sess_temp_id;
         }
     }
     //create a unique session id if needed
     if ($session_id === false) {
         do {
             $session_id = common::RandomString(40);
         } while (isset($sessions[$session_id]));
     }
     $expires = !isset($_POST['remember']);
     gpsession::cookie(gp_session_cookie, $session_id, $expires);
     //save session id
     $sessions[$session_id] = array();
     $sessions[$session_id]['file_name'] = $user_file_name;
     $sessions[$session_id]['uid'] = $uid;
     //$sessions[$session_id]['time'] = time(); //for session locking
     if (!gpsession::SaveSessionIds($sessions)) {
         return false;
     }
     //make sure the user's file exists
     $new_data = gpsession::SessionData($user_file, $checksum);
     $new_data['username'] = $username;
     $new_data['granted'] = $user_info['granted'];
     admin_tools::EditingValue($new_data);
     gpFiles::SaveArray($user_file, 'gpAdmin', $new_data);
     return $session_id;
 }
Example #2
0
 function GetUsers()
 {
     $this->users = gpFiles::Get('_site/users');
     //fix the editing value
     foreach ($this->users as $username => $userinfo) {
         $userinfo += array('granted' => '');
         admin_tools::EditingValue($userinfo);
         $this->users[$username] = $userinfo;
     }
 }
Example #3
0
 function GetUsers()
 {
     global $dataDir;
     require $dataDir . '/data/_site/users.php';
     $this->users = $users;
     //fix the editing value
     foreach ($this->users as $username => $userinfo) {
         $userinfo += array('granted' => '');
         admin_tools::EditingValue($userinfo);
         $this->users[$username] = $userinfo;
     }
 }