add_record.php
changeset 182 049347a649e0
parent 140 e68c3d6094d1
equal deleted inserted replaced
181:76a304b484ed 182:049347a649e0
    47 $prio = "10";
    47 $prio = "10";
    48 if ((isset($_GET['prio'])) && (v_num($_GET['prio']))) {
    48 if ((isset($_GET['prio'])) && (v_num($_GET['prio']))) {
    49 	$prio = $_GET['prio'];
    49 	$prio = $_GET['prio'];
    50 }
    50 }
    51 
    51 
    52 $name = $_POST['name'];
    52 if (isset($_POST['name'])) {
    53 $type = $_POST['type'];
    53 	$name = $_POST['name'];
    54 $content = $_POST['content'];
    54 } else {
       
    55 	$name = "";
       
    56 }
       
    57 
       
    58 if (isset($_POST['type'])) { 
       
    59 	$type = $_POST['type'];
       
    60 } else {
       
    61 	$type = "";
       
    62 }
       
    63 
       
    64 if (isset($_POST['content'])) { 
       
    65 	$content = $_POST['content'];
       
    66 } else {
       
    67 	$content = "";
       
    68 }
    55 
    69 
    56 if ($zone_id == "-1") {
    70 if ($zone_id == "-1") {
    57 	error(ERR_INV_INPUT);
    71 	error(ERR_INV_INPUT);
    58 	include_once("inc/footer.inc.php");
    72 	include_once("inc/footer.inc.php");
    59 	exit;
    73 	exit;
    61 
    75 
    62 $user_is_zone_owner = verify_user_is_owner_zoneid($zone_id);
    76 $user_is_zone_owner = verify_user_is_owner_zoneid($zone_id);
    63 $zone_type = get_domain_type($zone_id);
    77 $zone_type = get_domain_type($zone_id);
    64 $zone_name = get_zone_name_from_id($zone_id);
    78 $zone_name = get_zone_name_from_id($zone_id);
    65 
    79 
    66 if ($_POST["commit"]) {
    80 if (isset($_POST["commit"])) {
    67 	if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) {
    81 	if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) {
    68 		error(ERR_PERM_ADD_RECORD);
    82 		error(ERR_PERM_ADD_RECORD);
    69 	} else {
    83 	} else {
    70 		if ( add_record($zone_id, $name, $type, $content, $ttl, $prio)) {
    84 		if ( add_record($zone_id, $name, $type, $content, $ttl, $prio)) {
    71 			success(_('The record was successfully added.'));
    85 			success(_('The record was successfully added.'));
    72 			unset($zone_id, $name, $type, $content, $ttl, $prio);
    86 			$name = $type = $content = $ttl = $prio = "";
    73 		}
    87 		}
    74 	}
    88 	}
    75 }
    89 }
    76 
    90 
    77 echo "    <h2>" . _('Add record to zone') . " " .  $zone_name . "</h2>\n";
    91 echo "    <h2>" . _('Add record to zone') . " " .  $zone_name . "</h2>\n";
    98 	foreach (get_record_types() as $record_type) {
   112 	foreach (get_record_types() as $record_type) {
    99 		if ($type) {
   113 		if ($type) {
   100 			if ($type == $record_type) {
   114 			if ($type == $record_type) {
   101 				$add = " SELECTED";
   115 				$add = " SELECTED";
   102 			} else {
   116 			} else {
   103 				unset ($add);
   117 				$add = "";
   104 			}
   118 			}
   105 		} else {
   119 		} else {
   106 			if (eregi('in-addr.arpa', $zone_name) && strtoupper($record_type) == 'PTR') {
   120 			if (eregi('in-addr.arpa', $zone_name) && strtoupper($record_type) == 'PTR') {
   107 				$add = " SELECTED";
   121 				$add = " SELECTED";
   108 			} elseif (strtoupper($record_type) == 'A') {
   122 			} elseif (strtoupper($record_type) == 'A') {
   109 				$add = " SELECTED";
   123 				$add = " SELECTED";
   110 			} else {
   124 			} else {
   111 				unset($add);
   125 				$add = "";
   112 			}
   126 			}
   113 		}
   127 		}
   114 		echo "          <option" . $add . " value=\"" . $record_type . "\">" . $record_type . "</option>\n";
   128 		echo "          <option" . $add . " value=\"" . $record_type . "\">" . $record_type . "</option>\n";
   115 	}
   129 	}
   116 	echo "         </select>\n";
   130 	echo "         </select>\n";