142
+ − 1
<?php
+ − 2
156
+ − 3
if ( ! isset ( $_POST [ 'language' ])) {
+ − 4
$language = "en_EN" ;
+ − 5
} else {
+ − 6
$step = $_POST [ 'step' ];
+ − 7
}
+ − 8
+ − 9
+ − 10
151
+ − 11
$language = $_POST [ 'language' ];
+ − 12
setlocale ( LC_ALL , $language );
+ − 13
$gettext_domain = 'messages' ;
+ − 14
bindtextdomain ( $gettext_domain , "./../locale" );
+ − 15
textdomain ( $gettext_domain );
+ − 16
@ putenv ( 'LANG=' . $language );
+ − 17
@ putenv ( 'LANGUAGE=' . $language );
+ − 18
149
+ − 19
$local_config_file = "../inc/config.inc.php" ;
+ − 20
151
+ − 21
function error ( $msg ) {
+ − 22
if ( $msg ) {
+ − 23
echo " <div class= \" error \" >Error: " . $msg . "</div> \n " ;
+ − 24
} else {
+ − 25
echo " <div class= \" error \" >" . _ ( 'An unknown error has occurred.' ) . "</div> \n " ;
+ − 26
}
+ − 27
}
+ − 28
142
+ − 29
echo "<!DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.0 Transitional//EN \" > \n " ;
+ − 30
echo "<html> \n " ;
+ − 31
echo " <head> \n " ;
+ − 32
echo " <title>Poweradmin</title> \n " ;
+ − 33
echo " <link rel=stylesheet href= \" ../style/example.inc.php \" type= \" text/css \" > \n " ;
+ − 34
echo " </head> \n " ;
+ − 35
echo " <body> \n " ;
+ − 36
+ − 37
if ( ! isset ( $_POST [ 'step' ]) || ! is_numeric ( $_POST [ 'step' ])) {
+ − 38
$step = 1 ;
+ − 39
} else {
+ − 40
$step = $_POST [ 'step' ];
+ − 41
}
+ − 42
+ − 43
echo " <h1>Poweradmin</h1>" ;
151
+ − 44
echo " <h2>" . _ ( 'Installation step' ) . " " . $step . "</h2>" ;
142
+ − 45
+ − 46
switch ( $step ) {
151
+ − 47
142
+ − 48
case 1 :
+ − 49
$step ++ ;
151
+ − 50
+ − 51
echo "<p> \n " ;
+ − 52
echo " <form method= \" post \" > \n " ;
+ − 53
echo " <input type= \" radio \" name= \" language \" value= \" en_EN \" > I prefer to proceed in english.<br> \n " ;
+ − 54
echo " <input type= \" radio \" name= \" language \" value= \" nl_NL \" > Ik ga graag verder in het Nederlands.<br><br> \n " ;
+ − 55
echo " <input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
+ − 56
echo " <input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
+ − 57
echo " </form> \n " ;
+ − 58
echo "</p> \n " ;
+ − 59
break ;
+ − 60
+ − 61
case 2 :
+ − 62
$step ++ ;
+ − 63
+ − 64
echo "<p>" . _ ( 'This installer expects you to have a PowerDNS database accessable from this server. This installer also expects you to have never ran Poweradmin before, or that you want to overwrite the Poweradmin part of the database. If you have had Poweradmin running before, any data in the following tables will be destroyed: perm_items, perm_templ, perm_templ_items, users and zones. This installer will, of course, not touch the data in the PowerDNS tables of the database. However, it is recommended that you create a backup of your database before proceeding.' ) . "</p> \n " ;
+ − 65
+ − 66
echo "<p>" . _ ( 'The alternative for this installer is a manual installation. Refer to the poweradmin.org website if you want to go down that road.' ) . "</p> \n " ;
+ − 67
+ − 68
echo "<p>" . _ ( 'Finally, if you see any errors during the installation process, a problem report would be appreciated. You can report problems (and ask for help) on the poweradmin-users mailinglist.' ) . "</p>" ;
+ − 69
+ − 70
echo "<p>" . _ ( 'Do you want to proceed now?' ) . "</p> \n " ;
+ − 71
142
+ − 72
echo "<form method= \" post \" >" ;
151
+ − 73
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
142
+ − 74
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
151
+ − 75
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
142
+ − 76
echo "</form>" ;
+ − 77
break ;
+ − 78
151
+ − 79
case 3 :
142
+ − 80
$step ++ ;
151
+ − 81
echo "<p>" . _ ( 'To prepare the database for using Poweradmin, the installer needs to modify the PowerDNS database. It will add a number of tables and it will fill these tables with some data. If the tables are already present, the installer will drop them first.' ) . "</p>" ;
+ − 82
+ − 83
echo "<p>" . _ ( 'To do all of this, the installer needs to access the database with an account which has sufficient rights. If you trust the installer, you may give it the username and password of the database user root. Otherwise, make sure the user has enough rights, before actually proceeding.' ) . "</p>" ;
+ − 84
142
+ − 85
echo "<form method= \" post \" >" ;
151
+ − 86
echo " <table> \n " ;
+ − 87
echo " <tr> \n " ;
+ − 88
echo " <td>" . _ ( 'Username' ) . "</td> \n " ;
+ − 89
echo " <td><input type= \" text \" name= \" user \" value= \"\" ></td> \n " ;
+ − 90
echo " <td>" . _ ( 'The username to use to connect to the database, make sure the username has sufficient rights to perform administrative task to the PowerDNS database (the installer wants to drop, create and fill tables to the database).' ) . "</td> \n " ;
+ − 91
echo " </tr> \n " ;
+ − 92
echo " <tr> \n " ;
+ − 93
echo " <td>" . _ ( 'Password' ) . "</td> \n " ;
+ − 94
echo " <td><input type= \" password \" name= \" pass \" value= \"\" ></td> \n " ;
+ − 95
echo " <td>" . _ ( 'The password for this username.' ) . "</td> \n " ;
+ − 96
echo " </tr> \n " ;
+ − 97
echo " <tr> \n " ;
+ − 98
echo " <td>" . _ ( 'Hostname' ) . "</td> \n " ;
+ − 99
echo " <td><input type= \" text \" name= \" host \" value= \"\" ></td> \n " ;
+ − 100
echo " <td>" . _ ( 'The hostname on which the PowerDNS database resides. Frequently, this will be "localhost".' ) . "</td> \n " ;
+ − 101
echo " </tr> \n " ;
+ − 102
echo " <tr> \n " ;
+ − 103
echo " <td>" . _ ( 'Database' ) . "</td> \n " ;
+ − 104
echo " <td><input type= \" text \" name= \" name \" value= \"\" ></td> \n " ;
+ − 105
echo " <td>" . _ ( 'The name of the PowerDNS database.' ) . "</td> \n " ;
+ − 106
echo " </tr> \n " ;
+ − 107
echo " <tr> \n " ;
+ − 108
echo " <td>" . _ ( 'Database type' ) . "</td> \n " ;
+ − 109
echo " <td>" .
+ − 110
"<select name= \" type \" >" .
+ − 111
"<option value= \" mysql \" >MySQL</option>" .
+ − 112
"<option value= \" pgsql \" >PostgreSQL</option>" .
+ − 113
"</td> \n " ;
+ − 114
echo " <td>" . _ ( 'The type of the PowerDNS database.' ) . "</td> \n " ;
+ − 115
echo " </tr> \n " ;
165
+ − 116
echo " <tr> \n " ;
+ − 117
echo " <td>" . _ ( 'Poweradmin administrator password' ) . "</td> \n " ;
+ − 118
echo " <td><input type= \" text \" name= \" pa_pass \" value= \"\" ></td> \n " ;
+ − 119
echo " <td>" . _ ( 'The password of the Poweradmin administrator. This administrator has full rights to Poweradmin using the web interface.' ) . "</td> \n " ;
+ − 120
echo " </tr> \n " ;
142
+ − 121
echo "</table> \n " ;
+ − 122
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
151
+ − 123
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
+ − 124
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
142
+ − 125
echo "</form>" ;
+ − 126
break ;
+ − 127
151
+ − 128
case 4 :
142
+ − 129
$step ++ ;
151
+ − 130
echo "<p>" . _ ( 'Updating database...' ) . " " ;
142
+ − 131
include_once ( "../inc/config-me.inc.php" );
+ − 132
$db_user = $_POST [ 'user' ];
+ − 133
$db_pass = $_POST [ 'pass' ];
+ − 134
$db_host = $_POST [ 'host' ];
+ − 135
$db_name = $_POST [ 'name' ];
146
+ − 136
$db_type = $_POST [ 'type' ];
165
+ − 137
$pa_pass = $_POST [ 'pa_pass' ];
142
+ − 138
require_once ( "../inc/database.inc.php" );
+ − 139
$db = dbConnect ();
+ − 140
$db -> loadModule ( 'Manager' );
+ − 141
$db -> loadModule ( 'Extended' );
165
+ − 142
include_once ( "database-structure.inc.php" );
142
+ − 143
$current_tables = $db -> listTables ();
+ − 144
foreach ( $def_tables as $table ) {
+ − 145
if ( in_array ( $table [ 'table_name' ], $current_tables )) $db -> dropTable ( $table [ 'table_name' ]);
+ − 146
$db -> createTable ( $table [ 'table_name' ], $table [ 'fields' ]);
+ − 147
}
+ − 148
$fill_perm_items = $db -> prepare ( 'INSERT INTO perm_items VALUES (?, ?, ?)' );
+ − 149
$db -> extended -> executeMultiple ( $fill_perm_items , $def_permissions );
+ − 150
$fill_perm_items -> free ();
+ − 151
foreach ( $def_remaining_queries as $query ) {
+ − 152
$db -> query ( $query );
+ − 153
}
151
+ − 154
echo _ ( 'done!' ) . "</p>" ;
142
+ − 155
156
+ − 156
echo "<p>" . _ ( 'Now we will gather all details for the configuration itself.' ) . "</p> \n " ;
142
+ − 157
echo "<form method= \" post \" >" ;
151
+ − 158
echo " <table>" ;
+ − 159
echo " <tr>" ;
+ − 160
echo " <td>" . _ ( 'Username' ) . "</td> \n " ;
+ − 161
echo " <td><input type= \" text \" name= \" db_user \" value= \"\" ></td> \n " ;
156
+ − 162
echo " <td>" . _ ( 'The username for Poweradmin. This new user will have limited rights only.' ) . "</td> \n " ;
151
+ − 163
echo " </tr> \n " ;
+ − 164
echo " <tr> \n " ;
+ − 165
echo " <td>" . _ ( 'Password' ) . "</td> \n " ;
+ − 166
echo " <td><input type= \" text \" name= \" db_pass \" value= \"\" ></td> \n " ;
+ − 167
echo " <td>" . _ ( 'The password for this username.' ) . "</td> \n " ;
+ − 168
echo " </tr> \n " ;
+ − 169
echo " <tr> \n " ;
+ − 170
echo " <td>" . _ ( 'Hostmaster' ) . "</td> \n " ;
+ − 171
echo " <td><input type= \" text \" name= \" dns_hostmaster \" value= \"\" ></td> \n " ;
+ − 172
echo " <td>" . _ ( 'When creating SOA records and no hostmaster is provided, this value here will be used. Should be in the form "hostmaster.example.net".' ) . "</td> \n " ;
+ − 173
echo " </tr> \n " ;
+ − 174
echo " <tr> \n " ;
+ − 175
echo " <td>" . _ ( 'Primary nameserver' ) . "</td> \n " ;
+ − 176
echo " <td><input type= \" text \" name= \" dns_ns1 \" value= \"\" ></td> \n " ;
+ − 177
echo " <td>" . _ ( 'When creating new zones using the template, this value will be used as primary nameserver. Should be like "ns1.example.net".' ) . "</td> \n " ;
+ − 178
echo " </tr> \n " ;
+ − 179
echo " <tr> \n " ;
+ − 180
echo " <td>" . _ ( 'Secondary nameserver' ) . "</td> \n " ;;
+ − 181
echo " <td><input type= \" text \" name= \" dns_ns2 \" value= \"\" ></td> \n " ;
+ − 182
echo " <td>" . _ ( 'When creating new zones using the template, this value will be used as secondary nameserver. Should be like "ns2.example.net".' ) . "</td> \n " ;
+ − 183
echo " </tr> \n " ;
142
+ − 184
echo "</table>" ;
+ − 185
echo "<input type= \" hidden \" name= \" db_host \" value= \" " . $db_host . " \" >" ;
+ − 186
echo "<input type= \" hidden \" name= \" db_name \" value= \" " . $db_name . " \" >" ;
+ − 187
echo "<input type= \" hidden \" name= \" db_type \" value= \" " . $db_type . " \" >" ;
165
+ − 188
echo "<input type= \" hidden \" name= \" pa_pass \" value= \" " . $pa_pass . " \" >" ;
142
+ − 189
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
151
+ − 190
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
+ − 191
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
142
+ − 192
echo "</form>" ;
+ − 193
break ;
+ − 194
156
+ − 195
case 5 :
+ − 196
$step ++ ;
+ − 197
$db_user = $_POST [ 'db_user' ];
+ − 198
$db_pass = $_POST [ 'db_pass' ];
+ − 199
$db_host = $_POST [ 'db_host' ];
+ − 200
$db_name = $_POST [ 'db_name' ];
+ − 201
$db_type = $_POST [ 'db_type' ];
165
+ − 202
$pa_pass = $_POST [ 'pa_pass' ];
180
+ − 203
$pa_srvr = getenv ( 'SERVER_NAME' );
156
+ − 204
$dns_hostmaster = $_POST [ 'dns_hostmaster' ];
+ − 205
$dns_ns1 = $_POST [ 'dns_ns1' ];
+ − 206
$dns_ns2 = $_POST [ 'dns_ns2' ];
+ − 207
189
+ − 208
require_once ( "../inc/database.inc.php" );
+ − 209
$db = dbConnect ();
+ − 210
include_once ( "database-structure.inc.php" );
+ − 211
156
+ − 212
echo "<p>" . _ ( 'You now want to give limited rights to Poweradmin so it can update the data in the tables. To do this, you should create a new user and give it rights to select, delete, insert and update records in the PowerDNS database.' ) . " " ;
+ − 213
if ( $db_type == 'mysql' ) {
+ − 214
echo _ ( 'In MySQL you should now perform the following command:' ) . "</p>" ;
180
+ − 215
echo "<p><tt>GRANT SELECT, INSERT, UPDATE, DELETE<BR>ON " . $db_name . ".*<br>TO '" . $db_user . "'@'" . $pa_srvr . "'<br>IDENTIFIED BY '" . $db_pass . "';</tt></p>" ;
156
+ − 216
} elseif ( $db_type == 'pgsql' ) {
+ − 217
echo _ ( 'On PgSQL you would use:' ) . "</p>" ;
157
+ − 218
echo "<p><tt>$ createuser -E -P " . $db_user . "<br>" .
+ − 219
"Enter password for new role: " . $db_pass . "<br>" .
+ − 220
"Enter it again: " . $db_pass . "<br>" .
159
+ − 221
"Shall the new role be a superuser? (y/n) n<br>" .
156
+ − 222
"Shall the new user be allowed to create databases? (y/n) n<br>" .
+ − 223
"Shall the new user be allowed to create more new users? (y/n) n<br>" .
+ − 224
"CREATE USER<br>" .
189
+ − 225
"$ psql " . $db_name . "<br>" ;
+ − 226
foreach ( $grantTables as $tableName ) {
+ − 227
echo "psql> GRANT SELECT, INSERT, DELETE, UPDATE ON " . $tableName . " TO " . $db_user . ";<br />" ;
+ − 228
echo "GRANT<br />" ;
+ − 229
}
+ − 230
echo "</tt></p> \n " ;
156
+ − 231
}
+ − 232
echo "<p>" . _ ( 'After you have added the new user, proceed with this installation procedure.' ) . "</p> \n " ;
+ − 233
echo "<form method= \" post \" >" ;
+ − 234
echo "<input type= \" hidden \" name= \" db_host \" value= \" " . $db_host . " \" >" ;
+ − 235
echo "<input type= \" hidden \" name= \" db_name \" value= \" " . $db_name . " \" >" ;
+ − 236
echo "<input type= \" hidden \" name= \" db_type \" value= \" " . $db_type . " \" >" ;
+ − 237
echo "<input type= \" hidden \" name= \" db_user \" value= \" " . $db_user . " \" >" ;
+ − 238
echo "<input type= \" hidden \" name= \" db_pass \" value= \" " . $db_pass . " \" >" ;
165
+ − 239
echo "<input type= \" hidden \" name= \" pa_pass \" value= \" " . $pa_pass . " \" >" ;
156
+ − 240
echo "<input type= \" hidden \" name= \" dns_hostmaster \" value= \" " . $dns_hostmaster . " \" >" ;
+ − 241
echo "<input type= \" hidden \" name= \" dns_ns1 \" value= \" " . $dns_ns1 . " \" >" ;
+ − 242
echo "<input type= \" hidden \" name= \" dns_ns2 \" value= \" " . $dns_ns2 . " \" >" ;
+ − 243
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
+ − 244
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
+ − 245
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
+ − 246
echo "</form>" ;
+ − 247
break ;
+ − 248
151
+ − 249
case 6 :
142
+ − 250
$step ++ ;
165
+ − 251
$pa_pass = $_POST [ 'pa_pass' ];
155
+ − 252
$config = "<?php \n\n " .
150
+ − 253
" \$ db_host \t\t = \" " . $_POST [ 'db_host' ] . " \" ; \n " .
142
+ − 254
" \$ db_user \t\t = \" " . $_POST [ 'db_user' ] . " \" ; \n " .
+ − 255
" \$ db_pass \t\t = \" " . $_POST [ 'db_pass' ] . " \" ; \n " .
+ − 256
" \$ db_name \t\t = \" " . $_POST [ 'db_name' ] . " \" ; \n " .
+ − 257
" \$ db_type \t\t = \" " . $_POST [ 'db_type' ] . " \" ; \n " .
+ − 258
" \n " .
151
+ − 259
" \$ iface_lang \t\t = \" " . $_POST [ 'language' ] . " \" ; \n " .
+ − 260
" \n " .
142
+ − 261
" \$ dns_hostmaster \t\t = \" " . $_POST [ 'dns_hostmaster' ] . " \" ; \n " .
+ − 262
" \$ dns_ns1 \t\t = \" " . $_POST [ 'dns_ns1' ] . " \" ; \n " .
+ − 263
" \$ dns_ns2 \t\t = \" " . $_POST [ 'dns_ns2' ] . " \" ; \n " .
150
+ − 264
" \n ?> \n " ;
+ − 265
+ − 266
if ( is_writeable ( $local_config_file )) {
+ − 267
$h_config = fopen ( $local_config_file , "w" );
+ − 268
fwrite ( $h_config , $config );
+ − 269
fclose ( $h_config );
151
+ − 270
echo "<p>" . _ ( 'The installer was able to write to the file "' ) . $local_config_file . _ ( '". A basic configuration, based on the details you have given, has been created.' ) . "</p> \n " ;
150
+ − 271
} else {
151
+ − 272
echo "<p>" . _ ( 'The installer is unable to write to the file "' ) . $local_config_file . _ ( '" (which is in itself good). The configuration is printed here. You should now create the file "' ) . $local_config_file . _ ( '" in the Poweradmin root directory yourself. It should contain the following few lines:' ) . "</p> \n " ;
150
+ − 273
echo "<pre>" ;
152
+ − 274
echo htmlentities ( $config );
150
+ − 275
echo "</pre>" ;
+ − 276
};
142
+ − 277
echo "<form method= \" post \" >" ;
165
+ − 278
echo "<input type= \" hidden \" name= \" pa_pass \" value= \" " . $pa_pass . " \" >" ;
142
+ − 279
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
151
+ − 280
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
+ − 281
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
142
+ − 282
echo "</form>" ;
+ − 283
break ;
+ − 284
151
+ − 285
case 7 :
142
+ − 286
$step ++ ;
151
+ − 287
echo "<p>" . _ ( 'Now we have finished the configuration, you should (must!) remove the directory "install/" from the Poweradmin root directory. You will not be able to use Poweradmin if it exists. Do it now.' ) . "</p>" ;
178
+ − 288
echo "<p>" . _ ( 'After you have removed the directory, you can login to <a href="../index.php">Poweradmin</a> with username "admin" and password "' ) . $_POST [ 'pa_pass' ] . _ ( '". You are highly encouraged to change these as soon as you are logged in.' ) . "</p>" ;
142
+ − 289
break ;
+ − 290
+ − 291
default :
+ − 292
break ;
+ − 293
}
+ − 294
+ − 295
echo "<div class= \" footer \" >" ;
+ − 296
echo "<a href= \" https://www.poweradmin.org/ \" >a complete(r) <strong>poweradmin</strong></a> - <a href= \" https://www.poweradmin.org/trac/wiki/Credits \" >credits</a>" ;
+ − 297
echo "</div></body></html>" ;
+ − 298
+ − 299
?>
+ − 300
+ − 301
+ − 302