示例#1
0
function DNS_SERVERS_SAVE(){
	$resolv=new resolv_conf();
	
	while (list ($num, $val) = each ($_POST) ){
		$resolv->MainArray[$num]=$val;
		
	}
	
	$resolv->save();
	$sock=new sockets();
	$sock->getFrameWork("services.php?resolvConf=yes");
	
}
示例#2
0
function checkParams()
{
    progress_logs(5, "{apply_settings}", "Checks settings..");
    $sock = new sockets();
    $array = unserialize(base64_decode($sock->GET_INFO("KerbAuthInfos")));
    if ($array["WINDOWS_DNS_SUFFIX"] == null) {
        progress_logs(20, "{apply_settings}", "Auth Winbindd, misconfiguration failed WINDOWS_DNS_SUFFIX = NULL");
        return false;
    }
    if ($array["WINDOWS_SERVER_NETBIOSNAME"] == null) {
        progress_logs(20, "{apply_settings}", "Auth Winbindd, misconfiguration failed WINDOWS_SERVER_NETBIOSNAME = NULL");
        return false;
    }
    if ($array["WINDOWS_SERVER_TYPE"] == null) {
        progress_logs(20, "{apply_settings}", "Auth Winbindd, misconfiguration failed WINDOWS_SERVER_TYPE = NULL");
        return false;
    }
    if ($array["WINDOWS_SERVER_ADMIN"] == null) {
        progress_logs(20, "{apply_settings}", "Auth Winbindd, misconfiguration failed WINDOWS_SERVER_ADMIN = NULL");
        return false;
    }
    if ($array["WINDOWS_SERVER_PASS"] == null) {
        progress_logs(20, "{apply_settings}", "Auth Winbindd, misconfiguration failed WINDOWS_SERVER_PASS = NULL");
        return false;
    }
    $ADNETIPADDR = $array["ADNETIPADDR"];
    $UseADAsNameServer = $sock->GET_INFO("UseADAsNameServer");
    if (!$UseADAsNameServer) {
        $UseADAsNameServer = 0;
    }
    if ($UseADAsNameServer == 1) {
        $resolve = new resolv_conf();
        progress_logs(20, "{apply_settings}", "Auth Winbindd, SET {$ADNETIPADDR} as 1st DNS in line " . __LINE__);
        $resolve->MainArray["DNS1"] = $ADNETIPADDR;
        progress_logs(20, "{apply_settings}", "Auth Winbindd, Building configuration " . __LINE__);
        $REX = $resolve->build();
        progress_logs(20, "{apply_settings}", "Auth Winbindd, saving /etc/resolv.conf " . __LINE__);
        @file_put_contents("/etc/resolv.conf", $resolve->build());
        progress_logs(20, "{apply_settings}", "Auth Winbindd, saving new configuration " . __LINE__);
        $resolve->save();
    }
    $hostname = strtolower(trim($array["WINDOWS_SERVER_NETBIOSNAME"])) . "." . strtolower(trim($array["WINDOWS_DNS_SUFFIX"]));
    progress_logs(20, "{apply_settings}", "Trying to resolve host {$hostname} ...." . __LINE__);
    $ip = gethostbyname($hostname);
    progress_logs(20, "{apply_settings}", "host {$hostname} = {$ip}...." . __LINE__);
    if ($ip == $hostname) {
        progress_logs(7, "{apply_settings}", "!!!!! {$ip} gethostbyname({$hostname}) failed !!!!!");
        return false;
    }
    progress_logs(7, "{apply_settings}", "Checks settings success..");
    return true;
}
示例#3
0
function popup_dns_save()
{
    $resolv = new resolv_conf();
    $resolv->MainArray["DNS1"] = $_POST["DNS1"];
    $resolv->MainArray["DNS2"] = $_POST["DNS2"];
    $resolv->save();
    $sock = new sockets();
    $sock->SET_INFO("myhostname", $_POST["hostname"]);
    $sock->getFrameWork("cmd.php?ChangeHostName={$_POST["hostname"]}");
    $sock->getFrameWork("services.php?resolvConf=yes");
}
示例#4
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"]);
}
示例#5
0
function savedns()
{
    $DNS1 = @file_get_contents("/etc/artica-postfix/WIZARDMASK_DNS1");
    $DNS2 = @file_get_contents("/etc/artica-postfix/WIZARDMASK_DNS2");
    $resolv = new resolv_conf();
    echo "92%] Set DNS to {$DNS1} - {$DNS2}\n";
    $resolv->MainArray["DNS1"] = $DNS1;
    $resolv->MainArray["DNS2"] = $DNS1;
    $resolv->output = true;
    echo "93%] Saving config\n";
    $resolvDatas = $resolv->build();
    echo "94%] Saving /etc/resolv.conf\n";
    @file_put_contents("/etc/resolv.conf", $resolvDatas);
    echo "###################################################\n";
    echo "############                          #############\n";
    echo "############         SUCCESS          #############\n";
    echo "############                          #############\n";
    echo "###################################################\n\n\n\n";
}
示例#6
0
function resolvconf()
{
    $resolv = new resolv_conf();
    $resolvDatas = $resolv->build();
    @file_put_contents("/etc/resolv.conf", $resolvDatas);
    if (is_dir("/var/spool/postfix/etc")) {
        @file_put_contents("/var/spool/postfix/etc/resolv.conf", $resolvDatas);
    }
    if (is_dir("/etc/resolvconf")) {
        @mkdir("/etc/resolvconf/resolv.conf.d", 0755, true);
        $f = array();
        if ($resolv->MainArray["DNS1"] != null) {
            $f[] = "nameserver {$resolv->MainArray["DNS1"]}";
        }
        if ($resolv->MainArray["DNS2"] != null) {
            $f[] = "nameserver {$resolv->MainArray["DNS2"]}";
        }
        if ($resolv->MainArray["DNS3"] != null) {
            $f[] = "nameserver {$resolv->MainArray["DNS3"]}";
        }
        if (count($f) > 0) {
            @file_put_contents("/etc/resolvconf/resolv.conf.d/base", @implode("\n", $f));
        }
    }
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    shell_exec("{$nohup} {$php5} " . dirname(__FILE__) . "/exec.dnsmasq.php --build >/dev/null 2>&1 &");
}
示例#7
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");
}
function ACTION_NETWORK()
{
    $unix = new unix();
    $clear = $unix->find_program("clear");
    if (is_file($clear)) {
        system("{$clear}");
    }
    $users = new usersMenus();
    $q = new mysql();
    if (!$q->BD_CONNECT(true)) {
        echo "There is an issue while connecting to MySQL\n{$q->mysql_error}\nPress Key to exit.\n";
        $line = fgets(STDIN);
        return;
    }
    $DEFAULT = null;
    $net = new networking();
    $interfaces = $net->Local_interfaces();
    unset($interfaces["lo"]);
    if (isset($interfaces["eth0"])) {
        $DEFAULT = "eth0";
    }
    while (list($num, $letter) = each($interfaces)) {
        $int[] = "\"{$num}\"";
    }
    if ($DEFAULT == null) {
        $DEFAULT = $int[0];
    }
    $q->BuildTables();
    echo "This wizard will help to configure network.\n";
    echo "Press q letter to exit or any key to continue:";
    $answer = trim(strtolower(fgets(STDIN)));
    if ($answer == "q") {
        return;
    }
    if (is_file($clear)) {
        system("{$clear}");
    }
    echo "Give here the interface name of the network interface\n";
    echo "you need to setup.\n\n";
    echo "Should be one of :" . @implode(", ", $int) . "\n";
    echo "Default: [{$DEFAULT}]\n";
    $NIC = trim(strtolower(fgets(STDIN)));
    if ($NIC == null) {
        $NIC = $DEFAULT;
    }
    if (!preg_match("#([a-z])([0-9+)\$#", $NIC)) {
        $NIC = $DEFAULT;
    }
    $ETH_IP = trim(ASK_ETH_IP($NIC));
    $GATEWAY = trim(ASK_GATEWAY($NIC));
    $NETMASK = trim(ASK_NETMASK($NIC));
    $DNS = trim(ASK_DNS1($NIC));
    if (is_file($clear)) {
        system("{$clear}");
    }
    echo "Your Settings:\n";
    echo "Interface.........: \"{$NIC}\"\n";
    echo "IP address........: \"{$ETH_IP}\"\n";
    echo "Gateway...........: \"{$GATEWAY}\"\n";
    echo "Netmask...........: \"{$NETMASK}\"\n";
    echo "DNS server 1......: \"{$DNS}\"\n";
    echo "\n";
    //ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);ini_set('error_append_string',null);
    echo "If your are agree with these settings\n";
    echo "Press any key to apply settings or press \"q\" to return to menu.\n";
    $answer = trim(strtolower(fgets(STDIN)));
    if ($answer == "q") {
        return;
    }
    echo "5%] Please Wait, saving configuration...\n";
    $nics = new system_nic($NIC);
    $nics->eth = $NIC;
    $nics->IPADDR = $ETH_IP;
    $nics->NETMASK = $NETMASK;
    $nics->GATEWAY = $GATEWAY;
    $nics->DNS1 = $DNS;
    $nics->dhcp = 0;
    $nics->metric = 1;
    $nics->defaultroute = 1;
    $nics->enabled = 1;
    echo "7%] Please Wait, saving Networks parameters to MySQL DB...\n";
    if (!$nics->SaveNic()) {
        echo "There is an issue while saving your settings\n";
        echo "Press any key to exit.\n";
        $answer = trim(strtolower(fgets(STDIN)));
        return;
    }
    echo "10%] Please Wait, building configuration....\n";
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $php5 = $php;
    shell_exec2("{$php5} " . dirname(__FILE__) . " /exec.virtuals-ip.php --build --force >/dev/null 2>&1");
    echo "20%] Please Wait, apply network configuration....\n";
    shell_exec2("{$php5} /usr/share/artica-postfix/exec.initslapd.php");
    shell_exec2("/etc/init.d/artica-ifup start");
    echo "30%] Please Wait, restarting services....\n";
    $unix->THREAD_COMMAND_SET("{$php5} /usr/share/artica-postfix/exec.postfix.maincf.php --reconfigure");
    $unix->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --reconfigure-cyrus");
    shell_exec2("{$nohup} /etc/init.d/artica-status reload >/dev/null 2>&1 &");
    shell_exec2("{$nohup} /etc/init.d/nginx restart >/dev/null 2>&1 &");
    shell_exec2("{$nohup} /etc/init.d/monit restart >/dev/null 2>&1 &");
    echo "30%] Please Wait, Changing IP address to {$NIC}....\n";
    $ifconfig = $unix->find_program("ifconfig");
    shell_exec2("{$ifconfig} {$NIC} down");
    shell_exec2("{$ifconfig} {$NIC} {$ETH_IP} netmask {$NETMASK} up");
    shell_exec2("/bin/ip route add 127.0.0.1 dev lo");
    if ($GATEWAY != "0.0.0.0") {
        echo "31%] Please Wait, Define default gateway to {$GATEWAY}....\n";
        shell_exec2("/sbin/route add {$GATEWAY} dev {$NIC}");
        $route = $unix->find_program("route");
        shell_exec("{$route} add -net 0.0.0.0 gw {$GATEWAY} dev {$NIC} metric 1");
    }
    echo "80%] Please Wait, Changing DNS to {$DNS}....\n";
    echo "81%] Please Wait, Loading DNS library\n";
    $GLOBALS["PROGRESS"] = true;
    $resolv = new resolv_conf();
    echo "92%] Set DNS1 to {$DNS}\n";
    $resolv->MainArray["DNS1"] = $DNS;
    $resolv->output = true;
    echo "93%] Saving config\n";
    $resolvDatas = $resolv->build();
    echo "94%] Saving /etc/resolv.conf\n";
    @file_put_contents("/etc/resolv.conf", $resolvDatas);
    echo "95%] Restarting Web Console\n";
    shell_exec2("{$nohup} /etc/init.d/artica-webconsole restart");
    echo "100%] Configuration done.\n";
    echo "Press any key to return to menu.";
    $answer = trim(strtolower(fgets(STDIN)));
    MAIN_MENU();
}
示例#9
0
function setup_3()
{
    $GLOBALS["DEBUG_TEMPLATE"] = true;
    include_once dirname(__FILE__) . "/ressources/class.langages.inc";
    $langAutodetect = new articaLang();
    $DetectedLanguage = $langAutodetect->get_languages();
    $GLOBALS["FIXED_LANGUAGE"] = $DetectedLanguage;
    $tpl = new templates();
    $page = CurrentPageName();
    $users = new usersMenus();
    $sock = new sockets();
    $savedsettings = unserialize(base64_decode($_GET["savedsettings"]));
    $users = new usersMenus();
    $sock = new sockets();
    $EnableUfdbGuard = $sock->GET_INFO("EnableUfdbGuard");
    if ($EnableUfdbGuard != $savedsettings["EnableWebFiltering"]) {
        $savedsettings["EnableWebFiltering"] = $EnableUfdbGuard;
    }
    $please_fill_all_form_values = $tpl->javascript_parse_text("{please_fill_all_form_values}");
    $organization = $savedsettings["organization"];
    $employees = $savedsettings["employees"];
    $company_name = $savedsettings["company_name"];
    $country = $savedsettings["country"];
    $city = $savedsettings["city"];
    $mail = $savedsettings["mail"];
    $telephone = $savedsettings["telephone"];
    $UseServerV = $savedsettings["UseServer"];
    $smtp_domainname = $savedsettings["smtp_domainname"];
    $company_www = $savedsettings["company_www"];
    $GoldKey = $savedsettings["GoldKey"];
    $KEEPNET = $savedsettings["KEEPNET"];
    if (!is_numeric($KEEPNET)) {
        $KEEPNET = 0;
    }
    $t = time();
    $MBX = false;
    $Postfix = false;
    $Samba = false;
    $squid_installed = false;
    $nginx_installed = false;
    $UseServer[null] = "{select}";
    if ($users->POSTFIX_INSTALLED) {
        $Postfix = true;
    }
    if ($users->ZARAFA_INSTALLED) {
        $MBX = true;
    }
    if ($users->cyrus_imapd_installed) {
        $MBX = true;
    }
    if ($MBX) {
        $UseServer["ASMAIL"] = "{mail_server}";
    }
    if ($users->SAMBA_INSTALLED) {
        $Samba = true;
    }
    if ($users->SQUID_INSTALLED) {
        $squid_installed = true;
    }
    if ($users->NGINX_INSTALLED) {
        $nginx_installed = true;
    }
    if ($Postfix) {
        $UseServer["ASRELAY"] = "{relay_server}";
    }
    if ($Samba) {
        $UseServer["ASFILE"] = "{file_server}";
    }
    if ($squid_installed) {
        $UseServer["ASPROXY"] = "{proxy_server}";
    }
    if ($nginx_installed) {
        $UseServer["ASREVERSEPROXY"] = "{reverse_proxy_server}";
    }
    $UseServer["AS_WORDPRESS"] = "Wordpress appliance";
    $netbiosname = $savedsettings["netbiosname"];
    $domainname = $savedsettings["domain"];
    $arrayNameServers[0] = $savedsettings["DNS1"];
    $arrayNameServers[1] = $savedsettings["DNS2"];
    $page = CurrentPageName();
    $tpl = new templates();
    if ($KEEPNET == 0) {
        $resolv = new resolv_conf();
        $resolv->MainArray["DNS1"] = $arrayNameServers[0];
        $resolv->MainArray["DNS2"] = $arrayNameServers[1];
        $resolv->save();
    }
    if ($KEEPNET == 0) {
        if ($_POST["IPADDR"] != null) {
            $nics = new system_nic("eth0");
            $nics->eth = "ethO";
            $nics->IPADDR = $arrayNameServers["IPADDR"];
            $nics->NETMASK = $arrayNameServers["NETMASK"];
            $nics->GATEWAY = $arrayNameServers["GATEWAY"];
            $nics->BROADCAST = $arrayNameServers["BROADCAST"];
            $nics->DNS1 = $arrayNameServers[0];
            $nics->DNS2 = $arrayNameServers[1];
            $nics->dhcp = 0;
            $nics->metric = $savedsettings["metric"];
            $nics->enabled = 1;
            $nics->NoReboot = true;
            $nics->SaveNic();
        }
    }
    $UseServerF = Field_array_Hash($UseServer, "UseServer", $UseServerV, "style:font-size:25px");
    $UseServerFF = "\t\n\t</tr>\n\t\t<td class=legend style='font-size:25px'>{you_using_this_server_for}:</td>\n\t\t<td>{$UseServerF}</td>\n\t</tr>";
    if ($users->WORDPRESS_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Wordpress Appliance'>";
    }
    if ($users->SMTP_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='SMTP Relay Appliance'>";
    }
    if ($users->KASPERSKY_WEB_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Kaspersky Web Appliance'>";
    }
    if ($users->LOAD_BALANCE_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Load balance Appliance'>";
    }
    if ($users->ZARAFA_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Zarafa Appliance'>";
    }
    if ($users->SAMBA_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='File Sharing Appliance'>";
    }
    if ($users->WEBSTATS_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Web statistics Appliance'>";
    }
    if ($users->STATS_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Statistics Appliance'>";
    }
    if ($users->KASPERSKY_SMTP_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Kaspersky SMTP Appliance'>";
    }
    if ($users->APACHE_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Apache Appliance'>";
    }
    if ($users->SQUID_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Proxy Appliance'>";
    }
    if ($users->HAPRROXY_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Load balance Appliance'>";
    }
    if ($users->FULL_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Artica Full Appliance'>";
    }
    if ($users->MYCOSI_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='MyCOSI Appliance'>";
    }
    if ($users->CYRUS_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='IMAP-POP3 OpenSource Appliance'>";
    }
    if ($users->PROXYTINY_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Tiny Proxy Appliance'>";
    }
    if ($users->SQUID_REVERSE_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Reverse Proxy Appliance' >";
    }
    if ($users->GATEWAY_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Gateway Appliance' >";
    }
    if ($users->WORDPRESS_APPLIANCE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Wordpress Appliance' >";
    }
    if ($users->WEBSECURIZE) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='WebSecurize Appliance' >";
    }
    if ($users->BAMSIGHT) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='BamSight' >";
    }
    if ($users->LANWANSAT) {
        $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='LANWANSAT Appliance' >";
    }
    //toujours à la fin...
    if ($UseServerFF == null) {
        if ($users->FROM_SETUP) {
            $UseServerFF = "<input type='hidden' id='UseServer' name='UseServer' value='Installed from Setup'>";
        }
    }
    $noticeregisterform = "<div style='font-size:11px;text-align:right'>{noticeregisterform}</div>";
    if ($users->WEBSECURIZE) {
        $noticeregisterform = null;
    }
    if ($users->LANWANSAT) {
        $noticeregisterform = null;
    }
    if ($users->BAMSIGHT) {
        $noticeregisterform = null;
    }
    $company_name_txtjs = $tpl->javascript_parse_text("{company_name}");
    $FORM = "\n\t<div style='width:98%' class=form>\n\t<table style='width:100%' id='{$t}'>\n\t\n\t<tr>\n\t\t<td colspan=2 style='font-size:50px;font-weight:bolder'>{YourRealCompany}</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:25px'>{gold_license}:</td>\n\t\t<td>" . Field_text("GoldKey", $GoldKey, "font-size:25px;width:440px") . "</td>\n\t</tr>\n\t\t<tr><td colspan=2 align='right'><i>{gold_license_explain}</i></td></tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:25px'>{company_name}:</td>\n\t\t<td>" . Field_text("company_name", $company_name, "font-size:25px;width:440px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:25px'>{company_website}:</td>\n\t\t<td>" . Field_text("company_www", $company_www, "font-size:25px;width:440px") . "</td>\n\t</tr>\t\t\t\t\n\t</tr>\n\t\t<td class=legend style='font-size:25px'>{country}:</td>\n\t\t<td>" . Field_text("country", $country, "font-size:25px;width:440px") . "</td>\n\t</tr>\n\t</tr>\n\t\t<td class=legend style='font-size:25px'>{city}:</td>\n\t\t<td>" . Field_text("city", $city, "font-size:25px;width:440px") . "</td>\n\t</tr>\n\t\t\t\t\t\n\t</tr>\n\t\t<td class=legend style='font-size:25px'>{your_email_address}:</td>\n\t\t<td>" . Field_text("mail", $mail, "font-size:25px;width:440px") . "</td>\n\t</tr>\t\n\t</tr>\n\t\t<td class=legend style='font-size:25px'>{phone_title}:</td>\n\t\t<td>" . Field_text("telephone", $telephone, "font-size:25px;width:440px") . "</td>\n\t</tr>\n\t</tr>\n\t\t<td class=legend style='font-size:25px'>{nb_employees}</td>\n\t\t<td>" . Field_text("employees", $employees, "font-size:25px;width:440px") . "</td>\n\t</tr>\n\n\t{$UseServerFF}\n\t\n\t<tr>\n\t\t<td colspan=2 style='font-size:25px;font-weight:bolder'>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=2 style='font-size:50px;font-weight:bolder'>{virtual_company}</div></td>\n\t</tr>\t\n\t</tr>\n\t\t<td class=legend style='font-size:25px'>{organization}:</td>\n\t\t<td>" . Field_text("organization", $organization, "font-size:25px;width:440px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:25px'>{domain}:</td>\n\t\t<td>" . Field_text("smtp_domainname", $smtp_domainname, "font-size:25px;width:440px", null, null, null, false, "CheckMyForm{$t}(event)") . "</td>\n\t</tr>\t\n\t\t<tr>\n\t\t<td colspan=2 style='font-size:25px;font-weight:bolder'>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td style='font-size:16px;font-weight:bolder'><div style='text-align:left'>" . button("{back}", "LoadAjax('setup-content','{$page}?setup-2=yes&savedsettings={$_GET["savedsettings"]}')", "30px") . "</div></td>\n\t\t<td style='font-size:16px;font-weight:bolder'><div style='text-align:right'>" . button("{next}", "ChangeCompanySettings()", "30px") . "</div></td>\n\t</tr>\n\t</table>\n\t{$noticeregisterform}\n\t\n\t<script>\n\t\tvar X_ChangeCompanySettings= function (obj) {\n\t\t\tUnlockPage();\n\t\t\tvar results=obj.responseText;\n\t\t\tvar KEEPNET={$KEEPNET};\n\t\t\tif(KEEPNET==0){\n\t\t\t\tLoadAjax('setup-content','{$page}?setup-4=yes&savedsettings='+results);\n\t\t\t}else{\n\t\t\t\tLoadAjax('setup-content','{$page}?setup-5=yes&savedsettings='+results);\n\t\t\t}\n\t\t\n\t\t\t}\n\t\t\n\t\t\t\n\t\tfunction CheckMyForm{$t}(e){\n\t\t\tif(!checkEnter(e)){return;}\n\t\t}\n\t\t\n\t\tfunction ChangeCompanySettings(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tvar testval=document.getElementById('company_name').value;\n\t\t\tif(testval.length==0){alert('{$please_fill_all_form_values}: {$company_name_txtjs}');return;}\n\t\t\tvar testval=document.getElementById('country').value;\n\t\t\tif(testval.length==0){alert('{$please_fill_all_form_values}');return;}\n\t\t\tvar testval=document.getElementById('city').value;\n\t\t\tif(testval.length==0){alert('{$please_fill_all_form_values}');return;}\t\t\t\t\t\t\n\t\t\tvar testval=document.getElementById('mail').value;\n\t\t\tif(testval.length==0){alert('{$please_fill_all_form_values} - mail');return;}\n\t\t\tvar testval=document.getElementById('employees').value;\n\t\t\tif(testval.length==0){alert('{$please_fill_all_form_values}');return;}\n\t\t\tvar testval=document.getElementById('organization').value;\n\t\t\tif(testval.length==0){alert('{$please_fill_all_form_values}');return;}\n\t\t\tvar testval=document.getElementById('smtp_domainname').value;\n\t\t\tif(testval.length==0){alert('{$please_fill_all_form_values}');return;}\t\t\t\n\t\t\t\n\t\t\tXHR.appendData('company_name',encodeURIComponent(document.getElementById('company_name').value));\n\t\t\tXHR.appendData('city',encodeURIComponent(document.getElementById('city').value));\n\t\t\tXHR.appendData('organization',encodeURIComponent(document.getElementById('organization').value));\n\t\t\tXHR.appendData('country',encodeURIComponent(document.getElementById('country').value));\n\t\t\tXHR.appendData('smtp_domainname',document.getElementById('smtp_domainname').value);\n\t\t\tXHR.appendData('organization',document.getElementById('organization').value);\n\t\t\tXHR.appendData('mail',document.getElementById('mail').value);\n\t\t\tXHR.appendData('telephone',document.getElementById('telephone').value);\n\t\t\tXHR.appendData('employees',document.getElementById('employees').value);\n\t\t\tXHR.appendData('company_www',document.getElementById('company_www').value);\n\t\t\tXHR.appendData('EnableWebFiltering','{$savedsettings["EnableWebFiltering"]}');\n\t\t\tXHR.appendData('GoldKey',document.getElementById('GoldKey').value);\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tXHR.appendData('savedsettings','{$_GET["savedsettings"]}');\n\t\t\tLockPage();\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',X_ChangeCompanySettings);\n\t\t\t\n\t\t}\n\tdocument.getElementById('content').style.height='930px';\n\t</script>\n\t\n\t";
    $html = "\n\t\n\t<div style='font-size:32px;font-weight:bolder;margin-bottom:50px'>{ContactAndOrganization}</div>{$FORM}\n\t\n\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
示例#10
0
function ResolvConfChecks()
{
    $unix = new unix();
    $sock = new sockets();
    $EnableDNSMASQ = $sock->GET_INFO("EnableDNSMASQ");
    if (!is_numeric($EnableDNSMASQ)) {
        $EnableDNSMASQ = 0;
    }
    $f = file("/etc/resolv.conf");
    $dnsmasqbin = $unix->find_program("dnsmasq");
    $configured = false;
    while (list($dir, $line) = each($f)) {
        if (preg_match("#^nameserver.+#", $line, $re)) {
            $configured = true;
        }
    }
    if ($configured) {
        return;
    }
    if (file_exists($dnsmasqbin)) {
        if ($EnableDNSMASQ == 0) {
            $resolv = new resolv_conf();
            $resolvConfBuild = $resolv->build();
            echo "Starting......: " . date("H:i:s") . " /etc/resolv.conf not configured, write it...\n";
            @file_put_contents("/etc/resolv.conf", $resolvConfBuild);
        }
        if ($EnableDNSMASQ == 1) {
            reset($f);
            $f[] = "nameserver 127.0.0.1";
            echo "Starting......: " . date("H:i:s") . " /etc/resolv.conf not configured, write it...\n";
            @file_put_contents("/etc/resolv.conf", $resolvConfBuild);
            reload_dnsmasq();
        }
    } else {
        $resolv = new resolv_conf();
        $resolvConfBuild = $resolv->build();
        echo "Starting......: " . date("H:i:s") . " /etc/resolv.conf not configured, write it...\n";
        @file_put_contents("/etc/resolv.conf", $resolvConfBuild);
    }
}