[feladat @ 198]
authorrejo
Thu, 27 Mar 2008 17:55:33 +0000
changeset 98 9c10fd623368
parent 97 090be08858db
child 99 a4b469dac161
[feladat @ 198] Bugfix. User was unable to delete a record from a zone due to a number of errors in de code.
delete_record.php
inc/record.inc.php
--- a/delete_record.php	Thu Mar 27 17:44:49 2008 +0000
+++ b/delete_record.php	Thu Mar 27 17:55:33 2008 +0000
@@ -27,9 +27,8 @@
 	$record_id = $_GET['id'];
 }
 
-
 $confirm = "-1";
-if ((isset($_GET['confirm']) && v_num($_GET['confirm'])
+if (isset($_GET['confirm']) && v_num($_GET['confirm'])) {
         $confirm = $_GET['confirm'];
 }
 
@@ -40,6 +39,8 @@
 $user_is_zone_owner = verify_user_is_owner_zoneid($_GET["domain"]);
 
 if ($record_id == "-1" ) {
+	error(ERR_INV_INPUT);
+} else {
 	if ($confirm == '1') {
 		if ( delete_record($record_id) ) {
 			success(SUC_RECORD_DEL);
@@ -79,7 +80,5 @@
 			echo "     <input type=\"button\" class=\"button\" OnClick=\"location.href='index.php'\" value=\"" . _('No') . "\">\n";
 		}
         }
-} else {
-	error(ERR_INV_INPUT);
 }
 include_once("inc/footer.inc.php");
--- a/inc/record.inc.php	Thu Mar 27 17:44:49 2008 +0000
+++ b/inc/record.inc.php	Thu Mar 27 17:55:33 2008 +0000
@@ -238,22 +238,12 @@
 
 	global $db;
 
-	$query = "SELECT * FROM records WHERE id = " . $db->quote($rid) ;
+	$query = "SELECT id AS rid, domain_id AS zid, name, type, content, ttl, prio, change_date FROM records WHERE id = " . $db->quote($rid) ;
 
 	$response = $db->query($query);
 	if (PEAR::isError($response)) { error($response->getMessage()); return false; }
-
-	while ($r = $response->fetchRow()) {
-		$return[] = array(
-			"rid"		=>	$r['id'],
-			"zid"		=>	$r['domain_id'],
-			"name"		=>	$r['name'],
-			"type"		=>	$r['type'],
-			"content"	=>	$r['content'],
-			"ttl"		=>	$r['ttl'],
-			"prio"		=>	$r['prio'],
-			"change_date"	=>	$r['change_date']);
-	}
+	
+	$return = $response->fetchRow();
 	return $return;
 }
 
@@ -277,7 +267,7 @@
 		if ($record['type'] == "SOA") {
 			error(_('You are trying to delete the SOA record. If are not allowed to remove it, unless you remove the entire zone.'));
 		} else {
-			$quote = "DELETE FROM records WHERE id = " . $db->quote($rid);
+			$query = "DELETE FROM records WHERE id = " . $db->quote($rid);
 			$response = $db->query($query);
 			if (PEAR::isError($response)) { error($response->getMessage()); return false; }
 			return true;