function fetch_blacklist($log_notice = true, $install_process = false)
{
    global $config, $g;
    if (is_array($config['installedpackages']['dansguardianblacklist']) && is_array($config['installedpackages']['dansguardianblacklist']['config'])) {
        $url = $config['installedpackages']['dansguardianblacklist']['config'][0]['url'];
        $uw = "Found a previouns install, checking Blacklist config...";
    } else {
        $uw = "Found a clean install, reading default access lists...";
    }
    conf_mount_rw();
    if ($install_process == true) {
        update_output_window($uw);
    }
    if (isset($url) && is_url($url)) {
        if ($log_notice == true) {
            print "file download start..";
            unlink_if_exists("/usr/local/pkg/blacklist.tgz");
            exec("/usr/bin/fetch -o /usr/local/pkg/blacklist.tgz " . escapeshellarg($url), $output, $return);
        } else {
            #install process
            if (file_exists("/usr/local/pkg/blacklist.tgz")) {
                update_output_window("Found previous blacklist database, skipping download...");
                $return = 0;
            } else {
                update_output_window("Fetching blacklist");
                download_file_with_progress_bar($url, "/usr/local/pkg/blacklist.tgz");
                if (file_exists("/usr/local/pkg/blacklist.tgz")) {
                    $return = 0;
                }
            }
        }
        if ($return == 0) {
            chdir(DANSGUARDIAN_DIR . "/etc/dansguardian/lists");
            if (is_dir("blacklists.old")) {
                exec('rm -rf ' . DANSGUARDIAN_DIR . '/etc/dansguardian/lists/blacklists.old');
            }
            rename("blacklists", "blacklists.old");
            exec('/usr/bin/tar -xvzf /usr/local/pkg/blacklist.tgz 2>&1', $output, $return);
            if (preg_match("/x\\W+(\\w+)/", $output[1], $matches)) {
                if ($matches[1] != "blacklists") {
                    rename("./" . $matches[1], "blacklists");
                }
                read_lists($log_notice);
            } else {
                file_notice("Dansguardian - Could not determine Blacklist extract dir. Categories not updated", "");
            }
        } else {
            file_notice("Dansguardian - Could not fetch blacklists from url", "");
        }
    } else {
        if ($install_process == true) {
            read_lists(false, $uw);
        } elseif (!empty($url)) {
            file_notice("Dansguardian - Blacklist url is invalid.", "");
        }
    }
}
            download_file_with_progress_bar("http://www.emergingthreats.net/rules/emerging.rules.tar.gz", $tmpfname . "/{$emergingthreats_filename}", "read_body_firmware");
            update_all_status($static_output);
            update_status(gettext("Done downloading Emergingthreats rules file."));
        }
    }
}
/* download pfsense rules file */
if ($pfsense_md5_check_ok != on) {
    if (file_exists("{$tmpfname}/{$pfsense_rules_filename}")) {
        update_status(gettext("Snortrule tar file exists..."));
    } else {
        unhide_progress_bar_status();
        update_status(gettext("There is a new set of Pfsense rules posted. Downloading..."));
        update_output_window(gettext("May take 4 to 10 min..."));
        //    download_file_with_progress_bar("http://www.mtest.local/pub-bin/oinkmaster.cgi/{$oinkid}/pfsense_rules.tar.gz", $tmpfname . "/{$pfsense_rules_filename}", "read_body_firmware");
        download_file_with_progress_bar("http://www.pfsense.com/packages/config/snort/pfsense_rules/pfsense_rules.tar.gz", $tmpfname . "/{$pfsense_rules_filename}", "read_body_firmware");
        update_all_status($static_output);
        update_status(gettext("Done downloading rules file."));
    }
}
/* Compair md5 sig to file sig */
//$premium_url_chk = $config['installedpackages']['snort']['config'][0]['subscriber'];
//if ($premium_url_chk == on) {
//$md5 = file_get_contents("{$tmpfname}/{$snort_filename_md5}");
//$file_md5_ondisk = `/sbin/md5 {$tmpfname}/{$snort_filename} | /usr/bin/awk '{ print $4 }'`;
// if ($md5 == $file_md5_ondisk) {
//    update_status(gettext("Valid md5 checksum pass..."));
//} else {
//    update_status(gettext("The downloaded file does not match the md5 file...P is ON"));
//    update_output_window(gettext("Error md5 Mismatch..."));
//    exit(0);
    $latest_version_pfsense = strtotime($latest_version);
    if (!$latest_version) {
        update_output_window(gettext("Unable to check for updates."));
        require "fend.inc";
        exit;
    } else {
        if (pfs_version_compare($current_installed_buildtime, $g['product_version'], $latest_version) == -1) {
            update_status(gettext("Downloading updates") . "...");
            conf_mount_rw();
            if ($g['platform'] == "nanobsd") {
                $update_filename = "latest{$nanosize}.img.gz";
            } else {
                $update_filename = "latest.tgz";
            }
            $status = download_file_with_progress_bar("{$updater_url}/{$update_filename}", "{$g['upload_path']}/latest.tgz", "read_body_firmware");
            $status = download_file_with_progress_bar("{$updater_url}/{$update_filename}.sha256", "{$g['upload_path']}/latest.tgz.sha256");
            conf_mount_ro();
            update_output_window("{$g['product_name']} " . gettext("download complete."));
        } else {
            update_output_window(gettext("You are on the latest version."));
            require "fend.inc";
            exit;
        }
    }
}
/* launch external upgrade helper */
$external_upgrade_helper_text = "/etc/rc.firmware ";
if ($g['platform'] == "nanobsd") {
    $external_upgrade_helper_text .= "pfSenseNanoBSDupgrade ";
} else {
    $external_upgrade_helper_text .= "pfSenseupgrade ";
    $updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
} else {
    $updater_url = $g['update_url'];
}
$needs_system_upgrade = false;
$static_text .= gettext("Downloading new version information...");
$nanosize = "";
if ($g['platform'] == "nanobsd") {
    if (!isset($g['enableserial_force'])) {
        $nanosize = "-nanobsd-vga-";
    } else {
        $nanosize = "-nanobsd-";
    }
    $nanosize .= strtolower(trim(file_get_contents("/etc/nanosize.txt")));
}
if (download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 'read_body', 5, 5) === true) {
    $remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version"));
}
$static_text .= gettext("done") . "\\n";
if (!$remote_version) {
    $static_text .= gettext("Unable to check for updates.") . "\\n";
    if (isset($curcfg['alturl']['enable'])) {
        $static_text .= gettext("Could not contact custom update server.") . "\\n";
    } else {
        $static_text .= sprintf(gettext('Could not contact %1$s update server %2$s%3$s'), $g['product_name'], $updater_url, "\\n");
    }
} else {
    $static_text .= gettext("Obtaining current version information...");
    panel_text($static_text);
    $current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime"));
    $static_text .= "done<br />";
    if (file_exists("{$snortdir}/{$emergingthreats_filename_md5}")) {
        /* Check if were up to date emergingthreats.net */
        $emerg_md5_check_new = file_get_contents("{$tmpfname}/{$emergingthreats_filename_md5}");
        $emerg_md5_check_old = file_get_contents("{$snortdir}/{$emergingthreats_filename_md5}");
        if ($emerg_md5_check_new == $emerg_md5_check_old) {
            update_status(gettext("Emerging threat rules are up to date..."));
            log_error("Emerging threat rules are up to date...");
            $emergingthreats = 'off';
        }
    }
}
/* download emergingthreats rules file */
if ($emergingthreats == "on") {
    update_status(gettext("There is a new set of Emergingthreats rules posted. Downloading..."));
    log_error("There is a new set of Emergingthreats rules posted. Downloading...");
    download_file_with_progress_bar("http://rules.emergingthreats.net/open/snort-{$emerging_threats_version}/emerging.rules.tar.gz", "{$tmpfname}/{$emergingthreats_filename}");
    update_status(gettext('Done downloading Emergingthreats rules file.'));
    log_error("Emergingthreats rules file update downloaded succsesfully");
}
/* XXX: need to be verified */
/* Compair md5 sig to file sig */
//$premium_url_chk = $config['installedpackages']['snort']['config'][0]['subscriber'];
//if ($premium_url_chk == on) {
//$md5 = file_get_contents("{$tmpfname}/{$snort_filename_md5}");
//$file_md5_ondisk = `/sbin/md5 {$tmpfname}/{$snort_filename} | /usr/bin/awk '{ print $4 }'`;
// if ($md5 == $file_md5_ondisk) {
//    update_status(gettext("Valid md5 checksum pass..."));
//} else {
//    update_status(gettext("The downloaded file does not match the md5 file...P is ON"));
//    update_output_window(gettext("Error md5 Mismatch..."));
//    return;
<p>

<?php 
/* Define necessary variables. */
$firmware_version = trim(file_get_contents('/etc/version'));
$static_text = "Downloading current version information... ";
update_output_window($static_text);
$static_text .= "done.\n";
update_output_window($static_text);
if (isset($curcfg['alturl']['enable'])) {
    $updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
} else {
    $updater_url = $g['update_url'];
}
update_status("Downloading current version information...");
$latest_version = download_file_with_progress_bar("{$updater_url}/version", "/tmp/{$g['product_name']}_version");
if (strstr($latest_version, "404")) {
    update_output_window("Could not download version information file {$updater_url}/version");
    include "fend.inc";
    exit;
}
$current_installed_pfsense_version = str_replace("\n", "", file_get_contents("/etc/version"));
$latest_version = str_replace("\n", "", file_get_contents("/tmp/{$g['product_name']}_version"));
$needs_system_upgrade = false;
if ($current_installed_pfsense_version != $latest_version) {
    $needs_system_upgrade = true;
}
if (!$latest_version) {
    if (isset($curcfg['alturl']['enable'])) {
        update_output_window("Could not contact custom update server.");
    } else {