Aleksander Machniak
2014-03-22 2369305ad8f54b69e5ff751609dbb077c77ef4bb
Merge pull request #167 from Steffen185/allow_url_fopen_off

Make modcss.inc work with allow_url_fopen = Off
1 files modified
27 ■■■■ changed files
program/steps/utils/modcss.inc 27 ●●●● patch | view | raw | blame | history
program/steps/utils/modcss.inc
@@ -33,11 +33,7 @@
    exit("Invalid URL");
}
if (!ini_get('allow_url_fopen')) {
    header('HTTP/1.1 403 Forbidden');
    exit("HTTP connections disabled");
}
if (ini_get('allow_url_fopen')) {
$scheme  = strtolower($matches[1]);
$options = array(
    $scheme => array(
@@ -51,6 +47,27 @@
// php.net/manual/en/reserved.variables.httpresponseheader.php
$headers = implode("\n", (array)$http_response_header);
} else if (function_exists('curl_init')) {
    $curl = curl_init($realurl);
    curl_setopt($curl, CURLOPT_TIMEOUT, 15);
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 15);
    curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
    curl_setopt($curl, CURLOPT_ENCODING, '');
    curl_setopt($curl, CURLOPT_HEADER, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($curl);
    if ($data !== false) {
        list($headers, $source) = explode("\r\n\r\n", $data, 2);
    } else {
        $headers = false;
        $source = false;
    }
} else {
    header('HTTP/1.1 403 Forbidden');
    exit("HTTP connections disabled");
}
$ctype   = '~Content-Type:\s+text/(css|plain)~i';
if ($source !== false && preg_match($ctype, $headers)) {