Example #1
0
function save()
{
    $eth = new system_nic($_POST["nic"]);
    $eth->FireQOS = $_POST["FireQOS"];
    $eth->InputSpeed = $_POST["InputSpeed"];
    $eth->OutputSpeed = $_POST["OutputSpeed"];
    $eth->ModemType = $_POST["ModemType"];
    $eth->SpeedUnit = $_POST["SpeedUnit"];
    $eth->SaveNic();
}
function qos_containers_tab()
{
    $tpl = new templates();
    $users = new usersMenus();
    $page = CurrentPageName();
    $fontsize = 18;
    $ID = $_GET["ID"];
    $q = new mysql();
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT eth FROM `qos_containers` WHERE ID='{$ID}'", "artica_backup"));
    $eth = $ligne["eth"];
    $p = new system_nic();
    $eth = $p->NicToOther($eth);
    $array["container-popup"] = "{Q.O.S} mark {$ID}";
    $array["container-status"] = "{status} {$eth}";
    $t = time();
    while (list($num, $ligne) = each($array)) {
        $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"{$page}?{$num}={$t}&ID={$ID}&eth={$eth}\" style='font-size:{$fontsize};font-weight:normal'><span>{$ligne}</span></a></li>\n");
    }
    $html = build_artica_tabs($html, 'main_qos_eth' . $eth) . "<script>// LeftDesign('qos-256-white.png');</script>";
    echo $html;
}
Example #3
0
function ipconfig_routes_del(){
	$user=new usersMenus();
	$tpl=new templates();
	$ERROR_NO_PRIVS=$tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
	if(!$user->AsSystemAdministrator){echo $ERROR_NO_PRIVS;return;}
	$ip=new networking();
	$nic=new system_nic($_GET["nic"]);
	unset($nic->ROUTES[$_GET["IP"]]);
	$nic->SaveNic();	
}
Example #4
0
function wizard_list_nic()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $sock = new sockets();
    $datas = unserialize(base64_decode($sock->getFrameWork("cmd.php?list-nics=yes")));
    $refresh = imgtootltip("refresh-24.png", "{refresh}", "WizardRefreshNics()");
    $html = "<center>\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t\t<th colspan=2 align='center' style='text-align:center'>{$refresh}</th>\n\t\t<th>{tcp_address}</td>\n\t\t<th>{netmask}</th>\n\t\t<th>{gateway}</th>\n\t\t<th>{mac_addr}</th>\n\t\t<th>DHCP</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>";
    $configured = true;
    while (list($num, $val) = each($datas)) {
        if (trim($val) == null) {
            continue;
        }
        writelogs("Found: {$val}", __FUNCTION__, __FILE__, __LINE__);
        $val = trim($val);
        if (preg_match('#master#', $val)) {
            continue;
        }
        if (preg_match("#^veth.+?#", $val)) {
            continue;
        }
        if (preg_match("#^tunl[0-9]+#", $val)) {
            continue;
        }
        if (preg_match("#^dummy[0-9]+#", $val)) {
            continue;
        }
        if (preg_match("#^gre[0-9]+#", $val)) {
            continue;
        }
        if (preg_match("#^ip6tnl[0-9]+#", $val)) {
            continue;
        }
        if (preg_match("#^sit[0-9]+#", $val)) {
            continue;
        }
        if (preg_match("#^vlan[0-9]+#", $val)) {
            continue;
        }
        $nicinfos = $sock->getFrameWork("cmd.php?nicstatus={$val}");
        $tbl = explode(";", $nicinfos);
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        if ($tbl[0] == null) {
            $tbl[0] = "{not_set}";
        }
        if ($tbl[1] == null) {
            $tbl[1] = "{not_set}";
        }
        if ($tbl[2] == null) {
            $tbl[2] = "{not_set}";
        }
        if ($tbl[4] == null) {
            $tbl[4] = "&nbsp;";
        }
        $js = "javascript:Loadjs('system.nic.edit.php?nic={$val}&button=confirm&noreboot=noreboot')";
        $href = "<a href=\"javascript:blur();\" OnClick=\"{$js}\" style='font-weight:bold;font-size:14px;text-decoration:underline'>";
        $nic = new system_nic($val);
        if (!$nic->IsConfigured()) {
            $configured = false;
            $img = imgtootltip("warning-panneau-32.png", "<b>{$val}:{$tbl[0]}</b><hr>{this_nic_is_not_configured_text}");
        } else {
            $img = imgtootltip("check-32.png", "<b>{$val}:{$tbl[0]}</b><hr>{this_nic_is_configured_text}");
        }
        if ($nic->dhcp == 1) {
            $dhcp = "{yes}";
            if (!preg_match("#[0-9\\.]+#", $tbl[0])) {
                $tbl[0] = "{automatic}";
            }
            $tbl[2] = "{automatic}";
            $tbl[4] = "{automatic}";
        } else {
            $dhcp = "{no}";
        }
        $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t\t<td style='font-weight:bold;font-size:14px' width=1%>{$href}{$val}</a></td>\n\t\t\t<td style='font-weight:bold;font-size:14px' width=1%>{$img}</a></td>\n\t\t\t<td style='font-weight:bold;font-size:14px'>{$href}{$tbl[0]}</a></td>\n\t\t\t<td style='font-weight:bold;font-size:14px'>{$href}{$tbl[2]}</a></td>\n\t\t\t<td style='font-weight:bold;font-size:14px'>{$href}{$tbl[4]}</a></td>\n\t\t\t<td style='font-weight:bold;font-size:14px'>{$href}{$tbl[1]}</a></td>\n\t\t\t<td style='font-weight:bold;font-size:14px'>{$href}{$dhcp}</a></td>\n\t\t</tr>\t\t\t\n\t\t";
    }
    $html = $html . "</tbody>\n\t</table>\n\t\n\t<script>\n\t\n\tvar x_ApplyNetSettingsWizard= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>3){alert(results);}\n\t\tWizardRefreshNics();\n\t}\t\n\t\n\tfunction ApplyNetSettingsWizard(){\n\t\tvar XHR = new XHRConnection();\n\t\tAnimateDiv('wizard-nic-list');\n\t\tXHR.appendData('ApplyNetSettingsWizard','1');\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_ApplyNetSettingsWizard);\t\n\t\n\t}\n\t</script>\n\t";
    if ($configured) {
        $html = $html . "<div class=explain style='font-size:14px'>{FIRST_WIZARD_NIC2}</div>\n\t\t<center>" . button("{SaveToDisk}", "ApplyNetSettingsWizard()", 18) . "</center>\n\t\t\n\t\t";
    }
    echo $tpl->_ENGINE_parse_body($html);
}
Example #5
0
function build_qos()
{
    $q = new mysql();
    $unix = new unix();
    $sock = new sockets();
    $tc = $unix->find_program("tc");
    if (!is_file($tc)) {
        return "# tc No such binary";
    }
    $F = array();
    $nic = new system_nic();
    $F[] = "# Remove rules on any interfaces";
    $results = $q->QUERY_SQL("SELECT Interface FROM nics ORDER BY Interface", "artica_backup");
    while ($ligne = mysql_fetch_assoc($results)) {
        $Interface = $ligne["Interface"];
        $Interface = $nic->NicToOther($Interface);
        $INT[$Interface] = $Interface;
    }
    while (list($Interface, $ligne) = each($INT)) {
        $F[] = "{$tc} qdisc del dev {$Interface} root";
    }
    $EnableQOS = intval($sock->GET_INFO("EnableQOS"));
    if ($EnableQOS == 0) {
        return @implode("\n", $F);
    }
    $results = $q->QUERY_SQL("SELECT Interface,QOSMAX FROM nics WHERE QOS=1 ORDER BY Interface", "artica_backup");
    if (mysql_num_rows($results) == 0) {
        return "# No interface defined for QOS";
    }
    $ID_ROOT = 0;
    $classid = 0;
    while ($ligne = mysql_fetch_assoc($results)) {
        $Interface = $ligne["Interface"];
        $results2 = $q->QUERY_SQL("SELECT * FROM qos_containers WHERE enabled=1 AND eth='{$Interface}' ORDER BY prio", "artica_backup");
        if (mysql_num_rows($results2) == 0) {
            $F[] = "# {$Interface} no container defined or enabled";
            continue;
        }
        $Interface = $nic->NicToOther($Interface);
        $F[] = "# *********** {$ligne["Interface"]} -> {$Interface} ***********";
        $ID_ROOT++;
        $classid++;
        $F[] = "# {$Interface} Capacity of {$ligne["QOSMAX"]}Mbits Level {$ID_ROOT}";
        $F[] = "{$tc} qdisc add dev {$Interface} root handle {$ID_ROOT}: htb default {$ID_ROOT}00";
        $F[] = "{$tc} class add dev {$Interface} parent {$ID_ROOT}:0 classid {$ID_ROOT}:{$classid} htb rate {$ligne["QOSMAX"]}Mbit ceil {$ligne["QOSMAX"]}Mbit";
        while ($ligne = mysql_fetch_assoc($results2)) {
            $id = $ligne["ID"];
            $gar = "{$ligne["rate"]}{$ligne["rate_unit"]}";
            $band = "{$ligne["ceil"]}{$ligne["ceil_unit"]}";
            if (intval($ligne["rate"]) == 0) {
                $F[] = "# {$Interface}: Container {$ligne["name"]} Guaranteed Rate invalid";
                continue;
            }
            if (intval($ligne["ceil"]) == 0) {
                $F[] = "# {$Interface}: Container {$ligne["name"]} Bandwidth invalid";
                continue;
            }
            $F[] = "# {$Interface}: Container {$ligne["name"]} Guaranteed Rate of {$gar} , Bandwidth of {$band} Level Prio {$ligne["prio"]}";
            $F[] = "{$tc} class add dev {$Interface} parent {$ID_ROOT}:{$classid} classid {$classid}:{$id} htb rate {$gar} ceil {$band}";
            $F[] = "# {$Interface}: Container {$ligne["name"]} add policy for mark {$id}";
            $F[] = "{$tc} filter add dev {$Interface} parent {$ID_ROOT}: protocol ip prio {$ligne["prio"]} handle {$id} fw flowid {$classid}:{$id}";
        }
    }
    return @implode("\n", $F);
}
Example #6
0
function savenic($NIC)
{
    $unix = new unix();
    $ipClass = new IP();
    $ETH_IP = trim(@file_get_contents("/etc/artica-postfix/WIZARDIP_{$NIC}"));
    $NETMASK = trim(@file_get_contents("/etc/artica-postfix/WIZARDMASK_{$NIC}"));
    $GATEWAY = trim(@file_get_contents("/etc/artica-postfix/WIZARDGATEWAY_{$NIC}"));
    if (!$ipClass->isIPAddress($ETH_IP)) {
        echo "* * * * {$ETH_IP} * * * * WRONG !!!!\n";
        @file_put_contents("/etc/artica-postfix/WIZARDRESULT_{$NIC}", 0);
        return;
    }
    if (!$ipClass->isIPAddress($GATEWAY)) {
        echo "* * * * {$GATEWAY} * * * * WRONG !!!!\n";
        @file_put_contents("/etc/artica-postfix/WIZARDRESULT_{$NIC}", 0);
        return;
    }
    $nics = new system_nic($NIC);
    $nics->eth = $NIC;
    $nics->IPADDR = $ETH_IP;
    $nics->NETMASK = $NETMASK;
    $nics->GATEWAY = $GATEWAY;
    $nics->dhcp = 0;
    $nics->metric = 1;
    $nics->defaultroute = 1;
    $nics->enabled = 1;
    if (!$nics->SaveNic()) {
        echo "* * * * MYSQL ERROR !!! * * * * WRONG !!!!\n";
        @file_put_contents("/etc/artica-postfix/WIZARDRESULT_{$NIC}", 0);
        return;
    }
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $php5 = $php;
    system("{$php5} " . dirname(__FILE__) . " /exec.virtuals-ip.php --build --force >/dev/null 2>&1");
    echo "20%] Please Wait, apply network configuration....\n";
    system("/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");
    system("{$nohup} /etc/init.d/artica-status reload >/dev/null 2>&1 &");
    system("{$nohup} /etc/init.d/nginx restart >/dev/null 2>&1 &");
    system("{$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");
    system("{$ifconfig} {$NIC} down");
    system("{$ifconfig} {$NIC} {$ETH_IP} netmask {$NETMASK} up");
    system("/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";
        system("/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 "95%] Restarting Web Console\n";
    system("/etc/init.d/artica-webconsole restart");
    echo "100%] Configuration done.\n";
    @file_put_contents("/etc/artica-postfix/WIZARDRESULT_{$NIC}", 1);
    echo "###################################################\n";
    echo "############                          #############\n";
    echo "############         SUCCESS          #############\n";
    echo "############                          #############\n";
    echo "###################################################\n\n\n\n";
}
Example #7
0
function isFW_save(){
	$eth=$_POST["eth"];
	
	if(preg_match("#^br([0-9]+)#", $eth,$re)){
		$q=new mysql();
		$q->QUERY_SQL("UPDATE `nics_bridge` SET 
		`isFW`='{$_POST["isFW"]}',
		`isFWLogBlocked`='{$_POST["isFWLogBlocked"]}',
		`isFWAcceptNet`='{$_POST["isFWAcceptNet"]}'		
		WHERE `ID`='{$re[1]}'","artica_backup");
		if(!$q->ok){echo $q->mysql_error;}
		return;
	}	
	
	
	$ethC=new system_nic($eth);
	$ethC->isFW=$_POST["isFW"];
	$ethC->isFWAcceptNet=$_POST["isFWAcceptNet"];
	$ethC->isFWLogBlocked=$_POST["isFWLogBlocked"];
	$ethC->SaveNic();
}
Example #8
0
function BuildNetWorksRedhat()
{
    echo "Starting......: Building networks mode RedHat\n";
    $nic = new system_nic();
    $datas = $nic->root_build_redhat_config();
    bridges_build();
    $unix = new unix();
    $unix->THREAD_COMMAND_SET($unix->LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.ip-rotator.php --build");
    if (!$GLOBALS["NO_GLOBAL_RELOAD"]) {
        $unix->NETWORK_REDHAT_RESTART();
    }
}
function isFW()
{
    $nic = new system_nic($_POST["nic"]);
    $nic->isFW = $_POST["isFW"];
    $nic->SaveNic();
}
Example #10
0
function popup()
{
    $tpl = new templates();
    $sock = new sockets();
    $page = CurrentPageName();
    $users = new usersMenus();
    $squid = new squidbee();
    $EnableArticaHotSpot = $sock->GET_INFO("EnableArticaHotSpot");
    $SquidHotSpotPort = intval($sock->GET_INFO("SquidHotSpotPort"));
    $ArticaHotSpotPort = intval($sock->GET_INFO("ArticaHotSpotPort"));
    $ArticaSSLHotSpotPort = $sock->GET_INFO("ArticaSSLHotSpotPort");
    $ArticaSplashHotSpotPort = $sock->GET_INFO("ArticaSplashHotSpotPort");
    $ArticaSplashHotSpotPortSSL = $sock->GET_INFO("ArticaSplashHotSpotPortSSL");
    $ArticaSplashHotSpotCertificate = $sock->GET_INFO("ArticaSplashHotSpotCertificate");
    $SquidHotSpotSSLPort = intval($sock->GET_INFO("SquidHotSpotSSLPort"));
    $WifiDogDebugLevel = intval($sock->GET_INFO("WifiDogDebugLevel"));
    $ArticaHotSpotInterface2 = $sock->GET_INFO("ArticaHotSpotInterface2");
    $WifidogClientTimeout = intval($sock->GET_INFO("WifidogClientTimeout"));
    if ($WifidogClientTimeout < 5) {
        $WifidogClientTimeout = 30;
    }
    $HospotHTTPServerName = trim($sock->GET_INFO("HospotHTTPServerName"));
    $HotSpotDenySSL = intval($sock->GET_INFO("HotSpotDenySSL"));
    $ArticaHotSpotInterface = $sock->GET_INFO("ArticaHotSpotInterface");
    if (!$users->CONNTRACK_INSTALLED) {
        echo FATAL_ERROR_SHOW_128("{conntrackd_not_installed}");
    }
    $WifiDogDebugLevelZ[null] = "{none}";
    for ($i = 0; $i < 11; $i++) {
        $WifiDogDebugLevelZ[$i] = $i;
    }
    $Timez[30] = "30 {minutes}";
    $Timez[60] = "1 {hour}";
    $Timez[120] = "2 {hours}";
    $Timez[180] = "3 {hours}";
    $Timez[360] = "6 {hours}";
    $Timez[720] = "12 {hours}";
    $Timez[1440] = "1 {day}";
    $Timez[2880] = "2 {days}";
    $Timez[10080] = "1 {week}";
    $Timez[20160] = "2 {weeks}";
    $Timez[40320] = "1 {month}";
    $ArticaHotSpotEnableMIT = $sock->GET_INFO("ArticaHotSpotEnableMIT");
    $ArticaHotSpotEnableProxy = $sock->GET_INFO("ArticaHotSpotEnableProxy");
    if (!is_numeric($ArticaHotSpotEnableMIT)) {
        $ArticaHotSpotEnableMIT = 1;
    }
    if (!is_numeric($ArticaHotSpotEnableProxy)) {
        $ArticaHotSpotEnableProxy = 1;
    }
    if (!is_numeric($ArticaHotSpotPort)) {
        $ArticaHotSpotPort = 0;
    }
    if (!is_numeric($ArticaSplashHotSpotPort)) {
        $ArticaSplashHotSpotPort = 16080;
    }
    if (!is_numeric($ArticaSplashHotSpotPortSSL)) {
        $ArticaSplashHotSpotPortSSL = 16443;
    }
    $Params = unserialize($sock->GET_INFO("HotSpotEvasive"));
    $ApacheEvasiveInstalled = intval($sock->GET_INFO("ApacheEvasiveInstalled"));
    if (!is_numeric($Params["DOSEnable"])) {
        $Params["DOSEnable"] = 1;
    }
    if (!is_numeric($Params["DOSHashTableSize"])) {
        $Params["DOSHashTableSize"] = 1024;
    }
    if (!is_numeric($Params["DOSPageCount"])) {
        $Params["DOSPageCount"] = 3;
    }
    if (!is_numeric($Params["DOSSiteCount"])) {
        $Params["DOSSiteCount"] = 20;
    }
    if (!is_numeric($Params["DOSPageInterval"])) {
        $Params["DOSPageInterval"] = 1;
    }
    if (!is_numeric($Params["DOSSiteInterval"])) {
        $Params["DOSSiteInterval"] = 10;
    }
    if (!is_numeric($Params["DOSBlockingPeriod"])) {
        $Params["DOSBlockingPeriod"] = 5;
    }
    $HotSpotErrorRedirect = $sock->GET_INFO("HotSpotErrorRedirect");
    $ArticaSplashHotSpotTitle = $sock->GET_INFO("ArticaSplashHotSpotTitle");
    if ($ArticaSplashHotSpotTitle == null) {
        $ArticaSplashHotSpotTitle = "HotSpot system";
    }
    if ($ArticaHotSpotPort == 0) {
        $ArticaHotSpotPort = rand(38000, 64000);
        $sock->SET_INFO("ArticaHotSpotPort", $ArticaHotSpotPort);
    }
    if ($ArticaSSLHotSpotPort == 0) {
        $ArticaSSLHotSpotPort = rand(38500, 64000);
        $sock->SET_INFO("ArticaSSLHotSpotPort", $ArticaSSLHotSpotPort);
    }
    if ($SquidHotSpotPort == 0) {
        $SquidHotSpotPort = rand(40000, 64000);
        $sock->SET_INFO("SquidHotSpotPort", $SquidHotSpotPort);
    }
    if ($SquidHotSpotSSLPort == 0) {
        $SquidHotSpotSSLPort = rand(40500, 64000);
        $sock->SET_INFO("SquidHotSpotSSLPort", $SquidHotSpotSSLPort);
    }
    $tcp = new networking();
    $interfacesZ = $tcp->Local_interfaces();
    while (list($interface, $line) = each($interfacesZ)) {
        $p = new system_nic($interface);
        if ($p->IsBridged($interface)) {
            continue;
        }
        $interfaces[$interface] = $p->NICNAME;
    }
    $HotSpotUseSSL = 1;
    $HospotNoSSL = intval($sock->GET_INFO("HospotNoSSL"));
    if ($HospotNoSSL == 1) {
        $HotSpotUseSSL = 0;
    }
    if ($HotSpotDenySSL == 1) {
        $HotSpotUseSSL = 0;
    }
    $interfaces[null] = "{none}";
    include_once dirname(__FILE__) . "/ressources/class.squid.reverse.inc";
    $squid_reverse = new squid_reverse();
    $sslcertificates = $squid_reverse->ssl_certificates_list();
    if ($HotSpotErrorRedirect == null) {
        $HotSpotErrorRedirect = "http://www.bing.com";
    }
    $t = time();
    $html = "\n\t\n\t\n\t<div id='{$t}' class=explain style='font-size:20px'>{HotSpot_text}<br>{HotSpot_infra_text}</div>\n\t<div style='width:98%' class=form>\n\t<table style='width:99%'>\n\t\n\t<tr>\n\t\t<td  style='font-size:42px' colspan=2>{sessions}:</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{session_time}", "{wifidog_disconnect_time}") . ":</td>\n\t\t<td>" . Field_array_Hash($Timez, "WifidogClientTimeout", $WifidogClientTimeout, "style:font-size:22px") . "</td>\n\t</tr>\t\t\n\t\n\t<tr>\n\t\t<td  style='font-size:42px' colspan>{service2}:</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{listen_port}:</td>\n\t\t<td>" . Field_text("ArticaHotSpotPort", $ArticaHotSpotPort, "font-size:22px;width:110px") . "</td>\n\t</tr>\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{interface} (IN):</td>\n\t\t<td>" . Field_array_Hash($interfaces, "ArticaHotSpotInterface", $ArticaHotSpotInterface, "style:font-size:22px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{interface} (OUT):</td>\n\t\t<td>" . Field_array_Hash($interfaces, "ArticaHotSpotInterface2", $ArticaHotSpotInterface2, "style:font-size:22px") . "</td>\n\t</tr>\n\t\t\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{log_level}:</td>\n\t\t<td>" . Field_array_Hash($WifiDogDebugLevelZ, "WifiDogDebugLevel", $WifiDogDebugLevel, "style:font-size:22px") . "</td>\n\t</tr>\t\t\t\t\n\t<tr>\n\t\t<td  style='font-size:42px' colspan=2>{webserver}:</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{HospotHTTPServerName}", "{HospotHTTPServerName_explain}") . ":</td>\n\t\t<td>" . Field_text("HospotHTTPServerName", $HospotHTTPServerName, "font-size:22px;width:300px") . "</td>\n\t</tr>\n\n\t<tr><td  style='font-size:42px' colspan=2>&nbsp;</td></tr>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{FreeWebsEnableModEvasive}", "{mod_evasive_explain}") . ":</td>\n\t\t<td style='font-size:22px'>" . Field_checkbox_design("DOSEnable", 1, $Params["DOSEnable"], "EvasiveDisabled()") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{DOSHashTableSize}", "{DOSHashTableSize_explain}") . ":</td>\n\t\t<td style='font-size:22px'>" . Field_text("DOSHashTableSize", $Params["DOSHashTableSize"], "font-size:22px;width:110px") . "&nbsp;MB</td>\n\t</tr>\t\n\t\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{threshold}", "{DOSPageCount_explain}") . ":</td>\n\t\t<td style='font-size:22px'>" . Field_text("DOSPageCount", $Params["DOSPageCount"], "font-size:22px;width:110px") . "</td>\n\t</tr>\n\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{total_threshold}", "{DOSSiteCount_explain}") . ":</td>\n\t\t<td style='font-size:22px'>" . Field_text("DOSSiteCount", $Params["DOSSiteCount"], "font-size:22px;width:110px") . "</td>\n\t</tr>\n\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{page_interval}", "{DOSPageInterval_explain}") . ":</td>\n\t\t<td style='font-size:22px'>" . Field_text("DOSPageInterval", $Params["DOSPageInterval"], "font-size:22px;width:110px") . "&nbsp;{seconds}</td>\n\t</tr>\t\n\t\n\n\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{site_interval}", "{DOSSiteInterval_explain}") . ":</td>\n\t\t<td style='font-size:22px'>" . Field_text("DOSSiteInterval", $Params["DOSSiteInterval"], "font-size:22px;width:110px") . "&nbsp;{seconds}</td>\n\t</tr>\n\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{Blocking_period}", "{DOSBlockingPeriod_explain}") . ":</td>\n\t\t<td style='font-size:22px'>" . Field_text("DOSBlockingPeriod", $Params["DOSBlockingPeriod"], "font-size:22px;width:110px") . "&nbsp;{seconds}</td>\n\t\t\n\t</tr>\n\t<tr><td  style='font-size:42px' colspan=2>&nbsp;</td></tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{listen_authentication_http_port}:</td>\n\t\t<td>" . Field_text("ArticaSplashHotSpotPort", $ArticaSplashHotSpotPort, "font-size:22px;width:110px") . "</td>\n\t</tr>\t\t\t\t\t\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{listen_authentication_https_port}:</td>\n\t\t<td>" . Field_text("ArticaSplashHotSpotPortSSL", $ArticaSplashHotSpotPortSSL, "font-size:22px;width:110px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{http_error_redirect}", "{wifidog_http_error_redirect_explain}") . ":</td>\n\t\t<td>" . Field_text("HotSpotErrorRedirect", $HotSpotErrorRedirect, "font-size:22px;width:400px") . "</td>\n\t</tr>\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{ssl_redirection}", "{wifidog_use_ssl_explain}") . ":</td>\n\t\t<td>" . Field_checkbox_design("HotSpotUseSSL", 1, $HotSpotUseSSL) . "</td>\n\t</tr>\t\t\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{deny_ssl}", "{wifidog_deny_ssl_explain}") . ":</td>\n\t\t<td>" . Field_checkbox_design("HotSpotDenySSL", 1, $HotSpotDenySSL) . "</td>\n\t</tr>\t\t\t\t\n\t\t\t\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:22px;'>{certificate}:</td>\n\t\t<td >" . Field_array_Hash($sslcertificates, "ArticaSplashHotSpotCertificate", $ArticaSplashHotSpotCertificate, null, null, 0, "font-size:22px") . "</td>\n\t</tr>\n<tr><td style='font-size:16px;text-align:right' colspan=2> " . texttooltip("{see} {certificates_center}", "position:right:{certificate_center_explain}", "GotoCertificatesCenter()") . "</td>\n</tr>\n\t\t\t\t\t\t\n\t<tr>\n\t\t<td  style='font-size:42px' colspan=2>Proxy:</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>" . texttooltip("{transparent_ssl}", "{wifidog_transparent_ssl_explain}") . ":</td>\n\t\t<td>" . Field_checkbox_design("ArticaHotSpotEnableMIT", 1, $ArticaHotSpotEnableMIT) . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>." . texttooltip("{transparent_http}", "{wifidog_transparent_http_explain}") . ":</td>\n\t\t<td>" . Field_checkbox_design("ArticaHotSpotEnableProxy", 1, $ArticaHotSpotEnableProxy) . "</td>\n\t</tr>\t\t\t\t\t\t\t\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{listen_proxy_http_port}:</td>\n\t\t<td>" . Field_text("SquidHotSpotPort", $SquidHotSpotPort, "font-size:22px;width:110px") . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{listen_proxy_https_port}:</td>\n\t\t<td>" . Field_text("SquidHotSpotSSLPort", $SquidHotSpotSSLPort, "font-size:22px;width:110px") . "</td>\n\t</tr>\t\t\t\t\t\n\n\t\t\t\t\t\t\n\t<tr>\n\t\t<td colspan=2 align='right'><hr>" . button("{apply}", "SaveHotSpot()", "42px") . "</td>\n\t</tr>\n\t</table>\n\t</div>\n\t<script>\n\tvar x_SaveHotSpot= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>3){alert(results);return;}\n\t\tLoadjs('squid.webauth.restart.php');\n\n\t}\n\n\nfunction SaveHotSpot(){\n\t\tvar XHR = new XHRConnection();\n\t\t\n\t\tXHR.appendData('ArticaHotSpotPort',document.getElementById('ArticaHotSpotPort').value);\n\t\tXHR.appendData('SquidHotSpotPort',document.getElementById('SquidHotSpotPort').value);\n\t\t\n\t\tXHR.appendData('ArticaSplashHotSpotPort',document.getElementById('ArticaSplashHotSpotPort').value);\n\t\tXHR.appendData('ArticaSplashHotSpotPortSSL',document.getElementById('ArticaSplashHotSpotPortSSL').value);\n\t\tXHR.appendData('ArticaHotSpotInterface',document.getElementById('ArticaHotSpotInterface').value);\n\t\tXHR.appendData('ArticaHotSpotInterface2',document.getElementById('ArticaHotSpotInterface2').value);\n\t\tXHR.appendData('HospotHTTPServerName',document.getElementById('HospotHTTPServerName').value);\n\t\t\n\t\tXHR.appendData('ArticaSplashHotSpotCertificate',document.getElementById('ArticaSplashHotSpotCertificate').value);\n\t\t\n\t\tXHR.appendData('WifiDogDebugLevel',document.getElementById('WifiDogDebugLevel').value);\n\t\tXHR.appendData('WifidogClientTimeout',document.getElementById('WifidogClientTimeout').value);\n\t\t\n\t\t\n\t\tif(document.getElementById('DOSEnable').checked){XHR.appendData('DOSEnable',1);}else{XHR.appendData('DOSEnable',0);}\n\t\tXHR.appendData('DOSHashTableSize',document.getElementById('DOSHashTableSize').value);\n\t\tXHR.appendData('DOSPageCount',document.getElementById('DOSPageCount').value);\n\t\tXHR.appendData('DOSSiteCount',document.getElementById('DOSSiteCount').value);\n\t\tXHR.appendData('DOSPageInterval',document.getElementById('DOSPageInterval').value);\n\t\tXHR.appendData('DOSSiteInterval',document.getElementById('DOSSiteInterval').value);\n\t\tXHR.appendData('DOSBlockingPeriod',document.getElementById('DOSBlockingPeriod').value);\n\t\t\n\t\t\n\t\tif(document.getElementById('ArticaHotSpotEnableMIT').checked){\n\t\t\tXHR.appendData('ArticaHotSpotEnableMIT',1);\n\t\t}else{\n\t\t\tXHR.appendData('ArticaHotSpotEnableMIT',0);\n\t\t}\n\t\tif(document.getElementById('HotSpotUseSSL').checked){\n\t\t\tXHR.appendData('HospotNoSSL',0);\n\t\t}else{\n\t\t\tXHR.appendData('HospotNoSSL',1);\n\t\t}\n\t\tif(document.getElementById('HotSpotDenySSL').checked){\n\t\t\tXHR.appendData('HotSpotDenySSL',1);\n\t\t}else{\n\t\t\tXHR.appendData('HotSpotDenySSL',0);\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\t\n\t\tif(document.getElementById('ArticaHotSpotEnableProxy').checked){\n\t\t\tXHR.appendData('ArticaHotSpotEnableProxy',1);\n\t\t}else{\n\t\t\tXHR.appendData('ArticaHotSpotEnableProxy',0);\n\t\t}\t\n\t\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_SaveHotSpot);\n\t}\t\n\n\t\n\t\n\tfunction EvasiveDisabled(){\n\t\tdocument.getElementById('DOSHashTableSize').disabled=true;\n\t\tdocument.getElementById('DOSPageCount').disabled=true;\n\t\tdocument.getElementById('DOSSiteCount').disabled=true;\n\t\tdocument.getElementById('DOSPageInterval').disabled=true;\n\t\tdocument.getElementById('DOSSiteInterval').disabled=true;\n\t\tdocument.getElementById('DOSBlockingPeriod').disabled=true;\n\t\t\n\t\tvar ApacheEvasiveInstalled={$ApacheEvasiveInstalled};\n\t\tif(ApacheEvasiveInstalled==0){\n\t\t\tdocument.getElementById('DOSEnable').checked=false;\n\t\t\tdocument.getElementById('DOSEnable').disabled=true;\n\t\t\treturn;\n\t\t}\n\t\n\t\tif(document.getElementById('DOSEnable').checked){\t\n\t\t\tdocument.getElementById('DOSHashTableSize').disabled=false;\n\t\t\tdocument.getElementById('DOSPageCount').disabled=false;\n\t\t\tdocument.getElementById('DOSSiteCount').disabled=false;\n\t\t\tdocument.getElementById('DOSPageInterval').disabled=false;\n\t\t\tdocument.getElementById('DOSSiteInterval').disabled=false;\n\t\t\tdocument.getElementById('DOSBlockingPeriod').disabled=false;\t\n\t\t\t}\t\t\n\t}\t\n\t\nEvasiveDisabled();\t\n\t</script>\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Example #11
0
function nic_params_save()
{
    $nic = new system_nic($_POST["nic"]);
    $nic->firewall_policy = $_POST["firewall_policy"];
    $nic->firewall_behavior = $_POST["firewall_behavior"];
    $nic->firewall_masquerade = $_POST["firewall_masquerade"];
    $nic->SaveNic();
}
Example #12
0
function start($aspid = false)
{
    $unix = new unix();
    $sock = new sockets();
    $Masterbin = $unix->find_program("arpd");
    if (!is_file($Masterbin)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, arpd not installed\n";
        }
        return;
    }
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $pid = PID_NUM();
    if ($unix->MEM_TOTAL_INSTALLEE() < 624288) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} not enough memory\n";
        }
        if ($unix->process_exists($pid)) {
            stop();
        }
        return;
    }
    if ($unix->process_exists($pid)) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started {$pid} since {$timepid}Mn...\n";
        }
        return;
    }
    $EnableArpDaemon = $sock->GET_INFO("EnableArpDaemon");
    $ArpdKernelLevel = $sock->GET_INFO("ArpdKernelLevel");
    if (!is_numeric($EnableArpDaemon)) {
        $EnableArpDaemon = 1;
    }
    if (!is_numeric($ArpdKernelLevel)) {
        $ArpdKernelLevel = 0;
    }
    if ($EnableArpDaemon == 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see EnableArpDaemon)\n";
        }
        return;
    }
    $php5 = $unix->LOCATE_PHP5_BIN();
    $sysctl = $unix->find_program("sysctl");
    $echo = $unix->find_program("echo");
    $nohup = $unix->find_program("nohup");
    if ($ArpdKernelLevel > 0) {
        $ArpdKernelLevel_string = " -a {$ArpdKernelLevel}";
    }
    $Interfaces = $unix->NETWORK_ALL_INTERFACES();
    $nic = new system_nic();
    while (list($Interface, $ligne) = each($Interfaces)) {
        if ($Interface == "lo") {
            continue;
        }
        if ($ligne["IPADDR"] == "0.0.0.0") {
            continue;
        }
        $Interface = $nic->NicToOther($Interface);
        $TRA[$Interface] = $Interface;
    }
    while (list($Interface, $ligne) = each($TRA)) {
        $TR[] = $Interface;
    }
    @mkdir('/var/lib/arpd', 0755, true);
    $f[] = "{$Masterbin} -b /var/lib/arpd/arpd.db";
    $f[] = $ArpdKernelLevel;
    if (count($TR) > 0) {
        $f[] = "-k " . @implode($TR, " ");
    }
    $cmd = @implode(" ", $f) . " >/dev/null 2>&1 &";
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service\n";
    }
    shell_exec($cmd);
    for ($i = 1; $i < 5; $i++) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} waiting {$i}/5\n";
        }
        sleep(1);
        $pid = PID_NUM();
        if ($unix->process_exists($pid)) {
            break;
        }
    }
    $pid = PID_NUM();
    if ($unix->process_exists($pid)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success PID {$pid}\n";
        }
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Failed\n";
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$cmd}\n";
        }
    }
}
Example #13
0
function install_bridge()
{
    @unlink("/usr/share/artica-postfix/ressources/logs/vserver.daemon.log");
    echo2("Starting......: VPS server: install bridge");
    shell_exec("/bin/chmod 777 /usr/share/artica-postfix/ressources/logs/vserver.daemon.log");
    $sock = new sockets();
    $users = new usersMenus();
    $unix = new unix();
    $breth = "br5";
    $LXCINterface = $sock->GET_INFO("LXCInterface");
    $routebin = $unix->find_program("route");
    $ifconfig = $unix->find_program("ifconfig");
    $brctl = $unix->find_program("brctl");
    if (!is_file($brctl)) {
        echo2("Starting......: VPS server:{$breth} brctl no such binary");
        return;
    }
    $ifdown = $unix->find_program("ifdown");
    $lxcstart = $unix->find_program("lxc-start");
    if (!is_file($lxcstart)) {
        echo2("Starting......: VPS server:{$breth} lx-start no such binary");
        return;
    }
    if ($LXCINterface == null) {
        echo2("Starting......: VPS server:{$breth} no interface set...");
        return;
    }
    $nics = new system_nic();
    echo2("Starting......: VPS server: {$breth} interface \"{$LXCINterface}\" set...");
    if (!$nics->CreateLXCBridge($LXCINterface, $breth)) {
        echo2("Starting......: VPS server: {$breth} CreateLXCBridge() failed");
        return;
    }
    echo2("Starting......: VPS server: lock Artica Interface");
    $sock->SET_INFO("LXCEthLocked", 1);
    $sock->SET_INFO("LXCEnabled", 1);
    $sock->SET_INFO("LXCBridged", 1);
    $q = new mysql();
    $sql = "UPDATE nics_virtuals SET nic='{$breth}' WHERE nic='{$LXCINterface}'";
    $q->QUERY_SQL($sql, "artica_backup");
    $sql = "UPDATE nics_vlan SET nic='{$breth}' WHERE nic='{$LXCINterface}'";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo2("Starting......: VPS server: mysql error {$q->mysql_error}");
    }
    echo2("Starting......: VPS server: {$breth} linking bridge");
    preup_checkbridgre($breth, $LXCINterface);
    echo2("Starting......: VPS server: {$breth} linking bridge done..");
    $nicsAll = ifconfiglisteth();
    echo2("Starting......: VPS server: {$breth} " . count($nicsAll) . " Listed interface(s)");
    while (list($ethL, $eth2) = each($nicsAll)) {
        if (preg_match("#{$LXCINterface}#", $ethL)) {
            echo2("Starting......: VPS server: shutdown {$ethL}");
            shell_exec("{$ifconfig} {$ethL} down >/dev/null 2>&1");
            continue;
        }
        if (preg_match("#vlan#", $ethL)) {
            echo2("Starting......: VPS server: shutdown {$ethL}");
            shell_exec("{$ifconfig} {$ethL} down >/dev/null 2>&1");
            continue;
        }
        echo2("Starting......: VPS server: keep {$ethL}");
    }
    $nets = new system_nic();
    if ($users->AS_DEBIAN_FAMILY) {
        echo2("Starting......: VPS server: Building network configuration (debian mode)");
        $datas = $nets->root_build_debian_config();
        @file_put_contents("/etc/network/interfaces", $datas);
    } else {
        echo2("Starting......: VPS server: Building network configuration (redhat mode)");
        $nets->root_build_redhat_config();
    }
    $ip = $unix->find_program("ip");
    exec("{$ip} route 2>&1", $results);
    while (list($index, $line) = each($results)) {
        if (preg_match("#dev {$LXCINterface}#", $line)) {
            echo2("Starting......: VPS server: remove route {$line}");
            shell_exec("{$ip} route del {$line}");
        }
    }
    shell_exec2("{$ifconfig} {$LXCINterface} down");
    shell_exec2("{$ifconfig} {$LXCINterface} 0.0.0.0 up");
    if ($users->AS_DEBIAN_FAMILY) {
        $unix->NETWORK_DEBIAN_RESTART();
    } else {
        $unix->NETWORK_REDHAT_RESTART();
    }
}
function save_nic()
{
    $eth = $_POST["save_nic"];
    if (preg_match("#^tun#", $eth)) {
        echo "{$eth} cannot be edited manually...";
        return;
    }
    unset($_POST["save_nic"]);
    $nic = new system_nic($eth);
    if ($_POST["ucarp_vip"] == $nic->IPADDR) {
        echo "{$_POST["ucarp_vip"]} cannot be the same of the real interface !";
        return;
    }
    while (list($key, $value) = each($_POST)) {
        writelogs("{$key} = `{$value}`", __FUNCTION__, __FILE__, __LINE__);
        $nic->{$key} = $value;
    }
    $nic->NoReboot = true;
    $nic->SaveNic();
    $sock = new sockets();
    $sock->getFrameWork("system.php?ucarp-compile=yes");
    $sock->getFrameWork("chilli.php?restart=yes&nohup=yes");
}
Example #15
0
function step7(){
	$tpl=new templates();
	$sock=new sockets();
	$net=new networking();
	$page=CurrentPageName();
	$MAIN=unserialize(base64_decode($sock->GET_INFO("HASettings")));
	$eth=$MAIN["eth"];
	$t=time();
	if(!is_numeric($MAIN["SLAVE_SSL"])){$MAIN["SLAVE_SSL"]=1;}
	$proto="http";
	if($MAIN["SLAVE_SSL"]==1){$proto="https";}
	
	$MAIN=unserialize(base64_decode($sock->GET_INFO("HASettings")));
	$eth=$MAIN["eth"];
	$nic=new system_nic($eth);
	$MAIN["BALANCE_IP"]=$MAIN["first_ipaddr"];

	$nic->IPADDR=$MAIN["second_ipaddr"];
	$nic->ucarp_enabled=1;
	$nic->ucarp_vip=$MAIN["BALANCE_IP"];
	$nic->ucarp_vid=$MAIN["ucarp_vid"];
	$nic->ucarp_master=1;
	$nic->NoReboot=true;
	if(!$nic->SaveNic()){
		echo FATAL_WARNING_SHOW_128("<hr><strong>Unable to save local settings</strong>".wizard_restart());
		return;
	}
	
	$t=time();
	$reboot_remote_server_net=$tpl->javascript_parse_text("{reboot_networks}");
	echo $tpl->_ENGINE_parse_body("<center style='font-size:22px'>{please_wait}</center>").
	"<script>
	function Start$t(){
	document.getElementById('failover-title').innerHTML='$reboot_remote_server_net';
	LoadAjax('failover-div','$page?step8=yes');
	}
	setTimeout('Start$t()',2000);
	</script>
	";	
	
}
function qos_containers_tab()
{
    $tpl = new templates();
    $users = new usersMenus();
    $page = CurrentPageName();
    $fontsize = 18;
    $ID = $_GET["ID"];
    $q = new mysql();
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT name,eth FROM `qos_containers` WHERE ID='{$ID}'", "artica_backup"));
    $suffix["in"] = "{inbound}";
    $suffix["out"] = "{outbound}";
    $eth = $ligne["eth"];
    if (preg_match("#(.*?)-(.+)\$#", $eth, $re)) {
        $eth_text = $re[1] . " " . $suffix[$re[2]];
    }
    $p = new system_nic();
    $eth = $p->NicToOther($eth);
    $array["container-popup"] = "{Q.O.S} {$ligne["name"]}";
    $array["container-rules"] = "{rules}";
    $array["container-DSCP"] = "TOS";
    $t = time();
    while (list($num, $ligne) = each($array)) {
        if ($num == "container-rules") {
            $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"system.qos.container.rules.php?aclid={$ID}\" style='font-size:{$fontsize};font-weight:normal'><span>{$ligne}</span></a></li>\n");
            continue;
        }
        if ($num == "container-DSCP") {
            $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"system.qos.container.DSCP.php?aclid={$ID}\" style='font-size:{$fontsize};font-weight:normal'><span>{$ligne}</span></a></li>\n");
            continue;
        }
        $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"{$page}?{$num}={$t}&ID={$ID}&eth={$eth}\" style='font-size:{$fontsize};font-weight:normal'><span>{$ligne}</span></a></li>\n");
    }
    $html = build_artica_tabs($html, 'main_qos_eth' . $eth) . "<script>// LeftDesign('qos-256-white.png');</script>";
    echo $html;
}
function stepfinal()
{
    $sock = new sockets();
    $sock->GET_INFO("FireHolConfigured", 1);
    $sock->SET_INFO("FireHolEnable", 1);
    $sock->SET_INFO("FireHolRouter", 0);
    $FireHolConf = unserialize(base64_decode($sock->GET_INFO("FireHolConf")));
    $eth = new system_nic($FireHolConf["IF_LAN"]);
    $eth->firewall_policy = $FireHolConf["IF_LAN_BEHAVIOR"];
    $eth->isFW = 1;
    $eth->SaveNic();
    $servs[] = "artica";
    $servs[] = "http";
    $servs[] = "https";
    $servs[] = "dns";
    $servs[] = "ping";
    $servs[] = "ssh";
    $servs[] = "squid";
    $servs[] = "snmp";
    $servs[] = "snmptrap";
    $servs[] = "icmp";
    $servs[] = "dhcp";
    $f = new firehol();
    if ($FireHolConf["IF_LAN_BEHAVIOR"] == "reject") {
        if (!$f->checkTables()) {
            echo "FAILED";
            return false;
        }
        while (list($a, $service) = each($servs)) {
            if (!$f->edit_service($FireHolConf["IF_LAN"], $service, 1, 1)) {
                echo "edit_service({$service}) FAILED";
                return;
            }
        }
    }
    $servs = array();
    $servs1[] = "http";
    $servs1[] = "https";
    $servs1[] = "ftp";
    $servs1[] = "dns";
    $servs1[] = "ping";
    $servs1[] = "icmp";
    if (!$f->checkTables()) {
        echo "FAILED";
        return false;
    }
    while (list($a, $service) = each($servs1)) {
        if (!$f->edit_client_service($FireHolConf["IF_LAN"], $service, 1, 1)) {
            echo "edit_client_service({$service}) FAILED";
            return;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "edit_client_service({$service}) TRUE<br>\n";
        }
    }
    $sock->SET_INFO("FireHolConfigured", 1);
    echo "<script>Loadjs('firehol.progress.php');</script>";
}
Example #18
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);
}
function Save()
{
    $sock = new sockets();
    while (list($a, $b) = each($_POST)) {
        $_POST[$a] = url_decode_special_tool($b);
    }
    $nic = new system_nic($_POST["eth"]);
    $nic->ShoreWallServices = $_POST;
    $nic->SaveNicFW();
}
Example #20
0
function UCARP_REMOVE()
{
    $sock = new sockets();
    $SEND_SETTING = unserialize(base64_decode($_GET["ucarp2-remove"]));
    if (!is_array($SEND_SETTING)) {
        $array["ERROR"] = true;
        $array["ERROR_SHOW"] = "{corrupted_parameters}";
        echo "\n\n<RESULTS>" . base64_decode(serialize($array)) . "<br>Not an array()</RESULTS>\n\n";
        return;
    }
    $second_ipaddr = $SEND_SETTING["SLAVE"];
    $ip = new IP();
    if (!$ip->isValid($second_ipaddr)) {
        $array["ERROR"] = true;
        while (list($a, $b) = each($SEND_SETTING)) {
            $f[] = "<strong>{$a} = {$b}</strong><br>";
        }
        $array["ERROR_SHOW"] = "{corrupted_parameters}: {ipaddr}: {$second_ipaddr}<br>" . @implode("\n", $f);
        echo "\n\n<RESULTS>" . base64_encode(serialize($array)) . "</RESULTS>\n\n";
        return;
    }
    $ip = new networking();
    while (list($eth, $cip) = each($ip->array_TCP)) {
        if ($cip == null) {
            continue;
        }
        if ($cip == $second_ipaddr) {
            $MyEth = $eth;
        }
    }
    if ($MyEth == null) {
        $array["ERROR"] = true;
        $array["ERROR_SHOW"] = "{corrupted_parameters}: {ipaddr}: {$second_ipaddr} {cannot_found_interface}";
        echo "\n\n<RESULTS>" . base64_encode(serialize($array)) . "</RESULTS>\n\n";
        return;
    }
    $nic = new system_nic($MyEth);
    if ($nic->IPADDR == null) {
        $array["ERROR"] = true;
        $array["ERROR_SHOW"] = "{unconfigured_network}";
        echo "\n\n<RESULTS>" . base64_encode(serialize($array)) . "</RESULTS>\n\n";
        return;
    }
    $nic->ucarp_enabled = 0;
    $nic->ucarp_vip = null;
    $nic->ucarp_vid = 0;
    $nic->ucarp_master = 0;
    $nic->NoReboot = true;
    if (!$nic->SaveNic()) {
        $array["ERROR"] = true;
        $array["ERROR_SHOW"] = "Save in Database failed";
        echo "\n\n<RESULTS>" . base64_encode(serialize($array)) . "</RESULTS>\n\n";
        return;
    }
    echo "\n<RESULTS>SUCCESS</RESULTS>";
    $data = base64_decode($sock->getFrameWork("network.php?ucarp-down={$MyEth}&master={$_SERVER["REMOTE_ADDR"]}"));
    $sock->getFrameWork("network.php?reconfigure-restart=yes");
}
Example #21
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"]);
}
Example #22
0
function MII_TOOLS()
{
    $sock = new sockets();
    while (list($a, $b) = each($_POST)) {
        $f[] = "{$a}={$b}";
    }
    $duptype = $_POST["duptype"];
    $eth = $_POST["MII-TOOL"];
    $nicClass = new system_nic($eth);
    $nicClass->SetMiittools($duptype);
    $data = trim(base64_decode($sock->getFrameWork("system.php?mii-tool-save=yes&" . @implode("&", $f))));
    if ($data != null) {
        echo $data;
    }
}
Example #23
0
function exunlink()
{
    $unix = new unix();
    $sock = new sockets();
    $net = new networking();
    $WgetBindIpAddress = $sock->GET_INFO("WgetBindIpAddress");
    $MAIN = unserialize(base64_decode($sock->GET_INFO("HASettings")));
    $eth = $MAIN["eth"];
    $t = time();
    if (!is_numeric($MAIN["SLAVE_SSL"])) {
        $MAIN["SLAVE_SSL"] = 1;
    }
    $proto = "http";
    if ($MAIN["SLAVE_SSL"] == 1) {
        $proto = "https";
    }
    $MAIN = unserialize(base64_decode($sock->GET_INFO("HASettings")));
    $eth = $MAIN["eth"];
    $nic = new system_nic($eth);
    $MAIN["BALANCE_IP"] = $MAIN["first_ipaddr"];
    $SEND_SETTING = base64_encode(serialize($MAIN));
    $uri = "{$proto}://{$MAIN["SLAVE"]}:{$MAIN["SLAVE_PORT"]}/nodes.listener.php?ucarp2-remove={$SEND_SETTING}&continue=true";
    build_progress("Notify {$MAIN["SLAVE"]}", 20);
    $curl = new ccurl($uri, true, $WgetBindIpAddress, true);
    $curl->NoHTTP_POST = true;
    if (!$curl->get()) {
        echo "{$curl->error}\n";
        debug_curl($curl->CURL_ALL_INFOS);
        build_progress("{reboot_networks} {$MAIN["SLAVE"]}:{$MAIN["SLAVE_PORT"]} {failed}", 110);
        return;
    }
    if (!preg_match("#<RESULTS>(.+?)</RESULTS>#is", $curl->data, $re)) {
        echo "Please verify that both servers must have the same Artica version\n";
        build_progress("{reboot_networks} {$MAIN["SLAVE"]}:{$MAIN["SLAVE_PORT"]} {protocol_error}", 110);
        return;
    }
    $array = unserialize(base64_decode($re[1]));
    if ($array["ERROR"]) {
        echo "{$array["ERROR_SHOW"]}\n";
        build_progress("{reboot_networks} {$MAIN["SLAVE"]}:{$MAIN["SLAVE_PORT"]} {failed}", 110);
        return;
    }
    build_progress("{please_wait_reconfigure_network}", 80);
    $nic = new system_nic($eth);
    $nic->ucarp_enabled = 0;
    $nic->ucarp_vip = null;
    $nic->ucarp_vid = 0;
    $nic->ucarp_master = 0;
    $nic->NoReboot = true;
    if (isset($MAIN["first_ipaddr"])) {
        if ($MAIN["first_ipaddr"] != null) {
            $nic->IPADDR = $MAIN["first_ipaddr"];
        }
    }
    if (!$nic->SaveNic()) {
        echo "Unable to save local settings\n";
        build_progress("{saving_local_parameters} {failed}", 110);
        return;
    }
    //please_wait_reconfigure_network
    $sock->SET_INFO("HASettings", base64_encode(serialize(array())));
    build_progress("{reboot_networks}", 75);
    $php = $unix->LOCATE_PHP5_BIN();
    system("{$php} /usr/share/artica-postfix/exec.virtuals-ip.php --build --force");
    build_progress("{reboot_networks}", 80);
    squid_admin_mysql(0, "Rebooting Network", null, __FILE__, __LINE__);
    system("/etc/init.d/artica-ifup --script=exec.failover.php/" . __FUNCTION__);
    build_progress("{starting_service}", 90);
    system("/etc/init.d/artica-failover stop");
    sleep(3);
    build_progress("{done}", 100);
}
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();
}
function save()
{
    $sock = new sockets();
    $FireHolConf = unserialize(base64_decode($sock->GET_INFO("FireHolConf")));
    while (list($index, $ligne) = each($_POST)) {
        $FireHolConf[$index] = $ligne;
    }
    $sock->SaveConfigFile(base64_encode(serialize($FireHolConf)), "FireHolConf");
    //$FireHolConf=unserialize(base64_decode(@file_get_contents("/etc/artica-postfix/settings/Daemons/FireHolConf")));
    $IF_WAN = $FireHolConf["IF_WAN"];
    $IF_LAN = $FireHolConf["IF_LAN"];
    if ($IF_WAN == null) {
        return;
    }
    $zMD5 = md5($IF_LAN . $IF_WAN);
    if ($IF_LAN == null) {
        echo "No LAN interface defined !";
        return;
    }
    if ($IF_WAN == null) {
        echo "No WAN interface defined !";
        return;
    }
    $q = new mysql();
    $sql = "CREATE TABLE IF NOT EXISTS `pnic_bridges` (\n\t\t`ID` INT(10) NOT NULL AUTO_INCREMENT,\n\t\t`zMD5` varchar(90) NOT NULL,\n\t\t`nic_from` varchar(50) NOT NULL,\n\t\t`nic_to` varchar(50) NOT NULL,\n\t\t`enabled` smallint(1) NOT NULL DEFAULT 1,\n\t\t`DenyDHCP` smallint(1) NOT NULL DEFAULT 1,\n\t\tPRIMARY KEY (`ID`),\n\t\tUNIQUE KEY (`zMD5`),\n\t\tKEY `nic_from` (`nic_from`),\n\t\tKEY `nic_to` (`nic_to`),\n\t\tKEY `DenyDHCP` (`DenyDHCP`),\n\t\tKEY `enabled` (`enabled`)\n\t\t) ENGINE=MYISAM;";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->FIELD_EXISTS("pnic_bridges", "zMD5", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE pnic_bridges ADD zMD5 varchar(90), ADD UNIQUE KEY (`zMD5`)", "artica_backup");
        if (!$q->ok) {
            echo "ALTER TABLE pnic_bridges failed\n{$q->mysql_error}\n";
            return;
        }
    }
    if (!$q->FIELD_EXISTS("pnic_bridges", "STP", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE pnic_bridges ADD STP smallint(1) DEFAULT 1", "artica_backup");
        if (!$q->ok) {
            echo "ALTER TABLE STP failed\n{$q->mysql_error}\n";
            return;
        }
    }
    if (!$q->FIELD_EXISTS("pnic_bridges", "DenyDHCP", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE pnic_bridges ADD DenyDHCP smallint(1) DEFAULT 1", "artica_backup");
        if (!$q->ok) {
            echo "ALTER TABLE DenyDHCP failed\n{$q->mysql_error}\n";
            return;
        }
    }
    if (!$q->FIELD_EXISTS("pnic_bridges", "DenyCountries", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE pnic_bridges ADD DenyCountries smallint(1) DEFAULT 0", "artica_backup");
        if (!$q->ok) {
            echo "ALTER TABLE DenyCountries failed\n{$q->mysql_error}\n";
            return;
        }
    }
    if (!$q->FIELD_EXISTS("pnic_bridges", "masquerading", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE pnic_bridges ADD masquerading smallint(1) DEFAULT 0", "artica_backup");
        if (!$q->ok) {
            echo "ALTER TABLE masquerading failed\n{$q->mysql_error}\n";
            return;
        }
    }
    if (!$q->FIELD_EXISTS("pnic_bridges", "masquerading_invert", "artica_backup")) {
        $q->QUERY_SQL("ALTER TABLE pnic_bridges ADD masquerading_invert smallint(1) DEFAULT 0", "artica_backup");
        if (!$q->ok) {
            echo "ALTER TABLE masquerading_invert failed\n{$q->mysql_error}\n";
            return;
        }
    }
    $sql = "INSERT INTO pnic_bridges (zMD5,nic_from,nic_to,enabled,STP,DenyDHCP,masquerading,masquerading_invert)\n\tVALUES ('{$zMD5}','{$IF_LAN}','{$IF_WAN}','1','1','1','1','0')";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $nic = new system_nic($IF_WAN);
    $nic->firewall_policy = "reject";
    $nic->firewall_behavior = 2;
    $nic->firewall_masquerade = 1;
    $nic->firewall_artica = 1;
    $nic->SaveNic();
    $nic = new system_nic($IF_LAN);
    $nic->firewall_policy = "accept";
    $nic->firewall_behavior = 1;
    $nic->SaveNic();
    $sock->GET_INFO("FireHolConfigured", 1);
    $sock->SET_INFO("FireHolEnable", 1);
    $sock->SET_INFO("FireHolRouter", 1);
    $sock->SET_INFO("FireHolConfigured", 1);
    $sock->SaveConfigFile(base64_encode(serialize(array())), "FireHolConf");
}
Example #26
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");
}
Example #27
0
function ConstructVirtsIP(){
	$nic=new system_nic();
	$nic->ConstructVirtsIP();
}
Example #28
0
function bridge_deletemanu($eth)
{
    $NetBuilder = new system_nic();
    $NetBuilder->LoadTools();
    if (!$NetBuilder->IfBridgeExists($eth)) {
        return;
    }
    exec("{$GLOBALS["brctlbin"]} show {$eth} 2>&1", $result);
    while (list($id, $ligne) = each($result)) {
        if (preg_match("#.*\\s+.*?\\s+.*?\\s+([a-z\\.0-9]+)\$#", $ligne, $re)) {
            if (strtolower(trim($re[1]) == "interfaces")) {
                continue;
            }
            echo "Removing {$re[1]}\n";
            $GLOBALS["SCRIPTS_DEL"][] = "{$GLOBALS["brctlbin"]} delif {$eth} {$re[1]}";
            $GLOBALS["SCRIPTS_DEL"][] = "{$GLOBALS["ifconfig"]} {$re[1]} down";
            continue;
        }
        if (preg_match("#\\s+\\s+([a-z\\.0-9]+)\$#", $ligne, $re)) {
            if (strtolower(trim($re[1]) == "interfaces")) {
                continue;
            }
            echo "Removing {$re[1]}\n";
            $GLOBALS["SCRIPTS_DEL"][] = "{$GLOBALS["brctlbin"]} delif {$eth} {$re[1]}";
            $GLOBALS["SCRIPTS_DEL"][] = "{$GLOBALS["ifconfig"]} {$re[1]} down";
            continue;
        }
    }
    $GLOBALS["SCRIPTS_DEL"][] = "{$GLOBALS["ifconfig"]} {$eth} down";
    $GLOBALS["SCRIPTS_DEL"][] = "{$GLOBALS["brctlbin"]} delbr {$eth}";
    while (list($id, $ligne) = each($GLOBALS["SCRIPTS_DEL"])) {
        echo "Starting......: " . date("H:i:s") . " `{$ligne}`\n";
        shell_exec("{$ligne}");
    }
}
function network_bridge_associates_save(){
	$eth=$_POST["eth"];
	$nic=new system_nic($eth);
	$nic->Bridged=1;
	$nic->BridgedTo="br{$_POST["ID"]}";
	$nic->SaveNic();
	
}
Example #30
0
function popup(){
	$tpl=new templates();
	$sock=new sockets();
	$page=CurrentPageName();
	$users=new usersMenus();
	$squid=new squidbee();
	$EnableArticaHotSpot=$sock->GET_INFO("EnableArticaHotSpot");
	$SquidHotSpotPort=intval($sock->GET_INFO("SquidHotSpotPort"));
	$ArticaHotSpotPort=intval($sock->GET_INFO("ArticaHotSpotPort"));
	$ArticaSSLHotSpotPort=$sock->GET_INFO("ArticaSSLHotSpotPort");
	$ArticaSplashHotSpotPort=$sock->GET_INFO("ArticaSplashHotSpotPort");
	$ArticaSplashHotSpotPortSSL=$sock->GET_INFO("ArticaSplashHotSpotPortSSL");
	$ArticaSplashHotSpotCacheAuth=$sock->GET_INFO("ArticaSplashHotSpotCacheAuth");
	$ArticaSplashHotSpotCertificate=$sock->GET_INFO("ArticaSplashHotSpotCertificate");
	$ArticaSplashHotSpotEndTime=$sock->GET_INFO("ArticaSplashHotSpotEndTime");
	$SquidHotSpotSSLPort=intval($sock->GET_INFO("SquidHotSpotSSLPort"));
	$WifiDogDebugLevel=intval($sock->GET_INFO("WifiDogDebugLevel"));
	$ArticaHotSpotInterface2=$sock->GET_INFO("ArticaHotSpotInterface2");
	
	
	if(!is_numeric($ArticaSplashHotSpotCacheAuth)){$ArticaSplashHotSpotCacheAuth=60;}
	if(!is_numeric($ArticaSplashHotSpotEndTime)){$ArticaSplashHotSpotEndTime=0;}
	
	$ArticaHotSpotInterface=$sock->GET_INFO("ArticaHotSpotInterface");
	
	if(!$users->CONNTRACK_INSTALLED){
		echo FATAL_WARNING_SHOW_128("{conntrackd_not_installed}");
	}
	
	for($i=0;$i<11;$i++){
		$WifiDogDebugLevelZ[$i]=$i;
	}
	
	$Timez[60]="1 {hour}";
	$Timez[120]="2 {hours}";
	$Timez[180]="3 {hours}";
	$Timez[360]="6 {hours}";
	$Timez[720]="12 {hours}";
	$Timez[1440]="1 {day}";
	$Timez[2880]="2 {days}";
	$Timez[10080]="1 {week}";
	
	
	$Timez[0]="{unlimited}";
	$Timez[30]="30 {minutes}";
	$Timez[60]="1 {hour}";
	$Timez[120]="2 {hours}";
	$Timez[180]="3 {hours}";
	$Timez[360]="6 {hours}";
	$Timez[720]="12 {hours}";
	$Timez[1440]="1 {day}";
	$Timez[2880]="2 {days}";
	$Timez[10080]="1 {week}";
	$Timez[20160]="2 {weeks}";
	$Timez[40320]="1 {month}";
	
	$ArticaHotSpotEnableMIT=$sock->GET_INFO("ArticaHotSpotEnableMIT");
	$ArticaHotSpotEnableProxy=$sock->GET_INFO("ArticaHotSpotEnableProxy");
	
	if(!is_numeric($ArticaHotSpotEnableMIT)){$ArticaHotSpotEnableMIT=1;}
	if(!is_numeric($ArticaHotSpotEnableProxy)){$ArticaHotSpotEnableProxy=1;}
	
	if(!is_numeric($ArticaHotSpotPort)){$ArticaHotSpotPort=0;}
	if(!is_numeric($ArticaSplashHotSpotPort)){$ArticaSplashHotSpotPort=16080;}
	if(!is_numeric($ArticaSplashHotSpotPortSSL)){$ArticaSplashHotSpotPortSSL=16443;}
	
	
	$ArticaSplashHotSpotTitle=$sock->GET_INFO("ArticaSplashHotSpotTitle");
	if($ArticaSplashHotSpotTitle==null){$ArticaSplashHotSpotTitle="HotSpot system";}
	
	if($ArticaHotSpotPort==0){
		$ArticaHotSpotPort=rand(38000, 64000);
		$sock->SET_INFO("ArticaHotSpotPort", $ArticaHotSpotPort);
	}
	
	if($ArticaSSLHotSpotPort==0){
		$ArticaSSLHotSpotPort=rand(38500, 64000);
		$sock->SET_INFO("ArticaSSLHotSpotPort", $ArticaSSLHotSpotPort);
	}
	
	if($SquidHotSpotPort==0){
		$SquidHotSpotPort=rand(40000, 64000);
		$sock->SET_INFO("SquidHotSpotPort", $SquidHotSpotPort);
	}
	
	if($SquidHotSpotSSLPort==0){
		$SquidHotSpotSSLPort=rand(40500, 64000);
		$sock->SET_INFO("SquidHotSpotSSLPort", $SquidHotSpotSSLPort);
	}
	
	
	$tcp=new networking();
	$interfacesZ=$tcp->Local_interfaces();
	while (list ($interface, $line) = each ($interfacesZ) ){
		$p=new system_nic($interface);
		if($p->IsBridged($interface)){continue;}
		$interfaces[$interface]=$p->NICNAME;
		
	}
	
	
	
	
	
	$interfaces[null]="{none}";
	include_once(dirname(__FILE__)."/ressources/class.squid.reverse.inc");
	$squid_reverse=new squid_reverse();
	$sslcertificates=$squid_reverse->ssl_certificates_list();
	
	
	$t=time();
	$html="
	
	
	<div id='$t' class=text-info style='font-size:18px'>{HotSpot_text}</div>
	<div style='width:98%' class=form>
	<table style='width:99%'>
	<tr>
		<td colspan=2>
		<center><img src='img/hotspot-howto.png' align=center></center>
		</td>
	</tr>
	<tr>
		<td  style='font-size:42px' colspan>{service2}:</td>
	</tr>		
	<tr>
		<td class=legend style='font-size:22px'>{listen_port} (HotSpot):</td>
		<td>". Field_text("ArticaHotSpotPort",$ArticaHotSpotPort,"font-size:22px;width:110px")."</td>
	</tr>		
	<tr>
		<td class=legend style='font-size:22px'>{interface} (IN):</td>
		<td>". Field_array_Hash($interfaces,"ArticaHotSpotInterface", $ArticaHotSpotInterface,"style:font-size:22px")."</td>
	</tr>
	<tr>
		<td class=legend style='font-size:22px'>{interface} (OUT):</td>
		<td>". Field_array_Hash($interfaces,"ArticaHotSpotInterface2", $ArticaHotSpotInterface2,"style:font-size:22px")."</td>
	</tr>
				
	<tr>
		<td class=legend style='font-size:22px'>{log_level}:</td>
		<td>". Field_array_Hash($WifiDogDebugLevelZ,"WifiDogDebugLevel", $WifiDogDebugLevel,"style:font-size:22px")."</td>
	</tr>				
	<tr>
		<td  style='font-size:42px' colspan>{webserver}:</td>
	</tr>	
	<tr>
		<td class=legend style='font-size:22px'>{listen_port} (splash):</td>
		<td>". Field_text("ArticaSplashHotSpotPort",$ArticaSplashHotSpotPort,"font-size:22px;width:110px")."</td>
	</tr>							
	<tr>
		<td class=legend style='font-size:22px'>{listen_port} (splash/SSL):</td>
		<td>". Field_text("ArticaSplashHotSpotPortSSL",$ArticaSplashHotSpotPortSSL,"font-size:22px;width:110px")."</td>
	</tr>
	<tr>
		<td  style='font-size:42px' colspan>Proxy:</td>
	</tr>
	<tr>
		<td class=legend style='font-size:22px'>{transparent_ssl}:</td>
		<td>". Field_checkbox("ArticaHotSpotEnableMIT",1,$ArticaHotSpotEnableMIT)."</td>
	</tr>
	<tr>
		<td class=legend style='font-size:22px'>{transparent_http}:</td>
		<td>". Field_checkbox("ArticaHotSpotEnableProxy",1,$ArticaHotSpotEnableProxy)."</td>
	</tr>									
	<tr>
		<td class=legend style='font-size:22px'>{listen_port} (Proxy HTTP):</td>
		<td>". Field_text("SquidHotSpotPort",$SquidHotSpotPort,"font-size:22px;width:110px")."</td>
	</tr>	
	<tr>
		<td class=legend style='font-size:22px'>{listen_port} (Proxy SSL):</td>
		<td>". Field_text("SquidHotSpotSSLPort",$SquidHotSpotSSLPort,"font-size:22px;width:110px")."</td>
	</tr>					
	
	<tr>
		<td  style='font-size:42px' colspan>{defaults}:</td>
	</tr>	
	<tr>
		<td class=legend style='font-size:22px;text-transform:capitalize'>{re_authenticate_each} ({default}):</td>
		<td style='font-size:18px'>". Field_array_Hash($Timez,"ArticaSplashHotSpotCacheAuth",
					$ArticaSplashHotSpotCacheAuth,null,null,0,"font-size:22px")."</td>
	</tr>
	<tr>
		<td class=legend style='font-size:22px;text-transform:capitalize'>{endtime} ({default}):</td>
		<td style='font-size:18px'>". Field_array_Hash($Timez,"ArticaSplashHotSpotEndTime",
				$ArticaSplashHotSpotEndTime,null,null,0,"font-size:22px")."</td>
	</tr>
				
	<tr>
		<td  style='font-size:42px' colspan>{web_page}:</td>
	</tr>
	<tr>
		<td class=legend style='font-size:22px'>{title2}:</td>
		<td>". Field_text("ArticaSplashHotSpotTitle",$ArticaSplashHotSpotTitle,"font-size:22px;width:390px")."</td>
	</tr>	
	<tr>
		<td class=legend nowrap style='font-size:22px;'>{certificate}:</td>
		<td >". Field_array_Hash($sslcertificates, "ArticaSplashHotSpotCertificate",
				$ArticaSplashHotSpotCertificate,null,null,0,"font-size:22px")."</td>
	</tr>
	<tr>
		<td colspan=2 align='right'><hr>". button("{apply}","SaveHotSpot()","42px")."</td>
	</tr>
	</table>
	</div>
	<script>
	var x_SaveHotSpot= function (obj) {
		var results=obj.responseText;
		if(results.length>3){alert(results);return;}
		Loadjs('squid.webauth.restart.php');

	}


function SaveHotSpot(){
		var XHR = new XHRConnection();
		
		XHR.appendData('ArticaHotSpotPort',document.getElementById('ArticaHotSpotPort').value);
		XHR.appendData('SquidHotSpotPort',document.getElementById('SquidHotSpotPort').value);
		
		XHR.appendData('ArticaSplashHotSpotPort',document.getElementById('ArticaSplashHotSpotPort').value);
		XHR.appendData('ArticaSplashHotSpotPortSSL',document.getElementById('ArticaSplashHotSpotPortSSL').value);
		XHR.appendData('ArticaHotSpotInterface',document.getElementById('ArticaHotSpotInterface').value);
		XHR.appendData('ArticaHotSpotInterface2',document.getElementById('ArticaHotSpotInterface2').value);
		
		XHR.appendData('ArticaSplashHotSpotCacheAuth',document.getElementById('ArticaSplashHotSpotCacheAuth').value);
		XHR.appendData('ArticaSplashHotSpotCertificate',document.getElementById('ArticaSplashHotSpotCertificate').value);
		XHR.appendData('ArticaSplashHotSpotEndTime',document.getElementById('ArticaSplashHotSpotEndTime').value);
		XHR.appendData('WifiDogDebugLevel',document.getElementById('WifiDogDebugLevel').value);
		
		
		if(document.getElementById('ArticaHotSpotEnableMIT').checked){
			XHR.appendData('ArticaHotSpotEnableMIT',1);
		}else{
			XHR.appendData('ArticaHotSpotEnableMIT',0);
		}
		if(document.getElementById('ArticaHotSpotEnableProxy').checked){
			XHR.appendData('ArticaHotSpotEnableProxy',1);
		}else{
			XHR.appendData('ArticaHotSpotEnableProxy',0);
		}		
		
		
		var ArticaSplashHotSpotTitle=encodeURIComponent(document.getElementById('ArticaSplashHotSpotTitle').value);
		XHR.appendData('ArticaSplashHotSpotTitle',document.getElementById('ArticaSplashHotSpotTitle').value);
		XHR.sendAndLoad('$page', 'POST',x_SaveHotSpot);
	}		
	</script>
	";
	
	echo $tpl->_ENGINE_parse_body($html);
	
	
}