예제 #1
0
function ipconfig_routes(){
	$ip=new networking();
	$eth=$_GET["nic"];
	$nic=$_GET["nic"];
	$page=CurrentPageName();
	$arrayNic=$ip->GetNicInfos($eth);
	$page=CurrentPageName();
	$tpl=new templates();
	$ERROR_NO_PRIVS=$tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
	$users=new usersMenus();
	if($users->AsSystemAdministrator){$AsNetworksAdministrator=1;}else{$AsNetworksAdministrator=0;}

	$html="
	<center>
	<table style='width:100px' class=form id='routes-$eth'>
		<tr>
			<td class=legend width=1% nowrap>{from_ip_address}:</td>
			<td width=1% nowrap>" . Field_text('ip_1',null,'width:35px;font-size:13px;padding:3px')."</td>
			<td style='font-size:13px' width=1% nowrap>.</td>
			<td width=1% nowrap>" . Field_text('ip_2',null,'width:35px;font-size:13px;padding:3px')."</td>
			<td style='font-size:13px' width=1% nowrap>.</td>
			<td width=1% nowrap>" . Field_text('ip_3',null,'width:35px;font-size:13px;padding:3px')."</td>
			<td style='font-size:13px' width=1% nowrap>.</td>
			<td style='font-size:13px' width=1% nowrap><strong>0</strong></td>	 
		 </tr>
		 <tr>
			<td class=legend>{netmask}:</td>
			<td width=1% nowrap>" . Field_text('mask_1',null,'width:35px;font-size:13px;padding:3px')."</td>
			<td style='font-size:13px' width=1% nowrap>.</td>
			<td width=1% nowrap>" . Field_text('mask_2',null,'width:35px;font-size:13px;padding:3px')."</td>
			<td style='font-size:13px' width=1% nowrap>.</td>
			<td width=1% nowrap>" . Field_text('mask_3',null,'width:35px;font-size:13px;padding:3px')."</td>
			<td style='font-size:13px' width=1% nowrap>.</td>
			<td width=1% nowrap>" . Field_text('mask_4',null,'width:35px;font-size:13px;padding:3px')."</td>
		 </tr>
		<tr>
			<td class=legend width=1% nowrap>{gateway}:</td>
			<td width=1% nowrap>" . Field_text('gw_1',null,'width:35px;font-size:13px;padding:3px')."</td>
			<td style='font-size:13px' width=1% nowrap>.</td>
			<td width=1% nowrap>" . Field_text('gw_2',null,'width:35px;font-size:13px;padding:3px')."</td>
			<td style='font-size:13px' width=1% nowrap>.</td>
			<td width=1% nowrap>" . Field_text('gw_3',null,'width:35px;font-size:13px;padding:3px')."</td>
			<td style='font-size:13px' width=1% nowrap>.</td>
			<td width=1% nowrap>" . Field_text('gw_4',null,'width:35px;font-size:13px;padding:3px')."</td>	 
		</tr>	
			<td colspan=8 align='right' ><hr>". button("{add}","AddRouteIpNic{$_GET["nic"]}()")."</td>
		</tr>		 				
	</table>	
	</center>
	
	<div id='routes-list-{$_GET["nic"]}' style='height:225px;width:100%;overflow:auto'></div>
	
	<script>
		var x_AddRouteIpNic{$_GET["nic"]}= function (obj) {
			var results=obj.responseText;
			if(results.length>0){alert(results);return;}
			RefreshTab('main_config_$nic');
			
			
			}		
	
	
		function AddRouteIpNic{$_GET["nic"]}(){
			var AsNetworksAdministrator='$AsNetworksAdministrator';
			if(AsNetworksAdministrator!=='1'){alert('$ERROR_NO_PRIVS');return;}				
			var XHR=XHRParseElements('routes-{$_GET["nic"]}');
			XHR.appendData('add-routes','yes');
			XHR.appendData('eth','{$_GET["nic"]}');
			XHR.appendData('nic','{$_GET["nic"]}');
			XHR.sendAndLoad('$page', 'GET',x_AddRouteIpNic{$_GET["nic"]});		
		
		}
	
	LoadAjax('routes-list-{$_GET["nic"]}','$page?ifconfig-route-list=yes&nic={$_GET["nic"]}');
	</script>";
	echo $tpl->_ENGINE_parse_body($html);	
	
}
예제 #2
0
function Bridges_list(){
	
	
	$t=$_GET["t"];
	$tpl=new templates();
	$MyPage=CurrentPageName();
	$q=new mysql();
	$users=new usersMenus();
	$sock=new sockets();
	$xtime=$_GET["xtime"];
	$table="iptables_bridge";
	$search='%';
	$database="artica_backup";	
	$page=1;
	$FORCE_FILTER=null;
	$tcp=new networking();
	
	if(!$q->TABLE_EXISTS($table, $database)){json_error_show("`$table` doesn't exists...");}
	if($q->COUNT_ROWS($table, $database)==0){json_error_show("No rule");}

	if(isset($_POST["sortname"])){if($_POST["sortname"]<>null){$ORDER="ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";}}	
	if(isset($_POST['page'])) {$page = $_POST['page'];}
	
	$searchstring=string_to_flexquery();
	if($searchstring<>null){
		$sql="SELECT COUNT(*) as TCOUNT FROM $table WHERE 1 $FORCE_FILTER $searchstring";
		$ligne=mysql_fetch_array($q->QUERY_SQL($sql,$database));
		$total = $ligne["TCOUNT"];
		
	}else{
		$sql="SELECT COUNT(*) as TCOUNT FROM $table WHERE 1 $FORCE_FILTER";
		$ligne=mysql_fetch_array($q->QUERY_SQL($sql,$database));
		$total = $ligne["TCOUNT"];
	}
	
	if (isset($_POST['rp'])) {$rp = $_POST['rp'];}	
	

	
	$pageStart = ($page-1)*$rp;
	$limitSql = "LIMIT $pageStart, $rp";
	
	$sql="SELECT *  FROM $table WHERE 1 $searchstring $FORCE_FILTER $ORDER $limitSql";	
	writelogs($sql,__FUNCTION__,__FILE__,__LINE__);
	$results = $q->QUERY_SQL($sql,$database);
	
	$data = array();
	$data['page'] = $page;
	$data['total'] = $total;
	$data['rows'] = array();
	
	if(!$q->ok){json_error_show($q->mysql_error);}	

	while ($ligne = mysql_fetch_assoc($results)) {
	$zmd5=md5(serialize($ligne));
	$color="black";
	$ipaddrinfos=VirtualNicInfosIPaddr($ligne["nics_virtuals_id"]);
	$nic_linked=$ligne["nic_linked"];
	$infos=$tcp->GetNicInfos($nic_linked);	
	$rulesIcon=imgsimple("script-32.png","{rules}","BridgeRules({$ligne["ID"]})");
	$delete=imgsimple("delete-24.png","{delete}","BridgeDelete({$ligne["ID"]},'$zmd5')");
	$data['rows'][] = array(
		'id' => "$zmd5",
		'cell' => array(
			"<span style='font-size:16px;color:$color'><img src='img/folder-network-32.png'></span>",
			"<span style='font-size:16px;color:$color'>{$ipaddrinfos["ETH"]} ({$ipaddrinfos["IPADDR"]})</span>",
			"<span style='font-size:16px;color:$color'><img src='img/arrow-right-32.png'></span>",
			"<span style='font-size:16px;color:$color'>$nic_linked ({$infos["IPADDR"]})</strong></span>",
			"<span style='font-size:16px;color:$color'>$rulesIcon</span>",
			"<span style='font-size:16px;color:$color'>$delete</span>",
			)
		);
	}
	
	
echo json_encode($data);

}
예제 #3
0
function Networks()
{
    $nics = new networking();
    $array = $nics->Local_interfaces();
    $array = DetectSubNics($array);
    while (list($nic, $null) = each($array)) {
        usleep(35000);
        $nics->ifconfig($nic);
        $res = $nics->GetNicInfos($nic);
        $array_returned[] = $res;
    }
    if ($GLOBALS["VERBOSE"]) {
        print_r($array_returned);
    }
    return base64_encode(serialize($array_returned));
}
예제 #4
0
function net_control_center_popup(){
	
	$sock=new sockets();
	$SquidActHasReverse=$sock->GET_INFO("SquidActHasReverse");
	if($SquidActHasReverse==1){net_control_center_reverse_popup();exit;}
	
	$ip=new networking();
	$squid=new squidbee();
	$count_dns=0;
	if(is_array($squid->dns_array)){
		while (list ($num, $val) = each ($squid->dns_array)){
			if($val==null){continue;}
			$count_dns=$count_dns+1;
			$dns=$dns."<tr><td width=1%><img src='img/fw_bold.gif'></td><td width=99%><strong>$val</strong></td></tr>";
		}
		
	}
	
	if($count_dns==0){
		
		if(is_array($ip->arrayNameServers)){
			while (list ($num, $val) = each ($ip->arrayNameServers)){
				if($val==null){continue;}
				$count_dns=$count_dns+1;
				$dns=$dns."<tr><td width=1%><img src='img/fw_bold.gif'></td><td width=99%><strong>$val</strong></td></tr>";
			}
			
		}
	}
	
	if($count_dns>0){
		$dns_div="<div style='position:absolute;top:300px;left:420px'>
		<strong>{nic_static_dns}</strong>
		<table style='width:50px'>
		$dns
		</table>
		</div>";
	}
	
	if(count($squid->network_array)==0){
		$network_t="<tr><td width=1%><img src='img/fw_bold.gif'></td><td width=99%><strong>{error_miss_datas}</strong></td></tr>";
	}else{
		while (list ($num, $val) = each ($squid->network_array)){
			$network_t=$network_t."<tr><td width=1%><img src='img/fw_bold.gif'></td><td width=99%><strong>$val</strong></td></tr>";
		}
	}
	
	
	$proxy_port=
	"<div style='position:absolute;top:160px;left:90px'>
	<a href=\"javascript:Loadjs('squid.popups.php?script=listen_port')\"><strong>{listen_port}:$squid->listen_port</strong></a>
	</div>";
	
	if(is_array($ip->array_TCP)){
		while (list ($num, $val) = each ($ip->array_TCP)){
			$array=$ip->GetNicInfos($num);
			if($array["GATEWAY"]==null){continue;}
			if($array["GATEWAY"]=="0.0.0.0"){continue;}
			$gw=$gw."<tr><td width=1%><img src='img/fw_bold.gif'></td><td width=99%><strong>{$array["GATEWAY"]}</strong></td></tr>";
		}
	}

$gayteway="
	<div style='position:absolute;top:170px;left:320px'><img src='img/gateway.png'></div>
	<div style='position:absolute;top:110px;left:280px'>
		<strong>{gateway}</a></strong>
		<table style='width:150px'>
		$gw
		</table>
		</div>";	
	

if($squid->hasProxyTransparent){
$gw=null;	
if(is_array($ip->array_TCP)){
	reset($ip->array_TCP);
		while (list ($num, $val) = each ($ip->array_TCP)){
			if($val==null){continue;}
			$gw=$gw."<tr><td width=1%><img src='img/fw_bold.gif'></td><td width=99%><strong>$val</strong></td></tr>";
		}
	}

	$transparent="<div style='position:absolute;top:120px;left:90px'><strong style='color:red'>{transparent_mode}</strong></div>";
	
	$gayteway="
	
	<div style='position:absolute;top:420px;left:280px'>
		<strong>{gateway}&nbsp;<span class=caption>({should_connected_to})</a></span></strong>
		<table style='width:150px'>
		$gw
		</table>
		</div>";
}



	
	
$network_d="
	<div style='position:absolute;top:420px;left:120px'>
		<strong><a href=\"javascript:Loadjs('squid.popups.php?script=network')\">{your_network}</a></strong>
		<table style='width:150px'>
		$network_t
		</table>
		</div>";	


 $panel="<div style='position:absolute;top:80px;left:600px;width:230px;'>
 <table style='width:100%'>
 <tr>
 	<td valign='top'>" . Paragraphe('folder-realyrules-64.png','{your_network}','{your_network_text}',"javascript:Loadjs('squid.popups.php?script=network')")."</td>
 </tr>
	<td valign='top'>" . Paragraphe('folder-network-64.png','{listen_port}','{listen_port_text}',"javascript:Loadjs('squid.popups.php?script=listen_port')")."</td>

	<tr>
<td valign='top'>" . Paragraphe('relayhost.png','{transparent_mode}','{transparent_mode_text}',"javascript:Loadjs('$page?squid-transparent-js=yes')")."</td>
</tr>
 </table>
 </div>";
	
	$html="<H1>{your_network_loupe}</H1>
	<div style='width:100%;background-image:url(img/squid-net-550.png);height:481px;background-repeat:no-repeat'>
	$transparent$gayteway$dns_div$network_d$proxy_port$panel
	</div>
	
	
	";
	

	
	$tpl=new templates();
		echo $tpl->_ENGINE_parse_body($html,'squid.index.php');
}
예제 #5
0
function server_settings()
{
    $vpn = new openvpn();
    $nic = new networking();
    $sock = new sockets();
    $OpenVpnPasswordCert = $sock->GET_INFO("OpenVpnPasswordCert");
    if ($OpenVpnPasswordCert == null) {
        $OpenVpnPasswordCert = "MyKey";
    }
    //openvpn_access_interface
    $DEV_TYPE = $vpn->main_array["GLOBAL"]["DEV_TYPE"];
    $dev = Field_array_Hash(array("tun" => "{routed_IP_tunnel}", "tap0" => "{ethernet_tunnel}"), "DEV_TYPE", $vpn->main_array["GLOBAL"]["DEV_TYPE"], "OpenVPNChangeServerMode()", null, 0, 'font-size:16px;padding:3px');
    $dev = "{routed_IP_tunnel}<input type='hidden' name='DEV_TYPE' id='DEV_TYPE' value='tun'>";
    if ($vpn->main_array["GLOBAL"]["IP_START"] == null) {
        $vpn->main_array["GLOBAL"]["IP_START"] = "10.8.0.0";
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $vpn->main_array["GLOBAL"]["NETMASK"] = "255.255.255.0";
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $openvpn_local = null;
    }
    $CLIENT_NAT_PORT = $vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"];
    if ($CLIENT_NAT_PORT == null) {
        $CLIENT_NAT_PORT = $vpn->main_array["GLOBAL"]["LISTEN_PORT"];
    }
    $vpn->main_array["GLOBAL"]["PUBLIC_IP"];
    $vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"];
    $vpn->main_array["GLOBAL"]["LISTEN_PORT"];
    $vpn->main_array["GLOBAL"]["LISTEN_PROTO"];
    $vpn->main_array["GLOBAL"]["ENABLE_SERVER"];
    $vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"];
    $vpn->main_array["GLOBAL"]["IP_START"];
    $vpn->main_array["GLOBAL"]["IPTABLES_ETH"];
    if ($vpn->main_array["GLOBAL"]["PUBLIC_IP"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{public_ip_addr}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["LISTEN_PORT"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{listen_port}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{listen_port}:{public_ip_addr}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["IP_START"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{from_ip_address}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{netmask}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["LISTEN_PROTO"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{protocol}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["IP_START"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{from_ip_address}</strong></p>";
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $status = "<p class=text-error style='font-size:18px'><strong>{MISSING_PARAMETER}</strong><br>{MISSING_PARAMETER_TEXT}<br><strong>{netmask}</strong></p>";
    }
    $LDAP_AUTH = "{no}";
    $EnableOpenVPNEndUserPage = "{no}";
    if ($vpn->main_array["GLOBAL"]["LDAP_AUTH"] == 1) {
        $LDAP_AUTH = "{yes}";
    }
    if ($sock->GET_INFO("EnableOpenVPNEndUserPage") == 1) {
        $EnableOpenVPNEndUserPage = "{yes}";
    }
    $wake_up_ip = $vpn->main_array["GLOBAL"]["WAKEUP_IP"];
    $tcp_ip = new ip();
    if (!$tcp_ip->isValid($wake_up_ip)) {
        $wake_up_ip = "{disabled}";
    }
    if (!$tcp_ip->isValid($vpn->main_array["GLOBAL"]["PUBLIC_IP"])) {
        $vpn->main_array["GLOBAL"]["PUBLIC_IP"] = "0.0.0.0";
    }
    $ahref_edit = "<a href=\"javascript:blur();\" OnClick=\"Loadjs('index.openvpn.server.php');\" style='font-size:16px;text-decoration:underline'>";
    $button_edit = button("{change_settings}", "Loadjs('index.openvpn.server.php')", 34);
    if ($vpn->main_array["GLOBAL"]["LOCAL_BIND"] == null) {
        $vpn->main_array["GLOBAL"]["LOCAL_BIND"] = "{none}";
    }
    $openvpn_local = "\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:20px'>{openvpn_local}</a>:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:20px'>{$vpn->main_array["GLOBAL"]["LOCAL_BIND"]}</a></td>\n\t\t\t</tr>";
    $mandatories = "<table style='width:99%'>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:20px'>{listen_port}:</a></td>\n\t\t\t\t<td style='font-weight:bold;font-size:20px;width:850px'>{$vpn->main_array["GLOBAL"]["LISTEN_PORT"]}&nbsp;{$vpn->main_array["GLOBAL"]["LISTEN_PROTO"]}</a></td>\n\t\t\t</tr>\n\t\t\t{$openvpn_local}\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:20px'>{public_ip_addr}</a>:</td>\n\t\t\t\t<td style='font-weight:bold;font-size:20px;'>{$vpn->main_array["GLOBAL"]["PUBLIC_IP"]}:{$CLIENT_NAT_PORT}</a></td>\n\t\t\t<tr>\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:20px'>{password}:</a></td>\n\t\t\t\t<td style='font-weight:bold;font-size:20px'>*****</a></td>\n\t\t\t<tr>\n\t\t\t</table>";
    $proxy = "{no}";
    if ($vpn->main_array["GLOBAL"]["USE_RPROXY"] == 1) {
        $proxy = "{$vpn->main_array["GLOBAL"]["PROXYADDR"]}:{$vpn->main_array["GLOBAL"]["PROXYPORT"]}";
    }
    if ($vpn->main_array["GLOBAL"]["IPTABLES_ETH"] == null) {
        $vpn->main_array["GLOBAL"]["IPTABLES_ETH"] = "{no}";
    }
    $mode_tun = "<table style='width:99%'>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{enable_authentication}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px;;width:850px'>{$LDAP_AUTH}</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{EnableOpenVPNEndUserPage}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$EnableOpenVPNEndUserPage}</td>\n\t\t<td>&nbsp;</td>\n\t<tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{reverse_proxy}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$proxy}</td>\n\t<tr>\t\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{from_ip_address}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$vpn->main_array["GLOBAL"]["IP_START"]}</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{netmask}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$vpn->main_array["GLOBAL"]["NETMASK"]}</a></td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{openvpn_access_interface}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$vpn->main_array["GLOBAL"]["IPTABLES_ETH"]}</a></td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:20px'>{wake_up_ip}</a>:</td>\n\t\t<td style='font-weight:bold;font-size:20px'>{$wake_up_ip}</a></td>\n\t</tr>\t\n\t\n</table>";
    $VPN_SERVER_IP = $vpn->main_array["GLOBAL"]["VPN_SERVER_IP"];
    $VPN_DHCP_FROM = $vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"];
    $VPN_DHCP_TO = $vpn->main_array["GLOBAL"]["VPN_DHCP_TO"];
    $tcp = new networking();
    if ($vpn->main_array["GLOBAL"]["BRIDGE_ETH"] == null) {
        $vpn->main_array["GLOBAL"]["BRIDGE_ETH"] = "eth0";
    }
    $array_ip = $tcp->GetNicInfos($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
    if ($vpn->main_array["GLOBAL"]["VPN_SERVER_IP"] == null) {
        $vpn->main_array["GLOBAL"]["VPN_SERVER_IP"] = $array_ip["IPADDR"];
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $vpn->main_array["GLOBAL"]["NETMASK"] = $array_ip["NETMASK"];
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $nics = Field_array_Hash($vpn->virtual_ip_lists(), 'BRIDGE_ETH', $vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
    }
    $mode_tap = "\n\t<div style='width:100%;margin-bottom:5px'>\n\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td valign='top'>\n\t\t\t\t\t<div id='nicvpninfo' style='float:right;margin:5px;'>" . ShowIPConfig($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]) . "</div>\n\t\t\t\t</td>\n\t\t\t\t<td valign='top'>\n\t\t\t\t\t<div class=explain>{SERVER_MODE_TAP}</div>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t</div>\n<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:20px'>{BRIDGE_ETH}:</td>\n\t\t<td width=1% nowrap>{$nics}</td>\n\t\t<td align='left' style='font-weight:bold;font-size:20px' width=1% nowrap>" . texttooltip("{add_virtual_ip_address}", "{add_virtual_ip_address}", "Loadjs('system.nic.config.php?js-add-nic=yes')", null, 0, "font-size:16px;padding:3px") . "</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:20px'>{BRIDGE_ADDR}:</td>\n\t\t<td width=1% style='font-weight:bold;font-size:20px' nowrap >" . Field_text('BRIDGE_ADDR', $vpn->main_array["GLOBAL"]["BRIDGE_ADDR"], 'width:120px;font-size:16px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:20px'>{VPN_DHCP_FROM}:</td>\n\t\t<td width=1% style='font-weight:bold;font-size:20px' nowrap>" . Field_text('VPN_DHCP_FROM', $vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"], 'width:120px;font-size:16px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:20px'>{VPN_DHCP_TO}:</td>\n\t\t<td width=1% style='font-weight:bold;font-size:20px' nowrap>" . Field_text('VPN_DHCP_TO', $vpn->main_array["GLOBAL"]["VPN_DHCP_TO"], 'width:120px;font-size:16px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\t\t\n\t<tr>\n\t\t<td colspan=3 align='right'><hr>" . button("{apply}", "SaveServerSettings()") . "</td>\n\t</tr>\t\t\t\t\n</table>\n";
    $mode = $mode_tun;
    if ($vpn->main_array["GLOBAL"]["DEV_TYPE"] == "tap0") {
        $mode = $mode_tap;
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $mode = $mode_tap;
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_SERVER"] != 1) {
        $status = FATAL_ERROR_SHOW_128("<strong style='font-size:22px'>{OPENVPN_NOT_ENABLED}</strong><hr>\n\t\t\t{OPENVPN_NOT_ENABLED_TEXT}\n\t\t\t") . "<center style='margin:30px'>" . button("{enable_service}", "Loadjs('index.openvpn.enable.progress.php')", 42) . "</center>";
    }
    if ($status == null) {
        $button_apply = button("{OPENVPN_APPLY_CONFIG}", "Loadjs('index.openvpn.enable.progress.php')", 34) . "&nbsp;|&nbsp;";
    }
    $html = "\n<div style='font-size:28px;margin-bottom:30px'>{OPENVPN_SERVER_SETTINGS}</div>\n{$status}\n<div style='width:98%' class=form>\n\n\n<div id='OPENVPN_SERVER_SETTINGS'>\n<div style='text-align:right'>{$button_script}</div>\n{$mandatories}\n{$mode}\n<div style='margin-top:15px;text-align:right;font-size:34px'><hr>{$button_apply}{$button_edit}</div>\t\n</div>\n";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
    // openvpn --remote touzeau.ath.cx --port 1194 --dev tun --comp-lzo --tls-client --ca /home/dtouzeau/ca.crt --cert /home/dtouzeau/dtouzeau.crt --key /home/dtouzeau/dtouzeau.key --verb 5 --pull
}
function bridge_search()
{
    $boot = new boostrap_form();
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $q = new mysql();
    $table = "iptables_bridge";
    $database = "artica_backup";
    $t = time();
    $ORDER = $boot->TableOrder(array("ID" => "DESC"));
    $sock = new sockets();
    $net = new networking();
    $ip = new IP();
    $interfaces = unserialize(base64_decode($sock->getFrameWork("cmd.php?ifconfig-interfaces=yes")));
    $searchstring = string_to_flexquery("search-bridge");
    $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250";
    $results = $q->QUERY_SQL($sql, $database);
    if (!$q->ok) {
        senderrors($q->mysql_error . "<br>{$sql}");
    }
    $net = new networking();
    while ($ligne = mysql_fetch_assoc($results)) {
        $md = md5(serialize($ligne));
        $ip = new IP();
        $img = "folder-network-48.png";
        $cdir = $ligne["cdir"];
        $eth = "br{$ligne["ID"]}";
        $eth_text = "br{$ligne["ID"]}";
        $array = $net->GetNicInfos($ligne["nic_inbound"]);
        $nic_inbound_ip = $array["IPADDR"];
        $array = $net->GetNicInfos($ligne["nic_linked"]);
        $nic_linked_ip = $array["IPADDR"];
        $delete = imgsimple("delete-48.png", "{delete}", "Delete{$t}('{$ligne["ID"]}','{$md}')");
        $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t\t<td style='font-size:18px' width=1% nowrap><img src='img/{$img}'></td>\n\t\t\t<td style='font-size:18px' width=1% nowrap>{$ligne["nic_inbound"]} - {$nic_inbound_ip}</td>\n\t\t\t<td style='font-size:18px' width=10% nowrap>{$ligne["nic_linked"]} - {$nic_linked_ip}</td>\n\t\t\t<td style='font-size:18px' width=1% nowrap>{$delete}</td>\n\t\t</tr>\n\t\t";
    }
    $delete_text = $tpl->javascript_parse_text("{delete_nic_bridge}");
    echo $boot->TableCompile(array("ID" => "ID", "nic_inbound" => "{from}", "nic_linked" => "{to}", "delete" => null), $tr) . "\n\t\t\t\t\t\n<script>\nvar mem{$t}='';\nvar xDelete{$t}=function(obj){\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue);return;}\n\t\$('#'+mem{$t}).remove();\n}\nfunction Delete{$t}(ID,mem){\n\tmem{$t}=mem;\n\tif(confirm('{$delete_text} ID: '+ID+'?')){\n\t\tmem{$t}=mem;\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('bridge-delete',ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t\t}\n\t}\n</script>\t\t\t\t\t\n";
}
예제 #7
0
function ipconfig_routes_add_popup(){
	$ip=new networking();
	$eth=$_GET["nic"];
	$nic=$_GET["nic"];
	$t=$_GET["t"];
	$page=CurrentPageName();
	$arrayNic=$ip->GetNicInfos($eth);
	$page=CurrentPageName();
	$tpl=new templates();
	$ERROR_NO_PRIVS=$tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
	$users=new usersMenus();
	if($users->AsSystemAdministrator){$AsNetworksAdministrator=1;}else{$AsNetworksAdministrator=0;}

	$html="
	<center style='margin:20px'>
	<div id='id='routes-$eth'></div>
	<div style='width:98%' class=form>
	<table style='width:100%' >
		<tr>
			<td class=legend width=1% nowrap style='font-size:16px'>{from_ip_address}:</td>
			<td width=1% nowrap>" . field_ipv4("route-network-$t", null,"font-size:16px")."</td>
		 </tr>
		 <tr>
			<td class=legend style='font-size:16px'>{netmask}:</td>
			<td width=1% nowrap>" . field_ipv4("route-mask-$t", null,"font-size:16px")."</td>
		 </tr>
		<tr>
			<td class=legend width=1% nowrap style='font-size:16px'>{gateway}:</td>
			<td width=1% nowrap>" . field_ipv4("route-gateway-$t", null,"font-size:16px")."</td>	 
		</tr>	
			<td colspan=8 align='right' ><hr>". button("{add}","AddRouteIpNic$t()",18)."</td>
		</tr>		 				
	</table>	
	</div>
	</center>
<script>
var x_AddRouteIpNic$t= function (obj) {
	var results=obj.responseText;
	if(results.length>0){alert(results);return;}
	YahooWin6Hide();
	$('#flexRT$t').flexReload();
}		
	
	
function AddRouteIpNic$t(){
	var AsNetworksAdministrator='$AsNetworksAdministrator';
	if(AsNetworksAdministrator!=='1'){alert('$ERROR_NO_PRIVS');return;}	
	var XHR = new XHRConnection();				
	XHR.appendData('add-routes','yes');
	XHR.appendData('eth','{$_GET["nic"]}');
	XHR.appendData('nic','{$_GET["nic"]}');
	XHR.appendData('route-network',document.getElementById('route-network-$t').value);
	XHR.appendData('route-mask',document.getElementById('route-mask-$t').value);
	XHR.appendData('route-gateway',document.getElementById('route-gateway-$t').value);
	XHR.sendAndLoad('$page', 'POST',x_AddRouteIpNic$t);		
}
</script>";
	echo $tpl->_ENGINE_parse_body($html);	
	
}
예제 #8
0
function ipconfig()
{
    $sock = new sockets();
    $ip = new networking();
    $eth = $_GET["ipconfig"];
    $page = CurrentPageName();
    $array = $ip->GetNicInfos($eth);
    $dns = $sock->getFrameWork('cmd.php?dnslist=yes');
    $dnslist = explode(";", $dns);
    if (is_array($dnslist)) {
        while (list($num, $val) = each($dnslist)) {
            if (trim($val) != null) {
                $dns_text[] = $val;
            }
        }
    }
    if ($array["BOOTPROTO"] == 'dhcp' or $array["BOOTPROTO"] == null) {
        $DISABLED = true;
        $dhcp = 'yes';
    }
    $html = "\n\t<form name='ffm{$eth}'>\n\t<table style='width:100%'>\n\t<input type='hidden' name='save_nic' id='save_nic' id='save_nic' value='{$eth}'>\n\t\n\t\n\t<tr>\n\t<td class=legend>{use_dhcp}:</td>\n\t<td width=1%>" . Field_yesno_checkbox('dhcp', $dhcp, 'SwitchDHCP()') . "</td>\n\t</tr>\n\t\n\t\n\t</tr>\n\t</table>\n\t\n\t<div style='background-color:#F7F7F7;border:1px solid #676767;padding:3px;margin:3px'>\n\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td class=legend>{proto}:</td>\n\t\t\t<td>{$array["BOOTPROTO"]}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend>{tcp_address}:</td>\n\t\t\t<td>" . Field_text("IPADDR", $array["IPADDR"], 'width:100px', null, null, null, false, null, $DISABLED) . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend>{netmask}:</td>\n\t\t\t<td>" . Field_text("NETMASK", $array["NETMASK"], 'width:100px', null, null, null, false, null, $DISABLED) . "</td>\n\t\t</tr>\t\n\t\t<tr>\n\t\t\t<td class=legend>{gateway}:</td>\n\t\t\t<td>" . Field_text("GATEWAY", $array["GATEWAY"], 'width:100px', null, null, null, false, null, $DISABLED) . "</td>\n\t\t</tr>\n\t\n\t\t\n\t</table>\n\t</div>\t\n\t<br>\n\t<div style='background-color:#F7F7F7;border:1px solid #676767;padding:3px;margin:3px'>\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend>{primary_dns}:</td>\n\t\t<td>" . Field_text("DNS_1", $dns_text[0], 'width:100px', null, null, null, false, null) . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend>{secondary_dns}:</td>\n\t\t<td>" . Field_text("DNS_2", $dns_text[1], 'width:100px', null, null, null, false, null) . "</td>\n\t</tr>\t\n\t</table>\n\t\t\n\t\n\t</div>\n\t<table style='width:100%'>\n\t<tr>\n\t<td align='right'>\n\t\t" . button("{edit}", "SaveNicSettings()") . "&nbsp;&nbsp;" . button("{cancel}", "YahooWin2(300,'{$page}?netconfig={$eth}','{$eth}','');") . "\n\t</td>\n\t</tr>\n\t</table>\n\t<script>\n\t\n\t\tvar X_SaveNicSettings= function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tvar ipaddr=document.getElementById('IPADDR').value;\n\t\t\talert(results+'\\n'+'<https://'+ipaddr+':{$_SERVER['SERVER_PORT']}>');\n\t\t\tsetTimeout(\"logofff()\",15000);\n\t\t\t}\n\n\t\tfunction logofff(){\n\t\t\tvar ipaddr=document.getElementById('IPADDR').value;\n\t\t\tdocument.location.href='https://'+ipaddr+':{$_SERVER['SERVER_PORT']}';\n\t\t}\n\t\n\t\tfunction SaveNicSettings(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tif(document.getElementById('dhcp').checked){XHR.appendData('dhcp','yes');}else{XHR.appendData('dhcp','no');}\n\t\t\tXHR.appendData('IPADDR',document.getElementById('IPADDR').value);\n\t\t\tXHR.appendData('NETMASK',document.getElementById('NETMASK').value);\n\t\t\tXHR.appendData('GATEWAY',document.getElementById('GATEWAY').value);\n\t\t\tXHR.appendData('DNS_1',document.getElementById('DNS_1').value);\n\t\t\tXHR.appendData('DNS_2',document.getElementById('DNS_2').value);\n\t\t\tXHR.appendData('save_nic',document.getElementById('save_nic').value);\n\t\t\tXHR.sendAndLoad('{$page}', 'GET',X_SaveNicSettings);\n\t\t\t\n\t\t}\n\t\n\t</script>\t\n\t";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
예제 #9
0
function Bridges_list()
{
    $html = "<table cellspacing='0' cellpadding='0' border='0' class='tableView'>\n<thead class='thead'>\n\t<tr>\n\t<th colspan=2  nowrap>{from}</th>\n\t<th nowrap>&nbsp;</th>\n\t<th colspan=2 nowrap>{to}</th>\n\t<th>{rules}</th>\n\t<th nowrap>{delete}</th>\n\t</tr>\n</thead>";
    $sql = "SELECT * FROM iptables_bridge ORDER BY ID DESC";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        if (preg_match("#doesn't exist#", $q->mysql_error)) {
            $q->BuildTables();
            echo "<script>BridgeRefresh();</script>";
        }
        echo "<H2>{$q->mysql_error}</H2>";
    }
    $tcp = new networking();
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $ipaddrinfos = VirtualNicInfosIPaddr($ligne["nics_virtuals_id"]);
        $nic_linked = $ligne["nic_linked"];
        $infos = $tcp->GetNicInfos($nic_linked);
        $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t\t<td width=1% style='padding:3px'><img src='img/folder-network-32.png'></td>\n\t\t\t<td width=33%><strong style='font-size:14px'>{$ipaddrinfos["ETH"]} ({$ipaddrinfos["IPADDR"]})</strong></td>\n\t\t\t<td width=33% style='padding:3px' align='center'><img src='img/arrow-right-32.png'></td>\n\t\t\t<td width=1% style='padding:3px'><img src='img/folder-network-32.png'></td>\n\t\t\t<td width=33% nowrap><strong style='font-size:14px'>{$nic_linked} ({$infos["IPADDR"]})</strong></td>\n\t\t\t<td width=1% align=center>" . imgtootltip("script-32.png", "{rules}", "BridgeRules({$ligne["ID"]})") . "</td>\n\t\t\t<td width=1% align=center>" . imgtootltip("delete-24.png", "{delete}", "BridgeDelete({$ligne["ID"]})") . "</td>\n\t\t\t\n\t\t</tr>";
    }
    $html = $html . "</table>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
예제 #10
0
function GetMyDefaultGateway($eth)
{
    if (is_array($GLOBALS["IPDEF-{$eth}"])) {
        return $GLOBALS["IPDEF-{$eth}"]["GATEWAY"];
    }
    $ip = new networking();
    $GLOBALS["IPDEF-{$eth}"] = $ip->GetNicInfos($eth);
    return $GLOBALS["IPDEF-{$eth}"]["GATEWAY"];
}
예제 #11
0
function server_settings()
{
    $vpn = new openvpn();
    $nic = new networking();
    $restart = button("{APP_OPENVPN_APPLY}", "YahooWin3(500,\"index.openvpn.php?restart-server=yes\",\"windows:{APP_OPENVPN_APPLY}\");");
    $sock = new sockets();
    $OpenVpnPasswordCert = $sock->GET_INFO("OpenVpnPasswordCert");
    if ($OpenVpnPasswordCert == null) {
        $OpenVpnPasswordCert = "MyKey";
    }
    while (list($num, $ligne) = each($nic->array_TCP)) {
        if ($ligne == null) {
            continue;
        }
        $ips[$ligne] = "{$ligne} ({$num})";
        $arr[$num] = $num;
        $ipeth[$num] = "{$num} ({$ligne})";
    }
    $ips[null] = "{all}";
    $ipeth[null] = "{none}";
    $nics = Field_array_Hash($arr, 'BRIDGE_ETH', $vpn->main_array["GLOBAL"]["BRIDGE_ETH"], 'OpenVPNChangeNIC()');
    $ips = Field_array_Hash($ips, 'LOCAL_BIND', $vpn->main_array["GLOBAL"]["LOCAL_BIND"]);
    $IPTABLES_ETH = Field_array_Hash($ipeth, 'IPTABLES_ETH', $vpn->main_array["GLOBAL"]["IPTABLES_ETH"], null, null, 0, 'font-size:13px;padding:3px');
    //openvpn_access_interface
    $DEV_TYPE = $vpn->main_array["GLOBAL"]["DEV_TYPE"];
    $dev = Field_array_Hash(array("tun" => "{routed_IP_tunnel}", "tap0" => "{ethernet_tunnel}"), "DEV_TYPE", $vpn->main_array["GLOBAL"]["DEV_TYPE"], "OpenVPNChangeServerMode()", null, 0, 'font-size:13px;padding:3px');
    $dev = "{routed_IP_tunnel}<input type='hidden' name='DEV_TYPE' id='DEV_TYPE' value='tun'>";
    $protocol = Field_array_Hash(array("tcp" => "TCP", "udp" => "UDP"), "LISTEN_PROTO", $vpn->main_array["GLOBAL"]["LISTEN_PROTO"], null, null, 0, 'font-size:13px;padding:3px');
    if ($vpn->main_array["GLOBAL"]["IP_START"] == null) {
        $vpn->main_array["GLOBAL"]["IP_START"] = "10.8.0.0";
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $vpn->main_array["GLOBAL"]["NETMASK"] = "255.255.255.0";
    }
    $old = "\t\t\t<tr>\n\t\t\t\t<td colspan=2 align='right'>\n\t\t\t\t\t<input type='button' OnClick=\"javascript:WizardFindMyNetworksMask()\" value='{newtork_help_me}'>\n\t\t\t\t</td>\n\t\t\t</tr>";
    $entete = "\n<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:13px'>{enable_openvpn_server_mode}:</td>\n\t\t\t\t<td style='font-size:13px' width=1%>" . Field_checkbox('ENABLE_SERVER', '1', $vpn->main_array["GLOBAL"]["ENABLE_SERVER"]) . "</td>\n\t\t\t\t<td class=legend style='font-size:13px'>{tunnel_type}:</td>\n\t\t\t\t<td style='font-size:13px' nowrap>{$dev}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t<td class=legend style='font-size:13px'>{ethernet_tunnel}</td>\n\t\t\t\t<td style='font-size:13px' width=1%>" . Field_checkbox('ENABLE_BRIDGE', '1', $vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"], "OpenVPNChangeServerMode()") . "</td>\n\t\t\t\t\n\t\t\t</tr>\n</table>";
    $openvpn_local = "\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:13px'>{openvpn_local}:</td>\n\t\t\t\t<td>{$ips}&nbsp;</td>\n\t\t\t\t<td>" . help_icon("{openvpn_local_text}") . "</td>\n\t\t\t</tr>";
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $openvpn_local = null;
    }
    $mandatories = "<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:13px'>{listen_port}:</td>\n\t\t\t\t<td>" . Field_text('LISTEN_PORT', $vpn->main_array["GLOBAL"]["LISTEN_PORT"], 'width:90px;font-size:13px;padding:3px') . "&nbsp;{$protocol}</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t</tr>\n\t\t\t{$openvpn_local}\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:13px'>{public_ip_addr}:</td>\n\t\t\t\t<td>" . Field_text('PUBLIC_IP', $vpn->main_array["GLOBAL"]["PUBLIC_IP"], 'width:210px;;font-size:13px;padding:3px') . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t<tr>\t\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:13px'>{password}:</td>\n\t\t\t\t<td>" . Field_password('OpenVpnPasswordCert', $OpenVpnPasswordCert, 'width:210px;;font-size:13px;padding:3px') . "</td>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t<tr>\n\t\t\n\n\t\t\t\n\t\t\t\n</table>";
    $mode_tun = "<table style='width:100%'>\n\t<tr>\n\t\t<td colspan=2 ><br>\n\t\t\t<p class=caption style='font-size:13px'>{LOCAL_NETWORK} {SERVER_MODE_TUNE}</p>\n\t\t</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:13px'>{from_ip_address}:</td>\n\t\t<td>" . Field_text('IP_START', $vpn->main_array["GLOBAL"]["IP_START"], 'width:210px;font-size:13px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend style='font-size:13px'>{netmask}:</td>\n\t\t<td>" . Field_text('NETMASK', $vpn->main_array["GLOBAL"]["NETMASK"], 'width:210px;font-size:13px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:13px'>{openvpn_access_interface}:</td>\n\t\t<td>{$IPTABLES_ETH}</td>\n\t\t<td>" . help_icon("{openvpn_access_interface_text}") . "</td>\n\t</tr>\n\t\n\t\n\t\n\t\t\t<tr>\n\t\t\t\t<td colspan=2 align='right'>\n\t\t\t\t\t<hr>" . button("{apply}", "SaveServerSettings()") . "\n\t\t\t\t\t\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\t\n</table>";
    $VPN_SERVER_IP = $vpn->main_array["GLOBAL"]["VPN_SERVER_IP"];
    $VPN_DHCP_FROM = $vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"];
    $VPN_DHCP_TO = $vpn->main_array["GLOBAL"]["VPN_DHCP_TO"];
    $tcp = new networking();
    if ($vpn->main_array["GLOBAL"]["BRIDGE_ETH"] == null) {
        $vpn->main_array["GLOBAL"]["BRIDGE_ETH"] = "eth0";
    }
    $array_ip = $tcp->GetNicInfos($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
    if ($vpn->main_array["GLOBAL"]["VPN_SERVER_IP"] == null) {
        $vpn->main_array["GLOBAL"]["VPN_SERVER_IP"] = $array_ip["IPADDR"];
    }
    if ($vpn->main_array["GLOBAL"]["NETMASK"] == null) {
        $vpn->main_array["GLOBAL"]["NETMASK"] = $array_ip["NETMASK"];
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $nics = Field_array_Hash($vpn->virtual_ip_lists(), 'BRIDGE_ETH', $vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
    }
    $mode_tap = "\n<div style='width:100%;margin-bottom:5px'><div id='nicvpninfo' style='float:right;margin:5px;'>" . ShowIPConfig($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]) . "</div>\n\t\t\t<p class=caption>{SERVER_MODE_TAP}</p>\n\t\t</div>\n<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:13px'>{BRIDGE_ETH}:</td>\n\t\t<td width=1% nowrap>{$nics}</td>\n\t\t<td align='left' width=1% nowrap>" . texttooltip("{add_virtual_ip_address}", "{add_virtual_ip_address}", "Loadjs('system.nic.config.php?js-add-nic=yes')", null, 0, "font-size:13px;padding:3px") . "</td>\n\t<tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:13px'>{BRIDGE_ADDR}:</td>\n\t\t<td width=1% nowrap>" . Field_text('BRIDGE_ADDR', $vpn->main_array["GLOBAL"]["BRIDGE_ADDR"], 'width:120px;font-size:13px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:13px'>{VPN_DHCP_FROM}:</td>\n\t\t<td width=1% nowrap>" . Field_text('VPN_DHCP_FROM', $vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"], 'width:120px;font-size:13px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend nowrap style='font-size:13px'>{VPN_DHCP_TO}:</td>\n\t\t<td width=1% nowrap>" . Field_text('VPN_DHCP_TO', $vpn->main_array["GLOBAL"]["VPN_DHCP_TO"], 'width:120px;font-size:13px;padding:3px') . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td colspan=3 align='right'><hr>" . button("{apply}", "SaveServerSettings()") . "\n\t\t\t\t\t\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\t\t\n</table>\n";
    $mode = $mode_tun;
    if ($vpn->main_array["GLOBAL"]["DEV_TYPE"] == "tap0") {
        $mode = $mode_tap;
    }
    if ($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) {
        $mode = $mode_tap;
    }
    $html = "\n<div style='text-align:right;padding-bottom:4px'>{$restart}</div>\n<table style='width:100%'>\n<tr>\n<td valign='top'>\n<div id='OPENVPN_SERVER_SETTINGS'>\n\t\t{$entete}\n\t\t<hr>\n\t\t{$mandatories}\n\t\t<hr>\n\t\t{$mode}\n\t\t\n\t</div>\n</td>\n</tr>\n</table>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
    // openvpn --remote touzeau.ath.cx --port 1194 --dev tun --comp-lzo --tls-client --ca /home/dtouzeau/ca.crt --cert /home/dtouzeau/dtouzeau.crt --key /home/dtouzeau/dtouzeau.key --verb 5 --pull
}
예제 #12
0
function server_settings(){
	
$vpn=new openvpn();
$nic=new networking();
$sock=new sockets();
$OpenVpnPasswordCert=$sock->GET_INFO("OpenVpnPasswordCert");
if($OpenVpnPasswordCert==null){$OpenVpnPasswordCert="MyKey";}




//openvpn_access_interface

$DEV_TYPE=$vpn->main_array["GLOBAL"]["DEV_TYPE"];
	

$dev=Field_array_Hash(
	array("tun"=>"{routed_IP_tunnel}","tap0"=>"{ethernet_tunnel}"),
	"DEV_TYPE",$vpn->main_array["GLOBAL"]["DEV_TYPE"],
	"OpenVPNChangeServerMode()",null,0,'font-size:13px;padding:3px'
	);
	
	
$dev="{routed_IP_tunnel}<input type='hidden' name='DEV_TYPE' id='DEV_TYPE' value='tun'>";	
	

if($vpn->main_array["GLOBAL"]["IP_START"]==null){$vpn->main_array["GLOBAL"]["IP_START"]="10.8.0.0";}
if($vpn->main_array["GLOBAL"]["NETMASK"]==null){$vpn->main_array["GLOBAL"]["NETMASK"]="255.255.255.0";} 

			
				

if($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"]==1){$openvpn_local=null;}
$CLIENT_NAT_PORT=$vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"];

if($CLIENT_NAT_PORT==null){$CLIENT_NAT_PORT=$vpn->main_array["GLOBAL"]["LISTEN_PORT"];}
$vpn->main_array["GLOBAL"]["PUBLIC_IP"];
$vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"];
$vpn->main_array["GLOBAL"]["LISTEN_PORT"];
$vpn->main_array["GLOBAL"]["LISTEN_PROTO"];
$vpn->main_array["GLOBAL"]["ENABLE_SERVER"];
$vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"];
$vpn->main_array["GLOBAL"]["IP_START"];
$vpn->main_array["GLOBAL"]["IPTABLES_ETH"];

if($vpn->main_array["GLOBAL"]["PUBLIC_IP"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{public_ip_addr}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["LISTEN_PORT"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{listen_port}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["CLIENT_NAT_PORT"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{listen_port}:{public_ip_addr}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["IP_START"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{from_ip_address}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["NETMASK"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{netmask}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["LISTEN_PROTO"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{protocol}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["IP_START"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{from_ip_address}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
if($vpn->main_array["GLOBAL"]["NETMASK"]==null){
$status=LocalParagraphe("MISSING_PARAMETER","{MISSING_PARAMETER_TEXT}<br><strong>{netmask}</strong>","Loadjs('index.openvpn.server.php')","42-red.png");
}
$LDAP_AUTH="{no}";
$EnableOpenVPNEndUserPage="{no}";
if($vpn->main_array["GLOBAL"]["LDAP_AUTH"]==1){$LDAP_AUTH="{yes}";}
if($sock->GET_INFO("EnableOpenVPNEndUserPage")==1){$EnableOpenVPNEndUserPage="{yes}";}

$wake_up_ip=$vpn->main_array["GLOBAL"]["WAKEUP_IP"];
$tcp_ip=new ip();
if(!$tcp_ip->isValid($wake_up_ip)){$wake_up_ip="{disabled}";}


$ahref_edit="<a href=\"javascript:blur();\" OnClick=\"Loadjs('index.openvpn.server.php');\" style='font-size:13px;text-decoration:underline'>";

$openvpn_local="
			<tr>
				<td class=legend style='font-size:13px'>$ahref_edit{openvpn_local}</a>:</td>
				<td style='font-size:13px'>$ahref_edit{$vpn->main_array["GLOBAL"]["LOCAL_BIND"]}</a></td>
				<td>&nbsp;</td>
			</tr>";	



$mandatories="<table style='width:100%' class=form>
			<tr>
				<td class=legend style='font-size:13px'>$ahref_edit{listen_port}:</a></td>
				<td style='font-size:13px'>$ahref_edit{$vpn->main_array["GLOBAL"]["LISTEN_PORT"]}&nbsp;{$vpn->main_array["GLOBAL"]["LISTEN_PROTO"]}</a></td>
				<td>&nbsp;</td>
			</tr>
			$openvpn_local
			<tr>
				<td class=legend style='font-size:13px'>$ahref_edit{public_ip_addr}</a>:</td>
				<td style='font-size:13px;'>$ahref_edit{$vpn->main_array["GLOBAL"]["PUBLIC_IP"]}:$CLIENT_NAT_PORT</a></td>
				<td>&nbsp;</td>
			<tr>	
			<tr>
				<td class=legend style='font-size:13px'>$ahref_edit{password}:</a></td>
				<td style='font-size:13px'>$ahref_edit*****</a></td>
				<td>&nbsp;</td>
			<tr>
			</table>";
$proxy="{no}";
if($vpn->main_array["GLOBAL"]["USE_RPROXY"]==1){
	$proxy="{$vpn->main_array["GLOBAL"]["PROXYADDR"]}:{$vpn->main_array["GLOBAL"]["PROXYPORT"]}";
}	

if($vpn->main_array["GLOBAL"]["IPTABLES_ETH"]==null){$vpn->main_array["GLOBAL"]["IPTABLES_ETH"]="{no}";}
				
$mode_tun="<table style='width:100%' class=form>
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{enable_authentication}</a>:</td>
		<td style='font-size:13px'>$ahref_edit{$LDAP_AUTH}</td>
		<td>&nbsp;</td>
	<tr>
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{EnableOpenVPNEndUserPage}</a>:</td>
		<td style='font-size:13px'>$ahref_edit{$EnableOpenVPNEndUserPage}</td>
		<td>&nbsp;</td>
	<tr>	
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{reverse_proxy}</a>:</td>
		<td style='font-size:13px'>$ahref_edit$proxy</td>
		<td>&nbsp;</td>
	<tr>	
	
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{from_ip_address}</a>:</td>
		<td style='font-size:13px'>$ahref_edit{$vpn->main_array["GLOBAL"]["IP_START"]}</td>
		<td>&nbsp;</td>
	<tr>
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{netmask}</a>:</td>
		<td style='font-size:13px'>$ahref_edit{$vpn->main_array["GLOBAL"]["NETMASK"]}</a></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{openvpn_access_interface}</a>:</td>
		<td style='font-size:13px'>$ahref_edit{$vpn->main_array["GLOBAL"]["IPTABLES_ETH"]}</a></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td class=legend style='font-size:13px'>$ahref_edit{wake_up_ip}</a>:</td>
		<td style='font-size:13px'>$ahref_edit$wake_up_ip</a></td>
		<td>&nbsp;</td>
	</tr>	
	
</table>";	

	$VPN_SERVER_IP=$vpn->main_array["GLOBAL"]["VPN_SERVER_IP"];
	$VPN_DHCP_FROM=$vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"];
	$VPN_DHCP_TO=$vpn->main_array["GLOBAL"]["VPN_DHCP_TO"];
	

	$tcp=new networking();
	if($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]==null){$vpn->main_array["GLOBAL"]["BRIDGE_ETH"]="eth0";}
	$array_ip=$tcp->GetNicInfos($vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
	if($vpn->main_array["GLOBAL"]["VPN_SERVER_IP"]==null){$vpn->main_array["GLOBAL"]["VPN_SERVER_IP"]=$array_ip["IPADDR"];}
	if($vpn->main_array["GLOBAL"]["NETMASK"]==null){$vpn->main_array["GLOBAL"]["NETMASK"]=$array_ip["NETMASK"];}
	
if($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"]==1){
	
	$nics=Field_array_Hash($vpn->virtual_ip_lists(),'BRIDGE_ETH',$vpn->main_array["GLOBAL"]["BRIDGE_ETH"]);
}

$mode_tap="
	<div style='width:100%;margin-bottom:5px'>
		<table style='width:100%'>
			<tr>
				<td valign='top'>
					<div id='nicvpninfo' style='float:right;margin:5px;'>".ShowIPConfig($vpn->main_array["GLOBAL"]["BRIDGE_ETH"])."</div>
				</td>
				<td valign='top'>
					<div class=explain>{SERVER_MODE_TAP}</div>
				</td>
			</tr>
		</table>
	</div>
<table style='width:100%'>
	<tr>
		<td class=legend nowrap style='font-size:13px'>{BRIDGE_ETH}:</td>
		<td width=1% nowrap>$nics</td>
		<td align='left' width=1% nowrap>". texttooltip("{add_virtual_ip_address}","{add_virtual_ip_address}","Loadjs('system.nic.config.php?js-add-nic=yes')",null,0,"font-size:13px;padding:3px")."</td>
	<tr>
	<tr>
		<td class=legend nowrap style='font-size:13px'>{BRIDGE_ADDR}:</td>
		<td width=1% nowrap>" . Field_text('BRIDGE_ADDR',$vpn->main_array["GLOBAL"]["BRIDGE_ADDR"],'width:120px;font-size:13px;padding:3px')."</td>
		<td>&nbsp;</td>
	</tr>	
	<tr>
		<td class=legend nowrap style='font-size:13px'>{VPN_DHCP_FROM}:</td>
		<td width=1% nowrap>" . Field_text('VPN_DHCP_FROM',$vpn->main_array["GLOBAL"]["VPN_DHCP_FROM"],'width:120px;font-size:13px;padding:3px')."</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td class=legend nowrap style='font-size:13px'>{VPN_DHCP_TO}:</td>
		<td width=1% nowrap>" . Field_text('VPN_DHCP_TO',$vpn->main_array["GLOBAL"]["VPN_DHCP_TO"],'width:120px;font-size:13px;padding:3px')."</td>
		<td>&nbsp;</td>
	</tr>			
	<tr>
		<td colspan=3 align='right'><hr>". button("{apply}","SaveServerSettings()")."</td>
	</tr>				
</table>
";

$mode=$mode_tun;
if($vpn->main_array["GLOBAL"]["DEV_TYPE"]=="tap0"){
	$mode=$mode_tap;
}

if($vpn->main_array["GLOBAL"]["ENABLE_BRIDGE_MODE"]==1){
	$mode=$mode_tap;
}

$schedule=LocalParagraphe("OPENVPN_SCHEDULE_RUN","OPENVPN_SCHEDULE_RUN_TEXT","Loadjs('index.openvpn.schedule.php')",
"ScheduleSettings-48.png");

if($vpn->main_array["GLOBAL"]["ENABLE_SERVER"]<>1){$status=LocalParagraphe("OPENVPN_NOT_ENABLED","OPENVPN_NOT_ENABLED_TEXT","Loadjs('index.openvpn.server.php')","warning42.png");}

if($status==null){
	$status=LocalParagraphe("OPENVPN_APPLY_CONFIG","OPENVPN_APPLY_CONFIG_TEXT","YahooWin3(500,'index.openvpn.php?restart-server=yes','{APP_OPENVPN_APPLY}')","reconfigure-42.png");
	$script=LocalParagraphe("BUILD_OPENVPN_CLIENT_CONFIG","BUILD_OPENVPN_CLIENT_CONFIG_TEXT","Loadjs('index.openvpn.build.client.php')","script-42.png");
	
}

$html="
<table style='width:100%'>
<tr>
<td valign='top'>
<div id='OPENVPN_SERVER_SETTINGS'>
<table style='width:100%'>
		<tr>
			<td valign='top' style='padding-right:5px;border-right:5px solid #CCCCCC'>$script$status$schedule</td>
			<td valign='top'>
			<div style='font-size:16px'>{service_parameters}</div>
			$mandatories$mode</td>
		</tr>
		</table>
		
	</div>
</td>
</tr>
</table>";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);		
// openvpn --remote touzeau.ath.cx --port 1194 --dev tun --comp-lzo --tls-client --ca /home/dtouzeau/ca.crt --cert /home/dtouzeau/dtouzeau.crt --key /home/dtouzeau/dtouzeau.key --verb 5 --pull	
}