1
+ − 1
<?php
47
+ − 2
+ − 3
/* PowerAdmin, a friendly web-based admin tool for PowerDNS.
+ − 4
* See <https://rejo.zenger.nl/poweradmin> for more details.
+ − 5
*
+ − 6
* Copyright 2007, 2008 Rejo Zenger <rejo@zenger.nl>
+ − 7
*
+ − 8
* This program is free software: you can redistribute it and/or modify
+ − 9
* it under the terms of the GNU General Public License as published by
+ − 10
* the Free Software Foundation, either version 3 of the License, or
+ − 11
* (at your option) any later version.
+ − 12
*
+ − 13
* This program is distributed in the hope that it will be useful,
+ − 14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
+ − 15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ − 16
* GNU General Public License for more details.
+ − 17
*
+ − 18
* You should have received a copy of the GNU General Public License
+ − 19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
+ − 20
*/
+ − 21
1
+ − 22
require_once ( "inc/toolkit.inc.php" );
+ − 23
+ − 24
$id = ( $_POST [ "id" ]) ? $_POST [ "id" ] : $_GET [ "id" ];
+ − 25
+ − 26
if ( isset ( $id ))
+ − 27
{
+ − 28
if ( $_POST [ "confirm" ] == '1' )
+ − 29
{
+ − 30
$domain = is_array ( $_POST [ "domain" ]) ? $_POST [ "domain" ] : $domain = array ();
+ − 31
$delete = is_array ( $_POST [ "delete" ]) ? $_POST [ "delete" ] : $delete = array ();
+ − 32
+ − 33
if ( count ( $domain ) > 0 )
+ − 34
{
+ − 35
foreach ( $domain as $dom => $newowner )
+ − 36
{
+ − 37
if ( ! in_array ( $dom , $delete ))
+ − 38
{
+ − 39
add_owner ( $dom , $newowner );
+ − 40
}
+ − 41
}
+ − 42
}
+ − 43
if ( count ( $delete ) > 0 )
+ − 44
{
+ − 45
foreach ( $delete as $del )
+ − 46
{
+ − 47
delete_domain ( $del );
+ − 48
}
+ − 49
}
+ − 50
+ − 51
delete_user ( $id );
+ − 52
clean_page ( $BASE_URL . $BASE_PATH . "users.php" );
+ − 53
}
+ − 54
include_once ( "inc/header.inc.php" );
13
+ − 55
?>
+ − 56
+ − 57
<h3> <? echo _ ( 'Delete user' ); ?> " <? echo get_fullname_from_userid ( $id ) ?> "</h3>
+ − 58
<form method="post">
1
+ − 59
<?
+ − 60
$domains = get_domains_from_userid ( $id );
+ − 61
if ( count ( $domains ) > 0 )
+ − 62
{
13
+ − 63
echo _ ( 'This user has access to the following zone(s)' ); ?> :<BR> <?
1
+ − 64
$users = show_users ( $id );
+ − 65
if ( count ( $users ) < 1 )
+ − 66
{
+ − 67
$add = " CHECKED DISABLED" ;
+ − 68
$no_users = 1 ;
+ − 69
}
+ − 70
?>
13
+ − 71
<table>
+ − 72
<tr>
+ − 73
<td class="n">Delete</td>
+ − 74
<td class="n">Name</td>
+ − 75
<? if ( ! $no_users ) { ?>
+ − 76
<td class="n">New owner</td>
+ − 77
<? } ?>
+ − 78
</tr>
1
+ − 79
<?
+ − 80
foreach ( $domains as $d )
+ − 81
{
13
+ − 82
?>
+ − 83
<tr>
+ − 84
<td class="n" align="center"> <?
1
+ − 85
if ( $no_users )
+ − 86
{
13
+ − 87
?> <input type="hidden" name="delete[]" value=" <? echo $d [ "id" ] ?> "> <?
1
+ − 88
}
13
+ − 89
?> <input type="checkbox" <? echo $add ?> name="delete[]" value=" <? echo $d [ "id" ] ?> "></td><td class="n"> <? echo $d [ "name" ] ?> </td><td class="n"> <?
1
+ − 90
if ( ! $no_users )
+ − 91
{
13
+ − 92
?> <select name="domain[ <? echo $d [ "id" ] ?> ]"> <?
1
+ − 93
foreach ( $users as $u )
+ − 94
{
13
+ − 95
?> <option value=" <? echo $u [ "id" ] ?> "> <? echo $u [ "fullname" ] ?> </option> <?
1
+ − 96
}
13
+ − 97
?> </select></td> <?
1
+ − 98
}
13
+ − 99
?> </tr> <?
1
+ − 100
}
13
+ − 101
?> </table> <?
1
+ − 102
}
+ − 103
2
+ − 104
$message = _ ( 'You are going to delete this user, are you sure?' );
65
+ − 105
if (( $numrows = $db -> queryOne ( "SELECT count(id) FROM zones WHERE owner=" . $db -> quote ( $id ))) != 0 )
1
+ − 106
{
13
+ − 107
$message .= " " . _ ( 'This user has access to ' ) . $numrows . _ ( ' zones, by deleting him you will also delete these zones.' );
1
+ − 108
}
+ − 109
+ − 110
?>
13
+ − 111
<font class="warning"> <? echo $message ?> </font><br>
+ − 112
<input type="hidden" name="id" value=" <? echo $id ?> ">
+ − 113
<input type="hidden" name="confirm" value="1">
+ − 114
<input type="submit" class="button" value=" <? echo _ ( 'Yes' ); ?> "> <input type="button" class="button" OnClick="location.href='users.php'" value=" <? echo _ ( 'No' ); ?> "></FORM>
1
+ − 115
<?
+ − 116
include_once ( "inc/footer.inc.php" );
+ − 117
}
+ − 118
else
+ − 119
{
+ − 120
message ( "Nothing to do!" );
+ − 121
}
+ − 122