function GetTargetedSize($URI)
{
    $ExpectedSize = 0;
    $curl = new ccurl($URI);
    $curl->NoLocalProxy();
    $Headers = $curl->getHeaders();
    if (isset($Headers["Content-Length"])) {
        return $Headers["Content-Length"];
    }
    if ($ExpectedSize == 0) {
        if (isset($Headers["download_content_length"])) {
            return $Headers["download_content_length"];
        }
    }
    return 0;
}
Ejemplo n.º 2
0
function Getheaders()
{
    $curl = new ccurl("http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz");
    print_r($curl->getHeaders());
}
Ejemplo n.º 3
0
function ufdb_phistank()
{
    $unix = new unix();
    $sock = new sockets();
    $EnableSquidPhishTank = intval($sock->GET_INFO("EnableSquidPhishTank"));
    $PhishTankApiKey = $sock->GET_INFO("PhishTankApiKey");
    if ($EnableSquidPhishTank == 0) {
        updatev2_progress(80, "Phishtank {disabled}...");
        return;
    }
    if ($PhishTankApiKey == null) {
        updatev2_progress(80, "Phishtank {disabled}...");
        echo "Warning, API Key is not set, aborting...\n";
        return;
    }
    $path = "/home/artica/squid/phishtank/online-valid.php_serialized";
    $FinalPath = "/home/artica/squid/phishtank";
    $uri = "http://data.phishtank.com/data/{$PhishTankApiKey}/online-valid.php_serialized";
    $curl = new ccurl($uri);
    @mkdir(dirname($path), 0755, true);
    $heads = $curl->getHeaders();
    if (!isset($heads["http_code"])) {
        updatev2_progress(80, "Phishtank {failed}...");
        echo "phishtank: Unable to get header information\n";
        squid_admin_mysql(1, "phishtank: Unable to get header information", null, __FILE__, __LINE__);
        return;
    }
    $http_code = intval($heads["http_code"]);
    if ($http_code != 200) {
        updatev2_progress(80, "Phishtank {failed}...");
        echo "Unable to get header information error code {$http_code}\n";
        squid_admin_mysql(1, "phishtank: Unable to get header information error code {$http_code}", null, __FILE__, __LINE__);
        return;
    }
    $Time = $heads["Last-Modified"];
    $MyDate = $sock->GET_INFO("PhishTankLastDate");
    echo "Last date: {$Time}\n";
    if (!is_file($path)) {
        $MyDate = null;
    }
    if ($Time == $MyDate) {
        updatev2_progress(80, "Phishtank {no_update}...");
        echo "No new update...\n";
        return;
    }
    $tmpfile = $unix->FILE_TEMP();
    if (!$curl->GetFile($tmpfile)) {
        updatev2_progress(80, "Phishtank {failed}...");
        echo "Unable to download online-valid.php_serialized\n";
        squid_admin_mysql(1, "phishtank: Unable to download online-valid.php_serialized, {$curl->error}", null, __FILE__, __LINE__);
        @unlink($tmpfile);
        return;
    }
    @unlink($path);
    if (!@copy($tmpfile, $path)) {
        updatev2_progress(80, "Phishtank {failed}...");
        echo "Unable to copy online-valid.php_serialized\n";
        squid_admin_mysql(1, "phishtank: Unable to copy online-valid.php_serialized", null, __FILE__, __LINE__);
        @unlink($tmpfile);
        return;
    }
    @unlink($tmpfile);
    $size = @filesize($path);
    updatev2_progress(80, "Phishtank {compiling}...");
    squid_admin_mysql(2, "phishtank: Success to download new phishtank database (" . FormatBytes($size / 1024) . ")", null, __FILE__, __LINE__);
    $sock->SET_INFO("PhishTankLastDate", $Time);
    ufdb_phistank_createdb();
}
Ejemplo n.º 4
0
function GetTargetedSize($URI)
{
    $ExpectedSize = 0;
    $curl = new ccurl($URI);
    $curl->FollowLocation = true;
    $Headers = $curl->getHeaders();
    if (isset($Headers["Content-Length"])) {
        return $Headers["Content-Length"];
    }
    if ($ExpectedSize == 0) {
        if (isset($Headers["download_content_length"])) {
            return $Headers["download_content_length"];
        }
    }
    while (list($index, $value) = each($Headers)) {
        events("Failed {$index} {$value}", __LINE__);
    }
    return 0;
}