예제 #1
0
 * 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;
$app = App::getInstance();
$user = $app->user()->get();
$form = new Mobicms\Form\Form(['action' => $app->request()->getUri()]);
if ($user->rights >= 7 || $user->nickChanged < time() - Config::$usrChangeNicknamePeriod * 86400) {
    $form->title(_m('Change Nickname'))->element('text', 'nickname', ['label' => _m('New Nickname'), 'maxlength' => 20, 'required' => true])->element('text', 'repeat', ['label' => _m('Repeat Nickname'), 'maxlength' => 20, 'description' => _s('Min. 2, Max. 20 Characters.<br>Allowed letters are Cyrillic and Latin alphabet, numbers, spaces and punctuation - = @ ! ? ~ . _ ( ) [ ] *') . '<br/>' . _m('Please note that while changing the nickname is changing your Login on the site.<br>The next change of nickname is allowed through') . ' ' . Config::$usrChangeNicknamePeriod . ' ' . _sp('Day', 'Days', Config::$usrChangeNicknamePeriod) . '.', 'required' => true])->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('nickname', 'lenght', ['min' => 2, 'max' => 20])->validate('repeat', 'compare', ['compare_field' => 'nickname']);
} else {
    $form->html('<div class="alert alert-danger">' . '<strong>' . _m('Nickname can not change more than once a') . ' ' . Config::$usrChangeNicknamePeriod . ' ' . _sp('Day', 'Days', Config::$usrChangeNicknamePeriod) . '</strong><br/><br/>' . _m('You have already changed their nickname:') . ' ' . Includes\Functions::displayDate($user->nickChanged) . '<br/>' . _m('Next time will be able to change:') . ' ' . Includes\Functions::displayDate($user->nickChanged + Config::$usrChangeNicknamePeriod * 86400) . '</div>')->html('<a class="btn btn-primary" href="../">' . _s('Back') . '</a>');
}
if ($form->process() === true) {
    $valid = $app->user()->validate();
    // Проверяем Ник
    if (!$valid->checkNicknameChars($form->output['nickname'])) {
        // Обнаружены запрещенные символы
        $form->setError('nickname', _s('Invalid characters'));
    } elseif (!$valid->checkNicknameCharsets($form->output['nickname'])) {
        // Обнаружены символы из разных языков
        $form->setError('nickname', _s('It is forbidden to use characters of different languages'));
    } elseif (ctype_digit($form->output['nickname']) && !Config::$usrNicknameDigitsOnly) {
        // Ник состоит только из цифр
        $form->setError('nickname', _s('Nicknames consisting only of numbers are prohibited'));
    } elseif (!$valid->checkNicknameRepeatedChars($form->output['nickname'])) {
        // Обнаружены повторяющиеся символыь (более 3-х подряд)
예제 #2
0
파일: delete.php 프로젝트: eskrano/mobicms
 * 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');
$id = App::request()->getFiltered('id', 0, FILTER_VALIDATE_INT);
$form = new Mobicms\Form\Form(['action' => App::request()->getUri() . '?id=' . $id]);
if ($id) {
    $stmt = App::db()->query("SELECT * FROM `news` WHERE `id` = " . $id);
    if ($stmt->rowCount()) {
        $form->title(_dg('Delete Article'))->divider()->element('submit', 'submit', ['value' => _g('Delete'), 'class' => 'btn btn-primary'])->html('<a class="btn btn-link" href="../">' . _g('Cancel') . '</a>');
    } else {
        $form->html('<div class="alert alert-danger">' . _g('Wrong data') . '</div>')->html('<a class="btn btn-link" href="../">' . _g('Back') . '</a>');
    }
} else {
    $form->html('<div class="alert alert-danger">' . _g('Wrong data') . '</div>')->html('<a class="btn btn-link" href="../">' . _g('Back') . '</a>');
}
if ($form->process() === true) {
    App::db()->exec("DELETE FROM `news` WHERE `id` = " . $id);
    //TODO: Добавить удаление комментариев к новости
    $form->confirmation = true;
    $form->continueLink = '../';
    $form->successMessage = _dg('Article deleted');
}
App::view()->form = $form->display();
App::view()->setTemplate('edit_form.php');
예제 #3
0
 *
 * 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;
$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'];