142
+ − 1
<?php
+ − 2
151
+ − 3
$language = $_POST [ 'language' ];
+ − 4
setlocale ( LC_ALL , $language );
+ − 5
$gettext_domain = 'messages' ;
+ − 6
bindtextdomain ( $gettext_domain , "./../locale" );
+ − 7
textdomain ( $gettext_domain );
+ − 8
@ putenv ( 'LANG=' . $language );
+ − 9
@ putenv ( 'LANGUAGE=' . $language );
+ − 10
149
+ − 11
$local_config_file = "../inc/config.inc.php" ;
+ − 12
151
+ − 13
function error ( $msg ) {
+ − 14
if ( $msg ) {
+ − 15
echo " <div class= \" error \" >Error: " . $msg . "</div> \n " ;
+ − 16
} else {
+ − 17
echo " <div class= \" error \" >" . _ ( 'An unknown error has occurred.' ) . "</div> \n " ;
+ − 18
}
+ − 19
}
+ − 20
142
+ − 21
echo "<!DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.0 Transitional//EN \" > \n " ;
+ − 22
echo "<html> \n " ;
+ − 23
echo " <head> \n " ;
+ − 24
echo " <title>Poweradmin</title> \n " ;
+ − 25
echo " <link rel=stylesheet href= \" ../style/example.inc.php \" type= \" text/css \" > \n " ;
+ − 26
echo " </head> \n " ;
+ − 27
echo " <body> \n " ;
+ − 28
+ − 29
if ( ! isset ( $_POST [ 'step' ]) || ! is_numeric ( $_POST [ 'step' ])) {
+ − 30
$step = 1 ;
+ − 31
} else {
+ − 32
$step = $_POST [ 'step' ];
+ − 33
}
+ − 34
+ − 35
echo " <h1>Poweradmin</h1>" ;
151
+ − 36
echo " <h2>" . _ ( 'Installation step' ) . " " . $step . "</h2>" ;
142
+ − 37
+ − 38
switch ( $step ) {
151
+ − 39
142
+ − 40
case 1 :
+ − 41
$step ++ ;
151
+ − 42
+ − 43
echo "<p> \n " ;
+ − 44
echo " <form method= \" post \" > \n " ;
+ − 45
echo " <input type= \" radio \" name= \" language \" value= \" en_EN \" > I prefer to proceed in english.<br> \n " ;
+ − 46
echo " <input type= \" radio \" name= \" language \" value= \" nl_NL \" > Ik ga graag verder in het Nederlands.<br><br> \n " ;
+ − 47
echo " <input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
+ − 48
echo " <input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
+ − 49
echo " </form> \n " ;
+ − 50
echo "</p> \n " ;
+ − 51
break ;
+ − 52
+ − 53
case 2 :
+ − 54
$step ++ ;
+ − 55
+ − 56
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 " ;
+ − 57
+ − 58
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 " ;
+ − 59
+ − 60
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>" ;
+ − 61
+ − 62
echo "<p>" . _ ( 'Do you want to proceed now?' ) . "</p> \n " ;
+ − 63
142
+ − 64
echo "<form method= \" post \" >" ;
151
+ − 65
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
142
+ − 66
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
151
+ − 67
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
142
+ − 68
echo "</form>" ;
+ − 69
break ;
+ − 70
151
+ − 71
case 3 :
142
+ − 72
$step ++ ;
151
+ − 73
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>" ;
+ − 74
+ − 75
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>" ;
+ − 76
142
+ − 77
echo "<form method= \" post \" >" ;
151
+ − 78
echo " <table> \n " ;
+ − 79
echo " <tr> \n " ;
+ − 80
echo " <td>" . _ ( 'Username' ) . "</td> \n " ;
+ − 81
echo " <td><input type= \" text \" name= \" user \" value= \"\" ></td> \n " ;
+ − 82
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 " ;
+ − 83
echo " </tr> \n " ;
+ − 84
echo " <tr> \n " ;
+ − 85
echo " <td>" . _ ( 'Password' ) . "</td> \n " ;
+ − 86
echo " <td><input type= \" password \" name= \" pass \" value= \"\" ></td> \n " ;
+ − 87
echo " <td>" . _ ( 'The password for this username.' ) . "</td> \n " ;
+ − 88
echo " </tr> \n " ;
+ − 89
echo " <tr> \n " ;
+ − 90
echo " <td>" . _ ( 'Hostname' ) . "</td> \n " ;
+ − 91
echo " <td><input type= \" text \" name= \" host \" value= \"\" ></td> \n " ;
+ − 92
echo " <td>" . _ ( 'The hostname on which the PowerDNS database resides. Frequently, this will be "localhost".' ) . "</td> \n " ;
+ − 93
echo " </tr> \n " ;
+ − 94
echo " <tr> \n " ;
+ − 95
echo " <td>" . _ ( 'Database' ) . "</td> \n " ;
+ − 96
echo " <td><input type= \" text \" name= \" name \" value= \"\" ></td> \n " ;
+ − 97
echo " <td>" . _ ( 'The name of the PowerDNS database.' ) . "</td> \n " ;
+ − 98
echo " </tr> \n " ;
+ − 99
echo " <tr> \n " ;
+ − 100
echo " <td>" . _ ( 'Database type' ) . "</td> \n " ;
+ − 101
echo " <td>" .
+ − 102
"<select name= \" type \" >" .
+ − 103
"<option value= \" mysql \" >MySQL</option>" .
+ − 104
"<option value= \" pgsql \" >PostgreSQL</option>" .
+ − 105
"</td> \n " ;
+ − 106
echo " <td>" . _ ( 'The type of the PowerDNS database.' ) . "</td> \n " ;
+ − 107
echo " </tr> \n " ;
142
+ − 108
echo "</table> \n " ;
+ − 109
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
151
+ − 110
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
+ − 111
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
142
+ − 112
echo "</form>" ;
+ − 113
break ;
+ − 114
151
+ − 115
case 4 :
142
+ − 116
$step ++ ;
151
+ − 117
echo "<p>" . _ ( 'Updating database...' ) . " " ;
142
+ − 118
include_once ( "../inc/config-me.inc.php" );
+ − 119
include_once ( "database-structure.inc.php" );
+ − 120
$db_user = $_POST [ 'user' ];
+ − 121
$db_pass = $_POST [ 'pass' ];
+ − 122
$db_host = $_POST [ 'host' ];
+ − 123
$db_name = $_POST [ 'name' ];
146
+ − 124
$db_type = $_POST [ 'type' ];
142
+ − 125
require_once ( "../inc/database.inc.php" );
+ − 126
$db = dbConnect ();
+ − 127
$db -> loadModule ( 'Manager' );
+ − 128
$db -> loadModule ( 'Extended' );
+ − 129
$current_tables = $db -> listTables ();
+ − 130
foreach ( $def_tables as $table ) {
+ − 131
if ( in_array ( $table [ 'table_name' ], $current_tables )) $db -> dropTable ( $table [ 'table_name' ]);
+ − 132
$db -> createTable ( $table [ 'table_name' ], $table [ 'fields' ]);
+ − 133
}
+ − 134
$fill_perm_items = $db -> prepare ( 'INSERT INTO perm_items VALUES (?, ?, ?)' );
+ − 135
$db -> extended -> executeMultiple ( $fill_perm_items , $def_permissions );
+ − 136
$fill_perm_items -> free ();
+ − 137
foreach ( $def_remaining_queries as $query ) {
+ − 138
$db -> query ( $query );
+ − 139
}
151
+ − 140
echo _ ( 'done!' ) . "</p>" ;
142
+ − 141
151
+ − 142
echo "<p>" . _ ( 'We have now updated the PowerDNS database to work with Poweradmin. 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.' ) . " " ;
146
+ − 143
if ( $db_type == 'mysql' ) {
151
+ − 144
echo _ ( 'In MySQL you should now perform the following command:' ) . "</p>" ;
146
+ − 145
echo "<p><tt>GRANT SELECT, INSERT, UPDATE, DELETE<BR>ON powerdns-database.*<br>TO 'poweradmin-user'@'localhost'<br>IDENTIFIED BY 'poweradmin-password';</tt></p>" ;
+ − 146
} elseif ( $db_type == 'pgsql' ) {
151
+ − 147
echo _ ( 'On PgSQL you would use:' ) . "</p>" ;
+ − 148
echo "<p><tt>$ createuser poweradmin-user<br>" .
+ − 149
"Shall the new role be a superuser? (y/n) n<br>" .
+ − 150
"Shall the new user be allowed to create databases? (y/n) n<br>" .
+ − 151
"Shall the new user be allowed to create more new users? (y/n) n<br>" .
+ − 152
"CREATE USER<br>" .
+ − 153
"$ psql powerdns-database<br>" .
+ − 154
"psql> GRANT SELECT, INSERT, DELETE, UPDATE<br>" .
+ − 155
"ON powerdns-database<br>" .
+ − 156
"TO poweradmin-user;</tt></p> \n " ;
146
+ − 157
}
151
+ − 158
echo "<p>" . _ ( 'After you have added the new user, proceed with this installation procedure.' ) . "</p> \n " ;
142
+ − 159
echo "<form method= \" post \" >" ;
+ − 160
echo "<input type= \" hidden \" name= \" host \" value= \" " . $db_host . " \" >" ;
+ − 161
echo "<input type= \" hidden \" name= \" name \" value= \" " . $db_name . " \" >" ;
+ − 162
echo "<input type= \" hidden \" name= \" type \" value= \" " . $db_type . " \" >" ;
+ − 163
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
151
+ − 164
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
+ − 165
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
142
+ − 166
echo "</form>" ;
+ − 167
break ;
+ − 168
151
+ − 169
case 5 :
142
+ − 170
$step ++ ;
+ − 171
$db_host = $_POST [ 'host' ];
+ − 172
$db_name = $_POST [ 'name' ];
+ − 173
$db_type = $_POST [ 'type' ];
151
+ − 174
echo "<p>" . _ ( 'Now we will put together the configuration. To do so, the installer needs some details:' ) . "</p> \n " ;
142
+ − 175
echo "<form method= \" post \" >" ;
151
+ − 176
echo " <table>" ;
+ − 177
echo " <tr>" ;
+ − 178
echo " <td>" . _ ( 'Username' ) . "</td> \n " ;
+ − 179
echo " <td><input type= \" text \" name= \" db_user \" value= \"\" ></td> \n " ;
+ − 180
echo " <td>" . _ ( 'The username as created in the previous step.' ) . "</td> \n " ;
+ − 181
echo " </tr> \n " ;
+ − 182
echo " <tr> \n " ;
+ − 183
echo " <td>" . _ ( 'Password' ) . "</td> \n " ;
+ − 184
echo " <td><input type= \" text \" name= \" db_pass \" value= \"\" ></td> \n " ;
+ − 185
echo " <td>" . _ ( 'The password for this username.' ) . "</td> \n " ;
+ − 186
echo " </tr> \n " ;
+ − 187
echo " <tr> \n " ;
+ − 188
echo " <td>" . _ ( 'Hostmaster' ) . "</td> \n " ;
+ − 189
echo " <td><input type= \" text \" name= \" dns_hostmaster \" value= \"\" ></td> \n " ;
+ − 190
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 " ;
+ − 191
echo " </tr> \n " ;
+ − 192
echo " <tr> \n " ;
+ − 193
echo " <td>" . _ ( 'Primary nameserver' ) . "</td> \n " ;
+ − 194
echo " <td><input type= \" text \" name= \" dns_ns1 \" value= \"\" ></td> \n " ;
+ − 195
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 " ;
+ − 196
echo " </tr> \n " ;
+ − 197
echo " <tr> \n " ;
+ − 198
echo " <td>" . _ ( 'Secondary nameserver' ) . "</td> \n " ;;
+ − 199
echo " <td><input type= \" text \" name= \" dns_ns2 \" value= \"\" ></td> \n " ;
+ − 200
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 " ;
+ − 201
echo " </tr> \n " ;
142
+ − 202
echo "</table>" ;
+ − 203
echo "<input type= \" hidden \" name= \" db_host \" value= \" " . $db_host . " \" >" ;
+ − 204
echo "<input type= \" hidden \" name= \" db_name \" value= \" " . $db_name . " \" >" ;
+ − 205
echo "<input type= \" hidden \" name= \" db_type \" value= \" " . $db_type . " \" >" ;
+ − 206
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
151
+ − 207
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
+ − 208
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
142
+ − 209
echo "</form>" ;
+ − 210
break ;
+ − 211
151
+ − 212
case 6 :
142
+ − 213
$step ++ ;
155
+ − 214
$config = "<?php \n\n " .
150
+ − 215
" \$ db_host \t\t = \" " . $_POST [ 'db_host' ] . " \" ; \n " .
142
+ − 216
" \$ db_user \t\t = \" " . $_POST [ 'db_user' ] . " \" ; \n " .
+ − 217
" \$ db_pass \t\t = \" " . $_POST [ 'db_pass' ] . " \" ; \n " .
+ − 218
" \$ db_name \t\t = \" " . $_POST [ 'db_name' ] . " \" ; \n " .
+ − 219
" \$ db_type \t\t = \" " . $_POST [ 'db_type' ] . " \" ; \n " .
+ − 220
" \n " .
151
+ − 221
" \$ iface_lang \t\t = \" " . $_POST [ 'language' ] . " \" ; \n " .
+ − 222
" \n " .
142
+ − 223
" \$ dns_hostmaster \t\t = \" " . $_POST [ 'dns_hostmaster' ] . " \" ; \n " .
+ − 224
" \$ dns_ns1 \t\t = \" " . $_POST [ 'dns_ns1' ] . " \" ; \n " .
+ − 225
" \$ dns_ns2 \t\t = \" " . $_POST [ 'dns_ns2' ] . " \" ; \n " .
150
+ − 226
" \n ?> \n " ;
+ − 227
+ − 228
if ( is_writeable ( $local_config_file )) {
+ − 229
$h_config = fopen ( $local_config_file , "w" );
+ − 230
fwrite ( $h_config , $config );
+ − 231
fclose ( $h_config );
151
+ − 232
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
+ − 233
} else {
151
+ − 234
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
+ − 235
echo "<pre>" ;
152
+ − 236
echo htmlentities ( $config );
150
+ − 237
echo "</pre>" ;
+ − 238
};
142
+ − 239
echo "<form method= \" post \" >" ;
+ − 240
echo "<input type= \" hidden \" name= \" step \" value= \" " . $step . " \" >" ;
151
+ − 241
echo "<input type= \" hidden \" name= \" language \" value= \" " . $language . " \" >" ;
+ − 242
echo "<input type= \" submit \" name= \" submit \" value= \" " . _ ( 'Go to step' ) . " " . $step . " \" >" ;
142
+ − 243
echo "</form>" ;
+ − 244
break ;
+ − 245
151
+ − 246
case 7 :
142
+ − 247
$step ++ ;
151
+ − 248
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>" ;
+ − 249
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
+ − 250
break ;
+ − 251
+ − 252
default :
+ − 253
break ;
+ − 254
}
+ − 255
+ − 256
echo "<div class= \" footer \" >" ;
+ − 257
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>" ;
+ − 258
echo "</div></body></html>" ;
+ − 259
+ − 260
?>
+ − 261
+ − 262
+ − 263