Ejemplo n.º 1
0
function get_option($opt, $arr = true, $full = false)
{
    global $DETDB;
    $param = set_ID($opt);
    $cols = $full ? '*' : 'value';
    $res = null;
    if ($param && ($res = $DETDB->select('options', $cols, true, "WHERE {$param}='{$opt}'"))) {
        $value = $res->value;
        if (check_json($value)) {
            $value = json_decode($value, $arr);
            if ($arr && !is_array($value)) {
                $value = array($value);
            }
        }
        if ($full) {
            $res->value = $value;
        } else {
            $res = $value;
        }
    }
    return $res;
}
Ejemplo n.º 2
0
function show_calendar_events($params = array())
{
    global $DETDB;
    $custom = array('links' => false, 'type' => 'month', 'month' => isset($_GET['month']) && is_numeric($_GET['month']) ? $_GET['month'] : date('m'), 'year' => isset($_GET['year']) && is_numeric($_GET['year']) ? $_GET['year'] : date('Y'), 'start' => '', 'end' => '', 'show' => 'table', 'exclude_ID' => null, 'limit' => 100);
    $query = null;
    if (is_merged($params)) {
        $custom = set_merge($custom, $params);
        if ($custom['start']) {
            $custom['start'] = date('Y-m-d H:i', strtotime($custom['start']));
        }
        if ($custom['end']) {
            $custom['end'] = date('Y-m-d H:i', strtotime($custom['end']));
        }
        $custom['year'] = is_numeric($custom['year']) && checkdate('01', '01', $custom['year']) ? $custom['year'] : date('Y');
        $custom['month'] = is_numeric($custom['month']) && checkdate($custom['month'], '01', $custom['year']) ? $custom['month'] : date('m');
        if ($custom['type'] == 'month') {
            $query = array(array('param' => 'MONTH(date_start)', 'value' => $custom['month']), array('param' => 'YEAR(date_start)', 'value' => $custom['year']));
        } else {
            $query = array(array('param' => 'date_end', 'value' => $custom['start'], 'relation' => '>='), array('param' => 'date_start', 'value' => $custom['end'], 'relation' => '<='));
        }
        if ($custom['exclude_ID'] && !is_array($custom['exclude_ID'])) {
            $custom['exclude_ID'] = array($custom['exclude_ID']);
        }
        if ($custom['exclude_ID']) {
            foreach ($custom['exclude_ID'] as $item) {
                $query[] = array('param' => 'ID', 'value' => $item, 'relation' => '!=');
            }
        }
    }
    $events = $query ? $DETDB->select(array('table' => 'calendar_events', 'cols' => '*', 'cond' => $query, 'order_by' => 'date_start', 'order_type' => 'ASC', 'limit' => $custom['limit'])) : null;
    ?>
        <?php 
    if ($events && count($events) > 0 && $custom['show'] == 'table') {
        ?>
            <table class="table table-striped table-hover table-bordered" width="100%">
                <thead>
                    <tr>
                        <th width="7%">Дата</th>
                        <th width="7%">Время</th>
                        <th>Наименование  мероприятия</th>
                        <th width="18%">Место проведения</th>
                        <th width="14%">Ответственный</th>
                    </tr>
                </thead>
                <tbody>
                    <?php 
        foreach ($events as $item) {
            ?>
                        <?php 
            $start = strtotime($item->date_start);
            $end = strtotime($item->date_end);
            ?>
                        <tr class="field">
                            <td>
                                <?php 
            echo date('d', $start);
            if ($end && $end > 0 && date('d', $start) != date('d', $end)) {
                echo ' - ' . date('d', $end);
            }
            ?>
                            </td>
                            <td>
                                <?php 
            if ($item->date_params && check_json($item->date_params)) {
                $item->date_params = json_decode($item->date_params, true);
                if (count($item->date_params) == 2) {
                    $item->date_params = !$item->date_params[0];
                }
            } else {
                $item->date_params = true;
            }
            if ($start && $item->date_params) {
                echo date('G.i', $start);
                if ($end && $end > 0 && $start && $end != $start) {
                    echo ' - ' . date('G.i', $end);
                }
            }
            ?>
                            </td>
                            <td><?php 
            echo $item->name;
            ?>
                            <?php 
            if ($custom['links']) {
                ?>
                                <p class="controls">
                                    <a href="<?php 
                echo get_page_link('calendar_event_add') . '&event_id=' . $item->ID;
                ?>
">Редактировать</a> |
                                    <a class="table-delete button-control" data-set-action="delete_calendar_event" data-id="<?php 
                echo $item->ID;
                ?>
">Удалить</a>
                                </p>
                            <?php 
            }
            ?>
                            </td>
                            <td><?php 
            echo $item->place;
            ?>
</td>
                            <td><?php 
            echo $item->worker;
            ?>
</td>
                        </tr>
                    <?php 
        }
        ?>
                </tbody>
                <tfoot>
                    <tr>
                        <th>Дата</th>
                        <th>Время</th>
                        <th>Наименование  мероприятия</th>
                        <th>Место проведения</th>
                        <th>Ответственный</th>
                    </tr>
                </tfoot>
            </table>
        <?php 
    } elseif ($custom['show'] == 'json') {
        ?>
            <?php 
        echo json_val_encode($events);
        ?>
        <?php 
    } else {
        ?>
            <p>Нет событий, выбранных за данный период.</p>
        <?php 
    }
    ?>
    <?php 
}
Ejemplo n.º 3
0
<?php

//Инициализация пользователя
int_user();
//Подключение модулей
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) {
Ejemplo n.º 4
0
function get_remote_key($ID)
{
    global $DETDB;
    if ($res = $DETDB->select('remote_keys', '*', true, "WHERE ID={$ID}")) {
        if (check_json($res->rules)) {
            $res->rules = json_decode($res->rules, true);
        }
        return $res;
    }
    return null;
}
Ejemplo n.º 5
0
function get_users($par, $only = false)
{
    global $DETDB;
    if (is_object($par)) {
        $par = (array) $par;
    }
    $par['table'] = 'users';
    if ($res = $DETDB->select($par)) {
        $L = count($res);
        for ($i = 0; $i < $L; $i++) {
            if (isset($res[$i]->groups_ID) && check_json($res[$i]->groups_ID)) {
                $res[$i]->groups_ID = json_decode($res[$i]->groups_ID, true);
            }
            if (isset($res[$i]->rules)) {
                $res[$i] = form_user_rules($res, $only);
            }
        }
        return $res;
    }
    return null;
}
Ejemplo n.º 6
0
    if ($hostname['multiple_ip']) {
        $data["error"] = ["Host format is incorrect. (use \$host:\$ip.)"];
    }
    $host = $hostname['hostname'];
    $ip = $hostname['ip'];
    $port = get($_GET['port'], '443');
    if (!is_numeric($port)) {
        $port = 443;
    }
    $fastcheck = $_GET['fastcheck'];
    $write_cache = 1;
    $hostfilename = preg_replace("([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).])", '', $host);
    $hostfilename = preg_replace("([\\.]{2,})", '', $host);
    $hostfilename = preg_replace("([^a-z0-9])", '', $host);
    $cache_filename = (string) "results/saved." . $hostfilename . "." . $epoch . "." . $random_bla . ".api.json";
    $data["data"] = check_json($host, $ip, $port, $fastcheck);
} elseif (isset($_GET['csr']) && !empty($_GET['csr'])) {
    $write_cache = 1;
    $cache_filename = (string) "results/saved.csr." . $epoch . "." . $random_bla . ".api.json";
    $data["data"]["chain"]["1"] = csr_parse_json($_GET['csr']);
} else {
    $data["error"] = ["Host is required"];
}
$data['version'] = $version;
$data = utf8encodeNestedArray($data);
if (isset($data["data"]["error"])) {
    $data["error"] = $data["data"]["error"];
    unset($data["data"]);
}
if ($_GET["type"] == "pretty") {
    header('Content-Type: text/html');
Ejemplo n.º 7
0
        $CONNECT->type = 'remote';
    } elseif ($CONNECT->host == $_SERVER['HTTP_HOST']) {
        $CONNECT->type = 'ajax';
    }
    if ($CONNECT->type) {
        require_once ABSPATH . INCLUDES . '/basic-load.php';
        global $BLOCK;
        if (!$BLOCK) {
            if ($CONNECT->type == 'remote' && (!check_remote_key($CONNECT->key) || $_SERVER['HTTP_USER_AGENT'] != 'DETWorker')) {
                echo 'Wrong key';
            } else {
                $CONNECT->action = canone_code($CONNECT->action);
                if (!preg_match('/^(' . $CONNECT->type . '_)/i', $CONNECT->action)) {
                    $CONNECT->action = $CONNECT->type . '_' . $CONNECT->action;
                }
                if ($CONNECT->params && check_json($CONNECT->params)) {
                    $CONNECT->params = json_decode($CONNECT->params, true);
                }
                if ($CONNECT->category == 'admin') {
                    require_once ABSPATH . '/' . ADMIN . INCLUDES . '/admin-load.php';
                } else {
                    require_once ABSPATH . INCLUDES . '/public/public-load.php';
                }
                require_once ABSPATH . INCLUDES . '/basic-doit.php';
                actions_zone($CONNECT->type . '_before_action', $CONNECT->params);
                make_action($CONNECT->action, $CONNECT->params);
                actions_zone($CONNECT->type . '_after_action', $CONNECT->params);
            }
        }
    }
}
Ejemplo n.º 8
0
function take_good_array($arr, $exp = false, $json = true)
{
    if (!is_array($arr)) {
        if ($json && check_json($arr)) {
            $arr = json_decode($arr, true);
        } elseif (is_object($arr)) {
            $arr = (array) $arr;
        } elseif ($exp && is_string($arr)) {
            $arr = explode(',', $arr);
        } else {
            $arr = array($arr);
        }
    }
    return $arr;
}
Ejemplo n.º 9
0
  <?php 
if (isset($_GET['host']) && !empty($_GET['host'])) {
    echo '<div id="wrapper">';
    $data = [];
    $hostname = mb_strtolower(get($_GET['host']));
    $hostname = parse_hostname($hostname);
    $host = $hostname['hostname'];
    $port = get($_GET['port'], '443');
    if (!is_numeric($port)) {
        $port = 443;
    }
    if ($hostname['multiple_ip']) {
        choose_endpoint($hostname['multiple_ip'], $host, $port, $_GET['ciphersuites']);
    }
    $ip = $hostname['ip'];
    $data["data"] = check_json($host, $ip, $port);
    if (isset($data["data"]["error"])) {
        $data["error"] = $data["data"]["error"];
        unset($data["data"]);
    }
    $chain_length = count($data["data"]["chain"]);
    $chain_data = $data["data"]["chain"];
    if ($chain_length >= 1 && $chain_length < 10) {
        ?>
  <!-- Sidebar -->
  <div id="sidebar-wrapper">
    <nav>
      <ul class="sidebar-nav">
        <br>
        <li class="sidebar-brand">
          <h2>Navigation</h2>
Ejemplo n.º 10
0
<?php

$groups = get_users_groups();
$rules = get_glob_content();
$main_ID = isset($_GET['group']) ? $_GET['group'] : 1;
$current_group = get_user_group($main_ID, 'rules');
if ($current_group) {
    $current_group = $current_group->rules;
    $current_group = check_json($current_group) ? json_decode($current_group, false) : array();
}
?>

<div id="rules-panel">
    <div class="panel panel-default detwork-control">
        <div class="panel-body">
            <b>Упраление правами: </b>
            <a role="button" class="btn btn-primary button-control" data-window="dialog-add" data-set-action="add_rule"><span class="glyphicon glyphicon-certificate"></span> Добавить право</a>
            <form methot="GET" class="pull-right">
                <input type="hidden" name="page" value="<?php 
echo get_current_key();
?>
" />
                <select name="group" onchange="this.form.submit()" class="form-control">
                    <?php 
foreach ($groups as $item) {
    echo '<option value="' . $item->ID . '"' . ($main_ID == $item->ID ? ' selected' : '') . '>' . $item->name . '</option>';
}
?>
                </select>
            </form>
        </div>