[feladat @ 278]
authorrejo
Sun, 18 May 2008 12:28:16 +0000
changeset 171 2a10febd6af9
parent 170 391e744a1def
child 172 4708e6b152a0
[feladat @ 278] Added user configurable option to show serial of zone in zone listing. Closes: #53.
inc/config-me.inc.php
inc/record.inc.php
list_zones.php
--- a/inc/config-me.inc.php	Sun May 18 11:51:59 2008 +0000
+++ b/inc/config-me.inc.php	Sun May 18 12:28:16 2008 +0000
@@ -12,6 +12,7 @@
 $iface_style		= "example";
 $iface_rowamount	= "50";
 $iface_expire		= "1800";
+$iface_zonelist_serial	= "0";
 
 $dns_hostmaster		= "";
 $dns_ns1		= "";
--- a/inc/record.inc.php	Sun May 18 11:51:59 2008 +0000
+++ b/inc/record.inc.php	Sun May 18 12:28:16 2008 +0000
@@ -1049,6 +1049,19 @@
         }
 }
 
+function get_serial_by_zid($zid) {
+	global $db;
+	if (is_numeric($zid)) {
+		$query = "SELECT content FROM records where TYPE = 'SOA' and domain_id = " . $db->quote($zid);
+		$rr_soa = $db->queryOne($query);
+		if (PEAR::isError($rr_soa)) { error($rr_soa->getMessage()); return false; }
+		$rr_soa_fields = explode(" ", $rr_soa);
+	} else {
+		error(sprintf(ERR_INV_ARGC, "get_serial_by_zid", "id must be a number"));
+		return false;
+	}
+	return $rr_soa_fields[2];
+}
 
 function validate_account($account) {
   	if(preg_match("/^[A-Z0-9._-]+$/i",$account)) {
--- a/list_zones.php	Sun May 18 11:51:59 2008 +0000
+++ b/list_zones.php	Sun May 18 12:28:16 2008 +0000
@@ -58,6 +58,7 @@
 	echo "       <th>" . _('Type') . "</th>\n";
 	echo "       <th>" . _('Records') . "</th>\n";
 	echo "       <th>" . _('Owner') . "</th>\n";
+	if ($iface_zonelist_serial == "1") echo "       <th>" . _('Serial') . "</th>\n";
 	echo "      </tr>\n";
 
 	if ($count_zones_view <= $iface_rowamount) {
@@ -68,7 +69,8 @@
 	}
 	foreach ($zones as $zone)
 	{
-		$zone_owners = get_fullnames_owners_from_domainid($zone["id"]);
+		$zone_owners = get_fullnames_owners_from_domainid($zone['id']);
+		if ($iface_zonelist_serial == "1") $serial = get_serial_by_zid($zone['id']);
 
 		echo "         <tr>\n";
 		echo "          <td>\n";
@@ -84,6 +86,13 @@
 		echo "          <td class=\"y\">" . strtolower($zone["type"]) . "</td>\n";
 		echo "          <td class=\"y\">" . $zone["count_records"] . "</td>\n";
 		echo "          <td class=\"y\">" . $zone_owners . "</td>\n";
+		if ($iface_zonelist_serial == "1") {
+			if ($serial != "") {
+				echo "          <td class=\"y\">" . $serial . "</td>\n";
+			} else {
+				echo "          <td class=\"n\">&nbsp;</td>\n";
+			}
+		}
 		echo "           </tr>\n";
 	}
 	echo "          </table>\n";