示例#1
0
function restore($id, $target_resource, $db)
{
    $sql = "SELECT * FROM dar_index where filekey='{$id}'";
    $q = new mysql();
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    $ressource = $ligne["mount_md5"];
    $sourcefile = $ligne["filepath"];
    if ($_GET["RESTORE_DIR"]) {
        $sourcefile = dirname($sourcefile);
    }
    $ini = new Bs_IniHandler("/tmp/restore.{$id}.ini");
    $ini->set('INFO', "backup_resource", $ressource);
    $ini->set('INFO', "target_resource", $target_resource);
    $ini->set('INFO', "database", $db);
    $ini->set('INFO', "source_path", $sourcefile);
    $ini->saveFile("/tmp/restore.{$id}.ini");
    $ini = new Bs_IniHandler(dirname(__FILE__) . "/ressources/logs/exec.dar.find.restore.ini");
    $ini->set("STATUS", "progress", 15);
    $ini->set("STATUS", "text", "{Executing}...");
    $ini->saveFile(dirname(__FILE__) . "/ressources/logs/exec.dar.find.restore.ini");
    $cmd = "/usr/share/artica-postfix/bin/artica-backup --dar-restore-path /tmp/restore.{$id}.ini";
    events($cmd);
    system($cmd);
}
示例#2
0
function del_icon()
{
    $uid = $_SESSION["uid"];
    $tab = $_GET["delete_icon_tab"];
    $icon = $_GET["delete_icon"];
    $page = CurrentPageName();
    $cache_tab_file = "ressources/profiles/{$uid}.{$tab}";
    @unlink($cache_tab_file);
    $ini = new Bs_IniHandler("ressources/profiles/{$uid}.tabs");
    $icons = explode(",", $ini->_params[$tab]["icons"]);
    while (list($num, $ligne) = each($icons)) {
        if ($ligne == $icon) {
            unset($icons[$num]);
        }
    }
    $ini->_params[$tab]["icons"] = implode(",", $icons);
    $ini->saveFile("ressources/profiles/{$uid}.tabs");
}
示例#3
0
function network_scanner_execute()
{
    $tpl = new templates();
    $net = new networkscanner();
    $net->save();
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?LaunchNetworkScanner=yes");
    $box = $tpl->javascript_parse_text('{network_scanner_execute_background}', 1);
    $ini = new Bs_IniHandler('ressources/logs/nmap.progress.ini');
    $ini->set('NMAP', 'pourc', '10');
    $ini->set('NMAP', 'text', '{scheduled}');
    $ini->saveFile('ressources/logs/nmap.progress.ini');
    echo $box;
}
示例#4
0
function CreateOnpenSSLCOnf()
{
    $path = "/etc/ocs/cert";
    $conf = "{$path}/openssl.conf";
    @mkdir($path, 666, true);
    $sock = new sockets();
    $ldap = new clladp();
    $CertificateMaxDays = $sock->GET_INFO('CertificateMaxDays');
    if ($CertificateMaxDays == null) {
        $CertificateMaxDays = 730;
    }
    $ini = new Bs_IniHandler("/etc/artica-postfix/ssl.certificate.conf");
    $sock = new sockets();
    $OCSCertInfos = unserialize(base64_decode($sock->GET_INFO("OCSCertInfos")));
    if ($OCSCertInfos["OCSCertServerName"] == null) {
        $users = new usersMenus();
        $OCSCertInfos["OCSCertServerName"] = $users->hostname;
    }
    if ($OCSCertInfos["OCSCertDomainName"] == null) {
        return;
    }
    $hostname = $OCSCertInfos["OCSCertServerName"] . "." . $OCSCertInfos["OCSCertDomainName"];
    $email = $OCSCertInfos["OCSCertEmail"];
    unset($ini->_params["HOSTS_ADDONS"]);
    $ini->_params["default_db"]["default_days"] = $CertificateMaxDays;
    $ini->_params["server_policy"]["commonName"] = $hostname;
    $ini->_params["user_policy"]["commonName"] = $hostname;
    $ini->_params["default_ca"]["commonName"] = $hostname;
    $ini->_params["default_ca"]["commonName_value"] = $hostname;
    $ini->_params["policy_match"]["commonName"] = $hostname;
    $ini->_params["policy_anything"]["commonName"] = $hostname;
    $ini->_params["req"]["default_keyfile"] = "{$path}/privkey.key";
    $ini->_params["req"]["default_bits"] = "1024";
    $ini->_params["req"]["distinguished_name"] = "default_ca";
    $ini->_params["req"]["attributes"] = "req_attributes";
    $ini->_params["req"]["x509_extensions"] = "v3_ca";
    $ini->_params["default_db"]["dir"] = "{$path}";
    $ini->_params["default_db"]["certs"] = "{$path}";
    $ini->_params["default_db"]["new_certs_dir"] = "{$path}";
    $ini->_params["default_db"]["database"] = "{$path}/ca.index";
    $ini->_params["default_db"]["serial"] = "{$path}/ca.serial";
    $ini->_params["default_db"]["RANDFILE"] = "{$path}/.rnd";
    $ini->_params["default_db"]["certificate"] = "{$path}/certificate.pem";
    $ini->_params["default_db"]["private_key"] = "{$path}/privkey.pem";
    $ini->_params["default_db"]["name_opt"] = "default_ca";
    $ini->_params["default_db"]["cert_opt"] = "default_ca";
    $ini->_params["ca"]["default_ca"]["CA_default"];
    $ini->_params["CA_default"]["dir"] = $path;
    $ini->_params["CA_default"]["certs"] = "{$path}/certs";
    # Where the issued certs are kept
    $ini->_params["CA_default"]["crl_dir"] = "{$path}/crl";
    # Where the issued crl are kept
    $ini->_params["CA_default"]["database"] = "{$path}/index.txt";
    # database index file.
    $ini->_params["CA_default"]["new_certs_dir"] = "{$path}/newcerts";
    # default place for new certs.
    $ini->_params["CA_default"]["certificate"] = "{$path}/cacert.pem";
    # The CA certificate
    $ini->_params["CA_default"]["serial"] = "{$path}/serial";
    # The current serial number
    $ini->_params["CA_default"]["crlnumber"] = "{$path}/crlnumber";
    # the current crl number
    $ini->_params["CA_default"]["crl"] = "{$path}/crl.pem";
    # The current CRL
    $ini->_params["CA_default"]["private_key"] = "{$path}/cakey.pem";
    # The private key
    $ini->_params["CA_default"]["RANDFILE"] = "{$path}/.rand";
    # private random number file
    $ini->_params["CA_default"]["x509_extensions"] = "usr_cert";
    # The extentions to add to the cert
    $ini->_params["CA_default"]["name_opt"] = "ca_default";
    # Subject Name options
    $ini->_params["CA_default"]["cert_opt"] = "ca_default";
    # Certificate field options
    $ini->_params["CA_default"]["default_days"] = "{$CertificateMaxDays}";
    # how long to certify for
    $ini->_params["CA_default"]["default_crl_days"] = "30";
    # how long before next CRL
    $ini->_params["CA_default"]["default_md"] = "sha1";
    # which md to use.
    $ini->_params["CA_default"]["policy"] = "policy_match";
    $ini->_params["req_attributes"]["challengePassword"] = "******";
    $ini->_params["req_attributes"]["challengePassword_min"] = "4";
    $ini->_params["req_attributes"]["challengePassword_max"] = "20";
    $ini->_params["req_attributes"]["unstructuredName"] = "An optional company name";
    $ini->_params["default_ca"]["commonName"] = $hostname;
    $ini->_params["default_ca"]["emailAddress"] = $email;
    $ini->saveFile($conf);
    echo "Starting......: OCS web Engine certificate, writing {$conf} done\n";
}
function ImportNets()
{
    $sock = new sockets();
    $ini = new Bs_IniHandler();
    $ini->loadString($sock->GET_INFO("ComputersImportArtica"));
    if (!is_array($ini->_params)) {
        writelogs("No artica masters defined", __FUNCTION__, __FILE__, __LINE__);
        die;
    }
    if (count($ini->_params) == 0) {
        writelogs("No artica masters defined", __FUNCTION__, __FILE__, __LINE__);
        die;
    }
    while (list($ip, $array) = each($ini->_params)) {
        if (trim($ip) == null) {
            continue;
        }
        $curl = new ccurl("https://{$ip}:{$array["port"]}/exec.import-networks.php");
        while (list($key, $value) = each($array)) {
            $curl->parms[$key] = $value;
        }
        $curl->get();
        $datas = $curl->data;
        if (trim($datas) == null) {
            continue;
        }
        $md5 = md5($datas);
        import_vpn_remotes_sites($datas);
        if (!$GLOBALS["FORCE"]) {
            if ($array["md5"] != $md5) {
                ImportDatas($datas);
            }
        } else {
            ImportDatas($datas);
        }
        $ini->_params[$ip]["md5"] = $md5;
    }
    reset($ini->_params);
    $ini->saveFile("/etc/artica-postfix/settings/Daemons/ComputersImportArtica");
}
示例#6
0
function WriteCOmputerBrowseProgress($pourc,$text){
	$ini=new Bs_IniHandler();
	$ini->set('NMAP','pourc',$pourc);
	$ini->set('NMAP','text',$text);
	$ini->saveFile('/usr/share/artica-postfix/ressources/logs/nmap.progress.ini');
	@chmod("/usr/share/artica-postfix/ressources/logs/nmap.progress.ini",0755);
}
示例#7
0
function UpdateUtility()
{
    if ($GLOBALS["VERBOSE"]) {
        echo "Line: " . __LINE__ . ":: " . __FUNCTION__ . "\n";
    }
    $unix = new unix();
    $sock = new sockets();
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/" . basename(__FILE__) . ".pid";
    $pidtime = "/etc/artica-postfix/" . basename(__FILE__) . ".time";
    $pidtimeT = $unix->file_time_min($pidtime);
    if ($pidtimeT < 3) {
        if (!$GLOBALS["FORCE"]) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Line: " . __LINE__ . ":: last execution time {$pidtimeT} (require 3mn) or set --force " . __FUNCTION__ . "\n";
            }
            die;
        }
    }
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $ProcessTime = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["VERBOSE"]) {
            echo "Line: " . __LINE__ . ":: Process {$pid}  already in memory since {$ProcessTime} minutes - " . __FUNCTION__ . "\n";
        }
        system_admin_events("Process {$pid}  already in memory since {$ProcessTime} minutes", "MAIN", __FILE__, __LINE__, "updateutility");
        die;
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    @file_put_contents($pidfile, getmypid());
    $UpdateUtility_Console = $unix->find_program("UpdateUtility-Console");
    if (!is_file($UpdateUtility_Console)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Line: " . __LINE__ . ":: UpdateUtility-Console no such binary - " . __FUNCTION__ . "\n";
        }
        system_admin_events("UpdateUtility-Console no such binary", __FUNCTION__, __FILE__, __LINE__, "update");
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Line: " . __LINE__ . ":: UpdateUtility_Console - {$UpdateUtility_Console}" . __FUNCTION__ . "\n";
    }
    @copy($UpdateUtility_Console, "/etc/UpdateUtility/UpdateUtility-Console");
    $UpdateUtilityAllProducts = $sock->GET_INFO("UpdateUtilityAllProducts");
    $UpdateUtilityOnlyForKav4Proxy = $sock->GET_INFO("UpdateUtilityOnlyForKav4Proxy");
    $UpdateUtilityUseLoop = $sock->GET_INFO("UpdateUtilityUseLoop");
    if (!is_numeric($UpdateUtilityAllProducts)) {
        $UpdateUtilityAllProducts = 1;
    }
    $UpdateUtilityStorePath = $sock->GET_INFO("UpdateUtilityStorePath");
    if ($UpdateUtilityStorePath == null) {
        $UpdateUtilityStorePath = "/home/kaspersky/UpdateUtility";
    }
    if (is_file("/opt/kaspersky/kav4proxy/sbin/kav4proxy-kavicapserver")) {
        if (!is_numeric($UpdateUtilityOnlyForKav4Proxy)) {
            $UpdateUtilityOnlyForKav4Proxy = 1;
        }
    }
    if ($UpdateUtilityUseLoop == 1) {
        $UpdateUtilityStorePath = "/automounts/UpdateUtility";
        $dev = $unix->MOUNTED_DIR($UpdateUtilityStorePath);
        if ($dev == null) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Line: " . __LINE__ . ":: {$UpdateUtilityStorePath} -> NOT MOUNTED " . __FUNCTION__ . "\n";
            }
            @file_put_contents("/var/log/artica-postfix/UpdateUtility-report-" . time() . ".log", "Report finished at " . date("Y-m-d H:i:s") . "\n{$UpdateUtilityStorePath} not mounted!\n");
            return;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "Line: " . __LINE__ . ":: {$UpdateUtilityStorePath} -> {$dev} OK" . __FUNCTION__ . "\n";
        }
    }
    @mkdir("{$UpdateUtilityStorePath}/databases/Updates", 0755, true);
    if (!is_dir($UpdateUtilityStorePath)) {
        @file_put_contents("/var/log/artica-postfix/UpdateUtility-report-" . time() . ".log", "Report finished at " . date("Y-m-d H:i:s") . "\n{$UpdateUtilityStorePath}/databases/Updates permission denied!\n");
        return;
    }
    $updateutility = new updateutilityv2();
    if ($UpdateUtilityAllProducts == 1) {
        system_admin_events("All products as been set...", __FUNCTION__, __FILE__, __LINE__, "update");
        while (list($key, $line) = each($updateutility->ALL_PKEYS)) {
            $updateutility->MAIN_ARRAY["ComponentSettings"][$key] = "true";
        }
        if (!isset($updateutility->MAIN_ARRAY["ComponentSettings"]["DownloadAllDatabases"])) {
            $updateutility->MAIN_ARRAY["ComponentSettings"]["DownloadAllDatabases"] = "true";
        }
        if (!isset($updateutility->MAIN_ARRAY["ComponentSettings"]["KasperskyAdministrationKit_8_0_2048_2090"])) {
            $updateutility->MAIN_ARRAY["ComponentSettings"]["KasperskyAdministrationKit_8_0_2048_2090"] = "true";
        }
        if (!isset($updateutility->MAIN_ARRAY["ComponentSettings"]["KasperskySecurityCenter_9"])) {
            $updateutility->MAIN_ARRAY["ComponentSettings"]["KasperskySecurityCenter_9"] = "true";
        }
    }
    if ($UpdateUtilityOnlyForKav4Proxy == 1) {
        system_admin_events("Kav4Proxy as been set...", __FUNCTION__, __FILE__, __LINE__, "update");
        reset($updateutility->ALL_PKEYS);
        while (list($key, $line) = each($updateutility->ALL_PKEYS)) {
            $updateutility->MAIN_ARRAY["ComponentSettings"][$key] = "false";
        }
        $updateutility->MAIN_ARRAY["ComponentSettings"]["KasperskyAntiVirusProxyServer_5_5"] = "true";
        $updateutility->MAIN_ARRAY["ComponentSettings"]["KasperskyAntiVirusProxyServer_5_5_41_51"] = "true";
        $updateutility->MAIN_ARRAY["ComponentSettings"]["KasperskyAntiVirusProxyServer_5_5_62"] = "true";
        $updateutility->MAIN_ARRAY["ComponentSettings"]["KasperskyAntiVirusProxyServer_5_5_62"] = "true";
        $updateutility->MAIN_ARRAY["ComponentSettings"]["DownloadAllDatabases"] = "false";
    }
    $updateutility->MAIN_ARRAY["ShedulerSettings"]["LastUpdate"] = '@Variant(\\0\\0\\0\\x10\\0\\0\\0\\0\\xff\\xff\\xff\\xff\\xff)';
    $updateutility->MAIN_ARRAY["ShedulerSettings"]["Time"] = '@Variant(\\0\\0\\0\\xf\\0\\0\\0\\0)';
    $t = time();
    $ini = new Bs_IniHandler();
    $ini2 = new Bs_IniHandler();
    $ini->_params = $updateutility->MAIN_ARRAY;
    $ini->_params["DirectoriesSettings"]["UpdatesFolder"] = "{$UpdateUtilityStorePath}/databases";
    $ini->_params["DirectoriesSettings"]["TempFolder"] = "{$UpdateUtilityStorePath}/TempFolder";
    @mkdir("{$UpdateUtilityStorePath}/databases", 0755, true);
    @mkdir("{$UpdateUtilityStorePath}/TempFolder", 0755, true);
    $report_file = "/var/log/artica-postfix/UpdateUtility-report-" . time() . ".log";
    $ini->_params["ConnectionSettings"]["UseSpecifiedProxyServerSettings"] = "false";
    $ini->_params["ConnectionSettings"]["UseAuthenticationProxyServer"] = "false";
    $ini->_params["ReportSettings"]["ReportFileName"] = "{$report_file}";
    $datas = $sock->GET_INFO("ArticaProxySettings");
    if (trim($datas) != null) {
        $ini2->loadString($datas);
        $ArticaProxyServerEnabled = $ini->_params["PROXY"]["ArticaProxyServerEnabled"];
        $ArticaProxyServerName = $ini->_params["PROXY"]["ArticaProxyServerName"];
        $ArticaProxyServerPort = $ini->_params["PROXY"]["ArticaProxyServerPort"];
        $ArticaProxyServerUsername = trim($ini->_params["PROXY"]["ArticaProxyServerUsername"]);
        $ArticaProxyServerUserPassword = $ini->_params["PROXY"]["ArticaProxyServerUserPassword"];
        if ($ArticaProxyServerEnabled == "yes") {
            $ini->_params["ConnectionSettings"]["UseSpecifiedProxyServerSettings"] = "true";
            $ini->_params["ConnectionSettings"]["AddressProxyServer"] = $ArticaProxyServerName;
            $ini->_params["ConnectionSettings"]["PortProxyServer"] = $ArticaProxyServerPort;
            if ($ArticaProxyServerUsername != null) {
                $ini->_params["ConnectionSettings"]["UseAuthenticationProxyServer"] = "true";
                $ini->_params["ConnectionSettings"]["UserNameProxyServer"] = "{$ArticaProxyServerUsername}";
                $ini->_params["ConnectionSettings"]["PasswordProxyServer"] = "{$ArticaProxyServerUserPassword}";
            }
        }
    }
    $ini->saveFile("/etc/UpdateUtility/updater.ini");
    chdir("/etc/UpdateUtility");
    @chmod("/etc/UpdateUtility/UpdateUtility-Console", 0755);
    $cmd = "./UpdateUtility-Console -u -o /etc/UpdateUtility/updater.ini -r 2>&1";
    $Restart1 = false;
    writelogs("Running `{$cmd}`", __FUNCTION__, __FILE__, __LINE__);
    exec("{$cmd}", $results);
    while (list($key, $line) = each($results)) {
        if (preg_match("#Total downloading:\\s+([0-9]+)", $line, $re)) {
            $PERCT = $re[1];
        }
        if (preg_match("#Segmentation fault#", $line)) {
            $text = @implode("\n", $results);
            $Restart1 = true;
            system_admin_events("Segmentation fault at {$PERCT}% on UpdateUtility restart again...\n{$text}", __FUNCTION__, __FILE__, __LINE__, "update");
            $results = array();
            break;
        }
        writelogs("{$line}", __FUNCTION__, __FILE__, __LINE__);
    }
    if ($Restart1) {
        exec("{$cmd}", $results);
        while (list($key, $line) = each($results)) {
            if (preg_match("#Total downloading:\\s+([0-9]+)#", $line, $re)) {
                $PERCT = $re[1];
            }
            if (preg_match("#Segmentation fault#", $line)) {
                $text = @implode("\n", $results);
                system_admin_events("Segmentation fault at {$PERCT}%  on UpdateUtility Aborting...\n{$text}", __FUNCTION__, __FILE__, __LINE__, "update");
            }
            writelogs("{$line}", __FUNCTION__, __FILE__, __LINE__);
        }
    }
    $t2 = time();
    $timehuman = $unix->distanceOfTimeInWords($t, $t2);
    $text = @implode("\n", $results);
    system_admin_events("Executing UpdateUtility Success took {$timehuman}\n{$text}", __FUNCTION__, __FILE__, __LINE__, "update");
    $nohup = $unix->find_program("nohup");
    $php = $unix->LOCATE_PHP5_BIN();
    shell_exec("{$nohup} {$php} " . dirname(__FILE__) . "/exec.freeweb.php --reconfigure-updateutility >/dev/null 2>&1 &");
    ScanUpdateUtilityLogs(true);
    UpdateUtilitySize(true);
}
示例#8
0
function SetStatus($filetype, $max, $current, $startedAT)
{
    $ini = new Bs_IniHandler();
    $ini->set("PROGRESS", "type", $filetype);
    $ini->set("PROGRESS", "max", $max);
    $ini->set("PROGRESS", "current", $current);
    $ini->set("PROGRESS", "time", date('Y-m-d H:i:s'));
    $ini->set("PROGRESS", "pid", getmypid());
    $ini->set("PROGRESS", "starton", $startedAT);
    $ini->saveFile("/usr/share/artica-postfix/ressources/logs/postfix-logger.ini");
    @chmod("/usr/share/artica-postfix/ressources/logs/postfix-logger.ini", 0777);
}
function progress($pourc, $text)
{
    $file = "/usr/share/artica-postfix/ressources/logs/compile.iptables.progress";
    $ini = new Bs_IniHandler();
    $ini->set("PROGRESS", "pourc", $pourc);
    $ini->set("PROGRESS", "text", $text);
    $ini->saveFile($file);
    chmod($file, 0777);
}
示例#10
0
function CheckExistentDirectories()
{
    $change = false;
    $sock = new sockets();
    $ArticaMetaEnabled = $sock->GET_INFO("ArticaMetaEnabled");
    if ($ArticaMetaEnabled == null) {
        $ArticaMetaEnabled = 0;
    }
    $SharedFoldersDefaultMask = $sock->GET_INFO("SharedFoldersDefaultMask");
    $ArticaSambaAutomAskCreation = $sock->GET_INFO("ArticaSambaAutomAskCreation");
    if (!is_numeric($ArticaSambaAutomAskCreation)) {
        $ArticaSambaAutomAskCreation = 1;
    }
    if (!is_numeric($SharedFoldersDefaultMask)) {
        $SharedFoldersDefaultMask = 0755;
    }
    if ($ArticaSambaAutomAskCreation == 0) {
        $ArticaSambaAutomAskCreation = 0600;
    }
    $ini = new Bs_IniHandler("/etc/artica-postfix/settings/Daemons/SambaSMBConf");
    if (is_array($ini->_params)) {
        while (list($index, $array) = each($ini->_params)) {
            if ($index == "print\$") {
                continue;
            }
            if ($index == "printers") {
                continue;
            }
            if ($index == "homes") {
                continue;
            }
            if ($index == "global") {
                continue;
            }
            if ($array["path"] == null) {
                continue;
            }
            if (is_link($array["path"])) {
                continue;
            }
            if (is_dir($array["path"])) {
                continue;
            } else {
                if ($ArticaMetaEnabled == 1) {
                    @mkdir($array["path"], $SharedFoldersDefaultMask, true);
                    continue;
                }
            }
            unset($ini->_params[$index]);
            $change = true;
            continue;
        }
    }
    $ini->saveFile("/etc/artica-postfix/settings/Daemons/SambaSMBConf");
}
示例#11
0
function readlsfile($path)
{
    if (!preg_match('#-md-(.+?)\\.ls#', $path, $re)) {
        events("Unable to determine source from this file " . basename($path));
        return true;
    } else {
        $external_source = $re[1];
    }
    $file_name = basename($path);
    $filename = $path;
    $filesize = @filesize($filename);
    events("Request for analyze file {$path} size {$filesize} bytes");
    if ($filesize == 0) {
        events("Obytes -> Abort but return true;");
        return true;
    }
    if (preg_match('#(.+?)-md-.+?\\.[a-z0-9]+$#', $path, $re)) {
        $database_path = $re[1];
    }
    $database_name = basename($database_path);
    if (preg_match('#(.+?)\\-.+?\\-diff#', $database_name, $re)) {
        $database_name = $re[1];
    }
    if ($filesize > 400) {
        DeleteDatabase($database_name);
    }
    $source_path = GetSources($database_path);
    if ($source_path == null) {
        $source_path = GetSources($database_name);
    }
    $external_source_pattern = $_GET["STORAGES"][$external_source];
    if ($external_source == null) {
        events("Unable to find source for {$external_source} !!");
        return false;
    }
    events("*********************************************************************");
    events("Analyzing cache from {$filename}...");
    events("MD5 source....: {$external_source}");
    events("Pattern source: {$external_source_pattern}");
    events("database name.: {$database_name}");
    events("database Path.: {$database_path}");
    events("Source Path...: {$source_path}");
    events("*********************************************************************");
    $content = file_get_contents($filename);
    $md5 = md5($content);
    $ini = new Bs_IniHandler("/etc/artica-postfix/dar.cache.ini");
    if ($ini->_params["{$database_name}"]["md5"] == $md5) {
        events("Analyzing {$database_name} cache:{$md5} already set");
        return true;
    }
    $ini->set($database_name, "md5", $md5);
    $ini->saveFile("/etc/artica-postfix/dar.cache.ini");
    $filesize = @filesize($filename);
    $filesize = round($filesize / 1024, 2) . " Ko";
    events("Analyzing " . basename($filename) . " ({$filesize}) for database: {$database_name} cache:{$md5}");
    if ($fd = @fopen($filename, "r")) {
        while ($fd && !feof($fd)) {
            $line = trim(fgets($fd, 4096));
            if (preg_match("#^\\[.+?\\]\\s+\\[.*?\\]\\s+[a-z\\-]+\\s+[a-zA-Z0-9\\-\\_\\.]+\\s+[a-zA-Z0-9\\-\\_\\.]+\\s+([0-9]+)\\s+([a-zA-Z0-9\\s\\:]+)\\s+(.+)#", $line, $re)) {
                if (!Insert($re[3], $re[1], $re[2], $source_path, $database_name, $external_source_pattern)) {
                    events("Failed line \"{$line}\" aborting process");
                    return false;
                }
            } else {
                events("Failed line {$num} \"{$line}\" -> continue reading file...");
            }
        }
        fclose($fd);
        events("{$_GET["COUNT"][$database_name]} files added...");
        events("Optimize table...");
        $sql = "OPTIMIZE TABLE `dar_index`";
        $q = new mysql();
        $q->QUERY_SQL($sql, "artica_backup");
        return true;
    }
}
示例#12
0
function SambaAudit()
{
    $sock = new sockets();
    $EnableSambaXapian = $sock->GET_INFO("EnableSambaXapian");
    $EnableScannedOnly = $sock->GET_INFO('EnableScannedOnly');
    if ($EnableSambaXapian == null) {
        $EnableSambaXapian = 1;
    }
    if ($EnableScannedOnly == null) {
        $EnableScannedOnly = 1;
    }
    $users = new usersMenus();
    if (!$users->XAPIAN_PHP_INSTALLED) {
        $EnableSambaXapia = 0;
    }
    if (!$users->SCANNED_ONLY_INSTALLED) {
        $EnableScannedOnly = 0;
    }
    $ini = new Bs_IniHandler("/etc/samba/smb.conf");
    $write = true;
    while (list($num, $ligne) = each($ini->_params)) {
        if ($num != "homes") {
            if ($ligne["path"] == null) {
                continue;
            }
        }
        if ($num == "profiles") {
            continue;
        }
        if ($num == "printers") {
            continue;
        }
        if ($num == "print\$") {
            continue;
        }
        if ($num == "netlogon") {
            continue;
        }
        $vfs_objects = $ligne["vfs object"];
        if ($EnableSambaXapian == 1) {
            if (!IsVfsExists($vfs_objects, "full_audit")) {
                $ini->_params[$num]["vfs object"] = $ini->_params[$num]["vfs object"] . " full_audit";
                $ini->_params[$num]["vfs object"] = VFSClean($ini->_params[$num]["vfs object"]);
                $ini->_params[$num]["full_audit:prefix"] = "%u|%I|%m|%S|%P";
                $ini->_params[$num]["full_audit:success"] = "rename unlink pwrite write";
                $ini->_params[$num]["full_audit:failure"] = "none";
                $ini->_params[$num]["full_audit:facility"] = "LOCAL7";
                $ini->_params[$num]["full_audit:priority"] = "NOTICE";
                $write = true;
            }
        } else {
            if (IsVfsExists($vfs_objects, "full_audit")) {
                $ini->_params[$num]["vfs object"] = str_replace("full_audit", "", $ini->_params[$num]["vfs object"]);
                $ini->_params[$num]["vfs object"] = VFSClean($ini->_params[$num]["vfs object"]);
                unset($ini->_params[$num]["full_audit:prefix"]);
                unset($ini->_params[$num]["full_audit:success"]);
                unset($ini->_params[$num]["full_audit:failure"]);
                unset($ini->_params[$num]["full_audit:facility"]);
                unset($ini->_params[$num]["full_audit:priority"]);
                $write = true;
            }
        }
        if ($EnableScannedOnly == 0) {
            if (IsVfsExists($vfs_objects, "scannedonly")) {
                $ini->_params[$num]["vfs object"] = str_replace("scannedonly", "", $ini->_params[$num]["vfs object"]);
                $ini->_params[$num]["vfs object"] = VFSClean($ini->_params[$num]["vfs object"]);
                $write = true;
            }
        }
    }
    if ($write) {
        $ini->saveFile("/etc/samba/smb.conf");
    }
}
示例#13
0
function NotifyClient($server)
{
    $file = "/etc/artica-cluster/notify-{$server}";
    $ini = new Bs_IniHandler();
    $ini->loadFile($file);
    $ini->_params["PARAMS"]["name"] = "{$server}";
    $sock = new sockets();
    $cyrus_id = $sock->getFrameWork("cmd.php?idofUser=cyrus");
    $ini->_params["PARAMS"]["cyrus_id"] = $cyrus_id;
    if (!function_exists("curl_init")) {
        $ini->_params["PARAMS"]["notify"] = 0;
        $ini->_params["PARAMS"]["error"] = 1;
        $ini->_params["PARAMS"]["error_text"] = "{error_php_curl}";
        $ini->_params["PARAMS"]["name"] = "{$server}";
        $ini->_params["PARAMS"]["cyrus_id"] = $cyrus_id;
        $ini->saveFile($file);
        return null;
    }
    while (list($num, $ligne) = each($ini->_params["PARAMS"])) {
        $curlPost .= '&' . $num . '=' . urlencode($ligne);
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://{$server}:9000/exec.gluster.php");
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
    $data = curl_exec($ch);
    $error = curl_errno($ch);
    if ($error > 0) {
        writelogs("Connect to {$server} error {$error}", __FUNCTION__, __FILE__, __LINE__);
    }
    switch ($error) {
        case 6:
            $ini->_params["PARAMS"]["notify"] = 0;
            $ini->_params["PARAMS"]["error"] = 1;
            $ini->_params["PARAMS"]["error_text"] = "{error_curl_resolve}";
            $ini->saveFile($file);
            curl_close($ch);
            return null;
            break;
        default:
            break;
    }
    if (curl_errno($ch) == false) {
        if (preg_match("#404 Not Found#is", $data)) {
            writelogs("Connect to {$server} error 404 Not Found", __FUNCTION__, __FILE__, __LINE__);
            $ini->_params["PARAMS"]["notify"] = 0;
            $ini->_params["PARAMS"]["error"] = 1;
            $ini->_params["PARAMS"]["notified"] = 0;
            $ini->_params["PARAMS"]["error_text"] = "{error_wrong_artica_version}";
            $ini->saveFile($file);
            curl_close($ch);
            return null;
        }
        if (preg_match("#GLUSTER_NOT_INSTALLED#is", $data)) {
            writelogs("Connect to {$server} error GLUSTER_NOT_INSTALLED", __FUNCTION__, __FILE__, __LINE__);
            $ini->_params["PARAMS"]["notify"] = 0;
            $ini->_params["PARAMS"]["error"] = 1;
            $ini->_params["PARAMS"]["notified"] = 0;
            $ini->_params["PARAMS"]["error_text"] = "{error_gluster_not_installed}";
            $ini->saveFile($file);
            curl_close($ch);
            return null;
        }
        if (preg_match("#CURL_NOT_INSTALLED#is", $data)) {
            writelogs("Connect to {$server} error CURL_NOT_INSTALLED", __FUNCTION__, __FILE__, __LINE__);
            $ini->_params["PARAMS"]["notify"] = 0;
            $ini->_params["PARAMS"]["error"] = 1;
            $ini->_params["PARAMS"]["notified"] = 0;
            $ini->_params["PARAMS"]["error_text"] = "{error_php_curl}";
            $ini->saveFile($file);
            curl_close($ch);
            return null;
        }
    }
    if (preg_match("#GLUSTER_OK#is", $data)) {
        writelogs("Connect to {$server} success", __FUNCTION__, __FILE__, __LINE__);
        $ini->_params["PARAMS"]["notify"] = 0;
        $ini->_params["PARAMS"]["error"] = 0;
        $ini->_params["PARAMS"]["notified"] = 1;
        $ini->_params["PARAMS"]["error_text"] = "{success}";
        writelogs("Set this server has notified", __FUNCTION__, __FILE__, __LINE__);
        $ini->saveFile($file);
        curl_close($ch);
        return null;
    }
    //echo $data;
}
示例#14
0
    }
    $count = $count + 1;
    $ini = new Bs_IniHandler();
    $ini->set("PROGRESS", "current", $count);
    $ini->set("PROGRESS", "total", $max);
    $ini->set("PROGRESS", "pid", $pid);
    $ini->set("PROGRESS", "quarantine", "(spam)/virus *.gz,virus-");
    $ini->saveFile("/usr/share/artica-postfix/ressources/logs/mailarchive-quarantine-progress.ini");
    chmod("/usr/share/artica-postfix/ressources/logs/mailarchive-quarantine-progress.ini", 0755);
    //if($count>50){break;}
}
$ini = new Bs_IniHandler();
$ini->set("PROGRESS", "pid", "0");
$date = date('H:i:s');
$ini->set("PROGRESS", "quarantine", "Finish {$date1} -> {$date}, next in 5mn");
$ini->saveFile("/usr/share/artica-postfix/ressources/logs/mailarchive-quarantine-progress.ini");
system('/bin/rm /var/virusmails/*.eml >/dev/null 2>&1');
ASSP_QUAR("/usr/share/assp/spam");
ASSP_QUAR("/usr/share/assp/discarded");
ASSP_QUAR("/usr/share/assp/quarantine");
ASSP_QUAR("/usr/share/assp/errors/notspam");
ASSP_QUAR("/usr/share/assp/errors/spam");
ASSP_QUAR("/var/spam-mails");
die;
function ASSP_QUAR($baseDir)
{
    //""
    if (!is_dir($baseDir)) {
        return null;
    }
    $files = DirEML($baseDir);
function point_events($postfix_id=null,$smtp_sender=null,$from=null,$to=null,$error=null,$mailsize=0){
	if($postfix_id==null){
		if($GLOBALS["DebugArticaFilter"]==1){events("postfix_id is null",__FUNCTION__,__LINE__);}
		return;
	}
	@mkdir("/var/log/artica-postfix/RTM",null,true);
	$file="/var/log/artica-postfix/RTM/$postfix_id.msg";
	if($GLOBALS["DebugArticaFilter"]==1){events("Loading monitor file $file",__FUNCTION__,__LINE__);}
	$ini=new Bs_IniHandler($file);
	
	if($GLOBALS["DebugArticaFilter"]==1){events("populate monitor file $file",__FUNCTION__,__LINE__);}
	if($smtp_sender<>null){$ini->set("TIME","smtp_sender",$smtp_sender);}
	
	if($from<>null){$ini->set("TIME","mailfrom",$from);}
	$ini->set("TIME","mailto","$to");
	
	$ini->set("TIME","time_end",date("Y-m-d H:i:s"));
	$ini->set("TIME","message-id",$postfix_id);
	$ini->set("TIME","mailsize",$mailsize);
	
	
	if($error==null){
		$ini->set("TIME","bounce_error","Success");
		$ini->set("TIME","delivery_success","yes");
	}else{
		$ini->set("TIME","bounce_error","$error");
		$ini->set("TIME","delivery_success","no");
	}
	if($GLOBALS["DebugArticaFilter"]==1){events("save monitor file $file",__FUNCTION__,__LINE__);}
	$ini->saveFile($file);	
	
	
}
示例#16
0
function progress($pourc, $text)
{
    if ($GLOBALS["VERBOSE"]) {
        echo "{$pourc}% {$text}\n";
    }
    $file = "/usr/share/artica-postfix/ressources/logs/compile.iptables.progress";
    $ini = new Bs_IniHandler();
    $ini->set("PROGRESS", "pourc", $pourc);
    $ini->set("PROGRESS", "text", $text);
    $ini->saveFile($file);
    chmod($file, 0777);
}
示例#17
0
function CheckExistentDirectories(){
	$change=false;
	$sock=new sockets();
	$ArticaMetaEnabled=$sock->GET_INFO("ArticaMetaEnabled");
	if($ArticaMetaEnabled==null){$ArticaMetaEnabled=0;}
	
	
	$ini=new Bs_IniHandler("/etc/artica-postfix/settings/Daemons/SambaSMBConf");
	if(is_array($ini->_params)){
		while (list ($index, $array) = each ($ini->_params) ){
			if($index=="print$"){continue;}
			if($index=="printers"){continue;}
			if($index=="homes"){continue;}
			if($index=="global"){continue;}
			if($array["path"]==null){continue;}
			if(is_link($array["path"])){continue;}
			if(is_dir($array["path"])){continue;}else{if($ArticaMetaEnabled==1){@mkdir($array["path"],0755,true);continue;}}
			unset($ini->_params[$index]);
			$change=true;
			continue;
		}
	}
	
	$ini->saveFile("/etc/artica-postfix/settings/Daemons/SambaSMBConf");
	
}
示例#18
0
function interface_events($product, $line)
{
    $ini = new Bs_IniHandler();
    if (is_file("/usr/share/artica-postfix/ressources/logs/interface.events")) {
        $ini->loadFile("/usr/share/artica-postfix/ressources/logs/interface.events");
    }
    $ini->set($product, 'error', $line);
    $ini->saveFile("/usr/share/artica-postfix/ressources/logs/interface.events");
    @chmod("/usr/share/artica-postfix/ressources/logs/interface.events", 0755);
}
示例#19
0
function mailboxes_flow()
{
    $tpl = new Templates();
    $users = new usersMenus();
    $users->LoadModulesEnabled();
    if ($users->EnableAmavisDaemon == 0) {
        die;
    }
    if ($users->EnableMysqlFeatures == 0) {
        die;
    }
    writelogs("user={$_SESSION['uid']}", __FUNCTION__, __FILE__);
    $cachfile = "ressources/logs/{$_SESSION['uid']}_stat.ini";
    if (!file_exists($cachfile)) {
        $build = true;
    } else {
        $Diff = round((time() - filemtime($cachfile)) / 60, 0);
        writelogs("{$cachfile}={$Diff} mn");
        if ($Diff > 10) {
            $build = true;
        } else {
            $build = false;
        }
    }
    if ($build) {
        $user = new user($_SESSION['uid']);
        $AllMails = $user->aliases;
        $AllMails[] = $user->mail;
        while (list($num, $array) = each($AllMails)) {
            if ($array == null) {
                continue;
            }
            $recieve[] = "OR mails_events.rcpt_to='{$array}'";
        }
        $recieve[0] = str_replace("OR ", '', $recieve[0]);
        $s = new mysql();
        $sql = "SELECT count( spam ) as tspam FROM `mails_events` WHERE spam=1 AND (" . implode(" ", $recieve) . ")";
        $ligne = @mysql_fetch_array($s->QUERY_SQL($sql, "artica_events"));
        $spam = $ligne["tspam"];
        writelogs("{$_SESSION['uid']} SPAM={$spam}", __FUNCTION__, __FILE__);
        $sql = "SELECT count( infected ) as tinfected FROM `mails_events` WHERE infected=1 AND (" . implode(" ", $recieve) . ")";
        $ligne = @mysql_fetch_array($s->QUERY_SQL($sql, "artica_events"));
        $infected = $ligne["tinfected"];
        $sql = "SELECT count( banned ) as tbanned FROM `mails_events` WHERE banned=1 AND (" . implode(" ", $recieve) . ")";
        $ligne = @mysql_fetch_array($s->QUERY_SQL($sql, "artica_events"));
        $banned = $ligne["tbanned"];
        $sql = "SELECT count(ID) as tot FROM `mails_events` WHERE 1 AND (" . implode(" ", $recieve) . ")";
        $ligne = @mysql_fetch_array($s->QUERY_SQL($sql, "artica_events"));
        $total = $ligne["tot"];
        $tot = $total - $banned - $spam - $infected;
        $ini = new Bs_IniHandler();
        $ini->_params["FLOW"]["SPAM"] = $spam;
        $ini->_params["FLOW"]["INFECTED"] = $infected;
        $ini->_params["FLOW"]["BANNED"] = $banned;
        $ini->_params["FLOW"]["TOTAL"] = $tot;
        $ini->saveFile($cachfile);
    } else {
        $ini = new Bs_IniHandler($cachfile);
        $spam = $ini->_params["FLOW"]["SPAM"];
        $infected = $ini->_params["FLOW"]["INFECTED"];
        $banned = $ini->_params["FLOW"]["BANNED"];
        $tot = $ini->_params["FLOW"]["TOTAL"];
    }
    if ($tot == 0) {
        die;
    }
    $data = array($spam, $infected, $banned, $tot);
    // Create the Pie Graph.
    $graph = new PieGraph(350, 350, 'auto');
    //$graph->SetShadow();
    $graph->title->Set("{$total} messages");
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    // Create
    $p1 = new PiePlot3D($data);
    //$p1->SetLegends(array("SPAM","Virus","Bann","Clean"));
    $p1->SetLabels(array("SPAM:{$spam}", "Virus:{$infected}", "Bann:{$banned}", "Clean:{$tot}"), 1);
    $p1->SetEdge('black', 1);
    $p1->SetAngle(75);
    $p1->SetLabelMargin(2);
    //$p1->SetCSIMTargets($targ,$alts);
    // Use absolute labels
    //$p1->SetLabelType(0);
    //$p1->value->SetFormat("%d kr");
    // Move the pie slightly to the left
    $p1->SetCenter(0.4, 0.5);
    $p1->ExplodeAll(10);
    $graph->Add($p1);
    $graph->SetFrame(false);
    // Send back the HTML page which will call this script again
    // to retrieve the image.
    $graph->StrokeCSIM();
}