1
+ − 1
<?php
+ − 2
47
+ − 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
// Assigning records to user: Check for records owned by user
45
+ − 25
$recordOwnerError = '' ;
1
+ − 26
if ( isset ( $_POST [ "action" ]) && $_POST [ "action" ] == "record-user" ) {
45
+ − 27
if ( ! is_array ( $_POST [ 'rowid' ])) {
+ − 28
$recordOwnerError = 'No records where selected to assign an sub-owner.' ;
+ − 29
} else {
56
+ − 30
foreach ( $_POST [ "rowid" ] as $x_user => $recordid ){
65
+ − 31
$x_userid = $db -> queryOne ( "SELECT id FROM record_owners WHERE user_id = " . $db -> quote ( $_POST [ "userid" ]) . " AND record_id=" . $db -> quote ( $recordid ));
45
+ − 32
if ( empty ( $x_userid )) {
56
+ − 33
add_record_owner ( $_GET [ "id" ], $_POST [ "userid" ], $recordid );
45
+ − 34
}
13
+ − 35
}
+ − 36
}
1
+ − 37
}
13
+ − 38
if ( isset ( $_POST [ 'change_slave_master' ]) && is_numeric ( $_POST [ "domain" ]) && level ( 5 ))
+ − 39
{
+ − 40
change_domain_slave_master ( $_POST [ 'domain' ], $_POST [ 'slave_master' ]);
+ − 41
}
1
+ − 42
if ( isset ( $_POST [ 'type_change' ]) && in_array ( $_POST [ 'newtype' ], $server_types ))
+ − 43
{
13
+ − 44
change_domain_type ( $_POST [ 'newtype' ], $_GET [ 'id' ]);
1
+ − 45
}
+ − 46
if ( isset ( $_POST [ "newowner" ]) && is_numeric ( $_POST [ "domain" ]) && is_numeric ( $_POST [ "newowner" ]))
+ − 47
{
+ − 48
add_owner ( $_POST [ "domain" ], $_POST [ "newowner" ]);
+ − 49
}
+ − 50
if ( isset ( $_POST [ "del_user" ]) && is_numeric ( $_POST [ "del_user" ]) && level ( 5 ))
+ − 51
{
+ − 52
delete_owner ( $_GET [ "id" ], $_POST [ "del_user" ]);
+ − 53
}
13
+ − 54
$info = get_domain_info_from_id ( $_GET [ "id" ]);
1
+ − 55
include_once ( "inc/header.inc.php" );
38
+ − 56
+ − 57
$domain_type = get_domain_type ( $_GET [ 'id' ]);
+ − 58
if ( $domain_type == "SLAVE" ) { $slave_master = get_domain_slave_master ( $_GET [ 'id' ]); };
13
+ − 59
45
+ − 60
if ( strlen ( $recordOwnerError )) {
+ − 61
?>
+ − 62
<div class="error"> <?php echo _ ( 'Error' ); ?> : <?php echo _ ( $recordOwnerError ); ?> </div>
71
+ − 63
<?php
45
+ − 64
}
+ − 65
38
+ − 66
if ( ! isset ( $info [ "ownerid" ]) && $domain_type != "SLAVE" )
13
+ − 67
{
1
+ − 68
?>
71
+ − 69
<div class="error"> <?php echo _ ( 'Error' ); ?> : <?php echo ( 'There is no owner for this zone, please assign someone.' ); ?> </div>
+ − 70
<?php
13
+ − 71
}
41
+ − 72
if ( $domain_type == "SLAVE" && ! $slave_master )
38
+ − 73
{
+ − 74
?>
71
+ − 75
<div class="error"> <?php echo _ ( 'Error' ); ?> : <?php echo _ ( 'Type of this zone is "slave", but there is no IP address for it\'s master given.' ); ?> </div>
+ − 76
<?php
38
+ − 77
}
13
+ − 78
?>
71
+ − 79
<h2> <?php echo _ ( 'Edit zone' ); ?> " <?php echo get_domain_name_from_id ( $_GET [ "id" ]) ?> "</h2>
+ − 80
<?php
13
+ − 81
if ( level ( 5 ))
+ − 82
{ ?>
+ − 83
<div id="meta">
+ − 84
<div id="meta-left">
+ − 85
<table>
+ − 86
<tr>
71
+ − 87
<th colspan="2"> <?php echo _ ( 'Owner of zone' ); ?> </th>
13
+ − 88
</tr>
71
+ − 89
<?php
13
+ − 90
if ( isset ( $info [ "ownerid" ]))
+ − 91
{
+ − 92
$userRes = get_users_from_domain_id ( $_GET [ "id" ]);
+ − 93
foreach ( $userRes as $user )
+ − 94
{ ?>
+ − 95
<tr>
71
+ − 96
<form method="post" action="edit.php?id= <?php echo $_GET [ 'id' ] ?> ">
13
+ − 97
<td>
71
+ − 98
<?php echo $user [ "fullname" ] ?>
13
+ − 99
</td>
+ − 100
<td>
71
+ − 101
<input type="hidden" name="del_user" value=" <?php echo $user [ "id" ] ?> ">
+ − 102
<input type="submit" class="sbutton" name="co" value=" <?php echo _ ( 'Delete' ); ?> ">
13
+ − 103
</td>
+ − 104
</form>
+ − 105
</tr>
71
+ − 106
<?php
13
+ − 107
}
+ − 108
}
+ − 109
else
+ − 110
{
+ − 111
?>
+ − 112
<tr>
71
+ − 113
<td> <?php echo _ ( 'No owner set or this zone!' ); ?> </td>
13
+ − 114
</tr>
71
+ − 115
<?php
13
+ − 116
}
+ − 117
?>
+ − 118
<tr>
71
+ − 119
<form method="post" action="edit.php?id= <?php echo $_GET [ 'id' ] ?> ">
13
+ − 120
<td>
71
+ − 121
<input type="hidden" name="domain" value=" <?php echo $_GET [ "id" ] ?> ">
13
+ − 122
<select name="newowner">
71
+ − 123
<?php
13
+ − 124
$users = show_users ();
+ − 125
foreach ( $users as $u )
+ − 126
{
79
+ − 127
$add = '' ;
13
+ − 128
if ( $u [ "id" ] == $info [ "ownerid" ])
+ − 129
{
+ − 130
$add = " SELECTED" ;
+ − 131
}
+ − 132
?>
71
+ − 133
<option <?php echo $add ?> value=" <?php echo $u [ "id" ] ?> "> <?php echo $u [ "fullname" ] ?> </option> <?php
13
+ − 134
}
+ − 135
?>
+ − 136
</select>
+ − 137
</td>
+ − 138
<td>
71
+ − 139
<input type="submit" class="sbutton" name="co" value=" <?php echo _ ( 'Add' ); ?> ">
13
+ − 140
</td>
+ − 141
</form>
+ − 142
</tr>
+ − 143
</table>
71
+ − 144
</div> <?php // eo div meta-left ?>
13
+ − 145
< div id = "meta-right" >
+ − 146
< table >
+ − 147
< tr >
71
+ − 148
< th colspan = "2" ><? php echo _ ( 'Type of zone' ); ?> </th>
13
+ − 149
</tr>
71
+ − 150
<form action=" <?php echo $_SERVER [ 'PHP_SELF' ] ?> ?id= <?php echo $_GET [ 'id' ] ?> " method="post">
+ − 151
<input type="hidden" name="domain" value=" <?php echo $_GET [ "id" ] ?> ">
13
+ − 152
<tr>
+ − 153
<td>
+ − 154
<select name="newtype">
71
+ − 155
<?php
13
+ − 156
foreach ( $server_types as $s )
+ − 157
{
79
+ − 158
$add = '' ;
13
+ − 159
if ( $s == $domain_type )
+ − 160
{
+ − 161
$add = " SELECTED" ;
+ − 162
}
+ − 163
?>
71
+ − 164
<option <?php echo $add ?> value=" <?php echo $s ?> "> <?php echo $s ?> </option> <?php
13
+ − 165
}
+ − 166
?>
+ − 167
</select>
+ − 168
</td>
+ − 169
<td>
71
+ − 170
<input type="submit" class="sbutton" name="type_change" value=" <?php echo _ ( 'Change' ); ?> ">
13
+ − 171
</td>
+ − 172
</tr>
+ − 173
</form>
+ − 174
71
+ − 175
<?php
13
+ − 176
if ( $domain_type == "SLAVE" )
+ − 177
{
+ − 178
$slave_master = get_domain_slave_master ( $_GET [ 'id' ]);
+ − 179
?>
+ − 180
<tr>
+ − 181
<th colspan="2">
71
+ − 182
<?php echo _ ( 'IP address of master NS' ); ?>
13
+ − 183
</th>
+ − 184
</tr>
71
+ − 185
<form action=" <?php echo $_SERVER [ 'PHP_SELF' ] ?> ?&id= <?php echo $_GET [ 'id' ] ?> " method="post">
+ − 186
<input type="hidden" name="domain" value=" <?php echo $_GET [ "id" ] ?> ">
13
+ − 187
<tr>
+ − 188
<td>
71
+ − 189
<input type="text" name="slave_master" value=" <?php echo $slave_master ; ?> " class="input">
13
+ − 190
</td>
+ − 191
<td>
71
+ − 192
<input type="submit" class="sbutton" name="change_slave_master" value=" <?php echo _ ( 'Change' ); ?> ">
13
+ − 193
</td>
+ − 194
</tr>
+ − 195
</form>
71
+ − 196
<?php
13
+ − 197
}
1
+ − 198
?>
13
+ − 199
</table>
71
+ − 200
</div> <?php // eo div meta-right ?>
+ − 201
</ div > <? php // eo div meta
38
+ − 202
}
+ − 203
else
+ − 204
{
+ − 205
?>
+ − 206
<div id="meta">
+ − 207
<div id="meta-right">
+ − 208
<table>
+ − 209
<tr>
71
+ − 210
<th> <?php echo _ ( 'Type of zone' ); ?> </th><td class="y"> <?php echo $domain_type ; ?> </td>
38
+ − 211
</tr>
71
+ − 212
<?php
38
+ − 213
if ( $domain_type == "SLAVE" && $slave_master )
+ − 214
{
+ − 215
?>
+ − 216
<tr>
71
+ − 217
<th> <?php echo _ ( 'IP address of master NS' ); ?> </th><td class="y"> <?php echo $slave_master ; ?> </td>
38
+ − 218
</tr>
71
+ − 219
<?php
38
+ − 220
}
+ − 221
?>
+ − 222
</table>
71
+ − 223
</div> <?php //eo div meta-right ?>
+ − 224
</ div > <? php // eo div meta
38
+ − 225
}
+ − 226
?>
13
+ − 227
<div id="meta">
71
+ − 228
<?php
13
+ − 229
if ( $_SESSION [ $_GET [ "id" ] . "_ispartial" ] != 1 && $domain_type != "SLAVE" )
+ − 230
{
1
+ − 231
?>
71
+ − 232
<input type="button" class="button" OnClick="location.href='add_record.php?id= <?php echo $_GET [ "id" ] ?> '" value=" <?php echo _ ( 'Add record' ); ?> ">
+ − 233
<?php
13
+ − 234
}
+ − 235
if ( level ( 5 ))
+ − 236
{
+ − 237
?>
71
+ − 238
<input type="button" class="button" OnClick="location.href='delete_domain.php?id= <?php echo $_GET [ "id" ] ?> '" value=" <?php echo _ ( 'Delete zone' ); ?> ">
+ − 239
<?php
13
+ − 240
}
+ − 241
?>
71
+ − 242
</div> <?php // eo div meta ?>
13
+ − 243
< div class = "showmax" >
71
+ − 244
<? php
76
+ − 245
show_pages ( $info [ "numrec" ], ROWAMOUNT , $_GET [ "id" ]);
1
+ − 246
?>
71
+ − 247
</div> <?php // eo div showmax ?>
+ − 248
< form action = "<?php echo $_SERVER["PHP_SELF"] ?>?id=<?php echo $_GET["id"] ?>" method = "post" >
13
+ − 249
< input type = "hidden" name = "action" value = "record-user" >
+ − 250
< table >
71
+ − 251
<? php
1
+ − 252
$countinput = 0 ;
76
+ − 253
$rec_result = get_records_from_domain_id ( $_GET [ "id" ], ROWSTART , ROWAMOUNT );
1
+ − 254
if ( $rec_result != - 1 )
+ − 255
{
13
+ − 256
?>
+ − 257
<tr>
+ − 258
<th> </th>
71
+ − 259
<?php
13
+ − 260
if ( level ( 10 ) && $domain_type != "SLAVE" )
+ − 261
{
+ − 262
echo "<th class= \" n \" >" . _ ( 'Sub-owners' ) . "</td>" ;
+ − 263
}
+ − 264
?>
71
+ − 265
<th> <?php echo _ ( 'Name' ); ?> </th>
+ − 266
<th> <?php echo _ ( 'Type' ); ?> </th>
+ − 267
<th> <?php echo _ ( 'Content' ); ?> </th>
+ − 268
<th> <?php echo _ ( 'Priority' ); ?> </th>
+ − 269
<th> <?php echo _ ( 'TTL' ); ?> </th>
13
+ − 270
</tr>
71
+ − 271
<?php
13
+ − 272
$recs = sort_zone ( $rec_result );
+ − 273
foreach ( $recs as $r )
+ − 274
{
+ − 275
?>
+ − 276
<tr>
+ − 277
<td class="n">
71
+ − 278
<?php
13
+ − 279
if ( $domain_type != "SLAVE" )
+ − 280
{
+ − 281
if ( level ( 5 ) || ( ! ( $r [ "type" ] == "SOA" && ! $GLOBALS [ "ALLOW_SOA_EDIT" ]) && ! ( $r [ "type" ] == "NS" && ! $GLOBALS [ "ALLOW_NS_EDIT" ])))
+ − 282
{
+ − 283
?>
71
+ − 284
<a href="edit_record.php?id= <?php echo $r [ 'id' ] ?> &domain= <?php echo $_GET [ "id" ] ?> "><img src="images/edit.gif" alt="[ <?php echo _ ( 'Edit record' ); ?> ]"></a>
+ − 285
<a href="delete_record.php?id= <?php echo $r [ 'id' ] ?> &domain= <?php echo $_GET [ "id" ] ?> "><img src="images/delete.gif" ALT="[ <?php echo _ ( 'Delete record' ); ?> ]" BORDER="0"></a>
+ − 286
<?php
13
+ − 287
}
+ − 288
}
+ − 289
if ( level ( 10 ) && $domain_type != "SLAVE" )
+ − 290
{
+ − 291
?>
71
+ − 292
<input type="checkbox" name="rowid[ <?php echo $countinput ++ ?> ]" value=" <?php echo $r [ 'id' ] ?> " />
+ − 293
<?php
13
+ − 294
}
+ − 295
?>
+ − 296
</td>
71
+ − 297
<?php
13
+ − 298
if ( level ( 10 ) && $domain_type != "SLAVE" )
+ − 299
{
1
+ − 300
?>
13
+ − 301
<td class="n">
71
+ − 302
<?php
65
+ − 303
$x_result = $db -> query ( "SELECT r.user_id,u.username,u.fullname FROM record_owners as r, users as u WHERE r.record_id=" . $db -> quote ( $r [ 'id' ]) . " AND u.id=r.user_id" );
13
+ − 304
echo "<select style= \" width:120px; \" >" ;
+ − 305
while ( $x_r = $x_result -> fetchRow ()) {
+ − 306
echo "<option value= \" " . $x_r [ "username" ] . " \" >" . $x_r [ "fullname" ] . "</option>" ;
+ − 307
}
+ − 308
echo "</select>" ;
+ − 309
?>
+ − 310
</td>
71
+ − 311
<?php
13
+ − 312
}
+ − 313
?>
71
+ − 314
<td class="y"> <?php echo $r [ 'name' ] ?> </td>
+ − 315
<td class="y"> <?php echo $r [ 'type' ] ?> </td>
+ − 316
<td class="y"> <?php echo $r [ 'content' ] ?> </td>
+ − 317
<?php
13
+ − 318
if ( $r [ 'prio' ] != 0 )
+ − 319
{
+ − 320
?>
71
+ − 321
<td class="y"> <?php echo $r [ 'prio' ]; ?> </td>
+ − 322
<?php
13
+ − 323
} else {
+ − 324
?>
71
+ − 325
<td class="n"></td> <?php
13
+ − 326
}
+ − 327
?>
71
+ − 328
<td class="y"> <?php echo $r [ 'ttl' ] ?> </td>
13
+ − 329
</tr>
71
+ − 330
<?php
1
+ − 331
}
+ − 332
}
+ − 333
else
+ − 334
{
+ − 335
?>
13
+ − 336
<tr>
+ − 337
<td class="n">
71
+ − 338
<div class="warning"> <?php echo _ ( 'No records for this zone.' ); ?> </div>
13
+ − 339
</td>
+ − 340
</tr>
71
+ − 341
<?php
1
+ − 342
}
+ − 343
?>
13
+ − 344
</table>
1
+ − 345
71
+ − 346
<?php
13
+ − 347
if ( $domain_type != "SLAVE" )
+ − 348
{
+ − 349
if ( level ( 10 )) { ?>
+ − 350
<img src="images/arrow.png" alt="arrow" class="edit-assign-to-user">
+ − 351
<select name="userid">
71
+ − 352
<?php
13
+ − 353
$users = show_users ();
+ − 354
foreach ( $users as $user ) {
+ − 355
echo "<option value= \" " . $user [ id ] . " \" >" . $user [ fullname ] . "</option>" ;
+ − 356
}
+ − 357
?>
+ − 358
</select>
71
+ − 359
<input type="submit" class="button" value=" <?php echo _ ( 'Assign to user' ); ?> ">
13
+ − 360
</form>
71
+ − 361
<?php
13
+ − 362
}
1
+ − 363
}
+ − 364
include_once ( "inc/footer.inc.php" );
+ − 365
?>