Пример #1
0
function settingsSave()
{
    include_once dirname(__FILE__) . "/ressources/externals/Net_DNS2/DNS2.php";
    include_once dirname(__FILE__) . "/ressources/class.resolv.conf.inc";
    $ipClass = new IP();
    $sock = new sockets();
    $users = new usersMenus();
    $tpl = new templates();
    include_once dirname(__FILE__) . "/ressources/class.html.tools.inc";
    $_POST["WINDOWS_SERVER_PASS"] = url_decode_special_tool($_POST["WINDOWS_SERVER_PASS"]);
    if (strpos($_POST["WINDOWS_SERVER_ADMIN"], "@") > 0) {
        $trx = explode("@", $_POST["WINDOWS_SERVER_ADMIN"]);
        $_POST["WINDOWS_SERVER_ADMIN"] = $trx[0];
    }
    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;
    }
    $_POST["WINDOWS_DNS_SUFFIX"] = trim(strtolower($_POST["WINDOWS_DNS_SUFFIX"]));
    if ($_POST["WINDOWS_DNS_SUFFIX"] == null) {
        echo "Please set the DNS domain of your Active Directory server";
        return;
    }
    $Myhostname = $sock->getFrameWork("cmd.php?full-hostname=yes");
    $MyhostnameTR = explode(".", $Myhostname);
    $MyNetbiosName = $MyhostnameTR[0];
    unset($MyhostnameTR[0]);
    $MyDomain = strtolower(@implode(".", $MyhostnameTR));
    if ($MyDomain != $_POST["WINDOWS_DNS_SUFFIX"]) {
        $nic = new system_nic();
        $nic->set_hostname("{$MyNetbiosName}.{$_POST["WINDOWS_DNS_SUFFIX"]}");
    }
    $adhost = "{$_POST["WINDOWS_SERVER_NETBIOSNAME"]}.{$_POST["WINDOWS_DNS_SUFFIX"]}";
    if (strtolower($adhost) == strtolower($Myhostname)) {
        echo "Active Directory: {$adhost} as the same name of this server:{$Myhostname}\n";
        return;
    }
    if ($_POST["ADNETIPADDR"] != null) {
        $ipaddrZ = explode(".", $_POST["ADNETIPADDR"]);
        while (list($num, $a) = each($ipaddrZ)) {
            $ipaddrZ[$num] = intval($a);
        }
        $_POST["ADNETIPADDR"] = @implode(".", $ipaddrZ);
    }
    $resolved = gethostbyname($adhost);
    if (!$ipClass->isValid($resolved)) {
        if ($ipClass->isValid($_POST["ADNETIPADDR"])) {
            $resolved = CheckDNS($adhost, $_POST["ADNETIPADDR"]);
            if ($ipClass->isValid($resolved)) {
                $_POST["UseADAsNameServer"] = 1;
            }
        }
    }
    $sock->SET_INFO("SambaBindInterface", $_POST["SambaBindInterface"]);
    $sock->SET_INFO("KerbAuthDisableNormalizeName", $_POST["KerbAuthDisableNormalizeName"]);
    $sock->SET_INFO("WindowsActiveDirectoryKerberos", $_POST["WindowsActiveDirectoryKerberos"]);
    $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"]);
    $sock->SET_INFO("UseADAsNameServer", $_POST["UseADAsNameServer"]);
    $sock->SET_INFO("NET_RPC_INFOS", base64_encode(serialize(array())));
    $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 ($_POST["UseADAsNameServer"] == 1) {
        $resolve = new resolv_conf();
        $resolve->MainArray["DNS1"] = $_POST["ADNETIPADDR"];
        $resolve->save();
        $resolved = CheckDNS($adhost, $_POST["ADNETIPADDR"]);
        if (!$ipClass->isValid($resolved)) {
            echo $tpl->javascript_parse_text("{error}: {unable_to_resolve} Active Directory: {$adhost} {with} {$_POST["ADNETIPADDR"]}", 1);
            return;
        }
    } else {
        $resolved = gethostbyname($adhost);
        if (!$ipClass->isValid($resolved)) {
            $tpl = new templates();
            if ($EnableWebProxyStatsAppliance == 0) {
                $sock->SET_INFO("EnableKerbAuth", 0);
            }
            $sock->SaveConfigFile(base64_encode(serialize($_POST)), "KerbAuthInfos");
            echo $tpl->javascript_parse_text("{error}: {unable_to_resolve} Active Directory: {$adhost}", 1);
            return;
        }
        if ($resolved == "127.0.0.1") {
            echo $tpl->javascript_parse_text("{error}: {$adhost} lookup to 127.0.0.1 !\n");
            return;
        }
    }
    if (strpos($_POST["ADNETBIOSDOMAIN"], ".") > 0) {
        echo "The netbios domain \"{$_POST["ADNETBIOSDOMAIN"]}\" is invalid.\n";
        $sock->SET_INFO("EnableKerbAuth", 0);
        return;
    }
    $sock->SET_INFO("EnableKerbAuth", $_POST["EnableKerbAuth"]);
}
Пример #2
0
function ChangeHostName(){
	
	$sock=new sockets();
	$tpl=new templates();
	$q=new mysql();
	
	$ERROR_NO_PRIVS=$tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
	$DisableNetworksManagement=$sock->GET_INFO("DisableNetworksManagement");
	if($DisableNetworksManagement==null){$DisableNetworksManagement=0;}	
	if($DisableNetworksManagement==1){echo $ERROR_NO_PRIVS;}
	
	
	$tpl=new templates();
	if($_GET["ChangeHostName"]=='null'){
		echo $tpl->_ENGINE_parse_body('{cancel}');
		return null;}
	$_GET["ChangeHostName"]=trim(strtolower($_GET["ChangeHostName"]));
	$t=explode(".",$_GET["ChangeHostName"]);
	if(count($t)==1){echo $tpl->_ENGINE_parse_body("{$_GET["ChangeHostName"]}: {not_an_fqdn}");return;}
	
	
	$nic=new system_nic();
	$nic->set_hostname($_GET["ChangeHostName"]);
}
Пример #3
0
function BUILD_NETWORK()
{
    $SUBNIC = null;
    $unix = new unix();
    $sock = new sockets();
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $savedsettings = unserialize(base64_decode(file_get_contents("/etc/artica-postfix/settings/Daemons/WizardSavedSettings")));
    $KEEPNET = $savedsettings["KEEPNET"];
    if ($KEEPNET == 1) {
        return;
    }
    $netbiosname = $savedsettings["netbiosname"];
    if (strlen($netbiosname) > 15) {
        $netbiosname = substr(0, 15, $netbiosname);
    }
    if (isset($savedsettings["domain"])) {
        $domainname = $savedsettings["domain"];
        $SEARCH_DOMAIN = $domainname;
    }
    $EnableKerbAuth = intval($sock->GET_INFO("EnableKerbAuth"));
    if ($EnableKerbAuth == 1) {
        $array = unserialize(base64_decode($sock->GET_INFO("KerbAuthInfos")));
        if (isset($array["WINDOWS_DNS_SUFFIX"])) {
            $SEARCH_DOMAIN = $array["WINDOWS_DNS_SUFFIX"];
            $domainname = $SEARCH_DOMAIN;
        }
    }
    $Encoded = base64_encode(serialize($savedsettings));
    @file_put_contents("/etc/artica-postfix/settings/Daemons/WizardSavedSettings", $Encoded);
    if (!isset($savedsettings["NIC"])) {
        $savedsettings["NIC"] = "eth0";
    }
    $NIC = $savedsettings["NIC"];
    if (preg_match("#(.+?):([0-9]+)#", $savedsettings["NIC"], $re)) {
        $NIC = trim($re[1]);
        $SUBNIC = $re[2];
    }
    writeprogress(60, "{building_networks}");
    $nics = new system_nic($NIC);
    $nics->CheckMySQLFields();
    $dhclient = $unix->find_program("dhclient");
    if (is_file($dhclient)) {
        $pid = $unix->PIDOF($dhclient);
        if ($unix->process_exists($pid)) {
            $unix->KILL_PROCESS($pid, 9);
        }
    }
    $nics->eth = $NIC;
    if ($SUBNIC != null) {
        $nics->IPADDR = "127.0.0.2";
        $nics->NETMASK = "255.255.255.255";
        $nics->GATEWAY = "0.0.0.0";
        $nics->BROADCAST = "0.0.0.0";
        $nics->DNS1 = $savedsettings["DNS1"];
        $nics->DNS2 = $savedsettings["DNS2"];
        $nics->dhcp = 0;
        $nics->metric = $savedsettings["metric"];
        $nics->enabled = 1;
        $nics->defaultroute = 1;
    } else {
        $nics->IPADDR = $savedsettings["IPADDR"];
        $nics->NETMASK = $savedsettings["NETMASK"];
        $nics->GATEWAY = $savedsettings["GATEWAY"];
        $nics->BROADCAST = $savedsettings["BROADCAST"];
        $nics->DNS1 = $savedsettings["DNS1"];
        $nics->DNS2 = $savedsettings["DNS2"];
        $nics->dhcp = 0;
        $nics->metric = $savedsettings["metric"];
        $nics->enabled = 1;
        $nics->defaultroute = 1;
    }
    writeprogress(60, "{saving_network}");
    $nics->SaveNic();
    if ($SUBNIC != null) {
        $q = new mysql();
        $sql = "INSERT INTO nics_virtuals (ID,nic,org,ipaddr,netmask,cdir,gateway,ForceGateway,failover,metric)\n\t\tVALUES('{$SUBNIC}','{$NIC}','','{$savedsettings["IPADDR"]}','{$savedsettings["NETMASK"]}',\n\t\t'','{$savedsettings["GATEWAY"]}',0,0,1);";
        $q->QUERY_SQL($sql, "artica_backup");
        $sql = "UPDATE nics_virtuals SET nic='{$NIC}',\n\t\torg='',\n\t\tipaddr='{$savedsettings["IPADDR"]}',\n\t\tnetmask='{$savedsettings["NETMASK"]}',\n\t\tcdir='',\n\t\t\t\tgateway='{$savedsettings["GATEWAY"]}',\n\t\t\t\tForceGateway='0',\n\t\t\t\tfailover='0',\n\t\t\t\tmetric='1'\n\t\t\t\tWHERE ID={$SUBNIC}";
        $q->QUERY_SQL($sql, "artica_backup");
    }
    writeprogress(60, "Loading resolv library");
    $resolv = new resolv_conf();
    $arrayNameServers[0] = $savedsettings["DNS1"];
    $arrayNameServers[1] = $savedsettings["DNS2"];
    $resolv->MainArray["DNS1"] = $arrayNameServers[0];
    $resolv->MainArray["DNS2"] = $arrayNameServers[1];
    $resolv->MainArray["DOMAINS1"] = $SEARCH_DOMAIN;
    writeprogress(60, "Saving DNS settings");
    $resolv->save();
    $nic = new system_nic();
    writeprogress(60, "{set_new_hostname} {$netbiosname}.{$domainname}");
    $nic->set_hostname("{$netbiosname}.{$domainname}");
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    writeprogress(60, "{building_resolv_configuration}");
    shell_exec(trim("{$nohup} " . $unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.virtuals-ip.php --resolvconf >/dev/null 2>&1"));
    writeprogress(60, "{building_networks_scripts}");
    shell_exec("{$php5} /usr/share/artica-postfix/exec.virtuals-ip.php >/dev/null 2>&1");
}