From: Alexander M. <key...@us...> - 2005-01-05 20:14:48
|
CVSROOT : /cvsroot/publicdnsadmin Module : publicdnsadmin Commit time: 2005-01-05 20:14:38 UTC Modified files: edit_zone.php whois.php docs/CHANGELOG lib/records.inc.php Log message: Author: Alexander Maassen <out...@ke...> Log message: Changed getRecords and added sorting to edit_zone.php ---------------------- diff included ---------------------- Index: publicdnsadmin/docs/CHANGELOG diff -u publicdnsadmin/docs/CHANGELOG:1.40 publicdnsadmin/docs/CHANGELOG:1.41 --- publicdnsadmin/docs/CHANGELOG:1.40 Fri May 7 09:42:08 2004 +++ publicdnsadmin/docs/CHANGELOG Wed Jan 5 12:14:28 2005 @@ -1,4 +1,5 @@ -$Id: +OUTsider <out...@ke...> - 05/01/2005 - Redone getRecords adding new sorting method and added sort support. + SiRVulcaN <vu...@li...> - 08/05/2004 - Fixed a bug in delete_user.php that OUTsider found. When a user who owned a domain was delete all other users who have access to the domain lost their access. Index: publicdnsadmin/edit_zone.php diff -u publicdnsadmin/edit_zone.php:1.7 publicdnsadmin/edit_zone.php:1.8 --- publicdnsadmin/edit_zone.php:1.7 Sat Sep 20 07:39:12 2003 +++ publicdnsadmin/edit_zone.php Wed Jan 5 12:14:27 2005 @@ -16,6 +16,7 @@ $perms = getUserPermissions($_SESSION["_UID"]); $zoneid = trim(addslashes($_GET["id"])); + $sortorder = trim(addslashes($_GET["order"])); echo "<h3>"._EDITDOMAIN."</h3>"; if ($perms["raw"] == 2) { @@ -31,11 +32,11 @@ $row = $result->fetchRow(); if ($perms["edit_other"] or userHasZoneAccess($_SESSION["_UID"], $zoneid) or ($perms["edit_own"] and $row["user_id"] == $_SESSION["_UID"])) { - $records = getRecords($zoneid); + $records = getRecords($zoneid,$sortorder); echo "<p>· <a href=\"new_record.php?zone=$zoneid\">"._NEWRECORDUP."</a></p>\n"; echo "<form action=\"delete_multi_records.php\" name=\"recdelform\" method=\"post\">\n"; - echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"background: #000000;\"><table border=\"0\" cellspacing=\"1\" cellpadding=\"2\"><tr><th><input type=\"submit\" name=\"delbut\" disabled=\"true\" value=\""._DEL."\"></th><th>"._RECORD."</th><th>"._TYPE."</th><th>"._CONTENT."</th><th>"._PRIORITY."</th><th>"._TTL."</th><th> </th></tr>\n"; + echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"background: #000000;\"><table border=\"0\" cellspacing=\"1\" cellpadding=\"2\"><tr><th><input type=\"submit\" name=\"delbut\" disabled=\"true\" value=\""._DEL."\"></th><th><a href=?id=$zoneid&order=name>"._RECORD."</a></th><th><a href=?id=$zoneid&order=type>"._TYPE."</a></th><th><a href=?id=$zoneid&order=content>"._CONTENT."</a></th><th><a href=?id=$zoneid&order=prio>"._PRIORITY."</a></th><th><a href=?id=$zoneid&order=ttl>"._TTL."</a></th><th> </th></tr>\n"; $row_id = 0; $row_c = -1; Index: publicdnsadmin/lib/records.inc.php diff -u publicdnsadmin/lib/records.inc.php:1.3 publicdnsadmin/lib/records.inc.php:1.4 --- publicdnsadmin/lib/records.inc.php:1.3 Thu Jul 17 05:02:28 2003 +++ publicdnsadmin/lib/records.inc.php Wed Jan 5 12:14:28 2005 @@ -7,133 +7,54 @@ Distributed under the GPL license, see LICENSE for more information - $Id: records.inc.php,v 1.3 2003/07/17 12:02:28 sirvulcan Exp $ + $Id: records.inc.php,v 1.4 2005/01/05 20:14:28 key2peace Exp $ */ -function getRecords($zoneid) { +function getRecords($zoneid, $sortorder) { $records = array(); - /* TODO: Improve the way records are sorted */ - - /* Fetch SOA */ - $rec = getRecordsByType($zoneid, "SOA"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); - } - } - - /* Fetch NS */ - $rec = getRecordsByType($zoneid, "NS"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); - } - } - - /* Fetch MX */ - $rec = getRecordsByType($zoneid, "MX"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); - } - } - - /* Fetch A */ - $rec = getRecordsByType($zoneid, "A"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); - } - } + if (empty($sortorder) || ($sortorder == 'type')) { - /* Fetch AAAA */ - $rec = getRecordsByType($zoneid, "AAAA"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); - } - } - - /* Fetch PTR */ - $rec = getRecordsByType($zoneid, "PTR"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); - } - } - - /* Fetch CNAME */ - $rec = getRecordsByType($zoneid, "CNAME"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); - } - } + $order = array("SOA","NS","MX","A","AAAA","PTR","CNAME","MBOXFW","URL", + "RP","HWINFO","A6","NS6"); - /* Fetch MBOXFW */ - $rec = getRecordsByType($zoneid, "MBOXFW"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); - } - } - - /* Fetch URL */ - $rec = getRecordsByType($zoneid, "URL"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); + foreach ($order as $type) { + $rec = getRecordsByType($zoneid, $type); + if (count($rec)) { + foreach ($rec as $r) { + array_push($records, $r); + } + } } - } - /* Fetch RP */ - $rec = getRecordsByType($zoneid, "RP"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); - } - } + /* Fetch everything else */ + $dbh = db_connect(); - /* Fetch HWINFO */ - $rec = getRecordsByType($zoneid, "HWINFO"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); - } - } + $result = $dbh->query("SELECT * FROM records WHERE domain_id = '$zoneid' AND (type <> 'SOA' AND type <> 'NS' AND type <> 'MX' AND type <> 'A' AND type <> 'AAAA' AND type <> 'PTR' AND type <> 'CNAME' AND type <> 'MBOXFW' AND type <> 'URL' AND type <> 'RP' AND type <> 'HWINFO' AND type <> 'A6' AND type <> 'NS6')"); + if (!$dbh->isError($result) && $result->numRows()) { + while ($row = $result->fetchRow()) { - /* Fetch A6 */ - $rec = getRecordsByType($zoneid, "A6"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); - } - } + array_push($records, array("id" => $row["id"], "name" => $row["name"], "type" => $row["type"], "prio" => $row["prio"], "content" => $row["content"], "ttl" => $row["ttl"], "change_date" => $row["change_date"])); - /* Fetch NS6 */ - $rec = getRecordsByType($zoneid, "NS6"); - if (count($rec)) { - foreach ($rec as $r) { - array_push($records, $r); + } } - } - - /* Fetch everything else */ - $dbh = db_connect(); - $result = $dbh->query("SELECT * FROM records WHERE domain_id = '$zoneid' AND (type <> 'SOA' AND type <> 'NS' AND type <> 'MX' AND type <> 'A' AND type <> 'AAAA' AND type <> 'PTR' AND type <> 'CNAME' AND type <> 'MBOXFW' AND type <> 'URL' AND type <> 'RP' AND type <> 'HWINFO' AND type <> 'A6' AND type <> 'NS6')"); - if (!$dbh->isError($result) && $result->numRows()) { - while ($row = $result->fetchRow()) { - - array_push($records, array("id" => $row["id"], "name" => $row["name"], "type" => $row["type"], "prio" => $row["prio"], "content" => $row["content"], "ttl" => $row["ttl"], "change_date" => $row["change_date"])); + $dbh->disconnect(); + } elseif ($sortorder == 'name' || $sortorder == 'prio' || $sortorder == 'content' || $sortorder == 'ttl') { + /* User wants to sort on something else */ + $dbh = db_connect(); + $result = $dbh->query("SELECT * FROM records WHERE domain_id = '$zoneid' ORDER BY $sortorder"); + if (!$dbh->isError($result) && $result->numRows()) { + while ($row = $result->fetchRow()) { + array_push($records, array("id" => $row["id"], "name" => $row["name"], "type" => $row["type"], "prio" => $row["prio"], "content" => $row["content"], "ttl" => $row["ttl"], "change_date" => $row["change_date"])); + } } - } - - $dbh->disconnect(); + $dbh->disconnect(); + } + return $records; } Index: publicdnsadmin/whois.php diff -u publicdnsadmin/whois.php:1.3 publicdnsadmin/whois.php:1.4 --- publicdnsadmin/whois.php:1.3 Wed Aug 13 05:14:13 2003 +++ publicdnsadmin/whois.php Wed Jan 5 12:14:27 2005 @@ -79,7 +79,7 @@ if (!$dbh->isError($result) && $result->numRows()) { $row = $result->fetchRow(); - $records = getRecords($zoneid); + $records = getRecords($zoneid,'name'); foreach ($records as $record) { wwwhois($record[name]); break; ----------------------- End of diff ----------------------- |