Esempio n. 1
0
<?php

## check url
$request_parameters = array('timeout' => 10, 'allowRedirects' => 1, 'method' => 'HEAD');
if (empty($_GET['url'])) {
    return;
}
$url = expandURL($_GET['url']);
$isOk = true;
$code = -1;
if ($GLOBALS['can_fetchUrl']) {
    $code = testUrl($url);
    if ($code != 200) {
        if (!empty($url_append)) {
            $status = $GLOBALS['I18N']->get('Error fetching URL') . ' ' . $GLOBALS['I18N']->get('Check your "remoteurl_append" setting.');
        } else {
            $status = $GLOBALS['I18N']->get('Error fetching URL');
        }
        $isOk = false;
    }
} else {
    $status = $GLOBALS['I18N']->get('Error fetching URL');
    $isOk = false;
}
if ($isOk) {
    $status = '<span class="pass">' . s('URL is valid') . '</span>';
} else {
    $status = '<span class="fail">' . $status . '. ' . s('Please verify that the URL entered is correct.') . '</span>';
}
        // Execute
        curl_exec($ch);
        // Check if any error occurred
        $error = curl_errno($ch);
        $info = curl_getinfo($ch);
        $hc = $info["http_code"];
        // Close handle
        curl_close($ch);
        if (!$error) {
            if (isset($header[$level]["location"])) {
                $url = $header[$level]["location"];
            }
            $level += 1;
            echo "INFO\n";
            print_r($info);
            echo "HEADER\n";
            print_r($header);
            echo "HTTP-CODE: " . $hc . "  " . gettype($hc) . "\n";
        } else {
            echo "Error: {$error}\n";
            break;
        }
    } while ($hc == 301 or $hc == 302);
    return $url;
}
$expandedURL = expandURL($argv[1]);
echo "URL " . $argv[1] . " ---> " . $expandedURL . "\n";
$parsed = parse_url($expandedURL);
$hostpath = implode("/", array_reverse(explode(".", $parsed["host"])));
$parsed["hostpath"] = $hostpath;
print_r($parsed);