1
+ − 1
<?php
+ − 2
119
+ − 3
/* Poweradmin, a friendly web-based admin tool for PowerDNS.
47
+ − 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
13
+ − 22
require_once ( "inc/toolkit.inc.php" );
82
+ − 23
include_once ( "inc/header.inc.php" );
1
+ − 24
126
+ − 25
if ( verify_permission ( 'zone_content_view_others' )) { $perm_view = "all" ; }
+ − 26
elseif ( verify_permission ( 'zone_content_view_own' )) { $perm_view = "own" ; }
82
+ − 27
else { $perm_view = "none" ; }
+ − 28
126
+ − 29
if ( verify_permission ( 'zone_content_edit_others' )) { $perm_content_edit = "all" ; }
+ − 30
elseif ( verify_permission ( 'zone_content_edit_own' )) { $perm_content_edit = "own" ; }
82
+ − 31
else { $perm_content_edit = "none" ; }
+ − 32
126
+ − 33
if ( verify_permission ( 'zone_meta_edit_others' )) { $perm_meta_edit = "all" ; }
+ − 34
elseif ( verify_permission ( 'zone_meta_edit_own' )) { $perm_meta_edit = "own" ; }
82
+ − 35
else { $perm_meta_edit = "none" ; }
+ − 36
+ − 37
$zone_id = "-1" ;
+ − 38
if (( isset ( $_GET [ 'id' ])) && ( v_num ( $_GET [ 'id' ]))) {
+ − 39
$zone_id = $_GET [ 'id' ];
+ − 40
}
+ − 41
136
+ − 42
$ttl = $dns_ttl ;
82
+ − 43
if (( isset ( $_POST [ 'ttl' ])) && ( v_num ( $_POST [ 'ttl' ]))) {
+ − 44
$ttl = $_POST [ 'ttl' ];
37
+ − 45
}
+ − 46
82
+ − 47
$prio = "10" ;
+ − 48
if (( isset ( $_GET [ 'prio' ])) && ( v_num ( $_GET [ 'prio' ]))) {
+ − 49
$prio = $_GET [ 'prio' ];
+ − 50
}
+ − 51
+ − 52
$name = $_POST [ 'name' ];
+ − 53
$type = $_POST [ 'type' ];
+ − 54
$content = $_POST [ 'content' ];
+ − 55
+ − 56
if ( $zone_id == "-1" ) {
+ − 57
error ( ERR_INV_INPUT );
+ − 58
include_once ( "inc/footer.inc.php" );
+ − 59
exit ;
+ − 60
}
+ − 61
+ − 62
$user_is_zone_owner = verify_user_is_owner_zoneid ( $zone_id );
+ − 63
$zone_type = get_domain_type ( $zone_id );
140
+ − 64
$zone_name = get_zone_name_from_id ( $zone_id );
82
+ − 65
+ − 66
if ( $_POST [ "commit" ]) {
+ − 67
if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) {
+ − 68
error ( ERR_PERM_ADD_RECORD );
+ − 69
} else {
+ − 70
if ( add_record ( $zone_id , $name , $type , $content , $ttl , $prio )) {
132
+ − 71
success ( _ ( 'The record was successfully added.' ));
82
+ − 72
unset ( $zone_id , $name , $type , $content , $ttl , $prio );
+ − 73
}
+ − 74
}
1
+ − 75
}
13
+ − 76
110
+ − 77
echo " <h2>" . _ ( 'Add record to zone' ) . " " . $zone_name . "</h2> \n " ;
1
+ − 78
82
+ − 79
if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) {
+ − 80
error ( ERR_PERM_ADD_RECORD );
+ − 81
} else {
+ − 82
echo " <form method= \" post \" > \n " ;
+ − 83
echo " <input type= \" hidden \" name= \" domain \" value= \" " . $zone_id . " \" > \n " ;
+ − 84
echo " <table border= \" 0 \" cellspacing= \" 4 \" > \n " ;
+ − 85
echo " <tr> \n " ;
+ − 86
echo " <td class= \" n \" >" . _ ( 'Name' ) . "</td> \n " ;
+ − 87
echo " <td class= \" n \" > </td> \n " ;
+ − 88
echo " <td class= \" n \" >" . _ ( 'Type' ) . "</td> \n " ;
+ − 89
echo " <td class= \" n \" >" . _ ( 'Priority' ) . "</td> \n " ;
+ − 90
echo " <td class= \" n \" >" . _ ( 'Content' ) . "</td> \n " ;
+ − 91
echo " <td class= \" n \" >" . _ ( 'TTL' ) . "</td> \n " ;
+ − 92
echo " </tr> \n " ;
+ − 93
echo " <tr> \n " ;
+ − 94
echo " <td class= \" n \" ><input type= \" text \" name= \" name \" class= \" input \" value= \" " . $name . " \" >." . $zone_name . "</td> \n " ;
+ − 95
echo " <td class= \" n \" >IN</td> \n " ;
+ − 96
echo " <td class= \" n \" > \n " ;
+ − 97
echo " <select name= \" type \" > \n " ;
+ − 98
foreach ( get_record_types () as $record_type ) {
+ − 99
if ( $type ) {
+ − 100
if ( $type == $record_type ) {
+ − 101
$add = " SELECTED" ;
+ − 102
} else {
+ − 103
unset ( $add );
+ − 104
}
+ − 105
} else {
+ − 106
if ( eregi ( 'in-addr.arpa' , $zone_name ) && strtoupper ( $record_type ) == 'PTR' ) {
+ − 107
$add = " SELECTED" ;
+ − 108
} elseif ( strtoupper ( $record_type ) == 'A' ) {
+ − 109
$add = " SELECTED" ;
+ − 110
} else {
+ − 111
unset ( $add );
+ − 112
}
+ − 113
}
+ − 114
echo " <option" . $add . " value= \" " . $record_type . " \" >" . $record_type . "</option> \n " ;
+ − 115
}
+ − 116
echo " </select> \n " ;
+ − 117
echo " </td> \n " ;
+ − 118
echo " <td class= \" n \" ><input type= \" text \" name= \" prio \" class= \" sinput \" value= \" " . $prio . " \" ></td> \n " ;
+ − 119
echo " <td class= \" n \" ><input type= \" text \" name= \" content \" class= \" input \" value= \" " . $content . " \" ></td> \n " ;
+ − 120
echo " <td class= \" n \" ><input type= \" text \" name= \" ttl \" class= \" sinput \" value= \" " . $ttl . " \" </td> \n " ;
+ − 121
echo " </tr> \n " ;
+ − 122
echo " </table> \n " ;
+ − 123
echo " <br> \n " ;
+ − 124
echo " <input type= \" submit \" name= \" commit \" value= \" " . _ ( 'Add record' ) . " \" class= \" button \" > \n " ;
+ − 125
echo " </form> \n " ;
1
+ − 126
}
82
+ − 127
+ − 128
include_once ( "inc/footer.inc.php" );
+ − 129
13
+ − 130
?>