Exemplo n.º 1
0
function action_login()
{
    global $DETDB;
    if (check_login() && action_check_login()) {
        replace_page('index');
    }
    if (isset($_POST['form_login'])) {
        $checker = actions_zone('login_check');
        if (!in_array(false, $checker, true)) {
            $login = $_POST['form_login'];
            if ($user = $DETDB->select('users', 'ID, login, password, salt', true, "WHERE login='******'")) {
                $password = md5($_POST['form_password']);
                if (crypt($password, $user->salt) == $user->password) {
                    setcookie('user_ID', $user->ID, time() + get_option('cookie_login_live'), '/');
                    $hash = random_hash(10);
                    setcookie('user_hash', $hash, time() + get_option('cookie_login_live'), '/');
                    if ($DETDB->update('users', array('hash' => $hash, 'last_ip' => $_SERVER['REMOTE_ADDR'], 'last_activity' => date('c'), 'last_agent' => $_SERVER['HTTP_USER_AGENT']), "WHERE ID='" . $user->ID . "'")) {
                        $_COOKIE['user_ID'] = $user->ID;
                        $_COOKIE['user_hash'] = $hash;
                        $url = isset($_COOKIE['from_page']) ? $_COOKIE['from_page'] : 'index';
                        destroy_cookie('from_page');
                        int_user();
                        if (make_action('check_login')) {
                            replace_page($url);
                        }
                    }
                }
            }
            if (!$user || !isset($hash)) {
                push_output_message(array('text' => 'Неверный логин или пароль', 'title' => 'Ошибка!', 'class' => 'alert alert-danger', 'type' => 'error'));
            }
        }
    }
}
Exemplo n.º 2
0
function set_glob_content($par)
{
    global $PAGE, $DETDB;
    $par = take_good_array($par);
    $custom =& $PAGE->content;
    $custom = set_merge($custom, $par);
    if ($custom['pagi']) {
        if ($custom['current'] === null) {
            $custom['current'] = get_pagination_number();
        }
        if ($custom['offset'] === null) {
            $custom['offset'] = $custom['limit'] * ($custom['current'] - 1);
        }
    }
    if ($custom['handler']) {
        $pre = null;
        if (is_string($custom['handler'])) {
            $pre = make_action($custom['handler'], $custom);
        } elseif (is_callable($custom['handler'])) {
            $pre = call_user_func($custom['handler'], $custom);
        }
        if ($pre && (is_object($pre) || is_array($pre))) {
            $custom = set_merge($custom, $pre, true);
        }
    }
    if ($custom['pagi'] && $custom['all'] === null) {
        $custom['all'] = isset($par['table']) ? $DETDB->count($par['table']) : 1;
    }
    if ($custom['body'] == '' && isset($par['table'])) {
        if ($custom['pagi']) {
            $par['offset'] = $custom['offset'];
            $par['limit'] = $custom['limit'];
        }
        $custom['body'] = $DETDB->select($par);
    }
    if ($custom['pagi'] && $custom['all'] && $custom['limit'] && ceil($custom['all'] / $custom['limit']) < $custom['current']) {
        redirect(get_current_key(), true);
    }
}
Exemplo n.º 3
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);
            }
        }
    }
}