Пример #1
0
 /**
  * Check if an external app can have access to the API.
  *
  * @param \PH7\Framework\Config\Config $oConfig
  * @param \PH7\Framework\Mvc\Request\Http $oRequest
  * @return boolean TRUE is the app has access, FALSE otherwise.
  */
 public static function checkAccess(Config $oConfig, Http $oRequest)
 {
     if (strcmp($oRequest->post('private_api_key'), $oConfig->values['api']['private_key']) === 0) {
         return in_array($oRequest->post('url'), $oConfig->values['api']['allow_domains']);
     }
     return false;
 }
Пример #2
0
 /**
  * Gets Ads Table.
  *
  * @return string The Table.
  */
 public static function getTable()
 {
     $oHttpRequest = new Http();
     $sTable = $oHttpRequest->getExists('ads_type') && $oHttpRequest->get('ads_type') == 'affiliate' ? 'AdsAffiliates' : 'Ads';
     unset($oHttpRequest);
     return $sTable;
 }
Пример #3
0
 public static function display()
 {
     if (isset($_POST['submit_edit'])) {
         if (\PFBC\Form::isValid($_POST['submit_edit'])) {
             new AdminEditFormProcess();
         }
         Framework\Url\HeaderUrl::redirect();
     }
     $oHttpRequest = new Http();
     $oGameModel = new GameModel();
     $iGameId = $oHttpRequest->get('id', 'int');
     $oGame = $oGameModel->get(strstr($oHttpRequest->get('title'), '-', true), $iGameId, 0, 1);
     $oCategoriesData = $oGameModel->getCategory(null, 0, 500);
     $aCategoriesName = array();
     foreach ($oCategoriesData as $oId) {
         $aCategoriesName[$oId->categoryId] = $oId->name;
     }
     unset($oHttpRequest, $oGameModel);
     $sTitlePattern = Config::getInstance()->values['module.setting']['url_title.pattern'];
     if (!empty($oGame) && (new Str())->equals($iGameId, $oGame->gameId)) {
         $oForm = new \PFBC\Form('form_edit', 650);
         $oForm->configure(array('action' => ''));
         $oForm->addElement(new \PFBC\Element\Hidden('submit_edit', 'form_edit'));
         $oForm->addElement(new \PFBC\Element\Token('edit'));
         $oForm->addElement(new \PFBC\Element\Select(t('Category Name:'), 'category_id', $aCategoriesName, array('value' => $oGame->categoryId, 'required' => 1)));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Name of the Game:'), 'name', array('value' => $oGame->name, 'pattern' => $sTitlePattern, 'validation' => new \PFBC\Validation\RegExp($sTitlePattern), 'required' => 1)));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Title of the Game:'), 'title', array('value' => $oGame->title, 'validation' => new \PFBC\Validation\Str(2, 120), 'required' => 1)));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Description:'), 'description', array('value' => $oGame->description, 'validation' => new \PFBC\Validation\Str(2, 255), 'required' => 1)));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Keywords:'), 'keywords', array('value' => $oGame->keywords, 'validation' => new \PFBC\Validation\Str(2, 255), 'required' => 1)));
         $oForm->addElement(new \PFBC\Element\Button());
         $oForm->render();
     } else {
         echo '<p class="center bold">' . t('Game Not Found!') . '</p>';
     }
 }
Пример #4
0
 public static function display()
 {
     if (isset($_POST['submit_bank_account'])) {
         if (\PFBC\Form::isValid($_POST['submit_bank_account'])) {
             new BankFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oHR = new Http();
     $iProfileId = AdminCore::auth() && !Affiliate::auth() && $oHR->getExists('profile_id') ? $oHR->get('profile_id', 'int') : (new Session())->get('affiliate_id');
     $oAff = (new AffiliateModel())->readProfile($iProfileId, 'Affiliates');
     $oForm = new \PFBC\Form('form_bank_account', 500);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_bank_account', 'form_bank_account'));
     $oForm->addElement(new \PFBC\Element\Token('bank_account'));
     if (AdminCore::auth() && !Affiliate::auth() && $oHR->getExists('profile_id')) {
         $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="center"><a class="s_button" href="' . Uri::get('affiliate', 'admin', 'browse') . '">' . t('Return to back affiliates browse') . '</a></p>'));
     }
     unset($oHR);
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<h2 class="underline">' . t('Bank Information:') . '</h2>'));
     $sHtmlPayPalIcon = '<a href="http://paypal.com" target="_blank"><img src="' . PH7_URL_STATIC . PH7_IMG . 'icon/paypal_small.gif" alt="PayPal" title="PayPal"></a><br />';
     $oForm->addElement(new \PFBC\Element\Email($sHtmlPayPalIcon . t('Your Bank Account:'), 'bank_account', array('id' => 'email_paypal', 'onblur' => 'CValid(this.value,this.id)', 'description' => t('Your Bank Account (PayPal Email Address).'), 'title' => t('Your Bank Account.'), 'value' => $oAff->bankAccount, 'validation' => new \PFBC\Validation\BankAccount(), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HtmlExternal('<span class="input_error email_paypal"></span>'));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'validate.js"></script>'));
     $oForm->render();
 }
Пример #5
0
 public static function display()
 {
     if (isset($_POST['submit_picture'])) {
         if (\PFBC\Form::isValid($_POST['submit_picture'])) {
             new PictureFormProcess();
         }
         Framework\Url\HeaderUrl::redirect();
     }
     $oHttpRequest = new Http();
     $iAlbumIdVal = $oHttpRequest->getExists('album_id') ? $oHttpRequest->get('album_id') : null;
     // Album ID Value
     unset($oHttpRequest);
     $oAlbumId = (new PictureModel())->getAlbumsName((new Session())->get('member_id'));
     $aAlbumName = array();
     foreach ($oAlbumId as $iId) {
         $aAlbumName[$iId->albumId] = $iId->name;
     }
     $oForm = new \PFBC\Form('form_picture', 500);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_picture', 'form_picture'));
     $oForm->addElement(new \PFBC\Element\Token('picture'));
     $oForm->addElement(new \PFBC\Element\Select(t('Choose your album - OR - <a href="%0%">Add a new Album</a>', Uri::get('picture', 'main', 'addalbum')), 'album_id', $aAlbumName, array('value' => $iAlbumIdVal, 'required' => 1)));
     unset($aAlbumName);
     $oForm->addElement(new \PFBC\Element\Hidden('album_title', @$iId->name));
     // Bad title! Thank you for finding a solution and send it by email
     $oForm->addElement(new \PFBC\Element\Textbox(t('Name of your photo(s):'), 'title', array('validation' => new \PFBC\Validation\Str(2, 40))));
     $oForm->addElement(new \PFBC\Element\File(t('Your picture(s)'), 'photos[]', array('description' => '<span class="bold">' . t('Tip:') . '</span> ' . t('You can select multiple photos at once by clicking multiple files while holding down the "CTRL" key.'), 'multiple' => 'multiple', 'accept' => 'image/*', 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="pfbc-label"><em><span class="bold">' . t('Note:') . '</span> ' . t('Please be patient while downloading pictures, this may take time (especially if you download a lot of photos at once).') . '</em></p>'));
     $oForm->addElement(new \PFBC\Element\Textarea(t('Description of your photo:'), 'description', array('validation' => new \PFBC\Validation\Str(2, 200))));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
 public function __construct()
 {
     $oHR = new HttpRequest();
     $aData = (new ImportUser($_FILES['csv_file'], $oHR->post('delimiter'), $oHR->post('enclosure')))->getResponse();
     if (!$aData['status']) {
         \PFBC\Form::setError('form_import_user', $aData['msg']);
     } else {
         Header::redirect(Uri::get(PH7_ADMIN_MOD, 'user', 'browse'), $aData['msg']);
     }
 }
Пример #7
0
 public static function display()
 {
     if (isset($_POST['submit_user_edit_account'])) {
         if (\PFBC\Form::isValid($_POST['submit_user_edit_account'])) {
             new EditFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $bAdminLogged = AdminCore::auth() && !User::auth();
     // Check if the admin is logged.
     $oUserModel = new UserModel();
     $oHR = new Http();
     $iProfileId = $bAdminLogged && $oHR->getExists('profile_id') ? $oHR->get('profile_id', 'int') : (new Session())->get('member_id');
     $oUser = $oUserModel->readProfile($iProfileId);
     // Birth Date with the date format for the date picker
     $sBirthDate = (new CDateTime())->get($oUser->birthDate)->date('m/d/Y');
     $oForm = new \PFBC\Form('form_user_edit_account');
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_user_edit_account', 'form_user_edit_account'));
     $oForm->addElement(new \PFBC\Element\Token('edit_account'));
     if ($bAdminLogged && $oHR->getExists('profile_id')) {
         $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="center"><a class="m_button" href="' . Uri::get(PH7_ADMIN_MOD, 'user', 'browse') . '">' . t('Back to Browse Users') . '</a></p>'));
         $oGroupId = (new AdminCoreModel())->getMemberships();
         $aGroupName = array();
         foreach ($oGroupId as $oId) {
             // Retrieve only the activated memberships
             if ($oId->enable == 1) {
                 $aGroupName[$oId->groupId] = $oId->name;
             }
         }
         $oForm->addElement(new \PFBC\Element\Select(t('Membership Group:'), 'group_id', $aGroupName, array('value' => $oUser->groupId, 'required' => 1)));
         unset($aGroupName);
     }
     unset($oHR);
     $oForm->addElement(new \PFBC\Element\Textbox(t('First Name:'), 'first_name', array('id' => 'str_first_name', 'onblur' => 'CValid(this.value,this.id,2,20)', 'value' => $oUser->firstName, 'required' => 1, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_first_name"></span>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Last Name:'), 'last_name', array('id' => 'str_last_name', 'onblur' => 'CValid(this.value,this.id,2,20)', 'value' => $oUser->lastName, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_last_name"></span>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Username:'******'username', array('description' => t('For site security, you cannot change your username.'), 'disabled' => 'disabled', 'value' => $oUser->username)));
     $oForm->addElement(new \PFBC\Element\Email(t('Email:'), 'mail', array('description' => t('For site security and to avoid spam, you cannot change your email address.'), 'disabled' => 'disabled', 'value' => $oUser->email)));
     $oForm->addElement(new \PFBC\Element\Radio(t('Gender:'), 'sex', array('female' => t('Female'), 'male' => t('Male'), 'couple' => t('Couple')), array('value' => $oUser->sex, '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' => Form::getVal($oUser->matchSex), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Date(t('Date of birth:'), 'birth_date', array('id' => 'birth_date', 'onblur' => 'CValid(this.value, this.id)', 'value' => $sBirthDate, 'validation' => new \PFBC\Validation\BirthDate(), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error birth_date"></span>'));
     // Generate dynamic fields
     $oFields = $oUserModel->getInfoFields($iProfileId);
     foreach ($oFields as $sColumn => $sValue) {
         $oForm = (new DynamicFieldCoreForm($oForm, $sColumn, $sValue))->generate();
     }
     $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();
 }
Пример #8
0
 /**
  * Output Advertisement.
  *
  * @static
  * @param object $oData Db query.
  * @return string
  */
 public static function output($oData)
 {
     // Stat Advertisement Shows
     \PH7\Framework\Analytics\Statistic::setView($oData->adsId, 'Ads');
     // Advertisement Clicks
     $oHttpRequest = new Mvc\Request\Http();
     if ($oHttpRequest->getExists(static::PARAM_URL) && $oHttpRequest->get(static::PARAM_URL) == $oData->adsId) {
         Mvc\Model\Ads::setClick($oData->adsId);
     }
     unset($oHttpRequest);
     return (new \PH7\Framework\Parse\SysVar())->parse($oData->code);
 }
Пример #9
0
 public static function display()
 {
     $oHttpRequest = new Http();
     $sUsername = $oHttpRequest->get('username');
     $sAction = $oHttpRequest->getExists('action') ? 'mutual' : 'index';
     unset($oHttpRequest);
     $oForm = new \PFBC\Form('form_search', 500);
     $oForm->configure(array('action' => Uri::get('user', 'friend', $sAction, $sUsername) . PH7_SH, 'method' => 'get'));
     $oForm->addElement(new \PFBC\Element\Search(t('Search a Friend of "%0%"', $sUsername), 'looking', array('title' => t('Enter its First Name, Last Name, Username, Email address or ID of your Friend.'))));
     $oForm->addElement(new \PFBC\Element\Select(t('Browse By:'), 'order', array(SearchCoreModel::USERNAME => t('Username'), SearchCoreModel::FIRST_NAME => t('First Name'), SearchCoreModel::LAST_NAME => t('Last Name'), SearchCoreModel::EMAIL => t('Email'), SearchCoreModel::LATEST => t('Latest'), SearchCoreModel::LAST_ACTIVITY => t('Last Activity'), SearchCoreModel::VIEWS => t('Popular'), SearchCoreModel::RATING => t('Rated'))));
     $oForm->addElement(new \PFBC\Element\Select(t('Direction:'), 'sort', array(SearchCoreModel::ASC => t('Ascending'), SearchCoreModel::DESC => t('Descending'))));
     $oForm->addElement(new \PFBC\Element\Button(t('Search'), 'submit', array('icon' => 'search')));
     $oForm->render();
 }
Пример #10
0
 /**
  * Allows a redirection URL respecting the HTTP status code for search engines friendly.
  *
  * @static
  * @param string $sUrl Default NULL, so it's the current URL.
  * @param string $sMessage Default NULL, so no message.
  * @param string $sType Type of message: "success", "info", "warning" or "error". Default: "success".
  * @param integer $iRedirectCode Default NULL, so the redirect code will be "301".
  * @return void
  */
 public static function redirect($sUrl = null, $sMessage = null, $sType = 'success', $iRedirectCode = null)
 {
     if (!Http::getStatusCodes($iRedirectCode)) {
         $iRedirectCode = 301;
     }
     Http::setHeadersByCode(Http::getStatusCodes($iRedirectCode));
     $oHttpRequest = new HttpRequest();
     $sUrl = !empty($sUrl) ? $sUrl : $oHttpRequest->currentUrl();
     $sUrl = $oHttpRequest->pH7Url($sUrl);
     unset($oHttpRequest);
     if (!empty($sMessage)) {
         (new \PH7\Framework\Layout\Html\Design())->setFlashMsg($sMessage, $sType);
     }
     header('Location: ' . $sUrl);
     exit;
 }
Пример #11
0
 private function _init()
 {
     $oHttpRequest = new Http();
     $sParam = $oHttpRequest->post('param');
     $sType = $oHttpRequest->post('type');
     unset($oHttpRequest);
     switch ($sType) {
         case 'profile_link':
             $this->_mOutput = $this->_oUser->getProfileLink($sParam);
             break;
             // If we receive another invalid value, we display a message with a HTTP header.
         // If we receive another invalid value, we display a message with a HTTP header.
         default:
             Framework\Http\Http::setHeadersByCode(400);
             exit('Bad Request Error!');
     }
 }
Пример #12
0
 public static function display()
 {
     if (isset($_POST['submit_admin_edit_account'])) {
         if (\PFBC\Form::isValid($_POST['submit_admin_edit_account'])) {
             new EditFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oHR = new Http();
     // Prohibit other administrators to edit the Root Administrator (ID 1)
     $iProfileId = $oHR->getExists('profile_id') && $oHR->get('profile_id', 'int') !== 1 ? $oHR->get('profile_id', 'int') : (new Session())->get('admin_id');
     $oAdmin = (new AdminModel())->readProfile($iProfileId, 'Admins');
     $oForm = new \PFBC\Form('form_admin_edit_account', 500);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_admin_edit_account', 'form_admin_edit_account'));
     $oForm->addElement(new \PFBC\Element\Token('edit_account'));
     if ($oHR->getExists('profile_id') && $oHR->get('profile_id', 'int') !== 1) {
         $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="center"><a class="s_button" href="' . Uri::get(PH7_ADMIN_MOD, 'admin', 'browse') . '">' . t('Return to back admins browse') . '</a></p>'));
     }
     unset($oHR);
     $oForm->addElement(new \PFBC\Element\Textbox(t('Username:'******'username', array('value' => $oAdmin->username, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Email(t('Login Email:'), 'mail', array('value' => $oAdmin->email, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('First Name:'), 'first_name', array('value' => $oAdmin->firstName, 'required' => 1, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Last Name:'), 'last_name', array('value' => $oAdmin->lastName, 'required' => 1, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\Radio(t('Sex:'), 'sex', array('male' => t('Male'), 'female' => t('Female')), array('value' => $oAdmin->sex, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Timezone('Time Zone:', 'time_zone', array('value' => $oAdmin->timeZone, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
Пример #13
0
 public static function display()
 {
     if (isset($_POST['submit_aff_edit_account'])) {
         if (\PFBC\Form::isValid($_POST['submit_aff_edit_account'])) {
             new EditFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $bAdminLogged = AdminCore::auth() && !Affiliate::auth();
     // Check if the admin is logged.
     $oAffModel = new AffiliateModel();
     $oHR = new Http();
     $iProfileId = $bAdminLogged && $oHR->getExists('profile_id') ? $oHR->get('profile_id', 'int') : (new Session())->get('affiliate_id');
     $oAff = $oAffModel->readProfile($iProfileId, 'Affiliates');
     // Birth date with the date format for the date picker
     $sBirthDate = (new CDateTime())->get($oAff->birthDate)->date('m/d/Y');
     $oForm = new \PFBC\Form('form_aff_edit_account', 500);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_aff_edit_account', 'form_aff_edit_account'));
     $oForm->addElement(new \PFBC\Element\Token('edit_account'));
     if ($bAdminLogged && $oHR->getExists('profile_id')) {
         $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="center"><a class="m_button" href="' . Uri::get('affiliate', 'admin', 'browse') . '">' . t('Back to Browse Affiliates') . '</a></p>'));
     }
     unset($oHR);
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<h2 class="underline">' . t('Global Information:') . '</h2>'));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="error">' . t('Attention all your information must be complete, candid and valid.') . '</p>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Your First Name:'), 'first_name', array('id' => 'str_first_name', 'onblur' => 'CValid(this.value,this.id,2,20)', 'value' => $oAff->firstName, 'required' => 1, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_first_name"></span>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Your Last Name:'), 'last_name', array('id' => 'str_last_name', 'onblur' => 'CValid(this.value,this.id,2,20)', 'value' => $oAff->lastName, 'required' => 1, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_last_name"></span>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Username:'******'username', array('description' => t('For site security, you cannot change your username.'), 'disabled' => 'disabled', 'value' => $oAff->username)));
     $oForm->addElement(new \PFBC\Element\Email(t('Your Email:'), 'mail', array('description' => t('For site security and to avoid spam, you cannot change your email address.'), 'disabled' => 'disabled', 'value' => $oAff->email)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error phone"></span>'));
     $oForm->addElement(new \PFBC\Element\Radio(t('Your Sex:'), 'sex', array('male' => t('Male'), 'female' => t('Female')), array('value' => $oAff->sex, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Date(t('Your Date of birth:'), 'birth_date', array('id' => 'birth_date', 'onblur' => 'CValid(this.value, this.id)', 'value' => $sBirthDate, 'validation' => new \PFBC\Validation\BirthDate(), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error birth_date"></span>'));
     // Generate dynamic fields
     $oFields = $oAffModel->getInfoFields($iProfileId, 'AffiliatesInfo');
     foreach ($oFields as $sColumn => $sValue) {
         $oForm = (new DynamicFieldCoreForm($oForm, $sColumn, $sValue))->generate();
     }
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'validate.js"></script>'));
     $oForm->render();
 }
Пример #14
0
 /**
  * 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);
 }
Пример #15
0
 public static function display()
 {
     if (isset($_POST['submit_edit_reply_msg'])) {
         if (\PFBC\Form::isValid($_POST['submit_edit_reply_msg'])) {
             new EditReplyMsgFormProcess();
         }
         Framework\Url\HeaderUrl::redirect();
     }
     $oHttpRequest = new Http();
     $oMsg = (new ForumModel())->getMessage($oHttpRequest->get('topic_id'), $oHttpRequest->get('message_id'), (new Session())->get('member_id'), 1, 0, 1);
     unset($oHttpRequest);
     $oForm = new \PFBC\Form('form_edit_reply_msg', '100%');
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_edit_reply_msg', 'form_edit_reply_msg'));
     $oForm->addElement(new \PFBC\Element\Token('edit_reply_msg'));
     $oForm->addElement(new \PFBC\Element\CKEditor(t('Message:'), 'message', array('value' => $oMsg->message, 'required' => 1, 'validation' => new \PFBC\Validation\Str(4))));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
 public static function display()
 {
     if (isset($_POST['submit_edit_comment'])) {
         if (\PFBC\Form::isValid($_POST['submit_edit_comment'])) {
             new EditCommentFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oHttpRequest = new Http();
     $oForm = new \PFBC\Form('form_edit_comment', 500);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_edit_comment', 'form_edit_comment'));
     $oForm->addElement(new \PFBC\Element\Token('edit_comment'));
     $oData = (new CommentModel())->get($oHttpRequest->get('id'), 1, $oHttpRequest->get('table'));
     $oForm->addElement(new \PFBC\Element\Textarea(t('Edit your comment:'), 'comment', array('value' => $oData->comment, 'required' => 1, 'validation' => new \PFBC\Validation\Str(2, 2000))));
     unset($oHttpRequest, $oData);
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
 public static function display()
 {
     if (isset($_POST['submit_edit_picture'])) {
         if (\PFBC\Form::isValid($_POST['submit_edit_picture'])) {
             new EditPictureFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oForm = new \PFBC\Form('form_edit_picture', 500);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_edit_picture', 'form_edit_picture'));
     $oForm->addElement(new \PFBC\Element\Token('edit_picture'));
     $oHttpRequest = new Http();
     $oPhoto = (new PictureModel())->photo((new Session())->get('member_id'), $oHttpRequest->get('album_id'), $oHttpRequest->get('picture_id'), 1, 0, 1);
     unset($oHttpRequest);
     $oForm->addElement(new \PFBC\Element\Textbox(t('Name of your photo:'), 'title', array('value' => $oPhoto->title, 'required' => 1, 'validation' => new \PFBC\Validation\Str(2, 40))));
     $oForm->addElement(new \PFBC\Element\Textarea(t('Description of your photo:'), 'description', array('value' => $oPhoto->description, 'validation' => new \PFBC\Validation\Str(2, 200))));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
Пример #18
0
 public static function display()
 {
     if (isset($_POST['submit_compose_mail'])) {
         if (\PFBC\Form::isValid($_POST['submit_compose_mail'])) {
             new MailFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oHttpRequest = new Http();
     // For Reply Function
     $oForm = new \PFBC\Form('form_compose_mail', '100%');
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_compose_mail', 'form_compose_mail'));
     $oForm->addElement(new \PFBC\Element\Token('compose_mail'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Recipient:'), 'recipient', array('id' => 'recipient', 'value' => $oHttpRequest->get('recipient'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Subject:'), 'title', array('id' => 'str_title', 'onblur' => 'CValid(this.value,this.id,2,60)', 'value' => $oHttpRequest->get('title') != '' ? t('RE: ') . str_replace('-', ' ', $oHttpRequest->get('title')) : '', 'validation' => new \PFBC\Validation\Str(2, 60), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_title"></span>'));
     $oForm->addElement(new \PFBC\Element\CKEditor(t('Your message:'), 'message', array('id' => 'str_msg', 'onblur' => 'CValid(this.value,this.id,2,2500)', 'value' => $oHttpRequest->get('message'), 'validation' => new \PFBC\Validation\Str(2, 2500), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_msg"></span>'));
     unset($oHttpRequest);
     if (!AdminCore::auth() && DbConfig::getSetting('isCaptchaMail')) {
         $oForm->addElement(new \PFBC\Element\CCaptcha(t('Captcha:'), 'captcha', array('id' => 'ccaptcha', 'onkeyup' => 'CValid(this.value, this.id)', 'description' => t('Enter the code above:'))));
         $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error ccaptcha"></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 . 'autocompleteUsername.js"></script>'));
     $oForm->render();
 }
Пример #19
0
 public static function display()
 {
     if (isset($_POST['submit_video'])) {
         if (\PFBC\Form::isValid($_POST['submit_video'])) {
             new VideoFormProcess();
         }
         Framework\Url\HeaderUrl::redirect();
     }
     $oHttpRequest = new Http();
     $iAlbumIdVal = $oHttpRequest->getExists('album_id') ? $oHttpRequest->get('album_id') : null;
     // Album ID Value
     unset($oHttpRequest);
     $oAlbumId = (new VideoModel())->getAlbumsName((new Session())->get('member_id'));
     $aAlbumName = array();
     foreach ($oAlbumId as $iId) {
         $aAlbumName[$iId->albumId] = $iId->name;
     }
     $oForm = new \PFBC\Form('form_video', 500);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_video', 'form_video'));
     $oForm->addElement(new \PFBC\Element\Token('video'));
     $oForm->addElement(new \PFBC\Element\Select(t('Choose your album - OR - <a href="%0%">Add a new Album</a>', Uri::get('video', 'main', 'addalbum')), 'album_id', $aAlbumName, array('value' => $iAlbumIdVal, 'required' => 1)));
     unset($aAlbumName);
     $oForm->addElement(new \PFBC\Element\Hidden('album_title', @$iId->name));
     // Bad title! Thank you for finding a solution and send it by email
     $oForm->addElement(new \PFBC\Element\Textbox(t('Name of your video(s):'), 'title', array('validation' => new \PFBC\Validation\Str(2, 40))));
     $oForm->addElement(new \PFBC\Element\Select('Video type:', 'type', array(t('Choose...'), 'embed' => t('Embed Code'), 'regular' => t('Regular')), array('required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<div class="hidden" id="regular">'));
     $oForm->addElement(new \PFBC\Element\File(t('Video:'), 'video', array('description' => '<span class="bold">' . t('Note:') . '</span> ' . t('Please be patient while downloading video, this may take time (especially if you download a long video).') . '</em>', 'multiple' => 'multiple', 'accept' => 'video/*')));
     $oForm->addElement(new \PFBC\Element\Checkbox('', 'agree', array('1' => t('I have the right to distribute this Video'))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('</div><div class="hidden" id="embed">'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Embed Code:'), 'embed_code', array('description' => t('Example: %0%', DbConfig::getSetting('defaultVideo')), 'title' => t('Video from Youtube, Vimeo, DailyMotion or MetaCafe.'), 'validation' => new \PFBC\Validation\Url())));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('</div>'));
     $oForm->addElement(new \PFBC\Element\Textarea(t('Description of your video:'), 'description', array('validation' => new \PFBC\Validation\Str(2, 200))));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'form.js"></script>'));
     $oForm->render();
 }
Пример #20
0
 public static function display()
 {
     $oHttpRequest = new Http();
     if ($oHttpRequest->postExists('submit_report')) {
         if (\PFBC\Form::isValid($oHttpRequest->post('submit_report'))) {
             new ReportFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oForm = new \PFBC\Form('form_report', 350);
     $oForm->configure(array('action' => $oHttpRequest->currentUrl()));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_report', 'form_report'));
     $oForm->addElement(new \PFBC\Element\Token('report'));
     $oForm->addElement(new \PFBC\Element\Hidden('spammer', $oHttpRequest->get('spammer'), array('required' => 1)));
     $oForm->addElement(new \PFBC\Element\Hidden('url', $oHttpRequest->get('url'), array('validation' => new \PFBC\Validation\Url())));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3 class="center">' . t('Do your want to report this?') . '</h4>'));
     $oForm->addElement(new \PFBC\Element\Select(t('Type the Content'), 'type', array('user' => t('Profile'), 'avatar' => t('Avatar'), 'mail' => t('Message'), 'comment' => t('Comment'), 'picture' => t('Photo'), 'video' => t('Video'), 'forum' => t('Forum'), 'note' => t('Note')), array('value' => $oHttpRequest->get('type'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textarea(t('Comment:'), 'desc', array('title' => t('Please tell us why you want to report this content (scam, illegal content, adult content, etc.). Help us to eliminate scams, fake profiles, spam ... Thank you'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Button(t('Report this'), 'submit'));
     $oForm->addElement(new \PFBC\Element\Button(t('Cancel'), 'cancel', array('onclick' => 'parent.$.colorbox.close()')));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'str.js"></script>'));
     $oForm->render();
 }
Пример #21
0
 public static function display()
 {
     if (isset($_POST['submit_edit_msg'])) {
         if (\PFBC\Form::isValid($_POST['submit_edit_msg'])) {
             new EditMsgFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oHttpRequest = new Http();
     $oMsg = (new ForumModel())->getTopic(strstr($oHttpRequest->get('forum_name'), '-', true), $oHttpRequest->get('forum_id'), strstr($oHttpRequest->get('topic_name'), '-', true), $oHttpRequest->get('topic_id'), (new Session())->get('member_id'), 1, 0, 1);
     unset($oHttpRequest);
     $sTitlePattern = Config::getInstance()->values['module.setting']['url_title.pattern'];
     $oForm = new \PFBC\Form('form_edit_msg', '100%');
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_edit_msg', 'form_edit_msg'));
     $oForm->addElement(new \PFBC\Element\Token('edit_msg'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Subject:'), 'title', array('value' => $oMsg->title, 'id' => 'str_title', 'onblur' => 'CValid(this.value,this.id,2,60)', 'pattern' => $sTitlePattern, 'required' => 1, 'validation' => new \PFBC\Validation\RegExp($sTitlePattern))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_title"></span>'));
     $oForm->addElement(new \PFBC\Element\CKEditor(t('Message:'), 'message', array('value' => $oMsg->message, 'required' => 1, 'validation' => new \PFBC\Validation\Str(4))));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'validate.js"></script>'));
     $oForm->render();
 }
            $this->_sMsg = t('OK!');
        }
    }
    /**
     * Validation of the acceptance of the terms of use.
     *
     * @access protected
     * @return string $sValue
     * @return void
     */
    protected function terms($sValue)
    {
        if ($sValue != 'true') {
            $this->_sMsg = t('You must read and approve the terms of use!');
        } else {
            $this->_iStatus = 1;
        }
    }
    /**
     * Destruction of objects to optimize the resources of RAM.
     */
    public function __destruct()
    {
        unset($this->_oStr, $this->_oValidate, $this->_oExistsModel, $this->_sMsg, $this->_iStatus);
    }
}
$oHttpRequest = new Http();
if ($oHttpRequest->postExists('fieldId')) {
    (new ValidateCoreAjax())->form($oHttpRequest->post('inputVal'), $oHttpRequest->post('fieldId'), $oHttpRequest->post('param1'), $oHttpRequest->post('param2'));
}
unset($oHttpRequest);
<?php

/**
 * @author         Pierre-Henry Soria <*****@*****.**>
 * @copyright      (c) 2012-2015, Pierre-Henry Soria. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7 / App / System / Module / Note / Asset / Ajax
 */
namespace PH7;

defined('PH7') or exit('Restricted access');
use PH7\Framework\Mvc\Request\Http;
$oHttpRequest = new Http();
$iStatus = 0;
// Error Default Value
if ($oHttpRequest->postExists('post_id')) {
    $iStatus = (new Note())->checkPostId($oHttpRequest->post('post_id'), $oHttpRequest->post('profile_id')) ? 1 : 0;
}
echo json_encode(array('status' => $iStatus));
unset($oHttpRequest);
<?php

/**
 * @author         Pierre-Henry Soria <*****@*****.**>
 * @copyright      (c) 2012-2016, Pierre-Henry Soria. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7 / App / System / Core / Asset / Ajax / Popup
 */
namespace PH7;

defined('PH7') or exit('Restricted access');
use PH7\Framework\Mvc\Request\Http, PH7\Framework\Layout\Html\Design, PH7\Framework\Url\Url, PH7\Framework\Mvc\Router\Uri, PH7\Framework\Url\Header;
if (AdminCore::auth() || UserCore::auth() || AffiliateCore::auth()) {
    $oHttpRequest = new Http();
    $oDesign = new Design();
    $oDesign->htmlHeader();
    $oDesign->usefulHtmlHeader();
    echo '<div class="center">';
    if ($oHttpRequest->getExists(array('mod', 'ctrl', 'act', 'id'))) {
        $sLabel = $oHttpRequest->get('label');
        $sMod = $oHttpRequest->get('mod');
        $sCtrl = $oHttpRequest->get('ctrl');
        $sAct = $oHttpRequest->get('act');
        $mId = $oHttpRequest->get('id');
        ConfirmCoreForm::display(array('label' => Url::decode($sLabel), 'module' => $sMod, 'controller' => $sCtrl, 'action' => $sAct, 'id' => $mId));
    } else {
        echo '<p>' . t('Bad parameters in the URL!') . '</p>';
    }
    echo '</div>';
    $oDesign->htmlFooter();
    unset($oHttpRequest, $oDesign);
<?php

/**
 * @author         Pierre-Henry Soria <*****@*****.**>
 * @copyright      (c) 2012-2016, Pierre-Henry Soria. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7 / App / System / Module / User / Asset / Ajax / Form
 */
namespace PH7;

defined('PH7') or exit('Restricted access');
use PH7\Framework\Security\Validate\Validate, PH7\Framework\Mvc\Model\DbConfig, PH7\Framework\Mvc\Request\Http;
$oHttpRequest = new Http();
$iStatus = 0;
// Error Default Value
if ($oHttpRequest->postExists('username')) {
    $iStatus = (new Validate())->username($oHttpRequest->post('username'), DbConfig::getSetting('minUsernameLength'), DbConfig::getSetting('maxUsernameLength')) ? 1 : 0;
}
echo json_encode(array('status' => $iStatus));
unset($oHttpRequest);
 * @title          Autocomplete Username File
 * @desc           This file can suggest a list of user name with jQuery and Ajax.
 *
 * @author         Pierre-Henry Soria <*****@*****.**>
 * @copyright      (c) 2012-2016, Pierre-Henry Soria. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7 / App / System / Core / Asset / Ajax
 * @version        1.0
 */
namespace PH7;

defined('PH7') or exit('Restricted access');
use PH7\Framework\Layout\Html\Design, PH7\Framework\Session\Session, PH7\Framework\Mvc\Request\Http;
// Only for members
if (UserCore::auth()) {
    $oHttpRequest = new Http();
    if ($oHttpRequest->postExists('username')) {
        if ($oUsernameResult = (new UserCoreModel())->getUsernameList($oHttpRequest->post('username'))) {
            // XML tags
            echo '<users><ul>';
            foreach ($oUsernameResult as $oList) {
                // Do not include the user profile that is connected since it doesn't make sense.
                if ($oList->profileId == (new Session())->get('member_id')) {
                    break;
                }
                echo '<li>
                        <username>', escape($oList->username, true), '</username>
                        <avatar>', (new Design())->getUserAvatar($oList->username, $oList->sex, 32), '</avatar>
                      </ul>';
            }
            echo '</ul></users>';
 /**
  * Checks the URL Token.
  *
  * @return boolean
  */
 public function checkUrl()
 {
     $oHttpRequest = new Http();
     $bRet = $this->currentSess() === true || $oHttpRequest->currentUrl() === PH7_URL_ROOT || $oHttpRequest->get(static::VAR_NAME) === $this->currentSess();
     unset($oHttpRequest);
     return $bRet;
 }
<?php

/**
 * @author         Pierre-Henry Soria <*****@*****.**>
 * @copyright      (c) 2012-2015, Pierre-Henry Soria. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7 / App / System / Module / Blog / Asset / Ajax / Form
 */
namespace PH7;

defined('PH7') or exit('Restricted access');
use PH7\Framework\Mvc\Request\Http;
$oHttpRequest = new Http();
$iStatus = 0;
// Error Default Value
if ($oHttpRequest->postExists('post_id')) {
    $iStatus = (new Blog())->checkPostId($oHttpRequest->post('post_id')) ? 1 : 0;
}
echo json_encode(array('status' => $iStatus));
unset($oHttpRequest);