Пример #1
0
function authenticate()
{
    $app = Slim::getInstance();
    if (!App::user()) {
        $app->redirect("/connect/");
    }
}
Пример #2
0
 /**
  * @return string
  */
 public function __toString()
 {
     $skin = \App::user()->get()->config()->skin;
     if ($this->isModule) {
         return $this->getModuleImage($skin);
     }
     return $this->getThemeImage($skin);
 }
Пример #3
0
 private function links($file)
 {
     $url = \App::request()->getBaseUrl();
     $skin = \App::user()->get()->config()->skin;
     $type = strtolower(pathinfo($file, PATHINFO_EXTENSION));
     $moduleDir = \App::router()->dir;
     $themeLink = $url . '/themes/';
     $skinLink = $themeLink . $skin . '/';
     $skinPath = THEMES_PATH . $skin . DS;
     return [[$skinPath . 'modules' . DS . $moduleDir . DS . $type . DS . $file, $skinLink . 'modules/' . $moduleDir . '/' . $type . '/' . $file], [ASSETS_PATH . 'modules' . DS . $moduleDir . DS . $type . DS . $file, $url . '/assets/modules/' . $moduleDir . '/' . $type . '/' . $file], [$skinPath . $type . DS . $file, $skinLink . $type . '/' . $file], [ASSETS_PATH . 'template' . DS . $type . DS . $file, $url . '/assets/template/' . $type . '/' . $file]];
 }
Пример #4
0
 public function __construct()
 {
     $size = \App::user()->get()->config()->pageSize;
     // Obtain variables
     if (filter_has_var(INPUT_ENV, 'page')) {
         $this->page = filter_input(INPUT_ENV, 'page', FILTER_SANITIZE_NUMBER_INT);
         $this->start = intval($this->page * $size - $size);
     } elseif (filter_has_var(INPUT_ENV, 'start')) {
         $this->start = filter_input(INPUT_ENV, 'start', FILTER_SANITIZE_NUMBER_INT);
     }
 }
Пример #5
0
 /**
  * 
  * @todo: test this functionality.
  * Sets App::$user and App::$real_user
  * @param string $identifier Optional - the nt_login or roswell id of the user you wish to act as
  */
 public static function setUser($identifier = '')
 {
     if (Gateway::$command_line) {
         App::$real_user = new \Models\User();
         App::$real_user->uname = 'commandline';
         App::$real_user->dname = 'Command Line';
         App::$real_user->roswell_id = 0;
         App::$real_user->is_admin = 1;
         App::$user = App::$real_user;
     } else {
         if (is_subclass_of(Gateway::$controller_class, '\\Controllers\\NoAuth')) {
             self::$real_user = new \Models\User();
             self::$real_user->uname = 'noauth';
             self::$real_user->dname = 'noauth';
             self::$real_user->roswell_id = 0;
             self::$user = self::$real_user;
         } else {
             if (!isset(Settings::$dev_group)) {
                 return false;
             }
             if (isset($_SESSION['real_user']) && isset($_SESSION['user'])) {
                 App::$real_user = unserialize($_SESSION['real_user']);
                 App::$user = unserialize($_SESSION['user']);
             } else {
                 App::$real_user = App::$directory->currentUser();
                 App::$real_user->is_admin = in_array(Settings::$dev_group, App::$real_user->workgroups);
                 if ($identifier) {
                     App::$user = App::$directory->currentUser($identifier);
                     App::$user->is_admin = in_array(Settings::$dev_group, App::$user->workgroups);
                 } else {
                     App::$user = App::$real_user;
                 }
             }
         }
     }
     $_SESSION['real_user'] = serialize(App::$real_user);
     $_SESSION['user'] = serialize(App::$user);
     if (App::$user->roswell_id == App::$real_user->roswell_id) {
         App::$user->acting_as_self = true;
     } else {
         App::$user->acting_as_self = false;
     }
 }
Пример #6
0
?>
</a>
        </li>
        <li>
            <a href="../ip/"><i class="bolt fw"></i><?php 
echo _g('IP Activity');
?>
</a>
        </li>
    </ul>
</div>

<!-- Список онлайн -->
<div class="content box m-list">
    <?php 
if (App::user()->isValid() || Config\System::$usrViewOnline) {
    ?>
        <h2><?php 
    echo _g('Guests');
    ?>
</h2>
        <ul class="striped">
            <?php 
    if (isset($this->list)) {
        ?>
                <?php 
        foreach ($this->list as $guest) {
            ?>
                    <li>
                        <!-- Кнопка выпадающего меню -->
                        <div>
Пример #7
0
<?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');
$homeUrl = App::request()->getBaseUrl();
$form = new Mobicms\Form\Form(['action' => App::request()->getUri()]);
$form->title(_s('Leave the site?'))->element('checkbox', 'clear', ['label_inline' => _s('Remove authorization from all devices')])->divider(12)->element('submit', 'submit', ['value' => '   ' . _s('Exit') . '   ', 'class' => 'btn btn-primary btn-lg btn-block'])->html('<br/><a class="btn btn-default btn-lg btn-block" href="' . $homeUrl . '/profile/' . App::user()->get()->id . '/">' . _s('Back') . '</a>');
if ($form->process() === true) {
    App::user()->logout($form->output['clear']);
    App::redirect($homeUrl);
}
App::view()->form = $form->display();
App::view()->setTemplate('login.php');
Пример #8
0
 public function authenticateUser($authMap = array())
 {
     App::$user = new User();
     // attempt the authentication methods in the order given
     // the first one that succeeds is the one we use
     foreach ($authMap as $method) {
         if (isset($this->authenticationMethods[$method])) {
             $authenticatorClass = $this->authenticationMethods[$method];
             $authenticator = new $authenticatorClass();
             if ($authenticator->authenticateUser(App::$user)) {
                 App::$user->authType = $method;
                 return true;
             }
         }
     }
     // if we get here, we have not authenticated the user
     // we explicitly call the anonymous user authenticator,
     // in case it does any specific setup at all
     $authenticatorClass = $this->authenticationMethods[User::AUTHTYPE_ANON];
     $authenticator = new $authenticatorClass();
     $authenticator->authenticateUser(App::$user);
     App::$user->authType = User::AUTHTYPE_ANON;
     // all done
 }
Пример #9
0
<?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->title(_dg('Add Article'))->element('text', 'title', ['label' => _g('Title'), 'required' => true])->element('textarea', 'text', ['label' => _g('Text'), 'editor' => true, 'required' => true])->element('checkbox', 'comments', ['label_inline' => _dg('Enable comments'), 'checked' => true])->divider()->element('submit', 'submit', ['value' => _g('Save'), 'class' => 'btn btn-primary'])->html('<a class="btn btn-link" href="../">' . _g('Back') . '</a>');
$form->validate('title', 'lenght', ['min' => 3, 'max' => 100])->validate('text', 'lenght', ['min' => 3]);
if ($form->process() === true) {
    $stmt = App::db()->prepare("\n        INSERT INTO `news` SET\n        `time`        = ?,\n        `author`      = ?,\n        `author_id`   = ?,\n        `title`       = ?,\n        `text`        = ?,\n        `comm_enable` = ?\n    ");
    $user = App::user()->get();
    $stmt->execute([time(), $user->nickname, $user->id, App::filter($form->output['title'])->specialchars(), App::purify($form->output['text']), $form->output['comments']]);
    $user->lastpost = time();
    $user->save();
    App::redirect('../');
}
App::view()->form = $form->display();
App::view()->setTemplate('edit_form.php');
Пример #10
0
 /**
  * @return string
  */
 private function prepareTextarea()
 {
     if (!empty($this->option['editor'])) {
         $config = \App::user()->get()->config();
         // Initialize editor
         $this->option['id'] = 'editor';
         $editor = new Editor($config->editor);
         $lng = \Config\System::$lng;
         //TODO: разобраться
         $editor->setLanguage($lng);
         $this->option['style'] = $editor->getStyle();
         if (empty($this->option['description'])) {
             $this->option['description'] = $editor->getHelp();
         } else {
             $this->option['description'] = $editor->getHelp() . '<br>' . $this->option['description'];
         }
         $editor->display();
     }
     return $this->build($this->option['type'], $this->option);
 }
Пример #11
0
<?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');
use Config\System as Config;
$uri = App::request()->getUri();
$form = new Mobicms\Form\Form(['action' => $uri]);
$form->title(_g('Registration'))->element('checkbox', 'usrRegAllow', ['label_inline' => _dg('Allow registration'), 'checked' => Config::$usrRegAllow])->element('checkbox', 'usrRegModeration', ['label_inline' => _dg('Enable moderation'), 'checked' => Config::$usrRegModeration])->element('checkbox', 'usrRegEmail', ['label_inline' => _dg('Confirmation by Email'), 'checked' => Config::$usrRegEmail])->element('checkbox', 'usrRegQuarantine', ['label_inline' => _dg('Enable Quarantine'), 'checked' => Config::$usrRegQuarantine]);
if (App::user()->get()->rights == 9) {
    $form->title(_dg('For Users'))->element('checkbox', 'usrChangeSex', ['label_inline' => _dg('Change Sex'), 'checked' => Config::$usrChangeSex])->element('checkbox', 'usrChangeStatus', ['label_inline' => _dg('Change Status'), 'checked' => Config::$usrChangeStatus])->element('checkbox', 'usrUploadAvatars', ['label_inline' => _dg('Upload Avatars'), 'checked' => Config::$usrUploadAvatars])->element('checkbox', 'usrGravatar', ['label_inline' => _dg('Use Gravatar'), 'checked' => Config::$usrGravatar])->element('checkbox', 'usrNicknameDigitsOnly', ['label_inline' => _dg('Allow Nicknames, consisting of digits'), 'checked' => Config::$usrNicknameDigitsOnly])->element('checkbox', 'usrChangeNickname', ['label_inline' => _dg('Allow to change Nickname'), 'checked' => Config::$usrChangeNickname])->element('text', 'usrChangeNicknamePeriod', ['label_inline' => _dg('After how many days?') . ' <span class="note">(0-90)</span>', 'value' => Config::$usrChangeNicknamePeriod, 'class' => 'mini', 'limit' => ['type' => 'int', 'min' => 0, 'max' => 90]])->title(_dg('For Guests'))->element('checkbox', 'usrViewOnline', ['label_inline' => _dg('Online Lists'), 'checked' => Config::$usrViewOnline])->element('checkbox', 'usrViewUserlist', ['label_inline' => _dg('List of Users'), 'checked' => Config::$usrViewUserlist])->element('checkbox', 'usrViewProfiles', ['label_inline' => _dg('View Profiles'), 'checked' => Config::$usrViewProfiles])->title(_dg('Antiflood'))->element('radio', 'usrFloodMode', ['checked' => Config::$usrFloodMode, 'items' => ['3' => _dg('Day'), '4' => _dg('Night'), '2' => _dg('Autoswitch'), '1' => _dg('Adaptive')]])->element('text', 'usrFloodDay', ['value' => Config::$usrFloodDay, 'class' => 'small', 'label_inline' => _dg('Sec.') . ', ' . _dg('Day') . ' <span class="note">(3-300)</span>', 'limit' => ['type' => 'int', 'min' => 3, 'max' => 300]])->element('text', 'usrFloodNight', ['value' => Config::$usrFloodNight, 'class' => 'small', 'label_inline' => _dg('Sec.') . ', ' . _dg('Night') . ' <span class="note">(3-300)</span>', 'limit' => ['type' => 'int', 'min' => 3, 'max' => 300]]);
}
$form->divider()->element('submit', 'submit', ['value' => _g('Save'), 'class' => 'btn btn-primary'])->html('<a class="btn btn-link" href="../">' . _g('Back') . '</a>');
if ($form->process() === true) {
    // Записываем настройки
    (new Mobicms\Config\WriteHandler())->write('System', $form->output);
    App::redirect($uri . '?saved');
}
App::view()->form = $form->display();
App::view()->setTemplate('edit_form.php');
Пример #12
0
<?php

$url = App::request()->getBaseUrl();
$profile = isset($profile) ? $profile : App::profile();
$rights = App::user()->get()->rights;
$proxy = App::request()->isProxyIp();
?>
<li>
    <!-- Кнопка выпадающего меню -->
    <?php 
if ($rights) {
    ?>
        <div>
            <a href="#" class="lbtn dropdown dropdown-toggle" data-toggle="dropdown"></a>
            <ul class="dropdown-menu" role="menu">
                <li class="dropdown-header"><?php 
    echo _g('IP Management');
    ?>
</li>
                <li><a href="<?php 
    echo $url;
    ?>
/whois/<?php 
    echo $profile['ip'];
    ?>
"><i class="search fw"></i>IP Whois</a></li>
                <?php 
    if ($proxy) {
        ?>
                    <li><a href="#"><i class="cogs fw"></i><?php 
        echo _g('Proxy Management');
Пример #13
0
 * @copyright   Copyright (C) mobiCMS Community
 * @license     LICENSE.md (see attached file)
 */
defined('MOBICMS') or die('Error: restricted access');
use Config\System as Config;
$user = App::user()->get();
$form = new Mobicms\Form\Form(['action' => App::request()->getUri()]);
if ($user->rights >= 7 || $user->change_time < time() - Config::$usrChangeNicknamePeriod * 86400) {
    $form->title(_dg('Change Nickname'))->element('text', 'nickname', ['label' => _dg('New Nickname'), 'maxlength' => 20, 'required' => true])->element('text', 'repeat', ['label' => _dg('Repeat Nickname'), 'maxlength' => 20, 'description' => _g('Min. 2, Max. 20 Characters.<br>Allowed letters are Cyrillic and Latin alphabet, numbers, spaces and punctuation - = @ ! ? ~ . _ ( ) [ ] *') . '<br/>' . _dg('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 . ' ' . _n('Day', 'Days', Config::$usrChangeNicknamePeriod) . '.', 'required' => true])->element('password', 'password', ['label' => _dg('Your Password'), 'required' => true])->divider()->element('submit', 'submit', ['value' => _g('Save'), 'class' => 'btn btn-primary'])->html('<a class="btn btn-link" href="../">' . _g('Back') . '</a>')->validate('nickname', 'lenght', ['min' => 2, 'max' => 20])->validate('repeat', 'compare', ['compare_field' => 'nickname']);
} else {
    $form->html('<div class="alert alert-danger">' . '<strong>' . _dg('Nickname can not change more than once a') . ' ' . Config::$usrChangeNicknamePeriod . ' ' . _n('Day', 'Days', Config::$usrChangeNicknamePeriod) . '</strong><br/><br/>' . _dg('You have already changed their nickname:') . ' ' . Includes\Functions::displayDate($user->change_time) . '<br/>' . _dg('Next time will be able to change:') . ' ' . Includes\Functions::displayDate($user->change_time + Config::$usrChangeNicknamePeriod * 86400) . '</div>')->html('<a class="btn btn-primary" href="../">' . _g('Back') . '</a>');
}
if ($form->process() === true) {
    try {
        // Проверяем ник
        App::user()->validate()->checkNickname($form->output['nickname']);
        // Проверяем пароль
        if (!$user->checkPassword($form->output['password'])) {
            $form->setError('password', _g('Invalid password'));
        }
    } catch (Mobicms\Checkpoint\Exceptions\UserExceptionInterface $e) {
        $form->setError('nickname', $e->getMessage());
    }
    // Если все проверки пройдены, записываем данные
    if ($form->isValid) {
        $profile = App::profile();
        $profile->nickname = $form->output['nickname'];
        $profile->change_time = time();
        $profile->save();
        $form->continueLink = '../';
        $form->successMessage = _dg('Nickname successfully changed');
Пример #14
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');
$user = App::user()->get();
$profile = App::profile();
$form = new Mobicms\Form\Form(['action' => App::request()->getUri()]);
$form->title(_m('Change Password'))->element('password', 'oldpass', ['label' => $profile->id == $user->id ? _m('Old Password') : _m('Admin Password'), 'required' => true])->element('password', 'newpass', ['label' => _m('New Password'), 'description' => _s('The password length min. 3 characters'), 'required' => true])->element('password', 'newconf', ['label' => _s('Repeat 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('oldpass', 'lenght', ['continue' => false, 'min' => 3])->validate('newpass', 'lenght', ['continue' => false, 'min' => 3])->validate('newconf', 'compare', ['compare_field' => 'newpass', 'error' => _s("Passwords don't coincide")]);
if ($form->process() === true) {
    if ($user->checkPassword($form->output['oldpass'])) {
        $profile->setPassword($form->output['newpass']);
        $profile->setToken(App::user()->generateToken());
        $profile->save();
        if ($profile->id == $user->id) {
            $remember = filter_has_var(INPUT_COOKIE, App::user()->domain);
            App::user()->login($user->nickname, $form->output['newpass'], $remember);
        }
        $form->continueLink = '../';
        $form->successMessage = _m('The password is successfully changed');
        $form->confirmation = true;
    } else {
        $form->setError('oldpass', _s('Invalid password'));
    }
}
App::view()->form = $form->display();
App::view()->setTemplate('edit_form.php');
Пример #15
0
 /**
  * Write session data
  *
  * @param string $sessionId
  * @param string $data
  * @return bool
  */
 public function write($sessionId, $data)
 {
     try {
         $stmt = $this->db->prepare('UPDATE `system__sessions` SET
             `data` = :data,
             `timestamp` = :time,
             `ip` = :ip,
             `user_agent` = :ua,
             `place` = :place,
             `views` = :views,
             `movings` = :movings,
             `user_id` = :uid
             WHERE `id` = :id');
         $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
         $stmt->bindParam(':data', $data, \PDO::PARAM_LOB);
         $stmt->bindValue(':time', time(), \PDO::PARAM_INT);
         $stmt->bindValue(':ip', $this->request->getClientIp(), \PDO::PARAM_STR);
         $stmt->bindValue(':ua', $this->request->getUserAgent(), \PDO::PARAM_STR);
         $stmt->bindValue(':place', \App::router()->getCurrentModule(), \PDO::PARAM_STR);
         $stmt->bindValue(':views', $this->views, \PDO::PARAM_INT);
         $stmt->bindValue(':movings', $this->movings, \PDO::PARAM_INT);
         $stmt->bindValue(':uid', \App::user()->get()->id, \PDO::PARAM_INT);
         $stmt->execute();
         return true;
     } catch (\PDOException $e) {
         $this->rollback();
         throw $e;
     }
 }
Пример #16
0
        </a>
    </div>
    <div class="separator"></div>
    <div><h1><?php 
echo _s('Avatars');
?>
</h1></div>
    <div class="button"></div>
</div>

<!-- Информация о пользователе -->
<?php 
if (!isset($this->hideuser)) {
    ?>
    <?php 
    $profile = App::user()->get();
    ?>
    <div class="info-block m-list">
        <ul><?php 
    include_once $this->getPath('include.user.php');
    ?>
</ul>
    </div>
<?php 
}
?>

<!-- Форма установки аватара -->
<div class="content box padding">
    <?php 
echo $this->form;
Пример #17
0
        } elseif ($valid->checkNicknameExists($form->output['nickname'])) {
            // Ник уже занят
            $form->setError('nickname', _s('This Nickname is already taken'));
        }
        // Проверяем Email
        if (!empty($form->output['email'])) {
            if (!filter_var($form->output['email'], FILTER_VALIDATE_EMAIL)) {
                $form->setError('email', _s('Invalid Email address'));
            } elseif ($valid->checkEmailExists($form->output['email'])) {
                $form->setError('email', _s('This Email is already taken'));
            }
        }
        // Добавляем пользователя в базу и впускаем на сайт
        if ($form->isValid) {
            try {
                $activate = Config::$usrRegEmail || Config::$usrRegModeration ? 1 : 2;
                $approve = Config::$usrQuarantine ? 1 : 2;
                App::user()->addUser($form->output['nickname'], $form->output['newpass'], $form->output['email'], $activate, $approve);
                App::user()->login($form->output['nickname'], $form->output['newpass'], true);
                App::redirect(App::request()->getBaseUrl());
            } catch (Exception $e) {
                $form->errorMessage = _s('When saving the form there errors occurred, try once again. If problem repeat, contact the Site Administrator');
            }
        }
    }
    App::view()->form = $form->display();
    App::view()->setTemplate('registration.php');
}
//TODO: Добавить подтверждение по Email
//TODO: Добавить отправку Welcome Message
//TODO: Добавить страницу с приветствием
Пример #18
0
        $form->successMessage = _g('Avatar is installed');
        $form->confirmation = true;
        App::view()->hideuser = true;
    }
    App::view()->form = $form->display();
    App::view()->setTemplate('avatars_set.php');
} elseif (isset($query[1], $query[2], $catalog[$query[2]]) && $query[1] == 'list') {
    // Показываем список аватаров в выбранной категории
    $avatars = glob(ROOT_PATH . 'assets' . DS . 'avatars' . DS . $query[2] . DS . '*.{gif,jpg,png}', GLOB_BRACE);
    App::view()->total = count($avatars);
    App::view()->start = App::vars()->page * App::view()->pagesize - App::view()->pagesize;
    $end = App::vars()->page * App::view()->pagesize;
    if ($end > App::view()->total) {
        $end = App::view()->total;
    }
    if (App::view()->total) {
        App::view()->list = [];
        for ($i = App::view()->start; $i < $end; $i++) {
            App::view()->list[$i] = ['image' => $homeUrl . '/assets/avatars/' . urlencode($query[2]) . '/' . basename($avatars[$i]), 'link' => App::user()->isValid() ? '../../set/' . urlencode($query[2]) . '/' . urlencode(basename($avatars[$i])) : '#'];
        }
    }
    App::view()->cat = $query[2];
    App::view()->setTemplate('avatars_list.php');
} else {
    // Показываем каталог аватаров (список категорий)
    App::view()->list = [];
    foreach ($catalog as $key => $val) {
        App::view()->list[] = ['link' => $uri . 'list/' . urlencode($key) . '/', 'name' => $val, 'count' => count(glob(ROOT_PATH . 'assets' . DS . 'avatars' . DS . $key . DS . '*.{gif,jpg,png}', GLOB_BRACE))];
    }
    App::view()->setTemplate('avatars_index.php');
}
Пример #19
0
">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
    </div>
</div>

<!-- Список пользователей -->
<div class="content box m-list">
    <?php 
if (App::user()->isValid() || Config\System::$usrViewOnline) {
    ?>
        <?php 
    $config = App::user()->get()->config();
    ?>
        <h2><?php 
    echo _s('Users List');
    ?>
</h2>
        <ul class="striped">
            <?php 
    if (isset($this->list)) {
        ?>
                <?php 
        foreach ($this->list as $profile) {
            ?>
                    <?php 
            include $this->getPath('include.user.php');
            ?>
Пример #20
0
                        <li><a href="#"><i class="group fw"></i><?php 
echo _s('Community');
?>
</a></li>
                        <li><a href="#"><i class="picture fw"></i><?php 
echo _s('Photo Album');
?>
</a></li>
                    </ul>
                </li>
            </ul>

            <!-- Ссылки справа -->
            <ul class="nav navbar-nav navbar-right">
                <?php 
if (App::user()->isValid()) {
    ?>
                    <?php 
    if ($user->rights) {
        ?>
                        <li<?php 
        echo App::router()->getCurrentModule() == 'admin' ? ' class="active"' : '';
        ?>
>
                            <a href="<?php 
        echo $url;
        ?>
/admin/"><i class="cogs fw"></i><?php 
        echo _s('Admin Panel');
        ?>
</a>
Пример #21
0
 *
 * @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;
$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-х подряд)
        $form->setError('nickname', _s('Repeated characters'));
    } elseif (filter_var($form->output['nickname'], FILTER_VALIDATE_EMAIL)) {
        // Попытка использовать Email адрес в качестве Ника
Пример #22
0
 public static function setUser($user)
 {
     self::$user = $user;
 }
Пример #23
0
 public function add()
 {
     if (!\App::isGranted('addPost')) {
         redirect('admin/dashboard');
     }
     try {
         // get post types and categories from helper
         $postTypes = getPostTypes();
         $categorys = getCategorys();
         if ($this->input->post()) {
             $postManager = $this->container->get('post.post_manager');
             $ruleManager = $this->container->get('post.rule_manager');
             $post = $postManager->createPost();
             $this->form_validation->set_rules($ruleManager->getRules(array('title')));
             if ($this->form_validation->run($this)) {
                 $post->setTitle($this->input->post('title'));
                 $post->setContent($this->input->post('content'));
                 $post->setAuthor(\App::user());
                 $postTypeManager = $this->container->get('post.post_type_manager');
                 if ($this->input->post('postType')) {
                     $postType = $postTypeManager->getPostTypeById($this->input->post('postType'));
                 } else {
                     $postType = defaultPostType();
                 }
                 $post->setPostType($postType);
                 $categoryManager = $this->container->get('post.category_manager');
                 if ($this->input->post('category')) {
                     foreach ($this->input->post('category') as $id) {
                         $cat = $categoryManager->getCategoryById($id);
                         if ($cat) {
                             $post->addCategory($cat);
                         }
                     }
                 } else {
                     $cat = defaultCategory();
                     $post->addCategory($cat);
                 }
                 if ($this->input->post('tags')) {
                     $tags = explode(',', $this->input->post('tags'));
                     $dbTags = getAllTags();
                     $tagManager = $this->container->get('post.tag_manager');
                     foreach ($tags as $tag) {
                         if (!in_array($tag, $dbTags) && $tag) {
                             $newTag = $tagManager->createTag();
                             $newTag->setName($tag);
                             $tagManager->updateTag($newTag);
                             $tag = $newTag;
                         } else {
                             $tag = $tagManager->getTagByName($tag);
                         }
                         if ($tag) {
                             $post->addTag($tag);
                         }
                     }
                 }
                 if ($this->input->post('mediaSrc')) {
                     $sources = explode(',', $this->input->post('mediaSrc'));
                     $dbMedia = getAllMediaSources();
                     $mediaManager = $this->container->get('media.media_manager');
                     foreach ($sources as $src) {
                         if (!in_array($src, $dbMedia) && $src) {
                             $newMedia = $mediaManager->createMedia();
                             $newMedia->setSource($src);
                             $mediaManager->updateMedia($newMedia);
                             $media = $newMedia;
                         } else {
                             $media = $mediaManager->getMediaBySource($src);
                         }
                         if ($src) {
                             $post->addMedia($media);
                         }
                     }
                 }
                 if ($this->input->post('btnSave')) {
                     $post->saveToDraft();
                 } elseif ($this->input->post('btnPublish')) {
                     $post->activate();
                 }
                 $postManager->updatePost($post);
                 $this->session->setFlashMessage('feedback', "Post ({$post->getTitle()}) has been created.", 'success');
                 redirect(site_url('admin/post'));
             }
         }
         $this->breadcrumbs->push('New', current_url());
         $this->templateData['postTypes'] = $postTypes;
         $this->templateData['categorys'] = $categorys;
         $this->templateData['pageTitle'] = 'Add Post';
         $this->templateData['content'] = 'post/new';
         $this->load->view('backend/main_layout', $this->templateData);
     } catch (Exception $e) {
         $this->session->setFlashMessage('feedback', "{$e->getMessage()}", 'error');
         redirect(site_url('admin/post/add'));
     }
 }
Пример #24
0
 public function pagination()
 {
     return ' LIMIT ' . \App::vars()->start . ',' . \App::user()->get()->config()->pageSize;
 }
Пример #25
0
 public static function item($aParams = array(), $bReturn = false)
 {
     $sHtml = '<div class="app_item">';
     $sHtml .= '<div class="app_item_time">' . $aParams['time'] . '</div>';
     $sHtml .= '<div class="app_item_left"><a href="#"><img src="' . $aParams['profile_image'] . '" /></a></div>';
     $sHtml .= '<div class="app_item_content">';
     $sHtml .= '<a href="#" class="app_item_title">' . $aParams['display_name'] . '</a>';
     $sHtml .= '<div class="app_item_data">' . $aParams['content'] . '</div>';
     $sHtml .= '<div class="app_item_comments">';
     $sHtml .= '<div class="app_item_cmt_total" id="app_comment_count_' . $aParams['module'] . '' . $aParams['id'] . '">' . $aParams['comments'] . '</div>';
     $sHtml .= '<a href="#do=get&amp;module=' . $aParams['module'] . '&amp;id=' . $aParams['id'] . '" class="app_item_comments_link app_ajax_call" rel="comment">Comment</a>';
     $sHtml .= '<div id="app_item_like_' . $aParams['module'] . $aParams['id'] . '">';
     $sHtml .= '<div class="app_item_likes">' . $aParams['likes'] . '</div>';
     if (isset($aParams['is_liked'])) {
         $sHtml .= '<a href="#module=' . $aParams['module'] . '&amp;id=' . $aParams['id'] . '&amp;do=add" rel="like" class="is_like app_ajax_call app_item_likeit"' . (empty($aParams['is_liked']) ? '' : ' style="display:none;"') . '>Like</a>';
         $sHtml .= '<a href="#module=' . $aParams['module'] . '&amp;id=' . $aParams['id'] . '&amp;do=remove" rel="like" class="is_unlike app_ajax_call app_item_likeit"' . (!empty($aParams['is_liked']) ? '' : ' style="display:none;"') . '>Unlike</a>';
     }
     $sHtml .= '</div>';
     $sHtml .= '</div>';
     $sHtml .= '<div class="app_item_comment_body" id="app_item_comment_body_' . $aParams['module'] . '' . $aParams['id'] . '">';
     $sHtml .= '<div id="app_comment_body_' . $aParams['module'] . '' . $aParams['id'] . '"></div>';
     $sHtml .= '<div class="app_comment"><div class="app_comment_image"><img src="' . App::user()->photo_50px_square . '" alt="" width="32" height="32" /></div>';
     $sHtml .= '<div class="app_comment_body">';
     $sHtml .= '<div><input type="hidden" class="app_comment_form" name="app_comment_form" value="' . $aParams['module'] . '|' . $aParams['id'] . '" /></div>';
     $sHtml .= '<input type="text" name="post[text]" placeholder="Write a comment..." class="app_comment_text" />';
     $sHtml .= '</div></div></div>';
     $sHtml .= '</div>';
     $sHtml .= '</div>';
     if ($bReturn) {
         return $sHtml;
     }
     echo $sHtml;
 }
Пример #26
0
</li>
    <li><a href="#"><i class="pictures lg fw"></i><?php 
echo _s('Photo Album');
?>
 <span class="label label-warning">planned</span> <span class="badge badge-right">0</span></a></li>
    <li><a href="#"><i class="comments lg fw"></i><?php 
echo _s('Guestbook');
?>
 <span class="label label-warning">planned</span> <span class="badge badge-right">0</span></a></li>
    <li><a href="#"><i class="group lg fw"></i><?php 
echo _m('Friends');
?>
 <span class="label label-warning">planned</span> <span class="badge badge-right">0</span></a></li>

    <?php 
if (App::user()->isValid() && $user->id != $profile->id) {
    ?>
        <li class="title"><?php 
    echo _s('Mail');
    ?>
</li>
        <?php 
    if (empty($this->banned)) {
        ?>
            <li><a href="<?php 
        echo $homeUrl;
        ?>
/mail/?act=messages&amp;id=<?php 
        echo $profile->id;
        ?>
"><i class="envelope lg fw"></i><?php 
Пример #27
0
" class="app_logo app_js" rel="index"><?php 
echo APP_SITE_NAME;
?>
</a>
				</div>
				<?php 
if (!App::isMobile()) {
    ?>
				<a href="<?php 
    echo App::link('profile/' . App::user()->user_name);
    ?>
" class="app_header_user"><div style="background-image:url('<?php 
    echo App::user()->photo_50px_square;
    ?>
');"></div><?php 
    echo App::user()->full_name;
    ?>
</a>
				<?php 
}
?>
			</div>
		</div>
		
		<div class="app_holder">
			<div id="app_body">
			
				<?php 
if (App::getToken()) {
    ?>
				<div id="app_body_left">
Пример #28
0
$public_actions = ['reputation' => 'reputation.php'];
$personal_actions = ['option' => 'option.php', 'option/avatar' => 'option_avatar.php', 'option/avatar/animation' => 'option_avatar_animation.php', 'option/avatar/delete' => 'option_avatar_delete.php', 'option/avatar/gravatar' => 'option_avatar_gravatar.php', 'option/avatar/image' => 'option_avatar_image.php', 'option/edit' => 'option_edit.php', 'option/email' => 'option_email.php', 'option/language' => 'option_language.php', 'option/nickname' => 'option_nickname.php', 'option/password' => 'option_password.php', 'option/rank' => 'option_rank.php', 'option/settings' => 'option_settings.php', 'option/theme' => 'option_theme.php'];
App::lng()->setModule('profile');
$query = App::router()->getQuery();
$user = App::user()->get();
$include = __DIR__ . '/includes/';
if (isset($query[0])) {
    try {
        if (!ctype_digit($query[0]) || $query[0] < 1) {
            throw new Exception('Invalid data');
        }
        $profile = App::user()->findById($query[0]);
        App::registerInstance($profile, 'profile');
        if (isset($query[1])) {
            $act = implode('/', array_slice($query, 1));
            if (($user->rights == 9 || $user->rights == 7 && $user->rights > $profile->rights || App::user()->isValid() && $user->id == $profile->id) && isset($personal_actions[$act])) {
                $include .= $personal_actions[$act];
            } elseif (isset($public_actions[$act])) {
                $include .= $public_actions[$act];
            } else {
                $include = false;
            }
        } else {
            $include .= 'profile.php';
        }
    } catch (Exception $e) {
        //TODO: Сделать пересылку на ошибку несуществующего юзера
        echo _s('User does not exists');
        exit;
    }
} else {
Пример #29
0
 public function confirmPassword($pwd)
 {
     if (!password_verify($pwd, \App::user()->getPassword())) {
         $this->form_validation->set_message('confirmPassword', 'Password is wrong.');
         return false;
     }
 }
Пример #30
0
                        <img src="" class="user-image" alt="User Image"/>
                        <span class="hidden-xs"><?php 
echo \App::user()->getName();
?>
</span>
                    </a>
                    <ul class="dropdown-menu">
                        <!-- User image -->
                        <li class="user-header">
                            <img src="" class="img-circle" alt="User Image" />
                            <p>
                                <?php 
echo \App::user()->getName();
?>
                                <small>Member since <?php 
echo \App::user()->getCreatedAt()->format('F d, Y');
?>
</small>
                            </p>
                        </li>
                        <!-- Menu Body -->
                        <li class="user-body">
                            <div class="col-xs-5 text-center">
                                <a href="<?php 
echo site_url('admin/user/profile');
?>
" class="btn btn-default btn-flat">Profile</a>
                            </div>
                            <div class="col-xs-7 text-center">
                                <a href="<?php 
echo site_url('admin/user/changePassword');