当前位置: 首页>>代码示例>>PHP>>正文


PHP unix::send_email_events方法代码示例

本文整理汇总了PHP中unix::send_email_events方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::send_email_events方法的具体用法?PHP unix::send_email_events怎么用?PHP unix::send_email_events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unix的用法示例。


在下文中一共展示了unix::send_email_events方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: detect_kernels

function detect_kernels()
{
    $unix = new unix();
    if (!$GLOBALS["VERBOSE"]) {
        if (is_file("/usr/share/artica-postfix/ressources/logs/kernel.lst")) {
            if ($unix->file_time_min("/usr/share/artica-postfix/ressources/logs/kernel.lst") < 360) {
                die;
            }
        }
    }
    $users = new usersMenus();
    if ($users->LinuxDistriCode != "DEBIAN" && $users->LinuxDistriCode != "UBUNTU") {
        die;
    }
    $unix = new unix();
    $apt_cache = $unix->find_program("apt-cache");
    if ($apt_cache == null) {
        echo "Could not find apt-cache\n";
        die;
    }
    if (system_is_overloaded(basename(__FILE__))) {
        $unix->send_email_events("apt-cache aborted, system is overloaded..", "will restart analyzis in next cycle", "system");
        die;
    }
    echo "{$apt_cache} search linux-image\n";
    exec("{$apt_cache} search linux-image", $results);
    while (list($num, $val) = each($results)) {
        if (preg_match("#linux-image-([0-9\\.]+)-([0-9]+)-(.+?)\\s+-\\s+(.+?)\$#", $val, $re)) {
            $array["DPKG"][] = array("VERSION" => $re[1], "BUILD" => $re[2], "ARCH" => $re[3], "INFOS" => $re[4], "PACKAGE" => "linux-image-{$re[1]}-{$re[2]}-{$re[3]}", "FULL_VERSION" => "{$re[1]}-{$re[2]}-{$re[3]}");
        }
    }
    $array["INFOS"] = CpuFamilyInfos();
    @file_put_contents("/usr/share/artica-postfix/ressources/logs/kernel.lst", base64_encode(serialize($array)));
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:34,代码来源:exec.apt-cache.kernel.php

示例2: execute

function execute()
{
    $pid = getmypid();
    $pidfile = "/etc/artica-postfix/" . basename(__FILE__) . ".pid";
    $unix = new unix();
    if ($unix->process_exists($unix->get_pid_from_file($pidfile))) {
        die;
    }
    file_put_contents($pidfile, $pid);
    build_conf();
    if (is_file("/etc/spamassassin/sa-learn-cyrus.conf")) {
        exec("/usr/share/artica-postfix/bin/sa-learn-cyrus", $results);
        $unix->send_email_events("Junk learning successfully executed for {$GLOBALS["USERS_LIST_COUNT"]} user(s)", @implode("\n", $results), 'mailbox');
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:15,代码来源:exec.sa-learn-cyrus.php

示例3: amavis_reload

function amavis_reload(){
	SPAMASSASSIN_V320();
	PhishTag();
	HitFreqsRuleTiming();
	if(!is_file("/usr/local/sbin/amavisd")){return null;}
	if(!is_file("/usr/local/etc/amavisd.conf")){return null;}
	$amavis=new amavis();
	$amavis->CheckDKIM();
	$conf=$amavis->buildconf();	
	@file_put_contents("/usr/local/etc/amavisd.conf",$conf);
	$unix=new unix();
	$unix->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-make APP_SPAMASSASSIN_RQ");
	CheckSecuritiesFolders();
	$unix->send_email_events("Amavis will be reloaded", "exec.spamassassin, ordered to reload amavis {$GLOBALS["CMDLINES"]}", "postfix");
	$unix->THREAD_COMMAND_SET("/usr/local/sbin/amavisd -c /usr/local/etc/amavisd.conf reload");	
	
}
开发者ID:rsd,项目名称:artica-1.5,代码行数:17,代码来源:exec.spamassassin.php

示例4: CleanDirLogs

function CleanDirLogs($path)
{
    return;
    if ($GLOBALS["VERBOSE"]) {
        echo "CleanDirLogs({$path})\n";
    }
    $BigSize = false;
    if ($path == '/var/log') {
        $BigSize = true;
    }
    if ($GLOBALS["ArticaMaxLogsSize"] < 100) {
        $GLOBALS["ArticaMaxLogsSize"] = 100;
    }
    $maxday = $GLOBALS["MaxTempLogFilesDay"] * 24;
    $maxday = $maxday * 60;
    $users = new usersMenus();
    $maillog_path = $users->maillog_path;
    $unix = new unix();
    $sock = new sockets();
    $restartSyslog = false;
    if ($path == null) {
        return;
    }
    $countfile = 0;
    foreach (glob("{$path}/*") as $filepath) {
        if ($filepath == null) {
            continue;
        }
        if (is_link($filepath)) {
            continue;
        }
        if (is_dir($filepath)) {
            continue;
        }
        if ($filepath == $maillog_path) {
            continue;
        }
        if (preg_match("#\\/log\\/artica-postfix\\/#", $filepath)) {
            continue;
        }
        $countfile++;
        if ($countfile > 500) {
            if (is_overloaded()) {
                $unix->send_email_events("Clean Files: [{$path}/*] System is overloaded ({$GLOBALS["SYSTEM_INTERNAL_LOAD"]}", "The clean logs function is stopped and wait a new schedule with best performances", "logs_cleaning");
                die;
            }
            $countfile = 0;
        }
        usleep(300);
        $size = round(unix_file_size("{$filepath}") / 1024);
        $time = $unix->file_time_min($filepath);
        $unix->events("{$filepath} {$size} Ko, {$time}Mn/{$maxday}Mn TTL");
        if ($size > $GLOBALS["ArticaMaxLogsSize"]) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Delete {$filepath}\n";
            }
            $restartSyslog = true;
            $GLOBALS["DELETED_SIZE"] = $GLOBALS["DELETED_SIZE"] + $size;
            $GLOBALS["DELETED_FILES"] = $GLOBALS["DELETED_FILES"] + 1;
            $GLOBALS["UNLINKED"][] = $filepath;
            @unlink($filepath);
            continue;
        }
        if ($time > $maxday) {
            $GLOBALS["DELETED_SIZE"] = $GLOBALS["DELETED_SIZE"] + $size;
            $GLOBALS["DELETED_FILES"] = $GLOBALS["DELETED_FILES"] + 1;
            if ($GLOBALS["VERBOSE"]) {
                echo "Delete {$filepath}\n";
            }
            @unlink($filepath);
            $GLOBALS["UNLINKED"][] = $filepath;
            $restartSyslog = true;
            continue;
        }
    }
    if ($restartSyslog) {
        $unix->send_email_events("System log will be restarted", "Logs files was deleted and log daemons will be restarted\n\t\t\t" . @implode("\n", $GLOBALS["UNLINKED"]), "logs_cleaning");
        $unix->RESTART_SYSLOG();
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:80,代码来源:exec.clean.logs.php

示例5: wakeup_client_mode

function wakeup_client_mode(){
	$main_path="/etc/artica-postfix/openvpn/clients";
	$unix=new unix();
	$pidpath="/etc/artica-postfix/pids/".basename(__FILE__).".".__FUNCTION__.".pid";
	$oldpid=@file_get_contents($pidpath);
	if($unix->process_exists($oldpid)){
		writelogs("OpenVPN Already instance executed pid $oldpid",__FUNCTION__,__FILE__,__LINE__);
		return;
	}
	
	@file_put_contents($pidpath, posix_getpid());
	$ping=$unix->find_program("ping");
	if(!is_file($ping)){writelogs("Fatal,ping, no such binary",__FUNCTION__,__FILE__,__LINE__);return;}	
	$tbl=$unix->dirdir($main_path);
	if(count($tbl)==0){return;}
	while (list ($path, $id) = each ($tbl) ){
			if(!preg_match("#/etc/artica-postfix/openvpn/clients/([0-9]+)#",$path,$re)){if($GLOBALS["VERBOSE"]){echo "Starting......: $path NO MATCH\n";}continue;}
			$id=$re[1];
			if($GLOBALS["VERBOSE"]){echo "Starting......: OpenVPN wake up checking client ID:$id\n";}
			if(!is_file("$path/settings.ovpn")){if($GLOBALS["VERBOSE"]){echo "Starting......: $path/settings.ovpn no such file\n";}continue;}
			$ip=wakeup_client_mode_getWakeup("$path/settings.ovpn");
			if($ip==null){continue;}
			
			$resultsPing=array();
			exec("$ping -c2 -i0.2 $ip 2>&1",$resultsPing);
			writelogs("OpenVPN  \"$ip\" ".count($resultsPing)." rows",__FUNCTION__,__FILE__,__LINE__);
			$text=date("Y-m-d H:i:s")."\n".@implode("\n", $resultsPing);	
			$ping_results=@file_get_contents("$path/ping_results");
			while (list ($nimber, $l) = each ($resultsPing) ){
				if(preg_match("#,\s+([0-9]+)\%\s+#", $l,$re)){
					writelogs("OpenVPN  \"{$re[1]}%\" Packets lost",__FUNCTION__,__FILE__,__LINE__);
					if($re[1]==100){
						$note=-1;
						writelogs("OpenVPN $ip Ping failed",__FUNCTION__,__FILE__,__LINE__);
						$unix->send_email_events("[VPN]: wake up failed server link $ip" , "It seems that OpenVPN server did not respond\n$text", "vpn");
						
					}else{
						$note=1;
						if($ping_results<>1){$unix->send_email_events("[VPN]: wake up server success $ip" , "It seems that the connection to the server has been established\n$text", "vpn");}
					}
					@file_put_contents("$path/ping_results", $note);
					
					}
			}
	}

}
开发者ID:rsd,项目名称:artica-1.5,代码行数:47,代码来源:exec.openvpn.php

示例6: mount_usb

function mount_usb($pattern, $ID, $testwrite = true)
{
    $backup = new backup_protocols();
    $uuid = $backup->extractFirsRessource($pattern);
    $unix = new unix();
    $rsync = $unix->find_program("rsync");
    if ($uuid == null) {
        backup_events($ID, "initialization", "ERROR, (usb) usb protocol error {$pattern}", __LINE__);
        writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]: usb protocol error {$pattern}", __FUNCTION__, __FILE__, __LINE__);
        return false;
    }
    $usb = new usb($uuid);
    writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]: {$uuid} {$usb->path} FS_TYPE: {$usb->ID_FS_TYPE}", __FUNCTION__, __FILE__, __LINE__);
    if ($usb->ID_FS_TYPE == null) {
        backup_events($ID, "initialization", "ERROR, (usb) usb type error {$pattern}", __LINE__);
        return false;
    }
    if ($usb->path == null) {
        backup_events($ID, "initialization", "ERROR, (usb) usb dev error {$pattern}", __LINE__);
        return false;
    }
    $mount = new mount($GLOBALS["ADDLOG"]);
    $mount_path = "/opt/artica/mounts/backup/{$ID}";
    if (!$mount->ismounted($mount_path)) {
        backup_events($ID, "initialization", "ERROR, (usb) local mount point {$mount_path} not mounted");
        @mkdir($mount_path, null, true);
    }
    if (!$mount->usb_mount($mount_path, $usb->ID_FS_TYPE, $usb->path)) {
        backup_events($ID, "initialization", "ERROR, (usb) unable to mount target point");
        return false;
    }
    if (!$testwrite) {
        writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]: Test write has been cancelled", __FUNCTION__, __FILE__, __LINE__);
        return true;
    }
    $md5 = md5(date('Y-m-d H:i:s'));
    writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]: Test write Creating file \"{$mount_path}/{$md5}\"", __FUNCTION__, __FILE__, __LINE__);
    try {
        file_put_contents("{$mount_path}/{$md5}", time());
    } catch (Exception $e) {
        $IOERROR = $e->getMessage();
    }
    if (is_file("{$mount_path}/{$md5}")) {
        @unlink("{$mount_path}/{$md5}");
        if (is_file($rsync)) {
            $GLOBALS["COMMANDLINECOPY"] = "{$rsync} -ar {SRC_PATH} {NEXT} --stats --chmod=ug=rwX,o=rwX";
        } else {
            $GLOBALS["COMMANDLINECOPY"] = "/bin/cp -ru {SRC_PATH} {NEXT}";
        }
        $GLOBALS["COMMANDLINE_MOUNTED_PATH"] = $mount_path;
        writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]: OK !", __FUNCTION__, __FILE__, __LINE__);
        if ($GLOBALS["ONLY_TESTS"]) {
            writelogs(date('m-d H:i:s') . " " . "<H2>{success}</H2>", __FUNCTION__, __FILE__, __LINE__);
        }
        return true;
    } else {
        backup_events($ID, "initialization", "ERROR, (usb) {$mount_path}/{$md5} {$IOERROR}");
        backup_events($ID, "initialization", "ERROR, (usb) {$mount_path}/{$md5} should be a permission denied (I/O error)");
        $unix = new unix();
        $unix->send_email_events("Backup: task id {$ID} aborted, unable to write into the device {$usb->path} FS_TYPE: {$usb->ID_FS_TYPE}", "Artica has tried to write {$mount_path}/{$md5} into this mounted device but it seems that it is impossible\n{$IOERROR}", "backup");
        writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]: Failed !!!, umounting...{$mount_path}", __FUNCTION__, __FILE__, __LINE__);
        $umount = $unix->find_program("umount");
        exec("{$umount} -l {$mount_path}");
    }
}
开发者ID:articatech,项目名称:artica,代码行数:65,代码来源:exec.backup.php

示例7: activedirectory_ping

function activedirectory_ping(){
	$sock=new sockets();
	$unix=new unix();
	$filetime="/etc/artica-postfix/pids/".basename(__FILE__).".".__FUNCTION__.".time";
	$EnableSambaActiveDirectory=$sock->GET_INFO("EnableSambaActiveDirectory");
	if(!is_numeric($EnableSambaActiveDirectory)){return;}
	if($EnableSambaActiveDirectory<>1){return;}
	$ping_dc=false;
	$time=$unix->file_time_min($filetime);
	if($time<120){
		if(!$GLOBALS["VERBOSE"]){return;}
		echo "$filetime ({$time}Mn)\n";
	}
	
	$kinit=$unix->find_program("kinit");
	$echo=$unix->find_program("echo");
	$net=$unix->LOCATE_NET_BIN_PATH();
	$wbinfo=$unix->find_program("wbinfo");
	$config=unserialize(base64_decode($sock->GET_INFO("SambaAdInfos")));
	$domain=strtoupper($config["ADDOMAIN"]);
	$domain_lower=strtolower($config["ADDOMAIN"]);

	$ADSERVER_IP=$config["ADSERVER_IP"];	
	$ad_server=strtolower($config["ADSERVER"]);
	$kinitpassword=$config["PASSWORD"];
	$kinitpassword=$unix->shellEscapeChars($kinitpassword);
	
	$clock_explain="The clock on you system (Linux/UNIX) is too far off from the correct time.\nYour machine needs to be within 5 minutes of the Kerberos servers in order to get any tickets.\nYou will need to run ntp, or a similar service to keep your clock within the five minute window";
	
	
	$cmd="$echo $kinitpassword|$kinit {$config["ADADMIN"]}@$domain 2>&1";
	echo "$cmd\n";
	exec("$cmd",$kinit_results);
	while (list ($num, $ligne) = each ($kinit_results) ){
		if(preg_match("#Clock skew too great while getting initial credentials#", $ligne)){$unix->send_email_events("Active Directory connection clock issue", "kinit program claim\n$ligne\n$clock_explain", "system");}
		if($GLOBALS["VERBOSE"]){echo "kinit: $ligne\n";}
	}	
	

	exec("$wbinfo --ping-dc 2>&1",$ping_dc_results);
	
	while (list ($num, $ligne) = each ($ping_dc_results) ){
		if($GLOBALS["VERBOSE"]){echo "ping-dc: $ligne\n";}
		if(preg_match("#succeeded#", $ligne)){$ping_dc=true;}
	}
	
	@unlink($filetime);
	@file_put_contents($filetime, time());
	
	
}
开发者ID:rsd,项目名称:artica-1.5,代码行数:51,代码来源:exec.samba.php

示例8: upgradeTo7

function upgradeTo7()
{
    return;
    if (is_file("/etc/artica-postfix/NO_ZARAFA_UPGRADE_TO_7")) {
        return;
    }
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid)) {
        echo "Already running pid {$pid}\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $python = $unix->find_program("python");
    $cmd = "{$python} /usr/share/artica-postfix/bin/zarafa7-upgrade 2>&1";
    exec($cmd, $results);
    writelogs("{$cmd} -> " . count($results) . "rows", __FUNCTION__, __FILE__, __LINE__);
    while (list($index, $line) = each($results)) {
        writelogs("{$line}", __FUNCTION__, __FILE__, __LINE__);
    }
    $unix->send_email_events("Zarafa upgraded to 7 (see details)", $cmd . "\n" . @implode("\n", $results), "mailbox");
    $nohup = $unix->find_program("nohup");
    shell_exec("{$nohup} /etc/init.d/artica-postfix restart zarafa >/dev/null 2>&1 &");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:25,代码来源:exec.zarafa-migrate.php

示例9: import_rules

function import_rules(){
	if (!$handle = opendir("/var/log/artica-postfix/iptaccount")) {return ;}
	$q=new mysql();
	$unix=new unix();
	while (false !== ($filename = readdir($handle))) {
		$targetFile="/var/log/artica-postfix/iptaccount/$filename";
		if(!is_file($targetFile)){continue;}
		if(!preg_match("#^([0-9]+)\.([0-9]+)$#",$filename,$re)){echo "$filename is not a requested file...\n";continue;}
		$rule_id=$re[2];
		$time=$re[1];
		$zDate=date('Y-m-d H:i:s',$time);
		$f=explode("\n",@file_get_contents($targetFile));
		$suffix=array();
		$sql_prefix="INSERT INTO tcp_account_events (rule_id,zDate,ipaddr,src_parckets,src_bytes,dst_packets,dst_bytes) VALUES ";
		while (list ($num, $ligne) = each ($f) ){
			if(!preg_match("#^(.+?);([0-9]+);([0-9]+);([0-9]+);([0-9]+)#", $ligne,$re)){continue;}
			$ipaddr=$re[1];
			$src_parckets=$re[2];
			$src_bytes=$re[3];
			$dst_packets=$re[4];
			$dst_bytes=$re[5];
			$suffix[]="('$rule_id','$zDate','$ipaddr','$src_parckets','$src_bytes','$dst_packets','$dst_bytes')";

		}
		
		$sql="$sql_prefix".@implode(",", $suffix);
		$q->QUERY_SQL($sql,"artica_events");
		if(!$q->ok){
			$unix->send_email_events("TCP/IP account failed $filename (MySQL)", "Artica encounter an error while inserting statistics\n$q->mysql_error\n$sql", "system");
			continue;
		}
		
		@unlink($targetFile);
		
	}
	
	
	
	
}
开发者ID:rsd,项目名称:artica-1.5,代码行数:40,代码来源:exec.iptaccount.php

示例10: av_stats

function av_stats()
{
    $GLOBALS["NO_PID_CHECKS"] = true;
    $users = new usersMenus();
    if (!$users->KAV4PROXY_INSTALLED) {
        if ($GLOBALS["VERBOSE"]) {
            writelogs("Kav4Proxy is not installed...", __FUNCTION__, __FILE__, __LINE__);
        }
        return;
    }
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $unix = new unix();
    $minute = $unix->file_time_min($timefile);
    if (!$GLOBALS["FORCE"]) {
        if ($minute < 15) {
            if ($GLOBALS["VERBOSE"]) {
                writelogs("{$minute}Mn need 15, aborting", __FUNCTION__, __FILE__, __LINE__);
            }
            return;
        }
    }
    $pid = $unix->get_pid_from_file("/var/run/kav4proxy/kavicapserver.pid");
    if (!$unix->process_exists($pid)) {
        if ($GLOBALS["VERBOSE"]) {
            writelogs("Process antivirus statistics failed, Kav4Proxy seems not running (PID:{$pid})", __FUNCTION__, __FILE__, __LINE__);
        }
        $unix->send_email_events("Process antivirus statistics failed, Kav4Proxy seems not running (PID:{$pid})", "/var/run/kav4proxy/kavicapserver.pid as no valid PID", "proxy");
        return;
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    $kill = $unix->find_program("kill");
    if ($GLOBALS["VERBOSE"]) {
        writelogs("{$kill} -USR2 {$pid}", __FUNCTION__, __FILE__, __LINE__);
    }
    shell_exec("{$kill} -USR2 {$pid}");
    if (!is_file("/var/log/kaspersky/kav4proxy/counter.stats")) {
        if (is_file("/var/log/kaspersky/kav4proxy/av.stats")) {
            av_events();
        }
        if ($GLOBALS["VERBOSE"]) {
            writelogs("/var/log/kaspersky/kav4proxy/counter.stats no such file", __FUNCTION__, __FILE__, __LINE__);
        }
        return;
    }
    if (is_file("/var/log/kaspersky/kav4proxy/av.stats")) {
        av_events();
    }
    $FileExploded = explode("\n", @file_get_contents("/var/log/kaspersky/kav4proxy/counter.stats"));
    if ($GLOBALS["VERBOSE"]) {
        writelogs("/var/log/kaspersky/kav4proxy/counter.stats " . count($FileExploded) . " items", __FUNCTION__, __FILE__, __LINE__);
    }
    $val = array();
    while (list($num, $line) = each($FileExploded)) {
        if (preg_match("#^(.+?)\\s+([0-9\\.]+)#", $line, $re)) {
            if ($GLOBALS["VERBOSE"]) {
                writelogs("item: {$re[1]} = \"{$re[2]}\"", __FUNCTION__, __FILE__, __LINE__);
            }
            $val[trim($re[1])] = trim($re[2]);
        } else {
            if ($GLOBALS["VERBOSE"]) {
                writelogs("{$line} no match ^(.+?)\\s+([0-9\\.]+)", __FUNCTION__, __FILE__, __LINE__);
            }
        }
    }
    if (count($val) == 0) {
        if ($GLOBALS["VERBOSE"]) {
            writelogs("\$val no items, aborting", __FUNCTION__, __FILE__, __LINE__);
        }
        return;
    }
    $fields[] = "`zDate`";
    $values[] = "'" . date('Y-m-d H:i:s') . "'";
    while (list($num, $line) = each($val)) {
        if ($num == null) {
            continue;
        }
        $fields[] = "`{$num}`";
        $values[] = "'{$line}'";
    }
    $sql = "INSERT IGNORE INTO kav4proxy_av_stats (" . @implode(",", $num) . ") VALUES(" . @implode(",", $values) . ")";
    if ($GLOBALS["VERBOSE"]) {
        writelogs("{$sql}", __FUNCTION__, __FILE__, __LINE__);
    }
    $q = new mysql();
    $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        if ($GLOBALS["VERBOSE"]) {
            writelogs("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__);
        }
        $unix->send_email_events("Process antivirus statistics failed, mysql errors", "Query was: {$sql}\nError was:{$q->mysql_error}\nData was\n" . @file_get_contents("/var/log/kaspersky/kav4proxy/counter.stats"), "proxy");
        return;
    }
    @unlink("/var/log/kaspersky/kav4proxy/counter.stats");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:95,代码来源:exec.kaspersky-update-logs.php

示例11: ParseResolvMX

function ParseResolvMX()
{
    $sock = new sockets();
    $WhiteListResolvMX = $sock->GET_INFO("WhiteListResolvMX");
    if (!is_numeric($WhiteListResolvMX)) {
        return null;
    }
    if ($WhiteListResolvMX == 0) {
        return null;
    }
    if (!function_exists("getmxrr")) {
        echo "getmxrr() no such function\n";
        return;
    }
    $sql = "SELECT sender FROM postfix_global_whitelist WHERE enabled=1 ORDER BY sender";
    if ($GLOBALS["VERBOSE"]) {
        echo $sql . "\n";
    }
    $q = new mysql();
    if (!$q->TestingConnection()) {
        echo "ParseResolvMX()/" . basename(__FILE__) . " Connection to MySQL server failed...\n";
        return;
    }
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $q = new mysql();
    $sql = "SELECT * FROM postfix_whitelist_con";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "{$q->mysql_error}\n";
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $WHITELISTED[$ligne["ipaddr"]] = true;
        $WHITELISTED[$ligne["hostname"]] = true;
    }
    $count_whitelisted_before = count($WHITELISTED);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $domain = trim($ligne["sender"]);
        if ($domain == null) {
            continue;
        }
        if (preg_match("#@(.+)#", $domain, $re)) {
            $domain = $re[1];
        }
        if (strpos($domain, "*") > 0) {
            continue;
        }
        $array_mx = resolvMX($domain);
        if (count($array_mx) == 0) {
            continue;
        }
        echo "{$domain} = " . count($array_mx) . " mx\n";
        while (list($ipaddr, $hostname) = each($array_mx)) {
            $notif[] = "{$domain}: {$hostname} [{$ipaddr}]";
            $WHITELISTED[$ipaddr] = $hostname;
        }
    }
    $count_whitelisted_after = count($WHITELISTED);
    $somme = $count_whitelisted_after - $count_whitelisted_before;
    if ($somme == 0) {
        echo "Nothing to do...\n";
        return;
    }
    if ($somme > 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "{$somme} items added in array\n" . @implode("\n", $notif);
        }
        $unix = new unix();
        $unix->send_email_events("{$somme} items MX has been whitelisted", @implode("\n", $notif), "postfix");
    }
    reset($WHITELISTED);
    while (list($value, $hostname) = each($WHITELISTED)) {
        if (trim($value) == null) {
            continue;
        }
        $sql = "DELETE FROM iptables WHERE serverip='{$value}' AND local_port=25";
        $q->QUERY_SQL($sql, "artica_backup");
        $sql = "INSERT IGNORE INTO postfix_whitelist_con (ipaddr,hostname) VALUES('{$value}','{$hostname}')";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    $cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.postfix.maincf.php --postscreen";
    shell_exec($cmd);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:86,代码来源:exec.postfix.iptables.php

示例12: ping_kdc

function ping_kdc()
{
    $sock = new sockets();
    $unix = new unix();
    $users = new settings_inc();
    $chmod = $unix->find_program("chmod");
    $filetime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    if (!is_numeric("{$EnableKerbAuth}")) {
        $EnableKerbAuth = 0;
    }
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $ttime = $unix->PROCCESS_TIME_MIN($pid);
        progress_logs(20, "{join_activedirectory_domain}", "[PING]: Already executed pid {$pid} since {$ttime}Mn");
        return;
    }
    @file_put_contents($pidfile, getmypid());
    if ($EnableKerbAuth == 0) {
        progress_logs(20, "{ping_kdc}", "[PING]: Kerberos, disabled");
        return;
    }
    if (!checkParams()) {
        progress_logs(20, "{ping_kdc}", "[PING]: Kerberos, misconfiguration failed");
        return;
    }
    $array["RESULTS"] = false;
    $array = unserialize(base64_decode($sock->GET_INFO("KerbAuthInfos")));
    $time = $unix->file_time_min($filetime);
    if (!$GLOBALS["FORCE"]) {
        if ($time < 10) {
            if (!$GLOBALS["VERBOSE"]) {
                return;
            }
            progress_logs(20, "{ping_kdc}", "{$filetime} ({$time}Mn)");
        }
    }
    $kinit = $unix->find_program("kinit");
    $echo = $unix->find_program("echo");
    $net = $unix->LOCATE_NET_BIN_PATH();
    $wbinfo = $unix->find_program("wbinfo");
    $chmod = $unix->find_program("chmod");
    $nohup = $unix->find_program("nohup");
    $domain = strtoupper($array["WINDOWS_DNS_SUFFIX"]);
    $domain_lower = strtolower($array["WINDOWS_DNS_SUFFIX"]);
    $ad_server = strtolower($array["WINDOWS_SERVER_NETBIOSNAME"]);
    $kinitpassword = $array["WINDOWS_SERVER_PASS"];
    $kinitpassword = $unix->shellEscapeChars($kinitpassword);
    $php5 = $unix->LOCATE_PHP5_BIN();
    $clock_explain = "The clock on you system (Linux/UNIX) is too far off from the correct time.\nYour machine needs to be within 5 minutes of the Kerberos servers in order to get any tickets.\nYou will need to run ntp, or a similar service to keep your clock within the five minute window";
    $cmd = "{$echo} {$kinitpassword}|{$kinit} {$array["WINDOWS_SERVER_ADMIN"]}@{$domain} -V 2>&1";
    progress_logs(20, "{ping_kdc}", "{$cmd}");
    exec("{$cmd}", $kinit_results);
    while (list($num, $ligne) = each($kinit_results)) {
        if (preg_match("#Clock skew too great while getting initial credentials#", $ligne)) {
            if ($GLOBALS["VERBOSE"]) {
                progress_logs(20, "{ping_kdc}", "Clock skew too great while");
            }
            $array["RESULTS"] = false;
            $array["INFO"] = $ligne;
            $unix->send_email_events("Active Directory connection clock issue", "kinit program claim\n{$ligne}\n{$clock_explain}", "system");
        }
        if (preg_match("#Client not found in Kerberos database while getting initial credentials#", $ligne)) {
            $array["RESULTS"] = false;
            $array["INFO"] = $ligne;
            $unix->send_email_events("Active Directory authentification issue", "kinit program claim\n{$ligne}\n", "system");
        }
        if (preg_match("#Authenticated to Kerberos#", $ligne)) {
            $array["RESULTS"] = true;
            $array["INFO"] = $ligne;
            progress_logs(20, "{join_activedirectory_domain}", "[PING]: Kerberos, Success");
        }
        if ($GLOBALS["VERBOSE"]) {
            progress_logs(20, "{ping_kdc}", "kinit: {$ligne}");
        }
    }
    $TestJoin = true;
    if ($array["RESULTS"] == true) {
        exec("{$net} ads testjoin 2>&1", $results);
        while (list($num, $ligne) = each($results)) {
            if (preg_match("#Unable to find#", $ligne)) {
                $array["RESULTS"] = false;
                $array["INFO"] = $array["INFO"] . "<div><i style='font-size:11px;color:#B3B3B3'>{$ligne}</i></div>";
                $TestJoin = false;
                continue;
            }
            if (preg_match("#is not valid:#", $ligne)) {
                $array["RESULTS"] = false;
                $array["INFO"] = $array["INFO"] . "<div><i style='font-size:11px;color:#B3B3B3'>{$ligne}</i></div>";
                $TestJoin = false;
                continue;
            }
        }
        if (preg_match("#OK#", $ligne)) {
            $array["INFO"] = $array["INFO"] . "<div><i style='font-size:11px;color:#B3B3B3'>{$ligne}</i></div>";
            $array["RESULTS"] = true;
        }
    }
    @unlink($filetime);
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.kerbauth.php

示例13: cyrus_empty_mailbox

function cyrus_empty_mailbox()
{
    $unix = new unix();
    $ipurge = $unix->LOCATE_CYRUS_IPURGE();
    if ($ipurge == null) {
        echo "<articadatascgi>" . base64_encode("Could not locate ipurge") . "</articadatascgi>";
        return;
    }
    $user = $_GET["uid"];
    if ($user == null) {
        echo "<articadatascgi>" . base64_encode("No user set") . "</articadatascgi>";
        return;
    }
    if (trim($_GET["size_of_message"]) != null) {
        $params[] = "-m{$_GET["size_of_message"]}";
    }
    if (trim($_GET["age_of_message"]) != null) {
        $params[] = "-d{$_GET["age_of_message"]}";
    }
    if ($_GET["submailbox"] != null) {
        $submailbox = "/{$_GET["submailbox"]}";
    }
    $params[] = "user/{$user}{$submailbox}";
    $cmd = "su cyrus -c \"{$ipurge} -f " . @implode(" ", $params) . " 2>&1\"";
    writelogs_framework("{$cmd}", __FUNCTION__, __FILE__, __LINE__);
    exec($cmd, $results);
    if ($_GET["by"] == -100) {
        $_GET["by"] = "Super Administrator";
    }
    $finale = trim(implode("", $results));
    if ($finale == null) {
        $results[] = "Executed...";
    }
    $unix->send_email_events("Messages task deletion on mailbox {$user}{$submailbox} by {{$_GET["by"]} executed", @implode("\n", $results), "mailbox");
    echo "<articadatascgi>" . base64_encode(@implode("\n", $results)) . "</articadatascgi>";
}
开发者ID:brucewu16899,项目名称:artica,代码行数:36,代码来源:cmd.php

示例14: SingleInstance

function SingleInstance()
{
    $sock = new sockets();
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $miltergreybin = $unix->find_program("milter-greylist");
    $MilterGreyListEnabled = $sock->GET_INFO("MilterGreyListEnabled");
    if (!is_numeric($MilterGreyListEnabled)) {
        $MilterGreyListEnabled = 0;
    }
    if ($MilterGreyListEnabled == 0) {
        echo "{$GLOBALS["deflog_start"]} Milter-greylist is not enabled\n";
        return;
    }
    $nohup = $unix->find_program("nohup");
    echo "{$GLOBALS["deflog_start"]} single instance execute exec.white-black-central.php\n";
    shell_exec("{$nohup} {$php5} /usr/share/artica-postfix/exec.white-black-central.php >/dev/null 2>&1 &");
    $mg = new milter_greylist(false, "master", "master");
    $datas = $mg->BuildConfig();
    if ($datas != null) {
        $conf_path = SingleInstanceConfPath();
        @mkdir(dirname($conf_path), 0666, true);
        echo "{$GLOBALS["deflog_start"]} single instance {$conf_path}\n";
        $tbl = explode("\n", $datas);
        echo "{$GLOBALS["deflog_start"]} cleaning {$conf_path} with " . count($tbl) . " lines\n";
        while (list($num, $ligne) = each($tbl)) {
            $ligne = trim($ligne);
            if ($ligne == null) {
                continue;
            }
            $newf[] = $ligne;
        }
        $newf[] = "";
        echo "{$GLOBALS["deflog_start"]} writing {$conf_path} (" . count($newf) . " lines)\n";
        @file_put_contents($conf_path, @implode("\n", $newf));
    }
    TestConfigFile($conf_path);
    echo "{$GLOBALS["deflog_start"]} notify administrator\n";
    $unix->send_email_events("Milter-greylist has been reconfigured", "By {$GLOBALS["WHOPROCESS"]}\nSettings:\n" . @implode("\n", $newf), "postfix");
    echo "{$GLOBALS["deflog_start"]} done.\n";
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:41,代码来源:exec.milter-greylist.php

示例15: logrotate

function logrotate()
{
    $unix = new unix();
    $sock = new sockets();
    $BackupMailLogPath = $sock->GET_INFO("BackupMailLogPath");
    $BackupMailLogMaxTimeCompressed = $sock->GET_INFO("BackupMailLogMaxTimeCompressed");
    if (!is_numeric($BackupMailLogMaxTimeCompressed)) {
        $BackupMailLogMaxTimeCompressed = 10080;
    }
    if ($BackupMailLogPath == null) {
        $BackupMailLogPath = "/home/logrotate_backup";
    }
    $du = $unix->find_program("du");
    $gzip = $unix->find_program("gzip");
    @mkdir("{$BackupMailLogPath}", true, 660);
    if (!is_dir("{$BackupMailLogPath}")) {
        $unix->send_email_events("PostFinder:Error while creating {$BackupMailLogPath}");
        return;
    }
    $nice = $unix->EXEC_NICE();
    $timestart = time();
    $log = array();
    foreach (glob("{$BackupMailLogPath}/*.log") as $filename) {
        $timefile = $unix->file_time_min($filename);
        $basename = basename($filename);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$basename}: {$timefile} minutes (need {$BackupMailLogMaxTimeCompressed} minutes)\n";
        }
        if ($timefile > $BackupMailLogMaxTimeCompressed) {
            $targetgzip = "{$BackupMailLogPath}/{$basename}.gz";
            $cmd = trim("{$nice}{$gzip} -c {$filename} >{$targetgzip}");
            if ($GLOBALS["VERBOSE"]) {
                echo "{$cmd}\n";
            }
            $time = time();
            shell_exec($cmd);
            if (is_file($targetgzip)) {
                $ev = "{$basename} -> {$targetgzip} " . $unix->distanceOfTimeInWords($time, time());
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$ev}\n";
                }
                $log[] = $ev;
                @unlink($filename);
            }
        }
    }
    $strings = null;
    exec("{$du} -h -s {$BackupMailLogPath}", $results);
    $strings = @implode("", $results);
    if (preg_match("#^(.+?)\\s+#", $strings, $re)) {
        $final_size = $re[1];
    }
    @file_put_contents("/usr/share/artica-postfix/ressources/logs/postfinder.dirsize.txt", $final_size);
    @chmod("/usr/share/artica-postfix/ressources/logs/postfinder.dirsize.txt", 777);
    if (count($log) > 0) {
        $unix->send_email_events("Postfinder: Directory size: {$strings} - " . count($log) . " maillog compressed (" . $unix->distanceOfTimeInWords($timestart, time()) . ")", "Directory: {$BackupMailLogPath}\n" . @implode("\n", $log), "postfix");
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:58,代码来源:exec.postfix.finder.php


注:本文中的unix::send_email_events方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。