Ejemplo n.º 1
0
function verify_caches()
{
    $blk = new blackboxes();
    $blk->NotifyAll("VERIFY_CACHE");
    $tpl = new templates();
    echo $tpl->javascript_parse_text("{all_nodes_has_been_notified}");
}
Ejemplo n.º 2
0
function SambeReconnectAD()
{
    $sock = new sockets();
    $users = new usersMenus();
    $sock->getFrameWork("services.php?kerbauth=yes");
    $sock->getFrameWork("services.php?nsswitch=yes");
    $sock->getFrameWork("cmd.php?samba-reconfigure=yes");
    $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    if (!is_numeric($EnableWebProxyStatsAppliance)) {
        $EnableWebProxyStatsAppliance = 0;
    }
    if ($users->WEBSTATS_APPLIANCE) {
        $EnableWebProxyStatsAppliance = 1;
    }
    if ($EnableWebProxyStatsAppliance == 1) {
        include_once "ressources/class.blackboxes.inc";
        $blk = new blackboxes();
        $blk->NotifyAll("WINBIND_RECONFIGURE");
    }
}
function notifyRemoteProxy()
{
    $sock = new sockets();
    $users = new usersMenus();
    $q = new mysql_squid_builder();
    $q->QUERY_SQL("DELETE FROM webfilter_aclsdynlogs WHERE zDate<DATE_SUB(NOW(),INTERVAL 15 DAY)");
    $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
    if (!is_numeric($EnableWebProxyStatsAppliance)) {
        $EnableWebProxyStatsAppliance = 0;
    }
    if ($users->WEBSTATS_APPLIANCE) {
        $EnableWebProxyStatsAppliance = 1;
    }
    if ($EnableWebProxyStatsAppliance == 0) {
        return;
    }
    include_once dirname(__FILE__) . "/ressources/class.blackboxes.inc";
    $black = new blackboxes();
    $black->NotifyAll("ACLSDYN");
}
function active_directory_save()
{
    $sock = new sockets();
    $users = new usersMenus();
    include_once dirname(__FILE__) . "/class.html.tools.inc";
    $_POST["WINDOWS_SERVER_PASS"] = url_decode_special_tool($_POST["WINDOWS_SERVER_PASS"]);
    unset($_SESSION["EnableKerbAuth"]);
    $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    if (!is_numeric($EnableWebProxyStatsAppliance)) {
        $EnableWebProxyStatsAppliance = 0;
    }
    if ($users->WEBSTATS_APPLIANCE) {
        $EnableWebProxyStatsAppliance = 1;
    }
    //CNTLM
    $sock->SET_INFO("EnableCNTLM", $_POST["EnableCNTLM"]);
    $sock->SET_INFO("CnTLMPORT", $_POST["CnTLMPORT"]);
    $sock->getFrameWork("squid.php?cntlm-restart=yes");
    $_POST["WINDOWS_DNS_SUFFIX"] = trim(strtolower($_POST["WINDOWS_DNS_SUFFIX"]));
    $Myhostname = $sock->getFrameWork("cmd.php?full-hostname=yes");
    $MyhostnameTR = explode(".", $Myhostname);
    unset($MyhostnameTR[0]);
    $MyDomain = strtolower(@implode(".", $MyhostnameTR));
    if ($MyDomain != $_POST["WINDOWS_DNS_SUFFIX"]) {
        $tpl = new templates();
        if ($EnableWebProxyStatsAppliance == 0) {
            $sock->SET_INFO("EnableKerbAuth", 0);
        }
        $sock->SET_INFO("EnableKerberosAuthentication", 0);
        $sock->SaveConfigFile(base64_encode(serialize($_POST)), "KerbAuthInfos");
        echo $tpl->javascript_parse_text("{error}: {WINDOWS_DNS_SUFFIX} {$_POST["WINDOWS_DNS_SUFFIX"]}\n{is_not_a_part_of} {$Myhostname} ({$MyDomain})", 1);
        return;
    }
    $adhost = "{$_POST["WINDOWS_SERVER_NETBIOSNAME"]}.{$_POST["WINDOWS_DNS_SUFFIX"]}";
    $resolved = gethostbyname($adhost);
    if (!preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+#", $resolved)) {
        $tpl = new templates();
        if ($EnableWebProxyStatsAppliance == 0) {
            $sock->SET_INFO("EnableKerbAuth", 0);
        }
        $sock->SET_INFO("EnableKerberosAuthentication", 0);
        $sock->SaveConfigFile(base64_encode(serialize($_POST)), "KerbAuthInfos");
        echo $tpl->javascript_parse_text("{error}: {unable_to_resolve} {$adhost}", 1);
        return;
    }
    $sock->SET_INFO("KerbAuthDisableNormalizeName", $_POST["KerbAuthDisableNormalizeName"]);
    $sock->SET_INFO("EnableKerberosAuthentication", $_POST["EnableKerberosAuthentication"]);
    $sock->SET_INFO("KerbAuthDisableNsswitch", $_POST["KerbAuthDisableNsswitch"]);
    $sock->SET_INFO("KerbAuthDisableGroupListing", $_POST["KerbAuthDisableGroupListing"]);
    $sock->SET_INFO("KerbAuthTrusted", $_POST["KerbAuthTrusted"]);
    $sock->SET_INFO("KerbAuthMapUntrustedDomain", $_POST["KerbAuthMapUntrustedDomain"]);
    $sock->SET_INFO("NtpdateAD", $_POST["NtpdateAD"]);
    $sock->SET_INFO("KerbAuthMethod", $_POST["KerbAuthMethod"]);
    $sock->SET_INFO("SquidNTLMKeepAlive", $_POST["SquidNTLMKeepAlive"]);
    if ($_POST["EnableKerberosAuthentication"] == 1) {
        $sock->SET_INFO("EnableKerbAuth", 0);
    }
    $ArrayKerbAuthInfos = unserialize(base64_decode($sock->GET_INFO("KerbAuthInfos")));
    while (list($num, $ligne) = each($_POST)) {
        $ArrayKerbAuthInfos[$num] = $ligne;
    }
    $sock->SaveConfigFile(base64_encode(serialize($ArrayKerbAuthInfos)), "KerbAuthInfos");
    if (strpos($_POST["ADNETBIOSDOMAIN"], ".") > 0) {
        echo "The netbios domain \"{$_POST["ADNETBIOSDOMAIN"]}\" is invalid.\n";
        $sock->SET_INFO("EnableKerbAuth", 0);
        return;
    }
    if ($_POST["ADNETIPADDR"] != null) {
        $ipaddrZ = explode(".", $_POST["ADNETIPADDR"]);
        while (list($num, $a) = each($ipaddrZ)) {
            $ipaddrZ[$num] = intval($a);
        }
        $_POST["ADNETIPADDR"] = @implode(".", $ipaddrZ);
    }
    $sock->SET_INFO("EnableKerbAuth", $_POST["EnableKerbAuth"]);
    $sock->SET_INFO("DynamicGroupsAclsTTL", $_POST["DynamicGroupsAclsTTL"]);
    $_POST["LDAP_PASSWORD"] = url_decode_special_tool($_POST["LDAP_PASSWORD"]);
    $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
    if (!is_numeric($EnableWebProxyStatsAppliance)) {
        $EnableWebProxyStatsAppliance = 0;
    }
    if ($_POST["UseDynamicGroupsAcls"] == 1) {
        if ($_POST["LDAP_SERVER"] == null) {
            echo $tpl->javascript_parse_text("LDAP: {hostname} Not set\n");
            return;
        }
        if (!is_numeric($_POST["LDAP_PORT"])) {
            echo $tpl->javascript_parse_text("LDAP: {ldap_port} Not set\n");
            return;
        }
        if ($_POST["LDAP_SUFFIX"] == null) {
            echo $tpl->javascript_parse_text("LDAP: {suffix} Not set\n");
            return;
        }
        if ($_POST["LDAP_DN"] == null) {
            echo $tpl->javascript_parse_text("LDAP: {bind_dn} Not set\n");
            return;
        }
        if ($_POST["LDAP_PASSWORD"] == null) {
            echo $tpl->javascript_parse_text("LDAP: {password} Not set\n");
            return;
        }
    }
    $sock->SET_INFO("UseDynamicGroupsAcls", $_POST["UseDynamicGroupsAcls"]);
    $array = unserialize(base64_decode($sock->GET_INFO("KerbAuthInfos")));
    while (list($num, $ligne) = each($_POST)) {
        $array[$num] = $ligne;
    }
    $sock->SaveConfigFile(base64_encode(serialize($array)), "KerbAuthInfos");
    $ldap_connection = @ldap_connect($_POST["LDAP_SERVER"], $_POST["LDAP_PORT"]);
    if (!$ldap_connection) {
        echo "Connection Failed to connect to DC ldap://{$_POST["LDAP_SERVER"]}:{$_POST["LDAP_PORT"]}";
        if (@ldap_get_option($ldap_connection, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extended_error)) {
            $error = $error . "\n{$extended_error}";
        }
        @ldap_close();
        return false;
    }
    ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0);
    $bind = ldap_bind($ldap_connection, $_POST["LDAP_DN"], $_POST["LDAP_PASSWORD"]);
    if (!$bind) {
        $error = ldap_err2str(ldap_errno($ldap_connection));
        if (@ldap_get_option($ldap_connection, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extended_error)) {
            $error = $error . "\n{$extended_error}";
        }
        echo "Failed to login to DC {$_POST["LDAP_SERVER"]} - {$_POST["LDAP_DN"]} \n`{$error}`";
        return false;
    }
    if ($EnableWebProxyStatsAppliance == 1) {
        include_once "ressources/class.blackboxes.inc";
        $blk = new blackboxes();
        $blk->NotifyAll("BUILDCONF");
        return;
    }
    $sock->getFrameWork("squid.php?squid-reconfigure=yes");
}
Ejemplo n.º 5
0
function notify_remote_proxys($COMMANDS = null)
{
    $unix = new unix();
    include_once dirname(__FILE__) . "/ressources/class.blackboxes.inc";
    $EXEC_PID_FILE = "/etc/artica-postfix/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $EXEC_PID_TIME = "/etc/artica-postfix/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pid = @file_get_contents($EXEC_PID_FILE);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timefile = $unix->file_time_min($EXEC_PID_FILE);
        if ($timefile < 15) {
            $unix->events("Skipping, Already executed pid {$pid} {$timefile}Mn", "/var/log/stats-appliance.log");
            ufdbguard_admin_events("Skipping, Already executed pid {$pid} {$timefile}Mn...", __FUNCTION__, __FILE__, __LINE__, "communicate");
            return;
        }
        $kill = $unix->find_program("kill");
        unix_system_kill_force($pid);
    }
    @file_put_contents($EXEC_PID_FILE, getmypid());
    if ($COMMANDS == null) {
        $COMMANDS = "BUILDCONF";
    }
    if ($COMMANDS == "PING") {
        $time = $unix->file_time_min($EXEC_PID_TIME);
        if (!$GLOBALS["VERBOSE"]) {
            if ($time < 5) {
                return;
            }
        }
        @unlink($EXEC_PID_TIME);
        @file_put_contents($EXEC_PID_TIME, time());
        $bb = new blackboxes();
        $bb->NotifyAll("PING");
        return;
    }
    $t = time();
    $f = new squid_stats_appliance();
    $f->export_tables();
    $took = $unix->distanceOfTimeInWords($t, time(), true);
    ufdbguard_admin_events("Exporting MySQL datas done... took:{$took}", __FUNCTION__, __FILE__, __LINE__, "communicate");
    $unix->events("Exporting MySQL datas done... took:{$took}", "/var/log/stats-appliance.log");
    include_once dirname(__FILE__) . "/ressources/class.blackboxes.inc";
    $unix->events("Send order to appliance(s)", "/var/log/stats-appliance.log");
    $bb = new blackboxes();
    $bb->NotifyAll("BUILDCONF");
}