function start()
{
    $sock = new sockets();
    $unix = new unix();
    if (!$GLOBALS["VERBOSE"]) {
        $pidtime = "/etc/artica-postfix/pids/exec.mimedefang.quarantine.php.start.time";
        if ($unix->file_time_min($pidtime) < 5) {
            return;
        }
        @unlink($pidtime);
        @file_put_contents($pidtime, time());
    }
    $postgres = new postgres_sql();
    $postgres->SMTP_TABLES();
    $storage_path = "/var/spool/MD-Quarantine";
    $unix = new unix();
    $pidpath = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = @file_get_contents($pidpath);
    if ($unix->process_exists($pid)) {
        system_admin_events("Already process {$pid} running.. Aborting", __FUNCTION__, __FILE__, __LINE__, "postfix");
        return;
    }
    @file_put_contents($pidpath, getmypid());
    $c = 0;
    $q = new postgres_sql();
    $q->SMTP_TABLES();
    if ($handle = opendir($storage_path)) {
        while (false !== ($file = readdir($handle))) {
            if ($file == "." && $file == "..") {
                continue;
            }
            if (substr($file, 0, 1) == '.') {
                continue;
            }
            if (!preg_match("#^qdir-#", $file)) {
                continue;
            }
            $path = "{$storage_path}/{$file}";
            if (!is_file("{$path}/ENTIRE_MESSAGE")) {
                continue;
            }
            import_quarantine($path);
        }
    }
    CleanDatabase();
}
function start()
{
    $storage_path = "/var/spool/MIMEDefang_replaced";
    $unix = new unix();
    $pidpath = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = @file_get_contents($pidpath);
    if ($unix->process_exists($pid)) {
        system_admin_events("Already process {$pid} running.. Aborting", __FUNCTION__, __FILE__, __LINE__, "postfix");
        return;
    }
    $q = new mysql_mimedefang_builder();
    if (!$q->TABLE_EXISTS("storage")) {
        $q->CheckTables();
    }
    if (!$q->TABLE_EXISTS("storage")) {
        system_admin_events("Fatal, `storage` table does not exists", __FUNCTION__, __FILE__, __LINE__, "postfix");
        return;
    }
    @file_put_contents($pidpath, getmypid());
    if ($handle = opendir("{$storage_path}")) {
        while (false !== ($file = readdir($handle))) {
            if ($file == "." && $file == "..") {
                if ($GLOBALS["VERBOSE"]) {
                    echo "skipped: `{$file}`\n";
                }
                continue;
            }
            if (substr($file, 0, 1) == '.') {
                if ($GLOBALS["VERBOSE"]) {
                    echo "skipped: `{$file}`\n";
                }
                continue;
            }
            $path = "{$storage_path}/{$file}";
            if (inject_extracted_attach($path)) {
                $c++;
            }
        }
    }
    CleanDatabase();
}