} if (isset($_GET["postfix-certificate"])) { postfix_certificate(); exit; } if (isset($_GET["certificate-viewinfos"])) { certificate_infos(); exit; } if (isset($_GET["postfix-perso-settings"])) { postfix_perso_settings(); exit; } //postmulti if (isset($_GET["postfix-multi-status"])) { postfix_multi_status(); exit; } if (isset($_GET["postfix-multi-reconfigure"])) { postfix_multi_reconfigure(); exit; } if (isset($_GET["postfix-multi-relayhost"])) { postfix_multi_relayhost(); exit; } if (isset($_GET["postfix-multi-sasl"])) { postfix_multi_ssl(); exit; } if (isset($_GET["postfix-multi-settings"])) {
function postfix() { $bin_path = $GLOBALS["CLASS_UNIX"]->find_program("postconf"); if ($bin_path == null) { return null; } if (is_file("/etc/artica-postfix/DO_NOT_DETECT_POSTFIX")) { return; } $EnablePostfixMultiInstance = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnablePostfixMultiInstance"); $EnableStopPostfix = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableStopPostfix"); if ($GLOBALS["VERBOSE"]) { echo "EnablePostfixMultiInstance=\"{$EnablePostfixMultiInstance}\"\n"; } if (!is_numeric($EnableStopPostfix)) { $EnableStopPostfix = 0; } if (!is_numeric($EnablePostfixMultiInstance)) { $EnablePostfixMultiInstance = 0; } $DisableMessaging = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("DisableMessaging")); if ($DisableMessaging == 1) { $EnableStopPostfix = 1; $EnablePostfixMultiInstance = 0; } if ($EnablePostfixMultiInstance == 1) { $l[] = postfix_multi_status(); } if ($EnableStopPostfix == 1) { events("watchdog-postfix:{$EnableStopPostfix} is enabled, stopping postfix", __FUNCTION__, __LINE__); $cmd = "{$GLOBALS["nohup"]} /etc/init.d/postfix stop >/dev/null 2>&1 &"; events("watchdog-postfix:{$EnableStopPostfix} is enabled, stopping postfix -> {$cmd}", __FUNCTION__, __LINE__); shell_exec2($cmd); } if ($EnableStopPostfix == 0) { $sendmail_pid_path = $GLOBALS["CLASS_UNIX"]->LOCATE_SENDMAIL_PID_PATH(); if (strlen($sendmail_pid_path) > 3) { $sendmail_pid = file_get_contents($sendmail_pid_path); if (is_numeric($sendmail_pid)) { events("watchdog-postfix:Sendmail pid detected {$sendmail_pid_path} ({$sendmail_pid})", __FUNCTION__, __LINE__); if ($GLOBALS["CLASS_UNIX"]->process_exists($sendmail_pid)) { $kill = $GLOBALS["CLASS_UNIX"]->find_program("kill"); $postfix = $GLOBALS["CLASS_UNIX"]->find_program("postfix"); $GLOBALS["CLASS_UNIX"]->KILL_PROCESS($sendmail_pid, 9); @unlink($sendmail_pid); $GLOBALS["CLASS_UNIX"]->send_email_events("SendMail (pid {$sendmail_pid}) is running, kill it !!", "This action has been performed to avoid ports conflicts", "smtp"); shell_exec2("{$postfix} start >/dev/null 2>&1 &"); } } } } $postfix_path = $GLOBALS["CLASS_UNIX"]->find_program("postfix"); $master_pid = $GLOBALS["CLASS_UNIX"]->POSTFIX_PID(); if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) { exec("{$postfix_path} status 2>&1", $status_results); while (list($num, $line) = each($status_results)) { if (preg_match("#PID:.+?([0-9]+)#", $line, $re)) { $GLOBALS["DEBUG_LOGS"][] = "postfix status: {$line}"; $master_pid = $re[1]; } } } if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) { $master_bin_path = $GLOBALS["CLASS_UNIX"]->POSTFIX_MASTER_BIN_PATH(); $master_pid = $GLOBALS["CLASS_UNIX"]->PIDOF($master_bin_path, true); events("watchdog-postfix:PIDOF({$master_bin_path},true) -> {$master_pid}", __FUNCTION__, __LINE__); } $l[] = "[POSTFIX]"; $l[] = "service_name=APP_POSTFIX"; $l[] = "master_version=" . postfix_version(); $l[] = "service_cmd=/etc/init.d/postfix"; $l[] = "service_disabled=1"; $l[] = "remove_cmd=--postfix-remove"; $l[] = "family=postfix"; $l[] = "watchdog_features=1"; if ($GLOBALS["ArticaWatchDogList"]["APP_POSTFIX"] == null) { $GLOBALS["ArticaWatchDogList"]["APP_POSTFIX"] = 1; } if ($EnableStopPostfix == 0) { if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) { if (!$GLOBALS["DISABLE_WATCHDOG"]) { $GLOBALS["DEBUG_LOGS"][] = "{$master_pid} does not exists"; if ($GLOBALS["ArticaWatchDogList"]["APP_POSTFIX"] == 1) { $postfix_path = $GLOBALS["CLASS_UNIX"]->find_program("postfix"); $GLOBALS["DEBUG_LOGS"][] = "Postfix bin = {$postfix_path}"; exec("{$postfix_path} start -v 2>&1", $pstfix_start); $GLOBALS["CLASS_UNIX"]->send_email_events("APP_POSTFIX stopped (watchdog)", "Artica will try to start it\n" . @implode("\n", $pstfix_start) . "\n" . @implode("\n", $GLOBALS["DEBUG_LOGS"]), "postfix"); unset($GLOBALS["DEBUG_LOGS"]); } } $l[] = ""; return implode("\n", $l); return; } } $l[] = GetMemoriesOf($master_pid); $l[] = ""; $cmd = "{$GLOBALS["nohup"]} {$GLOBALS["NICE"]}{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.postfix.iptables.php --export-drop >/dev/null 2>&1 &"; shell_exec2($cmd); $cmd = "{$GLOBALS["nohup"]} {$GLOBALS["NICE"]}{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.smtp-senderadv.php >/dev/null 2>&1 &"; shell_exec2($cmd); $cmd = "{$GLOBALS["nohup"]} {$GLOBALS["NICE"]}{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.postqueue.watchdog.php >/dev/null 2>&1 &"; shell_exec2($cmd); $timefile = "/etc/artica-postfix/pids/postqueue.clean.time"; $exTime = $GLOBALS["CLASS_UNIX"]->file_time_min($timefile); if ($exTime > 5) { $cmd = "{$GLOBALS["nohup"]} {$GLOBALS["NICE"]}{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.postfix-logger.php --postqueue-clean >/dev/null 2>&1 &"; shell_exec2($cmd); } $timefile = "/etc/artica-postfix/pids/postqueue.cnx-errors.time"; $exTime = $GLOBALS["CLASS_UNIX"]->file_time_min($timefile); if ($exTime > 7) { $cmd = "{$GLOBALS["nohup"]} {$GLOBALS["NICE"]}{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.postfix-logger.php --cnx-errors >/dev/null 2>&1 &"; shell_exec2($cmd); } $timefile = "/etc/artica-postfix/pids/postqueue.cnx-only.time"; $exTime = $GLOBALS["CLASS_UNIX"]->file_time_min($timefile); if ($exTime > 8) { $cmd = "{$GLOBALS["nohup"]} {$GLOBALS["NICE"]}{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.postfix-logger.php --cnx-only >/dev/null 2>&1 &"; shell_exec2($cmd); } $timefile = "/etc/artica-postfix/pids/exec.postfix.stats.hours.php.time"; $exTime = $GLOBALS["CLASS_UNIX"]->file_time_min($timefile); if ($exTime > 60) { $cmd = "{$GLOBALS["nohup"]} {$GLOBALS["NICE"]}{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.postfix.stats.hours.php >/dev/null 2>&1 &"; shell_exec2($cmd); } return implode("\n", $l); return; }
function postfix(){ $bin_path=$GLOBALS["CLASS_UNIX"]->find_program("postconf"); if($bin_path==null){return null;} $EnablePostfixMultiInstance=$GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnablePostfixMultiInstance"); if($GLOBALS["VERBOSE"]){echo "EnablePostfixMultiInstance=\"$EnablePostfixMultiInstance\"\n";} if($EnablePostfixMultiInstance==1){ $l[]=postfix_multi_status(); } $sendmail_pid_path=$GLOBALS["CLASS_UNIX"]->LOCATE_SENDMAIL_PID_PATH(); if(strlen($sendmail_pid_path)>3){ $sendmail_pid=file_get_contents($sendmail_pid_path); if(is_numeric($sendmail_pid)){ events("Sendmail pid detected $sendmail_pid_path ($sendmail_pid)",__FUNCTION__,__LINE__); if($GLOBALS["CLASS_UNIX"]->process_exists($sendmail_pid)){ $kill=$GLOBALS["CLASS_UNIX"]->find_program("kill"); $postfix=$GLOBALS["CLASS_UNIX"]->find_program("postfix"); shell_exec("$kill -9 $sendmail_pid >/dev/null 2>&1"); @unlink($sendmail_pid); $GLOBALS["CLASS_UNIX"]->send_email_events("SendMail (pid $sendmail_pid) is running, kill it !!","This action has been performed to avoid ports conflicts","smtp"); shell_exec("$postfix start >/dev/null 2>&1 &"); } } } $postfix_path=$GLOBALS["CLASS_UNIX"]->find_program("postfix"); $master_pid=$GLOBALS["CLASS_UNIX"]->POSTFIX_PID(); if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){ exec("$postfix_path status 2>&1",$status_results); while (list ($num, $line) = each ($status_results) ){ if(preg_match("#PID:.+?([0-9]+)#", $line)){ $GLOBALS["DEBUG_LOGS"][]="postfix status: $line"; $master_pid=$re[1]; } } } if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){ $master_bin_path=$GLOBALS["CLASS_UNIX"]->POSTFIX_MASTER_BIN_PATH(); $master_pid=$GLOBALS["CLASS_UNIX"]->PIDOF($master_bin_path,true); } $l[]="[POSTFIX]"; $l[]="service_name=APP_POSTFIX"; $l[]="master_version=".GetVersionOf("postfix"); $l[]="service_cmd=postfix-single"; $l[]="service_disabled=1"; $l[]="remove_cmd=--postfix-remove"; $l[]="family=postfix"; $l[]="watchdog_features=1"; if($GLOBALS["ArticaWatchDogList"]["APP_POSTFIX"]==null){$GLOBALS["ArticaWatchDogList"]["APP_POSTFIX"]=1;} if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){ $GLOBALS["DEBUG_LOGS"][]="$master_pid does not exists"; if($GLOBALS["ArticaWatchDogList"]["APP_POSTFIX"]==1){ $postfix_path=$GLOBALS["CLASS_UNIX"]->find_program("postfix"); $GLOBALS["DEBUG_LOGS"][]="Postfix bin = $postfix_path"; exec("$postfix_path start -v 2>&1",$pstfix_start); $GLOBALS["CLASS_UNIX"]->send_email_events("APP_POSTFIX stopped (watchdog)", "Artica will try to start it\n".@implode("\n",$pstfix_start)."\n".@implode("\n", $GLOBALS["DEBUG_LOGS"]),"postfix"); unset($GLOBALS["DEBUG_LOGS"]); } $l[]="";return implode("\n",$l);return; } $l[]=GetMemoriesOf($master_pid); $l[]=""; unset($GLOBALS["DEBUG_LOGS"]); return implode("\n",$l);return; }
if(isset($_GET["maillog-query"])){maillog_query();exit;} if(isset($_GET["postfix-whitelisted-global"])){postfix_whitelisted_global();exit;} if(isset($_GET["postfinder"])){postfinder();exit;} //cluebringer if(isset($_GET["cluebringer-restart"])){cluebringer_restart();exit;} if(isset($_GET["cluebringer-ini-status"])){cluebringer_status();exit;} if(isset($_GET["cluebringer-passwords"])){cluebringer_passwords();exit;} //postmulti if(isset($_GET["postfix-multi-status"])){postfix_multi_status();exit;} if(isset($_GET["postfix-multi-reconfigure"])){postfix_multi_reconfigure();exit;} if(isset($_GET["postfix-multi-relayhost"])){postfix_multi_relayhost();exit;} if(isset($_GET["postfix-multi-sasl"])){postfix_multi_ssl();exit;} if(isset($_GET["postfix-multi-settings"])){postfix_multi_settings();exit;} if(isset($_GET["postfix-multi-mastercf"])){postfix_multi_mastercf();exit;} if(isset($_GET["postfix-multi-aiguilleuse"])){postfix_multi_aiguilleuse();exit;} if(isset($_GET["postfix-multi-perform-reload"])){postfix_multi_perform_reload();exit;} if(isset($_GET["postfix-multi-perform-restart"])){postfix_multi_perform_restart();exit;} if(isset($_GET["postfix-multi-perform-flush"])){postfix_multi_perform_flush();exit;} if(isset($_GET["postfix-multi-reconfigure-all"])){postfix_multi_reconfigure_all();exit;} if(isset($_GET["postfix-multi-perform-reconfigure"])){postfix_multi_perform_reconfigure();exit;} if(isset($_GET["restart-postfix-single"])){postfix_restart_single();exit;}