Esempio n. 1
0
        suExec("touchconf \"/var/appliance/conf/dhcpd.conf.new\"");
        if (file_put_contents("/var/appliance/conf/dhcpd.conf.new", $nbconf) === FALSE) {
            echo "<div class=\"errorMessage\">ERROR: Unable to update dhcpd.conf</div>";
        }
        suExec("disablenetboot");
        suExec("installdhcpdconf");
        if ($wasrunning || isset($_POST['enablenetboot'])) {
            suExec("setnbimages " . $nbi);
        }
        $conf->setSetting("netbootimage", $nbi);
    }
}
if (isset($_POST['disablenetboot'])) {
    suExec("disablenetboot");
}
if (isset($_POST['addsubnet']) && isset($_POST['subnet']) && isset($_POST['netmask']) && isValidIPAddress($_POST['subnet']) && isValidNetmask($_POST['netmask']) && !isLoopbackAddress($_POST['subnet'])) {
    $conf->addSubnet(getNetAddress($_POST['subnet'], $_POST['netmask']), $_POST['netmask']);
    // 	echo "<script type=\"text/javascript\">\nchangeServiceType('NetBoot');\n</script>\n";
    $nbconf = file_get_contents("/var/appliance/conf/dhcpd.conf");
    $nbsubnets = "";
    foreach ($conf->getSubnets() as $key => $value) {
        $nbsubnets .= "subnet " . $value['subnet'] . " netmask " . $value['netmask'] . " {\n\tallow unknown-clients;\n}\n\n";
    }
    $nbconf = str_replace("##SUBNETS##", $nbsubnets, $nbconf);
    suExec("touchconf \"/var/appliance/conf/dhcpd.conf.new\"");
    if (file_put_contents("/var/appliance/conf/dhcpd.conf.new", $nbconf) === FALSE) {
        echo "<div class=\"errorMessage\">ERROR: Unable to update dhcpd.conf</div>";
    }
    $wasrunning = getNetBootStatus();
    if ($wasrunning) {
        suExec("disablenetboot");
Esempio n. 2
0
include "inc/config.php";
include "inc/auth.php";
include "inc/functions.php";
$title = "Network";
include "inc/header.php";
//Save the new network settings if the "SaveNetwork" button was clicked
if (isset($_POST['SaveNetwork'])) {
    if (isset($_POST['hostname']) && isValidHostname($_POST['hostname'])) {
        setHostName($_POST['hostname']);
    }
    if (isset($_POST['nettype'])) {
        $type = $_POST['nettype'];
        if ($type == "dhcp") {
            suExec("setdhcp");
        } else {
            if (isValidIPAddress($_POST['ip']) && !isLoopbackAddress($_POST['ip']) && getNetAddress($_POST['ip'], $_POST['netmask']) != $_POST['ip'] && getBcastAddress($_POST['ip'], $_POST['netmask']) != $_POST['ip'] && isValidNetmask($_POST['netmask']) && isValidIPAddress($_POST['gateway']) && !isLoopbackAddress($_POST['gateway']) && getNetAddress($_POST['gateway'], $_POST['netmask']) != $_POST['gateway'] && getBcastAddress($_POST['gateway'], $_POST['netmask']) != $_POST['gateway'] && $_POST['gateway'] != $_POST['ip'] && isValidIPAddress($_POST['dns1']) && (isValidIPAddress($_POST['dns2']) || $_POST['dns2'] == "")) {
                //address netmask gateway
                suExec("setip " . $_POST['ip'] . " " . $_POST['netmask'] . " " . $_POST['gateway']);
                suExec("setdns " . $_POST['dns1'] . " " . $_POST['dns2']);
            }
        }
        echo "<div class=\"alert alert-success\">Configuration saved.</div>";
    }
}
if (isset($_POST['SSH'])) {
    if (getSSHstatus()) {
        suExec("disableSSH");
        echo "<div class=\"alert alert-warning\">SSH Disabled.</div>";
    } else {
        suExec("enableSSH");
        echo "<div class=\"alert alert-success\">SSH Enabled.</div>";