Ejemplo n.º 1
0
 public static function display()
 {
     $oUserModel = new UserCoreModel();
     $iProfileId = (int) (new Session())->get('member_id');
     if (isset($_POST['submit_privacy_account'])) {
         if (\PFBC\Form::isValid($_POST['submit_privacy_account'])) {
             new PrivacyFormProcess($iProfileId, $oUserModel);
         }
         Framework\Url\Header::redirect();
     }
     $oPrivacy = $oUserModel->getPrivacySetting($iProfileId);
     $oForm = new \PFBC\Form('form_privacy_account', 500);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_privacy_account', 'form_privacy_account'));
     $oForm->addElement(new \PFBC\Element\Token('privacy_account'));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Profile:') . '</u></h3>'));
     $oForm->addElement(new \PFBC\Element\Radio(t('Who can view your profile?'), 'privacy_profile', array('all' => t('Everyone (including people who are not %0% members).', Registry::getInstance()->site_name), 'only_members' => t('Only %0% members who are logged in.', Registry::getInstance()->site_name), 'only_me' => t('Only me.')), array('value' => $oPrivacy->privacyProfile, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Web search engine:') . '</u></h3>'));
     $oForm->addElement(new \PFBC\Element\Radio(t('Do you want to be included in search results?'), 'search_profile', array('yes' => t("Yes, include my profile in search results (%site_name%'s search, Google, Bing, Yahoo, etc.)."), 'no' => t('No, do not include my profile in search results.')), array('value' => $oPrivacy->searchProfile, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Show profile visitors:') . '</u></h3>'));
     $oForm->addElement(new \PFBC\Element\Radio(t('Do you want display members who viewed your profile?'), 'user_save_views', array('yes' => t('Yes, display members who viewed my profile (Selecting this option will allow other members to see that you visited their profile).'), 'no' => t('No, don\'t display members who viewed my profile. (Selecting this option will prevent you from seeing who visited your profile).')), array('value' => $oPrivacy->userSaveViews, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Presence:') . '</u></h3>'));
     $oForm->addElement(new \PFBC\Element\Select(t('Your status'), 'user_status', array('1' => t('Online'), '2' => t('Busy'), '3' => t('Away'), '0' => 'Offline'), array('id' => 'status', 'onchange' => 'init_status()', 'value' => $oUserModel->getUserStatus($iProfileId), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<div class="user_status right" id="status_div"></div>'));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script>$(function(){ init_status() });</script>'));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
 public function __construct($sTable)
 {
     parent::__construct();
     $oUserModel = new UserCoreModel();
     $sMail = $this->httpRequest->post('mail');
     if (!($iProfileId = $oUserModel->getId($sMail, null, $sTable))) {
         sleep(1);
         // Security against brute-force attack to avoid drowning the server and the database
         \PFBC\Form::setError('form_forgot_password', t('Oops, this "%0%" is not associated with any %site_name% account. Please, make sure that you entered the e-mail address used in creating your account.', escape(substr($sMail, 0, PH7_MAX_EMAIL_LENGTH))));
     } else {
         $oUserModel->setNewHashValidation($iProfileId, Various::genRnd(), $sTable);
         (new UserCore())->clearReadProfileCache($iProfileId, $sTable);
         // Clean the profile data (for the new hash)
         $oData = $oUserModel->readProfile($iProfileId, $sTable);
         /** We place the text outside of Uri::get() otherwise special characters will be deleted and the parameters passed in the url will be unusable thereafter. **/
         $sResetUrl = Uri::get('lost-password', 'main', 'reset', $this->httpRequest->get('mod')) . PH7_SH . $oData->email . PH7_SH . $oData->hashValidation;
         $this->view->content = t('Hello %0%!<br />Somebody (from the IP address %1%) has requested a new password for their account.', $oData->username, Ip::get()) . '<br />' . t('If you requested for this, click on the link below, otherwise ignore this email and your password will remain unchanged.') . '<br /><a href="' . $sResetUrl . '">' . $sResetUrl . '</a>';
         $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_TPL_NAME . '/mail/sys/mod/lost-password/confirm-lost-password.tpl', $oData->email);
         $aInfo = ['to' => $oData->email, 'subject' => t('Request for new password - %site_name%')];
         unset($oData);
         if (!(new Mail())->send($aInfo, $sMessageHtml)) {
             \PFBC\Form::setError('form_forgot_password', Form::errorSendingEmail());
         } else {
             \PFBC\Form::setSuccess('form_forgot_password', t('Successfully requested a new password, email sent!'));
         }
     }
     unset($oUserModel);
 }
 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();
     $oUserModel = new UserCoreModel();
     $oSecurityModel = new SecurityModel();
     $sEmail = $this->httpRequest->post('mail');
     $sPassword = $this->httpRequest->post('password');
     /** Check if the connection is not locked **/
     $bIsLoginAttempt = (bool) DbConfig::getSetting('isUserLoginAttempt');
     $iMaxAttempts = (int) DbConfig::getSetting('maxUserLoginAttempts');
     $iTimeDelay = (int) DbConfig::getSetting('loginUserAttemptTime');
     if ($bIsLoginAttempt && !$oSecurityModel->checkLoginAttempt($iMaxAttempts, $iTimeDelay, $sEmail, $this->view)) {
         \PFBC\Form::setError('form_login_user', Form::loginAttemptsExceededMsg($iTimeDelay));
         return;
         // Stop execution of the method.
     }
     // Check Login
     $sLogin = $oUserModel->login($sEmail, $sPassword);
     if ($sLogin === 'email_does_not_exist' || $sLogin === 'password_does_not_exist') {
         sleep(1);
         // Security against brute-force attack to avoid drowning the server and the database
         if ($sLogin === 'email_does_not_exist') {
             $this->session->set('captcha_enabled', 1);
             // Enable Captcha
             \PFBC\Form::setError('form_login_user', t('Oops! "%0%" is not associated with any %site_name% account.', escape(substr($sEmail, 0, PH7_MAX_EMAIL_LENGTH))));
             $oSecurityModel->addLoginLog($sEmail, 'Guest', 'No Password', 'Failed! Incorrect Username');
         } elseif ($sLogin === 'password_does_not_exist') {
             $oSecurityModel->addLoginLog($sEmail, 'Guest', $sPassword, 'Failed! Incorrect Password');
             if ($bIsLoginAttempt) {
                 $oSecurityModel->addLoginAttempt();
             }
             $this->session->set('captcha_enabled', 1);
             // Enable Captcha
             $sWrongPwdTxt = t('Oops! This password you entered is incorrect.') . '<br />';
             $sWrongPwdTxt .= t('Please try again (make sure your caps lock is off).') . '<br />';
             $sWrongPwdTxt .= t('Forgot your password? <a href="%0%">Request a new one</a>.', Uri::get('lost-password', 'main', 'forgot', 'user'));
             \PFBC\Form::setError('form_login_user', $sWrongPwdTxt);
         }
     } else {
         $oSecurityModel->clearLoginAttempts();
         $this->session->remove('captcha_enabled');
         $iId = $oUserModel->getId($sEmail);
         $oUserData = $oUserModel->readProfile($iId);
         if ($this->httpRequest->postExists('remember')) {
             // We hash again the password
             (new Framework\Cookie\Cookie())->set(array('member_remember' => Security::hashCookie($oUserData->password), 'member_id' => $oUserData->profileId));
         }
         $oUser = new UserCore();
         if (true !== ($mStatus = $oUser->checkAccountStatus($oUserData))) {
             \PFBC\Form::setError('form_login_user', $mStatus);
         } else {
             $oUser->setAuth($oUserData, $oUserModel, $this->session);
             Header::redirect(Uri::get('user', 'account', 'index'), t('You are successfully logged!'));
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Set an user authentication.
  *
  * @param integer $iId
  * @param object \PH7\UserCoreModel $oUserModel
  * @return void
  */
 public function setLogin($iId, UserCoreModel $oUserModel)
 {
     $oUserData = $oUserModel->readProfile($iId);
     $oUser = new UserCore();
     if (true === ($sErrMsg = $oUser->checkAccountStatus($oUserData))) {
         $oUser->setAuth($oUserData, $oUserModel, new Framework\Session\Session());
     }
     unset($oUser, $oUserModel);
     true !== $sErrMsg ? $this->oDesign->setFlashMsg($sErrMsg) : t('Hi %0%, welcome to %site_name%', '<em>' . $oUserData->firstName . '</em>');
 }
Ejemplo n.º 6
0
 /**
  * @param array $aProfile
  * @param object \PH7\UserCoreModel $oUserModel
  * @return void
  */
 public function add(array $aProfile, UserCoreModel $oUserModel)
 {
     $sBirthDate = !empty($aProfile['birthday']) ? $aProfile['birthday'] : date('m/d/Y', strtotime('-30 year'));
     $sSex = $aProfile['gender'] != 'male' && $aProfile['gender'] != 'female' && $aProfile['gender'] != 'couple' ? 'female' : $aProfile['gender'];
     // Default 'female'
     $sMatchSex = $sSex == 'male' ? 'female' : ($sSex == 'female' ? 'male' : 'couple');
     $this->_sUsername = (new UserCore())->findUsername($aProfile['given_name'], $aProfile['name'], $aProfile['family_name']);
     $this->_aUserInfo = ['email' => $aProfile['email'], 'username' => $this->_sUsername, 'password' => Various::genRndWord(8, 30), 'first_name' => !empty($aProfile['given_name']) ? $aProfile['given_name'] : '', 'last_name' => !empty($aProfile['family_name']) ? $aProfile['family_name'] : '', 'sex' => $sSex, 'match_sex' => array($sMatchSex), 'birth_date' => (new CDateTime())->get($sBirthDate)->date('Y-m-d'), 'country' => Geo::getCountryCode(), 'city' => Geo::getCity(), 'state' => Geo::getState(), 'zip_code' => Geo::getZipCode(), 'description' => !empty($aProfile['bio']) ? $aProfile['bio'] : '', 'website' => '', 'social_network_site' => $aProfile['link'], 'ip' => Ip::get(), 'prefix_salt' => Various::genRnd(), 'suffix_salt' => Various::genRnd(), 'hash_validation' => Various::genRnd(), 'is_active' => DbConfig::getSetting('userActivationType')];
     $this->_iProfileId = $oUserModel->add($this->_aUserInfo);
 }
Ejemplo n.º 7
0
 /**
  * @param object $oProfile
  * @param object \PH7\UserCoreModel $oUserModel
  * @return void
  */
 public function add($oProfile, UserCoreModel $oUserModel)
 {
     $sBirthDate = isset($oProfile->birth_month, $oProfile->birth_day, $oProfile->birth_year) ? $oProfile->birth_month . '/' . $oProfile->birth_day . '/' . $oProfile->birth_year : date('m/d/Y', strtotime('-30 year'));
     $sSex = $oProfile->gender != 'male' && $oProfile->gender != 'female' && $oProfile->gender != 'couple' ? 'female' : $oProfile->gender;
     // Default 'female'
     $sMatchSex = $sSex == 'male' ? 'female' : ($sSex == 'female' ? 'male' : 'couple');
     $this->_sUsername = (new UserCore())->findUsername($oProfile->name, $oProfile->first_name, $oProfile->last_name);
     $this->_aUserInfo = ['email' => $oProfile->emails->account, 'username' => $this->_sUsername, 'password' => Various::genRndWord(8, 30), 'first_name' => !empty($oProfile->first_name) ? $oProfile->first_name : '', 'last_name' => !empty($oProfile->last_name) ? $oProfile->last_name : '', 'sex' => $sSex, 'match_sex' => array($sMatchSex), 'birth_date' => (new CDateTime())->get($sBirthDate)->date('Y-m-d'), 'country' => Geo::getCountryCode(), 'city' => Geo::getCity(), 'state' => Geo::getState(), 'zip_code' => Geo::getZipCode(), 'description' => '', 'website' => '', 'social_network_site' => '', 'ip' => Ip::get(), 'prefix_salt' => Various::genRnd(), 'suffix_salt' => Various::genRnd(), 'hash_validation' => Various::genRnd(), 'is_active' => DbConfig::getSetting('userActivationType')];
     $this->_iProfileId = $oUserModel->add($this->_aUserInfo);
 }
Ejemplo n.º 8
0
 /**
  * @param array $aProfile
  * @param object \PH7\UserCoreModel $oUserModel
  * @return void
  */
 public function add(array $aProfile, UserCoreModel $oUserModel)
 {
     $oUser = new UserCore();
     $sBirthDate = !empty($aProfile['birthday']) ? $aProfile['birthday'] : date('m/d/Y', strtotime('-30 year'));
     $sLocation = !empty($aProfile['location']['name']) ? $aProfile['location']['name'] : (!empty($aProfile['hometown']['name']) ? $aProfile['hometown']['name'] : '');
     $aLocation = @explode(',', $sLocation);
     $sSex = $aProfile['gender'] != 'male' && $aProfile['gender'] != 'female' && $aProfile['gender'] != 'couple' ? 'female' : $aProfile['gender'];
     // Default 'female'
     $sMatchSex = $oUser->getMatchSex($sSex);
     $this->_sUsername = $oUser->findUsername($aProfile['username'], $aProfile['first_name'], $aProfile['last_name']);
     $sSite = !empty($aProfile['link']) ? explode(' ', $aProfile['link'])[0] : '';
     $sSocialNetworkSite = !empty($aProfile['username']) ? 'http://facebook.com/' . $aProfile['username'] : '';
     unset($oUser);
     $this->_aUserInfo = ['email' => $aProfile['email'], 'username' => $this->_sUsername, 'password' => Various::genRndWord(8, 30), 'first_name' => !empty($aProfile['first_name']) ? $aProfile['first_name'] : '', 'last_name' => !empty($aProfile['last_name']) ? $aProfile['last_name'] : '', 'middle_name' => !empty($aProfile['middle_name']) ? $aProfile['middle_name'] : '', 'sex' => $sSex, 'match_sex' => array($sMatchSex), 'birth_date' => (new CDateTime())->get($sBirthDate)->date('Y-m-d'), 'country' => !empty($aLocation[1]) ? trim($aLocation[1]) : Geo::getCountryCode(), 'city' => !empty($aLocation[0]) ? trim($aLocation[0]) : Geo::getCity(), 'state' => !empty($aProfile['locale']) ? $aProfile['locale'] : Geo::getState(), 'zip_code' => !empty($aProfile['hometown_location']['zip']) ? $aProfile['hometown_location']['zip'] : Geo::getZipCode(), 'description' => !empty($aProfile['bio']) ? $aProfile['bio'] : '', 'website' => $sSite, 'social_network_site' => $sSocialNetworkSite, 'ip' => Ip::get(), 'prefix_salt' => Various::genRnd(), 'suffix_salt' => Various::genRnd(), 'hash_validation' => Various::genRnd(), 'is_active' => DbConfig::getSetting('userActivationType')];
     $this->_iProfileId = $oUserModel->add($this->_aUserInfo);
 }
Ejemplo n.º 9
0
 /**
  * Add the fields in the database
  *
  * @param array $aData The data to  add
  * @return object this
  */
 public function add(array $aData)
 {
     $this->_mStatus = (new ReportModel())->add($aData);
     if ($this->_mStatus == true) {
         if (DbConfig::getSetting('sendReportMail')) {
             $oUser = new UserCore();
             $oUserModel = new UserCoreModel();
             $sReporterUsername = $oUserModel->getUsername($aData['reporter_id']);
             $sSpammerUsername = $oUserModel->getUsername($aData['spammer_id']);
             $sDate = (new CDateTime())->get($aData['date'])->dateTime();
             $this->_oView->content = t('Reporter:') . ' <b><a href="' . $oUser->getProfileLink($sReporterUsername) . '">' . $sReporterUsername . '</a></b><br /><br /> ' . t('Spammer:') . ' <b><a href="' . $oUser->getProfileLink($sSpammerUsername) . '">' . $sSpammerUsername . '</a></b><br /><br /> ' . t('Contant Type:') . ' <b>' . $aData['type'] . '</b><br /><br /> ' . t('URL:') . ' <b>' . $aData['url'] . '</b><br /><br /> ' . t('Description of report:') . ' <b>' . $aData['desc'] . '</b><br /><br /> ' . t('Date:') . ' <b>' . $sDate . '</b><br /><br />';
             unset($oUser, $oUserModel);
             $sMessageHtml = $this->_oView->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_TPL_NAME . '/mail/sys/mod/report/abuse.tpl', DbConfig::getSetting('adminEmail'));
             $aInfo = ['subject' => t('Spam report from %site_name%')];
             (new Mail())->send($aInfo, $sMessageHtml);
         }
     }
     return $this;
 }
 public static function display()
 {
     $oUserModel = new UserCoreModel();
     $iProfileId = (int) (new Session())->get('member_id');
     if (isset($_POST['submit_notification'])) {
         if (\PFBC\Form::isValid($_POST['submit_notification'])) {
             new NotificationFormProcess($iProfileId, $oUserModel);
         }
         Framework\Url\Header::redirect();
     }
     $oNotification = $oUserModel->getNotification($iProfileId);
     $oForm = new \PFBC\Form('form_notification', 650);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_notification', 'form_notification'));
     $oForm->addElement(new \PFBC\Element\Token('notification'));
     $oForm->addElement(new \PFBC\Element\Select(t('Newsletters'), 'enable_newsletters', array('1' => t('Enable'), '0' => t('Disable')), array('description' => t('By enabling this option, you would be likely to receive occasional news on our website and our services and offers, promotions and other benefits to our partners.'), 'value' => $oNotification->enableNewsletters, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Message'), 'new_msg', array('1' => t('Yes'), '0' => t('No')), array('value' => $oNotification->newMsg, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Friend requests'), 'friend_request', array('1' => t('Yes'), '0' => t('No')), array('value' => $oNotification->friendRequest, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
 /**
  * If a user is logged, get "approximately" the relative age for better and more intuitive search.
  *
  * @param object \PH7\UserCoreModel $oUserModel
  * @param object \PH7\Framework\Session\Session $oSession
  * @return array 'min_age' and 'max_age' which is the approximately age the user is looking for.
  */
 protected static function getAgeVals(UserCoreModel $oUserModel, Session $oSession)
 {
     $iMinAge = (int) DbConfig::getSetting('minAgeRegistration');
     $iMaxAge = (int) DbConfig::getSetting('maxAgeRegistration');
     if (UserCore::auth()) {
         $sBirthDate = $oUserModel->getBirthDate($oSession->get('member_id'));
         $aAge = explode('-', $sBirthDate);
         $iAge = (new Year($aAge[0], $aAge[1], $aAge[2]))->get();
         $iMinAge = $iAge - 5 < $iMinAge ? $iMinAge : $iAge - 5;
         $iMaxAge = $iAge + 5 > $iMaxAge ? $iMaxAge : $iAge + 5;
     }
     return ['min_age' => $iMinAge, 'max_age' => $iMaxAge];
 }
 public function __construct()
 {
     parent::__construct();
     $oUserModel = new UserCoreModel();
     $oMailModel = new MailModel();
     $bIsAdmin = AdminCore::auth() && !UserCore::auth() && !$this->session->exists('login_user_as');
     $sMessage = $this->httpRequest->post('message', Http::ONLY_XSS_CLEAN);
     $sCurrentTime = $this->dateTime->get()->dateTime('Y-m-d H:i:s');
     $iTimeDelay = (int) DbConfig::getSetting('timeDelaySendMail');
     $sRecipient = $this->httpRequest->post('recipient');
     $iRecipientId = $oUserModel->getId(null, $sRecipient);
     $iSenderId = (int) ($bIsAdmin ? PH7_ADMIN_ID : $this->session->get('member_id'));
     if ($iSenderId == $iRecipientId) {
         \PFBC\Form::setError('form_compose_mail', t('Oops! You can not send a message to yourself.'));
     } elseif ($sRecipient == PH7_ADMIN_USERNAME) {
         \PFBC\Form::setError('form_compose_mail', t('Oops! You cannot reply to administrator! If you want to contact us, please use our <a href="%0%">contact form</a>.', Uri::get('contact', 'contact', 'index')));
     } elseif (!(new ExistsCoreModel())->id($iRecipientId, 'Members')) {
         \PFBC\Form::setError('form_compose_mail', t('Oops! The username "%0%" does not exist.', escape(substr($this->httpRequest->post('recipient'), 0, PH7_MAX_USERNAME_LENGTH), true)));
     } elseif (!$bIsAdmin && !$oMailModel->checkWaitSend($iSenderId, $iTimeDelay, $sCurrentTime)) {
         \PFBC\Form::setError('form_compose_mail', Form::waitWriteMsg($iTimeDelay));
     } elseif (!$bIsAdmin && $oMailModel->isDuplicateContent($iSenderId, $sMessage)) {
         \PFBC\Form::setError('form_compose_mail', Form::duplicateContentMsg());
     } else {
         $mSendMsg = $oMailModel->sendMsg($iSenderId, $iRecipientId, $this->httpRequest->post('title'), $sMessage, $sCurrentTime);
         if (false === $mSendMsg) {
             \PFBC\Form::setError('form_compose_mail', t('Problem while sending the message. Please try again later.'));
         } else {
             // If the notification is accepted and the message recipient isn't connected NOW, we send a message.
             if (!$oUserModel->isNotification($iRecipientId, 'newMsg') && $oUserModel->isOnline($iRecipientId, 0)) {
                 $this->view->content = t('Hello %0%!<br />You have received a new message from <strong>%1%</strong>.<br /> <a href="%2%">Click here</a> to read your message.', $this->httpRequest->post('recipient'), $this->session->get('member_username'), Uri::get('mail', 'main', 'inbox', $mSendMsg));
                 $sRecipientEmail = $oUserModel->getEmail($iRecipientId);
                 $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_TPL_NAME . '/mail/sys/mod/mail/new_msg.tpl', $sRecipientEmail);
                 $aInfo = ['to' => $sRecipientEmail, 'subject' => t('New private message from %0% on %site_name%', $this->session->get('member_first_name'))];
                 (new Mail())->send($aInfo, $sMessageHtml);
             }
             $sUrl = $bIsAdmin ? Uri::get(PH7_ADMIN_MOD, 'user', 'browse') : Uri::get('mail', 'main', 'index');
             Header::redirect($sUrl, t('Your message has been sent successfully!'));
         }
         unset($oUserModel, $oMailModel);
     }
 }
 public function __construct()
 {
     parent::__construct();
     $this->group = UserCoreModel::checkGroup();
 }
Ejemplo n.º 14
0
 protected function isOnline($sUsername)
 {
     $oUserModel = new UserCoreModel();
     $iProfileId = $oUserModel->getId(null, $sUsername);
     $bIsOnline = $oUserModel->isOnline($iProfileId, Framework\Mvc\Model\DbConfig::getSetting('userTimeout'));
     unset($oUserModel);
     return $bIsOnline;
 }
 public function __construct()
 {
     parent::__construct();
     $this->_aFile = $_FILES['csv_file'];
     $sExtFile = $this->file->getFileExt($this->_aFile['name']);
     $sDelimiter = $this->httpRequest->post('delimiter');
     $sEnDelimiter = $this->httpRequest->post('enclosure');
     if ($sExtFile != 'csv' && $sExtFile != 'txt') {
         $sErrMsg = static::ERR_BAD_FILE;
     } elseif (!($rHandler = @fopen($this->_aFile['tmp_name'], 'rb'))) {
         $sErrMsg = static::ERR_BAD_FILE;
     } elseif (!($aFileData = @fgetcsv($rHandler, 0, $sDelimiter, $sEnDelimiter)) || !is_array($aFileData)) {
         $sErrMsg = static::ERR_BAD_FILE;
     }
     if (!empty($sErrMsg) && $sErrMsg == static::ERR_BAD_FILE) {
         $this->_removeTmpFile();
         \PFBC\Form::setError('form_import_user', t('Wrong file! Please select a valid CSV file containing data members.'));
         return;
         // Stop execution of the method.
     }
     /**
      * Default value...
      */
     $aGenderList = ['male', 'female', 'couple'];
     $sFiveChars = Various::genRnd($this->_aFile['name'], 5);
     $aTmpData = ['email' => 'pierrehenrysoriasanz' . $sFiveChars . '@hizup' . $sFiveChars . '.com', 'username' => 'Hizup' . $sFiveChars, 'password' => Various::genRnd(), 'first_name' => 'Alex' . $sFiveChars, 'last_name' => 'Rolli' . $sFiveChars, 'sex' => $aGenderList[mt_rand(0, 2)], 'match_sex' => $aGenderList[mt_rand(0, 2)], 'birth_date' => date('Y') - mt_rand(20, 40) . '-' . mt_rand(1, 12) . '-' . mt_rand(1, 28), 'country' => 'US', 'city' => 'Virginia', 'state' => 'Doswell', 'zip_code' => '23047', 'description' => 'Hi all!<br />How are you today?<br /> Bye ;)', 'website' => '', 'social_network_site' => '', 'ip' => Ip::get()];
     foreach ($aFileData as $sKey => $sVal) {
         // Clean the text to make comparisons easier...
         $sVal = strtolower(trim(str_replace(array('-', '_', ' '), '', $sVal)));
         // Test comparisons of strings and adding values in an array "$aTmpData"
         if ($sVal == 'username' || $sVal == 'login' || $sVal == 'user' || $sVal == 'nickname') {
             $aTmpData['username'] = $sKey;
         }
         if ($sVal == 'name' || $sVal == 'firstname') {
             $aTmpData['first_name'] = $sKey;
         }
         if ($sVal == 'lastname' || $sVal == 'surname') {
             $aTmpData['last_name'] = $sKey;
         }
         if ($sVal == 'matchsex' || $sVal == 'looking' || $sVal == 'lookingfor') {
             $aTmpData['match_sex'] = $sKey;
         }
         if ($sVal == 'sex' || $sVal == 'gender') {
             $aTmpData['sex'] = $sKey;
         }
         if ($sVal == 'email' || $sVal == 'mail') {
             $aTmpData['email'] = $sKey;
         }
         if ($sVal == 'desc' || $sVal == 'description' || $sVal == 'descriptionme' || $sVal == 'generaldescription' || $sVal == 'about' || $sVal == 'aboutme' || $sVal == 'bio' || $sVal == 'biography' || $sVal == 'comment') {
             $aTmpData['description'] = $sKey;
         }
         if ($sVal == 'country' || $sVal == 'countryid') {
             $aTmpData['country'] = $sKey;
         }
         if ($sVal == 'city' || $sVal == 'town') {
             $aTmpData['city'] = $sKey;
         }
         if ($sVal == 'state' || $sVal == 'district' || $sVal == 'province' || $sVal == 'region') {
             $aTmpData['state'] = $sKey;
         }
         if ($sVal == 'zip' || $sVal == 'zipcode' || $sVal == 'postal' || $sVal == 'postalcode') {
             $aTmpData['zip_code'] = $sKey;
         }
         if ($sVal == 'website' || $sVal == 'site' || $sVal == 'url') {
             $aTmpData['website'] = $sKey;
         }
         if ($sVal == 'birthday' || $sVal == 'birthdate' || $sVal == 'dateofbirth') {
             $aTmpData['birth_date'] = $this->dateTime->get($sKey)->date('Y-m-d');
         }
     }
     $iRow = 0;
     $oUser = new UserCore();
     $oUserModel = new UserCoreModel();
     $oExistsModel = new ExistsCoreModel();
     $oValidate = new Validate();
     while (($aFileData = fgetcsv($rHandler, 0, $sDelimiter, $sEnDelimiter)) !== false) {
         $aData[$iRow] = $aTmpData;
         // Set data by the default contents
         $sEmail = trim($aFileData[$aTmpData['email']]);
         if ($oValidate->email($sEmail) && !$oExistsModel->email($sEmail)) {
             $sUsername = trim($aFileData[$aTmpData['username']]);
             $sFirstName = trim($aFileData[$aTmpData['first_name']]);
             $sLastName = trim($aFileData[$aTmpData['last_name']]);
             $aData[$iRow]['username'] = $oUser->findUsername($sUsername, $sFirstName, $sLastName);
             $aData[$iRow]['first_name'] = $sFirstName;
             $aData[$iRow]['last_name'] = $sLastName;
             $aData[$iRow]['sex'] = trim($aFileData[$aTmpData['sex']]);
             $aData[$iRow]['match_sex'] = array(trim($aFileData[$aTmpData['match_sex']]));
             $aData[$iRow]['email'] = $sEmail;
             $aData[$iRow]['description'] = trim($aFileData[$aTmpData['description']]);
             $aData[$iRow]['country'] = trim($aFileData[$aTmpData['country']]);
             $aData[$iRow]['city'] = trim($aFileData[$aTmpData['city']]);
             $aData[$iRow]['state'] = trim($aFileData[$aTmpData['state']]);
             $aData[$iRow]['zip_code'] = trim($aFileData[$aTmpData['zip_code']]);
             $aData[$iRow]['website'] = trim($aFileData[$aTmpData['website']]);
             $aData[$iRow]['birth_date'] = trim($aFileData[$aTmpData['birth_date']]);
             $oUserModel->add(escape($aData[$iRow], true));
             $iRow++;
         }
     }
     $this->_removeTmpFile();
     unset($oUser, $oUserModel, $oExistsModel, $oValidate, $aTmpData, $aData);
     fclose($rHandler);
     Header::redirect(Uri::get(PH7_ADMIN_MOD, 'user', 'browse'), nt('%n% User has been successfully added.', '%n% Users has been successfully added.', $iRow));
 }
Ejemplo n.º 16
0
 /**
  * @param array $aFiles
  * @param string $sDelimiter Delimiter Field delimiter (one character).
  * @param string $sEnclosure Enclosure Field enclosure (one character).
  * @return void
  */
 public function __construct(array $aFiles, $sDelimiter, $sEnclosure)
 {
     parent::__construct();
     $this->_aFile = $aFiles;
     $sExtFile = $this->file->getFileExt($this->_aFile['name']);
     if ($sExtFile != 'csv' && $sExtFile != 'txt') {
         $this->_iErrType = static::ERR_BAD_FILE;
     } elseif ($this->_aFile['error'] == UPLOAD_ERR_INI_SIZE) {
         $this->_iErrType = static::ERR_TOO_LARGE;
     } elseif (!($rHandler = @fopen($this->_aFile['tmp_name'], 'rb'))) {
         $this->_iErrType = static::ERR_INVALID;
     } elseif (!($this->_aFileData = @fgetcsv($rHandler, 0, $sDelimiter, $sEnclosure)) || !is_array($this->_aFileData)) {
         $this->_iErrType = static::ERR_INVALID;
     }
     if (!empty($this->_iErrType)) {
         $this->_removeTmpFile();
         $this->_aRes = ['status' => false, 'msg' => $this->getErrMsg()];
     } else {
         $this->setDefVals();
         foreach ($this->_aFileData as $sKey => $sVal) {
             // Clean the text to make comparisons easier...
             $sVal = strtolower(trim(str_replace(['-', '_', ' '], '', $sVal)));
             // Test comparisons of strings and adding values in an array "ImportUser::$_aTmpData"
             if ($sVal == 'username' || $sVal == 'login' || $sVal == 'user' || $sVal == 'nickname') {
                 $this->_aTmpData['username'] = $sKey;
             }
             if ($sVal == 'name' || $sVal == 'firstname' || $sVal == 'forname') {
                 $this->_aTmpData['first_name'] = $sKey;
             }
             if ($sVal == 'lastname' || $sVal == 'surname') {
                 $this->_aTmpData['last_name'] = $sKey;
             }
             if ($sVal == 'matchsex' || $sVal == 'looking' || $sVal == 'lookingfor') {
                 $this->_aTmpData['match_sex'] = $sKey;
             }
             if ($sVal == 'sex' || $sVal == 'gender') {
                 $this->_aTmpData['sex'] = $sKey;
             }
             if ($sVal == 'email' || $sVal == 'mail') {
                 $this->_aTmpData['email'] = $sKey;
             }
             if ($sVal == 'desc' || $sVal == 'description' || $sVal == 'descriptionme' || $sVal == 'generaldescription' || $sVal == 'about' || $sVal == 'aboutme' || $sVal == 'bio' || $sVal == 'biography' || $sVal == 'comment') {
                 $this->_aTmpData['description'] = $sKey;
             }
             if ($sVal == 'country' || $sVal == 'countryid') {
                 $this->_aTmpData['country'] = $sKey;
             }
             if ($sVal == 'city' || $sVal == 'town') {
                 $this->_aTmpData['city'] = $sKey;
             }
             if ($sVal == 'state' || $sVal == 'district' || $sVal == 'province' || $sVal == 'region') {
                 $this->_aTmpData['state'] = $sKey;
             }
             if ($sVal == 'zip' || $sVal == 'zipcode' || $sVal == 'postal' || $sVal == 'postalcode' || $sVal == 'eircode') {
                 $this->_aTmpData['zip_code'] = $sKey;
             }
             if ($sVal == 'website' || $sVal == 'site' || $sVal == 'url') {
                 $this->_aTmpData['website'] = $sKey;
             }
             if ($sVal == 'birthday' || $sVal == 'birthdate' || $sVal == 'dateofbirth') {
                 $this->_aTmpData['birth_date'] = $sKey;
             }
         }
         $iRow = 0;
         $oUserModel = new UserCoreModel();
         $oExistsModel = new ExistsCoreModel();
         $oValidate = new Validate();
         while (($this->_aFileData = fgetcsv($rHandler, 0, $sDelimiter, $sEnclosure)) !== false) {
             $sEmail = trim($this->_aFileData[$this->_aTmpData['email']]);
             if ($oValidate->email($sEmail) && !$oExistsModel->email($sEmail)) {
                 $this->setData($iRow);
                 $oUserModel->add(escape($this->_aData[$iRow], true));
                 $iRow++;
             }
         }
         $this->_removeTmpFile();
         fclose($rHandler);
         unset($rHandler, $oUserModel, $oExistsModel, $oValidate, $this->_aTmpData, $this->_aFileData, $this->_aData);
         $this->_aRes = ['status' => true, 'msg' => nt('%n% user has been successfully added.', '%n% users has been successfully added.', $iRow)];
     }
 }
Ejemplo n.º 17
0
 /**
  * Set a user authentication.
  *
  * @param object $oUserData User database object.
  * @param object \PH7\UserCoreModel $oUserModel
  * @param object \PH7\Framework\Session\Session $oSession
  * @return void
  */
 public function setAuth($oUserData, UserCoreModel $oUserModel, Session $oSession)
 {
     // Is disconnected if the user is logged on as "affiliate" or "administrator".
     if (AffiliateCore::auth() || AdminCore::auth()) {
         $oSession->destroy();
     }
     // Regenerate the session ID to prevent the session fixation
     $oSession->regenerateId();
     // Now we connect the member
     $aSessionData = ['member_id' => $oUserData->profileId, 'member_email' => $oUserData->email, 'member_username' => $oUserData->username, 'member_first_name' => $oUserData->firstName, 'member_sex' => $oUserData->sex, 'member_group_id' => $oUserData->groupId, 'member_ip' => Ip::get(), 'member_http_user_agent' => (new Browser())->getUserAgent(), 'member_token' => Various::genRnd($oUserData->email)];
     $oSession->set($aSessionData);
     (new Framework\Mvc\Model\Security())->addLoginLog($oUserData->email, $oUserData->username, '*****', 'Logged in!');
     $oUserModel->setLastActivity($oUserData->profileId);
     unset($oUserModel, $oUserData);
 }
Ejemplo n.º 18
0
 public function __construct()
 {
     parent::__construct();
     $this->_sQueryPath = __DIR__ . PH7_DS . PH7_QUERY;
 }