Example #1
0
function settings()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $sock = new sockets();
    $t = time();
    $EnablePDNS = $sock->GET_INFO("EnablePDNS");
    $PDNSRestartIfUpToMB = $sock->GET_INFO("PDNSRestartIfUpToMB");
    $DisablePowerDnsManagement = $sock->GET_INFO("DisablePowerDnsManagement");
    $EnablePDNS = $sock->GET_INFO("EnablePDNS");
    $PowerUseGreenSQL = $sock->GET_INFO("PowerUseGreenSQL");
    $PowerDisableDisplayVersion = $sock->GET_INFO("PowerDisableDisplayVersion");
    $PowerActHasMaster = $sock->GET_INFO("PowerActHasMaster");
    $PowerDNSDNSSEC = $sock->GET_INFO("PowerDNSDNSSEC");
    $PowerDNSDisableLDAP = $sock->GET_INFO("PowerDNSDisableLDAP");
    $PowerChroot = $sock->GET_INFO("PowerChroot");
    $PowerActAsSlave = $sock->GET_INFO("PowerActAsSlave");
    $PowerDNSLogLevel = $sock->GET_INFO("PowerDNSLogLevel");
    $PowerSkipCname = $sock->GET_INFO("PowerSkipCname");
    if (!is_numeric($EnablePDNS)) {
        $EnablePDNS = 0;
    }
    $PowerDNSMySQLEngine = 1;
    if (!is_numeric($PowerActHasMaster)) {
        $PowerActHasMaster = 0;
    }
    if (!is_numeric($PDNSRestartIfUpToMB)) {
        $PDNSRestartIfUpToMB = 700;
    }
    if (!is_numeric($DisablePowerDnsManagement)) {
        $DisablePowerDnsManagement = 0;
    }
    if (!is_numeric($PowerUseGreenSQL)) {
        $PowerUseGreenSQL = 0;
    }
    if (!is_numeric($PowerDisableDisplayVersion)) {
        $PowerDisableDisplayVersion = 0;
    }
    if (!is_numeric($PowerDNSDNSSEC)) {
        $PowerDNSDNSSEC = 0;
    }
    if (!is_numeric($PowerDNSDisableLDAP)) {
        $PowerDNSDisableLDAP = 1;
    }
    if (!is_numeric($PowerChroot)) {
        $PowerChroot = 0;
    }
    if (!is_numeric($PowerActAsSlave)) {
        $PowerActAsSlave = 0;
    }
    if (!is_numeric($PowerDNSLogLevel)) {
        $PowerDNSLogLevel = 1;
    }
    if (!is_numeric($PowerSkipCname)) {
        $PowerSkipCname = 0;
    }
    $PowerDNSMySQLType = $sock->GET_INFO("PowerDNSMySQLType");
    $PowerDNSMySQLRemoteServer = $sock->GET_INFO("PowerDNSMySQLRemoteServer");
    $PowerDNSMySQLRemotePort = $sock->GET_INFO("PowerDNSMySQLRemotePort");
    $PowerDNSMySQLRemoteAdmin = $sock->GET_INFO("PowerDNSMySQLRemoteAdmin");
    $PowerDNSMySQLRemotePassw = $sock->GET_INFO("PowerDNSMySQLRemotePassw");
    if (!is_numeric($PowerDNSMySQLType)) {
        $PowerDNSMySQLType = 1;
    }
    if (!is_numeric($PowerDNSMySQLRemotePort)) {
        $PowerDNSMySQLRemotePort = 3306;
    }
    $PowerDNSMySQLTypeA[1] = "{main_mysql_server_2}";
    $PowerDNSMySQLTypeA[2] = "{main_mysql_server_4}";
    $PowerDNSMySQLTypeA[3] = "{main_mysql_server_5}";
    for ($i = 0; $i < 10; $i++) {
        $loglevels[$i] = $i;
    }
    $boot = new boostrap_form();
    $boot->set_checkbox("EnablePDNS", "{EnablePDNS}", $EnablePDNS, array("ONDISABLE" => "{EnablePDNS_disable_text}"));
    $boot->set_checkbox("DisablePowerDnsManagement", "{DisablePowerDnsManagement}", $DisablePowerDnsManagement);
    $boot->set_checkbox("PowerActHasMaster", "{ActHasMaster}", $PowerActHasMaster);
    $boot->set_checkbox("PowerActAsSlave", "{ActHasSlave}", $PowerActAsSlave);
    $boot->set_checkbox("PowerDNSDNSSEC", "DNSSEC", $PowerDNSDNSSEC);
    $boot->set_checkbox("PowerUseGreenSQL", "{useGreenSQL}", $PowerUseGreenSQL);
    $boot->set_checkbox("PowerDisableDisplayVersion", "{DisableDisplayVersion}", $PowerDisableDisplayVersion);
    $boot->set_checkbox("PowerChroot", "{chroot}", $PowerChroot);
    $boot->set_list("PowerDNSLogLevel", "{log level}", $loglevels, $PowerDNSLogLevel);
    $boot->set_field("PDNSRestartIfUpToMB", "{RestartServiceifReachMb}", $PDNSRestartIfUpToMB);
    $boot->set_list("PowerDNSMySQLType", "{mysql_database}", $PowerDNSMySQLTypeA, $PowerDNSMySQLType);
    $boot->set_field("PowerDNSMySQLRemoteServer", "{remote_mysql_server}", $PowerDNSMySQLRemoteServer);
    $boot->set_field("PowerDNSMySQLRemotePort", "{mysql_server_port}", $PowerDNSMySQLRemotePort);
    $boot->set_field("PowerDNSMySQLRemoteAdmin", "{mysql_admin}", $PowerDNSMySQLRemoteAdmin);
    $boot->set_fieldpassword("PowerDNSMySQLRemotePassw", "{password}", $PowerDNSMySQLRemotePassw);
    $boot->set_button("{apply}");
    $boot->setAjaxPage("pdns.php");
    $boot->set_PROTO("GET");
    echo $tpl->_ENGINE_parse_body("<div class=text-info>{pdns_explain}</div>") . $boot->Compile();
}
function nic_config()
{
    $sock = new sockets();
    $tpl = new templates();
    $t = time();
    $page = CurrentPageName();
    $EnableipV6 = $sock->GET_INFO("EnableipV6");
    if (!is_numeric($EnableipV6)) {
        $EnableipV6 = 0;
    }
    $ERROR_NO_PRIVS = $tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
    $DisableNetworksManagement = $sock->GET_INFO("DisableNetworksManagement");
    if (!is_numeric($DisableNetworksManagement)) {
        $DisableNetworksManagement = 0;
    }
    $eth = $_GET["nic"];
    $BUTTON = true;
    if (preg_match("#^tun#", $eth)) {
        $BUTTON = false;
    }
    if (preg_match("#([a-z0-9]+)\\.[0-9]+#", $eth)) {
        $BUTTON = false;
    }
    $nic = new system_nic($eth);
    $users = new usersMenus();
    if ($users->SNORT_INSTALLED) {
        $EnableSnort = $sock->GET_INFO("EnableSnort");
        if ($EnableSnort != 1) {
            $jsSnort = "DisableSnortInterface();";
        }
        $snortInterfaces = unserialize(base64_decode($sock->GET_INFO("SnortNics")));
    }
    if (!$users->SNORT_INSTALLED) {
        $jsSnort = "DisableSnortInterface();";
    }
    $button = "{apply}";
    if ($_GET["button"] == "confirm") {
        $button = "{button_i_confirm_nic}";
    }
    $q = new mysql();
    if (!$q->FIELD_EXISTS("nics", "defaultroute", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE `nics` ADD `defaultroute` smallint(1) NOT NULL,ADD INDEX (`defaultroute`)", "artica_backup");
    }
    $results = $q->QUERY_SQL("SELECT ID,name FROM nics_bridge ORDER BY name", "artica_backup");
    $bridges[null] = "{select}";
    while ($ligne = mysql_fetch_assoc($results)) {
        $bridges["br{$ligne["ID"]}"] = $ligne["name"];
    }
    $defaultroute_interface = null;
    $defaultroute_field = false;
    $sql = "SELECT Interface  FROM `nics` WHERE defaultroute=1";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    if (!$q->ok) {
        if (strpos("Unknown column", $q->mysql_error) > 1) {
            $q->QUERY_SQL("ALTER TABLE `nics` ADD `defaultroute` smallint(1) NOT NULL,ADD INDEX (`defaultroute`)", "artica_backup");
            if (!$q->ok) {
                echo "<p class=text-error>Alter: {$q->mysql_error}</p>";
            }
            $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        }
    }
    if (!$q->ok) {
        echo "<p class=text-error>{$q->mysql_error}</p>";
    }
    if ($ligne["Interface"] == null) {
        $defaultroute_field = true;
    } else {
        if (trim($ligne["Interface"]) == $eth) {
            $defaultroute_field = true;
        }
        $defaultroute_interface = $ligne["Interface"];
    }
    $boot = new boostrap_form();
    if ($defaultroute_interface != null) {
        $defaultroute_interface_explain = $tpl->_ENGINE_parse_body("{defaultroute_interface_explain}");
        $defaultroute_interface_explain = str_replace("%s", $defaultroute_interface, $defaultroute_interface_explain);
        $boot->set_spacerexplain($defaultroute_interface_explain);
    }
    $boot->set_hidden("UseSnort", $snortInterfaces[$eth]);
    $boot->set_hidden("noreboot", $_GET["noreboot"]);
    $boot->set_hidden("save_nic", $eth);
    $boot->set_checkbox("enabled", "{enabled}", $nic->enabled, array("DISABLEALL" => true));
    $boot->set_checkbox("dhcp", "{use_dhcp}", $nic->dhcp);
    $boot->set_field("IPADDR", "{tcp_address}", $nic->IPADDR, array("IPV4" => true));
    $boot->set_field("NETMASK", "{netmask}", $nic->NETMASK, array("IPV4" => true));
    $boot->set_field("GATEWAY", "{gateway}", $nic->GATEWAY, array("IPV4" => true));
    $boot->set_field("DNS_1", "{primary_dns}", $nic->DNS1);
    $boot->set_field("DNS_2", "{secondary_dns}", $nic->DNS2);
    $boot->set_field("metric", "{metric}", $nic->metric);
    if ($defaultroute_field) {
        $boot->set_checkbox("defaultroute", "{default_route}", $nic->defaultroute);
    } else {
        $boot->set_hidden("defaultroute", 0);
    }
    $boot->set_checkbox("Bridged", "{attach_to_bridge}", $nic->Bridged, array("LINK" => "BridgedTo"));
    $boot->set_list("BridgedTo", "{network_bridge}", $bridges, $nic->BridgedTo);
    $boot->setAjaxPage("system.nic.edit.php");
    $boot->set_RefreshSearchs();
    if ($BUTTON) {
        $boot->set_button("{apply}");
    } else {
        $boot->set_form_locked();
    }
    $boot->set_PROTO("GET");
    if ($DisableNetworksManagement == 1) {
        $boot->set_form_locked();
    }
    if (!$users->AsSystemAdministrator) {
        $boot->set_form_locked();
    }
    $form = $boot->Compile();
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($form);
}