public static function step2() { $oSession = new Session(); if (!$oSession->exists('mail_step1')) { Framework\Url\Header::redirect(Uri::get('user', 'signup', 'step1')); } elseif ($oSession->exists('mail_step2')) { Header::redirect(Uri::get('user', 'signup', 'step3')); } unset($oSession); if (isset($_POST['submit_join_user2'])) { if (\PFBC\Form::isValid($_POST['submit_join_user2'])) { (new JoinFormProcess())->step2(); } Framework\Url\Header::redirect(); } $oForm = new \PFBC\Form('form_join_user2'); $oForm->configure(array('action' => '')); $oForm->addElement(new \PFBC\Element\Hidden('submit_join_user2', 'form_join_user2')); $oForm->addElement(new \PFBC\Element\Token('join2')); $oForm->addElement(new \PFBC\Element\Radio(t('Gender:'), 'sex', array('female' => t('Female') . ' ♀', 'male' => t('Male') . ' ♂', 'couple' => t('Couple')), array('value' => 'female', 'title' => t('Please specify your gender.'), 'required' => 1))); $oForm->addElement(new \PFBC\Element\Checkbox(t('Interested in:'), 'match_sex', array('male' => t('Male') . ' ♂', 'female' => t('Female') . ' ♀', 'couple' => t('Couple')), array('value' => 'male', 'title' => t('Please specify whom you are looking for'), 'required' => 1))); $oForm->addElement(new \PFBC\Element\Date(t('Your Date of birth:'), 'birth_date', array('placeholder' => t('Month/Day/Year'), 'id' => 'birth_date', 'title' => t('Please specify your birth date using the calendar or with this format: Month/Day/Year.'), 'onblur' => 'CValid(this.value, this.id)', 'validation' => new \PFBC\Validation\BirthDate(), 'required' => 1))); $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error birth_date"></span>')); $oForm->addElement(new \PFBC\Element\Country(t('Your Country:'), 'country', array('id' => 'str_country', 'value' => Geo::getCountryCode(), 'title' => t('Select the country where you live.'), 'required' => 1))); $oForm->addElement(new \PFBC\Element\Textbox(t('Your City:'), 'city', array('id' => 'str_city', 'value' => Geo::getCity(), 'onblur' => 'CValid(this.value,this.id,2,150)', 'title' => t('Specify the city where you live.'), 'validation' => new \PFBC\Validation\Str(2, 150), 'required' => 1))); $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_city"></span>')); $oForm->addElement(new \PFBC\Element\Textbox(t('Your State or Province:'), 'state', array('id' => 'str_state', 'value' => Geo::getState(), 'onblur' => 'CValid(this.value,this.id,2,150)', 'title' => t('Specify your state.'), 'validation' => new \PFBC\Validation\Str(2, 150), 'required' => 1))); $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_state"></span>')); $oForm->addElement(new \PFBC\Element\Textbox(t('Your ZIP/Postal Code:'), 'zip_code', array('id' => 'str_zip_code', 'value' => Geo::getZipCode(), 'onblur' => 'CValid(this.value,this.id,2,15)', 'title' => t('Enter your post code (Zip).'), 'validation' => new \PFBC\Validation\Str(2, 15), 'required' => 1))); $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_zip_code"></span>')); $oForm->addElement(new \PFBC\Element\Button()); $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'validate.js"></script><script src="' . PH7_URL_STATIC . PH7_JS . 'geo/autocompleteCity.js"></script>')); $oForm->render(); }
/** * 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; }
/** * 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; }
/** * Users'levels. * * @return boolean */ public static function auth() { $oSession = new Session(); $oBrowser = new Browser(); $bIsConnect = (int) $oSession->exists('member_id') && $oSession->get('member_ip') === Ip::get() && $oSession->get('member_http_user_agent') === $oBrowser->getUserAgent(); /** Destruction of the object and minimize CPU resources **/ unset($oSession, $oBrowser); return $bIsConnect; }
/** * Check if the JS validationbox has to be added and redirect if the site hasn't been validated yet for a while. * * @param object \PH7\Framework\Session\Session $oSess * @return boolean */ public static function needInject(Framework\Session\Session $oSess) { $oVSModel = new ValidateSiteCoreModel(); $iSinceSiteCreated = VDate::getTime(StatisticCoreModel::getSiteSinceDate()); // After over 2 months, the site is still not validated, maybe the validation box doesn't really work, so we redirected to the page form if (!$oVSModel->is() && VDate::setTime('-2 months') > $iSinceSiteCreated && !$oSess->exists(self::SESS_IS_VISITED)) { Header::redirect(Uri::get('validate-site', 'main', 'validationbox')); } if (!$oVSModel->is() && VDate::setTime('-2 days') > $iSinceSiteCreated) { // OK for adding the validation colorbox return true; } return false; }
public static function checkGroup() { $oSession = new Framework\Session\Session(); if (!$oSession->exists('member_group_id')) { $oSession->regenerateId(); $oSession->set('member_group_id', '1'); // Visitor's group } unset($oSession); $rStmt = Db::getInstance()->prepare('SELECT permissions FROM' . Db::prefix('Memberships') . 'WHERE groupId = :groupId LIMIT 1'); $rStmt->bindParam(':groupId', $_SESSION[Framework\Config\Config::getInstance()->values['session']['prefix'] . 'member_group_id'], \PDO::PARAM_INT); $rStmt->execute(); $oFetch = $rStmt->fetch(\PDO::FETCH_OBJ); Db::free($rStmt); return Framework\CArray\ObjArr::toObject(unserialize($oFetch->permissions)); }
public static function checkGroup() { $oSession = new Framework\Session\Session(); if (!$oSession->exists('member_group_id')) { $oSession->regenerateId(); $oSession->set('member_group_id', '1'); // By default, it's the Visitor's group (ID 1) } $rStmt = Db::getInstance()->prepare('SELECT permissions FROM' . Db::prefix('Memberships') . 'WHERE groupId = :groupId LIMIT 1'); $rStmt->bindValue(':groupId', $oSession->get('member_group_id'), \PDO::PARAM_INT); $rStmt->execute(); $oFetch = $rStmt->fetch(\PDO::FETCH_OBJ); Db::free($rStmt); unset($oSession); return Framework\CArray\ObjArr::toObject(unserialize($oFetch->permissions)); }
/** * Constructor. * * @param object \PH7\Framework\Session\Session $oSession * @param object \PH7\Framework\Mvc\Request\Http $oHttpRequest * @param object \PH7\Framework\Registry\Registry $oRegistry * @return void */ public function __construct(Session $oSession, HttpRequest $oHttpRequest, Registry $oRegistry) { parent::__construct(); /*** Import the libraries ***/ Import::lib('Service.Google.OAuth.Google_Client'); Import::lib('Service.Google.OAuth.contrib.Google_Oauth2Service'); $oClient = new \Google_Client(); $oClient->setApplicationName($oRegistry->site_name); $this->_setConfig($oClient); $oOauth = new \Google_Oauth2Service($oClient); if ($oHttpRequest->getExists('code')) { $oClient->authenticate(); $oSession->set('token', $oClient->getAccessToken()); $this->sUrl = Uri::get('connect', 'main', 'home'); } if ($oSession->exists('token')) { $oClient->setAccessToken($oSession->get('token', false)); } if ($oClient->getAccessToken()) { // User info is ok? Here we will be connect the user and/or adding the login and registering routines... $oUserModel = new UserCoreModel(); // Get information of user $aUserData = $oOauth->userinfo->get(); if (!($iId = $oUserModel->getId($aUserData['email']))) { // Add User if it does not exist in our database $this->add(escape($aUserData, true), $oUserModel); // Add User Avatar if (!empty($aUserData['picture'])) { $this->setAvatar($aUserData['picture']); } $this->oDesign->setFlashMsg(t('You have now been registered! %0%', (new Registration())->sendMail($this->_aUserInfo, true)->getMsg())); $this->sUrl = Uri::get('connect', 'main', 'register'); } else { // Login $this->setLogin($iId, $oUserModel); $this->sUrl = Uri::get('connect', 'main', 'home'); } // Add the access token $oSession->set('token', $oClient->getAccessToken()); unset($oUserModel); } else { $this->sUrl = $oClient->createAuthUrl(); } unset($oClient, $oOauth); }
/** * @return boolean Return "true" If we believe that this person takes too much request otherwise "false" */ public function session() { $oSession = new Session(); if (!$oSession->exists(static::COOKIE_NAME)) { $oSession->set(static::COOKIE_NAME, 1); } else { $oSession->set(static::COOKIE_NAME, $oSession->get(static::COOKIE_NAME) + 1); } if ($oSession->get(static::COOKIE_NAME) > PH7_DDOS_MAX_SESSION_PAGE_LOAD) { $oSession->remove(static::COOKIE_NAME); // Remove Session $bStatus = true; } else { $bStatus = false; } unset($oSession); return $bStatus; }