#268 Add Vlan Support

This commit is contained in:
Ulrich Block 2014-02-02 12:36:19 +01:00
parent f5bd3ced4d
commit d7bbbc0186
6 changed files with 215 additions and 0 deletions

View File

@ -0,0 +1,90 @@
<?php
/**
* File: update_430-440.php.
* Author: Ulrich Block
* Date: 02.02.14
* Contact: <ulrich.block@easy-wi.com>
*
* This file is part of Easy-WI.
*
* Easy-WI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Easy-WI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
*
* Diese Datei ist Teil von Easy-WI.
*
* Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
* der GNU General Public License, wie von der Free Software Foundation,
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
* veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
*
* Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
* OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
* Siehe die GNU General Public License fuer weitere Details.
*
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
*/
if (isset($include) and $include == true) {
$query = $sql->prepare("INSERT INTO `easywi_version` (`version`,`de`,`en`) VALUES
('4.40','<div align=\"right\">23.10.2013</div>
<b>Änderungen:</b><br/>
<ul>
<li></li>
</ul>
<br/><br/>
<b>Bugfixes:</b><br/>
<ul>
<li></li>
</ul>
','<div align=\"right\">10.23.2013</div>
<b>Changes:</b><br/>
<ul>
<li></li>
</ul>
<br/><br/>
<b>Bugfixes:</b><br/>
<ul>
<li></li>
</ul>
')");
$query->execute();
$response->add('Action: insert_easywi_version done: ');
$query->closecursor();
$query = $sql->prepare("SELECT `active`,`subnetOptions`,`ips`,`netmask`,`resellerid` FROM `rootsDHCP`");
$query2 = $sql->prepare("SELECT 1 FROM `rootsSubnets` WHERE `subnet`=? LIMIT 1");
$query3 = $sql->prepare("INSERT INTO `rootsSubnets` (`active`,`subnet`,`subnetOptions`,`netmask`,`vlan`,`vlanName`) VALUES (?,?,?,?,'N','')");
$query->execute();
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
foreach (explode("\r\n", $row['ips']) as $exip) {
$ex = explode('.', $exip);
if (isset($ex[2])) {
$query2->execute(array($ex[0] . '.' . $ex[1] . '.' . $ex[2] . '.0'));
if ($query2->rowCount() == 0) {
$query3->execute(array($row['active'], $ex[0] . '.' . $ex[1] . '.' . $ex[2] . '.0', str_replace("option subnet-mask %subnet-mask%;\r\n", '', $row['subnetOptions']), $row['netmask']));
}
}
}
}
} else {
echo "Error: this file needs to be included by the updater!<br />";
}

View File

@ -807,6 +807,7 @@ $add->execute();
$query = "CREATE TABLE IF NOT EXISTS `rootsSubnets` (
`subnetID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`dhcpServer` int(10) unsigned NOT NULL,
`active` enum('Y','N') DEFAULT 'Y',
`subnet` varchar(15) DEFAULT NULL,
`netmask` varchar(15) DEFAULT NULL,

View File

@ -194,6 +194,7 @@ $defined['rootsPXE'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"N
$defined['rootsSubnets'] = array(
'subnetID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
'dhcpServer' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
'subnet' => array("Type"=>"varchar(15)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
'subnetOptions' => array("Type"=>"text","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),

View File

@ -32,6 +32,16 @@
</select>
</div>
</div>
<div class="control-group<?php if(isset($errors['dhcpServer'])) echo ' error';?>">
<label class="control-label" for="inputDHCP">DHCP</label>
<div class="controls">
<select id="inputDHCP" name="dhcpServer">
<?php foreach($dhcpServers as $k=>$v){ ?>
<option value="<?php echo $k;?>" <?php if ($k==$dhcpServer) echo 'selected="selected"'; ?>><?php echo $v;?></option>
<?php } ?>
</select>
</div>
</div>
<div class="control-group<?php if(isset($errors['subnet'])) echo ' error';?>">
<label class="control-label" for="inputSubnet"><?php echo $sprache->subnet;?></label>
<div class="controls"><input id="inputSubnet" type="text" name="subnet" value="<?php echo $subnet;?>" maxlength="15" required></div>

View File

@ -0,0 +1,33 @@
<div class="row-fluid">
<div>
<ul class="breadcrumb">
<li><a href="admin.php">Home</a> <span class="divider">/</span></li>
<li><a href="admin.php?w=sn"><?php echo $gsprache->subnets;?></a> <span class="divider">/</span></li>
<li class="active"><?php echo $gsprache->del;?></li>
</ul>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<dl class="dl-horizontal">
<dt><?php echo $sprache->subnet;?></dt>
<dd><?php echo $subnet;?></dd>
<dt><?php echo $sprache->netmask;?></dt>
<dd><?php echo $netmask;?></dd>
</dl>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<form class="form-horizontal" action="admin.php?w=sn&amp;d=dl&amp;id=<?php echo $id;?>&amp;r=sn" onsubmit="return confirm('<?php echo $gsprache->sure; ?>');" method="post">
<input type="hidden" name="token" value="<?php echo token();?>">
<input type="hidden" name="action" value="dl">
<div class="control-group">
<label class="control-label" for="inputEdit"></label>
<div class="controls">
<button class="btn btn-danger pull-left" id="inputEdit" type="submit"><i class="fa fa-trash-o"></i> <?php echo $gsprache->del;?></button>
</div>
</div>
</form>
</div>
</div>

View File

@ -0,0 +1,80 @@
<div class="row-fluid">
<div>
<ul class="breadcrumb">
<li><a href="admin.php">Home</a> <span class="divider">/</span></li>
<li><a href="admin.php?w=sn"><?php echo $gsprache->subnets;?></a> <span class="divider">/</span></li>
<li class="active"><?php echo $gsprache->add;?></li>
</ul>
</div>
</div>
<div class="row-fluid hidden-phone">
<div class="span12 alert alert-info"><?php echo $sprache->help_vlan;?></div>
</div>
<hr>
<?php if (count($errors)>0){ ?>
<div class="alert alert-error">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<h4>Error(s)</h4>
<?php echo implode(', ',$errors);?>
</div>
<?php }?>
<div class="row-fluid">
<div class="span8">
<form class="form-horizontal" action="admin.php?w=sn&amp;d=md&amp;id=<?php echo $id;?>&amp;r=sn" onsubmit="return confirm('<?php echo $gsprache->sure; ?>');" method="post">
<input type="hidden" name="token" value="<?php echo token();?>">
<input type="hidden" name="action" value="md">
<div class="control-group<?php if(isset($errors['active'])) echo ' error';?>">
<label class="control-label" for="inputActive"><?php echo $gsprache->active;?></label>
<div class="controls">
<select id="inputActive" name="active">
<option value="Y"><?php echo $gsprache->yes;?></option>
<option value="N" <?php if ($active=='N') echo 'selected="selected"'; ?>><?php echo $gsprache->no;?></option>
</select>
</div>
</div>
<div class="control-group<?php if(isset($errors['dhcpServer'])) echo ' error';?>">
<label class="control-label" for="inputDHCP">DHCP</label>
<div class="controls">
<select id="inputDHCP" name="dhcpServer">
<?php foreach($dhcpServers as $k=>$v){ ?>
<option value="<?php echo $k;?>" <?php if ($k==$dhcpServer) echo 'selected="selected"'; ?>><?php echo $v;?></option>
<?php } ?>
</select>
</div>
</div>
<div class="control-group<?php if(isset($errors['subnet'])) echo ' error';?>">
<label class="control-label" for="inputSubnet"><?php echo $sprache->subnet;?></label>
<div class="controls"><input id="inputSubnet" type="text" name="subnet" value="<?php echo $subnet;?>" maxlength="15" required></div>
</div>
<div class="control-group">
<label class="control-label" for="inputSubnetOptions"><?php echo $sprache->subnetOptions;?></label>
<div class="controls">
<textarea id="inputSubnetOptions" rows="5" name="subnetOptions"><?php echo $subnetOptions;?></textarea>
</div>
</div>
<div class="control-group<?php if(isset($errors['netmask'])) echo ' error';?>">
<label class="control-label" for="inputNetmask"><?php echo $sprache->netmask;?></label>
<div class="controls"><input id="inputNetmask" type="text" name="netmask" value="<?php echo $netmask;?>" maxlength="15" required></div>
</div>
<div class="control-group<?php if(isset($errors['vlan'])) echo ' error';?>">
<label class="control-label" for="inputVlan"><?php echo $sprache->vlan;?></label>
<div class="controls">
<select id="inputVlan" name="vlan" onchange="textdrop('vlanName');">
<option value="Y"><?php echo $gsprache->yes;?></option>
<option value="N" <?php if ($vlan=='N') echo 'selected="selected"'; ?>><?php echo $gsprache->no;?></option>
</select>
</div>
</div>
<div class="control-group<?php if(isset($errors['vlanName'])) echo ' error';?><?php if ($vlan=='N') echo ' display_none';?>" id="vlanName">
<label class="control-label" for="inputVlanName"><?php echo $sprache->vlanName;?></label>
<div class="controls"><input id="inputVlanName" type="text" name="vlanName" value="<?php echo $vlanName;?>"></div>
</div>
<div class="control-group">
<label class="control-label" for="inputEdit"></label>
<div class="controls">
<button class="btn btn-primary" id="inputEdit" type="submit"><i class="icon-edit icon-white"></i> <?php echo $gsprache->save;?></button>
</div>
</div>
</form>
</div>
</div>