Esempio n. 1
0
 public function auth()
 {
     $this->load->model('Management/UsersManagement');
     $this->load->model('entities/admin');
     $admin = new Admin();
     $admin->email = $this->input->post('email');
     $admin->password = $this->input->post('password');
     if (UsersManagement::login($admin)) {
         $user_data = array('email' => $admin->email);
         $this->session->set_userdata($user_data);
         redirect(base_url() . "panel", "location");
         return;
     } else {
         echo 'Vous êtes mauvais!';
     }
 }
Esempio n. 2
0
 public static function userCanChangeHisPassword($login, $lostKey, $lostTime)
 {
     # Verify if the login exists
     $db = DbUtil::accessFactory();
     $login = urldecode($login);
     $login = $db->db_escape_string($login);
     $lostKey = $db->db_escape_string($lostKey);
     $lostTime = $db->db_escape_string($lostTime);
     $userId = UsersManagement::getUserIdByLogin($login);
     # If login exists fill db with lost key and timestamp
     if ($userId !== null) {
         $currentTime = time();
         $thresholdHour = VALIDE_LOST_KEY_PERIOD;
         # 2h
         $threshold = 3600 * $thresholdHour;
         # number of seconde
         # Store the state
         $rs = $db->select('SELECT * FROM `users` WHERE `id` = \'' . $userId . '\' AND `lostKey` = \'' . $lostKey . '\' AND `lostTime` = \'' . $lostTime . '\'');
         //			var_dump($rs->count());
         //			var_dump($threshold);
         //			var_dump($currentTime - $lostTime);
         if ($rs->count() == 1) {
             if ($currentTime - $lostTime < $threshold) {
                 return true;
             } else {
                 return -1;
             }
             # -1 means that the time is over
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Esempio n. 3
0
 public static function retrieveUsers()
 {
     $usernames = array();
     $users = UsersManagement::retrieveUsers('cop1');
     foreach ($users as $user) {
         if ($user['is_anonymous'] != 1) {
             $usernames[] = $user['username'];
         }
     }
     sort($usernames);
     var_dump($usernames);
 }
 public function addDefaultWidget($username)
 {
     $userId = UsersManagement::getUserIdByLogin($username);
     WidgetSpace::loadWidgetSpace($userId, DEFAULT_WIDGET_SPACE_ON_SIGNIN);
 }
 public static function addAnonymousUser()
 {
     do {
         # Create a new random user
         $suffix = '';
         for ($i = 0; $i < 8; $i++) {
             $suffix .= chr(ord('a') + rand(0, 25));
         }
         $password = $suffix;
         $login = ANONYMOUS_PREFIX . $suffix;
     } while (self::getUserIdByLogin($login) === false);
     #Check if this user exist
     # Add user as an anonymous user
     UsersManagement::addUser(array('username' => $login, 'password' => $suffix, 'confirm_password' => $suffix, 'openid' => '', 'rights' => 0, 'copname' => 'cop1'), true, 1);
     # Add ui for the new anonymous account
     $userId = self::getUserIdByLogin($login);
     WidgetSpace::loadWidgetSpace($userId, DEFAULT_WIDGET_SPACE_ON_SIGNIN);
     return array('login' => $login, 'password' => $password);
 }
 public function deleteAction($userId)
 {
     if (Auth::isAuth() && (Auth::isAdmin() || Auth::isGod())) {
         UsersManagement::deleteUser($userId);
         $_SESSION['isError'] = false;
         $_SESSION['message'] = __('The user has been successfuly removed from the portal.');
         DefaultFC::redirection('adminUsers/index');
     } else {
         redirect('users/index');
     }
 }