Exemplo n.º 1
0
 public static function display()
 {
     $sActUrl = Uri::get('newsletter', 'home', 'subscription');
     if (isset($_POST['submit_subscription'])) {
         if (\PFBC\Form::isValid($_POST['submit_subscription'])) {
             new SubscriptionFormProcess();
         }
         Framework\Url\HeaderUrl::redirect($sActUrl);
     }
     $oForm = new \PFBC\Form('form_subscription', 350);
     $oForm->configure(array('action' => $sActUrl));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_subscription', 'form_subscription'));
     $oForm->addElement(new \PFBC\Element\Token('subscription'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Your full name:'), 'name', array('id' => 'str_name', 'onblur' => 'CValid(this.value, this.id,4,80)', 'validation' => new \PFBC\Validation\Str(4, 80), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_name"></span>'));
     $oForm->addElement(new \PFBC\Element\Email(t('Your email:'), 'email', array('id' => 'email', 'onblur' => 'CValid(this.value, this.id)', 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error email"></span>'));
     $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\Hidden('direction', ''));
     $oForm->addElement(new \PFBC\Element\Button(t('Subscribe'), 'submit', array('onclick' => '$("#form_subscription [name=direction]").val("subscrire");')));
     $oForm->addElement(new \PFBC\Element\Button(t('Unsubscribe'), 'submit', array('onclick' => '$("#form_subscription [name=direction]").val("unsubscribe");')));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'validate.js"></script>'));
     $oForm->render();
 }
 public function __construct()
 {
     parent::__construct();
     $oBlog = new Blog();
     $oBlogModel = new BlogModel();
     if (!$oBlog->checkPostId($this->httpRequest->post('post_id'))) {
         \PFBC\Form::setError('form_blog', t('The ID of the article is invalid or incorrect.'));
     } else {
         $aData = ['post_id' => $this->httpRequest->post('post_id'), 'lang_id' => $this->httpRequest->post('lang_id'), 'title' => $this->httpRequest->post('title'), 'content' => $this->httpRequest->post('content', Http::ONLY_XSS_CLEAN), 'slogan' => $this->httpRequest->post('$slogan'), 'tags' => $this->httpRequest->post('tags'), 'page_title' => $this->httpRequest->post('page_title'), 'meta_description' => $this->httpRequest->post('meta_description'), 'meta_keywords' => $this->httpRequest->post('meta_keywords'), 'meta_robots' => $this->httpRequest->post('meta_robots'), 'meta_author' => $this->httpRequest->post('meta_author'), 'meta_copyright' => $this->httpRequest->post('meta_copyright'), 'enable_comment' => $this->httpRequest->post('enable_comment'), 'created_date' => $this->dateTime->get()->dateTime('Y-m-d H:i:s')];
         if (!$oBlogModel->addPost($aData)) {
             $this->sMsg = t('An error occurred while adding the article.');
         } else {
             /*** Set the categorie(s) ***/
             /**
              * WARNING: Be careful, you should use the \PH7\Framework\Mvc\Request\Http::ONLY_XSS_CLEAN constant, otherwise the Http::post() method
              * removes the special tags and damages the SQL queries for entry into the database.
              */
             $iBlogId = Db::getInstance()->lastInsertId();
             foreach ($this->httpRequest->post('category_id', Http::ONLY_XSS_CLEAN) as $iCategoryId) {
                 $oBlogModel->addCategory($iCategoryId, $iBlogId);
             }
             /*** Set the thumbnail if there's one ***/
             $oPost = $oBlogModel->readPost($aData['post_id']);
             $oBlog->setThumb($oPost, $this->file);
             /* Clean BlogModel Cache */
             (new Framework\Cache\Cache())->start(BlogModel::CACHE_GROUP, null, null)->clear();
             $this->sMsg = t('Post created successfully!');
         }
         Header::redirect(Uri::get('blog', 'main', 'read', $this->httpRequest->post('post_id')), $this->sMsg);
     }
 }
Exemplo n.º 3
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();
 }
Exemplo n.º 4
0
 public static function display()
 {
     if (isset($_POST['submit_edit_membership'])) {
         if (\PFBC\Form::isValid($_POST['submit_edit_membership'])) {
             new EditMembershipFormProcess();
         }
         Framework\Url\HeaderUrl::redirect();
     }
     $oMembership = (new PaymentModel())->getMemberships((new Http())->get('group_id', 'int'));
     $oForm = new \PFBC\Form('form_edit_membership', 600);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_edit_membership', 'form_edit_membership'));
     $oForm->addElement(new \PFBC\Element\Token('membership'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Name:'), 'name', array('value' => $oMembership->name, 'required' => 1, 'validation' => new \PFBC\Validation\Str(2, 64))));
     $oForm->addElement(new \PFBC\Element\Textarea(t('Description:'), 'description', array('value' => $oMembership->description, 'required' => 1, 'validation' => new \PFBC\Validation\Str(5, 255))));
     $aDefPerms = (include dirname(__DIR__) . '/config/perms.inc.php');
     $aDbPerms = unserialize($oMembership->permissions);
     $aPerms = array_merge($aDefPerms, $aDbPerms);
     // Update new permissions from perms.inc.php file
     foreach ($aPerms as $sKey => $sVal) {
         $sLabel = (new Str())->upperFirstWords(str_replace('_', ' ', $sKey));
         $oForm->addElement(new \PFBC\Element\Select($sLabel, 'perms[' . $sKey . ']', array(1 => t('Yes'), 0 => t('No')), array('value' => $sVal)));
     }
     unset($aPerms);
     $oForm->addElement(new \PFBC\Element\Number(t('Price:'), 'price', array('description' => t('Currency: %0%. 0 = Free. To change the currency, please <a href="%1%">go to settings</a>.', Config::getInstance()->values['module.setting']['currency'], Uri::get('payment', 'admin', 'config')), 'value' => $oMembership->price, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Expiration Days:'), 'expiration_days', array('description' => t('0 = Unlimited'), 'value' => $oMembership->expirationDays, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Radio(t('Active:'), 'enable', array(1 => t('Enabled'), 0 => t('Disabled')), array('value' => $oMembership->enable, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Button(t('Update')));
     $oForm->render();
 }
Exemplo n.º 5
0
 public static function display()
 {
     // Display the contact form on the template
     if (isset($_POST['submit_contact'])) {
         if (\PFBC\Form::isValid($_POST['submit_contact'])) {
             new ContactFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oForm = new \PFBC\Form('form_contact', 400);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_contact', 'form_contact'));
     $oForm->addElement(new \PFBC\Element\Token('contact'));
     $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)', 'title' => t('Enter your first name.'), '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)', 'title' => t('Enter your last name.'), '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\Email(t('Your Email:'), 'mail', array('id' => 'email', 'onblur' => 'CValid(this.value, this.id)', 'title' => t('Enter your valid email address.'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error email"></span>'));
     $oForm->addElement(new \PFBC\Element\Phone(t('Your Phone Number:'), 'phone', array('id' => 'phone', 'onblur' => 'CValid(this.value, this.id)', 'title' => t('Enter full phone number with area code.'))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error phone"></span>'));
     $oForm->addElement(new \PFBC\Element\Url(t('Your Website:'), 'website', array('id' => 'url', 'onblur' => 'CValid(this.value, this.id)', 'title' => t('If you have a website, please enter your site address.'))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error url"></span>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Your Subject:'), 'subject', array('id' => 'str_subject', 'onblur' => 'CValid(this.value, this.id,4,25)', 'title' => t('Enter the subject of the message.'), 'required' => 1, 'validation' => new \PFBC\Validation\Str(4, 25))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_subject"></span>'));
     $oForm->addElement(new \PFBC\Element\Textarea(t('Your Message:'), 'message', array('id' => 'str_message', 'onblur' => 'CValid(this.value, this.id,10,1500)', 'title' => t('Enter your message.'), 'required' => 1, 'validation' => new \PFBC\Validation\Str(10, 1500))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_message"></span>'));
     $oForm->addElement(new \PFBC\Element\CCaptcha(t('Captcha:'), 'captcha', array('id' => 'ccaptcha', 'onkeyup' => 'CValid(this.value, this.id)', 'title' => t('Enter the code above.'))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error ccaptcha"></span>'));
     $oForm->addElement(new \PFBC\Element\Button(t('Contact US'), 'submit', array('icon' => 'contact')));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'validate.js"></script>'));
     $oForm->render();
 }
Exemplo n.º 6
0
 public static function display()
 {
     if (isset($_POST['submit_msg'])) {
         if (\PFBC\Form::isValid($_POST['submit_msg'])) {
             new MsgFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oForumsId = (new ForumModel())->getForum();
     $aForumsName = array();
     foreach ($oForumsId as $oId) {
         $aForumsName[$oId->forumId] = $oId->name;
     }
     $sTitlePattern = Config::getInstance()->values['module.setting']['url_title.pattern'];
     $oForm = new \PFBC\Form('form_msg', '100%');
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_msg', 'form_msg'));
     $oForm->addElement(new \PFBC\Element\Token('msg'));
     $oForm->addElement(new \PFBC\Element\Select(t('Forum:'), 'forum', $aForumsName, array('value' => (new Http())->get('forum_id'))));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Subject:'), 'title', array('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('required' => 1, 'validation' => new \PFBC\Validation\Str(4))));
     if (DbConfig::getSetting('isCaptchaForum')) {
         $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>'));
     $oForm->render();
 }
Exemplo n.º 7
0
 public function result()
 {
     error_reporting(0);
     $iGroupId = $this->httpRequest->get('group_id', 'int');
     $iBan = $this->httpRequest->get('ban', 'int');
     $sWhere = $this->httpRequest->get('where');
     $sWhat = $this->httpRequest->get('what');
     if ($sWhere !== 'all' && $sWhere !== 'username' && $sWhere !== 'email' && $sWhere !== 'firstName' && $sWhere !== 'lastName' && $sWhere !== 'ip') {
         \PFBC\Form::setError('form_admin_search', 'Invalid argument.');
         HeaderUrl::redirect(Uri::get(PH7_ADMIN_MOD, 'user', 'search'));
     } else {
         $this->iTotalUsers = $this->oAdminModel->searchUser($sWhat, $sWhere, $iGroupId, $iBan, true, $this->httpRequest->get('order'), $this->httpRequest->get('sort'), null, null);
         $this->view->total_users = $this->iTotalUsers;
         $oPage = new Page();
         $this->view->total_pages = $oPage->getTotalPages($this->iTotalUsers, 15);
         $this->view->current_page = $oPage->getCurrentPage();
         $oSearch = $this->oAdminModel->searchUser($sWhat, $sWhere, $iGroupId, $iBan, false, $this->httpRequest->get('order'), $this->httpRequest->get('sort'), $oPage->getFirstItem(), $oPage->getNbItemsByPage());
         unset($oPage);
         if (empty($oSearch)) {
             $this->design->setRedirect(Uri::get(PH7_ADMIN_MOD, 'user', 'search'));
             $this->displayPageNotFound('Empty search result. Please try again with wider or new search parameters.');
         } else {
             // Adding the static files
             $this->design->addCss(PH7_LAYOUT . PH7_TPL . PH7_TPL_NAME . PH7_SH . PH7_CSS, 'browse.css');
             $this->design->addJs(PH7_STATIC . PH7_JS, 'form.js');
             $this->sTitle = t('Users - Your search returned');
             $this->view->page_title = $this->sTitle;
             $this->view->h1_title = $this->sTitle;
             $this->view->h3_title = nt('%n% User Result!', '%n% Users Result!', $this->iTotalUsers);
             $this->view->browse = $oSearch;
         }
         $this->manualTplInclude('browse.tpl');
         $this->output();
     }
 }
 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);
 }
Exemplo n.º 9
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();
 }
 public static function display()
 {
     if (isset($_POST['submit_add_user'])) {
         if (\PFBC\Form::isValid($_POST['submit_add_user'])) {
             new AddUserFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oForm = new \PFBC\Form('form_add_user', 550);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_add_user', 'form_add_user'));
     $oForm->addElement(new \PFBC\Element\Token('add_user'));
     $oForm->addElement(new \PFBC\Element\Username(t('Username:'******'username', array('required' => 1, 'validation' => new \PFBC\Validation\Username())));
     $oForm->addElement(new \PFBC\Element\Email(t('Login Email:'), 'mail', array('required' => 1, 'validation' => new \PFBC\Validation\CEmail('guest'))));
     $oForm->addElement(new \PFBC\Element\Password(t('Password:'******'password', array('required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('First Name:'), 'first_name', array('required' => 1, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Last Name:'), 'last_name', array('required' => 1, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Middle Name:'), 'middle_name', array('validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\Radio(t('Sex:'), 'sex', array('female' => t('Female'), 'male' => t('Male'), 'couple' => t('Couple')), array('value' => 'female', 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Checkbox(t('Match Sex:'), 'match_sex', array('male' => t('Male'), 'female' => t('Female'), 'couple' => t('Couple')), array('value' => 'male', 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Date(t('Date of birth:'), 'birth_date', array('placeholder' => t('Month/Day/Year'), 'title' => t('Please specify the birth date using the calendar or with this format: Month/Day/Year.'), 'validation' => new \PFBC\Validation\BirthDate(), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Country(t('Country:'), 'country', array('id' => 'str_country', 'value' => Geo::getCountryCode(), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('City:'), 'city', array('id' => 'str_city', 'validation' => new \PFBC\Validation\Str(2, 150), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('State:'), 'state', array('id' => 'str_state', 'validation' => new \PFBC\Validation\Str(2, 150), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('ZIP/Postal Code:'), 'zip_code', array('id' => 'str_zip_code', 'validation' => new \PFBC\Validation\Str(2, 15), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\CKEditor(t('Description:'), 'description', array('validation' => new \PFBC\Validation\Str(10, 2000), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\File(t('Avatar'), 'avatar', array('accept' => 'image/*')));
     $oForm->addElement(new \PFBC\Element\Url(t('Your Website:'), 'website'));
     $oForm->addElement(new \PFBC\Element\Url(t('Social Network Site:'), 'social_network_site', array('description' => t('The url of your profile Facebook, Twitter, Google+, etc.'))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'geo/autocompleteCity.js"></script>'));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
 public function __construct()
 {
     parent::__construct();
     $sTable = $this->registry->module == 'user' ? 'Members' : 'Affiliates';
     $sSessPrefix = $this->registry->module == 'user' ? 'member' : 'affiliate';
     if ((new UserCoreModel())->login($this->session->get($sSessPrefix . '_email'), $this->httpRequest->post('password'), $sTable) === 'password_does_not_exist') {
         \PFBC\Form::setError('form_delete_account', t('Oops! This password you entered is incorrect.'));
     } else {
         $sUsername = $this->session->get($sSessPrefix . '_username');
         $sMembershipType = $this->registry->module == 'affiliate' ? t('Affiliate') : t('Member');
         $this->view->membership = t('Type of Membership: %0%.', $sMembershipType);
         $this->view->message = nl2br($this->httpRequest->post('message'));
         $this->view->why_delete = t('Due to the deletion of the account: %0%', $this->httpRequest->post('why_delete'));
         $this->view->footer_title = t('Information of the user who has deleted their account');
         $this->view->email = t('Email: %0%', $this->session->get($sSessPrefix . '_email'));
         $this->view->username = t('Username: %0%', $sUsername);
         $this->view->first_name = t('First Name: %0%', $this->session->get($sSessPrefix . '_first_name'));
         $this->view->sex = t('Sex: %0%', $this->session->get($sSessPrefix . '_sex'));
         $this->view->ip = t('User IP: %0%', $this->session->get($sSessPrefix . '_ip'));
         $this->view->browser_info = t('Browser info: %0%', $this->session->get($sSessPrefix . '_http_user_agent'));
         $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_TPL_NAME . '/mail/sys/core/delete_account.tpl', DbConfig::getSetting('adminEmail'));
         $sMembershipName = $this->registry->module == 'user' ? t('Member') : t('Affiliate');
         $aInfo = ['subject' => t('Unregister %0% - User: %1%', $sMembershipName, $sUsername)];
         (new Mail())->send($aInfo, $sMessageHtml);
         $oUserModel = $this->registry->module == 'user' ? new UserCore() : new AffiliateCore();
         $oUserModel->delete($this->session->get($sSessPrefix . '_id'), $sUsername);
         unset($oUserModel);
         $this->session->destroy();
         Header::redirect(Uri::get('user', 'main', 'soon'), t('You delete account is successfully!'));
     }
 }
Exemplo n.º 12
0
 public static function display()
 {
     if (isset($_POST['submit_game'])) {
         if (\PFBC\Form::isValid($_POST['submit_game'])) {
             new AdminFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oCategoriesData = (new GameModel())->getCategory(null, 0, 500);
     $aCategoriesName = array();
     foreach ($oCategoriesData as $oId) {
         $aCategoriesName[$oId->categoryId] = $oId->name;
     }
     unset($oCategoriesData);
     $sTitlePattern = Config::getInstance()->values['module.setting']['url_title.pattern'];
     $oForm = new \PFBC\Form('form_game');
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_game', 'form_game'));
     $oForm->addElement(new \PFBC\Element\Token('game'));
     $oForm->addElement(new \PFBC\Element\Select(t('Category Name:'), 'category_id', $aCategoriesName, array('required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Name of the Game:'), 'name', array('pattern' => $sTitlePattern, 'validation' => new \PFBC\Validation\RegExp($sTitlePattern), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Title of the Game:'), 'title', array('validation' => new \PFBC\Validation\Str(2, 120), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Description:'), 'description', array('validation' => new \PFBC\Validation\Str(2, 255), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Keywords:'), 'keywords', array('validation' => new \PFBC\Validation\Str(2, 255), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\File(t('Thumbnail of the Game:'), 'thumb', array('accept' => 'image/*', 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\File(t('File of the Game:'), 'file', array('accept' => 'application/x-shockwave-flash', 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
Exemplo n.º 13
0
 public function __construct()
 {
     parent::__construct();
     // Thumbnail
     $oImg = new Image($_FILES['thumb']['tmp_name']);
     if (!$oImg->validate()) {
         \PFBC\Form::setError('form_game', Form::wrongImgFileTypeMsg());
         return;
         // Stop execution of the method.
     }
     $sThumbFile = Various::genRnd($oImg->getFileName(), 30) . $oImg->getExt();
     $sThumbDir = PH7_PATH_PUBLIC_DATA_SYS_MOD . 'game/img/thumb/';
     $oImg->square(60);
     $oImg->save($sThumbDir . $sThumbFile);
     unset($oImg);
     // Game
     $sGameFile = Various::genRnd($_FILES['file']['name'], 30) . PH7_DOT . $this->file->getFileExt($_FILES['file']['name']);
     $sGameDir = PH7_PATH_PUBLIC_DATA_SYS_MOD . 'game/file/';
     // If the folders is not created (games not installed), yet we will create.
     $this->file->createDir(array($sThumbDir, $sGameDir));
     if (!@move_uploaded_file($_FILES['file']['tmp_name'], $sGameDir . $sGameFile)) {
         \PFBC\Form::setError('form_game', t('Impossible to upload the game. If you are the administrator, please check if the folder of games data has the write permission (CHMOD 755).'));
     } else {
         $aData = ['category_id' => $this->httpRequest->post('category_id', 'int'), 'name' => $this->httpRequest->post('name'), 'title' => $this->httpRequest->post('title'), 'description' => $this->httpRequest->post('description'), 'keywords' => $this->httpRequest->post('keywords'), 'thumb' => $sThumbFile, 'file' => $sGameFile];
         (new GameModel())->add($aData);
         /* Clean GameModel Cache */
         (new Framework\Cache\Cache())->start(GameModel::CACHE_GROUP, null, null)->clear();
         HeaderUrl::redirect(Uri::get('game', 'main', 'game', $aData['title'] . ',' . Db::getInstance()->lastInsertId()), t('The game was added successfully!'));
     }
 }
Exemplo n.º 14
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();
 }
 public static function display()
 {
     if (isset($_POST['submit_add_aff'])) {
         if (\PFBC\Form::isValid($_POST['submit_add_aff'])) {
             new AddAffiliateFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oForm = new \PFBC\Form('form_add_aff', 550);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_add_aff', 'form_add_aff'));
     $oForm->addElement(new \PFBC\Element\Token('add_aff'));
     $oForm->addElement(new \PFBC\Element\Username(t('Username:'******'username', array('required' => 1, 'validation' => new \PFBC\Validation\Username('Affiliates'))));
     $oForm->addElement(new \PFBC\Element\Email(t('Login Email:'), 'mail', array('required' => 1, 'validation' => new \PFBC\Validation\CEmail('guest', 'Affiliates'))));
     $oForm->addElement(new \PFBC\Element\Password(t('Password:'******'password', array('required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('First Name:'), 'first_name', array('required' => 1, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Last Name:'), 'last_name', array('required' => 1, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Middle Name:'), 'middle_name', array('validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\Radio(t('Sex:'), 'sex', array('female' => t('Female'), 'male' => t('Male'), 'couple' => t('Couple')), array('value' => 'female', 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Date(t('Date of birth:'), 'birth_date', array('placeholder' => t('Month/Day/Year'), 'title' => t('Please specify the birth date using the calendar or with this format: Month/Day/Year.'), 'required' => 1, 'validation' => new \PFBC\Validation\BirthDate())));
     $oForm->addElement(new \PFBC\Element\Country(t('Country:'), 'country', array('id' => 'str_country', 'value' => Geo::getCountryCode(), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('City:'), 'city', array('id' => 'str_city', 'validation' => new \PFBC\Validation\Str(2, 150), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('State:'), 'state', array('id' => 'str_state', 'validation' => new \PFBC\Validation\Str(2, 150), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('ZIP/Postal Code:'), 'zip_code', array('id' => 'str_zip_code', 'validation' => new \PFBC\Validation\Str(2, 15), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Phone(t('Phone Number:'), 'phone', array('description' => t('Enter full phone number with area code.'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\CKEditor(t('Description:'), 'description', array('description' => t("Description of the affiliate's site(s)."), 'validation' => new \PFBC\Validation\Str(10, 2000), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Url(t('Website:'), 'website', array('description' => t('Main website where the affiliate is the owner.'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Email(t('Bank Account:'), 'bank_account', array('description' => t('Bank Account (PayPal Email Address).'), 'validation' => new \PFBC\Validation\BankAccount(), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'geo/autocompleteCity.js"></script>'));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
Exemplo n.º 16
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>';
     }
 }
Exemplo n.º 17
0
 public static function display()
 {
     if (isset($_POST['submit_forum'])) {
         if (\PFBC\Form::isValid($_POST['submit_forum'])) {
             new ForumFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oCategoriesData = (new ForumModel())->getCategory();
     $aCategoriesName = array();
     foreach ($oCategoriesData as $oId) {
         $aCategoriesName[$oId->categoryId] = $oId->title;
     }
     unset($oCategoriesData);
     $sTitlePattern = Config::getInstance()->values['module.setting']['url_title.pattern'];
     $oForm = new \PFBC\Form('form_forum', '100%');
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_forum', 'form_forum'));
     $oForm->addElement(new \PFBC\Element\Token('forum'));
     $oForm->addElement(new \PFBC\Element\Select(t('Category Name:'), 'category_id', $aCategoriesName, array('value' => (new Http())->get('category_id'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Forum Name:'), 'name', array('id' => 'str_name', '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_name"></span>'));
     $oForm->addElement(new \PFBC\Element\Textarea(t('Description:'), 'description', array('id' => 'str_description', 'required' => 1, 'onblur' => 'CValid(this.value,this.id,4,255)', 'validation' => new \PFBC\Validation\Str(4, 255))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_description"></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();
 }
 public function __construct()
 {
     parent::__construct();
     // PH7\UserCoreModel::login() method of the UserCoreModel Class works only for "user" and "affiliate" module.
     $oPasswordModel = $this->registry->module == PH7_ADMIN_MOD ? new AdminModel() : new UserCoreModel();
     $sEmail = $this->registry->module == PH7_ADMIN_MOD ? $this->session->get('admin_email') : ($this->registry->module == 'user' ? $this->session->get('member_email') : $this->session->get('affiliate_email'));
     $sTable = $this->registry->module == PH7_ADMIN_MOD ? 'Admins' : ($this->registry->module == 'user' ? 'Members' : 'Affiliates');
     $sMod = $this->registry->module == PH7_ADMIN_MOD ? PH7_ADMIN_MOD : ($this->registry->module == 'user' ? 'user' : 'affiliate');
     $sAction = $this->registry->module == 'affiliate' ? 'home' : 'main';
     // Login
     if ($this->registry->module == PH7_ADMIN_MOD) {
         $mLogin = $oPasswordModel->adminLogin($sEmail, $this->session->get('admin_username'), $this->httpRequest->post('old_password'));
     } else {
         $mLogin = $oPasswordModel->login($sEmail, $this->httpRequest->post('old_password'), $sTable);
     }
     // Check
     if ($this->httpRequest->post('new_password') !== $this->httpRequest->post('new_password2')) {
         \PFBC\Form::setError('form_change_password', t('The passwords do not match.'));
     } elseif ($this->httpRequest->post('old_password') === $this->httpRequest->post('new_password')) {
         \PFBC\Form::setError('form_change_password', t('The old and new passwords are identical. So why do you change your password?'));
     } elseif ($mLogin !== true) {
         \PFBC\Form::setError('form_change_password', t('The old password is not correct.'));
     } else {
         // Update
         $oPasswordModel->changePassword($sEmail, $this->httpRequest->post('new_password'), Various::genRnd(), Various::genRnd(), $sTable);
         \PFBC\Form::setSuccess('form_change_password', t('Your password has been correctly updated.'));
     }
 }
 public static function display()
 {
     if (isset($_POST['submit_membership'])) {
         if (\PFBC\Form::isValid($_POST['submit_membership'])) {
             new MembershipFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oForm = new \PFBC\Form('form_membership', 600);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_membership', 'form_membership'));
     $oForm->addElement(new \PFBC\Element\Token('membership'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Name:'), 'name', array('required' => 1, 'validation' => new \PFBC\Validation\Str(2, 64))));
     $oForm->addElement(new \PFBC\Element\Textarea(t('Description:'), 'description', array('required' => 1, 'validation' => new \PFBC\Validation\Str(5, 255))));
     $aPerms = (include dirname(__DIR__) . PH7_DS . PH7_CONFIG . 'perms.inc.php');
     foreach ($aPerms as $sKey => $sVal) {
         $sLabel = (new Str())->upperFirstWords(str_replace('_', ' ', $sKey));
         $oForm->addElement(new \PFBC\Element\Select($sLabel, 'perms[' . $sKey . ']', array(1 => t('Yes'), 0 => t('No')), array('value' => $sVal)));
     }
     unset($aPerms);
     $oForm->addElement(new \PFBC\Element\Number(t('Price:'), 'price', array('description' => t('Currency: %0%. 0 = Free. To change the currency, please <a href="%1%">go to settings</a>.', Config::getInstance()->values['module.setting']['currency'], Uri::get('payment', 'admin', 'config')), 'step' => '0.01', 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Number(t('Expiration Days:'), 'expiration_days', array('description' => t('0 = Unlimited'), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Radio(t('Active:'), 'enable', array(1 => t('Enabled'), 0 => t('Disabled')), array('value' => 1, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Button(t('Add')));
     $oForm->render();
 }
Exemplo n.º 20
0
 public static function display()
 {
     $oUserModel = new UserCoreModel();
     $iProfileId = (int) (new Session())->get('member_id');
     if (isset($_POST['submit_privacy_account'])) {
         if (\PFBC\Form::isValid($_POST['submit_privacy_account'])) {
             new PrivacyFormProcess($iProfileId, $oUserModel);
         }
         Framework\Url\Header::redirect();
     }
     $oPrivacy = $oUserModel->getPrivacySetting($iProfileId);
     $oForm = new \PFBC\Form('form_privacy_account', 500);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_privacy_account', 'form_privacy_account'));
     $oForm->addElement(new \PFBC\Element\Token('privacy_account'));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Profile:') . '</u></h3>'));
     $oForm->addElement(new \PFBC\Element\Radio(t('Who can view your profile?'), 'privacy_profile', array('all' => t('Everyone (including people who are not %0% members).', Registry::getInstance()->site_name), 'only_members' => t('Only %0% members who are logged in.', Registry::getInstance()->site_name), 'only_me' => t('Only me.')), array('value' => $oPrivacy->privacyProfile, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Web search engine:') . '</u></h3>'));
     $oForm->addElement(new \PFBC\Element\Radio(t('Do you want to be included in search results?'), 'search_profile', array('yes' => t("Yes, include my profile in search results (%site_name%'s search, Google, Bing, Yahoo, etc.)."), 'no' => t('No, do not include my profile in search results.')), array('value' => $oPrivacy->searchProfile, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Show profile visitors:') . '</u></h3>'));
     $oForm->addElement(new \PFBC\Element\Radio(t('Do you want display members who viewed your profile?'), 'user_save_views', array('yes' => t('Yes, display members who viewed my profile (Selecting this option will allow other members to see that you visited their profile).'), 'no' => t('No, don\'t display members who viewed my profile. (Selecting this option will prevent you from seeing who visited your profile).')), array('value' => $oPrivacy->userSaveViews, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Presence:') . '</u></h3>'));
     $oForm->addElement(new \PFBC\Element\Select(t('Your status'), 'user_status', array('1' => t('Online'), '2' => t('Busy'), '3' => t('Away'), '0' => 'Offline'), array('id' => 'status', 'onchange' => 'init_status()', 'value' => $oUserModel->getUserStatus($iProfileId), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<div class="user_status right" id="status_div"></div>'));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script>$(function(){ init_status() });</script>'));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
Exemplo n.º 21
0
 public function __construct()
 {
     parent::__construct();
     /**
      * This can cause minor errors (eg if a user sent a file that is not a video).
      * So we hide the errors if we are not in development mode.
      */
     if (!isDebug()) {
         error_reporting(0);
     }
     // Resizing and saving the video album thumbnail
     $oPicture = new Image($_FILES['album']['tmp_name']);
     if (!$oPicture->validate()) {
         \PFBC\Form::setError('form_video_album', Form::wrongImgFileTypeMsg());
     } else {
         $iApproved = DbConfig::getSetting('videoManualApproval') == 0 ? '1' : '0';
         $sFileName = Various::genRnd($oPicture->getFileName(), 1) . '-thumb.' . $oPicture->getExt();
         (new VideoModel())->addAlbum($this->session->get('member_id'), $this->httpRequest->post('name'), $this->httpRequest->post('description'), $sFileName, $this->dateTime->get()->dateTime('Y-m-d H:i:s'), $iApproved);
         $iLastAlbumId = (int) Db::getInstance()->lastInsertId();
         $oPicture->square(200);
         /* Set watermark text on thumbnail */
         $sWatermarkText = DbConfig::getSetting('watermarkTextImage');
         $iSizeWatermarkText = DbConfig::getSetting('sizeWatermarkTextImage');
         $oPicture->watermarkText($sWatermarkText, $iSizeWatermarkText);
         $sPath = PH7_PATH_PUBLIC_DATA_SYS_MOD . 'video/file/' . $this->session->get('member_username') . PH7_DS . $iLastAlbumId . PH7_DS;
         $this->file->createDir($sPath);
         $oPicture->save($sPath . $sFileName);
         /* Clean VideoModel Cache */
         (new Framework\Cache\Cache())->start(VideoModel::CACHE_GROUP, null, null)->clear();
         HeaderUrl::redirect(Uri::get('video', 'main', 'addvideo', $iLastAlbumId));
     }
 }
 public static function display()
 {
     if (isset($_POST['submit_module'])) {
         if (\PFBC\Form::isValid($_POST['submit_module'])) {
             new DisableModuleFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oModuleData = (new ModuleModel())->get();
     $aModuleNames = [];
     $aSelectedMods = [];
     foreach ($oModuleData as $oData) {
         if ((int) $oData->enabled === 1) {
             $aSelectedMods[] = $oData->moduleId;
         }
         $sPremiumText = '';
         if ((int) $oData->premiumMod === 1) {
             $sPremiumText = ' &nbsp; (<a class="italic darkred" href="' . Core::SOFTWARE_LICENSE_KEY_URL . '">' . t('Premium Module') . '</a>)';
         }
         $aModuleNames[$oData->moduleId] = ucwords(str_replace(['-', '_'], ' ', $oData->folderName)) . $sPremiumText;
     }
     unset($oModuleData);
     $oForm = new \PFBC\Form('form_module');
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_module', 'form_module'));
     $oForm->addElement(new \PFBC\Element\Token('module'));
     $oForm->addElement(new \PFBC\Element\Checkbox('', 'module_id', $aModuleNames, array('value' => $aSelectedMods)));
     $oForm->addElement(new \PFBC\Element\Button(t('Save')));
     $oForm->render();
 }
Exemplo n.º 23
0
 public static function display()
 {
     if (isset($_POST['submit_edit_note'])) {
         if (\PFBC\Form::isValid($_POST['submit_edit_note'])) {
             new EditNoteFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     // Generate edit form post of the note
     $oNoteModel = new NoteModel();
     $iNoteId = (new Http())->get('id', 'int');
     $iProfileId = (new Session())->get('member_id');
     $sPostId = $oNoteModel->getPostId($iNoteId);
     $oPost = $oNoteModel->readPost($sPostId, $iProfileId);
     if (!empty($oPost) && (new Str())->equals($iNoteId, $oPost->noteId)) {
         $oCategoriesData = $oNoteModel->getCategory(null, 0, 300);
         $aCategoriesName = array();
         foreach ($oCategoriesData as $oId) {
             $aCategoriesName[$oId->categoryId] = $oId->name;
         }
         $aSelectedCategories = array();
         $oCategoryId = $oNoteModel->getCategory($iNoteId, 0, 300);
         unset($oNoteModel);
         foreach ($oCategoryId as $iId) {
             $aSelectedCategories[] = $iId->categoryId;
         }
         $oForm = new \PFBC\Form('form_note', 650);
         $oForm->configure(array('action' => ''));
         $oForm->addElement(new \PFBC\Element\Hidden('submit_edit_note', 'form_note'));
         $oForm->addElement(new \PFBC\Element\Token('edit_note'));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Title of article:'), 'title', array('value' => $oPost->title, 'validation' => new \PFBC\Validation\Str(2, 100), 'required' => 1)));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Article ID:'), 'post_id', array('value' => $oPost->postId, 'description' => Uri::get('note', 'main', 'read', (new Session())->get('member_username')) . '/<strong><span class="your-address">' . $oPost->postId . '</span><span class="post_id"></span></strong>', 'title' => t('Article ID will be the name of the url.'), 'data-profile_id' => $iProfileId, 'id' => 'post_id', 'validation' => new \PFBC\Validation\Str(2, 60), 'required' => 1)));
         $oForm->addElement(new \PFBC\Element\HTMLExternal('<div class="label_flow">'));
         $oForm->addElement(new \PFBC\Element\Checkbox(t('Categories:'), 'category_id', $aCategoriesName, array('description' => t('Select a category that best fits your article. You can select up to three different categories'), 'value' => $aSelectedCategories, 'required' => 1)));
         $oForm->addElement(new \PFBC\Element\HTMLExternal('</div>'));
         $oForm->addElement(new \PFBC\Element\CKEditor(t('Contents:'), 'content', array('value' => $oPost->content, 'description' => t('Content of the article'), 'validation' => new \PFBC\Validation\Str(30), 'required' => 1)));
         $oForm->addElement(new \PFBC\Element\Textbox(t('The language of your post:'), 'lang_id', array('value' => $oPost->langId, 'description' => t('EX: "en", "fr", "es", "js"'), 'validation' => new \PFBC\Validation\Str(2, 2), 'required' => 1)));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Slogan:'), 'slogan', array('value' => $oPost->slogan, 'validation' => new \PFBC\Validation\Str(2, 200))));
         $oForm->addElement(new \PFBC\Element\File(t('Thumbnail:'), 'thumb', array('accept' => 'image/*')));
         if (!empty($oPost->thumb)) {
             $oForm->addElement(new \PFBC\Element\HTMLExternal('<p><br /><img src="' . PH7_URL_DATA_SYS_MOD . 'note/' . PH7_IMG . $oPost->username . PH7_SH . $oPost->thumb . '" alt="' . t('Thumbnail') . '" title="' . t('The current thumbnail of your post.') . '" class="avatar" /></p>'));
         }
         if (!empty($oPost->thumb)) {
             $oForm->addElement(new \PFBC\Element\HTMLExternal('<a href="' . Uri::get('note', 'main', 'removethumb', $oPost->noteId . (new Token())->url(), false) . '">' . t('Remove this thumbnail?') . '</a>'));
         }
         $oForm->addElement(new \PFBC\Element\Textbox(t('Tags:'), 'tags', array('value' => $oPost->tags, 'description' => t('Separate keywords by commas and without spaces between the commas.'), 'validation' => new \PFBC\Validation\Str(2, 200))));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Title (meta tag):'), 'page_title', array('value' => $oPost->pageTitle, 'validation' => new \PFBC\Validation\Str(2, 100), 'required' => 1)));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Description (meta tag):'), 'meta_description', array('validation' => new \PFBC\Validation\Str(2, 200), 'value' => $oPost->metaDescription)));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Keywords (meta tag):'), 'meta_keywords', array('description' => t('Separate keywords by commas and without spaces between the commas.'), 'validation' => new \PFBC\Validation\Str(2, 200), 'value' => $oPost->metaKeywords)));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Robots (meta tag):'), 'meta_robots', array('validation' => new \PFBC\Validation\Str(2, 50), 'value' => $oPost->metaRobots)));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Author (meta tag):'), 'meta_author', array('validation' => new \PFBC\Validation\Str(2, 50), 'value' => $oPost->metaAuthor)));
         $oForm->addElement(new \PFBC\Element\Textbox(t('Copyright (meta tag):'), 'meta_copyright', array('validation' => new \PFBC\Validation\Str(2, 50), 'value' => $oPost->metaCopyright)));
         $oForm->addElement(new \PFBC\Element\Radio(t('Enable Comment:'), 'enable_comment', array('1' => t('Enable'), '0' => t('Disable')), array('value' => $oPost->enableComment, 'required' => 1)));
         $oForm->addElement(new \PFBC\Element\Button());
         $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_TPL_SYS_MOD . 'note/' . PH7_TPL . PH7_TPL_MOD_NAME . PH7_SH . PH7_JS . 'common.js"></script>'));
         $oForm->render();
     } else {
         echo '<p class="center bold">' . t('Post Not Found!') . '</p>';
     }
 }
 /**
  * @param string $sConfigVar Specify the variable in the INI file where module options. Default module.setting
  * @param string $sConfigPath Specify the path of INI file configuration WITHOUT "config.ini". The default value is the current configuration file module. Default NULL
  * @return void
  */
 public static function display($sConfigVar = 'module.setting', $sConfigPath = null)
 {
     $sConfigFile = 'config.ini';
     $sIniFile = empty($sConfigPath) ? Registry::getInstance()->path_module_config . $sConfigFile : $sConfigPath . $sConfigFile;
     $aData = parse_ini_file($sIniFile, true);
     $rData = file_get_contents($sIniFile);
     if (isset($_POST['submit_config'])) {
         if (\PFBC\Form::isValid($_POST['submit_config'])) {
             new ConfigFileCoreFormProcess($sConfigVar, $sIniFile);
         }
         Framework\Url\Header::redirect();
     }
     $oForm = new \PFBC\Form('form_config', 600);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_config', 'form_config'));
     $oForm->addElement(new \PFBC\Element\Token('config'));
     foreach ($aData[$sConfigVar] as $sKey => $sVal) {
         $sLabel = str_replace(array('.', '_'), ' ', $sKey);
         $sLabel = (new Str())->upperFirstWords($sLabel);
         if (false !== strpos($sKey, 'enable')) {
             $oForm->addElement(new \PFBC\Element\Select($sLabel, 'config[' . $sKey . ']', array(1 => t('Enable'), 0 => t('Disable')), array('value' => $sVal)));
         } elseif (false !== strpos($sKey, 'email')) {
             $oForm->addElement(new \PFBC\Element\Email($sLabel, 'config[' . $sKey . ']', array('value' => $sVal)));
         } elseif (ctype_digit($sVal)) {
             $oForm->addElement(new \PFBC\Element\Number($sLabel, 'config[' . $sKey . ']', array('step' => 'any', 'value' => $sVal)));
         } else {
             $oForm->addElement(new \PFBC\Element\Textbox($sLabel, 'config[' . $sKey . ']', array('value' => $sVal)));
         }
     }
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->render();
 }
Exemplo n.º 25
0
 public function __construct()
 {
     parent::__construct();
     $oCommentModel = new CommentModel();
     $sComment = $this->httpRequest->post('comment');
     $sCurrentTime = $this->dateTime->get()->dateTime('Y-m-d H:i:s');
     $iTimeDelay = (int) DbConfig::getSetting('timeDelaySendComment');
     $sTable = $this->httpRequest->get('table');
     $iRecipientId = $this->httpRequest->get('recipient', 'int');
     $iSenderId = (int) $this->session->get('member_id');
     if (!$oCommentModel->idExists($iRecipientId, $sTable)) {
         \PFBC\Form::setError('form_comment', t('The comment recipient does not exists.'));
     } elseif (!$oCommentModel->checkWaitSend($iSenderId, $iTimeDelay, $sCurrentTime, $sTable)) {
         \PFBC\Form::setError('form_comment', Form::waitWriteMsg($iTimeDelay));
     } elseif ($oCommentModel->isDuplicateContent($iSenderId, $sComment, $sTable)) {
         \PFBC\Form::setError('form_comment', Form::duplicateContentMsg());
     } else {
         if (!$oCommentModel->add($sComment, $iRecipientId, $iSenderId, 1, $sCurrentTime, $sTable)) {
             \PFBC\Form::setError('form_comment', t('Oops! Error when adding comment.'));
         } else {
             /* Clean All Data of CommentModel Cache */
             (new Framework\Cache\Cache())->start(CommentCoreModel::CACHE_GROUP, null, null)->clear();
             HeaderUrl::redirect(Uri::get('comment', 'comment', 'read', $sTable . ',' . $iRecipientId), t('The comment has been sent successfully!'));
         }
     }
     unset($oCommentModel);
 }
 public static function display()
 {
     if (isset($_POST['submit_module'])) {
         if (\PFBC\Form::isValid($_POST['submit_module'])) {
             new DisableModuleFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oModuleData = (new ModuleModel())->get();
     $aModuleNames = [];
     $aSelectedMods = [];
     foreach ($oModuleData as $oId) {
         if ((int) $oId->enabled === 1) {
             $aSelectedMods[] = $oId->moduleId;
         }
         $aModuleNames[$oId->moduleId] = ucwords(str_replace(['-', '_'], ' ', $oId->folderName));
     }
     $oForm = new \PFBC\Form('form_module');
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_module', 'form_module'));
     $oForm->addElement(new \PFBC\Element\Token('module'));
     $oForm->addElement(new \PFBC\Element\Checkbox('', 'module_id', $aModuleNames, array('value' => $aSelectedMods)));
     $oForm->addElement(new \PFBC\Element\Button(t('Save')));
     $oForm->render();
 }
 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.'));
 }
Exemplo n.º 28
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()
 {
     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!'));
         }
     }
 }
Exemplo n.º 30
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!'));
     }
 }