list_zones.php
author rejo
Thu, 24 Apr 2008 22:33:28 +0000
changeset 141 1ede5203910d
parent 136 c795dd75a77e
child 143 bef105ffb017
permissions -rw-r--r--
[feladat @ 247] If the user was listing the details of a zone that did not exist, all kinds of error messages were given. Now we first determine if the ID is valid and if not, immediately return the correct error message.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
     1
<?php
47
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
     2
119
f74e4f88b680 [feladat @ 222]
rejo
parents: 108
diff changeset
     3
/*  Poweradmin, a friendly web-based admin tool for PowerDNS.
47
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 44
diff changeset
    21
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    22
require_once("inc/toolkit.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    23
include_once("inc/header.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    24
126
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    25
if (verify_permission('zone_content_view_others')) { $perm_view = "all" ; } 
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    26
elseif (verify_permission('zone_content_view_own')) { $perm_view = "own" ; }
82
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    27
else { $perm_view = "none" ;}
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    28
126
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    29
if (verify_permission('zone_content_edit_others')) { $perm_edit = "all" ; } 
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    30
elseif (verify_permission('zone_content_edit_own')) { $perm_edit = "own" ;} 
82
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    31
else { $perm_edit = "none" ; }
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    32
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    33
$count_zones_all = zone_count_ng("all");
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    34
$count_zones_all_letterstart = zone_count_ng($perm_view,LETTERSTART); 
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    35
$count_zones_view = zone_count_ng($perm_view);
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    36
$count_zones_edit = zone_count_ng($perm_edit);
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    37
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    38
echo "    <h2>" . _('List zones') . "</h2>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    39
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    40
if ($perm_view == "none") { 
108
b1015b3055af [feladat @ 208]
rejo
parents: 82
diff changeset
    41
	echo "     <p>" . _('You do not have the permission to see any zones.') . "</p>\n";
136
c795dd75a77e [feladat @ 242]
rejo
parents: 130
diff changeset
    42
} elseif ($count_zones_view > $iface_rowamount && $count_zones_all_letterstart == "0") {
108
b1015b3055af [feladat @ 208]
rejo
parents: 82
diff changeset
    43
	echo "     <p>" . _('There are no zones to show in this listing.') . "</p>\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    44
} else {
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    45
	echo "     <div class=\"showmax\">\n";
136
c795dd75a77e [feladat @ 242]
rejo
parents: 130
diff changeset
    46
	show_pages($count_zones_all_letterstart,$iface_rowamount);
82
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    47
	echo "     </div>\n";
20
76e20b9d45e6 [feladat @ 67]
rejo
parents: 15
diff changeset
    48
136
c795dd75a77e [feladat @ 242]
rejo
parents: 130
diff changeset
    49
	if ($count_zones_view > $iface_rowamount) {
82
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    50
		echo "<div class=\"showmax\">";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    51
		show_letters(LETTERSTART);
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    52
		echo "</div>";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    53
	}
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    54
	echo "     <table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    55
	echo "      <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    56
	echo "       <th>&nbsp;</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    57
	echo "       <th>" . _('Name') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    58
	echo "       <th>" . _('Type') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    59
	echo "       <th>" . _('Records') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    60
	echo "       <th>" . _('Owner') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    61
	echo "      </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    62
	echo "      <tr>\n";
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    63
136
c795dd75a77e [feladat @ 242]
rejo
parents: 130
diff changeset
    64
	if ($count_zones_view <= $iface_rowamount) {
c795dd75a77e [feladat @ 242]
rejo
parents: 130
diff changeset
    65
		$zones = get_zones($perm_view,$_SESSION['userid'],"all",ROWSTART,$iface_rowamount);
82
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    66
	} else {
136
c795dd75a77e [feladat @ 242]
rejo
parents: 130
diff changeset
    67
		$zones = get_zones($perm_view,$_SESSION['userid'],LETTERSTART,ROWSTART,$iface_rowamount);
82
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    68
		$count_zones_shown = ($zones == -1) ? 0 : count($zones);
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    69
	}
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    70
	foreach ($zones as $zone)
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    71
	{
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    72
		$zone_owners = get_fullnames_owners_from_domainid($zone["id"]);
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    73
82
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    74
		echo "         <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    75
		echo "          <td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    76
		echo "           <a href=\"edit.php?id=" . $zone['id'] . "\"><img src=\"images/edit.gif\" title=\"" . _('View zone') . " " . $zone['name'] . "\" alt=\"[ " . _('View zone') . " " . $zone['name'] . " ]\"></a>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    77
		if ( $perm_edit != "all" || $perm_edit != "none") {
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    78
			$user_is_zone_owner = verify_user_is_owner_zoneid($zone["id"]);
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    79
		}
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    80
		if ( $perm_edit == "all" || ( $perm_edit == "own" && $user_is_zone_owner == "1") ) {
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    81
      			echo "           <a href=\"delete_domain.php?id=" . $zone["id"] . "\"><img src=\"images/delete.gif\" title=\"" . _('Delete zone') . " " . $zone['name'] . "\" alt=\"[ ". _('Delete zone') . " " . $zone['name'] . " ]\"></a>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    82
		}
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    83
		echo "          </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    84
		echo "          <td class=\"y\">" . $zone["name"] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    85
		echo "          <td class=\"y\">" . strtolower($zone["type"]) . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    86
		echo "          <td class=\"y\">" . $zone["count_records"] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    87
		echo "          <td class=\"y\">" . $zone_owners . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    88
	}
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    89
	echo "           </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    90
	echo "          </table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 76
diff changeset
    91
13
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    92
}
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    93
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    94
include_once("inc/footer.inc.php");
2ff220cfde13 [feladat @ 60]
rejo
parents:
diff changeset
    95
?>