public function __construct()
 {
     parent::__construct();
     $oUser = new UserCore();
     $oUserModel = new UserCoreModel();
     $oExistsModel = new ExistsCoreModel();
     $oValidate = new Validate();
     $aUserData = json_decode($this->file->getFile('http://api.randomuser.me/?results=' . $this->httpRequest->post('num')), true);
     foreach ($aUserData['results'] as $aUser) {
         $aUser = $aUser['user'];
         $sEmail = trim($aUser['email']);
         $sUsername = trim($aUser['username']);
         if ($oValidate->email($sEmail) && !$oExistsModel->email($sEmail) && $oValidate->username($sUsername)) {
             $aData['username'] = $sUsername;
             $aData['email'] = $sEmail;
             $aData['first_name'] = $aUser['name']['first'];
             $aData['last_name'] = $aUser['name']['last'];
             $aData['password'] = $aUser['password'];
             $aData['sex'] = $aUser['gender'];
             $aData['match_sex'] = array($oUser->getMatchSex($aData['sex']));
             $aData['country'] = 'US';
             $aData['city'] = $aUser['location']['city'];
             $aData['state'] = $aUser['location']['state'];
             $aData['zip_code'] = $aUser['location']['zip'];
             $aData['birth_date'] = $this->dateTime->get($aUser['dob'])->date('Y-m-d');
             $aData['avatar'] = $aUser['picture']['large'];
             $aData['ip'] = Ip::get();
             $aData['profile_id'] = $oUserModel->add(escape($aData, true));
             $this->_addAvatar($aData, $oUser);
         }
     }
     unset($oUser, $oUserModel, $oExistsModel, $oValidate, $aUser, $aData, $aUserData);
     \PFBC\Form::setSuccess('form_add_fake_profiles', t('Users has been successfully added.'));
 }
 public function __construct()
 {
     parent::__construct();
     $oValidate = new Validate();
     $oAdminModel = new AdminModel();
     // Prohibit other administrators to edit the Root Administrator (ID 1)
     $iProfileId = $this->httpRequest->getExists('profile_id') && $this->httpRequest->get('profile_id', 'int') !== 1 ? $this->httpRequest->get('profile_id', 'int') : $this->session->get('admin_id');
     $oAdmin = $oAdminModel->readProfile($iProfileId, 'Admins');
     if (!$this->str->equals($this->httpRequest->post('username'), $oAdmin->username)) {
         $iMinUsernameLength = DbConfig::getSetting('minUsernameLength');
         $iMaxUsernameLength = DbConfig::getSetting('maxUsernameLength');
         if (!$oValidate->username($this->httpRequest->post('username'), $iMinUsernameLength, $iMaxUsernameLength)) {
             \PFBC\Form::setError('form_admin_edit_account', t('Your username has to contain from %0% to %1% characters, your username is not available or your username already used by other admin.', $iMinUsernameLength, $iMaxUsernameLength));
             $this->bIsErr = true;
         } else {
             $oAdminModel->updateProfile('username', $this->httpRequest->post('username'), $iProfileId, 'Admins');
             $this->session->set('admin_username', $this->httpRequest->post('username'));
             (new Framework\Cache\Cache())->start(UserCoreModel::CACHE_GROUP, 'username' . $iProfileId . 'Admins', null)->clear();
         }
     }
     if (!$this->str->equals($this->httpRequest->post('mail'), $oAdmin->email)) {
         if ((new ExistsCoreModel())->email($this->httpRequest->post('mail'))) {
             \PFBC\Form::setError('form_admin_edit_account', t('Invalid email address or this email is already used by another admin.'));
             $this->bIsErr = true;
         } else {
             $oAdminModel->updateProfile('email', $this->httpRequest->post('mail'), $iProfileId, 'Admins');
             $this->session->set('admin_email', $this->httpRequest->post('mail'));
         }
     }
     if (!$this->str->equals($this->httpRequest->post('first_name'), $oAdmin->firstName)) {
         $oAdminModel->updateProfile('firstName', $this->httpRequest->post('first_name'), $iProfileId, 'Admins');
         $this->session->set('admin_first_name', $this->httpRequest->post('first_name'));
         (new Framework\Cache\Cache())->start(UserCoreModel::CACHE_GROUP, 'firstName' . $iProfileId . 'Admins', null)->clear();
     }
     if (!$this->str->equals($this->httpRequest->post('last_name'), $oAdmin->lastName)) {
         $oAdminModel->updateProfile('lastName', $this->httpRequest->post('last_name'), $iProfileId, 'Admins');
     }
     if (!$this->str->equals($this->httpRequest->post('sex'), $oAdmin->sex)) {
         $oAdminModel->updateProfile('sex', $this->httpRequest->post('sex'), $iProfileId, 'Admins');
         (new Framework\Cache\Cache())->start(UserCoreModel::CACHE_GROUP, 'sex' . $iProfileId . 'Admins', null)->clear();
     }
     if (!$this->str->equals($this->httpRequest->post('time_zone'), $oAdmin->timeZone)) {
         $oAdminModel->updateProfile('timeZone', $this->httpRequest->post('time_zone'), $iProfileId, 'Admins');
     }
     $oAdminModel->setLastEdit($iProfileId, 'Admins');
     unset($oValidate, $oAdminModel, $oAdmin);
     (new Admin())->clearReadProfileCache($iProfileId, 'Admins');
     if (!$this->bIsErr) {
         \PFBC\Form::setSuccess('form_admin_edit_account', t('Your profile has been saved successfully!'));
     }
 }