Prepare $name in such a way that it always works. With or without dot, with or without a domainname

This commit is contained in:
Mark Schouten 2014-05-22 10:00:41 +02:00
parent 92e9f8c6af
commit 2418fc2f60

View file

@ -202,12 +202,11 @@ if ($action == "list" or $action== "listslaves") {
_do_curl("/servers/:serverid:/zones/".$_POST['id'], array(), 'delete'); _do_curl("/servers/:serverid:/zones/".$_POST['id'], array(), 'delete');
_jtable_respond(null, 'delete'); _jtable_respond(null, 'delete');
} elseif ($action == "createrecord" or $action == "editrecord") { } elseif ($action == "createrecord" or $action == "editrecord") {
if ($action == "createrecord") { $name = (!preg_match("/\.".$_POST['domain']."\.?$/", $_POST['name'])) ? $_POST['name'].'.'.$_POST['domain'] : $_POST['name'];
$name = $_POST['name'].'.'.$_POST['domain']; $name = preg_replace("/\.$/", "", $name);
$records = getrecords_by_name_type($_GET['zoneurl'], $name, $_POST['type']);
} elseif ($action == "editrecord") {
$name = $_POST['name'];
$records = array(); $records = array();
if ($action == "createrecord") {
$records = getrecords_by_name_type($_GET['zoneurl'], $name, $_POST['type']);
} }
$records =_create_record($name, $records, $_POST, $_GET['zoneurl']); $records =_create_record($name, $records, $_POST, $_GET['zoneurl']);