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 " ;
142
+ − 116
echo "</table> \n " ;
+ − 117
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
151
+ − 118
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
+ − 119
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
142
+ − 120
echo "</form>" ;
+ − 121
break ;
+ − 122
151
+ − 123
case 4 :
142
+ − 124
$step ++ ;
151
+ − 125
echo "<p>" . _ ( 'Updating database...' ) . " " ;
142
+ − 126
include_once ( "../inc/config-me.inc.php" );
+ − 127
include_once ( "database-structure.inc.php" );
+ − 128
$db_user = $_POST [ 'user' ];
+ − 129
$db_pass = $_POST [ 'pass' ];
+ − 130
$db_host = $_POST [ 'host' ];
+ − 131
$db_name = $_POST [ 'name' ];
146
+ − 132
$db_type = $_POST [ 'type' ];
142
+ − 133
require_once ( "../inc/database.inc.php" );
+ − 134
$db = dbConnect ();
+ − 135
$db -> loadModule ( 'Manager' );
+ − 136
$db -> loadModule ( 'Extended' );
+ − 137
$current_tables = $db -> listTables ();
+ − 138
foreach ( $def_tables as $table ) {
+ − 139
if ( in_array ( $table [ 'table_name' ], $current_tables )) $db -> dropTable ( $table [ 'table_name' ]);
+ − 140
$db -> createTable ( $table [ 'table_name' ], $table [ 'fields' ]);
+ − 141
}
+ − 142
$fill_perm_items = $db -> prepare ( 'INSERT INTO perm_items VALUES (?, ?, ?)' );
+ − 143
$db -> extended -> executeMultiple ( $fill_perm_items , $def_permissions );
+ − 144
$fill_perm_items -> free ();
+ − 145
foreach ( $def_remaining_queries as $query ) {
+ − 146
$db -> query ( $query );
+ − 147
}
151
+ − 148
echo _ ( 'done!' ) . "</p>" ;
142
+ − 149
156
+ − 150
echo "<p>" . _ ( 'Now we will gather all details for the configuration itself.' ) . "</p> \n " ;
142
+ − 151
echo "<form method= \" post \" >" ;
151
+ − 152
echo " <table>" ;
+ − 153
echo " <tr>" ;
+ − 154
echo " <td>" . _ ( 'Username' ) . "</td> \n " ;
+ − 155
echo " <td><input type= \" text \" name= \" db_user \" value= \"\" ></td> \n " ;
156
+ − 156
echo " <td>" . _ ( 'The username for Poweradmin. This new user will have limited rights only.' ) . "</td> \n " ;
151
+ − 157
echo " </tr> \n " ;
+ − 158
echo " <tr> \n " ;
+ − 159
echo " <td>" . _ ( 'Password' ) . "</td> \n " ;
+ − 160
echo " <td><input type= \" text \" name= \" db_pass \" value= \"\" ></td> \n " ;
+ − 161
echo " <td>" . _ ( 'The password for this username.' ) . "</td> \n " ;
+ − 162
echo " </tr> \n " ;
+ − 163
echo " <tr> \n " ;
+ − 164
echo " <td>" . _ ( 'Hostmaster' ) . "</td> \n " ;
+ − 165
echo " <td><input type= \" text \" name= \" dns_hostmaster \" value= \"\" ></td> \n " ;
+ − 166
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 " ;
+ − 167
echo " </tr> \n " ;
+ − 168
echo " <tr> \n " ;
+ − 169
echo " <td>" . _ ( 'Primary nameserver' ) . "</td> \n " ;
+ − 170
echo " <td><input type= \" text \" name= \" dns_ns1 \" value= \"\" ></td> \n " ;
+ − 171
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 " ;
+ − 172
echo " </tr> \n " ;
+ − 173
echo " <tr> \n " ;
+ − 174
echo " <td>" . _ ( 'Secondary nameserver' ) . "</td> \n " ;;
+ − 175
echo " <td><input type= \" text \" name= \" dns_ns2 \" value= \"\" ></td> \n " ;
+ − 176
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 " ;
+ − 177
echo " </tr> \n " ;
142
+ − 178
echo "</table>" ;
+ − 179
echo "<input type= \" hidden \" name= \" db_host \" value= \" " . $db_host . " \" >" ;
+ − 180
echo "<input type= \" hidden \" name= \" db_name \" value= \" " . $db_name . " \" >" ;
+ − 181
echo "<input type= \" hidden \" name= \" db_type \" value= \" " . $db_type . " \" >" ;
+ − 182
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
151
+ − 183
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
+ − 184
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
142
+ − 185
echo "</form>" ;
+ − 186
break ;
+ − 187
156
+ − 188
case 5 :
+ − 189
$step ++ ;
+ − 190
$db_user = $_POST [ 'db_user' ];
+ − 191
$db_pass = $_POST [ 'db_pass' ];
+ − 192
$db_host = $_POST [ 'db_host' ];
+ − 193
$db_name = $_POST [ 'db_name' ];
+ − 194
$db_type = $_POST [ 'db_type' ];
+ − 195
$dns_hostmaster = $_POST [ 'dns_hostmaster' ];
+ − 196
$dns_ns1 = $_POST [ 'dns_ns1' ];
+ − 197
$dns_ns2 = $_POST [ 'dns_ns2' ];
+ − 198
+ − 199
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.' ) . " " ;
+ − 200
if ( $db_type == 'mysql' ) {
+ − 201
echo _ ( 'In MySQL you should now perform the following command:' ) . "</p>" ;
+ − 202
echo "<p><tt>GRANT SELECT, INSERT, UPDATE, DELETE<BR>ON " . $db_name . ".*<br>TO '" . $db_user . "'@'" . $db_host . "'<br>IDENTIFIED BY '" . $db_pass . "';</tt></p>" ;
+ − 203
} elseif ( $db_type == 'pgsql' ) {
+ − 204
echo _ ( 'On PgSQL you would use:' ) . "</p>" ;
157
+ − 205
echo "<p><tt>$ createuser -E -P " . $db_user . "<br>" .
+ − 206
"Enter password for new role: " . $db_pass . "<br>" .
+ − 207
"Enter it again: " . $db_pass . "<br>" .
159
+ − 208
"Shall the new role be a superuser? (y/n) n<br>" .
156
+ − 209
"Shall the new user be allowed to create databases? (y/n) n<br>" .
+ − 210
"Shall the new user be allowed to create more new users? (y/n) n<br>" .
+ − 211
"CREATE USER<br>" .
+ − 212
"$ psql " . $db_name . "<br>" .
+ − 213
"psql> GRANT SELECT, INSERT, DELETE, UPDATE<br>" .
+ − 214
"ON " . $db_name . "<br>" .
+ − 215
"TO " . $db_user . ";</tt></p> \n " ;
+ − 216
}
+ − 217
echo "<p>" . _ ( 'After you have added the new user, proceed with this installation procedure.' ) . "</p> \n " ;
+ − 218
echo "<form method= \" post \" >" ;
+ − 219
echo "<input type= \" hidden \" name= \" db_host \" value= \" " . $db_host . " \" >" ;
+ − 220
echo "<input type= \" hidden \" name= \" db_name \" value= \" " . $db_name . " \" >" ;
+ − 221
echo "<input type= \" hidden \" name= \" db_type \" value= \" " . $db_type . " \" >" ;
+ − 222
echo "<input type= \" hidden \" name= \" db_user \" value= \" " . $db_user . " \" >" ;
+ − 223
echo "<input type= \" hidden \" name= \" db_pass \" value= \" " . $db_pass . " \" >" ;
+ − 224
echo "<input type= \" hidden \" name= \" dns_hostmaster \" value= \" " . $dns_hostmaster . " \" >" ;
+ − 225
echo "<input type= \" hidden \" name= \" dns_ns1 \" value= \" " . $dns_ns1 . " \" >" ;
+ − 226
echo "<input type= \" hidden \" name= \" dns_ns2 \" value= \" " . $dns_ns2 . " \" >" ;
+ − 227
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
+ − 228
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
+ − 229
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
+ − 230
echo "</form>" ;
+ − 231
break ;
+ − 232
151
+ − 233
case 6 :
142
+ − 234
$step ++ ;
155
+ − 235
$config = "<?php \n\n " .
150
+ − 236
" \$ db_host \t\t = \" " . $_POST [ 'db_host' ] . " \" ; \n " .
142
+ − 237
" \$ db_user \t\t = \" " . $_POST [ 'db_user' ] . " \" ; \n " .
+ − 238
" \$ db_pass \t\t = \" " . $_POST [ 'db_pass' ] . " \" ; \n " .
+ − 239
" \$ db_name \t\t = \" " . $_POST [ 'db_name' ] . " \" ; \n " .
+ − 240
" \$ db_type \t\t = \" " . $_POST [ 'db_type' ] . " \" ; \n " .
+ − 241
" \n " .
151
+ − 242
" \$ iface_lang \t\t = \" " . $_POST [ 'language' ] . " \" ; \n " .
+ − 243
" \n " .
142
+ − 244
" \$ dns_hostmaster \t\t = \" " . $_POST [ 'dns_hostmaster' ] . " \" ; \n " .
+ − 245
" \$ dns_ns1 \t\t = \" " . $_POST [ 'dns_ns1' ] . " \" ; \n " .
+ − 246
" \$ dns_ns2 \t\t = \" " . $_POST [ 'dns_ns2' ] . " \" ; \n " .
150
+ − 247
" \n ?> \n " ;
+ − 248
+ − 249
if ( is_writeable ( $local_config_file )) {
+ − 250
$h_config = fopen ( $local_config_file , "w" );
+ − 251
fwrite ( $h_config , $config );
+ − 252
fclose ( $h_config );
151
+ − 253
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
+ − 254
} else {
151
+ − 255
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
+ − 256
echo "<pre>" ;
152
+ − 257
echo htmlentities ( $config );
150
+ − 258
echo "</pre>" ;
+ − 259
};
142
+ − 260
echo "<form method= \" post \" >" ;
+ − 261
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
151
+ − 262
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
+ − 263
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
142
+ − 264
echo "</form>" ;
+ − 265
break ;
+ − 266
151
+ − 267
case 7 :
142
+ − 268
$step ++ ;
151
+ − 269
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>" ;
+ − 270
echo "<p>" . _ ( 'After you have removed the directory, you can login to <a href="index.php">Poweradmin</a> with username "admin" and password "admin". You are highly encouraged to change these as soon as you are logged in.' ) . "</p>" ;
142
+ − 271
break ;
+ − 272
+ − 273
default :
+ − 274
break ;
+ − 275
}
+ − 276
+ − 277
echo "<div class= \" footer \" >" ;
+ − 278
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>" ;
+ − 279
echo "</div></body></html>" ;
+ − 280
+ − 281
?>
+ − 282
+ − 283
+ − 284