[feladat @ 76]
Changed some of the functions that are used for the listing of (all)
zones. Instead of getting all zones from the database, it now only
requests exactlty what it needs. Considerable perfomance improvement.
--- a/credits.php Mon Jun 25 22:37:06 2007 +0000
+++ b/credits.php Wed Jun 27 20:45:51 2007 +0000
@@ -6,7 +6,7 @@
<p><a href="https://rejo.zenger.nl/poweradmin/">This version</a> is an adaption of the original <a href="http://www.poweradmin.org">Poweradmin</a>, version 1.2.7-patched. Poweradmin was written by <a href="http://sjeemz.nl/">Sjeemz</a> and <a href="http://www.trancer.nl/">Trancer</a>. The Poweradmin code includes patches by <a href="http://mostrey.be/">Wim Mostrey</a> and Dennis Roos. <a href="https://rejo.zenger.nl/poweradmin/">This version</a> has been patched by <a href="http://rejo.zenger.nl">Rejo Zenger</a> and includes many additional features like multi-language support, an update of the database abstraction layer, support for slave zones, support for supermasters, basic support for skins and a number of bug fixes.</p>
- <p>Thanks to Koert Buijzer, Peter Beernink, John Morris and Balazs Petrikovics for bug reports, patches and good ideas.</p>
+ <p>Thanks to Peter Beernink, Koert Buijzer, John Morris and Balazs Petrikovics for bug reports, patches and good ideas.</p>
<?
include_once("inc/footer.inc.php");
--- a/inc/toolkit.inc.php Mon Jun 25 22:37:06 2007 +0000
+++ b/inc/toolkit.inc.php Wed Jun 27 20:45:51 2007 +0000
@@ -88,34 +88,67 @@
* Display the alphabetic option: [0-9] [a] [b] .. [z]
*/
-function show_letters($letterstart,$doms)
+function show_letters($letterstart,$userid=true)
{
- foreach ($doms as $dom) {
- if (is_numeric($dom["name"][0])) {
- $letter_taken["0"] = 1;
- } else {
- $letter_taken[$dom["name"][0]] = 1;
- }
- }
+ echo _('Show zones beginning with:') . "<br>";
+
+ $letter = "[[:digit:]]";
+ if ($letterstart == "0")
+ {
+ echo "[ <span class=\"lettertaken\">0-9</span> ] ";
+ }
+ elseif (zone_letter_start($letter,$userid))
+ {
+ echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=0\">0-9</a> ] ";
+ }
+ else
+ {
+ echo "[ <span class=\"letternotavailble\">0-9</span> ] ";
+ }
- echo _('Show zones beginning with:') . "<br>";
- if ($letterstart == 1) {
- echo "[ <b>0-9</b> ] ";
- } elseif ($letter_taken["0"] != 1) {
- echo "[ 0-9 ] ";
- } else {
- echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=1\">0-9</a> ] ";
- }
-
- foreach (range('a','z') as $letter) {
- if ($letterstart === $letter) {
- echo "[ <span class=\"lettertaken\">".$letter."</span> ] ";
- } elseif ($letter_taken[$letter] != 1) {
- echo "[ <span class=\"letternotavailble\">".$letter."</span> ] ";
- } else {
- echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=".$letter."\">".$letter."</a> ] ";
- }
- }
+ foreach (range('a','z') as $letter)
+ {
+ if ($letter == $letterstart)
+ {
+ echo "[ <span class=\"lettertaken\">".$letter."</span> ] ";
+ }
+ elseif (zone_letter_start($letter,$userid))
+ {
+ echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=".$letter."\">".$letter."</a> ] ";
+ }
+ else
+ {
+ echo "[ <span class=\"letternotavailble\">".$letter."</span> ] ";
+ }
+ }
+}
+
+function zone_letter_start($letter,$userid=true)
+{
+ global $db;
+ $sqlq = "SELECT domains.id AS domain_id,
+ zones.owner,
+ records.id,
+ domains.name AS domainname
+ FROM domains
+ LEFT JOIN zones ON domains.id=zones.domain_id
+ LEFT JOIN records ON records.domain_id=domains.id
+ WHERE 1";
+ if((!level(5) || !$userid) && !level(10) && !level(5))
+ {
+ $sqlq .= " AND zones.owner=".$_SESSION["userid"];
+ }
+ $sqlq .= " AND substring(domains.name,1,1) REGEXP '^".$letter."' LIMIT 1";
+ $result = $db->query($sqlq);
+ $numrows = $result->numRows();
+ if ( $numrows == "1" )
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
}
/*
--- a/list_zones.php Mon Jun 25 22:37:06 2007 +0000
+++ b/list_zones.php Wed Jun 27 20:45:51 2007 +0000
@@ -3,21 +3,20 @@
require_once("inc/toolkit.inc.php");
include_once("inc/header.inc.php");
-$all_doms = get_domains(0);
-$num_all_domains = ($all_doms == -1) ? 0 : count($all_doms);
-$doms = get_domains(0,LETTERSTART);
+$num_all_domains = zone_count(0);
+$doms = zone_count(0, LETTERSTART);
?>
<h2><? echo _('List zones'); ?></h2>
<?
- echo "<div class=\"showmax\">";
- show_pages(count($doms),ROWAMOUNT);
- echo "</div>";
+ echo "<div class=\"showmax\">";
+ show_pages($doms,ROWAMOUNT);
+ echo "</div>";
-if ($num_all_domains > ROWAMOUNT)
+if ($num_all_domains > ROWAMOUNT)
{
- echo "<div class=\"showmax\">";
- show_letters(LETTERSTART,$all_doms);
- echo "</div>";
+ echo "<div class=\"showmax\">";
+ show_letters(LETTERSTART);
+ echo "</div>";
}
?>
<table>