Beispiel #1
0
function as_secure_uris($separate = false)
{
    global $additional_urls;
    //
    //	build arrays of default and additional urls to secure
    //
    $tmp1 = array();
    $tmp1[] = "wp-login.php";
    $tmp1[] = "wp-admin/profile.php";
    $tmp1[] = "wp-admin/user-edit.php";
    $tmp1[] = "wp-admin/users.php";
    if (is_https()) {
        $tmp1[] = "wp-admin/css/";
        # admin css files
        $tmp1[] = "wp-admin/images/";
        # admin images
        $tmp1[] = "wp-admin/js/";
        # admin javascript files
        $tmp1[] = "wp-admin/admin-ajax.php";
        # admin ajax scripts
        $tmp1[] = "wp-admin/rtl.css";
        # random admin css file
        $tmp1[] = "wp-admin/wp-admin.css";
        # main admin css file
        $tmp1[] = content_dir();
        # secures themes, plugins and uploads
        $tmp1[] = "wp-includes/";
        # secures WP javascript files etc
    }
    $tmp2 = explode("\n", $additional_urls);
    //
    //	clean both arrays so they match properly later
    //
    if (!function_exists("as_trim")) {
        function as_trim(&$v)
        {
            $v = trim($v);
        }
    }
    array_walk($tmp1, "as_trim");
    array_walk($tmp2, "as_trim");
    //
    //	remove any empty values from the additional urls array
    //
    foreach ($tmp2 as $k => $v) {
        if ($v == "") {
            unset($tmp2[$k]);
        }
    }
    //
    //	return additional uris
    //
    if ($separate) {
        return array("default" => $tmp1, "additional" => $tmp2);
    } else {
        return array_merge($tmp1, $tmp2);
    }
}
function as_siteurl_cookie($action)
{
    global $cookie_value, $cookie_expire, $dir, $plugins_dir, $secure_url;
    //
    //	continue only if action is 'set' and there is a cookie value,
    //	or if action is 'clear'
    //
    $continue = false;
    if ($action === "set" && $cookie_value) {
        $continue = true;
    } elseif ($action === "clear") {
        $cookie_value = " ";
        $cookie_expire = 1;
        $continue = true;
    }
    //
    //	redirect to cookie script - only ever called from wp-login.php
    //
    if ($continue) {
        $path = "/" . content_dir() . "{$plugins_dir}/{$dir}/admin-ssl-cookie.php";
        $file = str_replace("/wp-login.php", "", $_SERVER["SCRIPT_FILENAME"]) . $path;
        as_log("as_siteurl_cookie()\nPath to admin-ssl-cookie.php: {$file}");
        if (file_exists($file)) {
            //
            //	build the URL to redirect to after setting the cookie
            //
            if (redirect_to() && redirect_to() !== "wp-admin/") {
                if (strpos(redirect_to(), "http") === 0) {
                    $redirect = redirect_to();
                } elseif (strpos(redirect_to(), "/") === 0) {
                    $redirect = scheme($use_ssl) . host() . redirect_to();
                } else {
                    $redirect .= $secure_url . "/" . redirect_to();
                }
            } else {
                $redirect = $secure_url . "/wp-login.php";
            }
            //
            //	build the URL to admin-ssl-cookie.php with the cookie data
            //
            $location = rtrim(get_option("siteurl"), "/");
            $location .= "{$path}?name=" . AUTH_COOKIE . "&value={$cookie_value}";
            $location .= "&expire={$cookie_expire}&path=" . COOKIEPATH . "&domain=" . COOKIE_DOMAIN;
            $location .= "&redirect=" . urlencode($redirect);
            as_log("as_siteurl_cookie()\nRedirecting to: {$location}");
            as_redirect($location);
        }
    }
}
Beispiel #3
0
function save_cached($name, $data)
{
    if (strpos($name, '../') !== false) {
        return false;
    }
    $old_umask = @umask(00);
    @mkdir(content_dir() . '/_cache/');
    $ret = @file_put_contents(content_dir() . '/_cache/' . $name . '.html', $data);
    @umask($old_umask);
    return $ret;
}