function NicBuildTR($NicRequested)
{
    $val = $NicRequested;
    $val = trim($val);
    if (preg_match('#master#', $val)) {
        return;
    }
    if (preg_match("#^veth.+?#", $val)) {
        return;
    }
    if (preg_match("#^tunl[0-9]+#", $val)) {
        return;
    }
    if (preg_match("#^dummy[0-9]+#", $val)) {
        return;
    }
    if (preg_match("#^gre[0-9]+#", $val)) {
        return;
    }
    if (preg_match("#^ip6tnl[0-9]+#", $val)) {
        return;
    }
    if (preg_match("#^sit[0-9]+#", $val)) {
        return;
    }
    if (preg_match("#^vlan[0-9]+#", $val)) {
        return;
    }
    if (preg_match("#^lxc[0-9]+#", $val)) {
        return;
    }
    $sock = new sockets();
    $snortInterfaces = array();
    $LXCEthLocked = $sock->GET_INFO("LXCEthLocked");
    $EnableipV6 = $sock->GET_INFO("EnableipV6");
    if (!is_numeric($EnableipV6)) {
        $EnableipV6 = 0;
    }
    if (!is_numeric($LXCEthLocked)) {
        $LXCEthLocked = 0;
    }
    $IPBANS = unserialize(base64_decode($sock->GET_INFO("ArticaIpListBanned")));
    $LXCInterface = $sock->GET_INFO("LXCInterface");
    $DisableNetworksManagement = $sock->GET_INFO("DisableNetworksManagement");
    if (!is_numeric($DisableNetworksManagement)) {
        $DisableNetworksManagement = 0;
    }
    $page = CurrentPageName();
    $tpl = new templates();
    $apply_network_configuration = $tpl->_ENGINE_parse_body("{apply_network_configuration}");
    $ERROR_NO_PRIVS = $tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
    $apply_network_configuration_warn = $tpl->javascript_parse_text("{apply_network_configuration_warn}");
    $users = new usersMenus();
    if ($users->SNORT_INSTALLED) {
        $EnableSnort = $sock->GET_INFO("EnableSnort");
        if ($EnableSnort == 1) {
            $snortInterfaces = unserialize(base64_decode($sock->GET_INFO("SnortNics")));
        }
    }
    $tcp = new networking();
    if (!isset($GLOBALS["ipsZ"])) {
        $GLOBALS["ipsZ"] = $tcp->ALL_IPS_GET_ARRAY();
    }
    $nic = new system_nic($NicRequested);
    if (!$nic->unconfigured) {
        if ($LXCEthLocked == 1) {
            if ($val == $LXCInterface) {
                writelogs("LXCEthLocked:{$LXCEthLocked}; {$val}=={$LXCInterface} -> abort", __FUNCTION__, __FILE__, __LINE__);
                return;
            }
        }
    }
    $NIC_UP = false;
    if (trim($val) == null) {
        continue;
    }
    $tcp->ifconfig(trim($val));
    $array_ipcfg = listnicinfos(trim($val));
    $ipddr = $array_ipcfg["tcp_address"];
    $defaultroute_text = null;
    if ($nic->defaultroute == 1) {
        $defaultroute_text = "<div><i style='color:#C40000;font-size:11px'>{default_route}</i></div>";
    }
    /*		return array(
    				"textColor"=>$textColor,
    				"tcp_address"=>$IPADDR,
    				"IPV6"=>$IPV6,
    				"NETMASK"=>$tbl[2],
    				"gateway"=>$tbl[4],
    				"mac_addr"=>$tbl[1],
    				"HAMACHI"=>$HAMACHI
    		);		
    		*/
    $js = "javascript:Loadjs('system.nic.edit.php?nic={$val}')";
    if (!$tcp->linkup) {
        $img_on = "net-card-64-grey.png";
    } else {
        $img_on = "net-card-64.png";
        $NIC_UP = true;
        if ($snortInterfaces[trim($val)] == 1) {
            $img_on = "64-win-nic-snort.png";
        }
    }
    $icon1 = imgtootltip("service-restart-16.png", "{rebuild}", "RebuildMyNic{$val}()");
    $icon2 = imgtootltip("plus-16.png", "{add_virtual_ip_addr_explain_js}", "Loadjs('{$page}?js-add-nic={$val}')");
    if ($array_ipcfg["HAMACHI"]) {
        $img_on = "64-win-nic-hamachi.png";
        $js = "javascript:Loadjs('hamachi.php')";
        $icon1 = null;
        $icon2 = null;
    }
    if ($IPBANS[$ipddr]) {
        $img_on = "64-win-nic-off.png";
        $icon1 = null;
        $icon2 = null;
        $js = null;
    }
    $boot = new boostrap_form();
    $link = $boot->trswitch("Loadjs('miniadm.network.interfaces.NIC.php?nic={$NicRequested}')");
    if (!$GLOBALS["AsSystemAdministrator"]) {
        $link = null;
    }
    $nic = new system_nic($NicRequested);
    $oldnic = null;
    $oldMac = null;
    $failover_text = null;
    $error = null;
    if ($nic->ucarp_enabled == 0) {
        $failover_text = "{disabled}";
    }
    if ($nic->ucarp_enabled == 1) {
        $oldnic = $ipddr;
        $ipddr = $nic->ucarp_vip;
        if (!isset($GLOBALS["ipsZ"][$nic->ucarp_vip])) {
            $error = "<img src='img/ok24-grey.png' style='marign-right:10px;float-left'>";
        }
        if ($nic->ucarp_master == 1) {
            $failover_text = "{master2}";
        } else {
            $failover_text = "{slave}";
        }
        $failover_text = $error . $failover_text . ":&nbsp;{$oldnic}";
        $nicinfos = $sock->getFrameWork("cmd.php?nicstatus={$NicRequested}:ucarp");
        $tbl = explode(";", $nicinfos);
        $oldMac = "<div style='color:{$array_ipcfg["textColor"]};font-size:12px'><i>{$array_ipcfg["mac_addr"]}</i></div>";
        $array_ipcfg["mac_addr"] = $tbl[1];
    }
    if (!$users->UCARP_INSTALLED) {
        $failover_text = "{not_installed}";
    }
    if ($array_ipcfg["gateway"] == null) {
        $nicz = new system_nic($NicRequested);
        $array_ipcfg["gateway"] = $nicz->GATEWAY;
    }
    return $tpl->_ENGINE_parse_body("\n\t\t<tr style='font-size:18px' {$link}>\n\t\t\t<td><img src='img/{$img_on}'></td>\n\t\t\t<td style='color:{$array_ipcfg["textColor"]}'>{$NicRequested}</td>\n\t\t\t<td style='color:{$array_ipcfg["textColor"]}'><i class='icon-signal'></i>&nbsp;{$ipddr}<div style='color:{$array_ipcfg["textColor"]};font-size:12px'><i>{failover}:{$failover_text}</i><br>{$array_ipcfg["IPV6"]}</td>\n\t\t\t<td style='color:{$array_ipcfg["textColor"]}'><i class='icon-signal'></i>&nbsp;{$array_ipcfg["mac_addr"]}{$oldMac}</td>\n\t\t\t<td style='color:{$array_ipcfg["textColor"]}'>{$array_ipcfg["gateway"]}{$defaultroute_text}</td>\n\t\t\t<td style='color:{$array_ipcfg["textColor"]}'>{$array_ipcfg["NETMASK"]}</td>\n\t\t</tr>");
}
Example #2
0
function netconfig_popup(){
	$eth=$_GET["netconfig"];
	$text_ip=listnicinfos($eth);
	$NAMESERVERS=null;
	
	$ip=new networking();
	$page=CurrentPageName();
	$arrayNic=$ip->GetNicInfos($eth);
	

	$sock=new sockets();
	$type=$sock->getfile("SystemNetworkUse");
	$nicinfos=$sock->getFrameWork("cmd.php?nicstatus=$eth");
	
	$tbl=explode(";",$nicinfos);
	$wire=false;
	if(trim($tbl[5])=="yes"){$wire=true;}		
	

	
	$button=button("{properties}","ipconfig('$eth')");
	if($wire){
		$button="<div style='background-color:#F5F59F;border:1px solid #676767;padding:3px;margin:3px;font-weight:bold'>
		{warning_wireless_nic}
		</div>";
	}
	
	if(is_array($arrayNic["NAMESERVERS"])){
		$NAMESERVERS=implode(",",$arrayNic["NAMESERVERS"]);
	}

	$html="
	
	
	$text_ip
	
	<div class=text-info>
	{network_style}:<strong>$type</strong>
	</div>
	<div class=form>
		<H3>{dns_servers}:</H3>
			$NAMESERVERS
			
		</div>	
	
	<div style='margin:4px;text-align:right;'>
		$button
	</div>
	
	";
	
	$tpl=new templates();
	echo $tpl->_ENGINE_parse_body($html);
	
}
function netconfig_popup()
{
    $eth = $_GET["netconfig"];
    $text_ip = listnicinfos($eth);
    $sock = new sockets();
    $type = $sock->getfile("SystemNetworkUse");
    $dns = $sock->getFrameWork('cmd.php?dnslist=yes');
    $nicinfos = $sock->getfile("nicstatus:{$eth}");
    $tbl = explode(";", $nicinfos);
    $wire = false;
    if (trim($tbl[5]) == "yes") {
        $wire = true;
    }
    $dnslist = explode(";", $dns);
    if (is_array($dnslist)) {
        while (list($num, $val) = each($dnslist)) {
            $dns_text = $dns_text . "<div style='font-size:11px;padding-left:4px'><strong>{$val}</strong></div>";
        }
    }
    $button = button("{properties}", "ipconfig('{$eth}')");
    if ($wire) {
        $button = "<div style='background-color:#F5F59F;border:1px solid #676767;padding:3px;margin:3px;font-weight:bold'>\n\t\t{warning_wireless_nic}\n\t\t</div>";
    }
    $html = "\n\t<div style='background-color:#F7F7F7;border:1px solid #676767;padding:3px;margin:3px'>\n\t{$text_ip}\n\t</div>\n\t<div style='background-color:#F7F7F7;border:1px solid #676767;padding:3px;margin:3px'>\n\t{network_style}:<strong>{$type}</strong>\n\t</div>\n\t<div style='background-color:#F7F7F7;border:1px solid #676767;padding:3px;margin:3px'>\n\t{dns_servers}:\n\t{$dns_text}\n\t</div>\t\n\t\n\t<div style='margin:4px;text-align:right;'>\n\t\t{$button}\n\t</div>\n\t\n\t";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}