<?
require_once("../classes/user.php");
require_once("../classes/network.php");
session_start();
//User have entered a name that already exists in the database.
$exists = false;
//Look if the page have been posted
if ($HTTP_POST_VARS)
{
$new_network = $HTTP_POST_VARS["newNetwork"];
}
//Try to create a new network
if( !empty($new_network) )
{
$exists = false;
$user = new User();
$networks = new Network();
$dbcn = new DBConnection();
$network_result = $networks->GetNetworks(0, "yes");
while( List($network_id, $network_name) = $dbcn->FetchRow($network_result) )
{
if($network_name == $new_network)
{
$exists = true;
}
}
if(!$exists && !FindSqlSyntax($new_network))
{
$networks->SetNetworkDetails(0, $new_network);
}
else
{
$exists = true;
}
}
//Creates a user object
$user = new User();
//If we haven't logged in as a admin we should redirect to another page.
if (!$user->IsLoggedIn() || !$user->IsAdmin())
{
header("Location: index.php");
}
function createOption()
{
$user = new User();
$networks = new Network();
$dbcn = new DBConnection();
//
// THIS CODE GENERATES THE EXISTING NETWORK LIST.
//
$network_result = $networks->GetNetworks(0, "yes");
while( List($network_id, $network_name) = $dbcn->FetchRow($network_result) )
{
print "<option value=\"$network_name\">$network_name</option>\n";
}
//
// END OF EXISTING NETWORK
//
}
// check so that no unwanted SQL querys are inside the strings
function FindSqlSyntax($str)
{
$str = strtoupper($str);
if (strpos($str,"SELECT") === FALSE && strpos($str,"UPDATE") === FALSE && strpos($str,"INSERT") === FALSE && strpos($str,"DELETE") === FALSE)
return FALSE;
else
return TRUE;
}
?>
<html>
<head>
<title>Wavewatcher New Network</title>
<link href="css/style1.css" rel="styleSheet" type="text/css">
<script language="Javascript">
function AskConfirm()
{
var bQuestion = confirm("Are you sure you want to create this network?");
if(bQuestion)
{
document.create_network.submit();
}
}
</script>
</head>
<body bgcolor="#ffffff">
<table width = "100%" height=20 align="center" border=0 cellpadding="0" cellspacing="0">
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size=1 color="#000000"><b>Wavewatcher</b></font></td>
<td align=right>
<a href="home.php">home</a> |
<a href="monitor.php">monitor network</a> |
<a href="profile.php">profile</a> |
<? if ($user->IsAdmin())
print "<a href=\"procsetup.php\">process setup</a> | ";
?>
<? if ($user->IsAdmin())
print "<a href=\"sconfig.php\">configure server</a> | ";
?>
<a href="help.html" target="_blank">help</a> |
<a href="logout.php">logout</a>
</td>
</tr>
</table>
<form name="create_network" method="post">
<table width = "50%" height="80%" align="center" border="0">
<tr>
<td>
<!-- background table -->
<table width="350" align="center" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000">
<tr>
<td>
<!-- gui table -->
<table width="350" border="0" cellspacing="1" cellpadding="2">
<!-- title row -->
<tr>
<td bgcolor="#515173">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF">
<b>New Network</b>
</font>
</td>
</tr>
<!-- message row -->
<?
if (!$exists)
{
?>
<!-- message row -->
<tr>
<td bgcolor="#c0c0c0">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
Enter name of new network.
</font>
</td>
</tr>
<?
}
else
{
?>
<tr>
<td bgcolor="#FC4848">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
You have chosen a network name that already exists or it's invalid, please select a different name.
</font>
</td>
</tr>
<?
}
?>
<!-- new network -->
<tr bgcolor="#fcfcfc">
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td align="left">
<input type="text" size="30" name="newNetwork">
</td>
<td align="right">
<input onClick="javascript:AskConfirm()" name="createBtn" type="button" value="Create Network">
</td>
</tr>
</table>
</td>
</tr>
<!-- message row -->
<tr>
<td bgcolor="#c0c0c0">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
Existing networks.
</font>
</td>
</tr>
<!-- new network -->
<tr bgcolor="#fcfcfc">
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td align="center">
<select size="10" style="WIDTH: 100%">
<? createOption() ?>
</select>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
</td>
</tr>
</table>
</form>
</body>
<html>