function BuildDayTable()
{
    $q = new mysql();
    $q->BuildTables();
    if (!$q->TABLE_EXISTS('smtp_logs_day', 'artica_events')) {
        send_email_events("Mysql error on smtp_logs_day table", "Artica was unable to create or detect smtp_logs_day table...", "system");
        return false;
    }
    $today = date('Y-m-d');
    $sql = "SELECT COUNT(id) as tcount,delivery_domain,DATE_FORMAT(time_stamp,'%Y-%m-%d') as tdate,bounce_error FROM \n\tsmtp_logs \n\tGROUP BY delivery_domain,tdate,bounce_error HAVING tdate<'{$today}' ORDER BY tdate DESC";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo "Wrong sql query {$q->mysql_error}\n";
        write_syslog("Wrong sql query {$q->mysql_error}", __FILE__);
        return false;
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $count = $count + 1;
        $emails = $ligne["tcount"];
        $delivery_domain = $ligne["delivery_domain"];
        $date = $ligne["tdate"];
        $bounce_error = $ligne["bounce_error"];
        $md5 = md5($delivery_domain . $date . $bounce_error . $emails);
        $sql = "INSERT INTO smtp_logs_day (`key`,`day`,`delivery_domain`,`bounce_error`,`emails`)\n\t\tVALUES('{$md5}','{$date}','{$delivery_domain}','{$bounce_error}','{$emails}')";
        $q->QUERY_SQL($sql, "artica_events");
        if (!$q->ok) {
            echo "Wrong sql query {$q->mysql_error}\n";
            write_syslog("Wrong sql query \"{$sql}\" {$q->mysql_error}", __FILE__);
            return false;
        }
    }
    return true;
}
function watchdog()
{
    $ini = new Bs_IniHandler("/etc/artica-postfix/smtpnotif.conf");
    $PostfixQueueEnabled = $ini->get("SMTP", "PostfixQueueEnabled");
    $PostfixQueueMaxMails = $ini->get("SMTP", "PostfixQueueMaxMails");
    if ($PostfixQueueEnabled == null) {
        $PostfixQueueEnabled = 1;
    }
    if ($PostfixQueueMaxMails == null) {
        $PostfixQueueMaxMails = 20;
    }
    if ($PostfixQueueEnabled != 1) {
        return;
    }
    $postfix_system = new postfix_system();
    $array = $postfix_system->getQueuesNumber();
    while (list($num, $val) = each($array)) {
        $logs[] = "{$num}={$val} message(s)";
        if (intval($val) > $PostfixQueueMaxMails) {
            if (is_file("/etc/artica-postfix/croned.1/postfix.{$num}.exceed")) {
                if (file_time_min("/etc/artica-postfix/croned.1/postfix.{$num}.exceed") < 30) {
                    continue;
                }
            }
            @file_put_contents("/etc/artica-postfix/croned.1/postfix.{$num}.exceed", "#");
            $subject = "Postfix queue {$num} exceed limit";
            $text = "The {$num} storage queue contains {$val} messages\nIt exceed the maximum {$PostfixQueueMaxMails} messages number...";
            send_email_events($subject, $text, 'system');
        }
    }
    $logs[] = "{$num}={$val} message(s)";
    RTMevents(implode(" ", $logs));
}
Beispiel #3
0
function fetchtimeout($server, $port, $ip, $buffer)
{
    $file = "/etc/artica-postfix/cron.1/" . md5(__FILE__) . "-" . md5("{$server},{$port},{$ip}");
    if (file_time_min($file) < 15) {
        return null;
    }
    send_email_events("fetchmail network error on  {$server} {$port}", "fetchmail claim \"{$buffer}\", please set the right server for fetching messages", 'system');
    @unlink($file);
    @file_put_contents("#", $file);
}
Beispiel #4
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}");
}
Beispiel #5
0
function sync($ou){
	
if(!Build_pid_func(__FILE__,__FUNCTION__)){
	writelogs(basename(__FILE__).":Already executed.. aborting the process",basename(__FILE__),__FILE__,__LINE__);
	return;
}
$unix=new unix();	
$imapsync=$unix->find_program("imapsync");


	if(!is_file($unix->find_program("imapsync"))){
		writelogs("Unable to stat imapsync",__FUNCTION__,__FILE__,__LINE__);
		send_email_events("Could not migrate from cyrus to zarafa","Unable to stat imapsync tool,aborting","mailbox");
		return;
	}
	
	$ou=base64_decode($ou);
	
	
	$ldap=new clladp();
	$members=$ldap->hash_users_ou($ou);
	writelogs("Loading $ou organization ".count($members)." members imapsync=$imapsync",__FUNCTION__,__FILE__,__LINE__);
	send_email_events("migration from cyrus to zarafa starting","Cyrus to zarafa starting (". count($members)." members)","mailbox");
	

	while (list ($uid, $name) = each ($members) ){
		if($uid==null){continue;}
		$user=new user($uid);
		send_email_events("migration from cyrus to zarafa starting","Cyrus to zarafa starting (". count($members)." members)","mailbox");
		$cmdline="$imapsync  --noauthmd5  --subscribe --host1 127.0.0.1 --port1 1143";
		$cmdline=$cmdline." --user1 $uid --password1 $user->password --delete --expunge1";
		$cmdline=$cmdline." --sep2 / --prefix2 \"\" --host2 127.0.0.1 --user2 $uid --password2 $user->password >/root/imapsync.$uid 2>&1";
		writelogs("$cmdline",__FUNCTION__,__FILE__,__LINE__);
		shell_exec($cmdline);
		$datas=@file_get_contents("/root/imapsync.$uid");
		if($GLOBALS["VERBOSE"]){
			echo "$datas";
		}
		if(strlen($datas)>0){
			send_email_events("$uid migration status",@file_get_contents("/root/imapsync.$uid"),"mailbox");
		}
		@unlink("/root/imapsync.$uid");
		
		
	}
	
	
	
	
	
	
}
function CleanLogs()
{
    cleanTmplogs();
    CleanDirLogs('/var/log');
    CleanDirLogs('/opt/artica/tmp');
    CleanDirLogs('/etc/artica-postfix/pids');
    CleanDirLogs('/opt/artica/install');
    phplogs();
    CleanClamav();
    $size = str_replace("&nbsp;", " ", FormatBytes($GLOBALS["DELETED_SIZE"]));
    echo "{$size} cleaned :  {$GLOBALS["DELETED_FILES"]} files\n";
    if ($GLOBALS["DELETED_SIZE"] > 500) {
        send_email_events("{$size} logs files cleaned", "{$GLOBALS["DELETED_FILES"]} files cleaned for {$size} free disk space", "logs_cleaning");
    }
}
function orphans(){
$unix=new unix();
$zarafaadmin=$unix->find_program("zarafa-admin");
exec("$zarafaadmin --list-orphans 2>&1",$array);
$users=array();
$ff=false;
while (list ($index, $line) = each ($array) ){
	if(preg_match("#Users without stores#",$line)){$ff=true;}
	if(!$ff){continue;}
	if(preg_match("#\s+[0-9+\.\-a-zA-Z@]+$#",$line,$re)){
		$re[1]==trim($re[1]);
		if($re[1]=="Username"){continue;}
		if(strpos($re[1],"---")>0){continue;}
		if($re[1]=="--------------------------------------------------------"){continue;}
		if($re[1]=="---------------"){continue;}
		if($re[1]=="without stores:"){continue;}
		if($GLOBALS["VERBOSE"]){echo "found \"{$re[1]}\"\n";}
		
		$users[$re[1]]=$re[1];
	}
	
}


if(count($users)>1){
	while (list ($uid, $line) = each ($users) ){
		exec("$zarafaadmin --create-store $uid",$results);
		$logs[]="Create store for $uid";
		while (list ($a, $b) = each ($results) ){$logs[]="$b";}
		unset($results);
	}
	
	if($GLOBALS["VERBOSE"]){
		echo @implode("\n",$logs);
	}
	send_email_events("Creating store for ". count($users),"Artica has successfully created store in zarafa server:\n".@implode("\n",$logs));
	
}

	
}
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");

}
Beispiel #9
0
function BuildWarning($cpu, $time)
{
    $load = sys_getloadavg();
    $unix = new unix();
    $hostname = $unix->hostname_g();
    $ldtext[] = "**** Current system load ****";
    $ldtext[] = "Load 1mn.: " . $load[0];
    $ldtext[] = "Load 5mn.: " . $load[1];
    $ldtext[] = "Load 15mn: " . $load[2];
    $ldtext[] = "*****************************";
    $subject = "CPU overload ({$cpu}%) and overloaded ({$GLOBALS["SYSTEM_INTERNAL_LOAD"]}/{$GLOBALS["SYSTEM_MAX_LOAD"]})";
    shell_exec("/bin/ps -w axo ppid,pcpu,pmem,time,args --sort -pcpu,-pmem|/usr/bin/head --lines=20 >/tmp.top.txt 2>&1");
    $top = file_get_contents("/tmp.top.txt");
    @unlink("/tmp.top.txt");
    $top = SafeProcesses() . "\n" . $top;
    $text = "Server report that your {$hostname} server has reach {$cpu}% CPU average consumption in {$time} minute(s)\n" . @implode("\n", $ldtext) . "\nYou will find below a processes report:\n---------------------------------------------\n{$top}\nGenerated by " . basename(__FILE__) . " (" . __FUNCTION__ . " on line " . __LINE__ . ") at " . date("H:i:s") . "";
    send_email_events($subject, $text, 'system');
}
function BlockQuotaFrom($from,$mailto,$size){
	$from=trim(strtolower($from));
	$mailto=trim(strtolower($mailto));
	$date=date("Y-m-d");
	$action=false;
	$log=false;
	
	if($from==$mailto){return false;}
	if(preg_match("#(.+?)@(.+)#",$from,$re)){$domain_from=strtolower(trim($re[2]));}
	
	if(!$GLOBALS["LOCAL_DOMAINS"][$domain_from]){
		events("from=<$from> $domain_from not internal (on ". count($GLOBALS["LOCAL_DOMAINS"]). "domains",__FUNCTION__,__LINE__);
		return false;
	
	}	
	if(!is_array($GLOBALS["INTERNAL_FROM"][$from])){PopulateUser($from);}
	
	if($GLOBALS["INTERNAL_FROM"][$from]["uid"]==null){return false;}
	
	$uid=$GLOBALS["INTERNAL_FROM"][$from]["uid"];
	if($GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES"]==null){$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES"]=0;}
	
	
	
	
	if($GLOBALS["INTERNAL_FROM"][$uid]["MaxMailsDay"]>0){
		$log=true;
		$mem_quota=$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES"];
		$mem_quota=$mem_quota+1;
		
		$GLOBALS["CACHE"][$date][$uid]["MESSAGES"][]=date("Y-m-d H:i:s")." => $mailto (" .str_replace("&nbsp;",FormatBytes($size/1024)," ").")";
		if($mem_quota>=$GLOBALS["INTERNAL_FROM"][$uid]["MaxMailsDay"]){$action=true;}
		$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES"]=$mem_quota;
	}
	if($GLOBALS["INTERNAL_FROM"][$uid]["MaxMailDaySize"]>0){
		$log=true;
		$mem_quota=$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES_SIZE"];
		$mem_quota=$mem_quota+$size;
		if($mem_quota>=$GLOBALS["INTERNAL_FROM"][$uid]["MaxMailDaySize"]){$action=true;}
		$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES_SIZE"]=$mem_quota;
	}else{
		$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES_SIZE"]=$size;
	}
	
	if($log){
		events("from=<$from> ($uid) to=<$mailto> notify={$GLOBALS["INTERNAL_FROM"][$uid]["OnlyNotify"]} , quota message(s): {$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES"]}, size:{$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES_SIZE"]}",__FUNCTION__,__LINE__);
	}
	
	if($action){
		if($GLOBALS["INTERNAL_FROM"][$uid]["OnlyNotify"]==1){
			events("Send notification and clean cache",__FUNCTION__,__FILE__);
			$text[]="Messages count : {$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES"]}";
			$text[]="Messages Size : {$GLOBALS["CACHE"][$date][$uid]["COUNT_MESSAGES_SIZE"]}";
			$text[]="-------------------------------";
			$text[]=@implode("\n",$GLOBALS["CACHE"][$date][$uid]["MESSAGES"]);
			send_email_events("$uid exceed SMTP quotas",@implode("\n",$text),"postfix");
			unset($GLOBALS["CACHE"][$date][$uid]);
			return false;
		}
		return true;	
	}else{
		return false;
	}
	
	
}
Beispiel #11
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");
}
Beispiel #12
0
function BuildTunServer(){
LoadArgvs();
   $unix=new unix();
   if(isset($GLOBALS["CLASS_SOCKETS"])){$sock=$GLOBALS["CLASS_SOCKETS"];}else{$GLOBALS["CLASS_SOCKETS"]=new sockets();$sock=$GLOBALS["CLASS_SOCKETS"];}
   $servername=$unix->hostname_g();	
   $routess=array();
   $duplicate_cn=null;
 
   
  if(preg_match("#^(.+?)\.#",$servername,$re)){$servername=$re[1];}
   $servername=strtoupper($servername);       
   echo "Starting......: OpenVPN building settings for $servername...\n";
   
   
   
   $ini=new Bs_IniHandler();
   
   $ini->loadString($sock->GET_INFO("ArticaOpenVPNSettings"));
   if(!isset($ini->_params["GLOBAL"]["ENABLE_BRIDGE_MODE"])){$ini->_params["GLOBAL"]["ENABLE_BRIDGE_MODE"]=0;}
   if(!isset($ini->_params["GLOBAL"]["IP_START"])){$ini->_params["GLOBAL"]["IP_START"]="10.8.0.0";}
   if(!isset($ini->_params["GLOBAL"]["NETMASK"])){$ini->_params["GLOBAL"]["NETMASK"]="255.255.255.0";}
   
   
   if($ini->_params["GLOBAL"]["ENABLE_BRIDGE_MODE"]==1){
   		echo "Starting......: OpenVPN building settings mode bridge enabled...\n";
   		BuildBridgeServer();
   		return;
   }
   
   
   $IPTABLES_ETH=$GLOBALS["IPTABLES_ETH"];
   $DEV_TYPE=$ini->_params["GLOBAL"]["DEV_TYPE"];
   $port=$ini->_params["GLOBAL"]["LISTEN_PORT"];
   $IP_START=$ini->_params["GLOBAL"]["IP_START"];
   $NETMASK=$ini->_params["GLOBAL"]["NETMASK"];
   $bind_addr=$ini->_params["GLOBAL"]["LOCAL_BIND"];
   $LISTEN_PROTO=$ini->_params["GLOBAL"]["LISTEN_PROTO"];
   if($LISTEN_PROTO==null){$LISTEN_PROTO="udp";}
   if($LISTEN_PROTO=="udp"){$proto="--proto udp";}else{$proto="--proto tcp-server";}
   
    
   if(trim($port)==null){$port=1194;}
   if(trim($IP_START)==null){$IP_START="10.8.0.0";}
   if(trim($NETMASK)==null){$NETMASK="255.255.255.0";}
   
$nic=new networking();

while (list ($num, $ligne) = each ($nic->array_TCP) ){
	if($ligne==null){continue;}
		$eths[][$num]=$num;
		$ethi[$num]=$ligne;
	} 

if($IPTABLES_ETH<>null){
		echo "Starting......: OpenVPN linked to $IPTABLES_ETH ({$ethi[$IPTABLES_ETH]})...\n";
		$IPTABLES_ETH_ROUTE=IpCalcRoute($ethi[$IPTABLES_ETH]);
}else{
	echo "Starting......: OpenVPN no local NIC linked...\n";
}
	
   $ca='/etc/artica-postfix/openvpn/keys/allca.crt';
   $dh='/etc/artica-postfix/openvpn/keys/dh1024.pem';
   $key="/etc/artica-postfix/openvpn/keys/vpn-server.key";
   $crt="/etc/artica-postfix/openvpn/keys/vpn-server.crt";
   $route='';
   
   //$IPTABLES_ETH_IP=

if (is_file('/etc/artica-postfix/settings/Daemons/OpenVPNRoutes')){
   $routes=(explode("\n",@file_get_contents("/etc/artica-postfix/settings/Daemons/OpenVPNRoutes")));
   while (list ($num, $ligne) = each ($routes) ){
   	if(!preg_match("#(.+?)\s+(.+)#",$ligne,$re)){continue;}
   	$routess[]="--push \"route {$re[1]} {$re[2]}\"";
   }
}
$GetRoutes=GetRoutes();
$routess=$routess+$GetRoutes;



if(count($routess)==0){
	if($IPTABLES_ETH_ROUTE<>null){
		echo "Starting......: OpenVPN IP adding default route \"$IPTABLES_ETH_ROUTE\"\n";
		$routess[]="--push \"route $IPTABLES_ETH_ROUTE\"";
	}
  }else{
  	echo "Starting......: OpenVPN IP adding ".count($routess)." routes\n";
  }
   

	
   if(trim($bind_addr)<>null){
   	$local=" --local $bind_addr";
   	echo "Starting......: OpenVPN IP bind $bind_addr\n";
   }
   
   $IP_START=FIX_IP_START($IP_START,$local);
   $ini->set("GLOBAL","IP_START",$IP_START); 	
  
   if(preg_match("#(.+?)\.([0-9]+)$#",$IP_START,$re)){
   	$calc_ip=" {$re[1]}.0";
   	$calc_ip_end="{$re[1]}.254";
   	echo "Starting......: OpenVPN IP pool from {$re[1]}.2 to {$re[1]}.254 mask:$NETMASK\n";
   	$server_ip="{$re[1]}.1";
   	$IP_START_PREFIX=$re[1];
   }

   if($NETMASK==null){
			$ip=new IP();
			$cdir=$ip->ip2cidr($calc_ip,$calc_ip_end);
			$arr=$ip->parseCIDR($cdir);
			$rang=$arr[0];
			$netbit=$arr[1];
			$ipv=new ipv4($calc_ip,$netbit);
			$NETMASK=$ipv->netmask();	   
			if($NETMASK=="255.255.255.255"){$NETMASK="255.255.255.0";}		
   			echo "Starting......: OpenVPN Netmask is null for the range $calc_ip, assume $NETMASK\n";
   			$ini->set("GLOBAL","NETMASK",$NETMASK);
   	}
   	
	$OpenVpnPasswordCert=$sock->GET_INFO("OpenVpnPasswordCert");
	if($OpenVpnPasswordCert==null){$OpenVpnPasswordCert="MyKey";}
   
	$askpass=null;
   	if(is_file("/etc/artica-postfix/openvpn/keys/password")){
   		$askpass="******";
   	}
   	
   	$ifconfig_pool_persist=" --ifconfig-pool-persist /etc/artica-postfix/openvpn/ipp.txt ";
   	
 	if(isset($GLOBALS["OPENVPNPARAMS"]["duplicate-cn"])){
 		echo "Starting......: OpenVPN duplicate-cn is enabled\n";
 		$duplicate_cn=" --duplicate-cn ";
 		$ifconfig_pool_persist=null;
 	}
 	
 	if(isset($GLOBALS["OPENVPNPARAMS"]["script-security"])){
 		echo "Starting......: OpenVPN script-security is enabled\n";
 		$script_security=" --script-security 2";
 	} 	
 	
	if(!is_dir("/etc/openvpn/cdd")){@mkdir("/etc/openvpn/cdd");}
	$already=array();
 	echo "Starting......: OpenVPN get remote sites routes...\n";
 	$sql="SELECT sitename,IP_START,netmask,remote_site_routes,FixedIPAddr FROM vpnclient WHERE connexion_type=1";
 	$q=new mysql();
	$results=$q->QUERY_SQL($sql,"artica_backup");
	if(!$q->ok){echo2("Starting......: OpenVPN : $q->mysql_error");}
 	while($ligne=mysql_fetch_array($results,MYSQL_ASSOC)){
 		$iroute=array();
 		$sitename=$ligne["sitename"];
 		$FixedIPAddr=$ligne["FixedIPAddr"];
 		if(!is_numeric($FixedIPAddr)){$FixedIPAddr=0;}
 		
 		if($IP_START_PREFIX<>null){
 			if($FixedIPAddr>2){
 				if($FixedIPAddr<255){
 					echo "Starting......: OpenVPN $sitename $IP_START_PREFIX.$FixedIPAddr fixed IP address\n";
 					$iroute[]="ifconfig-push $IP_START_PREFIX.$FixedIPAddr $IP_START_PREFIX.2";
 				}
 			}
 		}
 		
 		if(!isset($already[$ligne["IP_START"]])){
 			echo "Starting......: OpenVPN $sitename ({$ligne["IP_START"]} {$ligne["netmask"]})\n";
 			$rou[]=" --route {$ligne["IP_START"]} {$ligne["netmask"]}";
 			$iroute[]="iroute {$ligne["IP_START"]} {$ligne["netmask"]}";
 			$already[$ligne["IP_START"]]=true;
 		}
 		
 		$remote_site_routes=unserialize(base64_decode($ligne["remote_site_routes"]));
		while (list ($num, $site_mask) = each ($remote_site_routes) ){
			if(!isset($already[$num])){
				echo "Starting......: OpenVPN $sitename ($num $site_mask)\n";
				$rou[]=" --route $num $site_mask";
				$iroute[]="iroute $num $site_mask";
				$already[$num]=true;
			}
		}
 		echo "Starting......: OpenVPN cdd $sitename\n";
 		@file_put_contents("/etc/openvpn/cdd/$sitename",@implode("\n", $iroute) );
 		
 	}
 	if(count($rou)>0){
 		$localroutes=@implode(" ", $rou);
 		$client_config_dir=" --client-config-dir /etc/openvpn/cdd";
 	}
 	
 	 
 	
 	$LDAP_AUTH=$ini->_params["GLOBAL"]["LDAP_AUTH"];
 	if($LDAP_AUTH==1){
 		if(is_file("/usr/lib/openvpn/openvpn-auth-pam.so")){
 		$plugin=" --plugin /usr/lib/openvpn/openvpn-auth-pam.so common-auth";
 		echo "Starting......: OpenVPN auth is enabled\n";
 		shell_exec("/usr/share/artica-postfix/bin/artica-install --nsswitch");
 		}
 	}
   
   @mkdir("/etc/openvpn/ccd",0666,true);
   $php5=$unix->LOCATE_PHP5_BIN();
   $me=__FILE__;
   $cmd=" --port $port --dev tun $proto --server $IP_START $NETMASK$localroutes$client_config_dir --comp-lzo $local --ca $ca --dh $dh --key $key --cert $crt";
   $cmd=$cmd. "$ifconfig_pool_persist " . implode(" ",$routess);
   $cmd=$cmd. " $askpass$duplicate_cn--client-to-client$script_security$plugin --learn-address \"$php5 $me --client-connect\" --keepalive 10 60 --persist-tun --verb 5 --daemon --writepid /var/run/openvpn/openvpn-server.pid --log \"/var/log/openvpn/openvpn.log\"";
   $cmd=$cmd. " --status /var/log/openvpn/openvpn-status.log 10";
   echo "Starting......: OpenVPN building /etc/openvpn/cmdline.conf done\n";
   @file_put_contents("/etc/openvpn/cmdline.conf",$cmd);
  
   
   $sock->SaveConfigFile($ini->toString(),"ArticaOpenVPNSettings");
   send_email_events("OpenVPN was successfully reconfigured",$cmd,"VPN");
   echo "Starting......: OpenVPN building settings done.\n";
   if($GLOBALS["VERBOSE"]){writelogs("$cmd",__FUNCTION__,__FILE__,__LINE__);}
}
Beispiel #13
0
function ChecksDNSBL($iptocheck = null, $output = false, $increment = false)
{
    if (trim($iptocheck == "--force")) {
        $iptocheck = null;
        $output = false;
    }
    $textip = null;
    if ($iptocheck == null) {
        $myip = GetMyIp();
    } else {
        $myip = $iptocheck;
    }
    if (!preg_match("#[0-9+]\\.[0-9+]\\.[0-9+]\\.[0-9+]#", $myip)) {
        $textip = " ({$myip}) ";
        $myip = gethostbyname($myip);
        if ($GLOBALS["VERBOSE"]) {
            echo "Checking {$myip}...........: was{$textip}\n";
        }
    }
    $sock = new sockets();
    $unix = new unix();
    $RBLCheckFrequency = $sock->GET_INFO("RBLCheckFrequency");
    $RBLCheckNotification = $sock->GET_INFO("RBLCheckNotification");
    if (!is_numeric($RBLCheckFrequency)) {
        $RBLCheckFrequency = 60;
    }
    if (!is_numeric($RBLCheckNotification)) {
        $RBLCheckNotification = 0;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Checking {$myip}{$textip}...........: RBLCheckFrequency...: {$RBLCheckFrequency}\n";
        echo "Checking {$myip}{$textip}...........: RBLCheckNotification: {$RBLCheckNotification}\n";
    }
    if (!$GLOBALS["FORCE"]) {
        $md = md5($myip);
        $timefile = "/etc/artica-postfix/cron.1/ChecksDNSBL.{$md}.time";
        if (!$GLOBALS["VERBOSE"]) {
            $time = file_time_min($timefile);
            if ($time < $RBLCheckFrequency) {
                echo @file_get_contents($timefile);
                return;
            }
        }
        @unlink($timefile);
        @file_put_contents($timefile, "#");
    }
    include_once 'Net/DNSBL.php';
    $dnsbl = new Net_DNSBL();
    if (!isset($GLOBALS["DDNS"])) {
        $sql = "SELECT * FROM rbl_servers WHERE enabled=1 ORDER BY `rbl`";
        $q = new mysql();
        $results = $q->QUERY_SQL($sql, "artica_backup");
        if ($q->ok) {
            while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
                $GLOBALS["DDNS"][] = $ligne["rbl"];
            }
        }
    }
    if (count($GLOBALS["DDNS"]) == 0) {
        $GLOBALS["DDNS"][] = "b.barracudacentral.org";
        $GLOBALS["DDNS"][] = "bl.deadbeef.com";
        $GLOBALS["DDNS"][] = "bl.emailbasura.org";
        $GLOBALS["DDNS"][] = "bl.spamcannibal.org";
        $GLOBALS["DDNS"][] = "bl.spamcop.net";
        //$dnss[]="blackholes.five-ten-sg.com";
        $GLOBALS["DDNS"][] = "blacklist.woody.ch";
        $GLOBALS["DDNS"][] = "bogons.cymru.com";
        $GLOBALS["DDNS"][] = "cbl.abuseat.org";
        $GLOBALS["DDNS"][] = "cdl.anti-spam.org.cn";
        $GLOBALS["DDNS"][] = "combined.abuse.ch";
        $GLOBALS["DDNS"][] = "combined.rbl.msrbl.net";
        $GLOBALS["DDNS"][] = "db.wpbl.info";
        $GLOBALS["DDNS"][] = "dnsbl-1.uceprotect.net";
        $GLOBALS["DDNS"][] = "dnsbl-2.uceprotect.net";
        $GLOBALS["DDNS"][] = "dnsbl-3.uceprotect.net";
        $GLOBALS["DDNS"][] = "dnsbl.ahbl.org";
        $GLOBALS["DDNS"][] = "dnsbl.cyberlogic.net";
        $GLOBALS["DDNS"][] = "dnsbl.inps.de";
        $GLOBALS["DDNS"][] = "dnsbl.njabl.org";
        $GLOBALS["DDNS"][] = "dnsbl.sorbs.net";
        $GLOBALS["DDNS"][] = "drone.abuse.ch";
        $GLOBALS["DDNS"][] = "drone.abuse.ch";
        $GLOBALS["DDNS"][] = "duinv.aupads.org";
        $GLOBALS["DDNS"][] = "dul.dnsbl.sorbs.net";
        $GLOBALS["DDNS"][] = "dul.ru";
        $GLOBALS["DDNS"][] = "dyna.spamrats.com";
        $GLOBALS["DDNS"][] = "dynip.rothen.com";
        $GLOBALS["DDNS"][] = "fl.chickenboner.biz";
        $GLOBALS["DDNS"][] = "http.dnsbl.sorbs.net";
        $GLOBALS["DDNS"][] = "images.rbl.msrbl.net";
        $GLOBALS["DDNS"][] = "ips.backscatterer.org";
        $GLOBALS["DDNS"][] = "ix.dnsbl.manitu.net";
        $GLOBALS["DDNS"][] = "korea.services.net";
        $GLOBALS["DDNS"][] = "misc.dnsbl.sorbs.net";
        $GLOBALS["DDNS"][] = "noptr.spamrats.com";
        $GLOBALS["DDNS"][] = "ohps.dnsbl.net.au";
        $GLOBALS["DDNS"][] = "omrs.dnsbl.net.au";
        $GLOBALS["DDNS"][] = "orvedb.aupads.org";
        $GLOBALS["DDNS"][] = "osps.dnsbl.net.au";
        $GLOBALS["DDNS"][] = "osrs.dnsbl.net.au";
        $GLOBALS["DDNS"][] = "owfs.dnsbl.net.au";
        $GLOBALS["DDNS"][] = "owps.dnsbl.net.au";
        $GLOBALS["DDNS"][] = "pbl.spamhaus.org";
        $GLOBALS["DDNS"][] = "phishing.rbl.msrbl.net";
        $GLOBALS["DDNS"][] = "probes.dnsbl.net.au";
        $GLOBALS["DDNS"][] = "proxy.bl.gweep.ca";
        $GLOBALS["DDNS"][] = "proxy.block.transip.nl";
        $GLOBALS["DDNS"][] = "psbl.surriel.com";
        $GLOBALS["DDNS"][] = "rbl.interserver.net";
        $GLOBALS["DDNS"][] = "rdts.dnsbl.net.au";
        $GLOBALS["DDNS"][] = "relays.bl.gweep.ca";
        $GLOBALS["DDNS"][] = "relays.bl.kundenserver.de";
        $GLOBALS["DDNS"][] = "relays.nether.net";
        $GLOBALS["DDNS"][] = "residential.block.transip.nl";
        $GLOBALS["DDNS"][] = "ricn.dnsbl.net.au";
        $GLOBALS["DDNS"][] = "rmst.dnsbl.net.au";
        $GLOBALS["DDNS"][] = "sbl.spamhaus.org";
        $GLOBALS["DDNS"][] = "short.rbl.jp";
        $GLOBALS["DDNS"][] = "smtp.dnsbl.sorbs.net";
        $GLOBALS["DDNS"][] = "socks.dnsbl.sorbs.net";
        $GLOBALS["DDNS"][] = "spam.abuse.ch";
        $GLOBALS["DDNS"][] = "spam.dnsbl.sorbs.net";
        $GLOBALS["DDNS"][] = "spam.rbl.msrbl.net";
        $GLOBALS["DDNS"][] = "spam.spamrats.com";
        $GLOBALS["DDNS"][] = "spamlist.or.kr";
        $GLOBALS["DDNS"][] = "spamrbl.imp.ch";
        $GLOBALS["DDNS"][] = "t3direct.dnsbl.net.au";
        $GLOBALS["DDNS"][] = "tor.ahbl.org";
        $GLOBALS["DDNS"][] = "tor.dnsbl.sectoor.de";
        $GLOBALS["DDNS"][] = "torserver.tor.dnsbl.sectoor.de";
        $GLOBALS["DDNS"][] = "ubl.lashback.com";
        $GLOBALS["DDNS"][] = "ubl.unsubscore.com";
        $GLOBALS["DDNS"][] = "virbl.bit.nl";
        $GLOBALS["DDNS"][] = "virus.rbl.jp";
        $GLOBALS["DDNS"][] = "virus.rbl.msrbl.net";
        $GLOBALS["DDNS"][] = "web.dnsbl.sorbs.net";
        $GLOBALS["DDNS"][] = "wormrbl.imp.ch";
        $GLOBALS["DDNS"][] = "xbl.spamhaus.org";
        $GLOBALS["DDNS"][] = "zen.spamhaus.org";
        $GLOBALS["DDNS"][] = "zombie.dnsbl.sorbs.net";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Checking {$myip}{$textip}...........: checking............: " . count($GLOBALS["DDNS"]) . " rbls servers\n";
        echo "Checking {$myip}{$textip}...........: Output..............: {$output}\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "checking " . count($GLOBALS["DDNS"]) . " rbls servers\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Checking {$myip}...........: ->setBlacklists();\n";
    }
    reset($GLOBALS["DDNS"]);
    $dnsbl->setBlacklists($GLOBALS["DDNS"]);
    if (!$output) {
        if (!$increment) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Delete /usr/share/artica-postfix/ressources/logs/web/blacklisted.html\n";
            }
            @unlink("/usr/share/artica-postfix/ressources/logs/web/blacklisted.html");
        }
    }
    if ($output) {
        if ($dnsbl->isListed($myip)) {
            $blacklist = $dnsbl->getListingBl($myip);
            $detail = $dnsbl->getDetails($myip);
            $final = "{$blacklist};{$detail["txt"][0]}";
            @file_put_contents($timefile, $final);
            echo $final;
        }
        return;
    }
    $date = date('l F H:i');
    if ($GLOBALS["VERBOSE"]) {
        echo "Checking {$myip}{$textip}...........: Output..............: {$date}\n";
    }
    if (!$increment) {
        @unlink("/usr/share/artica-postfix/ressources/logs/web/blacklisted.html");
        @unlink("/usr/share/artica-postfix/ressources/logs/web/Notblacklisted.html");
    }
    if ($dnsbl->isListed($myip)) {
        $blacklist = $dnsbl->getListingBl($myip);
        if ($RBLCheckNotification == 1) {
            $unix->send_email_events("Your server ({$myip}{$textip}) is blacklisted from {$blacklist}", "This is the result of checking your server from " . count($GLOBALS["DDNS"]) . " black list servers.\n   It seems your server (ip:{$myip}{$textip}) is blacklisted from {$blacklist}\n   If you trying to send mails from this server, it should be rejected from many SMTP servers that use \"{$blacklist}\" for check senders IP addresses.\n   ", "postfix");
        }
        echo "{$myip}: blacklisted from {$blacklist} write \"/usr/share/artica-postfix/ressources/logs/web/blacklisted.html\"\n";
        $p = Paragraphe('danger64.png', "{WARN_BLACKLISTED}", "{$myip}{$textip} {IS_BLACKLISTED_FROM} {$blacklist} ({$date})", "javascript:Loadjs('system.rbl.check.php')", "{$myip} {IS_BLACKLISTED_FROM} {$blacklist}", 300, 80);
        if ($increment) {
            $p = @file_get_contents("/usr/share/artica-postfix/ressources/logs/web/blacklisted.html") . $p;
        }
        @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/blacklisted.html", $p);
        shell_exec("/bin/chmod 777 /usr/share/artica-postfix/ressources/logs/web/blacklisted.html >/dev/null 2>&1");
        return;
    } else {
        if ($GLOBALS["VERBOSE"]) {
            echo "checking " . count($GLOBALS["DDNS"]) . " rbls servers success\n";
        }
    }
    $dnsbl = new Net_DNSBL();
    reset($GLOBALS["DDNS"]);
    $dnsbl->setBlacklists($GLOBALS["DDNS"]);
    if ($dnsbl->isListed($myip)) {
        $blacklist = $dnsbl->getListingBl($myip);
        if ($RBLCheckNotification == 1) {
            send_email_events("Your server ({$myip}{$textip}) is blacklisted from {$blacklist}", "This is the result of checking your server from " . count($GLOBALS["DDNS"]) . " black list servers.\n\t   It seems your server (ip:{$myip}{$textip}) is blacklisted from {$blacklist}\n\t   If you trying to send mails from this server, it should be rejected from many SMTP servers that use \"{$blacklist}\" for check senders IP addresses.\n\t   ", "postfix");
        }
        echo "{$myip}{$textip}: blacklisted from {$blacklist} write \"/usr/share/artica-postfix/ressources/logs/web/blacklisted.html\"\n";
        $p = Paragraphe('danger64.png', "{WARN_BLACKLISTED}", "{$myip}{$textip} {IS_BLACKLISTED_FROM} {$blacklist} ({$date})", "javascript:Loadjs('system.rbl.check.php')", "{$myip}{$textip} {IS_BLACKLISTED_FROM} {$blacklist}", 300, 80);
        if ($increment) {
            $p = @file_get_contents("/usr/share/artica-postfix/ressources/logs/web/blacklisted.html") . $p;
        }
        @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/blacklisted.html", $p);
        shell_exec("/bin/chmod 777 /usr/share/artica-postfix/ressources/logs/web/blacklisted.html >/dev/null 2>&1");
        return;
    } else {
        if ($GLOBALS["VERBOSE"]) {
            echo "checking " . count($GLOBALS["DDNS"]) . " rbls servers success\n";
        }
    }
    $p = Paragraphe('ok64.png', "{NOT_BLACKLISTED}", "{$myip}{$textip} {IS_NOT_BLACKLISTED } ({$date})", "javascript:Loadjs('system.rbl.check.php')", null, 300, 80);
    if ($increment) {
        $p = @file_get_contents("/usr/share/artica-postfix/ressources/logs/web/Notblacklisted.html") . $p;
    }
    @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/Notblacklisted.html", $p);
    shell_exec("/bin/chmod 777 /usr/share/artica-postfix/ressources/logs/web/Notblacklisted.html >/dev/null 2>&1");
}
Beispiel #14
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");
}
Beispiel #15
0
function backup_mysql($ID, $instance_id = 0)
{
    include_once dirname(__FILE__) . '/ressources/class.mysql-multi.inc';
    $sock = new sockets();
    $unix = new unix();
    $date_start = time();
    $TpmPrefix = null;
    $RemotePathSuffix = null;
    $instancename = null;
    $mysqlhotcopy = $unix->find_program("mysqlhotcopy");
    $email_spacer = "==========================================";
    if ($instance_id > 0) {
        $mysql = new mysql_multi($instance_id);
        $instancename = " ({$mysql->MyServer}) ";
    }
    if ($mysqlhotcopy == null) {
        backup_events($ID, "mysql", "ERROR, unable to stat mysqlhotcopy");
        if (is_file($unix->find_program("mysqldump"))) {
            backup_events($ID, "mysql", "INFO,{$instancename} switch to mysqldump processing");
            return backup_mysql_oldway($ID, $instance_id);
        }
        events("ERROR, unable to stat mysqlhotcopy", __FUNCTION__, __LINE__);
        send_email_events("Backup Task {$ID}:: Unable to backup mysql datas ", "ERROR, unable to stat mysqlhotcopy", "backup");
        return false;
    }
    $array = backup_mysql_databases_list($ID, $instance_id);
    if (!is_array($array)) {
        events("ERROR,{$instancename} unable to get databases list", __FUNCTION__, __LINE__);
        send_email_events("Backup Task {$ID}::{$instancename} Unable to backup mysql datas ", "ERROR, unable to get databases list", "backup");
        backup_events($ID, "mysql", "ERROR,{$instancename} unable to get databases list", __LINE__);
        return false;
    }
    $q = new mysql();
    if ($instance_id > 0) {
        $q = new mysql_multi($instance_id);
        $TpmPrefix = $instance_id;
        $Socket = " --socket={$q->SocketPath}";
        $RemotePathSuffix = "-{$q->MyServerCMDLINE}";
    }
    if ($q->mysql_password != null) {
        $password = "******";
    }
    if ($q->mysql_admin != null) {
        $user = "******";
    }
    $temporarySourceDir = $sock->GET_INFO("ExecBackupTemporaryPath");
    if ($temporarySourceDir == null) {
        $temporarySourceDir = "/home/mysqlhotcopy";
    }
    $temporarySourceDir = "{$temporarySourceDir}/mysql{$TpmPrefix}";
    events("temporarySourceDir has ExecBackupTemporaryPath token was \"{$temporarySourceDir}\"", __FUNCTION__, __LINE__);
    events("Creating {$temporarySourceDir}", __FUNCTION__, __LINE__);
    @mkdir($temporarySourceDir, 0755, true);
    if (!is_dir($temporarySourceDir)) {
        events("Creating Unable to backup mysql datas ", "ERROR,{$instancename} {$temporarySourceDir} permission denied or no such file or directory", __FUNCTION__, __LINE__);
        send_email_events("Backup Task {$ID}::{$instancename} Unable to backup mysql datas ", "ERROR, {$temporarySourceDir} permission denied or no such file or directory", "backup");
        backup_events($ID, "mysql", "ERROR,{$instancename} {$temporarySourceDir} permission denied or no such file or directory");
        return;
    }
    $BlacklistDatabases["performance_schema"] = true;
    $BlacklistDatabases["mysql"] = true;
    $BlacklistDatabases["log"] = true;
    backup_events($ID, "mysql", "INFO,{$instancename} using {$temporarySourceDir} for temp backup");
    while (list($num, $line) = each($array)) {
        if (trim($line) == null) {
            continue;
        }
        $database_name = trim(basename($line));
        $database_nameSTR = strtolower($database_name);
        if (isset($BlacklistDatabases[$database_nameSTR])) {
            events("{$instancename}skipping database \"{$database_name}\"", __FUNCTION__, __LINE__);
            backup_events($ID, "mysql", "INFO,{$instancename} mysqlhotcopy skip {$database_nameSTR} database", __LINE__);
            continue;
        }
        backup_events($ID, "mysql", "INFO,{$instancename} mysqlhotcopy database ({$database_name}) stored in {$line} -> {$temporarySourceDir}");
        $mysqlhotcopy_command = "{$mysqlhotcopy} --addtodest{$Socket}{$user}{$password} {$database_name} {$temporarySourceDir} 2>&1";
        events("\"{$mysqlhotcopy_command}\"", __FUNCTION__, __LINE__);
        exec($mysqlhotcopy_command, $results);
        while (list($num_line, $evenement) = each($results)) {
            if (preg_match("#No space left on device#", $evenement)) {
                events("ERROR, backup No space left on device ({$temporarySourceDir})", __FUNCTION__, __LINE__);
                backup_events($ID, "mysql", "ERROR,{$instancename} backup No space left on device ({$temporarySourceDir})\n" . implode("\n", $results));
                if (is_dir($temporarySourceDir)) {
                    shell_exec("/bin/rm -rf {$temporarySourceDir}/*");
                }
                return;
            }
            events("{$evenement}", __FUNCTION__, __LINE__);
            if (preg_match("#failed:#", $evenement)) {
                events("ERROR,{$instancename} database: \"{$database_name}\" ({$evenement})", __FUNCTION__, __LINE__);
                backup_events($ID, "mysql", "ERROR,{$instancename} database: \"{$database_name}\" ({$evenement})");
                $fulltext = @implode("\n", $results);
                send_email_events("Backup Task {$ID}::{$instancename} database: \"{$database_name}\" failed to backup ", "{$email_spacer}\n{$mysqlhotcopy_command}{$email_spacer}\nERROR:{$email_spacer}\n{$evenement}\n{$email_spacer}\n{$fulltext}", "backup");
            }
        }
        backup_events($ID, "mysql", "INFO,{$instancename} backup {$database_name}\n" . implode("\n", $results), __LINE__);
        if (strtolower($database_name) == "zarafa") {
            events("{$instancename}zarafa database -> backup_mysql_database_mysqldump({$ID},zarafa,{$temporarySourceDir})", __FUNCTION__, __LINE__);
            backup_mysql_database_mysqldump($ID, "zarafa", $temporarySourceDir, $instance_id);
        }
    }
    backup_events($ID, "mysql", "INFO,{$instancename} Send mysql backup to the \n" . implode("\n", $results));
    events("Create directory \"{$GLOBALS["MOUNTED_PATH_FINAL"]}/mysql{$RemotePathSuffix}\"", __FUNCTION__, __LINE__);
    backup_mkdir("{$GLOBALS["MOUNTED_PATH_FINAL"]}/mysql{$RemotePathSuffix}");
    backup_copy("{$temporarySourceDir}/*", "mysql{$RemotePathSuffix}", $ID);
    backup_events($ID, "mysql", "INFO,{$instancename} backup remove content of {$temporarySourceDir}/*");
    events("INFO,{$instancename} backup remove content of {$temporarySourceDir}/*", __FUNCTION__, __LINE__);
    if (is_dir($temporarySourceDir)) {
        events("/bin/rm -rf {$temporarySourceDir}/*", __FUNCTION__, __LINE__);
        shell_exec("/bin/rm -rf {$temporarySourceDir}/*");
    }
    backup_events($ID, "mysql", "INFO,{$instancename} backup END without known error");
    $date_end = time();
    $calculate = distanceOfTimeInWords($date_start, $date_end);
    events("INFO,{$instancename} time: {$calculate}", __FUNCTION__, __LINE__);
    backup_events($ID, "mysql", "INFO,{$instancename} time: {$calculate}");
}
Beispiel #16
0
function corrupted_file($filesource)
{
    if (preg_match("#\\/var\\/spool\\/artica-emailing\\/queues\\/([0-9]+)\\/emailrelay\\.#", $filesource, $re)) {
        $ID = $re[1];
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "corrupted_file:: ID:{$ID}\n";
    }
    if (strpos($filesource, "envelope.busy") > 0) {
        $replace_source = "envelope.busy";
    }
    if (strpos($filesource, "envelope.bad") > 0) {
        $replace_source = "envelope.bad";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "corrupted_file:: replace:{$replace_source}\n";
    }
    $enveloppe = str_replace("{$replace_source}", "envelope", $filesource);
    $content = str_replace("{$replace_source}", "content", $filesource);
    if ($GLOBALS["VERBOSE"]) {
        echo "corrupted_file:: enveloppe:{$enveloppe}\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "corrupted_file:: content..:{$content}\n";
    }
    $f = explode("\n", @file_get_contents($enveloppe));
    if (is_array($f)) {
        while (list($num, $line) = each($f)) {
            if (preg_match("#X-MailRelay-From:\\s+(.+?)\$#", $line, $re)) {
                $mailfrom = trim($re[1]);
            }
            if (preg_match("#X-MailRelay-To-Remote:\\s+(.+?)\$#", $line, $re)) {
                $mailto = trim($re[1]);
            }
        }
    }
    $basename = basename($enveloppe);
    if ($GLOBALS["VERBOSE"]) {
        echo "corrupted_file:: {$basename} from=<{$mailfrom}>\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "corrupted_file:: {$basename} to=<{$mailto}>\n";
    }
    @unlink($enveloppe);
    @unlink($content);
    write_syslog("[{$ID}]: Corrupted file {$basename} from {$mailfrom} to {$mailto}", basename(__FILE__));
    if (is_numeric($ID)) {
        if ($ID > 0) {
            send_email_events("[emailing instance {$ID}]: Corrupted file {$basename} from {$mailfrom} to {$mailto}", "files {$enveloppe}\n{$content} has been removed from queue", "system");
            emailing_emailrelay_start($ID);
        }
    }
    //;
}
Beispiel #17
0
function export_openvpn_sites_package()
{
    $sock = new sockets();
    $q = new mysql();
    $sql = "SELECT * FROM vpnclient WHERE connexion_type=1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $sitename = $ligne["sitename"];
        $servername = $ligne["servername"];
        $IP_START = $ligne["IP_START"];
        $meta = new artica_meta();
        $ovpnfile = _export_ovpn($sitename);
        if (!$ovpnfile) {
            send_email_events("{$sitename} failed to export vpn configuration to global Management console (CORRUPTED) datas", @implode("\n", $GLOBALS["html_logs"]), "CLOUD");
            events("User {$sitename} failed to export vpn configuration to global Management console (CORRUPTED) datas", __FUNCTION__, __FILE__, __LINE__);
            continue;
        }
        $meta = new artica_meta();
        $http = new httpget();
        $http->uploads["OVPNSITE"] = $ovpnfile;
        $body = $http->send("{$meta->ArticaMetaHostname}/lic.users.import.php", "post", array("DATAS" => base64_encode(serialize($meta->GLOBAL_ARRAY)), "sitename" => $sitename, "servername" => $servername, "IP_START" => $IP_START));
        @unlink($ovpnfile);
    }
}
Beispiel #18
0
function maintenance()
{
    return null;
    $unix = new unix();
    $time = $unix->file_time_min("/etc/artica-postfix/mysql.optimize.time");
    $time1 = time();
    $myisamchk = $unix->find_program("myisamchk");
    $mysqlcheck = $unix->find_program("mysqlcheck");
    if (!$GLOBALS["VERBOSE"]) {
        if ($time < 1440) {
            $unix->events(__FILE__ . "::" . __FUNCTION__ . " {$time}Mn wait 1440Mn, aborting");
            return;
        }
    }
    $mysqlcheck_logs = "";
    @unlink("/etc/artica-postfix/mysql.optimize.time");
    @file_put_contents("/etc/artica-postfix/mysql.optimize.time", "#");
    if (is_file($mysqlcheck)) {
        exec("{$mysqlcheck} -A -1 2>&1", $mysqlcheck_array);
        $mysqlcheck_logs = $mysqlcheck_logs . "\n" . @implode("\n", $mysqlcheck_array);
        unset($mysqlcheck_array);
    }
    $q = new mysql();
    $sql = "SHOW TABLES";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $table = $ligne["Tables_in_artica_backup"];
        $tt = time();
        if (is_file($mysqlcheck)) {
            exec("{$mysqlcheck} -r artica_backup  {$table} 2>&1", $mysqlcheck_array);
            $mysqlcheck_logs = $mysqlcheck_logs . "\n" . @implode("\n", $mysqlcheck_array);
            unset($mysqlcheck_array);
        }
        echo $table . "\n";
        if (is_file($myisamchk)) {
            shell_exec("{$myisamchk} -r --safe-recover --force /var/lib/mysql/artica_backup/{$table}");
        } else {
            $q->REPAIR_TABLE("artica_backup", $table);
        }
        $q->QUERY_SQL("OPTIMIZE table {$table}", "artica_backup");
        $time_duration = distanceOfTimeInWords($tt, time());
        $p[] = "artica_backup/{$table} {$time_duration}";
    }
    $sql = "SHOW TABLES";
    $results = $q->QUERY_SQL($sql, "artica_events");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $table = $ligne["Tables_in_artica_events"];
        $tt = time();
        echo "Repair & optimize {$table}\n";
        if (is_file($mysqlcheck)) {
            exec("{$mysqlcheck} -r artica_events {$table} 2>&1", $mysqlcheck_array);
            $mysqlcheck_logs = $mysqlcheck_logs . "\n" . @implode("\n", $mysqlcheck_array);
            unset($mysqlcheck_array);
        }
        if (is_file($myisamchk)) {
            shell_exec("{$myisamchk} -r --safe-recover --force /var/lib/mysql/artica_events/{$table}");
        } else {
            $q->REPAIR_TABLE("artica_events", $table);
        }
        $q->QUERY_SQL("OPTIMIZE table {$table}", "artica_events");
        $time_duration = distanceOfTimeInWords($tt, time());
        $p[] = "artica_events/{$table} {$time_duration}";
    }
    $t2 = time();
    $time_duration = distanceOfTimeInWords($time1, $t2);
    send_email_events("Maintenance on databases artica_backup & artica_events done {$time_duration}", "Operations has be proceed on \n" . @implode("\n", $p) . "\nmysqlchecks results:\n{$mysqlcheck_logs}", "system");
}
function ParseRetranslatorLogs()
{
    $unix = new unix();
    if ($unix->PIDOF("/usr/share/artica-postfix/bin/retranslator.bin") > 0) {
        return;
    }
    $dir = "/var/log/kretranslator";
    if (!is_dir($dir)) {
        return null;
    }
    $unix = new unix();
    $files = $unix->DirFiles($dir);
    while (list($num, $file) = each($files)) {
        if (!preg_match("#retranslator-([0-9\\-]+)_([0-9]+)-([0-9]+)-([0-9]+).debug#", $file, $re)) {
            continue;
        }
        $date = "{$re[1]} {$re[2]}:{$re[3]}:{$re[4]}";
        $NumberofFilesUpdated = NumberofRestransFilesUpdated("{$dir}/{$file}");
        if ($NumberofFilesUpdated[0] > 0) {
            $subject = "Kaspersky Retranslator: {$NumberofFilesUpdated[0]} files updated ({$NumberofFilesUpdated[1]})";
            send_email_events($subject, @file_get_contents("{$dir}/{$file}"), "KASPERSKY_UPDATES", $date);
            @unlink("{$dir}/{$file}");
            continue;
        }
        @unlink("{$dir}/{$file}");
    }
}
$unix = new unix();
if ($unix->process_exists(@file_get_contents($pidfile))) {
    echo "Process already exists...\n";
    die;
}
@file_put_contents($pidfile, getmypid());
$t1 = time();
$time = date('Y-m-d') . "_" . date('h:i');
$ini = new Bs_IniHandler();
$ini->loadFile("/etc/artica-postfix/settings/Daemons/CyrusAVConfig");
$nice = EXEC_NICE();
$clamscan = $unix->find_program("clamscan");
if (!is_file($clamscan)) {
    die;
}
$partition_default = $unix->IMAPD_GET("partition-default");
if (!is_dir($partition_default)) {
    send_email_events("Mailboxes antivirus scanning failed", "partition-default: \"{$partition_default}\"\nno such directory", "mailbox");
    echo "partition-default: no such directory\n";
    die;
}
@mkdir("/var/log/artica-postfix/antivirus/cyrus-imap", 0755, true);
$time = date('Y-m-d') . "_" . date('h:I');
$cmd = "{$nice} /usr/bin/clamscan --recursive=yes --infected ";
$cmd = $cmd . "--max-filesize=10M --max-scansize=10M --max-recursion=5 --max-dir-recursion=10 ";
$cmd = $cmd . "--log=/log/artica-postfix/antivirus/cyrus-imap/{$time}.scan {$partition_default}";
shell_exec($cmd);
$t2 = time();
$time_duration = distanceOfTimeInWords($t1, $t2);
send_email_events("Mailboxes antivirus scan terminated: {$time_duration}", @file_get_contents("/log/artica-postfix/antivirus/cyrus-imap/{$time}.scan"), "mailbox");
function UFDBGUARD_COMPILE_DB()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/UFDBGUARD_COMPILE_DB.pid";
    if ($unix->process_exists(@file_get_contents($pidfile))) {
        echo "Process already exists PID: " . @file_get_contents($pidfile) . "\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $ufdbGenTable = $unix->find_program("ufdbGenTable");
    $datas = explode("\n", @file_get_contents("/etc/squid/squidGuard.conf"));
    if (strlen($ufdbGenTable) < 5) {
        echo "ufdbGenTable no such file\n";
        return;
    }
    $md5db = unserialize(@file_get_contents("/etc/artica-postfix/ufdbGenTableMD5"));
    $count = 0;
    while (list($a, $b) = each($datas)) {
        if (preg_match("#domainlist.+?(.+)\\/domains#", $b, $re)) {
            $f["/var/lib/squidguard/{$re[1]}"] = "/var/lib/squidguard/{$re[1]}";
        }
    }
    if (!is_array($datas)) {
        echo "No databases set\n";
        return;
    }
    while (list($directory, $b) = each($f)) {
        $mustrun = false;
        if (preg_match("#.+?\\/([a-zA-Z0-9\\-\\_]+)\$#", $directory, $re)) {
            $category = $re[1];
            $category = substr($category, 0, 15);
            if ($GLOBALS["VERBOSE"]) {
                echo "Checking {$category}\n";
            }
        }
        // ufdbGenTable -n -D -W -t adult -d /var/lib/squidguard/adult/domains -u /var/lib/squidguard/adult/urls
        if (is_file("{$directory}/domains")) {
            $md5 = FileMD5("{$directory}/domains");
            if ($md5 != $md5db["{$directory}/domains"]) {
                $mustrun = true;
                $md5db["{$directory}/domains"] = $md5;
                $dbb[] = "{$directory}/domains";
            } else {
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$md5} is the same, skip {$directory}/domains\n";
                }
            }
            $d = " -d {$directory}/domains";
        } else {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$directory}/domains no such file\n";
            }
        }
        if (is_file("{$directory}/urls")) {
            $md5 = FileMD5("{$directory}/urls");
            if ($md5 != $md5db["{$directory}/urls"]) {
                $mustrun = true;
                $md5db["{$directory}/urls"] = $md5;
                $dbb[] = "{$directory}/urls";
            }
            $u = " -u {$directory}/urls";
        }
        if (!is_file("{$directory}/domains.ufdb")) {
            $mustrun = true;
            $dbb[] = "{$directory}/*";
        }
        if ($mustrun) {
            $dbcount = $dbcount + 1;
            $cmd = "{$ufdbGenTable} -n -D -W -t {$category}{$d}{$u}";
            echo $cmd . "\n";
            shell_exec($cmd);
        }
        $u = null;
        $d = null;
        $md5 = null;
    }
    @file_put_contents("/etc/artica-postfix/ufdbGenTableMD5", serialize($md5db));
    $user = GetSquidUser();
    $chown = $unix->find_program($chown);
    if (is_file($chown)) {
        shell_exec("{$chown} -R {$user} /var/lib/squidguard/*");
        shell_exec("{$chown} -R {$user} /var/log/squid/*");
    }
    if ($dbcount > 0) {
        send_email_events("Maintenance on Web Proxy urls Databases: {$dbcount} database(s)", @implode("\n", $dbb) . "\n", "system");
    }
}
Beispiel #22
0
function email_events($subject, $text, $context)
{
    send_email_events($subject, $text, $context);
}
function ScanPostfixID($q)
{
    $q = new mysql();
    $unix = new unix();
    $super = 0;
    $path = "{$GLOBALS["ARTICALOGDIR"]}/RTM";
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $timesched = $unix->file_time_min($timefile);
    if ($timesched <= $GLOBALS["ArticaSMTPStatsTimeFrame"]) {
        if ($GLOBALS["VERBOSE"]) {
            echo "{$timesched}/{$GLOBALS["ArticaSMTPStatsTimeFrame"]} aborting\n";
        }
        return;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Scanning {$path}...\n";
    }
    $startedAT = date("Y-m-d H:i:s");
    $count = 0;
    if (!($handle = opendir($path))) {
        @mkdir($path, 0755, true);
        return;
    }
    $countDeFiles = 0;
    $KILL_THIS_QUEUE = false;
    while (false !== ($file = readdir($handle))) {
        if ($file == ".") {
            continue;
        }
        if ($file == "..") {
            continue;
        }
        $targetFile = "{$path}/{$file}";
        $countDeFiles++;
        if ($countDeFiles > $GLOBALS["ArticaSMTPStatsMaxFiles"]) {
            break;
        }
        $count++;
        $super++;
        if (preg_match("#\\.id-message\$#", $file)) {
            $amavis[] = $file;
            continue;
        }
        events("ScanPostfixID():: ({$count}/{$GLOBALS["ArticaSMTPStatsMaxFiles"]})");
        events("ScanPostfixID()::  \"{$path}/{$file}\"");
        if (!preg_match("#\\.msg\$#", $file)) {
            continue;
        }
        if ($file == "NOQUEUE.msg") {
            events("ScanPostfixID():: Delete /{$path}/{$file}");
            @unlink("{$path}/{$file}");
            continue;
        }
        if ($KILL_THIS_QUEUE) {
            @unlink("/{$path}/{$file}");
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "ArticaStatusUsleep:{$GLOBALS["ArticaStatusUsleep"]}ms\n";
        }
        usleep($GLOBALS["ArticaStatusUsleep"]);
        if ($count > $GLOBALS["ArticaSMTPStatsMaxFiles"]) {
            events("ScanPostfixID():: Break...");
            break;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "PostfixFullProcess -> {$targetFile}\n";
        }
        $t1 = time();
        if (!PostfixFullProcess($targetFile, $q)) {
            continue;
        }
        $t2 = time();
        $distanceInSeconds = round(abs($t2 - $t1));
        if ($GLOBALS["VERBOSE"]) {
            echo "PostfixFullProcess -> {$distanceInSeconds} seconds\n";
        }
        if ($distanceInSeconds > 3) {
            send_email_events("Too many time parsing {$GLOBALS["ARTICALOGDIR"]}/RTM", "Processing file take more than 3s ({$distanceInSeconds}s) the realtime monitor will be kept for this queue..", "postfix");
            $KILL_THIS_QUEUE = true;
        }
        SetStatus("Postfix", $GLOBALS["ArticaSMTPStatsMaxFiles"], $count, $startedAT);
        events("ScanPostfixID():: ({$count}/{$GLOBALS["ArticaSMTPStatsMaxFiles"]}) with a sleep of {$GLOBALS["ArticaStatusUsleep"]} microseconds line " . __LINE__);
    }
    if (is_array($amavis)) {
        reset($amavis);
        $max = count($amavis);
        $count = 0;
        while (list($num, $file) = each($amavis)) {
            $count = $count + 1;
            $super++;
            if (!preg_match("#\\.id-message\$#", $file)) {
                continue;
            }
            events("ScanPostfixID():amavis_logger(): parsing /{$path}/{$file} {$count}/{$max}");
            SetStatus("amavis", $max, $count, $startedAT);
            amavis_logger("{$path}/{$file}");
        }
    }
    $path = "/tmp/savemail-infos";
    if (!($handle = opendir($path))) {
        @mkdir($path, 0755, true);
        return;
    }
    $max = $GLOBALS["ArticaSMTPStatsMaxFiles"];
    $count = 0;
    while (false !== ($file = readdir($handle))) {
        if ($file == ".") {
            continue;
        }
        if ($file == "..") {
            continue;
        }
        $targetFile = "{$path}/{$file}";
        $super++;
        events("ScanPostfixID():amavis_logger(): parsing /tmp/savemail-infos/{$file} {$count}/{$max}");
        amavis_logger("/tmp/savemail-infos/{$file}");
    }
    if ($super++ > 0) {
        $unix->THREAD_COMMAND_SET($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.postfix.vip.php");
        write_syslog("Success inserting {$super} mails events in mysql database...", __FILE__);
    }
}
Beispiel #24
0
function AutomaticInjectionAdd($MAC)
{
    echo "add {$MAC}\n";
    $cs = new ocs();
    if ($cs->INJECT_COMPUTER_TOLDAP($MAC)) {
        unset($GLOBALS["INJECT_COMPUTER_TOLDAP"]);
        $f = new computers();
        $uid = $f->ComputerIDFromMAC($ligne["MACADDR"]);
        $f = new computers($uid);
        $text[] = "uid\t:{$uid}";
        $text[] = "Computer\t:{$f->ComputerRealName}";
        $text[] = "IP\t:{$f->ComputerIP}";
        $text[] = "MAC\t:{$MAC}";
        send_email_events("New computer {$f->ComputerRealName} added into Database", @implode("\n", $text), "system");
    } else {
        $infos = @implode("\n", $GLOBALS["INJECT_COMPUTER_TOLDAP"]) . "\n\n" . @implode("\n", $text);
        send_email_events("Failed to inject computer {$f->ComputerRealName} ({$MAC})", $infos, "system");
    }
}
function upgrade($package){
	
	system('PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11');	
	$unix=new unix();
	$apt_get=$unix->find_program("apt-get");
	if($apt_get==null){return;}
	$cmd="DEBIAN_FRONTEND=noninteractive $apt_get -o Dpkg::Options::=\"--force-confnew\" -y install $package";
	if($GLOBALS["VERBOSE"]){echo $cmd."\n";}
	exec("DEBIAN_FRONTEND=noninteractive $apt_get -o Dpkg::Options::=\"--force-confnew\" -y install $package 2>&1",$results);
	$infos=@implode("\n",$results);
	if($GLOBALS["VERBOSE"]){echo $infos."\n";}
	unset($results);
	$update_grup=$unix->find_program("update-grub");
	if(is_file($update_grup)){
		exec($update_grup,$results);
	}
	if($GLOBALS["VERBOSE"]){echo @implode("\n",$results)."\n";}
	$infos=$infos."\n".@implode("\n",$results);
	
	send_email_events("Kernel $package upgrade results",$infos,"system");
	@unlink("/usr/share/artica-postfix/ressources/logs/kernel.lst");
	if(!$GLOBALS["VERBOSE"]){shell_exec("reboot");};
	
}
function DNS_DEL_ENTRY($value)
{
    $hostname = base64_decode($value);
    $EXEC_NICE = EXEC_NICE();
    if (is_file("/usr/bin/nohup")) {
        $nohup = "/usr/bin/nohup ";
    }
    $reload_datas = $nohup . $EXEC_NICE . LOCATE_PHP5_BIN() . " " . dirname(__FILE__) . "/exec.artica.meta.users.php --export-all-dns >/dev/null 2>&1 &";
    include_once dirname(__FILE__) . "/ressources/class.pdns.inc";
    $ldap = new clladp();
    $upd = array();
    $tbl = explode(".", $hostname);
    $dc = "dc=" . @implode(",dc=", $tbl);
    if ($ldap->ExistsDN("{$dc},ou=dns,{$ldap->suffix}")) {
        if ($ldap->ldap_delete("{$dc},ou=dns,{$ldap->suffix}", true)) {
            send_email_events("Success deleting DNS entry {$hostname}", "DN removed was : {$dc},ou=dns,{$ldap->suffix}", "CLOUD");
            return true;
        }
    } else {
        events("unable to stat {$dc},ou=dns,{$ldap->suffix}", __FUNCTION__, __FILE__, __LINE__);
    }
    $suffix = "ou=dns,{$ldap->suffix}";
    $pattern = "(&(objectclass=*)(associatedDomain={$hostname}))";
    $sr = @ldap_search($ldap->ldap_connection, $suffix, "{$pattern}", array());
    if ($sr) {
        $hash = ldap_get_entries($ldap->ldap_connection, $sr);
        for ($i = 0; $i < $hash["count"]; $i++) {
            $dn = $hash[$i]["dn"];
            if (strlen($dn) > 0) {
                $dns[] = $dn;
                events("removing  associateddomain={$hostname} in {$dn}", __FUNCTION__, __FILE__, __LINE__);
                $upd["associateddomain"] = $hostname;
                if (!$ldap->Ldap_del_mod($dn, $upd)) {
                    $dns[] = $ldap->ldap_last_error;
                }
            }
        }
        send_email_events("Success executing remove DNS entry {$hostname}", @implode("\n", $dns), "CLOUD");
        return true;
    }
    events("Failed -> notify", __FUNCTION__, __FILE__, __LINE__);
    send_email_events("Failed remove DNS entry {$hostname} does not exists", null, "CLOUD");
    shell_exec($reload_datas);
    return true;
}
Beispiel #27
0
function CleanLogs($aspid = false)
{
    $timefile = "/etc/artica-postfix/pids/exec.clean.logs.php.CleanLogs.time";
    if (!$aspid) {
        $maxtime = 480;
        $unix = new unix();
        $pidpath = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = @file_get_contents($pidpath);
        if ($unix->process_exists($pid)) {
            $unix->events(basename(__FILE__) . ":: " . __FUNCTION__ . " Already process {$pid} running.. Aborting");
            return;
        }
        @file_put_contents($pidpath, getmypid());
        $timeOfFile = $unix->file_time_min($timefile);
        $unix->events("CleanLogs():: Time {$timeOfFile}/{$maxtime}");
        if ($timeOfFile < $maxtime) {
            $unix->events("CleanLogs():: Aborting");
            return;
        }
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    cleanRoot();
    maillog();
    MakeSpace();
    cleanRoot();
    CheckSingle_logfile("/var/log/php.log", 102400);
    CheckSingle_logfile("/opt/squidsql/error.log", 51200);
    CheckSingle_logfile("/var/log/atop.log", 1024);
    CheckSingle_logfile("/var/log/php5-fpm.log", 1024);
    CheckSingle_logfile("/var/log/artica-squid-stats.log", 10240);
    CheckSingle_logfile("/var/log/atop.log", 10240);
    CheckSingle_logfile("/var/log/apache2/access-common.log", 204800);
    wrong_number();
    Clean_tmp_path();
    CleanOldInstall();
    LogRotateTimeAndSize("/var/log/samba");
    if (system_is_overloaded(dirname(__FILE__))) {
        $unix->send_email_events("logs cleaner task aborting, system is overloaded", "stopped after CleanOldInstall()\nWill restart in next cycle...", "system");
        return;
    }
    CleanBindLogs();
    if (system_is_overloaded(dirname(__FILE__))) {
        $unix->send_email_events("logs cleaner task aborting, system is overloaded", "stopped after CleanBindLogs()\nWill restart in next cycle...", "system");
        return;
    }
    $unix->events(basename(__FILE__) . ":: " . __FUNCTION__ . " Cleaning Clamav bases");
    CleanClamav();
    if (system_is_overloaded(dirname(__FILE__))) {
        $unix->send_email_events("logs cleaner task aborting, system is overloaded", "stopped after CleanClamav()\nWill restart in next cycle...", "system");
        return;
    }
    $size = str_replace("&nbsp;", " ", FormatBytes($GLOBALS["DELETED_SIZE"]));
    echo "{$size} cleaned :  {$GLOBALS["DELETED_FILES"]} files\n";
    if ($GLOBALS["DELETED_SIZE"] > 500) {
        send_email_events("{$size} logs files cleaned", "{$GLOBALS["DELETED_FILES"]} files cleaned for {$size} free disk space:\n\n\t\t" . @implode("\n", $GLOBALS["UNLINKED"]), "logs_cleaning");
    }
    $GLOBALS["DELETED_SIZE"] = 0;
    $GLOBALS["DELETED_FILES"] = 0;
    $unix->events(basename(__FILE__) . ":: " . __FUNCTION__ . " initalize");
    init();
    $unix->events(basename(__FILE__) . ":: " . __FUNCTION__ . " cleanTmplogs()");
    cleanTmplogs();
    if (system_is_overloaded(dirname(__FILE__))) {
        $unix->send_email_events("logs cleaner task aborting, system is overloaded", "stopped after cleanTmplogs()\nWill restart in next cycle...", "system");
        return;
    }
    $unix->events(basename(__FILE__) . ":: " . __FUNCTION__ . " Cleaning /opt/artica/tmp");
    CleanDirLogs('/opt/artica/tmp');
    if (system_is_overloaded(dirname(__FILE__))) {
        $unix->send_email_events("logs cleaner task aborting, system is overloaded", "stopped after CleanDirLogs(/opt/artica/tmp)\nWill restart in next cycle...", "system");
        return;
    }
    $unix->events(basename(__FILE__) . ":: " . __FUNCTION__ . " Cleaning /opt/artica/install");
    CleanDirLogs('/opt/artica/install');
    if (system_is_overloaded(dirname(__FILE__))) {
        $unix->send_email_events("logs cleaner task aborting, system is overloaded", "stopped after CleanDirLogs(/opt/artica/install)\nWill restart in next cycle...", "system");
        return;
    }
    $unix->events(basename(__FILE__) . ":: " . __FUNCTION__ . " Cleaning phplogs");
    phplogs();
    if (system_is_overloaded(dirname(__FILE__))) {
        $unix->send_email_events("logs cleaner task aborting, system is overloaded", "stopped after phplogs()\nWill restart in next cycle...", "system");
        return;
    }
    $unix->events(basename(__FILE__) . ":: " . __FUNCTION__ . " Cleaning /opt/openemm/tomcat/logs");
    CleanDirLogs('/opt/openemm/tomcat/logs');
    $unix->events(basename(__FILE__) . ":: " . __FUNCTION__ . " Cleaning PHP Sessions");
    sessions_clean();
    $unix->events(basename(__FILE__) . ":: " . __FUNCTION__ . " Cleaning old install sources packages");
    $size = str_replace("&nbsp;", " ", FormatBytes($GLOBALS["DELETED_SIZE"]));
    echo "{$size} cleaned :  {$GLOBALS["DELETED_FILES"]} files\n";
    if ($GLOBALS["DELETED_SIZE"] > 500) {
        send_email_events("{$size} logs files cleaned", "{$GLOBALS["DELETED_FILES"]} files cleaned for {$size} free disk space:\n\n\t\t" . @implode("\n", $GLOBALS["UNLINKED"]), "logs_cleaning");
    }
}
Beispiel #28
0
function CheckYum()
{
    @unlink("/usr/share/artica-postfix/ressources/logs/web/debian.update.html");
    exec("/usr/bin/yum check-updates 2>&1", $results);
    while (list($num, $val) = each($results)) {
        if (preg_match("#(.+?)\\s+(.+?)\\s+updates#", $val)) {
            $p[$re[1]] = true;
            $packages[] = $re[1];
        }
    }
    $count = count($p);
    if ($count > 0) {
        @file_put_contents("/etc/artica-postfix/apt.upgrade.cache", implode("\n", $packages));
        $text = "You can perform upgrade of linux packages for\n" . @file_get_contents("/etc/artica-postfix/apt.upgrade.cache");
        send_email_events("new upgrade {$count} packages(s) ready", $text, "update");
        $paragraph = Paragraphe('64-infos.png', "{$count} {system_packages}", "{$count} {system_packages_can_be_upgraded}", null, "{system_packages_can_be_upgraded}", 300, 80);
        @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/debian.update.html", $paragraph);
        shell_exec("/bin/chmod 777 /usr/share/artica-postfix/ressources/logs/web/debian.update.html");
    }
}
Beispiel #29
0
function DecodeShortURLsCheck()
{
    $f = array("0rz.tw", "1l2.us", "1u.ro", "1url.com", "2.gp", "2.ly", "2chap.it", "2pl.us", "2su.de", "2tu.us", "2ze.us", "3.ly", "301.to", "301url.com", "307.to", "6url.com", "7.ly", "9mp.com", "a.gd", "a.gg", "a.nf", "a2a.me", "a2n.eu", "abbr.com", "abe5.com", "access.im", "ad.vu", "adf.ly", "adjix.com", "alturl.com", "amzn.com", "amzn.to", "arm.in", "asso.in", "atu.ca", "aurls.info", "awe.sm", "ayl.lv", "azqq.com", "b23.ru", "b65.com", "b65.us", "bacn.me", "beam.to", "bgl.me", "bit.ly", "bkite.com", "blippr.com", "bloat.me", "blu.cc", "bon.no", "bt.io", "budurl.com", "buk.me", "burnurl.com", "c-o.in", "c.shamekh.ws", "canurl.com", "cd4.me", "chilp.it", "chopd.it", "chpt.me", "chs.mx", "chzb.gr", "clck.ru", "cli.gs", "cliccami.info", "clickthru.ca", "clipurl.us", "clk.my", "clop.in", "clp.ly", "coge.la", "cokeurl.com", "cort.as", "cot.ag", "crum.pl", "curio.us", "cuthut.com", "cuturl.com", "cuturls.com", "dealspl.us", "decenturl.com", "df9.net", "digbig.com", "digg.com", "digipills.com", "digs.by", "dld.bz", "dlvr.it", "dn.vc", "doi.org", "doiop.com", "dr.tl", "durl.me", "durl.us", "dvlr.it", "dwarfurl.com", "easyurl.net", "eca.sh", "eclurl.com", "eepurl.com", "eezurl.com", "ewerl.com", "ezurl.eu", "fa.by", "faceto.us", "fav.me", "fb.me", "ff.im", "fff.to", "fhurl.com", "flic.kr", "flingk.com", "flq.us", "fly2.ws", "fon.gs", "foxyurl.com", "fuseurl.com", "fwd4.me", "fwdurl.net", "fwib.net", "g8l.us", "get-shorty.com", "get-url.com", "get.sh", "gi.vc", "gkurl.us", "gl.am", "go.9nl.com", "go.to", "go2.me", "golmao.com", "goo.gl", "good.ly", "goshrink.com", "gri.ms", "gurl.es", "hao.jp", "hellotxt.com", "hex.io", "hiderefer.com", "hop.im", "hotredirect.com", "hotshorturl.com", "href.in", "ht.ly", "htxt.it", "hugeurl.com", "hurl.it", "hurl.no", "hurl.ws", "icanhaz.com", "icio.us", "idek.net", "ikr.me", "ir.pe", "irt.me", "is.gd", "iscool.net", "it2.in", "ito.mx", "j.mp", "j2j.de", "jdem.cz", "jijr.com", "just.as", "k.vu", "ketkp.in", "kisa.ch", "kissa.be", "kl.am", "klck.me", "kore.us", "korta.nu", "kots.nu", "krz.ch", "ktzr.us", "kxk.me", "l.pr", "l9k.net", "liip.to", "liltext.com", "lin.cr", "lin.io", "linkbee.com", "linkee.com", "linkgap.com", "linkslice.com", "linxfix.de", "liteurl.net", "liurl.cn", "livesi.de", "lix.in", "lk.ht", "ln-s.net", "ln-s.ru", "lnk.by", "lnk.in", "lnk.ly", "lnk.ms", "lnk.sk", "lnkurl.com", "loopt.us", "lost.in", "lru.jp", "lt.tl", "lu.to", "lurl.no", "mavrev.com", "memurl.com", "merky.de", "metamark.net", "migre.me", "min2.me", "minilien.com", "minilink.org", "miniurl.com", "minurl.fr", "moby.to", "moourl.com", "msg.sg", "murl.kz", "mv2.me", "mysp.in", "myurl.in", "myurl.si", "nanoref.com", "nanourl.se", "nbx.ch", "ncane.com", "ndurl.com", "ne1.net", "netnet.me", "netshortcut.com", "ni.to", "nig.gr", "nm.ly", "nn.nf", "notlong.com", "nutshellurl.com", "nyti.ms", "o-x.fr", "o.ly", "oboeyasui.com", "offur.com", "ofl.me", "om.ly", "omf.gd", "onecent.us", "onion.com", "onsaas.info", "ooqx.com", "oreil.ly", "ow.ly", "oxyz.info", "p.ly", "p8g.tw", "parv.us", "paulding.net", "pduda.mobi", "peaurl.com", "pendek.in", "pep.si", "pic.gd", "piko.me", "ping.fm", "piurl.com", "plumurl.com", "plurl.me", "pnt.me", "poll.fm", "pop.ly", "poprl.com", "post.ly", "posted.at", "pt2.me", "ptiturl.com", "puke.it", "pysper.com", "qik.li", "qlnk.net", "qoiob.com", "qr.cx", "quickurl.co.uk", "qurl.com", "qurlyq.com", "quu.nu", "qux.in", "r.im", "rb6.me", "rde.me", "readthis.ca", "reallytinyurl.com", "redir.ec", "redirects.ca", "redirx.com", "relyt.us", "retwt.me", "ri.ms", "rickroll.it", "rivva.de", "rly.cc", "rnk.me", "rsmonkey.com", "rt.nu", "rubyurl.com", "rurl.org", "s.gnoss.us", "s3nt.com", "s4c.in", "s7y.us", "safe.mn", "safelinks.ru", "sai.ly", "SameURL.com", "sfu.ca", "shadyurl.com", "shar.es", "shim.net", "shink.de", "shorl.com", "short.ie", "short.to", "shorten.ws", "shortenurl.com", "shorterlink.com", "shortio.com", "shortlinks.co.uk", "shortn.me", "shortna.me", "shortr.me", "shorturl.com", "shortz.me", "shoturl.us", "shredu", "shredurl.com", "shrinkify.com", "shrinkr.com", "shrinkster.com", "shrinkurl.us", "shrt.fr", "shrt.ws", "shrtl.com", "shrtn.com", "shrtnd.com", "shurl.net", "shw.me", "simurl.com", "simurl.net", "simurl.org", "simurl.us", "sitelutions.com", "siteo.us", "sl.ly", "slidesha.re", "slki.ru", "smallr.com", "smallr.net", "smfu.in", "smsh.me", "smurl.com", "sn.im", "sn.vc", "snadr.it", "snipie.com", "snipr.com", "snipurl.com", "snkr.me", "snurl.com", "song.ly", "sp2.ro", "spedr.com", "sqze.it", "srnk.net", "srs.li", "starturl.com", "stickurl.com", "stpmvt.com", "sturly.com", "su.pr", "surl.co.uk", "surl.it", "t.co", "t.lh.com", "ta.gd", "takemyfile.com", "tcrn.ch", "tgr.me", "th8.us", "thecow.me", "thrdl.es", "tighturl.com", "timesurl.at", "tini.us", "tiniuri.com", "tiny.cc", "tiny.pl", "tinyarro.ws", "tinylink.com", "tinypl.us", "tinysong.com", "tinytw.it", "tinyurl.com", "tl.gd", "tllg.net", "tncr.ws", "tnw.to", "to.je", "to.ly", "to.vg", "togoto.us", "tr.im", "tr.my", "tra.kz", "traceurl.com", "trcb.me", "trg.li", "trick.ly", "trii.us", "trim.li", "trumpink.lt", "trunc.it", "truncurl.com", "tsort.us", "tubeurl.com", "turo.us", "tw0.us", "tw1.us", "tw2.us", "tw5.us", "tw6.us", "tw8.us", "tw9.us", "twa.lk", "tweet.me", "tweetburner.com", "tweetl.com", "twi.gy", "twip.us", "twirl.at", "twit.ac", "twitclicks.com", "twitterurl.net", "twitthis.com", "twittu.ms", "twiturl.de", "twitzap.com", "twlv.net", "twtr.us", "twurl.cc", "twurl.nl", "u.mavrev.com", "u.nu", "u76.org", "ub0.cc", "uiop.me", "ulimit.com", "ulu.lu", "unfaker.it", "updating.me", "ur.ly", "ur1.ca", "urizy.com", "url.ag", "url.az", "url.co.uk", "url.go.it", "url.ie", "url.inc-x.eu", "url.lotpatrol.com", "urlao.com", "urlbee.com", "urlborg.com", "urlbrief.com", "urlcorta.es", "urlcut.com", "urlcutter.com", "urlg.info", "urlhawk.com", "urli.nl", "urlkiss.com", "urloo.com", "urlpire.com", "urltea.com", "urlu.ms", "urlvi.b", "urlvi.be", "urlx.ie", "urlz.at", "urlzen.com", "usat.ly", "uservoice.com", "ustre.am", "vado.it", "vb.ly", "vdirect.com", "vi.ly", "viigo.im", "virl.com", "vl.am", "voizle.com", "vtc.es", "w0r.me", "w33.us", "w34.us", "w3t.org", "wa9.la", "wapurl.co.uk", "webalias.com", "welcome.to", "wh.gov", "wipi.es", "wkrg.com", "woo.ly", "wp.me", "x.hypem.com", "x.se", "x.vu", "xeeurl.com", "xil.in", "xlurl.de", "xr.com", "xrl.in", "xrl.us", "xrt.me", "xurl.jp", "xxsurl.de", "xzb.cc", "yatuc.com", "ye-s.com", "yep.it", "z.pe", "zapt.in", "zi.ma", "zi.me", "zi.pe", "zip.li", "zipmyurl.com", "zootit.com", "zud.me", "zurl.ws", "zz.gd", "zzang.kr", "xn--cwg.ws", "xn--fwg.ws", "xn--bih.ws", "xn--l3h.ws", "xn--1ci.ws", "xn--odi.ws", "xn--rei.ws", "xn--3fi.ws", "xn--egi.ws", "xn--hgi.ws", "xn--ogi.ws", "xn--vgi.ws", "xn--5gi.ws", "xn--9gi.ws");
    $sql = "SELECT COUNT(ID) as tcount FROM spamassassin_table WHERE spam_type='DecodeShortURLs'";
    $q = new mysql();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    if ($ligne["tcount"] > 0) {
        return;
    }
    $sqlintro = "INSERT INTO spamassassin_table (`spam_type`,`value`) VALUES ";
    while (list($key, $line) = each($f)) {
        $sqls[] = "('DecodeShortURLs','{$line}')";
    }
    $sql = $sqlintro . @implode(",", $sqls);
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        send_email_events("APP_SPAMASSASSIN:: DecodeShortURLs mysql error", "Function :" . __FUNCTION__ . "\nFile" . basename(__FILE__) . "rror:" . $q->mysql_error, "postfix");
    }
}
Beispiel #30
0
function startvm($uuid, $name)
{
    $unix = new unix();
    $array = array();
    $manage = $unix->find_program("VBoxManage");
    $nohup = $unix->find_program("nohup");
    if ($manage == null) {
        if ($GLOBALS["VERBOSE"]) {
            echo "VBoxManage no such tool\n";
        }
        return;
    }
    $VBoxHeadless = $unix->LOCATE_VBoxHeadless();
    if (is_file($VBoxHeadless)) {
        $cmd = "{$VBoxHeadless} --startvm {$uuid} --vrdp on >/tmp/start-{$uuid} 2>&1 &";
    } else {
        $cmd = "{$manage} startvm {$uuid} --type headless >/tmp/start-{$uuid} 2>&1 &";
    }
    echo "{$cmd}\n";
    shell_exec($cmd);
    sleep(5);
    send_email_events("Virtual Machines: Watchdog for {$name}", "{$name} Virtual machine was powered off,\nartica automatically started it:\n" . @file_get_contents("/tmp/start-{$uuid}"), "virtual_machines");
}