Esempio n. 1
0
function schedules()
{
    @unlink("/etc/cron.d/apt-mirror");
    $php = LOCATE_PHP5_BIN2();
    $file = __FILE__;
    $sock = new sockets();
    shell_exec("/bin/rm -f /etc/cron.d/apt-mirror-* >/dev/null 2>&1");
    $config = unserialize(base64_decode($sock->GET_INFO("AptMirrorConfigSchedule")));
    if (!is_array($config)) {
        return;
    }
    $count = 0;
    while (list($uid, $schedule) = each($config)) {
        if (trim($schedule) == null) {
            continue;
        }
        $f[] = "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/share/artica-postfix/bin";
        $f[] = "MAILTO=\"\"";
        $f[] = "{$schedule}  root {$php} {$file} --perform >/dev/null 2>&1";
        $f[] = "";
        @file_put_contents("/etc/cron.d/apt-mirror-{$count}", @implode("\n", $f));
        $count++;
        unset($f);
    }
    shell_exec("/etc/init.d/cron reload");
}
Esempio n. 2
0
function status()
{
    $cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.status.php --transmission-daemon --nowachdog";
    exec($cmd, $results);
    writelogs_framework($cmd . " ->" . count($results) . " lines", __FUNCTION__, __FILE__, __LINE__);
    echo "<articadatascgi>" . base64_encode(implode("\n", $results)) . "</articadatascgi>";
}
Esempio n. 3
0
function Parseline($buffer)
{
    $buffer = trim($buffer);
    if ($buffer == null) {
        return null;
    }
    if (strpos($buffer, "init urllist") > 0) {
        return;
    }
    if (strpos($buffer, "init expressionlist") > 0) {
        return;
    }
    if (strpos($buffer, "init domainlist") > 0) {
        return;
    }
    if (preg_match('#INFO: loading dbfile (.+)#', $buffer, $re)) {
        events("LOADING {$re['1']}");
        $GLOBALS[__FILE__]["DBFILE"] = trim($re[1]);
        return null;
    }
    if (preg_match("#FATAL: Error db_open: Unknown error#", $buffer, $re)) {
        events("ERROR ON {$GLOBALS[__FILE__]["DBFILE"]} : {$buffer}");
        if (basename($GLOBALS[__FILE__]["DBFILE"]) == "urls.db") {
            events("urls.db -> create " . dirname($GLOBALS[__FILE__]["DBFILE"]) . "/urls it and recompile it");
            @file_put_contents(dirname($GLOBALS[__FILE__]["DBFILE"]) . "/urls", "www." . md5(time()) . ".bv");
        }
        $file = "/etc/artica-postfix/croned.1/squidguard." . md5($GLOBALS[__FILE__]["DBFILE"]) . ".error";
        if (IfFileTime($file)) {
            $cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.squidguard.php --compile-single \"{$GLOBALS[__FILE__]["DBFILE"]}\" &";
            events("{$cmd}");
            shell_exec($cmd);
            WriteFileCache($file);
        }
        return null;
    }
    if (preg_match("#\\]\\s+(.+?):\\s+Cannot allocate memory#", $buffer, $re)) {
        events("ERROR ON {$re[1]} : Cannot allocate memory -> create it");
        @file_put_contents($re[1], "www." . md5(time()) . ".bv");
        shell_exec("squid -k reconfigure");
        return null;
    }
    if (preg_match("#\\]\\s+(.+?):\\s+No such file or directory#", $buffer, $re)) {
        events("ERROR ON {$re[1]} : No such file or directory -> create it");
        @file_put_contents($re[1], "www.nodomain.bv");
        shell_exec("squid -k reconfigure");
        return null;
    }
    if (strpos($buffer, "ERROR: Going into emergency mode") > 0) {
        events("ERROR: Going into emergency mode");
        send_email_events("squidguard: squidguard turn to emergency mode", "SquidGuard claim\n{$buffer}\nPlease contact your support to fix this problem\ncurrently, no filtering urls will be enabled", "proxy");
        return;
    }
    events("Not filtered: {$buffer}");
}
Esempio n. 4
0
function schedules_mldonkey(){
	
	@unlink("/etc/artica-postfix/mldonkey.tasks");
	$sql="SELECT * FROM mldonkey ORDER BY schedule_time DESC";
	$q=new mysql();
	$results=$q->QUERY_SQL($sql,"artica_backup");

	
	while($ligne=mysql_fetch_array($results,MYSQL_ASSOC)){
		$params=unserialize(base64_decode($ligne["parameters"]));
		$params["hours"];
		$params["minutes"];
		if($params["minutes"]==null){$params["minutes"]="59";}
		if($params["hours"]==null){$params["hours"]="0";}
		$f[]="{$params["minutes"]} {$params["hours"]} * * * ".LOCATE_PHP5_BIN2()." ".dirname(__FILE__)."/exec.mldonkey.php --settings {$ligne["ID"]}";
	}
	
	if(is_array($f)){
		@file_put_contents("/etc/artica-postfix/mldonkey.tasks",@implode("\n",$f));	
	}
}
Esempio n. 5
0
function Parseline($buffer){
$buffer=trim($buffer);
if($buffer==null){return null;}

if(strpos($buffer,"init urllist")>0){return ;}
if(strpos($buffer,"init expressionlist")>0){return ;}
if(strpos($buffer,"init domainlist")>0){return ;}


	if(preg_match('#INFO: loading dbfile (.+)#',$buffer,$re)){
		events("LOADING $re[1]");
	  	$GLOBALS[__FILE__]["DBFILE"]=trim($re[1]);
		return null;
		}	
		
		
		
	if(preg_match("#FATAL: Error db_open: Unknown error#",$buffer,$re)){
	  	events("ERROR ON {$GLOBALS[__FILE__]["DBFILE"]}");
	  	$file="/etc/artica-postfix/croned.1/squidguard.". md5($GLOBALS[__FILE__]["DBFILE"]).".error";
		if(IfFileTime($file)){
	  		shell_exec(LOCATE_PHP5_BIN2()." /usr/share/artica-postfix/exec.squidguard.php --compile-single \"{$GLOBALS[__FILE__]["DBFILE"]}\" &");
	  		WriteFileCache($file);
		}
		return null;
		}

	if(strpos($buffer,"ERROR: Going into emergency mode")>0){
		events("ERROR: Going into emergency mode");
		send_email_events("squidguard: squidguard turn to emergency mode","SquidGuard claim\n$buffer\nPlease contact your support to fix this problem\ncurrently, no filtering urls will be enabled","proxy");
		return ;
	}
		
		

	events("Not filtered: $buffer");

}
$GLOBALS["bcc_maps"] = array();
$GLOBALS["transport_maps"] = array();
$GLOBALS["smtp_generic_maps"] = array();
if (!is_file($GLOBALS["postfix"])) {
    die;
}
if (!Build_pid_func(__FILE__, $argv[1])) {
    echo "Starting......: Already executed\n";
}
$ldap = new clladp();
if ($ldap->ldapFailed) {
    echo "Starting......: failed connecting to ldap server {$ldap->ldap_host}\n";
    die;
}
if ($GLOBALS["EnablePostfixMultiInstance"] == 1) {
    system(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.postfix-multi.php");
    die;
}
if ($argv[1] == "--postmaster") {
    postmaster();
    die;
}
if ($argv[1] == "--bcc") {
    recipient_bcc_maps();
    recipient_bcc_maps_build();
    sender_bcc_maps();
    sender_bcc_maps_build();
    shell_exec("{$GLOBALS["postfix"]} reload >/dev/null 2>&1");
    die;
}
if ($argv[1] == "--recipient-canonical") {
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);
}
Esempio n. 8
0
}
$pid = getmypid();
events("running {$pid} ");
file_put_contents($pidfile, $pid);
events("Memory: " . round(memory_get_usage() / 1024 / 1000, 2) . " after unix() declaration line: " . __LINE__);
$sock = new sockets();
events("Memory: " . round(memory_get_usage() / 1024 / 1000, 2) . " after sockets() declaration line: " . __LINE__);
$users = new settings_inc();
events("Memory: " . round(memory_get_usage() / 1024 / 1000, 2) . " after usersMenus() declaration line: " . __LINE__);
$_GET["server"] = $users->hostname;
$_GET["IMAP_HACK"] = array();
$GLOBALS["ZARAFA_INSTALLED"] = $users->ZARAFA_INSTALLED;
$GLOBALS["AMAVIS_INSTALLED"] = $users->AMAVIS_INSTALLED;
$GLOBALS["POP_HACK"] = array();
$GLOBALS["SMTP_HACK"] = array();
$GLOBALS["PHP5_BIN"] = LOCATE_PHP5_BIN2();
$GLOBALS["LN_BIN"] = $unix->find_program("ln");
$GLOBALS["PostfixNotifyMessagesRestrictions"] = $sock->GET_INFO("PostfixNotifyMessagesRestrictions");
$GLOBALS["PopHackEnabled"] = $sock->GET_INFO("PopHackEnabled");
$GLOBALS["PopHackCount"] = $sock->GET_INFO("PopHackCount");
$GLOBALS["DisableMailBoxesHack"] = $sock->GET_INFO("DisableMailBoxesHack");
$GLOBALS["EnableArticaSMTPStatistics"] = $sock->GET_INFO("EnableArticaSMTPStatistics");
if (!is_numeric($GLOBALS["EnableArticaSMTPStatistics"])) {
    $GLOBALS["EnableArticaSMTPStatistics"] = 1;
}
if (!is_numeric($GLOBALS["DisableMailBoxesHack"])) {
    $GLOBALS["DisableMailBoxesHack"] = 0;
}
if ($GLOBALS["PopHackEnabled"] == null) {
    $GLOBALS["PopHackEnabled"] = 1;
}
Esempio n. 9
0
function reconfigure(){
	if($GLOBALS["VERBOSE"]){writelogs("starting reconfigure()",__FUNCTION__,__FILE__,__LINE__);}
	$unix=new unix();
	$sock=new sockets();
	if($GLOBALS["VERBOSE"]){writelogs("->clladp()",__FUNCTION__,__FILE__,__LINE__);}
	$ldap=new clladp();
	$smbpasswd=$unix->find_program("smbpasswd");
	if($GLOBALS["VERBOSE"]){writelogs("smbpasswd=$smbpasswd -->samba()",__FUNCTION__,__FILE__,__LINE__);}
	$samba=new samba();
	$net=$unix->LOCATE_NET_BIN_PATH();	
	$ldap_passwd=$ldap->ldap_password;
	$EnableSambaActiveDirectory=$sock->GET_INFO("EnableSambaActiveDirectory");
	$EnableSambaRemoteLDAP=$sock->GET_INFO("EnableSambaRemoteLDAP");
	
	if($EnableSambaRemoteLDAP==1){
		$SambaRemoteLDAPInfos=unserialize(base64_decode($sock->GET_INFO("SambaRemoteLDAPInfos")));
		$ldap_passwd=$SambaRemoteLDAPInfos["user_dn_password"];
	}
	

	
	if($EnableSambaActiveDirectory==1){activedirectory();}
	CheckFilesAndDirectories();
	FixsambaDomainName();
	echo "Starting......: Samba building main configuration...\n";
	@file_put_contents("/etc/samba/smb.conf",$samba->BuildConfig());
	
	shell_exec("$smbpasswd -w $ldap_passwd");

	SambaAudit();
	fixEtcHosts();
	
	$master_password=$samba->GetAdminPassword("administrator");
	$SambaEnableEditPosixExtension=$sock->GET_INFO("SambaEnableEditPosixExtension");
	if($SambaEnableEditPosixExtension==1){
		$cmd="$net idmap secret {$samba->main_array["global"]["workgroup"]} \"$ldap_passwd\" >/dev/null 2>&1 &";
		shell_exec($cmd);
		$cmd="$net idmap secret alloc \"$ldap_passwd\" >/dev/null 2>&1 &";
		shell_exec($cmd);
	}
	
	if($EnableSambaActiveDirectory==1){kinit();}
	$unix->THREAD_COMMAND_SET(LOCATE_PHP5_BIN2()." ".__FILE__." --check-dirs");
	$unix->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --samba-reconfigure");
	reload();
	
	
	}
Esempio n. 10
0
function _CheckSambaConfig()
{
    if (!is_file("/etc/artica-postfix/settings/Daemons/SambaSMBConf")) {
        @copy("/etc/samba/smb.conf", "/etc/artica-postfix/settings/Daemons/SambaSMBConf");
        $EXEC_NICE = EXEC_NICE();
        shell_exec("{$EXEC_NICE}" . LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all-settings");
    }
}
Esempio n. 11
0
function CleanQueues()
{
    $unix = new unix();
    if (!$GLOBALS["FORCE"]) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $oldpid = @file_get_contents($pidfile);
        if ($unix->process_exists($oldpid)) {
            echo "CleanQueues() already executed pid {$oldpid}\n";
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $sql = "SELECT * FROM postqueue ORDER BY zDate";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
        return;
    }
    $count = mysql_num_rows($results);
    if ($count == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "No line\n";
        }
        return;
    }
    $postcat = $unix->find_program("postcat");
    $c = '';
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $hostname = $ligne["instance"];
        if ($hostname != "master") {
            $c = " -c /etc/postfix-{$hostname}";
        }
        $msgid = $ligne["msgid"];
        $results2 = array();
        if ($GLOBALS["VERBOSE"]) {
            echo "Check \"{$msgid}\"\n";
        }
        exec("{$postcat} -qh {$msgid} {$c} 2>&1", $results2);
        if (preg_match("#No such file#", $results2[0])) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$msgid} DIE\n";
            }
            $sql = "DELETE FROM postqueue WHERE msgid='{$msgid}'";
            $q->QUERY_SQL($sql, "artica_events");
            if (!$q->ok) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "Error \"{$q->mysql_error}\"\n";
                }
            }
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "{$msgid} LIVE\n";
        }
    }
    $unix->THREAD_COMMAND_SET(LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.postfix.vip.php --queue");
}
Esempio n. 12
0
        $unix = new unix();
        if ($GLOBALS["VERBOSE"]) {
            echo " --> /etc/hosts {$ComputerRealName} -> {$ip}\n";
        }
        $unix->del_EtcHosts($ip);
        $dns = new pdns($GLOBALS["domain"]);
        writelogs("EditIPName -> ComputerRealName=`{$ComputerRealName}` {$ip} {$MAC}", __FUNCTION__, __FILE__, __LINE__);
        if (trim($ComputerRealName) != null) {
            $dns->EditIPName(strtolower($ComputerRealName), $ip, 'A', $MAC);
        }
        $GLOBALS["FIXIPHOST"] = true;
    }
}
if ($GLOBALS["FIXIPHOST"]) {
    writelogs("-> exec.samba.php --fix-etc-hosts", __FUNCTION__, __FILE__, __LINE__);
    shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.samba.php --fix-etc-hosts");
}
events("Set content cache has {$md5}", "main", __LINE__);
$sock->SET_INFO('DHCPLeaseMD5', $md5);
function events($text, $function, $line)
{
    writelogs($text, $function, __FILE__, $line);
}
function Changed()
{
    if (!is_file("/var/lib/dhcp3/dhcpd.leases")) {
        if ($GLOBALS["VERBOSE"]) {
            echo " --> unable to stat /var/lib/dhcp3/dhcpd.leases\n";
        }
        return false;
    }
Esempio n. 13
0
function execute()
{
    $nice = EXEC_NICE();
    if (is_file(dirname(__FILE__) . "/exec.sarg.gilou.php")) {
        events("Executing exec.sarg.gilou.php instead...");
        shell_exec($nice . LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.sarg.gilou.php --exec");
        return;
    }
    $sock = new sockets();
    $SargOutputDir = $sock->GET_INFO("SargOutputDir");
    if ($SargOutputDir == null) {
        $SargOutputDir = "/var/www/html/squid-reports";
    }
    $nice = EXEC_NICE();
    $unix = new unix();
    $today = date("d/m/Y");
    $sarg_bin = $unix->find_program("sarg");
    if (!is_file($sarg_bin)) {
        sarg_admin_events("Fatal, unable to locate sarg binary, aborting...", __FUNCTION__, __FILE__, __LINE__, "sarg");
        return;
    }
    events("Building settings..");
    buildconf();
    $usersauth = false;
    $squid = new squidbee();
    if ($squid->LDAP_AUTH == 1) {
        $usersauth = true;
    }
    if ($squid->LDAP_EXTERNAL_AUTH == 1) {
        $usersauth = true;
    }
    if (!is_file("/etc/squid/exclude_codes")) {
        @file_put_contents("/etc/squid/exclude_codes", "\nNONE/400\n");
    }
    @mkdir("{$SargOutputDir}", 0755, true);
    $u = " -i ";
    $cmd = "{$nice}{$sarg_bin} -d {$today}-{$today} {$u}-f /etc/squid3/sarg.conf -l /var/log/squid/access.log -o \"{$SargOutputDir}\" -x -z 2>&1";
    $t1 = time();
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$cmd}\n";
    sargevents("execute(): {$cmd}");
    exec($cmd, $results);
    while (list($index, $line) = each($results)) {
        if (preg_match("#SARG: No records found#", $line)) {
            events("No records found");
            $subject_add = "(No records found)";
        }
        if (preg_match("#SARG:\\s+.+?mixed records format#", $line)) {
            send_email_events("SARG: Error, squid was reloaded", "It seems that there is a mixed log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to http access mode.\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
            shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
            shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
            shell_exec("/etc/init.d/auth-tail restart >/dev/null 2>&1");
            shell_exec("/etc/init.d/cache-tail restart >/dev/null 2>&1");
            return;
        }
        if (preg_match("#SARG:\\s+.+?enregistrements de plusieurs formats#", $line)) {
            send_email_events("SARG: Error, squid was reloaded", "It seems that there is a mixed log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to http access mode.\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
            shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
            shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
            shell_exec("/etc/init.d/auth-tail restart >/dev/null 2>&1");
            shell_exec("/etc/init.d/cache-tail restart >/dev/null 2>&1");
            return;
        }
        if (preg_match("#SARG.+?Unknown input log file format#", $line)) {
            send_email_events("SARG: \"Unknown input log file format\", squid was reloaded", "It seems that there is a input log file format log file format detected in squid\n\t\t\tThis reason is Artica change squid log format from orginial to log_fqn on, this will be disabled\n\t\t\tIn this case, the log will be moved and squid will be reloaded \n\t\t\tin order to build a full log file with only one log format.\n\t\t\t\n" . @implode("\n", $results), "proxy");
            shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --reconfigure");
            shell_exec($unix->LOCATE_SQUID_BIN() . " -k rotate");
            shell_exec("/etc/init.d/auth-tail restart >/dev/null 2>&1");
            shell_exec("/etc/init.d/cache-tail restart >/dev/null 2>&1");
            return;
        }
    }
    $NICE = EXEC_NICE();
    $unix = new unix();
    $lighttpd_user = $unix->APACHE_SRC_ACCOUNT();
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, lighttpd user: {$lighttpd_user}\n";
    $chown = $unix->find_program("chown");
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]},{$chown} -R {$lighttpd_user}:{$lighttpd_user} {$SargOutputDir}/*\n";
    exec("{$chown} -R {$lighttpd_user}:{$lighttpd_user} {$SargOutputDir}/* >/dev/null 2>&1", $results2);
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]},\n" . @implode("\n" . $results2) . "\n";
    shell_exec("{$nohup} {$php} " . __FILE__ . " --backup >/dev/null 2>&1 &");
    $t2 = time();
    $distanceOfTimeInWords = distanceOfTimeInWords($t1, $t2);
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$distanceOfTimeInWords}\n";
    events("Statistics generated ({$distanceOfTimeInWords})");
    if ($GLOBALS["VERBOSE"]) {
        echo "SARG: Statistics generated ({$distanceOfTimeInWords})\n\n";
        echo @implode("\n", $results) . "\n";
    }
    status(true);
    sarg_admin_events("SARG: Statistics generated ({$distanceOfTimeInWords}) {$subject_add}", "Command line:\n-----------\n{$cmd}\n" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "sarg");
}
function NMAP_SCAN($value)
{
    $value = base64_decode($value);
    $EXEC_NICE = EXEC_NICE();
    $unix = new unix();
    $tmpstr = $unix->FILE_TEMP();
    @unlink("/usr/share/artica-postfix/ressources/logs/nmap.log");
    $cmd = $EXEC_NICE . LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.scan-networks.php >{$tmpstr} 2>&1";
    events("running {$cmd}", __FUNCTION__, __FILE__, __LINE__);
    $t1 = time();
    shell_exec($cmd);
    $t2 = time();
    $time_duration = distanceOfTimeInWords($t1, $t2);
    events("success executing exec.scan-networks.php ", __FUNCTION__, __FILE__, __LINE__);
    send_email_events("success executing network scanning ({$time_duration})", @file_get_contents("/usr/share/artica-postfix/ressources/logs/nmap.log"), "CLOUD");
    @unlink($tmpstr);
    return true;
}
Esempio n. 15
0
function zarafa_hash()
{
    if (isset($_GET["rebuild"])) {
        @unlink("/etc/artica-postfix/zarafa-export.db");
    }
    if (!is_file("/etc/artica-postfix/zarafa-export.db")) {
        $cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.zarafa.build.stores.php --export-hash";
        shell_exec($cmd);
    }
    echo "<articadatascgi>" . @file_get_contents("/etc/artica-postfix/zarafa-export.db") . "</articadatascgi>";
}
Esempio n. 16
0
function zarafa_server(){
	
	
	
	
	if(!$GLOBALS["CLASS_USERS"]->ZARAFA_INSTALLED){
		if($GLOBALS["VERBOSE"]){echo __FUNCTION__." not installed\n";}
		return null;
	}	
	
	$enabled=1;
	$pid_path="/var/run/zarafa-server.pid";
	$master_pid=trim(@file_get_contents($pid_path));

	$l[]="[APP_ZARAFA_SERVER]";
	$l[]="service_name=APP_ZARAFA_SERVER";
	$l[]="master_version=".$GLOBALS["CLASS_UNIX"]->ZARAFA_VERSION();
	$l[]="service_cmd=zarafa";	
	$l[]="service_disabled=$enabled";
	$l[]="pid_path=$pid_path";
	$l[]="remove_cmd=--zarafa-remove";
	$l[]="watchdog_features=1";
	$l[]="family=mailbox";
	
	if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){
		WATCHDOG("APP_ZARAFA","zarafa");
		$l[]="running=0\ninstalled=1";$l[]="";
		
	}else{
		$l[]="running=1";		
	}			
	
	

	$meme=GetMemoriesOf($master_pid);
	$l[]=$meme;
	$l[]="";
	$l[]="[APP_ZARAFA]";
	$l[]="service_name=APP_ZARAFA";
	$l[]="master_version=".$GLOBALS["CLASS_UNIX"]->ZARAFA_VERSION();
	$l[]="family=mailbox";
	$l[]="service_cmd=zarafa";	
	$l[]="service_disabled=$enabled";
	$l[]="pid_path=$pid_path";
	$l[]="remove_cmd=--zarafa-remove";
	$l[]="watchdog_features=1";

	if(!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)){
		WATCHDOG("APP_ZARAFA","zarafa");
		$l[]="running=0\ninstalled=1";$l[]="";
		return implode("\n",$l);
		return;
	}		
	
	if(!$GLOBALS["DISABLE_WATCHDOG"]){
		$nohup=$GLOBALS["CLASS_UNIX"]->find_program("nohup")." ";
		if($GLOBALS["PHP5"]==null){$GLOBALS["PHP5"]=LOCATE_PHP5_BIN2();}
		$cmd=trim($nohup.$GLOBALS["PHP5"]." ".dirname(__FILE__)."/exec.zarafa.build.stores.php --export-hash >/dev/null 2>&1 &");
		events("running $cmd",__FUNCTION__,__LINE__);
		shell_exec($cmd);
	}
	$l[]="running=1";
	$l[]=$meme;
	$l[]="";	
	return implode("\n",$l);return;		
	}	
Esempio n. 17
0
function OPENGOO_INSTALL($servername, $root, $hash = array())
{
    $srcfolder = "/usr/local/share/artica/opengoo";
    $GLOBALS["ADDLOG"] = "{$GLOBALS["ARTICALOGDIR"]}/{$servername}.log";
    $sql_file = "/usr/share/artica-postfix/bin/install/opengoo/opengoo.sql";
    if ($root == null) {
        events("Starting install opengoo Unable to stat root dir");
        return false;
    }
    if (!is_dir($srcfolder)) {
        events("Starting install opengoo Unable to stat SRC");
        return false;
    }
    $user = $hash["wwwmysqluser"][0];
    $mysql_password = $hash[strtolower("WWWMysqlPassword")][0];
    $appli_user = $hash["wwwappliuser"][0];
    $appli_password = $hash["wwwapplipassword"][0];
    $wwwsslmode = $hash["wwwsslmode"][0];
    $server_database = str_replace(".", "_", $servername);
    $server_database = str_replace(" ", "_", $server_database);
    $server_database = str_replace("-", "_", $server_database);
    events("Starting install opengoo sub-system mysql database {$server_database}...");
    if ($user == null) {
        events("Starting install opengoo Unable to stat Mysql username");
        return false;
    }
    if ($mysql_password == null) {
        events("Starting install opengoo Unable to stat Mysql password");
        return false;
    }
    @mkdir($root, 0755, true);
    events("Starting install opengoo sub-system mysql database {$server_database}...");
    $q = new mysql();
    if (!$q->DATABASE_EXISTS($server_database)) {
        $q->CREATE_DATABASE($server_database);
    }
    if (!$q->DATABASE_EXISTS($server_database)) {
        events("Starting install opengoo unable to create MYSQL Database");
        return false;
    }
    events("Starting setting permissions on Database with user {$user}");
    $q->PRIVILEGES($user, $mysql_password, $server_database);
    if (!OPENGOO_TEST_FILES($root)) {
        events("Starting install opengoo installing source code");
        shell_exec("/bin/cp -rf {$srcfolder}/* {$root}/");
    }
    $opengoo = new opengoo(null, $server_database);
    if (!OPENGOO_CHECK_TABLES($server_database)) {
        if ($q->mysql_password != null) {
            $password = "******";
        } else {
            events("Starting install opengoo installing tables datas with null password");
        }
        $cmd = "mysql --port={$q->mysql_port} --skip-column-names --database={$server_database} --silent --xml ";
        $cmd = $cmd . " --user={$q->mysql_admin}{$password} <{$sql_file}";
        shell_exec($cmd);
    } else {
        events("Starting install opengo Mysql tables are already installed");
    }
    $sock = new sockets();
    $ApacheGroupWarePort = $sock->GET_INFO("ApacheGroupWarePort");
    events("Starting install opengo SSL={$wwwsslmode}");
    if ($wwwsslmode == "TRUE") {
        $ROOT_URL = "https://{$servername}";
    } else {
        $ROOT_URL = "http://{$servername}:{$ApacheGroupWarePort}";
    }
    $conf = "<?php\n";
    $conf = $conf . "define('DB_ADAPTER', 'mysql');\n";
    $conf = $conf . "define('DB_HOST', '127.0.0.1');\n";
    $conf = $conf . "define('DB_USER', '{$q->mysql_admin}');\n";
    $conf = $conf . "define('DB_PASS', '{$q->mysql_password}');\n";
    $conf = $conf . "define('DB_NAME', '{$server_database}');\n";
    $conf = $conf . "define('DB_PERSIST', true);\n";
    $conf = $conf . "define('TABLE_PREFIX', 'og_');\n";
    $conf = $conf . "define('DB_ENGINE', 'InnoDB');\n";
    $conf = $conf . "define('ROOT_URL', '{$ROOT_URL}');\n";
    $conf = $conf . "define('DEFAULT_LOCALIZATION', 'en_us');\n";
    $conf = $conf . "define('COOKIE_PATH', '/');\n";
    $conf = $conf . "define('DEBUG', false);\n";
    $conf = $conf . "define('SEED', '6eb2551152da5a57576754716397703c');\n";
    $conf = $conf . "define('DB_CHARSET', 'utf8');\n";
    $conf = $conf . "return true;\n";
    $conf = $conf . "?>";
    @file_put_contents("{$root}/config/config.php", $conf);
    $opengoo->DefaultsValues();
    events("updating administrator credentials");
    $opengoo->www_servername = $servername;
    $opengoo->UpdateAdmin($appli_user, $appli_password);
    events("updating company name");
    $ou = $opengoo->get_Organization($servername);
    $opengoo->UpdateCompany($ou);
    $unix = new unix();
    $sock = new sockets();
    sys_THREAD_COMMAND_SET(LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.opengoo.php");
}
Esempio n. 18
0
function status()
{
    exec(LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.status.php --squidguard-http --nowachdog", $results);
    writelogs_framework("/usr/share/artica-postfix/exec.status.php --squidguard-http " . count($results) . " rows", __FUNCTION__, __FILE__, __LINE__);
    echo "<articadatascgi>" . base64_encode(@implode("\n", $results)) . "</articadatascgi>";
}
Esempio n. 19
0
function compile_databases()
{
    $users = new usersMenus();
    $squid = new squidbee();
    $array = $squid->SquidGuardDatabasesStatus();
    $verb = " -d";
    $array = $squid->SquidGuardDatabasesStatus(0);
    if (count($array) > 0) {
        while (list($index, $file) = each($array)) {
            echo "Starting......: squidGuard compiling " . count($array) . " databases\n";
            $file = str_replace(".db", '', $file);
            $textfile = str_replace("/var/lib/squidguard/", "", $file);
            echo "Starting......: squidGuard compiling {$textfile} database " . ($index + 1) . "/" . count($array) . "\n";
            if ($GLOBALS["VERBOSE"]) {
                $verb = " -d";
                echo $users->SQUIDGUARD_BIN_PATH . " {$verb} -C {$file}\n";
            }
            system($users->SQUIDGUARD_BIN_PATH . " -P{$verb} -C {$file}");
        }
    } else {
        echo "Starting......: squidGuard compiling all databases\n";
        if ($GLOBALS["VERBOSE"]) {
            $verb = " -d";
            echo $users->SQUIDGUARD_BIN_PATH . " {$verb} -C all\n";
        }
        system($users->SQUIDGUARD_BIN_PATH . " -P{$verb} -C all");
    }
    $user = GetSquidUser();
    $unix = new unix();
    $chown = $unix->find_program("chown");
    $chmod = $unix->find_program("chmod");
    shell_exec("{$chown} -R {$user} /var/lib/squidguard/*");
    shell_exec("{$chmod} -R 755 /var/lib/squidguard/*");
    system(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --build");
    build();
    KillSquidGuardInstances();
}
Esempio n. 20
0
function ufdbguard_remote()
{
    include_once dirname(__FILE__) . "/ressources/class.ccurl.inc";
    $users = new usersMenus();
    $sock = new sockets();
    $unix = new unix();
    $trace = debug_backtrace();
    if (isset($trace[1])) {
        $called = " called by " . basename($trace[1]["file"]) . " {$trace[1]["function"]}() line {$trace[1]["line"]}";
    }
    $timeFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if ($unix->file_time_min($timeFile) < 5) {
        writelogs("too short time to change settings, aborting {$called}...", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    @unlink($timeFile);
    @file_put_contents($timeFile, time());
    @mkdir("/etc/ufdbguard", null, true);
    $tar = $unix->find_program("tar");
    $RemoteStatisticsApplianceSettings = unserialize(base64_decode($sock->GET_INFO("RemoteStatisticsApplianceSettings")));
    if (!is_numeric($RemoteStatisticsApplianceSettings["SSL"])) {
        $RemoteStatisticsApplianceSettings["SSL"] = 1;
    }
    if (!is_numeric($RemoteStatisticsApplianceSettings["PORT"])) {
        $RemoteStatisticsApplianceSettings["PORT"] = 9000;
    }
    $GLOBALS["REMOTE_SSERVER"] = $RemoteStatisticsApplianceSettings["SERVER"];
    $GLOBALS["REMOTE_SPORT"] = $RemoteStatisticsApplianceSettings["PORT"];
    $GLOBALS["REMOTE_SSL"] = $RemoteStatisticsApplianceSettings["SSL"];
    if ($GLOBALS["REMOTE_SSL"] == 1) {
        $refix = "https";
    } else {
        $refix = "http";
    }
    $DenyUfdbWriteConf = $sock->GET_INFO("DenyUfdbWriteConf");
    if (!is_numeric($DenyUfdbWriteConf)) {
        $DenyUfdbWriteConf = 0;
    }
    $baseUri = "{$refix}://{$GLOBALS["REMOTE_SSERVER"]}:{$GLOBALS["REMOTE_SPORT"]}/ressources/databases";
    if ($DenyUfdbWriteConf == 0) {
        $uri = "{$baseUri}/ufdbGuard.conf";
        $curl = new ccurl($uri, true);
        if ($curl->GetFile("/tmp/ufdbGuard.conf")) {
            @file_put_contents("/etc/ufdbguard/ufdbGuard.conf", @file_get_contents("/tmp/ufdbGuard.conf"));
            @file_put_contents("/etc/squid3/ufdbGuard.conf", @file_get_contents("/tmp/ufdbGuard.conf"));
        } else {
            ufdbguard_admin_events("Failed to download ufdbGuard.conf aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "global-compile");
        }
    }
    $uri = "{$baseUri}/blacklist.tar.gz";
    $curl = new ccurl($uri, true);
    if ($curl->GetFile("/tmp/blacklist.tar.gz")) {
        $cmd = "{$tar} -xf /tmp/blacklist.tar.gz -C /var/lib/squidguard/";
        writelogs($cmd, __FUNCTION__, __FILE__, __LINE__);
        shell_exec($cmd);
    } else {
        ufdbguard_admin_events("Failed to download blacklist.tar.gz aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "global-compile");
    }
    $uri = "{$baseUri}/ftpunivtlse1fr.tar.gz";
    $curl = new ccurl($uri, true);
    if ($curl->GetFile("/tmp/ftpunivtlse1fr.tar.gz")) {
        $cmd = "{$tar} -xf /tmp/ftpunivtlse1fr.tar.gz -C /var/lib/ftpunivtlse1fr/";
        writelogs($cmd, __FUNCTION__, __FILE__, __LINE__);
        shell_exec($cmd);
    } else {
        ufdbguard_admin_events("Failed to download ftpunivtlse1fr.tar.gz aborting `{$curl->error}`", __FUNCTION__, __FILE__, __LINE__, "global-compile");
    }
    Dansguardian_remote();
    CheckPermissions();
    ufdbguard_schedule();
    if ($unix->Ufdbguard_remote_srvc_bool()) {
        ufdbguard_admin_events("Using a remote UfdbGuard service, aborting", __FUNCTION__, __FILE__, __LINE__, "config");
        return;
    }
    ufdbguard_admin_events("Service will be rebuiled and restarted", __FUNCTION__, __FILE__, __LINE__, "config");
    build_ufdbguard_HUP();
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    if (is_file($GLOBALS["SQUIDBIN"])) {
        echo "Starting......: " . date("H:i:s") . " Squid reloading service\n";
        shell_exec("{$nohup} {$php5} " . basename(__FILE__) . "/exec.squid.php --reconfigure-squid >/dev/null 2>&1");
    }
    $datas = @file_get_contents("/etc/ufdbguard/ufdbGuard.conf");
    send_email_events("SquidGuard/ufdbGuard/Dansguardian rules was rebuilded", basename(__FILE__) . "\nFunction:" . __FUNCTION__ . "\nLine:" . __LINE__ . "\n" . "This is new configuration file of the squidGuard/ufdbGuard:\n-------------------------------------\n{$datas}", "proxy");
    shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.c-icap.php --maint-schedule");
}
Esempio n. 21
0
function backup($ID)
{
    $date_start = time();
    $sock = new sockets();
    $q = new mysql();
    $unix = new unix();
    $users = new usersMenus();
    $GLOBALS["RESOURCE_MOUNTED"] = true;
    $sql = "SELECT * FROM backup_schedules WHERE ID='{$ID}'";
    if ($GLOBALS["VERBOSE"]) {
        backup_events($ID, "initialization", "{$sql}", __LINE__);
    }
    $mount_path = "/opt/artica/mounts/backup/{$ID}";
    if (!$q->TABLE_EXISTS("backup_storages", "artica_backup", true)) {
        $q->BuildTables();
        if (!$q->TABLE_EXISTS("backup_storages", "artica_backup", true)) {
            backup_events($ID, "initialization", "ERROR, backup_storages, no such table", __LINE__);
            return;
        }
    }
    $servername = $users->fqdn;
    $servername = str_replace('.(none)', "", $servername);
    $servername = str_replace(')', "", $servername);
    $servername = str_replace('(', "", $servername);
    $GLOBALS["MYSERVERNAME"] = $servername;
    $ExecBackupDeadAfterH = $sock->GET_INFO("ExecBackupDeadAfterH");
    if (!is_numeric($ExecBackupDeadAfterH)) {
        $ExecBackupDeadAfterH = 2;
    }
    if ($ExecBackupDeadAfterH < 2) {
        $ExecBackupDeadAfterH = 2;
    }
    $ExecBackupDeadAfterH = $ExecBackupDeadAfterH * 60;
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    if (!$q->ok) {
        send_email_events("Backup Task {$ID}:: Mysql database error !", "Aborting backup\n{$q->mysql_error}", "backup");
        backup_events($ID, "initialization", "ERROR, Mysql database error\n{$q->mysql_error}", __LINE__);
        return false;
    }
    if (!$GLOBALS["ONNLY_MOUNT"]) {
        $pid = $ligne["pid"];
        if ($unix->process_exists($pid)) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($time > $ExecBackupDeadAfterH) {
                send_email_events("Backup Task {$ID}:: Already instance {$pid} running since {$time}Mn", "The old process was killed and a new backup task will be performed\nstatus:\n\n{$unix->proc_status}", "backup");
            } else {
                send_email_events("Backup Task {$ID}:: Already instance {$pid} running since {$time}Mn", "Aborting backup\n{$unix->proc_status}", "backup");
                backup_events($ID, "initialization", "ERROR, Already instance {$pid} running since {$time}Mn", $unix->proc_status);
                return false;
            }
        }
    }
    $sql = "UPDATE backup_schedules set pid='" . getmypid() . "' WHERE ID='{$ID}'";
    $q->QUERY_SQL($sql, "artica_backup");
    $ressources = unserialize(base64_decode($ligne["datasbackup"]));
    if (count($ressources) == 0) {
        backup_events($ID, "initialization", "ERROR,No source specified");
        send_email_events("Backup Task {$ID}::  No source specified", "Aborting backup", "backup");
        return false;
    }
    if ($ressources["OPTIONS"]["STOP_IMAP"] == 1) {
        $GLOBALS["NO_STOP_CYRUS"] = " --no-cyrus-stop";
    }
    $backup = new backup_protocols();
    $resource_type = $ligne["resource_type"];
    $pattern = $ligne["pattern"];
    $first_ressource = $backup->extractFirsRessource($ligne["pattern"]);
    $container = $ligne["container"];
    backup_events($ID, "initialization", "resource: {$resource_type} -> {$first_ressource}", __LINE__);
    if ($resource_type == null) {
        backup_events($ID, "initialization", "ERROR,No resource specified");
        send_email_events("Backup Task {$ID}:: No resource specified !", "Aborting backup", "backup");
        return false;
    }
    if ($resource_type == "smb") {
        $GLOBALS["CAN_CLEAN_CONTAINERS"] = true;
        $mounted_path_sep = "/";
        if (!mount_smb($pattern, $ID, true)) {
            backup_events($ID, "initialization", "ERROR,{$first_ressource} unable to mount mount_smb()", __LINE__);
            send_email_events("Backup Task {$ID}::  resource: {$first_ressource} unable to mount", "Aborting backup", "backup");
            return false;
        }
        $GLOBALS["PCOPY"] = true;
    }
    if ($resource_type == "ssh") {
        $GLOBALS["CAN_CLEAN_CONTAINERS"] = true;
        $mounted_path_sep = "/";
        if (!mount_ssh($pattern, $ID, true)) {
            backup_events($ID, "initialization", "ERROR,{$first_ressource} unable to mount mount_ssh()", __LINE__);
            send_email_events("Backup Task {$ID}::  resource: {$first_ressource} unable to mount to remote ssh service", "Aborting backup", "backup");
            return false;
        }
        $GLOBALS["PCOPY"] = true;
    }
    if ($resource_type == "usb") {
        $GLOBALS["CAN_CLEAN_CONTAINERS"] = true;
        $mounted_path_sep = "/";
        if (!mount_usb($pattern, $ID, true)) {
            backup_events($ID, "initialization", "ERROR,{$first_ressource} unable to mount mount_usb()", __LINE__);
            send_email_events("Backup Task {$ID}::  resource: {$first_ressource} unable to mount", "Aborting backup", "backup");
            return false;
        }
        backup_events($ID, "initialization", "INFO, using external device trough USB", __LINE__);
        $GLOBALS["PCOPY"] = true;
    }
    if ($resource_type == "rsync") {
        $mounted_path_sep = null;
        $mount_path = null;
        $GLOBALS["RESOURCE_MOUNTED"] = false;
        $GLOBALS["USE_RSYNC"] = true;
        $GLOBALS["NO_UMOUNT"] = true;
        $GLOBALS["CAN_CLEAN_CONTAINERS"] = false;
        if (!mount_rsync($pattern, $ID, true)) {
            backup_events($ID, "initialization", "ERROR,{$first_ressource} unable to connect");
            send_email_events("Backup Task {$ID}::  resource: {$first_ressource} unable to connect", "Aborting backup", "backup");
            return false;
        } else {
            backup_events($ID, "initialization", "INFO,{$first_ressource} connect success");
        }
    }
    if ($resource_type == "automount") {
        $mounted_path_sep = "/";
        $mount_path = $first_ressource;
        $GLOBALS["RESOURCE_MOUNTED"] = false;
        $GLOBALS["USE_RSYNC"] = true;
        $GLOBALS["NO_UMOUNT"] = true;
        $GLOBALS["CAN_CLEAN_CONTAINERS"] = true;
        $GLOBALS["MOUNTED_PATH_FINAL"] = $first_ressource;
        CheckCommandLineCopy();
        if (!mount_automount($pattern, $ID, true)) {
            backup_events($ID, "initialization", "ERROR,{$first_ressource} unable to connect");
            send_email_events("Backup Task {$ID}::  resource: {$first_ressource} unable to connect", "Aborting backup", "backup");
            return false;
        }
        backup_events($ID, "initialization", "INFO,{$first_ressource} connect success");
        $GLOBALS["PCOPY"] = true;
    }
    if ($resource_type == "local") {
        $mounted_path_sep = "/";
        $mount_path = $first_ressource;
        $GLOBALS["RESOURCE_MOUNTED"] = false;
        $GLOBALS["CAN_CLEAN_CONTAINERS"] = true;
        $GLOBALS["USE_RSYNC"] = true;
        $GLOBALS["NO_UMOUNT"] = true;
        $GLOBALS["MOUNTED_PATH_FINAL"] = $first_ressource;
        CheckCommandLineCopy();
        if (!is_dir($first_ressource)) {
            backup_events($ID, "initialization", "{$first_ressource} directory doesn't exsits, create it..", __LINE__);
            @mkdir($first_ressource, 0755, true);
        }
        if (!is_dir($first_ressource)) {
            backup_events($ID, "initialization", "{$first_ressource} no such directory permission denied", __LINE__);
            send_email_events("Backup Task {$ID}::  resource: {$first_ressource} no such directory", "Aborting backup", "backup");
            return false;
        }
        backup_events($ID, "initialization", "INFO,{$first_ressource} success");
        $GLOBALS["PCOPY"] = true;
    }
    if ($GLOBALS["ONLY_TESTS"]) {
        if ($GLOBALS["RESOURCE_MOUNTED"]) {
            writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:umount {$mount_path}", __FUNCTION__, __FILE__, __LINE__);
            exec("umount -l {$mount_path}");
        }
        writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]: terminated...", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    if ($GLOBALS["ONNLY_MOUNT"]) {
        return $mount_path;
    }
    if ($container == "daily") {
        backup_events($ID, "initialization", "INFO, Daily container", __LINE__);
        $DirectoryContainer = "backup." . date('Y-m-d') . "/{$servername}";
        $GLOBAL["BACKUP_MEMORY_SQL"]["CONTAINER"] = $DirectoryContainer;
        $mount_path_final = $mount_path . $mounted_path_sep . $DirectoryContainer;
    } else {
        backup_events($ID, "initialization", "INFO, Weekly container", __LINE__);
        $DirectoryContainer = "backup." . date('Y-W') . "/{$servername}";
        $GLOBAL["BACKUP_MEMORY_SQL"]["CONTAINER"] = $DirectoryContainer;
        $mount_path_final = $mount_path . $mounted_path_sep . $DirectoryContainer;
    }
    if ($GLOBALS["DEBUG"]) {
        $cmd_verb = " --verbose";
        writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]: Verbose mode detected", __FUNCTION__, __FILE__, __LINE__);
    }
    @mkdir($mount_path_final, 0755, true);
    if (!$GLOBALS["NO_STANDARD_BACKUP"]) {
        $GLOBALS["MOUNTED_PATH_FINAL"] = $mount_path_final;
        $WhatToBackup_ar = null;
        $BACKUP_WWW_ALREADY_DONE = array();
        $BACKUP_WEBGET_ALREADY_DONE = array();
        $BACKUP_INSTANCES_ALREADY_DONE = array();
        while (list($num, $WhatToBackup) = each($ressources)) {
            if (is_array($WhatToBackup)) {
                $WhatToBackup_ar = implode(",", $WhatToBackup);
                backup_events($ID, "initialization", "INFO, WhatToBackup Array = {$WhatToBackup_ar}", __LINE__);
                continue;
            }
            if ($WhatToBackup == "all") {
                backup_events($ID, "initialization", "INFO, Backup starting Running macro all cyrus, mysql, LDAP, Artica...", __LINE__);
                send_email_events("Backup Task {$ID}:: Backup starting Running macro all ", "Backup is running", "backup");
                if ($users->cyrus_imapd_installed) {
                    backup_events($ID, "initialization", "INFO, cyrus-imapd mailboxes processing");
                    backup_cyrus($ID);
                }
                backup_events($ID, "initialization", "INFO, LDAP Database processing", __LINE__);
                backup_ldap($ID);
                backup_events($ID, "initialization", "INFO, MySQL Database processing", __LINE__);
                backup_mysql($ID, 0);
                backup_events($ID, "initialization", "INFO, Restarting MySQL service...", __LINE__);
                mysql_admin_mysql(0, "Restarting mysql service.", null, __FILE__, __LINE__);
                shell_exec("/etc/init.d/mysql restart");
                backup_events($ID, "initialization", "INFO, Artica settings processing", __LINE__);
                backup_artica($ID);
                if ($users->ZARAFA_INSTALLED) {
                    if ($sock->GET_INFO("ZarafaStoreOutside") == 1) {
                        backup_events($ID, "initialization", "INFO, Zarafa external attachments processing...");
                        backup_ZarafaOutside($ID);
                    }
                }
                backup_events($ID, "initialization", "continue to next process", __LINE__);
                continue;
            }
            if (preg_match("#MYSQLINSTANCE:([0-9]+)#", $WhatToBackup, $re)) {
                $instance_id = $re[1];
                backup_events($ID, "initialization", "INFO, Backup starting backup MySQL instance Number:{$instance_id}", __LINE__);
                if ($instance_id > 0) {
                    if (!isset($BACKUP_INSTANCES_ALREADY_DONE[$instance_id])) {
                        backup_mysql($ID, $instance_id);
                        $BACKUP_INSTANCES_ALREADY_DONE[$instance_id] = true;
                    }
                }
                continue;
            }
            if (preg_match("#FREEWEB:(.+)#", $WhatToBackup, $re)) {
                $sitename = $re[1];
                backup_events($ID, "initialization", "INFO, Backup starting backup Website  {$sitename}", __LINE__);
                if (!isset($BACKUP_WWW_ALREADY_DONE[$sitename])) {
                    backup_freewebs($ID, $sitename);
                    $BACKUP_INSTANCES_ALREADY_DONE[$sitename] = true;
                }
                continue;
            }
            if (preg_match("#WEBGET:(.+)#", $WhatToBackup, $re)) {
                if (!isset($BACKUP_WEBGET_ALREADY_DONE[$re[1]])) {
                    $arr = unserialize(base64_decode($re[1]));
                    if (!is_array($arr)) {
                        backup_events($ID, "initialization", "ERROR, WEBGET `{$re[1]}` is not an array...", __LINE__);
                        continue;
                    }
                    backup_events($ID, "initialization", "INFO, Backup remote Artica FreeWebs Website {$arr["RemoteArticaSite"]} from source {$arr["RemoteArticaServer"]}", __LINE__);
                    backup_webget($ID, $arr);
                }
                continue;
            }
            backup_events($ID, "initialization", "INFO, `{$WhatToBackup}` could not understood", __LINE__);
        }
    }
    $sql = "SELECT * FROM backup_folders WHERE taskid={$ID}";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        if (strpos($q->mysql_error, "gone away")) {
            backup_events($ID, "personal", "ERROR, mysql {$q->mysql_error} Restarting MySQL server (Patch p.20130807)", __LINE__);
            mysql_admin_mysql(0, "Restarting mysql service.", $q->mysql_error, __FILE__, __LINE__);
            shell_exec("/etc/init.d/mysql restart");
            $q = new mysql();
            $results = $q->QUERY_SQL($sql, "artica_backup");
        }
    }
    if (!$q->ok) {
        backup_events($ID, "personal", "ERROR, mysql {$q->mysql_error}", __LINE__);
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $dd1 = time();
        if ($ligne["recursive"] == 1) {
            $recursive = " --recursive";
        } else {
            $recursive = null;
        }
        $path = trim(base64_decode($ligne["path"]));
        if (!is_dir($path)) {
            backup_events($ID, "personal", "ERROR, [{$path}] no such file or directory", __LINE__);
            continue;
        }
        backup_events($ID, "personal", "INFO, Backup starting for {$path}", __LINE__);
        send_email_events("Backup Task {$ID}:: Backup starting {$path}", "Backup is running for path {$path}", "backup");
        backup_mkdir($path);
        $results = backup_copy($path, $path, $ID);
        $calculate = distanceOfTimeInWords($dd1, time());
        backup_events($ID, "personal", "INFO, Backup finish for {$path}\n{$results} {$calculate}", __LINE__);
    }
    writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]: Calculate directory size on {$mount_path_final}", __FUNCTION__, __FILE__, __LINE__);
    $du = $unix->find_program("du");
    $dut1 = time();
    $nice = $unix->EXEC_NICE();
    $cmd = "{$nice}{$du} -s {$mount_path_final}";
    exec($cmd, $du_results);
    $calculate = distanceOfTimeInWords($dut1, time());
    $BackupSize = 0;
    if (preg_match("#^([0-9]+)\\s+#", @implode("", $du_results), $re)) {
        $BackupSize = $re[1];
        backup_events($ID, "initialization", "INFO, backup size {$BackupSize} bytes time:{$calculate}", __LINE__);
    }
    if ($GLOBALS["CAN_CLEAN_CONTAINERS"]) {
        backup_events($ID, "initialization", "INFO, cleaning containers....", __LINE__);
        CleanContainers($ID, $mount_path_final);
    } else {
        backup_events($ID, "initialization", "INFO, cannot clean containers, check protocols....", __LINE__);
    }
    $GLOBAL["BACKUP_MEMORY_SQL"]["mount_path_final"] = $mount_path_final;
    $zmd5 = md5("{$GLOBAL["BACKUP_MEMORY_SQL"]["CONTAINER"]}{$GLOBALS["MYSERVERNAME"]}");
    $cnx_params = addslashes(base64_encode(serialize($GLOBAL["BACKUP_MEMORY_SQL"])));
    $sql = "INSERT IGNORE INTO backup_storages (`taskid`,`size`,`cnx_params`,`zmd5`) VALUES('{$ID}','{$BackupSize}','{$cnx_params}','{$zmd5}')";
    $q->QUERY_SQL($sql, "artica_backup");
    $sql = "UPDATE backup_storages SET `size`='{$BackupSize}' WHERE `zmd5`='{$zmd5}'";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        backup_events($ID, "initialization", "ERROR, {$q->mysql_error}", __LINE__);
    }
    if (!$GLOBALS["NO_UMOUNT"]) {
        writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:umount {$mount_path_final}", __FUNCTION__, __FILE__, __LINE__);
        if (preg_match("#^\\/opt\\/artica\\/mounts\\/backup\\/[0-9]+(.+)#", $mount_path_final, $re)) {
            $mount_path_final = str_replace($re[1], "", $mount_path_final);
            writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:translated to {$mount_path_final}", __FUNCTION__, __FILE__, __LINE__);
        }
        backup_events($ID, "initialization", "INFO, umount {$mount_path_final}", __LINE__);
        writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:umount {$mount_path_final}", __FUNCTION__, __FILE__, __LINE__);
        exec("umount -l {$mount_path_final} 2>&1", $resultsUmount);
        if (count($resultsUmount) > 0) {
            writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:umount : ----- \n" . @implode("\n", $resultsUmount) . "\n", __FUNCTION__, __FILE__, __LINE__);
        }
    }
    $date_end = time();
    $calculate = distanceOfTimeInWords($date_start, $date_end);
    backup_events($ID, "TIME", "INFO, Time: {$calculate} ({$mount_path_final})", __LINE__);
    backup_events($ID, "initialization", "INFO, Backup task terminated", __LINE__);
    send_email_events("Backup Task {$ID}:: Backup stopping", "Backup is stopped", "backup");
    shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.cleanfiles.php");
}
Esempio n. 22
0
function create_user($filename)
{
    $tpl = new templates();
    $unix = new unix();
    $nohup = null;
    $path = "/usr/share/artica-postfix/ressources/logs/web/create-users/{$filename}";
    echo "Path:{$path}\n";
    build_progress("Open {$filename}", 10);
    if (!is_file($path)) {
        echo "{$path} no such file...\n";
        return false;
    }
    $MAIN = unserialize(base64_decode(@file_get_contents($path)));
    build_progress("Create new member {$MAIN["login"]}", 15);
    $users = new user($MAIN["login"]);
    if ($users->password != null) {
        echo "User already exists {$MAIN["login"]}\n";
        build_progress("{account_already_exists}", 110);
        @unlink($path);
        return;
    }
    $ou = $MAIN["ou"];
    $password = url_decode_special_tool($MAIN["password"]);
    $MAIN["firstname"] = url_decode_special_tool($MAIN["firstname"]);
    $MAIN["lastname"] = url_decode_special_tool($MAIN["lastname"]);
    build_progress("{$MAIN["firstname"]} {$MAIN["lastname"]}", 20);
    if (trim($MAIN["internet_domain"]) == null) {
        $MAIN["internet_domain"] = "localhost.localdomain";
    }
    echo "Add new user {$MAIN["login"]} {$MAIN["ou"]} {$MAIN["gpid"]}\n";
    $users->ou = $MAIN["ou"];
    $users->password = url_decode_special_tool($MAIN["password"]);
    $users->mail = "{$MAIN["email"]}@{$MAIN["internet_domain"]}";
    $users->DisplayName = "{$MAIN["firstname"]} {$MAIN["lastname"]}";
    $users->givenName = $MAIN["firstname"];
    $users->sn = $MAIN["lastname"];
    $users->group_id = $MAIN["gpid"];
    $users->homeDirectory = "/home/{$MAIN["login"]}";
    if (is_numeric($MAIN["gpid"])) {
        $gp = new groups($MAIN["gpid"]);
        echo "privileges: {$MAIN["gpid"]} -> AsComplexPassword = \"{$gp->Privileges_array["AsComplexPassword"]}\"\n";
        if ($gp->Privileges_array["AsComplexPassword"] == "yes") {
            $ldap = new clladp();
            $hash = $ldap->OUDatas($ou);
            $privs = $ldap->_ParsePrivieleges($hash["ArticaGroupPrivileges"], array(), true);
            $policiespwd = unserialize(base64_decode($privs["PasswdPolicy"]));
            if (is_array($policiespwd)) {
                $priv = new privileges();
                if (!$priv->PolicyPassword($password, $policiespwd)) {
                    build_progress("Need complex password", 110);
                    echo "Need complex password";
                    @unlink($path);
                    return;
                }
            }
        }
    }
    build_progress("{$MAIN["firstname"]} {$MAIN["lastname"]} {save}", 25);
    if (!$users->add_user()) {
        echo $users->error . "\n" . $users->ldap_error;
        build_progress("{failed}", 110);
        @unlink($path);
        return;
    }
    @mkdir("{$users->homeDirectory}");
    @chown("{$users->homeDirectory}", $users->uid);
    if ($MAIN["ByZarafa"] == "yes") {
        $terminated = " >/dev/null";
        $zarafa_admin = $unix->find_program("zarafa-admin");
        if (!$GLOBALS["WAIT"]) {
            $nohup = $unix->find_program("nohup");
            $terminated = null;
        }
        if (isset($MAIN["ZARAFA_LANG"])) {
            $users->SaveZarafaMbxLang($MAIN["ZARAFA_LANG"]);
            $langcmd = " --lang {$MAIN["ZARAFA_LANG"]} ";
        }
        $ldap = new clladp();
        $dn = "ou={$MAIN["ou"]},dc=organizations,{$ldap->suffix}";
        $upd["objectClass"] = "zarafa-company";
        $upd["cn"] = $MAIN["ou"];
        if (!$ldap->Ldap_add_mod("{$dn}", $upd)) {
            echo $ldap->ldap_last_error;
            build_progress("{failed} OpenLDAP Error", 110);
            @unlink($path);
            return;
        }
        build_progress("{create_store} {language}: {$MAIN["ZARAFA_LANG"]}", 30);
        $cmd = "{$nohup} {$zarafa_admin} {$langcmd}--create-store {$MAIN["login"]} >/dev/null 2>&1 &";
        system(trim($cmd));
        if (!$GLOBALS["WAIT"]) {
            $sock = new sockets();
            $sock->getFrameWork("cmd.php?zarafa-hash=yes&rebuild=yes");
            return;
        }
        @unlink("/usr/share/artica-postfix/ressources/databases/ZARAFA_DB_STATUS.db");
        @unlink("/etc/artica-postfix/zarafa-export.db");
        $cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.zarafa.build.stores.php --export-hash";
        build_progress("{export_stores_data}", 35);
        echo "{$cmd}\n";
        system($cmd);
    }
    echo "Remove {$path}\n";
    @unlink($path);
    return true;
}
Esempio n. 23
0
function OCSWEB_FINAL_CERTIFICATE()
{
    $path = base64_decode($_GET["path"]);
    if (!is_file($path)) {
        return null;
    }
    shell_exec("/bin/cp {$path} /etc/artica-postfix/settings/Daemons/OCSServerDotCrt");
    shell_exec("/bin/cp {$path} /etc/ocs/cert/server.crt");
    shell_exec(LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.ocsweb.php --final-cert");
    sys_THREAD_COMMAND_SET("/etc/init.d/artica-postfix restart ocsweb");
}
Esempio n. 24
0
    @fclose($handlet);
}
$pid = getmypid();
echo "[{$pid}]::master Running pid {$pid}\n";
file_put_contents($pidfile, $pid);
$unix = new unix();
$nohup = $unix->find_program("nohup");
$q = new mysql();
$sql = "SELECT ID FROM emailing_db_paths WHERE finish=0 ORDER BY ID DESC";
$results = $q->QUERY_SQL($sql, "artica_backup");
if (!$q->ok) {
    echo "[{$pid}]::master {$q->mysql_error}\n";
}
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
    $id = $ligne["ID"];
    $cmd = "{$nohup} " . LOCATE_PHP5_BIN2() . " " . __FILE__ . " --id {$id} &";
    echo "[{$pid}]::master {$cmd}\n";
    system($cmd);
}
echo "[{$pid}]::master halt {$pid}\n";
function parse_db($id)
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/" . basename(__FILE__) . ".{$id}.pid";
    $pid = trim(@file_get_contents($pidfile));
    if ($unix->process_exists($pid)) {
        $pid = getmypid();
        echo "[{$pid}]:: Process {$pid} already running...\n";
        die;
    }
    $pid = getmypid();
Esempio n. 25
0
function squid_parser($buffer){
	if(strpos($buffer,"Initializing IP Cache...")>0){return;}
	if(strpos($buffer,"DNS Socket created")>0){return;}
	if(strpos($buffer,"Target number of buckets")>0){return;}
	
	
if(preg_match("#httpAccept:\s+FD\s+[0-9]+:\s+accept failure:\s+\([0-9]+\)\s+Invalid argument#",$buffer)){
	$file="/etc/artica-postfix/croned.1/squid_accept_failure";	
	if(IfFileTime($file)){
			events("FD failure !!");
			email_events("Squid File System error","SQUID claim \"$buffer\" the squid service will be restarted",'proxy');
			$GLOBALS["CLASS_UNIX"]->THREAD_COMMAND_SET('/etc/init.d/artica-postfix restart squid-cache');
			WriteFileCache($file);
			return;
		}else{
			return;
		}	
}
	
if(preg_match("#squid.*?Failed to verify one of the swap directories, Check cache.log.+?squid -z#",$buffer)){
		events("Squid Must reconfigure squid caches");
		$file="/etc/artica-postfix/croned.1/squid-caches-failed";
		if(IfFileTime($file,5)){
		email_events("Squid failed to load (error swap directories)","Squid claim \"$buffer\"\nArtica will try to repair caches",'proxy');
		shell_exec(LOCATE_PHP5_BIN2()." /usr/share/artica-postfix/exec.squid.php --caches &");
		WriteFileCache($file);
		}else{events("Squid Must reconfigure squid caches (but timed out)");}
		return;	
	}	
	

	if(preg_match("#squid\[([0-9]+)\]:\s+Starting Squid Cache version\s+([0-9\.]+)\s+#",$buffer)){
			events("Squid start pid {$re[1]}");	
			email_events("Squid started pid {$re[1]} version {$re[2]}","Squid has been started \"$buffer\"\n",'proxy');
			return;
	}

	if(preg_match("#Your cache is running out of filedescriptors#",$buffer)){
			events("Squid Your cache is running out of filedescriptors");	
			email_events("SQUID: Your cache is running out of filedescriptors","Squid claim \"$buffer\"\nArtica will reload squid",'proxy');
			shell_exec(LOCATE_PHP5_BIN2()." /usr/share/artica-postfix/exec.squid.php --reload-squid &");
			return;
		}	
	
	
	
if(preg_match("#squid\[.+?comm_old_accept:\s+FD\s+[0-9]+:.+?Invalid argument#",$buffer,$re)){
	$file="/etc/artica-postfix/croned.1/comm_old_accept.FD15";
	if(IfFileTime($file)){
			events("comm_old_accept FD15 SQUID");
			email_events("Squid File System error","SQUID claim \"$buffer\" the squid service will be restarted",'proxy');
			$GLOBALS["CLASS_UNIX"]->THREAD_COMMAND_SET('/etc/init.d/artica-postfix restart squid-cache');
			WriteFileCache($file);
			return;
		}else{
			events("comm_old_accept FD15 SQUID");
			return;
		}	
}
if(preg_match("#httpAccept: FD [0-9]+: accept failure: \([0-9]+\) Invalid argument#",$buffer,$re)){
	$file="/etc/artica-postfix/croned.1/comm_old_accept.FD15";
	if(IfFileTime($file)){
			events("FD 83: accept failure SQUID");
			email_events("Squid File System error","SQUID claim \"$buffer\" the squid service will be restarted",'proxy');
			$GLOBALS["CLASS_UNIX"]->THREAD_COMMAND_SET('/etc/init.d/artica-postfix restart squid-cache');
			WriteFileCache($file);
			return;
		}else{
			events("FD 83: accept failure SQUID");
			return;
		}	
}


if(preg_match("#NetfilterInterception?+?failed on FD.+?No such file or directory#",$buffer)){
			events("Squid NetfilterInterception failed");	
			$file="/etc/artica-postfix/croned.1/NetfilterInterception.FD15";
			if(IfFileTime($file)){
				email_events("SQUID: NetfilterInterception failed","Squid claim \"$buffer\"\nArtica will reload squid",'proxy');
				shell_exec(LOCATE_PHP5_BIN2()." /usr/share/artica-postfix/exec.squid.php --reload-squid &");
				WriteFileCache($file);
			}
			return;
		}	


if(preg_match("#squid.+?:\s+essential ICAP service is down after an options fetch failure:\s+icap:\/\/:1344\/av\/respmod#",$buffer,$re)){
		$file="/etc/artica-postfix/croned.1/squid.icap1.error";
		if(IfFileTime($file)){
			email_events("Kaspersky for Squid Down","$buffer",'proxy');
			$GLOBALS["CLASS_UNIX"]->THREAD_COMMAND_SET('/etc/init.d/artica-postfix start kav4proxy');
			$GLOBALS["CLASS_UNIX"]->THREAD_COMMAND_SET("{$GLOBALS["SQUIDBIN"]} -k reconfigure");
			WriteFileCache($file);
		}else{
			events("KAV4PROXY error:$buffer, but take action after 10mn");
			
		}
	return;			
}

if(preg_match("#squid\[([0-9]+)\]:\s+storeLateRelease:\s+#",$buffer,$re)){
	email_events("Proxy: Squid was successfull loaded PID {$re[1]}","$buffer",'proxy');
	return;
}

if(preg_match("#squid\[.+?Squid Parent: child process ([0-9]+) exited with status ([0-9]+)#",$buffer,$re)){
	email_events("Proxy: Squid child process PID {$re[1]} was been terminated (code {$re[2]})","Squid claim \"$buffer\"",'proxy');
	return;
}

if(preg_match("#squid\[.+?:idnsSendQuery.+?Invalid argument#",$buffer,$re)){
	email_events("Proxy: DNS configuration error","Squid claim \"$buffer\"\nIt seems that you have a DNS misconfiguration under Proxy settings",'proxy');
	return;
}

if(preg_match("#squid\[.+?:\s+(.+?):\s+\(13\)\s+Permission denied#",$buffer,$re)){
	$file_error=trim($re[1]);
	$file="/etc/artica-postfix/croned.1/squid.". md5($file_error).".error";
	events("SQUID:: Permissions error on $file_error");
		if(IfFileTime($file)){
			email_events("Squid File $file_error error","SQUID claim \"$buffer\" permissions of $file_error will be changed to squid:squid ",'proxy');
			$dirfile=dirname($file_error);
			if(is_dir($dirfile)){
				$cmd="/bin/chown squid:squid $dirfile";
				events("$cmd");
				shell_exec("$cmd &");
				
				$cmd="/bin/chown -R squid:squid $dirfile";
				events("$cmd");
				shell_exec("$cmd &");
			}
			WriteFileCache($file);	
		}
		
		return;
}


events_not_filtered("SQUID:: Not Filtered:\"$buffer\"");
		
	
}
Esempio n. 26
0
function snort_networks()
{
    $cmd = LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.snort.php --networks";
    shell_exec($cmd);
}
Esempio n. 27
0
function pdns_status()
{
    exec(LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.status.php --pdns --nowachdog 2>&1", $results);
    echo "<articadatascgi>" . base64_encode(@implode("\n", $results)) . "</articadatascgi>";
}
Esempio n. 28
0
function RestartClientsTenir()
{
    exec(LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.openvpn.php --client-restart", $results);
    echo "<articadatascgi>" . base64_encode(serialize($results)) . "</articadatascgi>";
}
Esempio n. 29
0
function group300()
{
    if (!is_numeric($GLOBALS["TIME"]["GROUP300"])) {
        $GLOBALS["TIME"]["GROUP300"] = time();
        return;
    }
    if ($GLOBALS["TIME"]["GROUP300"] == 0) {
        $GLOBALS["TIME"]["GROUP300"] = time();
        return;
    }
    $mins = calc_time_min($GLOBALS["TIME"]["GROUP300"]);
    if ($mins < 120) {
        return;
    }
    $GLOBALS["TIME"]["GROUP300"] = time();
    if (!is_file("/etc/artica-postfix/settings/Daemons/HdparmInfos")) {
        sys_THREAD_COMMAND_SET(LOCATE_PHP5_BIN2() . " /usr/share/artica-postfix/exec.hdparm.php");
    }
    $array[] = "exec.mysql.build.php --tables";
    $array[] = "exec.mysql.build.php --maintenance";
    if ($GLOBALS["POSTFIX_INSTALLED"]) {
        $array[] = "exec.organization.statistics.php";
        $array[] = "exec.quarantine-clean.php";
        $array[] = "exec.smtp-hack.export.php --export";
        $array[] = "exec.postfix-logger.php --cnx-stats";
        $array[] = "exec.smtp.events.clean.php";
        $array[] = "exec.roundcube.php --verifyTables";
    }
    $array[] = "exec.squid.stats.php --visited-sites";
    $array2[] = "artica-install -geoip-updates";
    while (list($index, $file) = each($array)) {
        $cmd = "{$GLOBALS["PHP5"]} /usr/share/artica-postfix/{$file}";
        events("schedule {$cmd}", __FUNCTION__, __LINE__);
        $GLOBALS["CMDS"][] = $cmd;
    }
    while (list($index, $file) = each($array2)) {
        $cmd = "/usr/share/artica-postfix/bin/{$file}";
        events("schedule {$cmd}", __FUNCTION__, __LINE__);
        $GLOBALS["CMDS"][] = $cmd;
    }
    @file_put_contents("/etc/artica-postfix/pids/" . basename(__FILE__) . ".GLOBALS", serialize($GLOBALS["TIME"]));
}
    echo "\n";
    die;
}
//exec.dansguardian.compile.php --patterns
echo "\n";
echo "Starting......: Dansguardian reconfigure settings\n";
$q = new mysql();
if (!$q->test_mysql_connection()) {
    echo "Starting......: Dansguardian Mysql error\n";
    die;
}
$q->CheckTable_dansguardian();
LoadGlobal_exceptionsitelist();
$dans = new dansguardian();
$dans->SaveSettings();
$cmd = LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.web-community-filter.php --patterns{$GLOBALS["cmdlineadd"]}";
events("MAIN:: {$cmd}");
system($cmd);
HtmlTemplate();
BuildPersonalCategories();
bannedsitelist_userdefined();
weightedphraselist_userdefined();
BuildRules();
BuildWhiteIpList();
BuildBannedIPList();
FixMissingGroupsFiles();
FixMissingFiles();
BuildMasterRule();
echo "Starting......: Dansguardian reconfigure settings done\n";
function HtmlTemplate()
{