83 lines
1.6 KiB
PHP
83 lines
1.6 KiB
PHP
<?php
|
|
require_once('include.php');
|
|
|
|
function add_hlsw() {
|
|
$master = new Hlsw();
|
|
$master->name = "New Master";
|
|
$master->save();
|
|
Helper::reload();
|
|
}
|
|
|
|
function del_hlsw() {
|
|
$hlswid = Input::getVar('hlswid', INP_GET | INP_INT | INP_DEFAULT, 0);
|
|
if ($hlswid == 0)
|
|
Helper::reload();
|
|
|
|
Hlsw::delete($hlswid);
|
|
Helper::reload();
|
|
}
|
|
|
|
function mod_hlsw() {
|
|
$hlswid = Input::getVar('hlswid', INP_GET | INP_INT | INP_DEFAULT, 0);
|
|
if ($hlswid == 0)
|
|
Helper::reload();
|
|
|
|
$arr = Input::getVar('hlsw', INP_POST | INP_ARRAY | INP_DEFAULT, array());
|
|
|
|
$hlsw = Hlsw::load($hlswid);
|
|
$hlsw->name = $arr['name'];
|
|
$hlsw->ip = $arr['ip'];
|
|
$hlsw->vlanid = $arr['vlanid'];
|
|
$hlsw->save();
|
|
|
|
Helper::reload();
|
|
}
|
|
|
|
function show() {
|
|
$smarty = new MySmarty();
|
|
|
|
$masters = Hlsw::getAll();
|
|
$smarty->assign('masters', $masters);
|
|
|
|
$ifarr = array(0 => '- None -');
|
|
$bridges = Bridge::getAll();
|
|
foreach ($bridges as $bridge) {
|
|
$trunks = Trunk::getAll($bridge->id);
|
|
foreach ($trunks as $trunk) {
|
|
$vlans = Vlan::getAll($trunk->id);
|
|
foreach ($vlans as $vlan) {
|
|
if ($vlan->vlannum < 2)
|
|
$ifarr[$vlan->id] = "{$bridge->name} - {$trunk->name}";
|
|
else
|
|
$ifarr[$vlan->id] = "{$bridge->name} - {$trunk->name}.{$vlan->vlannum}";
|
|
}
|
|
}
|
|
}
|
|
|
|
$smarty->assign('ifarr', $ifarr);
|
|
$smarty->displaySite('Configuration: HLSW Master Server', 'hlsw.tpl');
|
|
}
|
|
|
|
$action = Input::getVar('action', INP_GET | INP_STRING | INP_DEFAULT, "show");
|
|
switch ($action) {
|
|
|
|
case 'add_hlsw':
|
|
add_hlsw();
|
|
break;
|
|
|
|
case 'del_hlsw':
|
|
del_hlsw();
|
|
break;
|
|
|
|
case 'mod_hlsw':
|
|
mod_hlsw();
|
|
break;
|
|
|
|
default:
|
|
case 'show':
|
|
show();
|
|
break;
|
|
}
|
|
|
|
?>
|