Location: PHPKode > projects > WaveWatcher > wavewatcher3/html/sconfig.php
<?
	require_once("../classes/network.php");
require_once("../classes/user.php");
session_start();                                                                                //Start session

$user = new User();
$network = new Network();
	if (!$user->IsLoggedIn())
		header("Location: index.php");

	else if (!$user->IsAdmin()) 
		header("Location: logout.php");

	if ($HTTP_POST_VARS)
	{
		$eth0ip = $HTTP_POST_VARS["eth0ip"];
		# we had big ideas about being able to configure
		# all ethernet ports via webben
		# just now its only eth0
		$parameters = "";
		$parameters = empty($eth0ip) || empty($eth0mask) || strpos($eth0ip, " ")!==false || strpos($eth0mask, " ")!==false ? "" : "eth0 $eth0ip $eth0mask ";

		exec("/usr/local/wavewatcher3/html/wrapper 100668953352841 $parameters");
	}

	function readValue($interface)
	{
		if (file_exists ("ifconf.set"))
		{
			$fp = fopen ("ifconf.set", "r");
			$arrSettings = array();
			while( !feof ($fp) ) 
			{
				$buffer = fgets($fp, 128);			
				$eth = strtok($buffer, " ");
				$eth = strtok(" ");
				$ip = strtok(" ");
				$netmask = strtok(" ");
				$netmask = strtok(" ");			
					
				$arrSettings[$eth."ip"] = $ip;
				$arrSettings[$eth."mask"] = $netmask;			
			}
			fclose( $fp );

			print $arrSettings[$interface];
		}
	}

?>

<html>
	<head>
		<title>Server Settings</title>
		<link href="css/style1.css" rel="styleSheet" type="text/css">		
		<script language="javascript">
			function savechanges()
			{
				addHiddenSetting();
				document.settings.submit();
			}

			function addSetting()
			{
				var networkSelect = document.settings.interfaces;
				var strEthXValue = networkSelect.options[networkSelect.selectedIndex].value;
								
				addHiddenSetting();

				switch(strEthXValue)
				{
					case "eth0":		document.settings.ip.value = document.settings.eth0ip.value;
											document.settings.netmask.value = document.settings.eth0mask.value;
											break;

						
					default:				break;
				}

				document.settings.interf.value = strEthXValue;
			}

			function addHiddenSetting()
			{
				var selInterface = document.settings.interf.value;
				switch(selInterface)
				{
					case "eth0":		document.settings.eth0ip.value = document.settings.ip.value;
											document.settings.eth0mask.value = document.settings.netmask.value;
											break;

						
					default:				break;
				}
				
			}
		</script>
	</head>

	<body>
<?include("menuinclude.php");?>

	<form method="post" name="settings">
	
	<table width = "50%" height="80%" align="center" border="0">
		<tr>
			<td>

				<!-- background table -->
				<table width="300" align="center" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000">
					<tr>
						<td>
							<!-- gui table -->
							<table width="300" border="0" cellspacing="1" cellpadding="2">
								
								<!-- title row -->
								<tr>
									<td bgcolor="#515173" colspan="2">
										<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b>Edit server settings</b></font>
									</td>
								</tr>
								
								<tr>
									<td bgcolor="#c0c0c0" colspan="2">
										<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
											Warning! Any submitted changes here will make server reboot!<br>
										</font>
									</td>
									
								</tr>

								<!-- Submit -->
								<tr bgcolor="#fcfcfc">
									<td>
										<table width="100%" border="0">
											<tr>
												<td>Interface</td>
												<td>
													<SELECT name="interfaces" onChange="addSetting()">
														<OPTION selected value="eth0">eth0</OPTION>
													</SELECT>
													<input type="hidden" name="interf" value="eth0">
													<input type="hidden" name="eth0ip" value="<?readValue('eth0ip')?>">
													<input type="hidden" name="eth0mask" value="<?readValue('eth0mask')?>">
												</td>
											</tr>
											<tr bgcolor="#fcfcfc">
												<td>IP</td>
												<td><input type="text" name="ip" value="<?readValue('eth0ip')?>"></td>
											</tr>
											<tr bgcolor="#fcfcfc">
												<td>Netmask</td>
												<td><input type="text" name="netmask" value="<?readValue('eth0mask')?>"></td>
											</tr>
											<tr bgcolor="#fcfcfc">
												<td colspan="2" align="center"><input type="button" onClick="savechanges()" value="Save changes and Reboot"></td>
											</tr>
									</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	</form>
	</body>
</html>
Return current item: WaveWatcher