コード例 #1
0
 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.'));
 }
コード例 #2
0
 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));
         }
     }
 }
コード例 #3
0
 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.'));
 }
コード例 #4
0
 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!'));
         }
     }
 }
コード例 #5
0
 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'));
     }
 }
コード例 #7
0
 /**
  * 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;
 }
コード例 #8
0
 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.'));
 }
コード例 #9
0
 /**
  * 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
ファイル: Ads.class.php プロジェクト: joswilson/NotJustOK
 /**
  * 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
ファイル: Logger.php プロジェクト: katemamba/katepokedex
 /**
  * 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;
 }
コード例 #13
0
 /**
  * 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
ファイル: Microsoft.php プロジェクト: joswilson/NotJustOK
 /**
  * @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);
 }
コード例 #16
0
 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
ファイル: UserCoreModel.php プロジェクト: joswilson/NotJustOK
 /**
  * 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);
 }
コード例 #19
0
 /**
  * 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.');
     }
 }
コード例 #20
0
 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);
 }
コード例 #22
0
 /**
  * @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
 public function __construct()
 {
     $this->_sIp = Ip::get();
     $this->_sCurrentTime = (new \PH7\Framework\Date\CDateTime())->get()->dateTime('Y-m-d H:i:s');
 }
コード例 #24
0
ファイル: Design.class.php プロジェクト: joswilson/NotJustOK
 /**
  * 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>';
 }
コード例 #25
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')));
 }
コード例 #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')));
 }
コード例 #27
0
 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
ファイル: Various.class.php プロジェクト: joswilson/NotJustOK
 /**
  * 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);
 }
コード例 #29
0
 /**
  * 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()];
 }
コード例 #30
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);
 }