function Execute()
{
    build_progress("Executing", 5);
    if (!ifMustBeExecuted()) {
        if ($GLOBALS["VERBOSE"]) {
            echo "No make sense to execute this script...\n";
        }
        while (list($filename, $line) = each($GLOBALS["ifMustBeExecuted"])) {
            ufdbevents("ifMustBeExecuted:: {$line}");
        }
        build_progress("No make sense to execute this script", 110);
        die;
    }
    $timeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $StandardTime = 240;
    $sock = new sockets();
    $kill = $unix->find_program("kill");
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, __FILE__)) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($time > 240) {
            unix_system_kill_force($pid);
        }
    }
    if ($unix->process_exists($pid, __FILE__)) {
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $CategoriesDatabasesByCron = $sock->GET_INFO("CategoriesDatabaseByCron");
    if (!is_numeric($CategoriesDatabasesByCron)) {
        $CategoriesDatabasesByCron = 1;
    }
    if (!$GLOBALS["FORCE"]) {
        if ($CategoriesDatabasesByCron == 1) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Execute():: Only bycron, aborting...\n";
            }
            if (!$GLOBALS["BYCRON"]) {
                build_progress("Not executed by CRON.. Aborting", 110);
                return;
            }
        }
    }
    if (!$GLOBALS["FORCE"]) {
        if (!$GLOBALS["BYCRON"]) {
            $timeFile = $unix->file_time_min($timeFile);
            if ($timeFile < $StandardTime) {
                build_progress("{$timeFile}mn < {$StandardTime}Mn, aborting...use --force ", 110);
                if ($GLOBALS["VERBOSE"]) {
                    echo "Execute():: {$timeFile}mn < {$StandardTime}Mn, aborting...use --force to bypass\n";
                }
                return;
            }
        }
    }
    @unlink($timeFile);
    @file_put_contents($timeFile, time());
    $sock = new sockets();
    $EnableArticaMetaClient = intval($sock->GET_INFO("EnableArticaMetaClient"));
    if ($EnableArticaMetaClient == 1) {
        build_progress("Using Artica Meta server", 10);
        return artica_meta_client();
    }
    $BASE_URI = "ftp://ftp.univ-tlse1.fr/pub/reseau/cache/squidguard_contrib";
    $myFile = basename(__FILE__);
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $cachetime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$GLOBALS["SCHEDULE_ID"]}.time";
    $unix = new unix();
    $ufdbGenTable = $unix->find_program("ufdbGenTable");
    $kill = $unix->find_program("kill");
    $pid = @file_get_contents($pidfile);
    $getmypid = $GLOBALS["MYPID"];
    if (!$GLOBALS["FORCE"]) {
        if ($unix->process_exists($pid, $myFile)) {
            $timePid = $unix->PROCCESS_TIME_MIN($pid);
            if ($timePid < 60) {
                build_progress("Already running PID {$pid}", 110);
                die;
            } else {
                unix_system_kill_force($pid);
            }
        }
    }
    @file_put_contents($pidfile, $getmypid);
    if ($GLOBALS["VERBOSE"]) {
        echo "Executed pid {$getmypid}\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "ufdbGenTable:{$ufdbGenTable}\n";
    }
    $sock = new sockets();
    $SquidDatabasesUtlseEnable = $sock->GET_INFO("SquidDatabasesUtlseEnable");
    if (!is_numeric($SquidDatabasesUtlseEnable)) {
        $SquidDatabasesUtlseEnable = 1;
    }
    if ($SquidDatabasesUtlseEnable == 0) {
        build_progress("{database_disabled}", 110);
        update_progress(100, "{database_disabled}");
        echo "Toulouse university is disabled\n";
        artica_update_event(2, "Toulouse university is disabled, aborting", null, __FILE__, __LINE__);
    }
    if (!$GLOBALS["FORCE"]) {
        $time = $unix->file_time_min($cachetime);
        if ($time < 120) {
            $q = new mysql_squid_builder();
            if ($q->COUNT_ROWS("univtlse1fr") == 0) {
                BuildDatabaseStatus();
            }
            ufdbevents("{$cachetime}: {$time}Mn need 120Mn");
            echo "{$cachetime}: {$time}Mn need 120Mn\n";
            die;
        }
    }
    @unlink($cachetime);
    @file_put_contents($cachetime, time());
    $q = new mysql_squid_builder();
    $results = $q->QUERY_SQL("SELECT * FROM ftpunivtlse1fr");
    if (!$q->ok) {
        if (strpos($q->mysql_error, "doesn't exist") > 0) {
            $q->CheckTables();
            $results = $q->QUERY_SQL("SELECT * FROM ftpunivtlse1fr");
        }
    }
    if (!$q->ok) {
        ufdbevents("Fatal: {$q->mysql_error}");
        ufdbguard_admin_events("Fatal: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "Toulouse DB");
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $ARRAYSUM_LOCALE[$ligne["filename"]] = $ligne["zmd5"];
    }
    $STATUS = unserialize(@file_get_contents("/etc/artica-postfix/TLSE_LAST_DOWNLOAD"));
    $STATUS["LAST_CHECK"] = time();
    @file_put_contents("/etc/artica-postfix/TLSE_LAST_DOWNLOAD", serialize($STATUS));
    if (!isset($GLOBALS["UFDB_COUNT_OF_DOWNLOADED"])) {
        $GLOBALS["UFDB_COUNT_OF_DOWNLOADED"] = 0;
    }
    build_progress("Check MD5", 10);
    $ARRAYSUM_REMOTE = GET_MD5S_REMOTE();
    $TOT = count($ARRAYSUM_REMOTE);
    $c = 0;
    $start = 15;
    while (list($filename, $md5) = each($ARRAYSUM_REMOTE)) {
        $c++;
        $prc = round($c / $TOT * 100);
        update_progress($c, $filename);
        if (!isset($ARRAYSUM_LOCALE[$filename])) {
            $ARRAYSUM_LOCALE[$filename] = null;
        }
        if ($ARRAYSUM_LOCALE[$filename] != $md5) {
            $size = FormatBytes($GLOBALS["UFDB_SIZE"] / 1024);
            if ($prc < 15) {
                build_progress("Downloading {$filename} ({$size})", 15);
                $prclog = 15;
            }
            if ($prc > 15) {
                if ($prc < 80) {
                    build_progress("Downloading {$filename} ({$size})", $prc);
                    $prclog = $prc;
                }
                if ($prc > 79) {
                    build_progress("Downloading {$filename} ({$size})", 79);
                    $prclog = 79;
                }
            }
            update_remote_file($BASE_URI, $filename, $md5, $prclog);
        }
    }
    if (count($GLOBALS["squid_admin_mysql"])) {
        $UFDB_SIZE = FormatBytes($GLOBALS["UFDB_SIZE"] / 1024);
        build_progress(count($GLOBALS["squid_admin_mysql"]) . " downloaded items - {$UFDB_SIZE}", 80);
        artica_update_event(2, count($GLOBALS["squid_admin_mysql"]) . " downloaded items - {$UFDB_SIZE} - Webfiltering Toulouse Databases updated", @implode("\n", $GLOBALS["squid_admin_mysql"]), __FILE__, __LINE__);
        unset($GLOBALS["squid_admin_mysql"]);
    }
    build_progress("{done}", 85);
    update_progress(100, "{done}");
    build_progress("CoherenceOffiels()", 85);
    CoherenceOffiels();
    build_progress("CoherenceRepertoiresUfdb()", 90);
    CoherenceRepertoiresUfdb();
    build_progress("BuildDatabaseStatus()", 95);
    BuildDatabaseStatus();
    build_progress("remove_bad_files()", 98);
    remove_bad_files();
    build_progress("{finish}", 100);
    if ($GLOBALS["UFDB_COUNT_OF_DOWNLOADED"] > 0) {
        artica_meta_server(true);
    } else {
        artica_meta_server();
    }
    $php5 = $unix->LOCATE_PHP5_BIN();
    $ufdbConvertDB = $unix->find_program("ufdbConvertDB");
    if (is_file($ufdbConvertDB)) {
        shell_exec("{$ufdbConvertDB} /var/lib/ftpunivtlse1fr");
    }
    if (is_dir("/var/lib/ftpunivtlse1fr")) {
        $chown = $unix->find_program("chown");
        shell_exec("{$chown} squid:squid /var/lib/ftpunivtlse1fr");
        shell_exec("{$chown} -R squid:squid /var/lib/ftpunivtlse1fr/");
    }
    $unix->THREAD_COMMAND_SET("{$php5} /usr/share/artica-postfix/exec.squidguard.php --disks");
}
function minecraft_restart_single($serverPort)
{
    // allow 10 seconds time
    set_time_limit(30);
    update_progress("10%");
    sleep(1);
    update_progress("15%");
    sleep(1);
    // Kill the cmd.exe processes
    //runCommand("start \"MineField\" cmd /C Call kill_${serverPort}.bat > NUL", "Shutting down server on ${serverPort}");
    runCommand('tasklist /A /V /S CIRCE /U CIRCE\\Mike /FI "IMAGENAME eq cmd*"');
    runCommand('tasklist /A /V /S CIRCE /U CIRCE\\Mike /FI "IMAGENAME eq java*"');
    //runCommand('tasklist /V /S CIRCE /U CIRCE\Mike /FI "WINDOWTITLE eq Minecraft*"');
    update_progress("30%");
    sleep(1);
    update_progress("50%");
    sleep(1);
    update_progress("60%");
    //runCommand("start \"MineCraft\" cmd /C Call start_${serverPort}.bat > NUL", "Starting server on ${serverPort}");
    update_progress("100%");
    flush_buffers();
}