function rsync_queue() { @mkdir("/var/log/artica-postfix/rsync-queue", 0755, true); $array = DirList("/var/log/artica-postfix/rsync-queue"); if (!is_array($array)) { events("No files in queue..."); return null; } events("Processing " . count($array) . " files"); while (list($num, $file) = each($array)) { if (ScanFile($file)) { @unlink("/var/log/artica-postfix/rsync-queue/{$file}"); } else { events("Processing /var/log/artica-postfix/rsync-queue/{$file} failed"); } } }
function ScanPostfixID($q) { $q = new mysql(); $unix = new unix(); $super = 0; $path = "var/log/artica-postfix/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"; } $files = DirList("/var/log/artica-postfix/RTM"); $startedAT = date("Y-m-d H:i:s"); $count = 0; if (!is_array($files)) { events("ScanPostfixID() No files.. Aborting"); return null; } events("ScanPostfixID():: Get messages in {$path} " . count($files)); $max = count($files); if ($max > 0) { events("ScanPostfixID():: Starting analyze {$max} sql files....", __FILE__); } if ($max > $GLOBALS["ArticaSMTPStatsMaxFiles"]) { $max = $GLOBALS["ArticaSMTPStatsMaxFiles"]; } if ($max > 0) { while (list($num, $file) = each($files)) { $count++; $super++; if (preg_match("#\\.id-message\$#", $file)) { $amavis[] = $file; continue; } events("ScanPostfixID():: ({$count}/{$max})"); events("ScanPostfixID():: \"/{$path}/{$file}\""); if (!preg_match("#\\.msg\$#", $file)) { continue; } if ($file == "NOQUEUE.msg") { events("ScanPostfixID():: Delete /{$path}/{$file}"); @unlink("/{$path}/{$file}"); continue; } usleep($GLOBALS["ArticaStatusUsleep"]); if ($count > $max) { events("ScanPostfixID():: Break..."); break; } if (PostfixFullProcess("/{$path}/{$file}", $q)) { SetStatus("Postfix", $max, $count, $startedAT); unset($files[$num]); events("ScanPostfixID():: ({$count}/{$max}) with a sleep of {$GLOBALS["ArticaStatusUsleep"]} microseconds line " . __LINE__); } else { continue; } } 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}"); } } } $files = DirList("/tmp/savemail-infos"); $max = count($files); if ($GLOBALS["VERBOSE"]) { echo "Scanning /tmp/savemail-infos...({$max} files)\n"; } if ($max > 0) { events("ScanPostfixID():: Starting analyze {$max} sql files....", __FILE__); } if ($max > $GLOBALS["ArticaSMTPStatsMaxFiles"]) { $max = $GLOBALS["ArticaSMTPStatsMaxFiles"]; } if (count($files > 0)) { $count = 0; while (list($num, $file) = each($files)) { $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__); } }
$_GET["DOMAINS"] = null; $_GET["FALSE_EMAILS"] = null; $_GET["EMAILS"] = null; if (posix_getuid() != 0) { die("Cannot be used in web server mode\n\n"); } if (!Build_pid_func(__FILE__, "MAIN")) { writelogs(basename(__FILE__) . ":Already executed.. aborting the process", basename(__FILE__), __FILE__, __LINE__); die; } $q = new mysql(); $q->EXECUTE_SQL("set global net_buffer_length=1000000"); $q->EXECUTE_SQL("set global max_allowed_packet=1000000000"); $quarantine_dir = "/var/virusmails"; @mkdir("/var/log/artica-postfix/artica-meta-msgs", 666, true); $files = DirList($quarantine_dir); $count = 0; $pid = getmypid(); $max = count($files); $date1 = date('H:i:s'); if (count($files) > 0) { write_syslog("Processing " . count($files), __FILE__); } while (list($num, $file) = each($files)) { events("################################################################### {$count}/{$max})"); if (quarantine_process("{$quarantine_dir}/{$file}")) { if (is_file("{$quarantine_dir}/{$file}")) { @unlink("{$quarantine_dir}/{$file}"); } } else { events("processing {$quarantine_dir}/{$file} failed");
function ParseQueue() { $array = DirList('/var/mail/artica-wbl'); if (!is_array($array)) { return null; } $ldap = new clladp(); while (list($key, $filename) = each($array)) { $continue = true; $noscan = false; if (!preg_match("#.+?\\.ini\$#", $filename)) { continue; } $ini = new Bs_IniHandler("/var/mail/artica-wbl/{$filename}"); $robot = $ini->_params["MAIL"]["action"]; $robot_from = $ini->_params["MAIL"]["robotname"]; if (preg_match("#.+?@(.+?)@(.+)#", $robot_from, $re)) { $robot_from = "{$re[1]}@{$re[2]}"; } $user = $ini->_params["MAIL"]["orignal_from"]; if ($user == null) { $user = $ini->_params["MAIL"]["From"]; } $filecontent = $ini->_params["MAIL"]["Content"]; $subject = $ini->_params["MAIL"]["subject"]; $uid = $ldap->uid_from_email($user); write_syslog("ParseQueue():: Robot \"{$robot_from}\" Subject:{$subject} From:\"{$uid}\" <{$user}> ({$robot})", __FILE__); if ($robot == null) { $continue = false; write_syslog("ParseQueue():: No robot specified", __FILE__); } if ($uid == null) { $uid = CreateThisUser($user); if ($uid == null) { write_syslog("ParseQueue():: Unable to detect internal user for {$user}", __FILE__); $continue = false; } } if (!is_file($filecontent)) { $continue = false; write_syslog("ParseQueue():: Unable to stat {$filecontent}", __FILE__); } if (!$continue) { @unlink("/var/mail/artica-wbl/{$filename}"); @unlink($filecontent); continue; } if ($robot == "report") { $noscan = true; } if ($robot == "quarantine") { $noscan = true; } $content = @file_get_contents($filecontent); if (!$noscan) { $emails = DetecteMails($content, $subject); if (!is_array($emails)) { write_syslog("ParseQueue():: Unable to detect mails in contents", __FILE__); @unlink("/var/mail/artica-wbl/{$filename}"); @unlink($filecontent); continue; } } $ct = new user($uid); if ($robot == "white") { $count = $count + 1; while (list($num, $addr) = each($emails)) { if (trim($addr) == null) { continue; } if (substr($addr, 0, 1) == '-') { $addr = substr($addr, 1, strlen($addr)); if (!$ct->del_whitelist($addr)) { $res[$addr] = "failed ({$robot}) (delete)"; } else { $res[$addr] = "Success ({$robot}) (delete)"; } continue; } if (!$ct->add_whitelist($addr)) { $res[$addr] = "failed ({$robot})"; } else { $res[$addr] = "Success ({$robot})"; } } } if ($robot == "black") { $count = $count + 1; while (list($num, $addr) = each($emails)) { if (trim($addr) == null) { continue; } if (substr($addr, 0, 1) == '-') { $addr = substr($addr, 1, strlen($addr)); if (!$ct->del_blacklist($addr)) { $res[$addr] = "failed ({$robot}) (delete)"; } else { $res[$addr] = "Success ({$robot}) (delete)"; } continue; } if (!$ct->add_blacklist($addr)) { $res[$addr] = "failed ({$robot})"; } else { $res[$addr] = "Success ({$robot})"; } } } if ($robot == "report") { $sender = $robot_from; $recipient = $ct->mail; $uid = $ct->uid; write_syslog("ParseQueue():: build white & black lists report for {$uid}", __FILE__); BuildWhiteListReport($uid, $sender, $subject); @unlink("/var/mail/artica-wbl/{$filename}"); @unlink($filecontent); continue; } if ($robot == "quarantine") { $sender = $robot_from; $recipient = $ct->mail; $uid = $ct->uid; write_syslog("ParseQueue():: build quarantine report for {$uid}", __FILE__); $usr = new usersMenus(); $PHP_BIN_PATH = $usr->PHP_BIN_PATH; $EXEC_NICE = $usr->EXEC_NICE; $cmd = "{$EXEC_NICE}{$PHP_BIN_PATH} " . dirname(__FILE__) . "/exec.quarantine.reports.php --single {$uid} {$ct->ou} {$sender} \"{$subject}\" &"; write_syslog("ParseQueue():: processing \"{$cmd}\"", __FILE__); system($cmd); @unlink("/var/mail/artica-wbl/{$filename}"); @unlink($filecontent); continue; } if (is_array($res)) { SendNotification($ct->mail, $robot_from, $subject, $res); write_syslog("ParseQueue():: Success for {$robot} list ordered by \"{$ct->mail}\" with " . implode(",", $emails) . " addresses", __FILE__); } write_syslog("ParseQueue():: Deleting {$filename} & " . basename($filecontent) . " in queue dir", __FILE__); unlink("/var/mail/artica-wbl/{$filename}"); unlink($filecontent); continue; } return $count; }
die; } if ($argv[1] == "-stat") { echo filesize($argv[2]); die; } if ($argv[1] == "-cyrus") { updateCyrus(); die; } $usersn = new usersMenus(); $_GET["LOGS_PATH"] = "/var/log/artica-postfix/increment-queue"; $_GET["CACHE"] = array(); $_GET["STORAGES"] = array(); $_GET["MY-HOSTNAME"] = $usersn->hostname; $files = DirList($_GET["LOGS_PATH"]); $count_de_files = count($files); if (is_file("/etc/artica-postfix/settings/Daemons/DarBackupStoragesList")) { $DarBackupStoragesList = file_get_contents("/etc/artica-postfix/settings/Daemons/DarBackupStoragesList"); $tb2 = explode("\n", $DarBackupStoragesList); if (is_array($tb2)) { while (list($num, $pattern) = each($tb2)) { $_GET["STORAGES"][md5($pattern)] = $pattern; } } } events("."); events("Parsing {$count_de_files} files in queue"); while (list($num, $file) = each($files)) { events("-> {$_GET["LOGS_PATH"]}/{$file}"); if (readlsfile("{$_GET["LOGS_PATH"]}/{$file}")) {
function ScanPostfixID($q) { $q = new mysql(); $path = "var/log/artica-postfix/RTM"; $files = DirList("/var/log/artica-postfix/RTM"); $startedAT = date("Y-m-d H:i:s"); $count = 0; if (!is_array($files)) { events("ScanPostfixID() No files.. Aborting"); return null; } events('ScanPostfixID():: ##########################################################'); events("ScanPostfixID():: Get msg in {$path} " . count($files)); $max = count($files); if ($max > 0) { events("ScanPostfixID():: Starting analyze {$max} sql files....", __FILE__); } while (list($num, $file) = each($files)) { $count = $count + 1; if (preg_match("#\\.id-message\$#", $file)) { $amavis[] = $file; continue; } events("ScanPostfixID():: ({$count}/{$max})"); events("ScanPostfixID():: \"/{$path}/{$file}\""); if (!preg_match("#\\.msg\$#", $file)) { continue; } if ($file == "NOQUEUE.msg") { events("ScanPostfixID(): Delete /{$path}/{$file}"); @unlink("/{$path}/{$file}"); continue; } if (PostfixFullProcess("/{$path}/{$file}", $q)) { SetStatus("Postfix", $max, $count, $startedAT); unset($files[$num]); events("ScanPostfixID(): DOne..."); events("ScanPostfixID():: ({$count}/{$max})"); } else { continue; } } events("##########################################################"); events("ScanPostfixID():Get messages-id"); if (is_array($amavis)) { reset($amavis); $max = count($amavis); $count = 0; while (list($num, $file) = each($amavis)) { $count = $count + 1; if (!preg_match("#\\.id-message\$#", $file)) { continue; } events("##########################################################"); events("ScanPostfixID():amavis_logger(): parsing /{$path}/{$file} {$count}/{$max}"); SetStatus("amavis", $max, $count, $startedAT); amavis_logger("/{$path}/{$file}"); events("##########################################################"); } } if ($count > 0) { write_syslog("Success inserting {$count} mails events in mysql database...", __FILE__); } }
function DirList($dir,$opt,$lvl){ global $row,$sub,$upllbl,$levlbl,$dellbl,$edilbl,$cfmmsg,$isadmin; $tsiz = 0; $ed = ''; foreach (glob("$dir/*") as $f){ if ($row % 2){$bg = "txta"; $bi = "imga";}else{$bg = "txtb"; $bi = "imgb";} $row++; $plen = strlen($dir); $t = substr($f,$plen+1); TblRow($bg); echo "<td class=\"$bi\" width=\"20\" nowrap>"; $i=0; while ($i < $lvl) { echo "<img src=\"img/sub.png\">"; $i++; } $i=0; if(is_dir($f)){ if($lvl and $opt == "web"){ echo "<a href=\"?sub=$f&mde=o\"><img src=\"img/16/".(($f == $sub)?'foye':'fogy').".png\" title=\"$upllbl $levlbl $lvl\"></a></td>"; }else{ echo "<img src=\"img/16/fogy.png\" title=\"Folder $levlbl $lvl\">"; } echo "</td><td colspan=\"4\">$t"; if($isadmin){ echo "<span style=\"float:right\"><a href=\"?del=".urlencode($f)."\"> <img src=\"img/16/bcnl.png\" onclick=\"return confirm('$dellbl, $cfmmsg')\" title=\"$dellbl!\"></a></span>"; } echo "</td></tr>\n"; $tsiz += DirList("$dir/$t",$opt,$lvl+1); }else{ list($ico,$ed) = FileImg($f); echo "$ico</td><td>"; if($opt == "web"){ echo "<a href=\"$f\" target=\"window\">$t</a></td>"; }else{ echo "$t</td>"; } $siz = filesize($f); $tsiz += $siz; echo "<td align=\"right\">".DecFix($siz)."</td><td align=\"right\">".date ($_SESSION['date'],filemtime($f))."<td align=\"right\">"; if($isadmin){ if($opt == "tftp" and $ed){ echo "<a href=\"?tft=".urlencode($t)."\"><img src=\"img/16/note.png\" title=\"$edilbl\"></a>"; } echo "<a href=\"?del=".urlencode($f)."\"><img src=\"img/16/bcnl.png\" onclick=\"return confirm('$dellbl, $cfmmsg')\" title=\"$dellbl!\"></a>"; } echo "</td></tr>\n"; } } return $tsiz; }