Example #1
0
File: api.php Project: arhone/cmf
<?php

/**
 * @var $Token arh\token\Token
 * @var $API arh\api\API
 * @var $Access arh\access\Access
 * @var $Access arh\access\AccessManager
 * @var $User arh\user\User
 */
use arh\di\DI;
$DI = new DI();
$Token = $DI->get('Token');
$API = $DI->get('API');
$Access = $DI->get('Access');
$AccessManager = $DI->get('AccessManager');
$token = $_POST['token'] ?? $_GET['token'] ?? false;
if ($Access->get('access.admin') && $Token->check($token)) {
    # Сортировка
    if (isset($_POST['sort'])) {
        $API->answer($AccessManager->sort($_POST['sort']));
        # Редактирование настроек доступа
    } elseif (isset($_POST['edit'])) {
        $API->answer($AccessManager->edit($_POST['edit'], $_POST));
        # Добавление настроек доступа
    } elseif (isset($_POST['add'])) {
        $API->answer($AccessManager->add($_POST));
        # Удаление настроек доступа
    } elseif (isset($_POST['delete'])) {
        $API->answer($AccessManager->delete($_POST['delete']));
        # Список прав доступа
    } elseif (isset($_POST['get'])) {
Example #2
0
File: index.php Project: arhone/cmf
<?php

/**
 * @var $User arh\user\User
 * @var $Config arh\user\Config
 * @var $Tpl arh\tpl\Tpl
 */
use arh\di\DI;
$DI = new DI();
$User = $DI->get('User');
$Config = $DI->get('Config');
$Tpl = $DI->get('Tpl');
if (!$User->get('id')) {
    if ($Config->get('auth.index_exit')) {
        $Tpl->display('exit.tpl');
        exit;
    } else {
        $Tpl->display('index.tpl');
    }
}
Example #3
0
File: admin.php Project: arhone/cmf
<?php

/**
 * @var $Tpl arh\tpl\Tpl
 * @var $Token arh\token\Token
 * @var $Access arh\access\AccessManager
 * @var $User arh\user\User
 */
use arh\di\DI;
$DI = new DI();
$AccessManager = $DI->get('AccessManager');
$Tpl = $DI->get('Tpl');
$Token = $DI->get('Token');
# Редактор прав доступа
if (isset($_GET['edit'])) {
    $Tpl->display('edit.tpl', ['token' => $Token->get(), 'data' => $AccessManager->get($_GET['edit'])]);
    # Хлебные крошки
    $DI->get('Registry')->set('breadcrumbs', ['Редактор настроек' => '/access/edit/' . (int) $_GET['edit']]);
    # Список прав доступа
} else {
    $owner = $_GET['owner'] ?? 'arh';
    $object['type'] = isset($_GET['group']) ? 'group' : 'user';
    $object['id'] = $_GET['user'] ?? $_GET['group'] ?? $DI->get('User')->get('id');
    $Tpl->display('admin.tpl', ['owner' => $owner, 'object' => $object, 'token' => $Token->get(), 'menu' => $DI->get('Module')->getAll(), 'data' => $AccessManager->get($owner, [$object['type'] => $object['id']]), 'Tpl' => $DI->get('Tpl'), 'Color' => $DI->get('Color')]);
}
Example #4
0
File: api.php Project: arhone/cmf
<?php

/**
 * @var $Token arh\token\Token
 * @var $API arh\api\API
 * @var $Access arh\access\Access
 * @var $Access arh\config\ConfigManager
 */
use arh\di\DI;
$DI = new DI();
$Token = $DI->get('Token');
$API = $DI->get('API');
$Access = $DI->get('Access');
$ConfigManager = $DI->get('ConfigManager');
$token = $_POST['token'] ?? $_GET['token'] ?? false;
if ($Access->get('config.admin') && $Token->check($token)) {
    # Сортировка
    if (isset($_POST['sort'])) {
        $API->answer($ConfigManager->sort($_POST['sort']));
        # Редактирование конфигурации
    } elseif (isset($_POST['edit'])) {
        $API->answer($ConfigManager->edit($_POST['edit'], $_POST));
        # Добавление конфигурации
    } elseif (isset($_POST['add'])) {
        $API->answer($ConfigManager->add($_POST));
        # Удаление конфигурации
    } elseif (isset($_POST['delete'])) {
        $API->answer($ConfigManager->delete($_POST['delete']));
        # Список конфигурации
    } elseif (isset($_POST['get'])) {
        $API->answer($Tpl->get('list.tpl', ['data' => $ConfigManager->get($_POST['get'])]));
Example #5
0
File: index.php Project: arhone/cmf
<?php

use arh\di\DI;
$DI = new DI();
/**@var $DB \PDO*/
$DB = $DI->get('DB');
/**@var $Tpl arh\tpl\Tpl*/
$Tpl = $DI->get('Tpl');
Example #6
0
File: admin.php Project: arhone/cmf
<?php

use arh\di\DI;
$DI = new DI(['Menu' => ['class' => ['name' => 'module\\modmenu\\library\\Menu', 'construct' => [['Module'], ['Access']]]]]);
$DI->get('Tpl')->display(CONTROLLER . '.tpl', ['data' => $DI->get('Menu')->getModule(CONTROLLER), 'Color' => $DI->get('Color')]);
Example #7
0
<?php

use arh\di\DI;
$DI = new DI();
$Converter = $DI->get('Converter');
$data = 'Я модуль новостей';
echo $Converter->get('post.content', $data);
Example #8
0
File: api.php Project: arhone/cmf
<?php

/**
 * @var $API arh\api\API
 * @var $Translate arh\translate\Translate
 * @var $User arh\user\User
 */
use arh\di\DI;
$DI = new DI();
$API = $DI->get('API');
$Translate = $DI->get('Translate');
if (isset($_GET['auth'])) {
    # Аутентификация
    if ($_GET['auth'] == 'login') {
        if (!empty($_POST['login']) && !empty($_POST['password'])) {
            $User = $DI->get('User');
            $user = $User->auth($_POST['login'], $_POST['password'], $_POST['remember'] ?? true, $_POST['reset'] ?? false);
            if (!empty($user['id'])) {
                $API->answer($user, ['status' => true, 'code' => 200, 'message' => $Translate->get('Успех', ROOT_DIR . '/translate/error/' . LANGUAGE . '.ini')], true);
            } else {
                $API->answer('', ['status' => false, 'code' => 403, 'message' => $Translate->get('Запрещено', ROOT_DIR . '/translate/error/' . LANGUAGE . '.ini')], true);
            }
        } else {
            $API->answer('', ['status' => false, 'code' => 403, 'message' => $Translate->get('Запрещено', ROOT_DIR . '/translate/error/' . LANGUAGE . '.ini')], true);
        }
    } else {
        $API->answer('', ['status' => false, 'code' => 405, 'message' => $Translate->get('Указанный в запросе метод не допускается для заданного ресурса', ROOT_DIR . '/translate/error/' . LANGUAGE . '.ini')], true);
    }
} else {
    $API->answer(false, 400, $Translate->get('Плохой запрос', ROOT_DIR . '/translate/error/' . LANGUAGE . '.ini'));
}
Example #9
0
File: admin.php Project: arhone/cmf
<?php

/**
 * @var $Tpl arh\tpl\Tpl
 * @var $Token arh\token\Token
 * @var $ConfigManager arh\config\ConfigManager
 */
use arh\di\DI;
$DI = new DI();
$Tpl = $DI->get('Tpl');
$Token = $DI->get('Token');
$ConfigManager = $DI->get('ConfigManager');
# Редактор настроек
if (isset($_GET['edit'])) {
    $Tpl->display('edit.tpl', ['token' => $Token->get(), 'data' => $ConfigManager->get($_GET['edit'])]);
    # Хлебные крошки
    $DI->get('Registry')->set('breadcrumbs', ['Редактор настроек' => '/config/edit/' . (int) $_GET['edit']]);
    # Список настроек
} else {
    $owner = $_GET['owner'] ?? 'arh';
    $Tpl->display('admin.tpl', ['owner' => $owner, 'token' => $Token->get(), 'menu' => $DI->get('Module')->getAll(), 'data' => $ConfigManager->get($owner, $_GET), 'Tpl' => $DI->get('Tpl'), 'Color' => $DI->get('Color'), 'ConfigManager' => $ConfigManager]);
}
Example #10
0
File: index.php Project: arhone/cmf
<?php

/**
 * @var $User arh\user\User
 * @var $Token arh\token\Token
 */
use arh\di\DI;
$DI = new DI();
$User = $DI->get('User');
$Token = $DI->get('Token');
# Выйти
if (isset($_GET['logout']) && $Token->check($_GET['logout'])) {
    $User->logout($_SERVER['HTTP_REFERER'] ?? HOME . '/');
}