Exemplo n.º 1
0
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'));
    }
}
Exemplo n.º 2
0
function action_settings_main($pre = null)
{
    $custom = array('site_name' => '', 'current_template' => '', 'default_group' => '', 'login_agent' => false, 'login_ip' => false, 'cookie_login_live' => null);
    if (!isset($_POST['site_name'])) {
        $custom['site_name'] = get_option('site_name');
        $custom['current_template'] = get_option('current_template');
        $custom['default_group'] = get_option('default_group');
        $login = get_option('admin_check_login');
        $custom['login_ip'] = $login['login_ip'];
        $custom['login_agent'] = $login['login_agent'];
        $custom['cookie_login_live'] = get_option('cookie_login_live') / 60;
        set_glob_content(array('body' => $custom));
    }
    if (isset($_POST['site_name'])) {
        $data = $pre ? $pre : $_POST;
        $custom_new = set_merge($custom, $data, false, true);
        set_glob_content(array('body' => $custom_new));
        if ($custom_new['site_name'] && $custom_new['current_template'] && $custom_new['default_group']) {
            $checker = array();
            if ($custom['site_name'] != $custom_new['site_name']) {
                $checker[] = update_option('site_name', $custom_new['site_name']);
            }
            if ($custom['current_template'] != $custom_new['current_template']) {
                $checker[] = update_option('current_template', $custom_new['current_template']);
            }
            if ($custom['default_group'] != $custom_new['default_group']) {
                $checker[] = update_option('default_group', $custom_new['default_group']);
            }
            if ($custom['login_agent'] !== $custom_new['login_agent'] || $custom['login_ip'] !== $custom_new['login_ip']) {
                $checker[] = update_option('admin_check_login', array('login_ip' => $custom_new['login_ip'] != false, 'login_agent' => $custom_new['login_agent'] != false));
            }
            if ($custom['cookie_login_live'] != $custom_new['cookie_login_live']) {
                $checker[] = update_option('cookie_login_live', $custom_new['cookie_login_live'] * 60);
            }
            $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'));
        }
    }
}
Exemplo n.º 3
0
function add_option($params)
{
    global $DETDB;
    if (is_array($params)) {
        $custom = (array) new option($params, true);
        $custom['code'] = canone_code($custom['code']);
        if (validate_code($custom['code'])) {
            if (!check_code('options', $custom['code'], 'code')) {
                return $DETDB->insert('options', $custom);
            } else {
                push_output_message(array('text' => 'Данный код уже занят.', 'title' => 'Ошибка!', 'class' => 'alert alert-warning', 'type' => 'error'));
            }
        } else {
            push_output_message(array('text' => 'Отправлен неправильный (невалидный) код.', 'title' => 'Ошибка!', 'class' => 'alert alert-warning', 'type' => 'error'));
        }
    }
    return false;
}
Exemplo n.º 4
0
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);
        if ($current) {
            if (update_detblock($current, $block)) {
                push_output_message(array('text' => "DET-блок успешно обновлён", 'title' => 'Успех!', 'class' => 'alert alert-success', 'type' => 'success'));
                $block->ID = $current;
                set_glob_content(array('body' => $block));
                return true;
            }
        } elseif ($ID = add_detblock($block)) {
            push_output_message(array('text' => "DET-блок {$block->code} успешно добавлен!<br />Создана таблица {$DETDB->prefix}detblocks_content_{$ID}", 'title' => 'Успех!', 'class' => 'alert alert-success', 'type' => 'success'));
            set_glob_content(array('body' => $temp));
            return true;
        } else {
            set_glob_content(array('body' => $block));
            return false;
        }
    } elseif (isset($_POST['action']) && $_POST['action'] == 'delete') {
        if (delete_detblock($current)) {
            push_output_message(array('text' => "DET-блок {$block->code} и все его связи успешно удалены!", 'title' => 'Успех!', 'class' => 'alert alert-success', 'type' => 'success'));
            set_glob_content(array('body' => $temp));
            return true;
        }
    }
    if ($current) {
        $block->ID = $current;
    }
    set_glob_content(array('body' => $block));
    return true;
}
Exemplo n.º 5
0
function delete_detblock($ID)
{
    global $DETDB;
    if (is_numeric($ID)) {
        if ($DETDB->delete('detblocks_types', $ID)) {
            if (!$DETDB->delete_table("detblocks_content_{$ID}")) {
                push_output_message(array('text' => "Ошибка удаления таблицы {$DETDB->prefix}_detblocks_content_{$ID}", 'title' => 'Ошибка!', 'class' => 'alert alert-danger', 'type' => 'error'));
            }
            if (!$DETDB->delete('detblocks_categories', null, "WHERE block_ID={$ID}")) {
                push_output_message(array('text' => 'Ошибка удаления категорий, связанных с DET-блоком (возможно их не было)', 'title' => 'Ошибка!', 'class' => 'alert alert-warning', 'type' => 'error'));
            }
            if (!$DETDB->delete('detblocks_fields', null, "WHERE block_ID={$ID}")) {
                push_output_message(array('text' => 'Ошибка удаления полей, связанных с DET-блоком (возможно их не было)', 'title' => 'Ошибка!', 'class' => 'alert alert-warning', 'type' => 'error'));
            }
            return true;
        } else {
            push_output_message(array('text' => 'Ошибка удаления типа DET-блока', 'title' => 'Ошибка!', 'class' => 'alert alert-danger', 'type' => 'error'));
        }
    }
    return false;
}
Exemplo n.º 6
0
function check_math_captcha($value)
{
    $t = false;
    if (session_status() == 2 && isset($_SESSION['math_captcha'])) {
        if ($value !== '') {
            $value = (int) $value;
        }
        if (is_numeric($_SESSION['math_captcha']['p1']) && is_numeric($_SESSION['math_captcha']['p2'])) {
            switch ($_SESSION['math_captcha']['op']) {
                case '*':
                    $t = $value === $_SESSION['math_captcha']['p1'] * $_SESSION['math_captcha']['p2'];
                    break;
                case '+':
                    $t = $value === $_SESSION['math_captcha']['p1'] + $_SESSION['math_captcha']['p2'];
                    break;
                case '-':
                    $t = $value === $_SESSION['math_captcha']['p1'] - $_SESSION['math_captcha']['p2'];
                    break;
            }
        }
        if (!$t) {
            $try = (int) get_option('admin_math_captcha');
            if (!is_numeric($try) || is_numeric($try) && $try <= 0) {
                $try = 1;
            }
            $_SESSION['math_captcha']['n']++;
            if ($_SESSION['math_captcha']['n'] > $try) {
                unset($_SESSION['math_captcha']);
                push_output_message(array('text' => 'Ошибка в ответе, пример обновлён.', 'title' => 'Ошибка!', 'class' => 'alert alert-danger', 'type' => 'error'));
                generate_math_captcha_session();
            } else {
                push_output_message(array('text' => 'Ошибка в ответе, у вас осталось ' . ($try - 1) . ' попыток.', 'title' => 'Ошибка!', 'class' => 'alert alert-danger', 'type' => 'error'));
            }
        } else {
            unset($_SESSION['math_captcha']);
            generate_math_captcha_session();
        }
    }
    return $t;
}
Exemplo n.º 7
0
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;
                }
            } elseif (add_remote_key($key)) {
                push_output_message(array('text' => 'Ключ успешно добавлен', 'title' => 'Успех!', 'class' => 'alert alert-success', 'type' => 'success'));
                set_glob_content(array('body' => $temp));
                return true;
            } else {
                set_glob_content(array('body' => $key));
                return false;
            }
        } else {
            push_output_message(array('title' => 'Ошибка!', 'text' => 'Заполните все поля (имя, ключ, хотя одно право)', 'class' => 'alert alert-danger'));
        }
    }
    set_glob_content(array('body' => $key));
    return true;
}
Exemplo n.º 8
0
function action_update_note($par = null)
{
    if (is_ajax() || isset($_POST['note'])) {
        $note = isset($par['note']) ? $par['note'] : (isset($_POST['note']) ? $_POST['note'] : '');
        $note = secure_text($note);
        if ((isset($par['note']) || isset($_POST['note'])) && check_rule('admin_settings') && update_option('admin_notes', $note)) {
            if (!is_ajax()) {
                push_output_message(array('title' => 'Обновлено!', 'text' => 'Заметка успешно обновлена', 'class' => 'alert alert-success'));
            }
            return true;
        } else {
            if (!is_ajax()) {
                push_output_message(array('title' => 'Ошибка!', 'text' => 'У вас недостаточно прав для правки публичной заметки', 'class' => 'alert alert-danger'));
            }
            return false;
        }
    }
    return false;
}
Exemplo n.º 9
0
//Подключение модулей
require_once ABSPATH . INCLUDES . '/basic-modules-doit.php';
//Проверка сообщений
if (isset($_COOKIE['reload_message']) && check_json($_COOKIE['reload_message'])) {
    $message = json_decode($_COOKIE['reload_message'], true);
    if (!is_array($message)) {
        $message = array('warning', $message, 'Внимание!');
    }
    if ($message[1]) {
        if ($message[0] == 'reload') {
            $message[0] = 'success';
        }
        if (!isset($message[2])) {
            $message[2] = 'Внимание!';
        }
        push_output_message(array('title' => $message[2], 'type' => $message[0], 'text' => $message[1], 'class' => "message-generate alert alert-{$message[0]}"));
    }
    unset($message);
    destroy_cookie('reload_message');
}
actions_zone('before_form_page');
//Формирование страницы
if (is_ajax()) {
    $PAGE->code = 'ajax_call';
} elseif (is_remote()) {
    $PAGE->code = 'remote_call';
} elseif (!$PAGE->code) {
    $key = get_current_key();
    $PAGE->title = $APAGES[$key]->title;
    $PAGE->code = $key;
}
Exemplo n.º 10
0
function action_edit_user()
{
    global $PAGE;
    $current = isset($_GET['user_id']) && is_numeric($_GET['user_id']) ? $_GET['user_id'] : null;
    if (!$current) {
        $PAGE->title = 'Добавить пользователя';
    }
    if (isset($_POST['action']) && $_POST['action'] == 'save') {
        $temp = $res = array('login' => '', 'code' => '', 'display_name' => '', 'mail' => '', 'groups_ID' => array(), 'rules' => array());
        $res = set_merge($res, $_POST);
        if ($password = $_POST['password']) {
            $salt = random_salt();
            $password = crypt(md5($password), $salt);
            $res['password'] = $password;
            $res['salt'] = $salt;
        }
        if ($res['login'] && $res['display_name'] && $res['mail'] && $res['code'] && count($res['groups_ID']) && (isset($res['password']) || $current)) {
            if ($current) {
                if (update_users($res, "WHERE ID='{$current}'")) {
                    push_output_message(array('title' => 'Обновлено!', 'text' => 'Пользователь успешно обновлён', 'class' => 'alert alert-success'));
                } else {
                    push_output_message(array('title' => 'Ошибка!', 'text' => 'Произошла неизвестная ошибка', 'class' => 'alert alert-danger'));
                }
                $res['ID'] = $current;
                set_glob_content(array('body' => (object) $res));
            } else {
                if (add_user($res)) {
                    push_output_message(array('title' => 'Добавлено!', 'text' => 'Пользователь успешно добавлен', 'class' => 'alert alert-success'));
                } else {
                    push_output_message(array('title' => 'Ошибка!', 'text' => 'Произошла неизвестная ошибка', 'class' => 'alert alert-danger'));
                }
            }
        } else {
            push_output_message(array('title' => 'Ошибка!', 'text' => 'Заполните все обязательные поля', 'class' => 'alert alert-danger'));
            set_glob_content(array('body' => (object) $res));
        }
    } elseif (isset($_POST['action']) && $_POST['action'] == 'delete' && $current && delete_user($current)) {
        push_output_message(array('title' => 'Удалено!', 'text' => 'Пользователь успешно удалён', 'class' => 'alert alert-success'));
        set_glob_content(array('body' => (object) $temp));
    } elseif ($current && ($user = get_user($current, 'ID, login, code, display_name, mail, groups_ID, rules', true))) {
        set_glob_content(array('body' => $user));
    }
}
Exemplo n.º 11
0
<?php

push_output_message(array('title' => 'Внимание!', 'text' => 'В данной консоли возможно выполнение любого PHP-кода, с использованием особенностей Detemiro.
                    <br />
                    Будьте предельно осторожны.', 'type' => 'danger', 'class' => 'alert alert-danger', 'closed' => false));
$tab = isset($_POST['input']) ? true : false;
?>

<div class="content-tags">
    <ul class="nav nav-tabs" role="tablist">
        <li<?php 
echo !$tab ? ' class="active"' : '';
?>
><a href="#input" role="tab" data-toggle="tab">Ввод</a></li>
        <li<?php 
echo $tab ? ' class="active"' : '';
?>
><a href="#output" role="tab" data-toggle="tab">Вывод</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane<?php 
echo !$tab ? ' active' : '';
?>
" id="input">
            <div class="code-input">
                <h3>Введите PHP-код</h3>
                <form method="POST">
                    <textarea name="input" class="form-control" rows="10"><?php 
echo get_glob_content()[0];
?>
</textarea>
Exemplo n.º 12
0
<?php

push_output_message(array('title' => 'Внимание!', 'text' => 'Редактирование опций предназначенно для "простых" (строк и 1-х массивов) данных.', 'type' => 'warning', 'class' => 'alert alert-warning', 'closed' => false));
$options = get_glob_content();
?>

<div id="options-block" class="detwork-control">
    <div class="panel panel-default">
        <div class="panel-body">
            <b>Упраление опциями: </b><a role="button" class="btn btn-primary button-control" data-window="option-edit" data-set-action="add_option"><span class="glyphicon glyphicon-cog"></span> Добавить опцию</a>
        </div>
    </div>
    <?php 
if (is_array($options) && count($options) > 0) {
    ?>
        <table class="table table-striped table-hover table-bordered">
            <thead>
                <tr>
                    <th width="5%">ID</th>
                    <th width="10%">Код</th>
                    <th width="20%">Имя</th>
                    <th>Значение</th>
                </tr>
            </thead>
            <tbody>
                <?php 
    foreach ($options as $item) {
        ?>
                    <tr class="parenter">
                        <td data-id="<?php 
        echo $item->ID;
Exemplo n.º 13
0
function action_calendar_event_proc()
{
    global $DETDB, $PAGE;
    $ID = null;
    $custom = array('name' => '', 'place' => '', 'worker' => '', 'date_start' => date('Y-m-d H:i:s'), 'date_end' => '', 'disable_start' => false, 'disable_end' => false);
    if (isset($_GET['event_id'])) {
        $ID = $_GET['event_id'];
        if ($DETDB->isset_cell('calendar_events', $ID)) {
            $PAGE->title = 'Редактировать событие';
            $custom['ID'] = $ID;
        } else {
            $ID = null;
        }
    }
    set_glob_content(array('body' => $custom));
    if (isset($_POST['calendar_event_submit'])) {
        if ($_POST['name'] && $_POST['worker'] && $_POST['date_start']) {
            $_POST['date_start'] = strtotime($_POST['date_start']);
            if (isset($_POST['time_start']) && $_POST['time_start']) {
                $_POST['time_start'] = explode(':', date('H:i', strtotime($_POST['time_start'])));
                for ($i = 0; $i < 1; $i++) {
                    if ($_POST['time_start'][$i][0] == '0') {
                        $_POST['time_start'][$i] = substr($_POST['time_start'][$i], 1);
                    }
                }
                $_POST['date_start'] += (intval($_POST['time_start'][0]) * 60 + intval($_POST['time_start'][1])) * 60;
            }
            $_POST['date_start'] = date('Y-m-d H:i', $_POST['date_start']);
            if (isset($_POST['date_end']) && $_POST['date_end']) {
                $_POST['date_end'] = strtotime($_POST['date_end']);
                if ($_POST['time_end']) {
                    $_POST['time_end'] = explode(':', date('H:i', strtotime($_POST['time_end'])));
                    for ($i = 0; $i < 1; $i++) {
                        if ($_POST['time_end'][$i][0] == '0') {
                            $_POST['time_end'][$i] = substr($_POST['time_start'][$i], 1);
                        }
                    }
                    $_POST['date_end'] += (intval($_POST['time_end'][0]) * 60 + intval($_POST['time_end'][1])) * 60;
                }
                $_POST['date_end'] = date('Y-m-d H:i', $_POST['date_end']);
            }
            $custom = set_merge($custom, $_POST);
            $custom['name'] = secure_text($custom['name']);
            $custom['place'] = secure_text($custom['place']);
            $custom['worker'] = secure_text($custom['worker']);
            $custom['disable_end'] = $custom['disable_end'] ? true : false;
            $custom['disable_start'] = $custom['disable_start'] ? true : false;
            if ($custom['disable_end']) {
                $custom['date_end'] = '';
            }
            $send = $custom;
            unset($send['disable_end'], $send['disable_start']);
            $send['date_params'] = json_val_encode(array($custom['disable_start'], $custom['disable_end']));
            if (strtotime($custom['date_start']) <= strtotime($custom['date_end']) || $custom['date_end'] == '') {
                if (!$ID && $DETDB->insert('calendar_events', $send)) {
                    push_output_message(array('text' => 'Событие успешно добавлено', 'title' => 'Готово!', 'class' => 'alert alert-success', 'type' => 'success'));
                } elseif ($ID && $DETDB->update('calendar_events', $send, "WHERE ID='{$ID}'")) {
                    push_output_message(array('text' => 'Событие успешно обновлено', 'title' => 'Готово!', 'class' => 'alert alert-success', 'type' => 'success'));
                    set_glob_content(array('body' => $custom));
                } else {
                    push_output_message(array('text' => 'Неизвестная ошибка', 'class' => 'alert alert-danger', 'type' => 'error'));
                    set_glob_content(array('body' => $custom));
                }
            } else {
                push_output_message(array('text' => 'Дата начала должна быть меньше или равна дате конца события', 'title' => 'Ошибка!', 'class' => 'alert alert-danger', 'type' => 'error'));
                set_glob_content(array('body' => $custom));
            }
        } else {
            push_output_message(array('text' => 'Заполните все поля', 'title' => 'Ошибка!', 'class' => 'alert alert-warning', 'type' => 'warning'));
            set_glob_content(array('body' => $custom));
        }
    } else {
        if ($ID && ($res = (array) $DETDB->select('calendar_events', '*', true, "WHERE ID='{$ID}'"))) {
            $custom = set_merge($custom, $res);
            if ($res['date_params'] && check_json($res['date_params'])) {
                $res['date_params'] = json_decode($res['date_params'], true);
                if (count($res['date_params']) == 2) {
                    $custom['disable_start'] = $res['date_params'][0];
                    $custom['disable_end'] = $res['date_params'][1];
                }
            }
        }
        set_glob_content(array('body' => $custom));
    }
}
Exemplo n.º 14
0
function update_remote_key($ID, $key)
{
    global $DETDB;
    if (is_object($key)) {
        $key = (array) $key;
    }
    if (is_merged($key) && isset($key['key_value'])) {
        $L = strlen($key['key_value']);
        $custom = set_merge(array('name' => '', 'key_value' => '', 'rules' => ''), $key);
        if ($L >= 16 && $L <= 20) {
            if (preg_match('/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPRQSTUVWXYZ0123456789!@#$%^*()]{16,20}$/i', $custom['key_value'])) {
                if ($DETDB->update('remote_keys', $custom, "WHERE ID={$ID}")) {
                    return true;
                } else {
                    push_output_message(array('title' => 'Ошибка!', 'text' => 'Произошла неизвестная ошибка, возможно, ключ повторяется', 'class' => 'alert alert-danger'));
                }
            } else {
                push_output_message(array('title' => 'Ошибка ключа!', 'text' => 'Воспользуйтесь генератором ключей', 'class' => 'alert alert-danger'));
            }
        } else {
            push_output_message(array('title' => 'Ошибка!', 'text' => 'Ключ должен иметь длину от 16 до 20 символов', 'class' => 'alert alert-danger'));
        }
    }
    return false;
}
Exemplo n.º 15
0
                <label>Проверочный код</label>
                <?php 
    show_recaptcha();
    ?>
                <p class="help-block">Введите код, представленный на изображении.</p>
            </div>
        <?php 
}));
add_action(array('code' => 'check_admin_recaptcha', 'rule' => 'public', 'category' => 'admin', 'auto' => 'login', 'zone' => 'login_check', 'priority' => '30', 'function' => function () {
    $t = true;
    $private_key = get_option('admin_recaptcha_keys')[1];
    if (isset($_POST['recaptcha_challenge_field'])) {
        $resp = recaptcha_check_answer($private_key, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST["recaptcha_response_field"]);
        if (!$resp->is_valid) {
            $t = false;
            push_output_message(array('text' => 'Ошибка заполнения проверочного кода', 'title' => 'Ошибка!', 'class' => 'alert alert-danger', 'type' => 'error'));
        }
    }
    return $t;
}));
function show_recaptcha($skin = 'white')
{
    $public_key = get_option('admin_recaptcha_keys')[0];
    echo "\n            <script>\n                var RecaptchaOptions = {\n                    theme : '{$skin}'\n                };\n            </script>\n        ";
    echo recaptcha_get_html($public_key, null, true);
}
add_action(array('code' => 'admin_recaptcha_settings', 'rule' => 'admin_settings', 'category' => 'admin', 'auto' => 'settings', 'zone' => 'settings_secure', 'priority' => 100, 'function' => function () {
    $keys = get_option('admin_recaptcha_keys');
    ?>
            <hr />
            <h3>Настройки Google ReCaptcha</h3>