prepare($sql); $sth->execute([$zone_origin, $zone_ttl_default, $zone_soa, $zone_hostmaster, $zone_refresh, $zone_retry, $zone_expire, $zone_ttl, $zone_serial, $zone_ns1, $zone_ns2, $zone_ns3, $zone_mx1, $zone_mx2, $zone_info]); $id = $dbh->lastInsertId(); $action = ACT_VIEW; break; case 'update': $origin = sanitize($_POST['zone_origin']); $ttl_default = sanitize($_POST['zone_ttl_default']); $soa = sanitize($_POST['zone_soa']); $hostmaster = sanitize($_POST['zone_hostmaster']); $refresh = sanitize($_POST['zone_refresh']); $retry = sanitize($_POST['zone_retry']); $expire = sanitize($_POST['zone_expire']); $ttl = sanitize($_POST['zone_ttl']); $serial = sanitize($_POST['zone_serial']); $ns1 = sanitize($_POST['zone_ns1']); $ns2 = sanitize($_POST['zone_ns2']); $ns3 = sanitize($_POST['zone_ns3']); $mx1 = sanitize($_POST['zone_mx1']); $mx2 = sanitize($_POST['zone_mx2']); $info = sanitize($_POST['zone_info']); $sql = "UPDATE zone SET zone_origin=?, zone_ttl_default=?, zone_soa=?, zone_hostmaster=?, zone_refresh=?, zone_retry=?, zone_expire=?, zone_ttl=?, zone_serial=?, zone_ns1=?, zone_ns2=?, zone_ns3=?, zone_mx1=?, zone_mx2=?, zone_info=? WHERE zone_id=?"; $sth = $dbh->prepare($sql); $sth->execute([$origin, $ttl_default, $soa, $hostmaster, $refresh, $retry, $expire, $ttl, $serial, $ns1, $ns2, $ns3, $mx1, $mx2, $info, $id]); $action = ACT_VIEW; break; case 'delete': $sth = $dbh->prepare("DELETE FROM zone WHERE zone_id=?"); $sth->execute([$id]); $g_message->Add(_("Deleted zone")); $action = ACT_DEFAULT; break; default: $g_error->Add(submit_error($submit)); $valid = FALSE; } // ========== ACTIONS END ===================================================== include("header.php"); if ($action == ACT_DEFAULT): // ========== VARIANT: default behavior ======================================= $sql = "SELECT zone_id AS id, zone_origin AS origin, zone_soa AS soa, zone_hostmaster AS hostmaster, zone_serial AS serial FROM zone ORDER BY zone_origin"; $sth = $dbh->query($sql); $smarty->assign("zones", $sth->fetchAll()); $smarty->display("zone.tpl"); elseif ($action == ACT_ADD): // ========== VARIANT: add record ============================================= $smarty->display("zoneadd.tpl"); elseif ($action == ACT_VIEW): // ========== VARIANT: view single record ===================================== $sql = "SELECT zone_id, zone_soa, zone_hostmaster, zone_origin, zone_ttl_default, zone_refresh, zone_retry, zone_expire, zone_ttl, zone_serial, zone_ns1, zone_ns2, zone_ns3, zone_mx1, zone_mx2, zone_info FROM zone WHERE zone_id=?"; $sth = $dbh->prepare($sql); $sth->execute([$id]); $smarty->assign("zone", $sth->fetch(PDO::FETCH_OBJ)); $smarty->display("zoneview.tpl"); elseif ($action == ACT_EDIT): // ========== VARIANT: edit single record ===================================== $sql = "SELECT zone_id, zone_soa, zone_hostmaster, zone_origin, zone_ttl_default, zone_refresh, zone_retry, zone_expire, zone_ttl, zone_serial, zone_ns1, zone_ns2, zone_ns3, zone_mx1, zone_mx2, zone_info FROM zone WHERE zone_id=?"; $sth = $dbh->prepare($sql); $sth->execute([$id]); $smarty->assign("zone", $sth->fetch(PDO::FETCH_OBJ)); $smarty->display("zoneedit.tpl"); elseif ($action == ACT_DELETE): // ========== VARIANT: delete record ========================================== $sth = $dbh->prepare("SELECT zone_id, zone_origin, zone_serial FROM zone WHERE zone_id=?"); $sth->execute([$id]); $smarty->assign("zone", $sth->fetch(PDO::FETCH_OBJ)); $smarty->display("zonedel.tpl"); else: // ========== ERROR UNKNOWN VARIANT =========================================== echo "
Unknown function call: Please report to system development!
\n"; endif; // $action == ... // ========== END OF VARIANTS ================================================= $smarty->display('footer.tpl'); ?>