예제 #1
0
 * Installing the system or redistributions of files must retain the above copyright notice.
 *
 * @link        http://mobicms.net mobiCMS Project
 * @copyright   Copyright (C) mobiCMS Community
 * @license     LICENSE.md (see attached file)
 */
defined('MOBICMS') or die('Error: restricted access');
use Config\System as Config;
$app = App::getInstance();
$profile = $app->profile();
$form = new Mobicms\Form\Form(['action' => $app->request()->getUri()]);
$form->title(_m('Edit Profile'));
if (Config::$usrChangeStatus) {
    $form->html('<div class="form-group">')->element('text', 'status', ['label' => _m('Status'), 'value' => $profile->status, 'description' => _m('Min.3, Max. 50 symbols, or blank to remove status'), 'filter' => FILTER_SANITIZE_SPECIAL_CHARS])->html('</div>');
}
$form->element('text', 'imname', ['label' => _m('Your Name'), 'value' => $profile->imname, 'description' => _m('Max. 50 characters'), 'filter' => FILTER_SANITIZE_STRING]);
if (Config::$usrChangeSex || $app->profile()->rights >= 7) {
    $form->element('radio', 'sex', ['label' => _s('Gender'), 'checked' => $profile->sex, 'items' => ['m' => _s('Male'), 'w' => _s('Female')]]);
}
$form->element('text', 'day', ['label' => _m('Birthday'), 'value' => date("d", strtotime($profile->birth)), 'class' => 'mini', 'filter' => FILTER_SANITIZE_NUMBER_INT])->element('text', 'month', ['value' => date("m", strtotime($profile->birth)), 'class' => 'mini', 'filter' => FILTER_SANITIZE_NUMBER_INT])->element('text', 'year', ['value' => date("Y", strtotime($profile->birth)), 'class' => 'small', 'description' => _m('Day, month, year'), 'filter' => FILTER_SANITIZE_NUMBER_INT])->element('text', 'live', ['label' => _m('Accommodation'), 'value' => $profile->live, 'description' => _m('Specify the country of residence, your city.<br/>Max. 100 characters.'), 'filter' => FILTER_SANITIZE_STRING])->element('textarea', 'about', ['label' => _m('About yourself'), 'value' => $profile->about, 'editor' => true, 'description' => _m('Max. 5000 characters')])->element('text', 'tel', ['label' => _m('Phone Number'), 'value' => $profile->tel, 'description' => _m('Max. 100 characters'), 'filter' => FILTER_SANITIZE_STRING])->element('text', 'siteurl', ['label' => _m('Site'), 'value' => $profile->siteurl, 'description' => _m('You can enter multiple URL, separated by spaces.<br/>Max. 100 characters'), 'filter' => FILTER_SANITIZE_STRING]);
if (!empty($profile->email)) {
    $form->element('text', 'email', ['label' => 'E-mail', 'value' => $profile->email, 'readonly' => true, 'filter' => FILTER_SANITIZE_EMAIL])->element('checkbox', 'mailvis', ['label_inline' => _m('Show in the Profile'), 'checked' => $profile->mailvis, 'description' => _m('Correctly specify your email address, that it will be sent your password.<br/>Max. 50 characters') . '<br/><a href="../email/">' . _m('Change E-mail') . '</a>']);
}
$form->element('text', 'skype', ['label' => 'Skype', 'value' => $profile->skype, 'description' => _m('Max. 50 characters'), 'filter' => FILTER_SANITIZE_STRING])->element('text', 'icq', ['label' => 'ICQ', 'value' => $profile->icq, 'description' => _m('Enter your UIN number'), 'filter' => FILTER_SANITIZE_NUMBER_INT])->divider()->element('submit', 'submit', ['value' => _s('Save'), 'class' => 'btn btn-primary'])->html('<a class="btn btn-link" href="../">' . _s('Back') . '</a>')->validate('status', 'lenght', ['min' => 3, 'max' => 50, 'empty' => true])->validate('imname', 'lenght', ['max' => 50])->validate('live', 'lenght', ['max' => 100])->validate('about', 'lenght', ['max' => 5000])->validate('tel', 'lenght', ['max' => 100])->validate('siteurl', 'lenght', ['max' => 100])->validate('skype', 'lenght', ['max' => 50])->validate('icq', 'numeric', ['min' => 10000, 'empty' => true]);
if ($form->process() === true) {
    $profile->status = $form->output['status'];
    $profile->sex = $form->output['sex'];
    $profile->imname = $form->output['imname'];
    $profile->live = $form->output['live'];
    $profile->about = $app->purify($form->output['about']);
    $profile->tel = $form->output['tel'];
예제 #2
0
 * mobiCMS Content Management System (http://mobicms.net)
 *
 * For copyright and license information, please see the LICENSE.md
 * Installing the system or redistributions of files must retain the above copyright notice.
 *
 * @link        http://mobicms.net mobiCMS Project
 * @copyright   Copyright (C) mobiCMS Community
 * @license     LICENSE.md (see attached file)
 */
defined('MOBICMS') or die('Error: restricted access');
$app = App::getInstance();
$profile = $app->profile();
$form = new Mobicms\Form\Form(['action' => $app->request()->getUri()]);
$form->title(_m('Change E-mail'));
if (!empty($profile->email)) {
    $form->element('text', 'oldemail', ['label' => _m('Old E-mail'), 'value' => $profile->email, 'readonly' => true]);
}
$form->element('text', 'email', ['label' => _m('New E-mail'), 'maxlength' => 50])->element('text', 'repeatemail', ['label' => _m('Repeat E-mail'), 'maxlength' => 50, 'description' => _m('Correctly specify your email address, that it will be sent your password.<br/>Max. 50 characters')])->element('password', 'password', ['label' => _m('Your Password'), 'required' => true])->divider()->element('submit', 'submit', ['value' => _s('Save'), 'class' => 'btn btn-primary'])->html('<a class="btn btn-link" href="../">' . _s('Back') . '</a>')->validate('email', 'lenght', ['min' => 5, 'max' => 50, 'empty' => true])->validate('repeatemail', 'compare', ['compare_field' => 'email']);
if ($form->process() === true) {
    // Проверяем Email
    if (!filter_var($form->output['email'], FILTER_VALIDATE_EMAIL)) {
        $form->setError('email', _s('Invalid Email address'));
    } elseif ($app->user()->validate()->checkEmailExists($form->output['email'])) {
        $form->setError('email', _s('This Email is already taken'));
    }
    // Проверяем пароль
    if (!$user->checkPassword($form->output['password'])) {
        $form->setError('password', _s('Invalid password'));
    }
    if ($form->isValid) {
        $profile->email = $form->output['email'];
예제 #3
0
 * mobiCMS Content Management System (http://mobicms.net)
 *
 * For copyright and license information, please see the LICENSE.md
 * Installing the system or redistributions of files must retain the above copyright notice.
 *
 * @link        http://mobicms.net mobiCMS Project
 * @copyright   Copyright (C) mobiCMS Community
 * @license     LICENSE.md (see attached file)
 */
defined('MOBICMS') or die('Error: restricted access');
use Config\System as Config;
$form = new Mobicms\Form\Form(['action' => App::request()->getUri()]);
if (Config::$usrRegAllow) {
    $form->title('TMP')->element('text', 'nickname', ['label' => _g('Choose Nickname'), 'description' => _g('Min. 2, Max. 20 Characters.<br>Allowed letters are Cyrillic and Latin alphabet, numbers, spaces and punctuation - = @ ! ? ~ . _ ( ) [ ] *'), 'required' => true]);
    if (Config::$usrRegEmail) {
        $form->element('text', 'email', ['label' => _g('Your Email'), 'description' => _g('Please correctly specify your email address. This address will be sent a confirmation code to your registration.'), 'required' => true]);
    }
    $form->element('password', 'newpass', ['label' => _g('Password'), 'required' => true])->element('password', 'newconf', ['label' => _g('Repeat password'), 'description' => _g('The password length min. 3 characters'), 'required' => true])->element('radio', 'sex', ['label' => _g('Gender'), 'checked' => 'm', 'items' => ['m' => '<i class="male lg fw"></i>' . _g('Male'), 'w' => '<i class="female lg fw"></i>' . _g('Female')]])->divider(8)->captcha()->element('text', 'captcha', ['label_inline' => _g('Verification code'), 'class' => 'small', 'maxlenght' => 5, 'reset_value' => ''])->divider()->element('submit', 'submit', ['value' => _g('Sign Up'), 'class' => 'btn btn-primary'])->html('<a class="btn btn-link" href="' . App::request()->getBaseUrl() . '/login/">' . _g('Cancel') . '</a>')->validate('captcha', 'captcha');
    if (Config::$usrRegEmail) {
        $form->validate('email', 'lenght', ['min' => 5, 'max' => 50])->validate('email', 'email');
    }
    $form->validate('nickname', 'lenght', ['min' => 2, 'max' => 20])->validate('nickname', 'nickname')->validate('newpass', 'lenght', ['continue' => false, 'min' => 3])->validate('newconf', 'compare', ['compare_field' => 'newpass', 'error' => _g("Passwords don't coincide")])->validate('nickname', 'nickoccupied', ['valid' => true]);
    if ($form->process() === true) {
        $token = Includes\Functions::generateToken();
        $stmt = App::db()->prepare("\n          INSERT INTO `user__` SET\n          `nickname`      = ?,\n          `password`      = ?,\n          `token`         = ?,\n          `email`         = ?,\n          `rights`        = 0,\n          `level`         = ?,\n          `sex`           = ?,\n          `join_date`     = ?,\n          `last_visit`    = ?,\n          `about`         = ?,\n          `reputation`  = ?\n        ");
        $stmt->execute([$form->output['nickname'], password_hash($form->output['newpass'], PASSWORD_DEFAULT), $token, Config::$usrRegEmail ? $form->output['email'] : '', Config::$usrRegAllow && !Config::$usrRegModeration && !Config::$usrRegEmail ? 1 : 0, $form->output['sex'], time(), time(), '', '']);
        //TODO: Добавить подтверждение по Email
        //TODO: Добавить отправку Welcome Message
        //TODO: Добавить страницу с приветствием
        // Запускаем пользователя на сайт
        $userid = App::db()->lastInsertId();
예제 #4
0
파일: login.php 프로젝트: eskrano/mobicms
<?php

/*
 * mobiCMS Content Management System (http://mobicms.net)
 *
 * For copyright and license information, please see the LICENSE.md
 * Installing the system or redistributions of files must retain the above copyright notice.
 *
 * @link        http://mobicms.net mobiCMS Project
 * @copyright   Copyright (C) mobiCMS Community
 * @license     LICENSE.md (see attached file)
 */
defined('MOBICMS') or die('Error: restricted access');
$form = new Mobicms\Form\Form(['action' => App::request()->getUri()]);
$form->element('text', 'login', ['label' => _g('Nickname or Email'), 'class' => 'relative largetext', 'required' => true])->element('password', 'password', ['label' => _g('Password'), 'class' => 'relative largetext', 'required' => true])->element('checkbox', 'remember', ['checked' => true, 'label_inline' => _g('Remember')])->divider(12)->element('submit', 'submit', ['value' => _g('Login'), 'class' => 'btn btn-primary btn-lg btn-block'])->html('<br/><a class="btn btn-default" href="#">' . _g('Forgot password?') . '</a>')->validate('login', 'lenght', ['min' => 2, 'max' => 20])->validate('password', 'lenght', ['min' => 3]);
if ($form->process() === true) {
    try {
        App::user()->validate()->checkLogin($form->output['login']);
        try {
            App::user()->login($form->output['login'], $form->output['password'], $form->output['remember']);
        } catch (\Mobicms\Checkpoint\Exceptions\UserExceptionInterface $e) {
            $form->errorMessage = _g('Login information are incorrect');
            $form->setError('login', '');
            $form->setError('password', '');
        }
    } catch (\Mobicms\Checkpoint\Exceptions\UserExceptionInterface $e) {
        $form->setError('login', $e->getMessage());
    }
    if (App::user()->isValid()) {
        App::redirect(App::request()->getBaseUrl());
    }