function progression_quarantine() { if (is_file("/usr/share/artica-postfix/ressources/logs/mailarchive-quarantine-progress.ini")) { $file = "/usr/share/artica-postfix/ressources/logs/mailarchive-quarantine-progress.ini"; } else { if (is_file("/usr/share/artica-postfix/ressources/mailarchive-quarantine-progress.ini")) { $file = "/usr/share/artica-postfix/ressources/mailarchive-quarantine-progress.ini"; } } if ($file == null) { $total = 0; $current = 0; $pourc = 100; } $ini = new Bs_IniHandler($file); $tot = $ini->get("PROGRESS", "total"); $cur = $ini->get("PROGRESS", "current"); $pid = $ini->get("PROGRESS", "pid"); $quarantine_type = $ini->get("PROGRESS", "quarantine"); if ($tot > 0) { $pourc = round($cur / $tot, 2); $pourc = $pourc * 100; $img = "<img src='img/wait.gif'>"; } else { $pourc = 100; } if ($pourc == 100) { $img = " "; } $color = "#5DD13D"; $html = "<table style='width:100%'>\n\t<tr>\n\t\t<td align='center' colspan=2><strong style='font-size:13px'>«{$quarantine_type}» {$cur}/{$tot} (pid:{$pid}) </td>\n\t</tr>\n\t\t\n\t<tr>\n\t\t<td width=1%><span id='wait'>{$img}</span>\n\t\t</td>\n\t\t<td width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t<td>\n\t\t\t\t<div style='width:100%;background-color:white;padding-left:0px;border:1px solid {$color}'>\n\t\t\t\t\t<div id='progression_postfix'>\n\t\t\t\t\t\t<div style='width:{$pourc}%;text-align:center;color:white;padding-top:3px;padding-bottom:3px;background-color:{$color}'>\n\t\t\t\t\t\t\t<strong style='color:#BCF3D6;font-size:12px;font-weight:bold'>{$pourc}%</strong></center>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t</table>\t\t\n\t\t</td>\n\t</tr>\n\t</table>"; return $html; }
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)); }
function PostfixAutoBlockCompileCheck() { $ini = new Bs_IniHandler(); $ini->loadFile("ressources/logs/compile.iptables.progress"); $pourc = $ini->get("PROGRESS", "pourc"); $text = $ini->get("PROGRESS", "text"); $color = "#5DD13D"; $html = "\n<center>\n<div style='width:96%;text-align:center;font-size:12px;font-weight:bold;margin:5px;background-color:white;padding:5px;border:1px solid #CCCCCC'>\n\t<div style='width:95%;text-align:center;font-size:12px;font-weight:bold;margin:5px'>{$text}</div>\n\t<div style='width:100%;border:1px dotted #CCCCCC'>\n\t<div style='width:{$pourc}%;text-align:center;color:white;padding-top:3px;padding-bottom:3px;background-color:{$color};'>\n\t\t<strong style='color:#BCF3D6;font-size:12px;font-weight:bold'>{$pourc}%</strong></center>\n\t</div>\n\t</div>\n</div>\n</center>\n"; $html = RoundedLightWhite($html); $tpl = new templates(); echo $tpl->_ENGINE_parse_body($html, "postfix.index.php"); }
function NightlyNotifs() { $sock = new sockets(); $ini = new Bs_IniHandler("ressources/index.ini"); $nightly = $ini->get("NEXT", "artica-nightly"); $version = $sock->getFrameWork("cmd.php?uri=artica_version"); $nightlybin = str_replace('.', '', $nightly); $versionbin = str_replace('.', '', $version); if ($versionbin == 0) { return; } if ($nightlybin == 0) { return; } if ($nightlybin > $versionbin) { echo ParagrapheTEXT("32-infos.png", "{NEW_NIGHTLYBUILD}: {$nightly}", '{NEW_NIGHTLYBUILD_TEXT}', "javascript:Loadjs('artica.update.php?js=yes');", null, 330); } }
function NightlyNotifs() { if ($GLOBALS["VERBOSE"]) { echo "<H1>NightlyNotifs()</H1>\n"; } $sock = new sockets(); $EnableNightlyInFrontEnd = $sock->GET_INFO("EnableNightlyInFrontEnd"); if (!is_numeric($EnableNightlyInFrontEnd)) { $EnableNightlyInFrontEnd = 1; } if ($EnableNightlyInFrontEnd == 0) { if ($GLOBALS["VERBOSE"]) { echo "<span style=color:blue>EnableNightlyInFrontEnd={$EnableNightlyInFrontEnd}</span><br>\n"; } return; } if (!is_file("ressources/index.ini")) { if ($GLOBALS["VERBOSE"]) { echo "<span style=color:blue>ressources/index.ini no such file</span><br>\n"; } return; } $ini = new Bs_IniHandler("ressources/index.ini"); if (!isset($ini->_params["NEXT"])) { $sock->getFrameWork("system.php?refresh-index-ini=yes"); $ini = new Bs_IniHandler("ressources/index.ini"); } $nightly = $ini->get("NEXT", "artica-nightly"); $version = @file_get_contents("VERSION"); $nightlybin = str_replace('.', '', $nightly); $versionbin = str_replace('.', '', $version); if ($GLOBALS["VERBOSE"]) { echo "<span style=color:blue>{$nightlybin} = {$versionbin}</span><br>\n"; } if ($versionbin == 0) { return; } if ($nightlybin == 0) { return; } if ($nightlybin > $versionbin) { $tpl = new templates(); $html = "<div style='margin-bottom:15px'>" . Paragraphe("download-info-64.png", "{NEW_NIGHTLYBUILD}: {$nightly}", "{NEW_NIGHTLYBUILD_TEXT}", "javascript:Loadjs('artica.update.php?js=yes')", "go_to_section", 665, 132, 1); $html = $tpl->_ENGINE_parse_body($html) . "</div>"; echo $html; return; } }
function postfixlogger_progress() { $user = new usersMenus(); if (is_file("/usr/share/artica-postfix/ressources/logs/postfix-logger.ini")) { $ini = new Bs_IniHandler("/usr/share/artica-postfix/ressources/logs/postfix-logger.ini"); } else { $ini = new Bs_IniHandler(); } $max = $ini->get("PROGRESS", "max"); $current = $ini->get("PROGRESS", "current"); $type = $ini->get("PROGRESS", "type"); $endtime = $ini->get("PROGRESS", "time"); if ($current == null) { $current = 0; } if ($type == null) { $type = "{scheduled}"; } if ($endtime == null) { $endtime = date("H:i:s"); } if ($max != null) { $pourc = round($current / $max, 2) * 100; } else { $pourc = "0"; } $queue = $user->POSTFIX_QUEUE["RTM"]; $endtime = str_replace("Y-m-d", "", $endtime); $color = "#5DD13D"; $html = "\n<table style='width:100%'>\n<tr>\n<td valign='top'>\n<table style='width:100%'>\n\t<tr>\n\t\t<td align='center' colspan=2><strong style='font-size:11px'>«{$type}» {$current}/{$max}/{$queue} ({end}:{$endtime}) </td>\n\t</tr>\n\t\t\n\t<tr>\n\t\t<td width=1%><span id='wait'>{$img}</span>\n\t\t</td>\n\t\t<td width=99%>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t<td>\n\t\t\t\t<div style='width:100%;background-color:white;padding-left:0px;border:1px solid {$color}'>\n\t\t\t\t\t<div id='progression_postfix'>\n\t\t\t\t\t\t<div style='width:{$pourc}%;text-align:center;color:white;padding-top:3px;padding-bottom:3px;background-color:{$color}'>\n\t\t\t\t\t\t\t<strong style='color:#BCF3D6;font-size:12px;font-weight:bold'>{$pourc}%</strong></center>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t</table>\t\t\n\t\t</td>\n\t</tr>\n\t</table>\n</td>\n<td valign='top' width=1%>\n\t<div style='padding:2px;border:1px solid #CCCCCC'>" . imgtootltip("rouage-32.png", "{parameters}", "Loadjs('RTMMailConfig.php')") . "</div>\n</td>\n<td valign='top' width=1%>\n\t<div style='padding:2px;border:1px solid #CCCCCC'>" . imgtootltip("loupe-32.png", "{detach}", "Loadjs('RTMMail.php')") . "</div>\n</td>\n\n\n\n</tr>\n</table>"; return $html; }
function ExportStatus() { if (!is_file("ressources/logs/export.status.conf")) { return null; } $ini = new Bs_IniHandler("ressources/logs/export.status.conf"); echo Status($ini->get('STATUS', 'progress'), $ini->get('STATUS', 'text')); }
function Status() { $ini = new Bs_IniHandler('ressources/logs/nmap.progress.ini'); $pourc = $ini->get('NMAP', 'pourc'); $text = $ini->get('NMAP', 'text'); if ($pourc == null) { $pourc = 0; } if ($pourc == 0) { $text = "{sleeping}"; } if ($pourc == 100) { $text = "{success}"; } $color = "#5DD13D"; $tpl = new templates(); $html = "\n<table style='width:100%'>\n<tr>\n<td valign='top'>\n\t<p class=caption>{$text}...</p>\n\t<div style='width:100%;background-color:white;padding-left:0px;border:1px solid {$color}'>\n\t\t<div id='progression_computers'>\n\t\t\t<div style='width:{$pourc}%;text-align:center;color:white;padding-top:3px;padding-bottom:3px;background-color:{$color}'>\n\t\t\t\t<strong style='color:#BCF3D6;font-size:12px;font-weight:bold'>{$pourc}%</strong></center>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</td>\n<td valign=middle width=1%><div style='background-color:white;padding:5px'>" . imgtootltip('loupe-32.png', '{events}', "ViewComputerScanLogs()") . "</div></td>\n</tr>\n</table>\n"; echo $tpl->_ENGINE_parse_body($html); }
$UsersNumber = 0; } $uriplus = "{$SYSTEMID};{$MEMORY_INSTALLED};{$SystemCpuNumber};{$LinuxDistributionFullName};{$ARTICA_VERSION};{$hostname};{$UsersNumber};{$datas}"; $uriplus = str_replace(" ", "%20", $uriplus); $ini = new Bs_IniHandler(); $ini->loadFile("/etc/artica-postfix/artica-update.conf"); $uri = $ini->get("AUTOUPDATE", "uri"); if (trim($uri) == null) { $uri = "http://93.88.245.88/auto.update.php"; } $uri = str_replace("www.artica.fr", "93.88.245.88", $uri); $localFile = '/usr/share/artica-postfix/ressources/index.ini'; $curl = new ccurl("{$uri}?datas={$uriplus}"); $tmpfile = "/tmp/artica." . basename(__FILE__) . '.tmp'; @unlink("/usr/share/artica-postfix/ressources/logs/INTERNET_FAILED"); if (!$curl->GetFile($tmpfile)) { $unix->send_email_events("Check Internet connexion Failed", "System is unable to connect trough internet: {$curl->error}", "update"); @file_put_contents("/usr/share/artica-postfix/ressources/logs/INTERNET_FAILED", $curl->error); shell_exec("{$chmod} 777 /usr/share/artica-postfix/ressources/logs/INTERNET_FAILED"); return; } $ini = new Bs_IniHandler(); $ini->loadFile("{$tmpfile}"); $articaversion = $ini->get("NEXT", "artica"); if ($GLOBALS["VERBOSE"]) { echo "Artica version:{$articaversion}\n"; } if (preg_match("#^[0-9\\.]+#", $articaversion)) { @copy($tmpfile, "/usr/share/artica-postfix/ressources/index.ini"); shell_exec("{$chmod} 777 /usr/share/artica-postfix/ressources/index.ini"); }
function restore_status() { if (!is_file("ressources/logs/exec.dar.find.restore.ini")) { echo Status(10, "{waiting}..."); return null; } $ini = new Bs_IniHandler("ressources/logs/exec.dar.find.restore.ini"); echo Status($ini->get('STATUS', 'progress'), $ini->get('STATUS', 'text')); }
function PostfixLoadeMailsQueue() { $tpl = new templates(); $tot = $_GET["total"]; if (!isset($_GET["numStart"])) { $numStart = 0; } if (!isset($_GET["tab"])) { $tab = 0; } else { $tab = $_GET["tab"]; } if ($tab == '') { $tab = 0; } $queue_name = $_GET["PostfixLoadeMailsQueue"]; $ini = new Bs_IniHandler(); if (!is_file('ressources/databases/postfix-queue-cache.conf')) { return $tpl->_ENGINE_parse_body("{no_cache_created}"); } $ini->loadFile('ressources/databases/postfix-queue-cache.conf'); $PagesNumber = $ini->get($queue_name, 'PagesNumber'); if ($PagesNumber > 0) { $tabublation = Tabs($PagesNumber, $queue_name); } $filetemp = "ressources/databases/queue.list.{$tab}.{$queue_name}.cache"; if (!is_file($filetemp)) { return $tpl->_ENGINE_parse_body("<strong>{unable_to_locate}: {$filetemp}</strong>"); } $datas = explode("\n", file_get_contents($filetemp)); $countRows = count($datas); $number_pages = round($tot / $countRows); $html = "\n\t<H4>{queue} {$queue_name} {$PagesNumber} {pages} {$countRows} {lines}</H4>\n\t<div align='right' class=caption>{from_cache_file} {$filetemp}</div>\n\t{$tabublation}\n\t<table style='width:100%'>\n\t<tr class='caption'>\n\t<td><strong>{date}</strong></td>\n\t<td><strong>{operation}</strong></td>\n\t<td><strong>{mail_from}</strong></td>\n\t<td><strong>{mail_to}</strong></td>\n\t<td><strong>{delete}</strong></td>\n\t</tr>\n\t"; while (list($num, $val) = each($datas)) { $val = str_replace('<sender></sender>', '<sender>unknown</sender>', $val); if (preg_match('#<file>(.+?)</file><path>(.+?)</path><time>(.+?)</time><named_attr>(.+?)</named_attr><sender>(.+?)</sender><recipient>(.+?)</recipient><subject>(.+?)</subject>#', $val, $regs)) { $file = $regs[1]; $path = $regs[2]; $time = PostFixTimeToPhp($regs[3]); $named = $regs[4]; $sender = $regs[5]; $recipient = $regs[6]; $subject = utf8_decode($subject); $subject = htmlentities('"' . $regs[7] . '"'); $varClick = "OnClick=\"javascript:LoadMailID('{$file}','{$queue_name}','{$tab}')\""; $tooltips = "<strong>{$file}</strong><br>{$subject}"; $html = $html . "\n\t\t\t<tr " . CellRollOver(null, $tooltips) . " class=caption>\n\t\t\t<td nowrap {$varClick}>{$time}</td>\n\t\t\t<td {$varClick}>{$named}</td>\n\t\t\t<td {$varClick}>{$sender}</td>\n\t\t\t<td {$varClick}>{$recipient}</td>\n\t\t\t<td align='center' width=1%>" . imgtootltip('x.gif', '{delete}', "DeleteMailID('{$queue_name}','{$tab}','{$file}')") . "</td>\n\t\t\t</tr>\n\t\t\t"; $count = $count + 1; if ($count > 100) { break; } } } $tpl = new templates(); $html = $tpl->_ENGINE_parse_body($html); $html = $html . "</table>"; return $html; }
function js_right_status($pourc = 0) { $color = "white"; $file = "ressources/logs/exec-right.status.ini"; if ($pourc == 0) { if (!is_file($file)) { error_log("unable to stat ressources/logs/exec-right.status.ini"); } $ini = new Bs_IniHandler("ressources/logs/exec-right.status.ini"); $pourc = $ini->get("status", 'pourc'); $text = $ini->get("status", 'text'); } else { $text = "Waiting..."; } if ($pourc < 1) { $pourc = 5; } $color = "#5DD13D"; $html = "\n\t<div style='width:{$pourc}%;text-align:center;color:white;padding-top:3px;padding-bottom:3px;background-color:{$color}'>\n\t\t<strong style='color:#BCF3D6;font-size:12px;font-weight:bold'>{$pourc}% {$text}</strong></center>\n\t</div>\n\t<input type='hidden' id='js-right-id' value='{$pourc}'>\n\t\n"; return $html; }
function ChangeRoot($instance_id) { echo "Loading instance {$instance_id}\n"; $mysqld = new mysqlserver_multi($instance_id); $username = $mysqld->mysql_admin; $password = $mysqld->mysql_password; if ($password == null) { echo "Password is null, aborting\n"; return; } $unix = new unix(); $mysqld_safe = $unix->find_program("mysqld_safe"); $nohup = $unix->find_program("nohup"); $killbin = $unix->find_program("kill"); echo "mysqld_safe:{$mysqld_safe}\n"; $ini = new Bs_IniHandler(); $ini->loadFile("/etc/mysql-multi.cnf"); $array = $ini->_params["mysqld{$instance_id}"]; $datadir = $ini->get("mysqld{$instance_id}", "datadir"); while (list($key, $value) = each($array)) { $tt[] = "{$key} = {$value}"; } $newconfig = "[mysqld]\n" . @implode("\n", $tt) . "\n"; @file_put_contents("/etc/mysql-temp-{$instance_id}.cf", $newconfig); for ($i = 0; $i < 5; $i++) { $pid = multi_get_pid($instance_id); if ($pid > 0) { echo "Stopping mysqld safe pid:{$pid}\n"; unix_system_kill_force($pid); sleep(1); } else { break; } } echo "Stopping instance {$instance_id}\n"; //shell_exec($unix->LOCATE_PHP5_BIN()." /usr/share/artica-postfix/exec.mysql.build.php --multi-stop $instance_id >/dev/null 2>&1"); for ($i = 0; $i < 5; $i++) { $pid = multi_get_pidNormal($instance_id); if ($pid > 0) { echo "Stopping mysqld pid:{$pid}\n"; unix_system_kill_force($pid); sleep(1); } else { break; } } $pid = @file_get_contents("/var/run/mysqld/mysqld{$instance_id}.pid"); if ($unix->process_exists($pid)) { echo "Stopping instance {$instance_id} failed...\n"; return; } echo "Running instance {$instance_id} in safe mode...\n"; if (file_exists("{$datadir}/error.log")) { @unlink("{$datadir}/error.log"); } $cmd = "{$nohup} {$mysqld_safe} --defaults-file=/etc/mysql-temp-{$instance_id}.cf --datadir=\"{$datadir}\" --skip-grant-tables --skip-networking --skip-external-locking --log-error=\"{$datadir}/error.log\" --pid-file=/var/run/mysqld/mysqld{$instance_id}.pid >/dev/null 2>&1 &"; if ($GLOBALS["VERBOSE"]) { echo "{$cmd}\n"; } shell_exec($cmd); for ($i = 0; $i < 4; $i++) { sleep(1); $pid = @file_get_contents("/var/run/mysqld/mysqld{$instance_id}.pid"); if ($unix->process_exists($pid)) { sleep(1); break; } } $pid = @file_get_contents("/var/run/mysqld/mysqld{$instance_id}.pid"); if (!$unix->process_exists($pid)) { echo "Failed to run mysqld safe\n"; if (file_exists("{$datadir}/error.log")) { echo @file_get_contents("{$datadir}/error.log"); } shell_exec($nohup . " " . $unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.mysql.build.php --multi-start {$instance_id} >/dev/null 2>&1 &"); return; } $q = new mysql_multi($instance_id); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT User from user WHERE User='******' LIMIT 0,1", "mysql")); if (!$q->ok) { echo $q->mysql_error . "\n"; } echo "User:{$username} = {$ligne["User"]}\n"; if ($ligne["User"] != null) { echo "User: Already exists, update password\n"; $sqlstring = "UPDATE user SET password=PASSWORD(\"{$password}\") WHERE user=\"{$username}\""; $q->QUERY_SQL($sqlstring, "mysql"); if (!$q->ok) { echo $q->mysql_error . "\n"; } $q->QUERY_SQL_NO_BASE("FLUSH PRIVILEGES"); if (!$q->ok) { echo $q->mysql_error . "\n"; } } else { echo "Root: did not exists, Create a new one...\n"; $q->QUERY_SQL_NO_BASE("create user root@localhost"); $q->QUERY_SQL_NO_BASE("GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' with grant option"); $q->QUERY_SQL_NO_BASE("FLUSH PRIVILEGES"); } echo "Stopping mysqld safe....\n"; for ($i = 0; $i < 5; $i++) { $pid = multi_get_pid($instance_id); if ($pid > 0) { echo "Stopping mysqld safe pid:{$pid}\n"; unix_system_kill_force($pid); sleep(1); } else { break; } } exec($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.mysql.build.php --multi-stop {$instance_id} 2>&1", $results); while (list($key, $value) = each($results)) { echo "{$value}\n"; } $results = array(); echo "Start mysqld in normal mode\n"; exec($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.mysql.build.php --multi-start {$instance_id} 2>&1", $results); while (list($key, $value) = each($results)) { echo "{$value}\n"; } }