<?php add_apage(array('code' => 'console', 'parent' => 'settings', 'title' => 'Консоль', 'rule' => 'admin_settings', 'category' => 'admin', 'priority' => 20, 'function' => function () { get_module_template('console.php'); })); add_action(array('code' => 'console_doit', 'function' => 'action_console_doit', 'rule' => 'admin, admin_settings', 'zone' => 'before_template', 'category' => 'admin', 'auto' => 'console')); function action_console_doit() { global $DETDB, $ACTIONS, $SCRIPTS, $BLOCK, $PAGE, $APAGES; set_glob_content(array('body' => array('', ''))); if (isset($_POST['input'])) { $input = $_POST['input']; $output = $input; ob_start(); $time_start = microtime(true); eval($output); $time_end = microtime(true); $output = ob_get_clean(); $time = number_format($time_end - $time_start, 7); set_glob_content(array('body' => array($input, $output))); push_output_message(array('title' => 'Выполнено!', 'text' => "Время выполнения вашего запроса: <b>{$time} сек</b>.", 'type' => 'success', 'class' => 'alert alert-success')); } }
<?php //All basic pages add_apage(array('code' => 'index', 'parent' => '0', 'title' => 'Главная страница', 'function' => 'show_index_page', 'rule' => 'public', 'priority' => 0)); add_apage(array('code' => '404_error', 'parent' => '0', 'title' => 'Страница не найдена', 'function' => 'show_404_page', 'rule' => 'public', 'priority' => 0)); function show_index_page() { get_template('index.php'); } function show_404_page() { echo '404'; }
})); add_apage(array('code' => 'detblocks_types', 'title' => 'Типы контента', 'rule' => 'admin_detblocks', 'category' => 'admin', 'priority' => 3, 'parent' => 'detblocks_panel', 'function' => function () { set_glob_content(array('table' => 'detblocks_types', 'pagi' => true, 'limit' => 10)); get_template('detblocks/types.php'); })); add_apage(array('code' => 'detblocks_type_add', 'title' => 'Добавить DET-блок', 'rule' => 'admin_detblocks', 'category' => 'admin', 'priority' => -1, 'parent' => 'detblocks_types', 'function' => function () { get_template('detblocks/type_add.php'); })); add_apage(array('code' => 'detblocks_categoreis', 'title' => 'Категории контента', 'rule' => 'admin_detblocks', 'category' => 'admin', 'priority' => 5, 'parent' => 'detblocks_panel', 'function' => function () { get_template('detblocks/categories.php'); })); add_apage(array('code' => 'detblocks_fields', 'title' => 'Поля', 'rule' => 'detblocks', 'category' => 'admin', 'priority' => 7, 'parent' => 'detblocks_panel', 'function' => function () { get_template('detblocks/fields.php'); })); add_apage(array('code' => 'detblocks_content', 'title' => 'Контент', 'rule' => 'detblocks', 'category' => 'admin', 'priority' => 7, 'parent' => 'admin_detblocks_panel', 'function' => function () { get_template('detblocks/content.php'); })); add_action(array('code' => 'action_detblocks_type', 'rule' => 'admin_detblocks', 'category' => 'admin', 'auto' => 'detblocks_type_add', 'function' => 'action_detblocks_type', 'zone' => 'before_template')); function action_detblocks_type() { global $DETDB, $PAGE; $current = isset($_GET['block_id']) && is_numeric($_GET['block_id']) ? $_GET['block_id'] : null; $temp = $block = (object) array('code' => '', 'name' => '', 'description' => ''); if ($current && ($res = get_detblock_type($current))) { $block = set_merge($block, $res); $PAGE->title = 'Обновить DET-блок'; } else { $current = null; } if (isset($_POST['action']) && $_POST['action'] == 'save') { $block = set_merge($block, $_POST);
<?php add_apage(array('code' => 'remote_keys', 'title' => 'Ключи доступа', 'rule' => 'admin_settings', 'category' => 'admin', 'parent' => 'settings', 'priority' => 35, 'function' => function () { set_glob_content(array('table' => 'remote_keys', 'cols' => '*', 'pagi' => true, 'limit' => 30)); get_template('remote/panel.php'); })); add_apage(array('code' => 'remote_keys_edit', 'title' => 'Добавить ключ доступа', 'rule' => 'admin_settings', 'category' => 'admin', 'parent' => 'remote_keys', 'priority' => -1, 'function' => function () { get_template('remote/add.php'); })); add_action(array('code' => 'action_remote_keys_edit', 'rule' => 'admin_settings', 'category' => 'admin', 'auto' => 'remote_keys_edit', 'function' => 'action_remote_keys_edit', 'zone' => 'before_template')); function action_remote_keys_edit() { global $PAGE; $current = isset($_GET['key_id']) && is_numeric($_GET['key_id']) ? $_GET['key_id'] : null; $temp = $key = (object) array('name' => '', 'key_value' => generate_remote_key(), 'rules' => array()); if ($current && ($res = get_remote_key($current))) { $key = set_merge($key, $res); $PAGE->title = 'Обновить ключ'; } else { $current = null; } if (isset($_POST['save'])) { $key = set_merge($key, $_POST); if ($key->name && $key->key_value && is_array($key->rules) && count($key->rules) > 0) { if ($current) { if (update_remote_key($current, $key)) { push_output_message(array('text' => 'Ключ успешно обновлён', 'title' => 'Успех!', 'class' => 'alert alert-success', 'type' => 'success')); $key->ID = $current; set_glob_content(array('body' => $key)); return true; }
$checker = array_merge($checker, actions_zone('settings_checking', $data)); if (!in_array(false, $checker, true)) { push_output_message(array('title' => 'Обновлено!', 'text' => 'Поля успешно обновлены', 'class' => 'alert alert-success')); } else { push_output_message(array('title' => 'Ошибка!', 'text' => 'Поля заполнены некорректно', 'class' => 'alert alert-danger', 'type' => 'error')); } } else { push_output_message(array('text' => 'Поля не заполнены', 'title' => 'Ошибка!', 'class' => 'alert alert-warning', 'type' => 'warning')); } } } add_apage(array('code' => 'settings_php', 'parent' => 'settings', 'title' => 'Информация о PHP', 'rule' => 'admin_settings', 'category' => 'admin', 'priority' => 100, 'function' => function () { get_template('settings/php_info.php'); })); add_apage(array('code' => 'options', 'parent' => 'settings', 'title' => 'Опции', 'rule' => 'admin_settings', 'category' => 'admin', 'priority' => 0, 'function' => function () { set_glob_content(array('table' => 'options', 'pagi' => true, 'limit' => 15)); get_template('settings/options.php'); })); //Others add_action(array('code' => 'ajax_add_option', 'rule' => 'admin_ajax, admin_settings', 'category' => 'admin', 'function' => function ($params = null) { if (isset($params['window']['input'])) { $params = $params['window']['input']; } if ($params) { foreach ($params as $key => $item) { if (is_object($item) || is_array($item)) { $params[$key] = json_val_encode($item); } } } if ($params !== null && isset($params['code']) && add_option($params)) { echo ajax_make_res('reload', "Опция {$params['code']} успешно добавлена", 'Успех!');
if (isset($_GET['user_id'])) { set_glob_content(array('body' => get_user($_GET['user_id']))); } get_template('users/info.php'); })); add_apage(array('code' => 'edit_user', 'parent' => 'users_panel', 'title' => 'Редактирование пользователя', 'function' => 'admin_edit_users', 'rule' => 'admin_users', 'category' => 'admin', 'priority' => -1)); function admin_edit_users() { get_template('users/edit.php'); } add_apage(array('code' => 'user_groups', 'parent' => 'users_panel', 'title' => 'Группы пользователей', 'rule' => 'admin_users', 'category' => 'admin', 'priority' => 10, 'function' => function () { set_glob_content(array('table' => 'users_groups', 'pagi' => true, 'limit' => 20)); get_template('users/groups.php'); })); add_apage(array('code' => 'user_rules', 'parent' => 'users_panel', 'title' => 'Настройка прав', 'rule' => 'admin_settings, admin_rules', 'category' => 'admin', 'priority' => 10, 'function' => function () { set_glob_content(array('body' => get_rules())); get_template('users/rules.php'); })); //Others add_action(array('code' => 'ajax_update_rules', 'category' => 'admin', 'rule' => 'admin_ajax, admin_settings', 'function' => function ($params = null) { if (isset($params['button']['input'])) { $params = $params['button']['input']; } if (isset($params['group']) || isset($params['user'])) { $res = array(); foreach ($params as $key => $item) { if ($key == 'rule') { foreach ($item as $item) { if (isset($item['on']) && $item['on']) { $res[] = $item['value']; } }
<?php //Pages add_apage(array('code' => 'modules_panel', 'title' => 'Модули', 'rule' => 'admin_modules, admin_settings', 'category' => 'admin', 'priority' => 15, 'function' => function () { set_glob_content(array('pagi' => true, 'limit' => 10, 'all' => get_modules_count(), 'handler' => function () { global $PAGE; return array('body' => get_modules_list($PAGE->content['limit'], $PAGE->content['offset'])); })); get_template('modules/panel.php'); })); //Others add_action(array('code' => 'ajax_deactivate_module', 'rule' => 'admin_ajax', 'category' => 'admin', 'function' => function ($params = null) { if (isset($params['button']['pre']['value'])) { $params = $params['button']['pre']['value']; } if ($params && deactivate_module($params)) { echo ajax_make_res('reload', "Модуль {$params} успешно деактивирован", 'Успех!'); } else { echo ajax_make_res('error', 'Произошла неизвестная ошибка', 'Ошибка!'); } })); add_action(array('code' => 'ajax_activate_module', 'rule' => 'admin_ajax', 'category' => 'admin', 'function' => function ($params = null) { if (isset($params['button']['pre']['value'])) { $params = $params['button']['pre']['value']; } if ($params && activate_module($params)) { echo ajax_make_res('reload', "Модуль {$params} успешно активирован", 'Успех!'); } else { echo ajax_make_res('error', 'Произошла неизвестная ошибка', 'Ошибка!'); } }));
add_apage(array('title' => 'Календарь событий', 'code' => 'calendar_event', 'parent' => '', 'rule' => 'calendar_event_admin', 'priority' => 30, 'category' => 'admin', 'function' => function () { get_module_template('panel.php'); })); add_apage(array('title' => 'Календарь событий', 'code' => 'calendar_event', 'rule' => 'public', 'priority' => 30, 'category' => 'public', 'function' => function () { get_module_template('public.php'); })); add_action(array('title' => 'Календарь событий', 'code' => 'remote_calendar_event', 'rule' => 'public', 'category' => 'public', 'function' => function ($params) { $_GET['month'] = isset($params['month']) ? $params['month'] : $_GET['month']; $_GET['year'] = isset($params['year']) ? $params['year'] : $_GET['year']; show_apage('calendar_event'); })); add_apage(array('title' => 'Календарь событий для обмена', 'code' => 'calendar_event_json', 'rule' => 'public', 'priority' => 30, 'category' => 'public', 'skelet' => false, 'function' => function () { show_calendar_events(array('links' => false, 'show' => 'json')); })); add_apage(array('title' => 'Добавить событие', 'category' => 'admin', 'code' => 'calendar_event_add', 'parent' => 'calendar_event', 'rule' => 'calendar_event_admin', 'priority' => -1, 'function' => function () { get_module_template('add.php'); })); add_script(array('type' => 'script', 'link' => get_module_file('js/jquery.datetimepicker.min.js'), 'priority' => '40', 'auto' => 'calendar_event_add', 'category' => 'admin', 'zone' => 'footer', 'code' => 'datetimepicker_js')); add_script(array('type' => 'style', 'link' => get_module_file('js/jquery.datetimepicker.min.css'), 'priority' => '35', 'auto' => 'calendar_event_add', 'category' => 'admin', 'zone' => 'footer', 'code' => 'datetimepicker_css')); add_script(array('type' => 'script', 'priority' => '49', 'auto' => 'calendar_event_add', 'category' => 'admin', 'zone' => 'footer', 'link' => 'http://momentjs.com/downloads/moment.min.js', 'code' => 'moment_js')); add_script(array('type' => 'script', 'priority' => '50', 'auto' => 'calendar_event_add', 'category' => 'admin', 'zone' => 'footer', 'code' => 'datetimepicker_doit', 'function' => function () { $option = get_option('calendar_events_range'); ?> <script> $(function(){ var time_start, time_end, min = null, max = null; var ID = ($('[name="event_ID"]:first-of-type').length) ? $('[name="event_ID"]:first-of-type').val() : ''; function check_calendar_events_near() { $('.datepicker-error').remove(); if($('.table_show table').length) {
<?php //All basic pages add_apage(array('code' => 'index', 'title' => 'Главная', 'function' => 'admin_index', 'rule' => 'admin_panel', 'category' => 'admin', 'priority' => 0)); add_apage(array('code' => '404_error', 'title' => '404. Страница не найдена', 'function' => 'admin_404', 'rule' => 'admin_panel', 'category' => 'admin', 'priority' => -1)); add_apage(array('code' => 'login', 'title' => 'Вход в админ-панель', 'function' => 'admin_show_login', 'rule' => 'public', 'category' => 'admin', 'priority' => -1, 'skelet' => false)); //All basic functions for pages function admin_show_login() { get_template('users/login.php'); } function admin_index() { get_template('index.php'); } function admin_404() { get_template('404.php'); }
function update_apage($par) { if (isset($par['code']) && delete_apage($par['code'])) { add_apage($par); } }