public function __construct()
 {
     parent::__construct();
     $oAffModel = new AffiliateModel();
     $oSecurityModel = new SecurityModel();
     $sEmail = $this->httpRequest->post('mail');
     $sPassword = $this->httpRequest->post('password');
     /** Check if the connection is not locked **/
     $bIsLoginAttempt = (bool) DbConfig::getSetting('isAffiliateLoginAttempt');
     $iMaxAttempts = (int) DbConfig::getSetting('maxAffiliateLoginAttempts');
     $iTimeDelay = (int) DbConfig::getSetting('loginAffiliateAttemptTime');
     if ($bIsLoginAttempt && !$oSecurityModel->checkLoginAttempt($iMaxAttempts, $iTimeDelay, $sEmail, $this->view, 'Affiliates')) {
         \PFBC\Form::setError('form_login_aff', Form::loginAttemptsExceededMsg($iTimeDelay));
         return;
         // Stop execution of the method.
     }
     // Check Login
     $sLogin = $oAffModel->login($sEmail, $sPassword, 'Affiliates');
     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_aff', 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', 'Affiliates');
         } elseif ($sLogin === 'password_does_not_exist') {
             $oSecurityModel->addLoginLog($sEmail, 'Guest', $sPassword, 'Failed! Incorrect Password', 'Affiliates');
             if ($bIsLoginAttempt) {
                 $oSecurityModel->addLoginAttempt('Affiliates');
             }
             $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', 'affiliate'));
             \PFBC\Form::setError('form_login_aff', $sWrongPwdTxt);
         }
     } else {
         $oSecurityModel->clearLoginAttempts('Affiliates');
         $this->session->remove('captcha_enabled');
         $iId = $oAffModel->getId($sEmail, null, 'Affiliates');
         $oAffData = $oAffModel->readProfile($iId, 'Affiliates');
         if (true !== ($mStatus = (new AffiliateCore())->checkAccountStatus($oAffData))) {
             \PFBC\Form::setError('form_login_aff', $mStatus);
         } else {
             // Is disconnected if the user is logged on as "user" or "administrator".
             if (UserCore::auth() || AdminCore::auth()) {
                 $this->session->destroy();
             }
             // Regenerate the session ID to prevent the session fixation
             $this->session->regenerateId();
             $aSessionData = ['affiliate_id' => $oAffData->profileId, 'affiliate_email' => $oAffData->email, 'affiliate_username' => $oAffData->username, 'affiliate_first_name' => $oAffData->firstName, 'affiliate_sex' => $oAffData->sex, 'affiliate_ip' => Ip::get(), 'affiliate_http_user_agent' => $this->browser->getUserAgent(), 'affiliate_token' => Various::genRnd($oAffData->email)];
             $this->session->set($aSessionData);
             $oSecurityModel->addLoginLog($oAffData->email, $oAffData->username, '*****', 'Logged in!', 'Affiliates');
             $oAffModel->setLastActivity($oAffData->profileId, 'Affiliates');
             Header::redirect(Uri::get('affiliate', 'account', 'index'), t('You are successfully logged!'));
         }
     }
 }
 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();
     $aData = ['email' => $this->httpRequest->post('mail'), 'username' => $this->httpRequest->post('username'), 'password' => $this->httpRequest->post('password'), 'first_name' => $this->httpRequest->post('first_name'), 'last_name' => $this->httpRequest->post('last_name'), 'sex' => $this->httpRequest->post('sex'), 'time_zone' => $this->httpRequest->post('time_zone'), 'ip' => Ip::get()];
     (new AdminModel())->add($aData);
     Header::redirect(Uri::get(PH7_ADMIN_MOD, 'admin', 'browse'), t('The administrator has been successfully added.'));
 }
 public function createAccount()
 {
     if ($this->oRest->getRequestMethod() != 'POST') {
         $this->oRest->response('', 406);
     } else {
         $aReqs = $this->oRest->getRequest();
         // Set the User Setting variables
         $iMinUsr = DbConfig::getSetting('minUsernameLength');
         $iMaxUsr = DbConfig::getSetting('maxUsernameLength');
         $iMinPwd = DbConfig::getSetting('minPasswordLength');
         $iMaxPwd = DbConfig::getSetting('maxPasswordLength');
         $iMinAge = DbConfig::getSetting('minAgeRegistration');
         $iMaxAge = DbConfig::getSetting('maxAgeRegistration');
         if (empty($aReqs['email']) || empty($aReqs['username']) || empty($aReqs['password']) || empty($aReqs['first_name']) || empty($aReqs['last_name']) || empty($aReqs['sex']) || empty($aReqs['match_sex']) || empty($aReqs['birth_date']) || empty($aReqs['country']) || empty($aReqs['city']) || empty($aReqs['state']) || empty($aReqs['zip_code']) || empty($aReqs['description'])) {
             $this->oRest->response($this->set(array('status' => 'failed', 'msg' => t('One or several profile fields are empty.'))), 400);
         } elseif (!$this->oValidate->email($aReqs['email'])) {
             $this->oRest->response($this->set(array('status' => 'form_error', 'msg' => t('The Email is not valid.'))), 400);
         } elseif (!$this->oValidate->username($aReqs['username'], $iMinUsr, $iMaxUsr)) {
             $this->oRest->response($this->set(array('status' => 'form_error', 'msg' => t('The Username must contain from %0% to %1% characters, the Username is not available or it is already used by other member.', $iMinUsr, $iMaxUsr))), 400);
         } elseif (!$this->oValidate->password($aReqs['password'], $iMinPwd, $iMaxPwd)) {
             $this->oRest->response($this->set(array('status' => 'form_error', 'msg' => t('The Password must contain from %0% to %1% characters.', $iMinPwd, $iMaxPwd))), 400);
         } elseif (!$this->oValidate->birthDate($aReqs['birth_date'], $iMinAge, $iMaxAge)) {
             $this->oRest->response($this->set(array('status' => 'form_error', 'msg' => t('You must be %0% to %1% years to register on the site.', $iMinAge, $iMinAge))), 400);
         } else {
             $aData = ['email' => $aReqs['email'], 'username' => $aReqs['username'], 'password' => $aReqs['password'], 'first_name' => $aReqs['first_name'], 'last_name' => $aReqs['last_name'], 'sex' => $aReqs['sex'], 'match_sex' => is_array($aReqs['match_sex']) ?: array($aReqs['match_sex']), 'birth_date' => $this->dateTime->get($aReqs['birth_date'])->date('Y-m-d'), 'country' => $aReqs['country'], 'city' => $aReqs['city'], 'state' => $aReqs['state'], 'zip_code' => $aReqs['zip_code'], 'description' => $aReqs['description'], 'ip' => Framework\Ip\Ip::get()];
             // Add 'profile_id' key into the array
             $aData['profile_id'] = $this->oUserModel->add($aData);
             // Displays the new user info and his ID
             $this->oRest->response($this->set($aData));
         }
     }
 }
 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);
 }
Пример #6
0
 public function step1()
 {
     $iAffId = (int) (new Cookie())->get(AffiliateCore::COOKIE_NAME);
     $sRef = $this->session->exists('joinRef') ? $this->session->get('joinRef') : t('No reference');
     // Statistics
     $this->session->remove('joinRef');
     $aData = ['email' => $this->httpRequest->post('mail'), 'username' => $this->httpRequest->post('username'), 'first_name' => $this->httpRequest->post('first_name'), 'reference' => $sRef, 'ip' => Ip::get(), 'hash_validation' => Various::genRnd(), 'current_date' => (new CDateTime())->get()->dateTime('Y-m-d H:i:s'), 'is_active' => $this->iActiveType, 'group_id' => (int) DbConfig::getSetting('defaultMembershipGroupId'), 'affiliated_id' => $iAffId];
     $aData += ['password' => Security::hashPwd($this->httpRequest->post('password'))];
     $iTimeDelay = (int) DbConfig::getSetting('timeDelayUserRegistration');
     if (!$this->oUserModel->checkWaitJoin($aData['ip'], $iTimeDelay, $aData['current_date'])) {
         \PFBC\Form::setError('form_join_user', Form::waitRegistrationMsg($iTimeDelay));
     } elseif (!$this->oUserModel->join($aData)) {
         \PFBC\Form::setError('form_join_user', t('An error occurred during registration!<br />
         Please try again with other information in the form fields or come back later.'));
     } else {
         // Successful registration in the database for step 1!
         /** Update the Affiliate Commission **/
         if ($this->iActiveType == 0) {
             // Only if the user's account is already activated.
             AffiliateCore::updateJoinCom($iAffId, $this->config, $this->registry);
         }
         // Send email
         $this->oRegistration->sendMail($aData);
         $this->session->set('mail_step1', $this->httpRequest->post('mail'));
         HeaderUrl::redirect(Uri::get('user', 'signup', 'step2'));
     }
 }
 /**
  * Parser for the System variables.
  *
  * @param string $sVar
  * @return The new parsed text
  */
 public function parse($sVar)
 {
     /*** Not to parse a text ***/
     if (preg_match('/#!.+!#/', $sVar)) {
         $sVar = str_replace(array('#!', '!#'), '', $sVar);
         return $sVar;
     }
     /***** Site Variables *****/
     $oRegistry = Registry::getInstance();
     $sVar = str_replace('%site_name%', $oRegistry->site_name, $sVar);
     $sVar = str_replace('%url_relative%', PH7_RELATIVE, $sVar);
     $sVar = str_replace(array('%site_url%', '%url_root%'), $oRegistry->site_url, $sVar);
     $sVar = str_replace('%url_static%', PH7_URL_STATIC, $sVar);
     $sVar = str_replace('%page_ext%', PH7_PAGE_EXT, $sVar);
     unset($oRegistry);
     /***** Affiliate Variables *****/
     $oSession = new Session();
     $sAffUsername = $oSession->exists('affiliate_username') ? $oSession->get('affiliate_username') : 'aid';
     $sVar = str_replace('%affiliate_url%', Uri::get('affiliate', 'router', 'refer', $sAffUsername), $sVar);
     unset($oSession);
     /***** Global Variables *****/
     $sVar = str_replace('%ip%', Ip::get(), $sVar);
     /***** Kernel Variables *****/
     $sVar = str_replace('%software_name%', Kernel::SOFTWARE_NAME, $sVar);
     $sVar = str_replace('%software_company%', Kernel::SOFTWARE_COMPANY, $sVar);
     $sVar = str_replace('%software_author%', 'Pierre-Henry Soria', $sVar);
     $sVar = str_replace('%software_version_name%', Kernel::SOFTWARE_VERSION_NAME, $sVar);
     $sVar = str_replace('%software_version%', Kernel::SOFTWARE_VERSION, $sVar);
     $sVar = str_replace('%software_build%', Kernel::SOFTWARE_BUILD, $sVar);
     $sVar = str_replace('%software_email%', Kernel::SOFTWARE_EMAIL, $sVar);
     $sVar = str_replace('%software_website%', Kernel::SOFTWARE_WEBSITE, $sVar);
     // Output
     return $sVar;
 }
 public function __construct()
 {
     parent::__construct();
     $sBirthDate = $this->dateTime->get($this->httpRequest->post('birth_date'))->date('Y-m-d');
     $aData = ['email' => $this->httpRequest->post('mail'), 'username' => $this->httpRequest->post('username'), 'password' => $this->httpRequest->post('password'), 'first_name' => $this->httpRequest->post('first_name'), 'last_name' => $this->httpRequest->post('last_name'), 'middle_name' => $this->httpRequest->post('middle_name'), 'sex' => $this->httpRequest->post('sex'), 'birth_date' => $sBirthDate, 'country' => $this->httpRequest->post('country'), 'city' => $this->httpRequest->post('city'), 'state' => $this->httpRequest->post('state'), 'zip_code' => $this->httpRequest->post('zip_code'), 'phone' => $this->httpRequest->post('phone'), 'description' => $this->httpRequest->post('description'), 'website' => $this->httpRequest->post('website'), 'bank_account' => $this->httpRequest->post('bank_account'), 'ip' => Ip::get()];
     (new AffiliateModel())->add($aData);
     Header::redirect(Uri::get('affiliate', 'admin', 'browse'), t('The affiliate has been successfully added.'));
 }
 /**
  * Initialize the methods of the class.
  *
  * @access protected
  * @return void
  */
 protected function initialize()
 {
     $this->_oLikeModel = new LikeCoreModel();
     $this->_sKey = $this->_oHttpRequest->post('key');
     $this->_iVote = $this->_oHttpRequest->postExists('vote');
     $this->_fLastIp = Ip::get();
     $this->select();
 }
Пример #10
0
 public function __construct()
 {
     parent::__construct();
     $sIp = Ip::get();
     $oAdminModel = new AdminModel();
     $oSecurityModel = new SecurityModel();
     $sEmail = $this->httpRequest->post('mail');
     $sUsername = $this->httpRequest->post('username');
     $sPassword = $this->httpRequest->post('password');
     /*** Security IP Login ***/
     $sIpLogin = DbConfig::getSetting('ipLogin');
     /*** Check if the connection is not locked ***/
     $bIsLoginAttempt = (bool) DbConfig::getSetting('isAdminLoginAttempt');
     $iMaxAttempts = (int) DbConfig::getSetting('maxAdminLoginAttempts');
     $iTimeDelay = (int) DbConfig::getSetting('loginAdminAttemptTime');
     if ($bIsLoginAttempt && !$oSecurityModel->checkLoginAttempt($iMaxAttempts, $iTimeDelay, $sEmail, $this->view, 'Admins')) {
         \PFBC\Form::setError('form_admin_login', Form::loginAttemptsExceededMsg($iTimeDelay));
         return;
         // Stop execution of the method.
     }
     /*** Check Login ***/
     $bIsLogged = $oAdminModel->adminLogin($sEmail, $sUsername, $sPassword);
     $bIsIpBanned = !empty($sIpLogin) && $sIpLogin !== $sIp;
     if (!$bIsLogged || $bIsIpBanned) {
         sleep(2);
         // Security against brute-force attack to avoid drowning the server and the database
         if (!$bIsLogged) {
             $oSecurityModel->addLoginLog($sEmail, $sUsername, $sPassword, 'Failed! Incorrect Email, Username or Password', 'Admins');
             if ($bIsLoginAttempt) {
                 $oSecurityModel->addLoginAttempt('Admins');
             }
             $this->session->set('captcha_admin_enabled', 1);
             // Enable Captcha
             \PFBC\Form::setError('form_admin_login', t('"Email", "Username" or "Password" is Incorrect'));
         } elseif ($bIsIpBanned) {
             $this->session->set('captcha_admin_enabled', 1);
             // Enable Captcha
             \PFBC\Form::setError('form_admin_login', t('Incorrect Login!'));
             $oSecurityModel->addLoginLog($sEmail, $sUsername, $sPassword, 'Failed! Bad Ip adress', 'Admins');
         }
     } else {
         $oSecurityModel->clearLoginAttempts('Admins');
         $this->session->remove('captcha_admin_enabled');
         // Is disconnected if the user is logged on as "user" or "affiliate".
         if (UserCore::auth() || AffiliateCore::auth()) {
             $this->session->destroy();
         }
         $iId = $oAdminModel->getId($sEmail, null, 'Admins');
         $oAdminData = $oAdminModel->readProfile($iId, 'Admins');
         // Regenerate the session ID to prevent the session fixation
         $this->session->regenerateId();
         $aSessionData = array('admin_id' => $oAdminData->profileId, 'admin_email' => $oAdminData->email, 'admin_username' => $oAdminData->username, 'admin_first_name' => $oAdminData->firstName, 'admin_ip' => $sIp, 'admin_http_user_agent' => $this->browser->getUserAgent(), 'admin_token' => Various::genRnd($oAdminData->email));
         $this->session->set($aSessionData);
         $oSecurityModel->addLoginLog($sEmail, $sUsername, '*****', 'Logged in!', 'Admins');
         $oAdminModel->setLastActivity($oAdminData->profileId, 'Admins');
         HeaderUrl::redirect(Uri::get(PH7_ADMIN_MOD, 'main', 'index'), t('You signup is successfully!'));
     }
 }
Пример #11
0
 /**
  * Adding an Advertisement Click.
  *
  * @param integer $iAdsId
  * @return void
  */
 public static function setClick($iAdsId)
 {
     $rStmt = Db::getInstance()->prepare('INSERT INTO' . Db::prefix('AdsClicks') . 'SET adsId = :adsId, url = :url, ip = :ip, dateTime = :dateTime');
     $rStmt->bindValue(':adsId', $iAdsId, \PDO::PARAM_INT);
     $rStmt->bindValue(':ip', \PH7\Framework\Ip\Ip::get(), \PDO::PARAM_STR);
     $rStmt->bindValue(':dateTime', (new \PH7\Framework\Date\CDateTime())->get()->dateTime('Y-m-d H:i:s'), \PDO::PARAM_STR);
     $rStmt->execute();
     Db::free($rStmt);
 }
Пример #12
0
 /**
  * Build the log message.
  *
  * @access protected
  * @return object this
  */
 protected function setLogMsg()
 {
     $sReferer = null !== ($mReferer = $this->browser->getHttpReferer()) ? $mReferer : 'NO HTTP REFERER';
     $sAgent = null !== ($mAgent = $this->browser->getUserAgent()) ? $mAgent : 'NO USER AGENT';
     $sQuery = null !== ($mQuery = (new Http())->getQueryString()) ? $mQuery : 'NO QUERY STRING';
     $this->_sIp = Ip::get();
     $this->_sContents = t('Date: %0%', $this->dateTime->get()->dateTime()) . "\n" . t('IP: %0%', $this->_sIp) . "\n" . t('QUERY: %0%', $sQuery) . "\n" . t('Agent: %0%', $sAgent) . "\n" . t('Referer: %0%', $sReferer) . "\n" . t('LOGIN - Email: %0% - Username: %1% - Password: %2%', $this->_aData['mail'], $this->_aData['username'], $this->_aData['password']) . "\n\n\n";
     return $this;
 }
 /**
  * Affiliates'levels.
  *
  * @return boolean
  */
 public static function auth()
 {
     $oSession = new Framework\Session\Session();
     $oBrowser = new Framework\Navigation\Browser();
     $bIsConnect = (int) $oSession->exists('affiliate_id') && $oSession->get('affiliate_ip') === Framework\Ip\Ip::get() && $oSession->get('affiliate_http_user_agent') === $oBrowser->getUserAgent();
     /** Destruction of the object and minimize CPU resources **/
     unset($oSession, $oBrowser);
     return $bIsConnect;
 }
Пример #14
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);
 }
Пример #15
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);
 }
 public function __construct()
 {
     parent::__construct();
     $sBirthDate = $this->dateTime->get($this->httpRequest->post('birth_date'))->date('Y-m-d');
     $aData = ['email' => $this->httpRequest->post('mail'), 'username' => $this->httpRequest->post('username'), 'password' => $this->httpRequest->post('password'), 'first_name' => $this->httpRequest->post('first_name'), 'last_name' => $this->httpRequest->post('last_name'), 'middle_name' => $this->httpRequest->post('middle_name'), 'sex' => $this->httpRequest->post('sex'), 'match_sex' => $this->httpRequest->post('match_sex'), 'birth_date' => $sBirthDate, 'country' => $this->httpRequest->post('country'), 'city' => $this->httpRequest->post('city'), 'state' => $this->httpRequest->post('state'), 'zip_code' => $this->httpRequest->post('zip_code'), 'description' => $this->httpRequest->post('description'), 'website' => $this->httpRequest->post('website'), 'social_network_site' => $this->httpRequest->post('social_network_site'), 'ip' => Ip::get()];
     $iProfileId = (new UserCoreModel())->add($aData);
     if (!empty($_FILES['avatar']['tmp_name'])) {
         (new UserCore())->setAvatar($iProfileId, $aData['username'], $_FILES['avatar']['tmp_name'], 1);
     }
     Header::redirect(Uri::get(PH7_ADMIN_MOD, 'user', 'browse'), t('The user has been successfully added.'));
 }
Пример #17
0
 /**
  * Set Log Session.
  *
  * @param string $sEmail
  * @param string $sUsername
  * @param string $sFirstName
  * @param string $sTable
  * @param string $sTable Default 'Members'
  * @return void
  */
 public function sessionLog($sEmail, $sUsername, $sFirstName, $sTable = 'Members')
 {
     Various::checkModelTable($sTable);
     $rStmt = Db::getInstance()->prepare('INSERT INTO' . Db::prefix($sTable . 'LogSess') . '(email, username, firstName, ip)
     VALUES (:email, :username, :firstName, :ip)');
     $rStmt->bindValue(':email', $sEmail, \PDO::PARAM_STR);
     $rStmt->bindValue(':username', $sUsername, \PDO::PARAM_STR);
     $rStmt->bindValue(':firstName', $sFirstName, \PDO::PARAM_STR);
     $rStmt->bindValue(':ip', Framework\Ip\Ip::get(), \PDO::PARAM_STR);
     $rStmt->execute();
     Db::free($rStmt);
 }
Пример #18
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);
 }
 /**
  * Write to the logfile.
  *
  * @param object $oExcept \Exception object.
  * @return void
  */
 public function except(\Exception $oExcept)
 {
     // Time: Set the log date/time.
     // IP: The IP address of the client.
     // UserAgent: The User Agent of the Browser Web.
     // UrlPag: The URL page where the exception is thrown.
     // Query: The request for such a page.
     // Message: constains the error message.
     // Level: contains the log level.
     // File: constains the file name.
     // Line: constains the line number.
     $sAgent = null !== ($mAgent = $this->browser->getUserAgent()) ? $mAgent : 'NO USER AGENT';
     $sQuery = null !== ($mQuery = (new Http())->getQueryString()) ? $mQuery : 'NO QUERY STRING';
     $aLog = ['Time' => $this->dateTime->get()->dateTime(), 'IP' => Ip::get(), 'UserAgent' => $sAgent, 'UrlPag' => $this->httpRequest->currentUrl(), 'Query' => $sQuery, 'Message' => $oExcept->getMessage(), 'Level' => $oExcept->getCode(), 'File' => $oExcept->getFile(), 'Line' => $oExcept->getLine()];
     // Encode the line
     $sContents = json_encode($aLog) . File::EOL . File::EOL . File::EOL;
     switch ($this->config->values['logging']['log_handler']) {
         case 'file':
             $sFullFile = $this->sDir . static::EXCEPT_DIR . $this->sFileName . '.json';
             $sFullGzipFile = $this->sDir . static::EXCEPT_DIR . static::GZIP_DIR . $this->sFileName . '.gz';
             // If the log file is larger than 5 Mo then it compresses it into gzip
             if (file_exists($sFullFile) && filesize($sFullFile) >= 5 * 1024 * 1024) {
                 $rHandler = @gzopen($sFullGzipFile, 'a') or exit('Unable to write to log file gzip.');
                 gzwrite($rHandler, $sContents);
                 gzclose($rHandler);
             } else {
                 $rHandler = @fopen($sFullFile, 'a') or exit('Unable to write to log file.');
                 fwrite($rHandler, $sContents);
                 fclose($rHandler);
             }
             break;
         case 'database':
             $rStmt = Db::getInstance()->prepare('INSERT INTO' . Db::prefix('LogError') . 'SET logError = :line');
             $rStmt->execute(array(':line' => $sContents));
             Db::free($rStmt);
             break;
         case 'email':
             $aInfo = ['to' => $this->config->values['logging']['bug_report_email'], 'subject' => t('Errors Reporting of the pH7 Framework')];
             (new \PH7\Framework\Mail\Mail())->send($aInfo, $sContents, false);
             break;
         default:
             exit('Invalid Log Option.');
     }
 }
 public function __construct()
 {
     parent::__construct();
     $oSubscriptionModel = new SubscriptionModel();
     $sEmail = $this->httpRequest->post('email');
     $sName = $this->httpRequest->post('name');
     $bIsSubscriber = (new ExistsCoreModel())->email($sEmail, 'Subscribers');
     switch ($this->httpRequest->post('direction')) {
         case 'subscrire':
             if (!$bIsSubscriber) {
                 $aData = ['name' => $sName, 'email' => $sEmail, 'current_date' => (new CDateTime())->get()->dateTime('Y-m-d H:i:s'), 'ip' => Ip::get(), 'hash_validation' => Various::genRnd(), 'active' => '0', 'affiliated_id' => (int) (new Cookie())->get(AffiliateCore::COOKIE_NAME)];
                 $sActivateLink = Uri::get('newsletter', 'home', 'activate') . PH7_SH . $aData['email'] . PH7_SH . $aData['hash_validation'];
                 $this->view->content = t('Hi %0%!', $aData['name']) . '<br />' . t("Welcome to %site_name%'s Subscription!") . '<br />' . t('Activation link: %0%.', '<a href="' . $sActivateLink . '">' . $sActivateLink . '</a>');
                 $this->view->footer = t('You are receiving this mail because we received an application for registration with the email "%0%" has been provided in the form of %site_name% (%site_url%).', $aData['email']) . '<br />' . t('If you think someone has used your email address without your knowledge to create an account on %site_name%, please contact us using our contact form available on our website.');
                 $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_TPL_NAME . '/mail/sys/mod/newsletter/registration.tpl', $sEmail);
                 $aInfo = ['subject' => t('Confirm you email address!'), 'to' => $sEmail];
                 if ((new Mail())->send($aInfo, $sMessageHtml)) {
                     \PFBC\Form::setSuccess('form_subscription', t('Please activate your subscription by clicking the activation link you received by email. If you can not find the email, please look in your SPAM FOLDER and mark as not spam.'));
                     $oSubscriptionModel->add($aData);
                 } else {
                     \PFBC\Form::setError('form_subscription', Form::errorSendingEmail());
                 }
             } else {
                 \PFBC\Form::setError('form_subscription', t('Oops! You are already subscribed to our newsletter.'));
             }
             break;
         case 'unsubscribe':
             if ($bIsSubscriber) {
                 $oSubscriptionModel->unsubscribe($sEmail);
                 \PFBC\Form::setSuccess('form_subscription', t('Your subscription was successfully canceled.'));
             } else {
                 \PFBC\Form::setError('form_subscription', t('We have not found any subscriber with the email address.'));
             }
             break;
         default:
             Framework\Http\Http::setHeadersByCode(400);
             exit('Bad Request Error!');
     }
     unset($oSubscriptionModel);
 }
Пример #21
0
 public function step1()
 {
     $sBirthDate = $this->dateTime->get($this->httpRequest->post('birth_date'))->date('Y-m-d');
     $iAffId = (int) (new Cookie())->get(AffiliateCore::COOKIE_NAME);
     $aData = ['email' => $this->httpRequest->post('mail'), 'username' => $this->httpRequest->post('username'), 'password' => $this->httpRequest->post('password'), 'first_name' => $this->httpRequest->post('first_name'), 'last_name' => $this->httpRequest->post('last_name'), 'sex' => $this->httpRequest->post('sex'), 'birth_date' => $sBirthDate, 'country' => $this->httpRequest->post('country'), 'city' => $this->httpRequest->post('city'), 'state' => $this->httpRequest->post('state'), 'zip_code' => $this->httpRequest->post('zip_code'), 'ip' => Ip::get(), 'hash_validation' => Various::genRnd(), 'current_date' => (new CDateTime())->get()->dateTime('Y-m-d H:i:s'), 'is_active' => $this->iActiveType, 'affiliated_id' => $iAffId];
     $oAffModel = new AffiliateModel();
     $iTimeDelay = (int) DbConfig::getSetting('timeDelayUserRegistration');
     if (!$oAffModel->checkWaitJoin($aData['ip'], $iTimeDelay, $aData['current_date'], 'Affiliates')) {
         \PFBC\Form::setError('form_join_aff', Form::waitRegistrationMsg($iTimeDelay));
     } elseif (!$oAffModel->join($aData)) {
         \PFBC\Form::setError('form_join_aff', t('An error occurred during registration!<br /> Please try again with other information in the form fields or come back later.'));
     } else {
         // Successful registration in the database!
         /** Update the Affiliate Commission **/
         if ($this->iActiveType == 0) {
             // Only if the user's account is already activated.
             AffiliateCore::updateJoinCom($iAffId, $this->config, $this->registry);
         }
         // Send an email and sets the welcome message.
         \PFBC\Form::setSuccess('form_join_aff', t('Your affiliate account has been created! %0%', (new Registration())->sendMail($aData)->getMsg()));
     }
     unset($oAffModel);
 }
 /**
  * @param string $sName Name of the Token.
  *
  * @param string $sInputToken The name of the token inserted in the hidden tag of the form.
  * (e.g. for a from with method "post" and the field "<input type="hidden" name="my_token" />" the name of the token is "$_POST['my_token']" Default NULL
  *
  * @param integer $iTime Lifetime of token in seconds. Default NULL (value specified in the database settings).
  *
  * @return boolean Returns TRUE if the token is validated, FALSE otherwise.
  */
 public function check($sName, $sInputToken = null, $iTime = null)
 {
     $iTime = empty($iTime) ? DbConfig::getSetting('securityTokenLifetime') : $iTime;
     // The default tag name for the security token
     $sInputToken = empty($sInputToken) ? (new Http())->post('security_token') : $sInputToken;
     $aCheckSession = ['security_token_' . $sName, 'security_token_time_' . $sName, 'security_token_ip_' . $sName, 'security_token_http_user_agent_' . $sName];
     if ($this->_oSession->exists($aCheckSession) && !empty($sInputToken)) {
         if ($this->_oSession->get('security_token_' . $sName) === $sInputToken) {
             if ($this->_oSession->get('security_token_time_' . $sName) >= time() - $iTime) {
                 //if ($this->_sHttpReferer === $this->_oSession->get('security_token_http_referer_' . $sName))
                 if (Ip::get() === $this->_oSession->get('security_token_ip_' . $sName)) {
                     if ($this->_sUserAgent === $this->_oSession->get('security_token_http_user_agent_' . $sName)) {
                         // Delete the token and data sessions expired
                         $this->_oSession->remove($aCheckSession);
                         return true;
                     }
                 }
             }
         }
     }
     // Delete the token and data sessions expired
     $this->_oSession->remove($aCheckSession);
     return false;
 }
Пример #23
0
 /**
  * Show the user IP address with a link to get the IP information.
  *
  * @param string $sIp IP address. Default NULL
  * @return void
  */
 public function ip($sIp = null)
 {
     echo '<a href="', Ip::api($sIp), '" title="', t('See information from this IP'), '" target="_blank">', Ip::get($sIp), '</a>';
 }
Пример #24
0
 public function loginUserAs($iId)
 {
     $aSessionData = ['login_affiliate_as' => 1, 'affiliate_id' => $iId, 'affiliate_email' => $this->oAffModel->getEmail($iId, 'Affiliates'), 'affiliate_username' => $this->oAffModel->getUsername($iId, 'Affiliates'), 'affiliate_first_name' => $this->oAffModel->getFirstName($iId, 'Affiliates'), 'affiliate_sex' => $this->oAffModel->getSex($iId, null, 'Affiliates'), 'affiliate_ip' => Framework\Ip\Ip::get(), 'affiliate_http_user_agent' => $this->browser->getUserAgent(), 'affiliate_token' => Framework\Util\Various::genRnd()];
     $this->session->set($aSessionData);
     HeaderUrl::redirect(Uri::get('affiliate', 'account', 'index'), t('You are now logged in as affiliate: %0%!', $this->session->get('affiliate_username')));
 }
Пример #25
0
 public static function display()
 {
     if (isset($_POST['submit_setting'])) {
         if (\PFBC\Form::isValid($_POST['submit_setting'])) {
             new SettingFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oForm = new \PFBC\Form('form_setting', 700);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_setting', 'form_setting'));
     $oForm->addElement(new \PFBC\Element\Token('setting'));
     /********** General Settings **********/
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<div class="content" id="general"><h2 class="underline">' . t('Global Settings:') . '</h2>'));
     $oFile = new File();
     $aTplsId = $oFile->getDirList(PH7_PATH_TPL);
     $aLangsId = $oFile->getDirList(PH7_PATH_APP_LANG);
     $aTpls = array();
     foreach ($aTplsId as $sTpl) {
         $aTpls[$sTpl] = ucfirst($sTpl);
     }
     $aLangs = array();
     foreach ($aLangsId as $sLang) {
         $sAbbrLang = substr($sLang, 0, 2);
         $aLangs[$sLang] = t($sAbbrLang) . ' (' . $sLang . ')';
     }
     $oForm->addElement(new \PFBC\Element\Textbox(t('Site Name:'), 'site_name', array('value' => DbConfig::getSetting('siteName'), 'validation' => new \PFBC\Validation\Str(2, 50), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Theme by default:'), 'default_template', $aTpls, array('value' => DbConfig::getSetting('defaultTemplate'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Language by default:'), 'default_language', $aLangs, array('value' => DbConfig::getSetting('defaultLanguage'), 'validation' => new \PFBC\Validation\Str(5, 5), 'required' => 1)));
     unset($oFile, $aTplsId, $aLangsId, $aTpls, $aLangs);
     $oForm->addElement(new \PFBC\Element\Select(t('Map Type:'), 'map_type', array('roadmap' => t('Roadmap (default)'), 'hybrid' => t('Hybrid'), 'terrain' => t('Terrain'), 'satellite' => t('Satellite')), array('value' => DbConfig::getSetting('mapType'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Splash Page:'), 'splash_page', array('1' => t('Enable'), '0' => t('Disable')), array('description' => t('Use the Splash Page for the visitors, otherwise it will classic page that will be used.'), 'value' => DbConfig::getSetting('splashPage'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Background Splash Video:'), 'bg_splash_vid', array('1' => t('Enable'), '0' => t('Disable')), array('description' => t('Enable or Disable the "Animated Video" on the Splash Page.'), 'value' => DbConfig::getSetting('bgSplashVideo'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Ajax Site with AjPH:'), 'full_ajax_site', array('1' => t('Enable'), '0' => t('Disable')), array('description' => t("Be careful! 'Full Ajax Navigation' feature is still in Beta and may not be working properly on all pages."), 'value' => DbConfig::getSetting('fullAjaxSite'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Site Status:'), 'site_status', array(DbConfig::ENABLE_SITE => t('Enable'), DbConfig::MAINTENANCE_SITE => t('Maintenance')), array('value' => DbConfig::getSetting('siteStatus'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Adult Disclaimer:'), 'disclaimer', array(1 => t('Enable'), 0 => t('Disable')), array('description' => t('Show an Adult Warning to enter to the site. This is useful for sites with adult content.'), 'value' => DbConfig::getSetting('disclaimer'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Cookie Consent Bar:'), 'cookie_consent_bar', array(1 => t('Enable'), 0 => t('Disable')), array('description' => t('Enable a Cookie Consent Bar to prevent your users that your site uses cookies. This is required for EU Law (if you have visitors from EU countries). The Cookie Bar will only be displayed if the visitor is in the EU.'), 'value' => DbConfig::getSetting('cookieConsentBar'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Show the News Feed:'), 'is_software_news_feed', array(1 => t('Enable'), 0 => t('Disable')), array('description' => t('Show the Latest News on the software in the admin dashboard (recommend).'), 'value' => DbConfig::getSetting('isSoftwareNewsFeed'), 'required' => 1)));
     /********** Logo Settings **********/
     $oForm->addElement(new \PFBC\Element\HTMLExternal('</div><div class="content" id="logotype"><h2 class="underline">' . t('Logo:') . '</h2>'));
     $oForm->addElement(new \PFBC\Element\File(t('Logo:'), 'logo', array('accept' => 'image/*')));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<p><img src="' . PH7_URL_TPL . PH7_TPL_NAME . PH7_SH . PH7_IMG . 'logo.png?v=' . File::version(PH7_PATH_TPL . PH7_TPL_NAME . PH7_DS . PH7_IMG . 'logo.png') . '" alt="' . t('Logo') . '" title="' . t('The current logo of your site.') . '" /></p>'));
     /********** Registration **********/
     $oForm->addElement(new \PFBC\Element\HTMLExternal('</div><div class="content" id="registration"><h2 class="underline">' . t('Registration:') . '</h2>'));
     $oForm->addElement(new \PFBC\Element\Select(t('Account activation type for Members:'), 'user_activation_type', array('1' => t('No activation required'), '2' => t('Self activation via email'), '3' => t('Manual activation by administrator')), array('value' => DbConfig::getSetting('userActivationType'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Account activation type for Affiliates:'), 'aff_activation_type', array('1' => t('No activation required'), '2' => t('Self activation via email'), '3' => t('Manual activation by administrator')), array('value' => DbConfig::getSetting('affActivationType'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Minimum username length:'), 'min_username_length', array('value' => DbConfig::getSetting('minUsernameLength'), 'max' => DbConfig::getSetting('maxUsernameLength') - 1, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Maximum username length:'), 'max_username_length', array('value' => DbConfig::getSetting('maxUsernameLength'), 'min' => DbConfig::getSetting('minUsernameLength') + 1, 'max' => PH7_MAX_USERNAME_LENGTH, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Minimum age for registration:'), 'min_age_registration', array('value' => DbConfig::getSetting('minAgeRegistration'), 'max' => DbConfig::getSetting('maxAgeRegistration') - 1, 'validation' => new \PFBC\Validation\Str(1, 3), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Maximum age for registration:'), 'max_age_registration', array('value' => DbConfig::getSetting('maxAgeRegistration'), 'min' => DbConfig::getSetting('minAgeRegistration') + 1, 'validation' => new \PFBC\Validation\Str(1, 3), 'required' => 1)));
     $oGroupId = (new AdminCoreModel())->getMemberships();
     $aGroupName = array();
     foreach ($oGroupId as $iId) {
         $aGroupName[$iId->groupId] = $iId->name;
     }
     $oForm->addElement(new \PFBC\Element\Select(t('Default Membership Group:'), 'default_membership_group_id', $aGroupName, array('value' => DbConfig::getSetting('defaultMembershipGroupId'), 'required' => 1)));
     unset($aGroupName);
     /********** Picture and Video **********/
     $oForm->addElement(new \PFBC\Element\HTMLExternal('</div><div class="content" id="pic_vid"><h2 class="underline">' . t('Picture and Video:') . '</h2>'));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<br /><h3 class="underline">' . t('Image:') . '</h3>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Watermark text:'), 'watermark_text_image', array('value' => DbConfig::getSetting('watermarkTextImage'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Size Watermark Text:'), 'size_watermark_text_image', array('description' => t('Between 0 to 5.'), 'value' => DbConfig::getSetting('sizeWatermarkTextImage'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<br /><h3 class="underline">' . t('Video:') . '</h3>'));
     $oForm->addElement(new \PFBC\Element\Url(t('Default video:'), 'default_video', array('description' => t('Video by default if no video found.'), 'value' => DbConfig::getSetting('defaultVideo'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Autoplay Video:'), 'autoplay_video', array('1' => t('Enable'), '0' => t('Disable')), array('value' => DbConfig::getSetting('autoplayVideo'), 'required' => 1)));
     /********** Moderation **********/
     $oForm->addElement(new \PFBC\Element\HTMLExternal('</div><div class="content" id="moderation"><h2 class="underline">' . t('Moderation:') . '</h2>'));
     $oForm->addElement(new \PFBC\Element\Select(t('Avatar Manual Approval:'), 'avatar_manual_approval', array('1' => t('Enable'), '0' => t('Disable')), array('value' => DbConfig::getSetting('avatarManualApproval'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Profile Background Manual Approval:'), 'profile_background_manual_approval', array('1' => t('Enable'), '0' => t('Disable')), array('value' => DbConfig::getSetting('profileBackgroundManualApproval'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Note Post Manual Approval:'), 'note_manual_approval', array('1' => t('Enable'), '0' => t('Disable')), array('value' => DbConfig::getSetting('noteManualApproval'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Pictures Manual Approval:'), 'picture_manual_approval', array('1' => t('Enable'), '0' => t('Disable')), array('value' => DbConfig::getSetting('pictureManualApproval'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Videos Manual Approval:'), 'video_manual_approval', array('1' => t('Enable'), '0' => t('Disable')), array('value' => DbConfig::getSetting('videoManualApproval'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Webcam Pictures Manual Approval:'), 'webcam_picture_manual_approval', array('1' => t('Enable'), '0' => t('Disable')), array('description' => t('This mode is experimental approval, do not use it in production.'), 'value' => DbConfig::getSetting('webcamPictureManualApproval'), 'required' => 1)));
     /********** Email **********/
     $oForm->addElement(new \PFBC\Element\HTMLExternal('</div><div class="content" id="email"><h2 class="underline">' . t('Email Parameters:') . '</h2>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Email Name:'), 'email_name', array('value' => DbConfig::getSetting('emailName'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Email(t('Admin Email:'), 'admin_email', array('value' => DbConfig::getSetting('adminEmail'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Email(t('Feedback Email:'), 'feedback_email', array('value' => DbConfig::getSetting('feedbackEmail'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Email(t('Return Email:'), 'return_email', array('description' => 'Generally noreply@yoursite.com', 'value' => DbConfig::getSetting('returnEmail'), 'required' => 1)));
     /********** Security **********/
     $oForm->addElement(new \PFBC\Element\HTMLExternal('</div><div class="content" id="security"><h2 class="underline">' . t('Security:') . '</h2>'));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<br /><h3 class="underline">' . t('Password:'******'</h3>'));
     $oForm->addElement(new \PFBC\Element\Number(t('Minimum password length:'), 'min_password_length', array('value' => DbConfig::getSetting('minPasswordLength'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Maximum password length:'), 'max_password_length', array('value' => DbConfig::getSetting('maxPasswordLength'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<br /><h3 class="underline">' . t('Blocking login attempts exceeded:') . '</h3>'));
     $oForm->addElement(new \PFBC\Element\Select(t('Enable blocking for User:'******'is_user_login_attempt', array('1' => t('Enable'), '0' => t('Disable')), array('value' => DbConfig::getSetting('isUserLoginAttempt'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Enable blocking for Affiliate:'), 'is_affiliate_login_attempt', array('1' => t('Enable'), '0' => t('Disable')), array('value' => DbConfig::getSetting('isAffiliateLoginAttempt'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Enable blocking for Admin:'), 'is_admin_login_attempt', array('1' => t('Enable'), '0' => t('Disable')), array('value' => DbConfig::getSetting('isAdminLoginAttempt'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Max login attempts before blocking for User:'******'max_user_login_attempts', array('value' => DbConfig::getSetting('maxUserLoginAttempts'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Max login attempts before blocking for Affiliate:'), 'max_affiliate_login_attempts', array('value' => DbConfig::getSetting('maxAffiliateLoginAttempts'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Max login attempts before blocking for Admin:'), 'max_admin_login_attempts', array('value' => DbConfig::getSetting('maxAdminLoginAttempts'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Time interval blocking for User:'******'login_user_attempt_time', array('description' => t('Time in minutes.'), 'value' => DbConfig::getSetting('loginUserAttemptTime'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Time interval blocking for Affiliate:'), 'login_affiliate_attempt_time', array('description' => t('Time in minutes.'), 'value' => DbConfig::getSetting('loginAffiliateAttemptTime'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Time interval blocking for Admin:'), 'login_admin_attempt_time', array('description' => t('Time in minutes.'), 'value' => DbConfig::getSetting('loginAdminAttemptTime'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<br /><h3 class="underline">' . t('Various:') . '</h3>'));
     $oForm->addElement(new \PFBC\Element\Select(t('Send reports by email:'), 'send_report_mail', array('1' => t('Activate'), '0' => t('Deactivate')), array('value' => DbConfig::getSetting('sendReportMail'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Security IP connection for Admin Panel:'), 'ip_login', array('description' => t('Enter <a href="%0%" title="Get your IP here!">your IP address</a> and an even higher security and exclude all other persons and bots that tried to connect with another IP address even if the login is correct! Leave blank to disable this feature.', Ip::api()), 'value' => DbConfig::getSetting('ipLogin'))));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Indicate a word that will replace the banned word in the <a href="%0%">list</a>.', Uri::get(PH7_ADMIN_MOD, 'file', 'protectededit', 'app/configs/bans/word.txt', false)), 'ban_word_replace', array('value' => DbConfig::getSetting('banWordReplace'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Enable or Disable the CSRF security tokens in forms:'), 'security_token', array('1' => t('Enable'), '0' => t('Disable')), array('description' => t('Sometime this protection can be annoying for users if there are not fast enough to fulfill the forms. However, if disabled, your site can be vulnerable on CSRF attacks in forms.'), 'value' => DbConfig::getSetting('securityToken'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('CSRF token lifetime:'), 'security_token_lifetime', array('description' => t('Time in seconds.'), 'value' => DbConfig::getSetting('securityTokenLifetime'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('System against the DDoS attacks:'), 'stop_DDoS', array('1' => t('Activate'), '0' => t('Deactivate')), array('value' => DbConfig::getSetting('DDoS'), 'required' => 1)));
     /********** Spam **********/
     $oForm->addElement(new \PFBC\Element\HTMLExternal('</div><div class="content" id="spam"><h2 class="underline">' . t('Spam:') . '</h2>'));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<br /><h3 class="underline">' . t('Time Delay:') . '</h3>'));
     $oForm->addElement(new \PFBC\Element\Number(t('Registration delay for User'), 'time_delay_user_registration', array('description' => t('Number of minutes for a new registration with the same IP address.'), 'value' => DbConfig::getSetting('timeDelayUserRegistration'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Registration delay for Affiliate'), 'time_delay_aff_registration', array('description' => t('Number of minutes for a new registration with the same IP address.'), 'value' => DbConfig::getSetting('timeDelayAffRegistration'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Send Note delay'), 'time_delay_send_note', array('description' => t('Number of minutes for the same user to post a new note.'), 'value' => DbConfig::getSetting('timeDelaySendNote'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Send Mail delay'), 'time_delay_send_mail', array('description' => t('Number of minutes for the same user can send a new email.'), 'value' => DbConfig::getSetting('timeDelaySendMail'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Send Comment delay'), 'time_delay_send_comment', array('description' => t('Number of minutes for the same user can send a new comment.'), 'value' => DbConfig::getSetting('timeDelaySendComment'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Send Forum Topic delay'), 'time_delay_send_forum_topic', array('description' => t('Number of minutes for the same user can send a new topic in the forum.'), 'value' => DbConfig::getSetting('timeDelaySendForumTopic'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Send Forum Message delay'), 'time_delay_send_forum_msg', array('description' => t('Number of minutes for the same user can send a reply message in the same topic.'), 'value' => DbConfig::getSetting('timeDelaySendForumMsg'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<br /><h3 class="underline">' . t('Captcha:') . '</h3>'));
     $oForm->addElement(new \PFBC\Element\Select(t('Captcha for User Signup Form:'), 'is_captcha_user_signup', array('1' => t('Activate'), '0' => t('Deactivate')), array('value' => DbConfig::getSetting('isCaptchaUserSignup'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Captcha for Affiliate Signup Form:'), 'is_captcha_affiliate_signup', array('1' => t('Activate'), '0' => t('Deactivate')), array('value' => DbConfig::getSetting('isCaptchaAffiliateSignup'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Captcha for send an Email:'), 'is_captcha_mail', array('1' => t('Activate'), '0' => t('Deactivate')), array('value' => DbConfig::getSetting('isCaptchaMail'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Captcha for adding a Comment:'), 'is_captcha_comment', array('1' => t('Activate'), '0' => t('Deactivate')), array('value' => DbConfig::getSetting('isCaptchaComment'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Captcha for adding or reply a message in the Forum:'), 'is_captcha_forum', array('1' => t('Activate'), '0' => t('Deactivate')), array('value' => DbConfig::getSetting('isCaptchaForum'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Select(t('Captcha for adding a User Post Note:'), 'is_captcha_note', array('1' => t('Activate'), '0' => t('Deactivate')), array('value' => DbConfig::getSetting('isCaptchaNote'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<br /><h3 class="underline">' . t('Pruning:') . '</h3>'));
     $oForm->addElement(new \PFBC\Element\Number(t('Delete older messages:'), 'clean_msg', array('description' => t('Delete messages older than days. 0 to disable.'), 'value' => DbConfig::getSetting('cleanMsg'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Delete older comments:'), 'clean_comment', array('description' => t('Delete comments older than days. 0 to disable.'), 'value' => DbConfig::getSetting('cleanComment'), 'required' => 1)));
     /********** Api **********/
     $oForm->addElement(new \PFBC\Element\HTMLExternal('</div><div class="content" id="api"><h2 class="underline">' . t('Api:') . '</h2>'));
     $oForm->addElement(new \PFBC\Element\Url(t('IP Api:'), 'ip_api', array('description' => t('The URL must end with a slash.'), 'value' => DbConfig::getSetting('ipApi'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Url(t('Chat Api:'), 'chat_api', array('description' => t('Parsing tags are permitted (e.g. #!http://api.your-service-chat.com/?url=%0%&name=%1%!#).', '<strong>%site_url%</strong>', '<strong>%site_name%</strong>'), 'value' => DbConfig::getSetting('chatApi'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Url(t('Chatroulette Api:'), 'chatroulette_api', array('description' => t('Parsing tags are permitted (e.g. #!http://api.your-service-chat.com/?url=%0%&name=%1%!#).', '<strong>%site_url%</strong>', '<strong>%site_name%</strong>'), 'value' => DbConfig::getSetting('chatrouletteApi'), 'required' => 1)));
     /********** Automation **********/
     $oForm->addElement(new \PFBC\Element\HTMLExternal('</div><div class="content" id="automation"><h2 class="underline">' . t('Automation:') . '</h2>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Secret word for the URL cron:'), 'cron_security_hash', array('description' => t('Your very secret word for the cron URL. It will be used for running automated cron job.'), 'value' => DbConfig::getSetting('cronSecurityHash'), 'required' => 1, 'validation' => new \PFBC\Validation\Str(1, 64))));
     $oForm->addElement(new \PFBC\Element\Number(t('User inactivity timeout:'), 'user_timeout', array('description' => t('The number of minutes that a member becomes inactive (offline).'), 'value' => DbConfig::getSetting('userTimeout'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('</div><script src="' . PH7_URL_STATIC . PH7_JS . 'tabs.js"></script><script>tabs(\'p\', [\'general\',\'logotype\',\'registration\',\'pic_vid\',\'moderation\',\'email\',\'security\',\'spam\',\'api\',\'automation\']);</script>'));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
Пример #26
0
 public function loginUserAs($iId)
 {
     $aSessionData = ['login_user_as' => 1, 'member_id' => $iId, 'member_email' => $this->oAdminModel->getEmail($iId), 'member_username' => $this->oAdminModel->getUsername($iId), 'member_first_name' => $this->oAdminModel->getFirstName($iId), 'member_sex' => $this->oAdminModel->getSex($iId), 'member_group_id' => $this->oAdminModel->getGroupId($iId), 'member_ip' => Framework\Ip\Ip::get(), 'member_http_user_agent' => $this->browser->getUserAgent(), 'member_token' => Framework\Util\Various::genRnd()];
     $this->session->set($aSessionData);
     HeaderUrl::redirect($this->registry->site_url, t('You are now logged in as member: %0%!', $this->session->get('member_username')));
 }
 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));
 }
Пример #28
0
 /**
  * Get Geo Ip Data Information.
  *
  * @access protected
  * @param string $sIpAddress Specify an IP address. If NULL, it will address the current customer who visits the site. Default: NULL
  * @return object
  */
 protected static function get($sIpAddress = null)
 {
     $sIpAddr = !empty($sIpAddress) ? $sIpAddress : Ip::get();
     if ($sIpAddr == '127.0.0.1') {
         // Set a valid IP address, if it's the invalid local one
         $sIpAddr = '128.101.101.101';
     }
     $oReader = new Reader(__DIR__ . '/GeoLite2-City.mmdb');
     return @$oReader->city($sIpAddr);
 }
Пример #29
0
 /**
  * Generate Random.
  *
  * @static
  * @param string $sStr
  * @param integer $iLength Default is 40 Characters.
  * @return string
  */
 public static function genRnd($sStr = null, $iLength = 40)
 {
     $sStr = !empty($sStr) ? (string) $sStr : '';
     $sChars = hash('whirlpool', hash('whirlpool', uniqid(mt_rand(), true) . $sStr . \PH7\Framework\Ip\Ip::get() . time()) . hash('sha512', (new \PH7\Framework\Navigation\Browser())->getUserAgent() . microtime(true) * 9999));
     return self::padStr($sChars, $iLength);
 }
 /**
  * Set default values for the "ImportUser::$_aTmpData" array.
  *
  * @return void
  */
 protected function setDefVals()
 {
     $sFiveChars = Various::genRnd($this->_aFile['name'], 5);
     $this->_aTmpData = ['email' => 'pierrehenrysoriasanz' . $sFiveChars . '@hizup' . $sFiveChars . '.com', 'username' => 'Hizup' . $sFiveChars, 'password' => Various::genRnd(), 'first_name' => 'Alex' . $sFiveChars, 'last_name' => 'Rolli' . $sFiveChars, 'sex' => $this->_aGenderList[mt_rand(0, 2)], 'match_sex' => $this->_aGenderList[mt_rand(0, 2)], 'birth_date' => date('Y') - mt_rand(20, 50) . '-' . 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()];
 }