Exemple #1
0
function plugin_qhmauth_action()
{
    global $script, $auth_method_type, $auth_users, $edit_auth_pages;
    $qm = get_qm();
    $page = isset($vars['page']) ? $vars['page'] : '';
    $msg = $qm->m['plg_qhmauth']['title'];
    // Checked by:
    $target_str = '';
    if ($auth_method_type == 'pagename') {
        $target_str = $page;
        // Page name
    } else {
        if ($auth_method_type == 'contents') {
            $target_str = join('', get_source($page));
            // Its contents
        }
    }
    $user_list = array();
    foreach ($edit_auth_pages as $key => $val) {
        if (preg_match($key, $target_str)) {
            $user_list = array_merge($user_list, explode(',', $val));
        }
    }
    if (empty($user_list)) {
        return array('msg' => $msg, 'body' => "<p>{$qm->m['plg_qhmauth']['err_pkwk_ini']}</p>");
    }
    //TRUE; // No limit
    //--------------------------------------------
    //Customize from here
    //Session Auth instead of Basic Auth
    //Thanks & Refer SiteDev + AT by AKKO
    if (array_key_exists($_SESSION['usr'], $auth_users)) {
        return array('msg' => $msg, 'body' => "<p>" . $qm->replace('plg_qhmauth.err_has_auth', $_SESSION['usr'], $script) . "</p>");
        //return TRUE;
    }
    $fg = FALSE;
    $fg = ss_chkusr($qm->m['plg_qhmauth']['title'], $auth_users);
    if ($fg) {
        $_SESSION['usr'] = $_POST['username'];
        header('Location: ' . $script);
        exit;
    }
    auth_catbody($msg, $qm->replace('plg_qhmauth.err_deny', $script));
    exit;
}
Exemple #2
0
function basic_auth($page, $auth_flag, $exit_flag, $auth_pages, $title_cannot)
{
    global $auth_method_type, $auth_users, $_msg_auth;
    // Checked by:
    $target_str = '';
    if ($auth_method_type == 'pagename') {
        $target_str = $page;
        // Page name
    } else {
        if ($auth_method_type == 'contents') {
            $target_str = join('', get_source($page));
            // Its contents
        }
    }
    $user_list = array();
    foreach ($auth_pages as $key => $val) {
        if (preg_match($key, $target_str)) {
            $user_list = array_merge($user_list, explode(',', $val));
        }
    }
    if (empty($user_list)) {
        return TRUE;
    }
    // No limit
    //--------------------------------------------
    //Customize from here
    //Session Auth instead of Basic Auth
    //Thanks & Refer SiteDev + AT by AKKO
    if (in_array($_SESSION['usr'], $user_list)) {
        return TRUE;
    }
    $fg = FALSE;
    if ($auth_flag) {
        $arr_temp = array();
        foreach ($user_list as $val) {
            foreach ($auth_users as $user => $pass) {
                if ($val == $user) {
                    $auth_temp[$user] = $pass;
                }
            }
        }
        $qm = get_qm();
        $fg = ss_chkusr($qm->m['auth']['ss_chkusr'], $auth_temp);
        if ($fg) {
            $_SESSION['usr'] = $_POST['username'];
            return TRUE;
        }
    }
    if ($exit_flag) {
        $body = $title = str_replace('$1', htmlspecialchars(strip_bracket($page)), $title_cannot);
        $page = str_replace('$1', make_search($page), $title_cannot);
        auth_catbody($title, $body);
        exit;
    }
    return FALSE;
}