function MultiplesInstancesFound($pid = false, $onlystart = false) { $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid"; $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time"; $unix = new unix(); if (!$GLOBALS["FORCE"]) { if ($pid) { if ($unix->file_time_min($pidtime) < 2) { if ($GLOBALS["VERBOSE"]) { echo "Minimal 2mn\n"; } return; } $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $processtime = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["VERBOSE"]) { echo "Already running pid {$pid}\n"; } if ($processtime < 5) { return; } $kill = $unix->find_program("kill"); unix_system_kill_force($pid); } } } if (!$GLOBALS["FORCE"]) { @unlink($pidtime); @file_put_contents($pidtime, time()); @file_put_contents($pidfile, getmypid()); } $sock = new sockets(); $uuid = base64_decode($sock->getFrameWork("cmd.php?system-unique-id=yes")); $sql = "SELECT ValueTEXT,ip_address,ou FROM postfix_multi WHERE `key`='PluginsEnabled' AND uuid='{$uuid}'"; if ($GLOBALS["DEBUG"]) { echo "{$sql}\n"; } $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo __FUNCTION__ . " {$q->mysql_error}\n"; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $array_filters = unserialize(base64_decode($ligne["ValueTEXT"])); if (!isset($array_filters["APP_MILTERGREYLIST"])) { $array_filters["APP_MILTERGREYLIST"] = null; } if ($GLOBALS["DEBUG"]) { echo "{$ligne["ip_address"]} APP_MILTERGREYLIST -> `{$array_filters["APP_MILTERGREYLIST"]}` \n"; } if ($array_filters["APP_MILTERGREYLIST"] == null) { continue; } if ($array_filters["APP_MILTERGREYLIST"] == 0) { continue; } $hostname = MultiplesInstancesGetmyhostname($ligne["ip_address"]); $ou = $ligne["ou"]; if ($GLOBALS["DEBUG"]) { echo "{$hostname} -> {$ou}\n"; } $GLOBALS["hostnames"][$hostname] = $ou; if ($onlystart) { MultiplesInstances_start($hostname, $ou); continue; } MultiplesInstances($hostname, $ou); } }
function MultiplesInstancesFound() { $sock = new sockets(); $uuid = base64_decode($sock->getFrameWork("cmd.php?system-unique-id=yes")); $sql = "SELECT ValueTEXT,ip_address,ou FROM postfix_multi WHERE `key`='PluginsEnabled' AND uuid='{$uuid}'"; if ($GLOBALS["DEBUG"]) { echo "{$sql}\n"; } $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo __FUNCTION__ . " {$q->mysql_error}\n"; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $array_filters = unserialize(base64_decode($ligne["ValueTEXT"])); if ($GLOBALS["DEBUG"]) { echo "{$ligne["ip_address"]} APP_MILTERGREYLIST ->{$array_filters["APP_MILTERGREYLIST"]} \n"; } if ($array_filters["APP_MILTERGREYLIST"] == null) { continue; } if ($array_filters["APP_MILTERGREYLIST"] == 0) { continue; } $hostname = MultiplesInstancesGetmyhostname($ligne["ip_address"]); $ou = $ligne["ou"]; if ($GLOBALS["DEBUG"]) { echo "{$hostname} -> {$ou}\n"; } $GLOBALS["hostnames"][$hostname] = $ou; MultiplesInstances($hostname, $ou); } }