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