bcast-bridge/web/forward.php
2006-12-11 21:36:44 +01:00

77 lines
1.5 KiB
PHP

<?php
require_once('include.php');
function add_forward() {
$ports = Input::getVar('ports', INP_POST | INP_STRING | INP_DEFAULT, "");
$name = Input::getVar('name', INP_POST | INP_STRING | INP_DEFAULT, "");
if (!empty($ports) && !empty($name)) {
$forward = new Forward();
$forward->flags |= 0x01;
$forward->name = $name;
$part = explode('-', $ports);
if (is_numeric($part[0]) && $part[0] > 0 && $part[0] < 65535) {
$forward->portlo = $part[0];
if (is_numeric($part[1]) && $part[1] > 0 && $part[1] < 65535)
$forward->porthi = $part[1];
$forward->save();
}
}
Helper::reload();
}
function del_forward() {
$forwardid = Input::getVar('forwardid', INP_GET | INP_INT | INP_DEFAULT, 0);
if ($forwardid == 0)
Helper::reload();
Forward::delete($forwardid);
Helper::reload();
}
function toggle_forward() {
$forwardid = Input::getVar('forwardid', INP_GET | INP_INT | INP_DEFAULT, 0);
if ($forwardid == 0)
Helper::reload();
$forward = Forward::load($forwardid);
$forward->toggle();
$forward->save();
Helper::reload();
}
function show() {
$smarty = new MySmarty();
$forwards = Forward::getAll();
$smarty->assign('forwards', $forwards);
$smarty->displaySite('Bridge Configuration: Forward Ports', 'forward.tpl');
}
$action = Input::getVar('action', INP_GET | INP_STRING | INP_DEFAULT, "show");
switch ($action) {
case 'add_forward':
add_forward();
break;
case 'del_forward':
del_forward();
break;
case 'toggle_forward':
toggle_forward();
break;
default:
case 'show':
show();
break;
}
?>