예제 #1
0
function metaevents_client2($uuid)
{
    $workingDir = "/usr/share/artica-postfix/ressources/conf/meta/hosts/uploaded/{$uuid}/CLIENT_META_EVENTS";
    if (!is_dir($workingDir)) {
        return;
    }
    $unix = new unix();
    if (!($handle = opendir($workingDir))) {
        meta_events("{$uuid}: {$workingDir} failed to parse");
        return;
    }
    $q = new mysql_meta();
    $hostname = $q->uuid_to_host($uuid);
    $q->create_table_meta_uuid_admin_mysql($uuid);
    $prefix = "INSERT IGNORE INTO `meta_admin_{$uuid}` (`zmd5`,`uuid`,`zDate`,`content`,`hostname`,`subject`,`function`,`filename`,`line` ,\t`severity` ,`sended`) VALUES ";
    while (false !== ($file = readdir($handle))) {
        if ($file == ".") {
            continue;
        }
        if ($file == "..") {
            continue;
        }
        $workingfile = "{$workingDir}/{$file}";
        if (is_dir($workingfile)) {
            continue;
        }
        $targetfile = "{$workingfile}.array";
        if (!$unix->uncompress($workingfile, $targetfile)) {
            @unlink($workingfile);
            @unlink($targetfile);
            continue;
        }
        $array = unserialize(base64_decode(@file_get_contents($targetfile)));
        @unlink($workingfile);
        @unlink($targetfile);
        if (!is_array($array)) {
            continue;
        }
        if (!is_numeric($array["TASKID"])) {
            $array["TASKID"] = 0;
        }
        $content = mysql_escape_string2($array["text"]);
        $subject = mysql_escape_string2($array["subject"]);
        $hostname = $zdate = $array["zdate"];
        $function = $array["function"];
        $file = $array["file"];
        $line = $array["line"];
        $TASKID = $array["TASKID"];
        $severity = $array["severity"];
        $md5 = md5(serialize($array));
        $f[] = "('{$md5}','{$uuid}','{$zdate}','{$content}','{$hostname}','{$subject}','{$function}','{$file}','{$line}','{$severity}',0)";
    }
    if (count($f) > 0) {
        $q->QUERY_SQL($prefix . @implode(",", $f));
        if (!$q->ok) {
            meta_admin_mysql(0, "MySQL error", "{$q->mysql_error}", __FILE__, __LINE__);
        }
    }
}