function MiltergreyList_scan($tablesource, $time)
{
    $q = new mysql_postfix_builder();
    if (date("Y-m-d h") == date("Y-m-d h", $time)) {
        return false;
    }
    $NextTable = "mgreyd_" . date("Ymd", $time);
    if ($GLOBALS["VERBOSE"]) {
        echo "Processing {$tablesource} -> {$NextTable}\n";
    }
    if (!$q->milter_BuildDayTable($NextTable)) {
        return false;
    }
    $database = $q->database;
    $prefix = "INSERT IGNORE INTO {$NextTable} \n\t(zmd5,hits,zhour,mailfrom,instancename,mailto,domainfrom,domainto,senderhost,`failed`) VALUES ";
    $sql = "SELECT COUNT(zmd5) as hits,zhour,mailfrom,instancename,mailto,domainfrom,domainto,senderhost,failed FROM {$tablesource} \n\tGROUP BY zhour,mailfrom,instancename,mailto,domainfrom,domainto,senderhost,failed";
    $results = $q->QUERY_SQL($sql, $database);
    $f = array();
    while ($ligne = mysql_fetch_assoc($results)) {
        $zmd5 = md5(serialize($ligne));
        $zhour = $ligne["zhour"];
        $hits = $ligne["hits"];
        $mailfrom = mysql_escape_string2($ligne["mailfrom"]);
        $instancename = mysql_escape_string2($ligne["instancename"]);
        $mailfrom = mysql_escape_string2($ligne["mailfrom"]);
        $mailto = mysql_escape_string2($ligne["mailto"]);
        $domainfrom = mysql_escape_string2($ligne["domainfrom"]);
        $domainto = mysql_escape_string2($ligne["domainto"]);
        $mailto = mysql_escape_string2($ligne["mailto"]);
        $senderhost = mysql_escape_string2($ligne["senderhost"]);
        $failed = $ligne["failed"];
        $f[] = "('{$zmd5}','{$hits}','{$zhour}','{$mailfrom}','{$instancename}','{$mailto}','{$domainfrom}','{$domainto}','{$senderhost}','{$failed}')";
        if (count($f) > 500) {
            if ($GLOBALS["VERBOSE"]) {
                echo $NextTable . " " . "500\n";
            }
            $q->QUERY_SQL($prefix . @implode(",", $f), $database);
            if (!$q->ok) {
                return false;
            }
            $f = array();
        }
    }
    if (count($f) > 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo $NextTable . " " . count($f) . "\n";
        }
        $q->QUERY_SQL($prefix . @implode(",", $f), $database);
        if (!$q->ok) {
            return false;
        }
        $f = array();
    }
    return true;
}