prepare($sql); $sth->execute([$vlan_name, $vlan_number, $vlan_color, $vlan_info]); $id = $dbh->lastInsertId(); $action = ACT_VIEW; break; case 'update': $vlan_name = sanitize($_POST['vlan_name']); $vlan_number = sanitize($_POST['vlan_number']); $vlan_info = sanitize($_POST['vlan_info']); $vlan_color = sanitize($_POST['vlan_color']); $sql = "UPDATE vlan SET vlan_name=?, vlan_number=?, vlan_color=?, vlan_info=? WHERE vlan_id=?"; $sth = $dbh->prepare($sql); $sth->execute([$vlan_name, $vlan_number, $vlan_color, $vlan_info, $id]); $action = ACT_VIEW; break; case 'delete': $sth = $dbh->prepare("DELETE FROM vlan WHERE vlan_id=?"); $sth->execute([$id]); $g_message->Add(_("VLAN deleted.")); $action = ACT_DEFAULT; break; default: $g_error->Add(submit_error($submit)); $valid = FALSE; } // ========== ACTIONS END ===================================================== $smarty->assign("scripts", 'jscolor.js'); include("header.php"); if ($action == ACT_DEFAULT): // ========== VARIANT: default behavior ======================================= $sql = "SELECT vlan_id AS id, vlan_number AS number, vlan_name AS name, vlan_color AS color, LEFT(vlan_info, 60) AS info FROM vlan ORDER BY vlan_number"; $sth = $dbh->query($sql); $smarty->assign("vlans", $sth->fetchAll()); $smarty->display("vlan.tpl"); elseif ($action == ACT_ADD): // ========== VARIANT: add record ============================================= $smarty->display("vlanadd.tpl"); elseif ($action == ACT_VIEW): // ========== VARIANT: view single record ===================================== // vlan $sql = "SELECT vlan_id AS id, vlan_name AS name, vlan_number AS number, vlan_info AS info, vlan_color AS color FROM vlan WHERE vlan_id=?"; $sth = $dbh->prepare($sql); $sth->execute([$id]); $smarty->assign("vlan", $sth->fetch(PDO::FETCH_OBJ)); // subnets $sql = "SELECT s.subnet_id, s.subnet_address, s.subnet_mask, s.subnet_info FROM subnet AS s LEFT JOIN subnetvlan AS v USING (subnet_id) WHERE v.vlan_id=? ORDER BY INET_ATON(s.subnet_address)"; $sth = $dbh->prepare($sql); $sth->execute([$id]); $smarty->assign("subnets", $sth->fetchAll()); $smarty->display("vlanview.tpl"); elseif ($action == ACT_EDIT): // ========== VARIANT: edit single record ===================================== $sql = "SELECT vlan_id AS id, vlan_name AS name, vlan_number AS number, vlan_color AS color, vlan_info AS info FROM vlan WHERE vlan_id=?"; $sth = $dbh->prepare($sql); $sth->execute([$id]); $smarty->assign("vlan", $sth->fetch(PDO::FETCH_OBJ)); $smarty->display("vlanedit.tpl"); elseif ($action == ACT_DELETE): // ========== VARIANT: delete record ========================================== $sql = "SELECT vlan_id AS id, vlan_name AS name, vlan_number AS number FROM vlan WHERE vlan_id=?"; $sth = $dbh->prepare($sql); $sth->execute([$id]); $smarty->assign("vlan", $sth->fetch(PDO::FETCH_OBJ)); $smarty->display("vlandel.tpl"); else: // ========== ERROR UNKNOWN VARIANT =========================================== echo "
Unknown function call: Please report to system development!
\n"; endif; // $action == ... // ========== END OF VARIANTS ================================================= $smarty->display('footer.tpl'); ?>