Exemplo n.º 1
0
function fetchmail(){
	
	
	
	if(!$GLOBALS["CLASS_USERS"]->fetchmail_installed){return null;}
	$EnablePostfixMultiInstance=$GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnablePostfixMultiInstance");
	$enabled=$GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableFetchmail");
	if($enabled==null){$enabled=0;}
	
	
	
	if($EnablePostfixMultiInstance<>1){
		if(!is_file("/etc/fetchmailrc")){$enabled=0;}
		$master_pid=trim(@file_get_contents("/var/run/fetchmail.pid"));
		if(preg_match("#^([0-9]+)#",$master_pid,$re)){$master_pid=$re[1];}
		$l[]="[FETCHMAIL]";
		$l[]="service_name=APP_FETCHMAIL";
	 	$l[]="master_version=".GetVersionOf("fetchmail");
	 	$l[]="service_cmd=fetchmail";	
	 	$l[]="service_disabled=$enabled";
	 	$l[]="watchdog_features=1";
	 	$l[]="family=mailbox";
	 	
	 	if($enabled==1){
 			$fetchmail_count_server=fetchmail_count_server();
 			if($GLOBALS["VERBOSE"]){echo "fetchmail_count_server: $fetchmail_count_server\n";}
	 			 		
	 		if($fetchmail_count_server>0){	
	 			if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){
					WATCHDOG("APP_FETCHMAIL","fetchmail");
					$l[]="running=0\ninstalled=1";$l[]="";return implode("\n",$l);
					return;
				}
	 		}
	 	}

	 	
	 	
		if($enabled==0){return implode("\n",$l);return;}
		if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){
			$l[]="running=0";}else{$l[]="running=1";$l[]=GetMemoriesOf($master_pid);}
		
		
		
		$l[]="";
		
		
		
	}else{
		$enabled=1;
	}
	
	$master_pid=trim(@file_get_contents("/etc/artica-postfix/exec.fetmaillog.php.pid"));
	$l[]="[FETCHMAIL_LOGGER]";
	$l[]="service_name=APP_FETCHMAIL_LOGGER";
 	$l[]="master_version=".GetVersionOf("fetchmail");
 	$l[]="service_cmd=fetchmail-logger";	
 	$l[]="service_disabled=$enabled";
 	$l[]="watchdog_features=1";
 	
	if($enabled==1){
	 		if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){
	 			$fetchmail_count_server=fetchmail_count_server();
	 			if($GLOBALS["VERBOSE"]){echo "fetchmail_count_server: $fetchmail_count_server\n";}
	 			if($fetchmail_count_server>0){
					WATCHDOG("APP_FETCHMAIL_LOGGER","fetchmail-logger");
					$l[]="running=0\ninstalled=1";$l[]="";return implode("\n",$l);
					return;
	 			}else{
	 				return implode("\n",$l);return;
	 			}
			}
	 	}		 	 	
 	
	if($enabled==0){return implode("\n",$l);return;}	
	$l[]="running=1";
	$l[]=GetMemoriesOf($master_pid);
	$l[]="";	
	return implode("\n",$l);return;	
	}
Exemplo n.º 2
0
function fetchmail()
{
    if (!$GLOBALS["CLASS_USERS"]->fetchmail_installed) {
        return null;
    }
    $EnablePostfixMultiInstance = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnablePostfixMultiInstance");
    $EnableFetchmailScheduler = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableFetchmailScheduler");
    $enabled = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableFetchmail");
    if (!is_numeric($enabled)) {
        $enabled = 0;
    }
    if (!is_numeric($EnableFetchmailScheduler)) {
        $EnableFetchmailScheduler = 0;
    }
    if ($EnableFetchmailScheduler == 1) {
        return;
    }
    $DisableMessaging = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("DisableMessaging"));
    if ($DisableMessaging == 1) {
        $enabled = 0;
    }
    if ($EnablePostfixMultiInstance != 1) {
        if (!is_file("/etc/fetchmailrc")) {
            $enabled = 0;
        }
        $master_pid = trim(@file_get_contents("/var/run/fetchmail.pid"));
        if (preg_match("#^([0-9]+)#", $master_pid, $re)) {
            $master_pid = $re[1];
        }
        $l[] = "[FETCHMAIL]";
        $l[] = "service_name=APP_FETCHMAIL";
        $l[] = "master_version=" . fetchmail_version();
        $l[] = "service_cmd=/etc/init.d/fetchmail";
        $l[] = "service_disabled={$enabled}";
        $l[] = "watchdog_features=1";
        $l[] = "family=mailbox";
        if ($enabled == 1) {
            $fetchmail_count_server = fetchmail_count_server();
            if ($GLOBALS["VERBOSE"]) {
                echo "fetchmail_count_server: {$fetchmail_count_server}\n";
            }
            if ($fetchmail_count_server > 0) {
                if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
                    if (!$GLOBALS["DISABLE_WATCHDOG"]) {
                        shell_exec2("{$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.initslapd.php --fetchmail >/dev/null 2>&1");
                        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.fetchmail.php --start >/dev/null 2>&1 &");
                    }
                    $l[] = "running=0\ninstalled=1";
                    $l[] = "";
                    return implode("\n", $l);
                    return;
                }
            }
        }
        if ($enabled == 0) {
            return implode("\n", $l);
            return;
        }
        if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
            $l[] = "running=0";
        } else {
            $l[] = "running=1";
            $l[] = GetMemoriesOf($master_pid);
        }
        $l[] = "";
    } else {
        $enabled = 1;
    }
    $master_pid = trim(@file_get_contents("/etc/artica-postfix/exec.fetmaillog.php.pid"));
    $l[] = "[FETCHMAIL_LOGGER]";
    $l[] = "service_name=APP_FETCHMAIL_LOGGER";
    $l[] = "master_version=" . fetchmail_version();
    $l[] = "service_cmd=fetchmail-logger";
    $l[] = "service_disabled={$enabled}";
    $l[] = "watchdog_features=1";
    if ($enabled == 1) {
        if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
            $fetchmail_count_server = fetchmail_count_server();
            if ($GLOBALS["VERBOSE"]) {
                echo "fetchmail_count_server: {$fetchmail_count_server}\n";
            }
            if ($fetchmail_count_server > 0) {
                WATCHDOG("APP_FETCHMAIL_LOGGER", "fetchmail-logger");
                $l[] = "running=0\ninstalled=1";
                $l[] = "";
                return implode("\n", $l);
                return;
            } else {
                return implode("\n", $l);
                return;
            }
        }
    }
    if ($enabled == 0) {
        return implode("\n", $l);
        return;
    }
    $l[] = "running=1";
    $l[] = GetMemoriesOf($master_pid);
    $l[] = "";
    return implode("\n", $l);
    return;
}