install/index.php
author rejo
Sat, 12 Jul 2008 13:44:34 +0000
changeset 187 ae77a8f97ee2
parent 180 e17c8536d718
child 189 b918c891f81d
permissions -rw-r--r--
[feladat @ 296] Fixed a number of errors for undefined variables.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
     1
<?php
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
     2
156
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
     3
if (!isset($_POST['language'])) {
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
     4
	$language = "en_EN";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
     5
} else {
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
     6
	$step = $_POST['step'];
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
     7
}
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
     8
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
     9
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
    10
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    11
$language = $_POST['language'];
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    12
setlocale(LC_ALL, $language);
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    13
$gettext_domain = 'messages';
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    14
bindtextdomain($gettext_domain, "./../locale");
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    15
textdomain($gettext_domain);
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    16
@putenv('LANG='.$language);
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    17
@putenv('LANGUAGE='.$language);
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    18
149
0f9739c8db48 [feladat @ 255]
rejo
parents: 146
diff changeset
    19
$local_config_file = "../inc/config.inc.php";
0f9739c8db48 [feladat @ 255]
rejo
parents: 146
diff changeset
    20
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    21
function error($msg) {
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    22
	if ($msg) {
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    23
		echo "     <div class=\"error\">Error: " . $msg . "</div>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    24
	} else {
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    25
		echo "     <div class=\"error\">" . _('An unknown error has occurred.') . "</div>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    26
	}
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    27
}
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    28
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    29
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    30
echo "<html>\n";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    31
echo " <head>\n";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    32
echo "  <title>Poweradmin</title>\n";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    33
echo "  <link rel=stylesheet href=\"../style/example.inc.php\" type=\"text/css\">\n";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    34
echo " </head>\n";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    35
echo " <body>\n";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    36
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    37
if (!isset($_POST['step']) || !is_numeric($_POST['step'])) {
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    38
	$step = 1;
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    39
} else {
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    40
	$step = $_POST['step'];
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    41
}
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    42
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    43
echo "  <h1>Poweradmin</h1>";
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    44
echo "  <h2>" . _('Installation step') . " " . $step . "</h2>";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    45
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    46
switch($step) {
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    47
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    48
	case 1:
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    49
		$step++;
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    50
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    51
		echo "<p>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    52
		echo " <form method=\"post\">\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    53
		echo "  <input type=\"radio\" name=\"language\" value=\"en_EN\"> I prefer to proceed in english.<br>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    54
		echo "  <input type=\"radio\" name=\"language\" value=\"nl_NL\"> Ik ga graag verder in het Nederlands.<br><br>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    55
		echo "  <input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    56
		echo "  <input type=\"submit\" name=\"submit\" value=\"" . _('Go to step') . " " . $step . "\">";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    57
		echo " </form>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    58
		echo "</p>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    59
		break;
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    60
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    61
	case 2:
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    62
		$step++;
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    63
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    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";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    65
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    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";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    67
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    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>";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    69
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    70
		echo "<p>" . _('Do you want to proceed now?') . "</p>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    71
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    72
		echo "<form method=\"post\">";
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    73
		echo "<input type=\"hidden\" name=\"language\" value=\"" . $language . "\">";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    74
		echo "<input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    75
		echo "<input type=\"submit\" name=\"submit\" value=\"" . _('Go to step') . " " . $step . "\">";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    76
		echo "</form>";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    77
		break;
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    78
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    79
	case 3:	
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    80
		$step++;
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    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>";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    82
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    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>";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    84
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
    85
		echo "<form method=\"post\">";
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    86
		echo " <table>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    87
		echo "  <tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    88
		echo "   <td>" . _('Username') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    89
		echo "   <td><input type=\"text\" name=\"user\" value=\"\"></td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    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";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    91
		echo "  </tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    92
		echo " <tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    93
		echo "  <td>" . _('Password') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    94
		echo "  <td><input type=\"password\" name=\"pass\" value=\"\"></td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    95
		echo "  <td>" . _('The password for this username.') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    96
		echo " </tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    97
		echo " <tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    98
		echo "  <td>" . _('Hostname') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
    99
		echo "  <td><input type=\"text\" name=\"host\" value=\"\"></td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   100
		echo "  <td>" . _('The hostname on which the PowerDNS database resides. Frequently, this will be "localhost".') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   101
		echo " </tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   102
		echo " <tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   103
		echo "  <td>" . _('Database') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   104
		echo "  <td><input type=\"text\" name=\"name\" value=\"\"></td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   105
		echo "  <td>" . _('The name of the PowerDNS database.') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   106
		echo " </tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   107
		echo " <tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   108
		echo "  <td>" . _('Database type') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   109
		echo "  <td>" .
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   110
			"<select name=\"type\">" . 
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   111
			"<option value=\"mysql\">MySQL</option>" . 
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   112
			"<option value=\"pgsql\">PostgreSQL</option>" . 
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   113
			"</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   114
		echo "  <td>" . _('The type of the PowerDNS database.') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   115
		echo " </tr>\n";
165
cc0763252b89 [feladat @ 271]
rejo
parents: 159
diff changeset
   116
                echo "  <tr>\n";
cc0763252b89 [feladat @ 271]
rejo
parents: 159
diff changeset
   117
		echo "   <td>" . _('Poweradmin administrator password') . "</td>\n";
cc0763252b89 [feladat @ 271]
rejo
parents: 159
diff changeset
   118
		echo "   <td><input type=\"text\" name=\"pa_pass\" value=\"\"></td>\n";
cc0763252b89 [feladat @ 271]
rejo
parents: 159
diff changeset
   119
		echo "   <td>" . _('The password of the Poweradmin administrator. This administrator has full rights to Poweradmin using the web interface.') . "</td>\n";
cc0763252b89 [feladat @ 271]
rejo
parents: 159
diff changeset
   120
		echo "  </tr>\n";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   121
		echo "</table>\n";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   122
		echo "<input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   123
		echo "<input type=\"hidden\" name=\"language\" value=\"" . $language . "\">";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   124
		echo "<input type=\"submit\" name=\"submit\" value=\"" . _('Go to step') . " " . $step . "\">";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   125
		echo "</form>";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   126
		break;
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   127
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   128
	case 4:
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   129
		$step++;
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   130
		echo "<p>" . _('Updating database...') . " ";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   131
		include_once("../inc/config-me.inc.php");
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   132
		$db_user = $_POST['user'];
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   133
		$db_pass = $_POST['pass'];
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   134
		$db_host = $_POST['host'];
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   135
		$db_name = $_POST['name'];
146
0756319df2d0 [feladat @ 252]
peter
parents: 142
diff changeset
   136
		$db_type = $_POST['type'];
165
cc0763252b89 [feladat @ 271]
rejo
parents: 159
diff changeset
   137
		$pa_pass = $_POST['pa_pass'];
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   138
		require_once("../inc/database.inc.php");
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   139
		$db = dbConnect();
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   140
		$db->loadModule('Manager');
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   141
		$db->loadModule('Extended');
165
cc0763252b89 [feladat @ 271]
rejo
parents: 159
diff changeset
   142
		include_once("database-structure.inc.php");
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   143
		$current_tables = $db->listTables();
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   144
		foreach ($def_tables as $table) {
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   145
			if (in_array($table['table_name'], $current_tables)) $db->dropTable($table['table_name']);
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   146
			$db->createTable($table['table_name'], $table['fields']);
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   147
		}
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   148
		$fill_perm_items = $db->prepare('INSERT INTO perm_items VALUES (?, ?, ?)');
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   149
		$db->extended->executeMultiple($fill_perm_items, $def_permissions);
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   150
		$fill_perm_items->free();
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   151
		foreach ($def_remaining_queries as $query) {
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   152
			$db->query($query);
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   153
		}
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   154
		echo _('done!') . "</p>";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   155
156
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   156
		echo "<p>" . _('Now we will gather all details for the configuration itself.') . "</p>\n";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   157
		echo "<form method=\"post\">";
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   158
		echo " <table>";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   159
		echo "  <tr>";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   160
		echo "   <td>" . _('Username') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   161
		echo "   <td><input type=\"text\" name=\"db_user\" value=\"\"></td>\n";
156
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   162
		echo "   <td>" . _('The username for Poweradmin. This new user will have limited rights only.') . "</td>\n";
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   163
		echo "  </tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   164
		echo "  <tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   165
		echo "   <td>" . _('Password') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   166
		echo "   <td><input type=\"text\" name=\"db_pass\" value=\"\"></td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   167
		echo "   <td>" . _('The password for this username.') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   168
		echo "  </tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   169
		echo "  <tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   170
		echo "   <td>" . _('Hostmaster') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   171
		echo "   <td><input type=\"text\" name=\"dns_hostmaster\" value=\"\"></td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   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";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   173
		echo "  </tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   174
		echo "  <tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   175
		echo "   <td>" . _('Primary nameserver') . "</td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   176
		echo "   <td><input type=\"text\" name=\"dns_ns1\" value=\"\"></td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   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";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   178
		echo "  </tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   179
		echo "  <tr>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   180
		echo "   <td>" . _('Secondary nameserver') . "</td>\n";;
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   181
		echo "   <td><input type=\"text\" name=\"dns_ns2\" value=\"\"></td>\n";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   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";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   183
		echo "  </tr>\n";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   184
		echo "</table>";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   185
		echo "<input type=\"hidden\" name=\"db_host\" value=\"" . $db_host . "\">";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   186
		echo "<input type=\"hidden\" name=\"db_name\" value=\"" . $db_name . "\">";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   187
		echo "<input type=\"hidden\" name=\"db_type\" value=\"" . $db_type . "\">";
165
cc0763252b89 [feladat @ 271]
rejo
parents: 159
diff changeset
   188
		echo "<input type=\"hidden\" name=\"pa_pass\" value=\"" . $pa_pass . "\">";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   189
		echo "<input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   190
		echo "<input type=\"hidden\" name=\"language\" value=\"" . $language . "\">";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   191
		echo "<input type=\"submit\" name=\"submit\" value=\"" . _('Go to step') . " " . $step . "\">";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   192
		echo "</form>";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   193
		break;
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   194
156
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   195
	case 5:
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   196
		$step++;
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   197
		$db_user = $_POST['db_user'];
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   198
		$db_pass = $_POST['db_pass'];
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   199
		$db_host = $_POST['db_host'];
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   200
		$db_name = $_POST['db_name'];
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   201
		$db_type = $_POST['db_type'];
165
cc0763252b89 [feladat @ 271]
rejo
parents: 159
diff changeset
   202
		$pa_pass = $_POST['pa_pass'];
180
e17c8536d718 [feladat @ 288]
rejo
parents: 178
diff changeset
   203
		$pa_srvr = getenv('SERVER_NAME');
156
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   204
		$dns_hostmaster = $_POST['dns_hostmaster'];
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   205
		$dns_ns1 = $_POST['dns_ns1'];
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   206
		$dns_ns2 = $_POST['dns_ns2'];
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   207
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   208
		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.') . " ";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   209
		if ($db_type == 'mysql') {
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   210
			echo _('In MySQL you should now perform the following command:') . "</p>";
180
e17c8536d718 [feladat @ 288]
rejo
parents: 178
diff changeset
   211
			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
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   212
		} elseif ($db_type == 'pgsql') {
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   213
			echo _('On PgSQL you would use:') . "</p>";
157
af604e6e1a71 [feladat @ 263]
rejo
parents: 156
diff changeset
   214
			echo "<p><tt>$ createuser -E -P " . $db_user . "<br>" .
af604e6e1a71 [feladat @ 263]
rejo
parents: 156
diff changeset
   215
				"Enter password for new role: " . $db_pass . "<br>" .
af604e6e1a71 [feladat @ 263]
rejo
parents: 156
diff changeset
   216
				"Enter it again: " . $db_pass . "<br>" . 
159
abe711eddd45 [feladat @ 265]
rejo
parents: 157
diff changeset
   217
				"Shall the new role be a superuser? (y/n) n<br>" .
156
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   218
				"Shall the new user be allowed to create databases? (y/n) n<br>" . 
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   219
				"Shall the new user be allowed to create more new users? (y/n) n<br>" . 
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   220
				"CREATE USER<br>" . 
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   221
				"$ psql " . $db_name . "<br>" .
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   222
				"psql> GRANT SELECT, INSERT, DELETE, UPDATE<br>" . 
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   223
				"ON " . $db_name . "<br>" .
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   224
				"TO " . $db_user . ";</tt></p>\n";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   225
		}
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   226
		echo "<p>" . _('After you have added the new user, proceed with this installation procedure.') . "</p>\n";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   227
		echo "<form method=\"post\">";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   228
		echo "<input type=\"hidden\" name=\"db_host\" value=\"" . $db_host . "\">";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   229
		echo "<input type=\"hidden\" name=\"db_name\" value=\"" . $db_name . "\">";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   230
		echo "<input type=\"hidden\" name=\"db_type\" value=\"" . $db_type . "\">";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   231
		echo "<input type=\"hidden\" name=\"db_user\" value=\"" . $db_user . "\">";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   232
		echo "<input type=\"hidden\" name=\"db_pass\" value=\"" . $db_pass . "\">";
165
cc0763252b89 [feladat @ 271]
rejo
parents: 159
diff changeset
   233
		echo "<input type=\"hidden\" name=\"pa_pass\" value=\"" . $pa_pass . "\">";
156
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   234
		echo "<input type=\"hidden\" name=\"dns_hostmaster\" value=\"" . $dns_hostmaster . "\">";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   235
		echo "<input type=\"hidden\" name=\"dns_ns1\" value=\"" . $dns_ns1 . "\">";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   236
		echo "<input type=\"hidden\" name=\"dns_ns2\" value=\"" . $dns_ns2 . "\">";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   237
		echo "<input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   238
		echo "<input type=\"hidden\" name=\"language\" value=\"" . $language . "\">";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   239
		echo "<input type=\"submit\" name=\"submit\" value=\"" . _('Go to step') . " " . $step . "\">";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   240
		echo "</form>";
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   241
		break;
04fa36f93e3a [feladat @ 262]
rejo
parents: 155
diff changeset
   242
	
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   243
	case 6:
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   244
		$step++;
165
cc0763252b89 [feladat @ 271]
rejo
parents: 159
diff changeset
   245
		$pa_pass = $_POST['pa_pass'];
155
dd568f2909e3 [feladat @ 261]
rejo
parents: 152
diff changeset
   246
		$config = "<?php\n\n" .
150
59c42a716f95 [feladat @ 256]
rejo
parents: 149
diff changeset
   247
			"\$db_host\t\t= \"" . $_POST['db_host'] . "\";\n" .
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   248
			"\$db_user\t\t= \"" . $_POST['db_user'] . "\";\n" .
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   249
			"\$db_pass\t\t= \"" . $_POST['db_pass'] . "\";\n" .
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   250
			"\$db_name\t\t= \"" . $_POST['db_name'] . "\";\n" .
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   251
			"\$db_type\t\t= \"" . $_POST['db_type'] . "\";\n" .
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   252
			"\n" .
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   253
			"\$iface_lang\t\t= \"" . $_POST['language'] . "\";\n" .
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   254
			"\n" .
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   255
			"\$dns_hostmaster\t\t= \"" . $_POST['dns_hostmaster'] . "\";\n" .
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   256
			"\$dns_ns1\t\t= \"" . $_POST['dns_ns1'] . "\";\n" .
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   257
			"\$dns_ns2\t\t= \"" . $_POST['dns_ns2'] . "\";\n" .
150
59c42a716f95 [feladat @ 256]
rejo
parents: 149
diff changeset
   258
			"\n?>\n";
59c42a716f95 [feladat @ 256]
rejo
parents: 149
diff changeset
   259
59c42a716f95 [feladat @ 256]
rejo
parents: 149
diff changeset
   260
		if (is_writeable($local_config_file)) {
59c42a716f95 [feladat @ 256]
rejo
parents: 149
diff changeset
   261
			$h_config = fopen($local_config_file, "w");
59c42a716f95 [feladat @ 256]
rejo
parents: 149
diff changeset
   262
			fwrite($h_config, $config);
59c42a716f95 [feladat @ 256]
rejo
parents: 149
diff changeset
   263
			fclose($h_config);
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   264
			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
59c42a716f95 [feladat @ 256]
rejo
parents: 149
diff changeset
   265
		} else {
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   266
			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
59c42a716f95 [feladat @ 256]
rejo
parents: 149
diff changeset
   267
			echo "<pre>";
152
16cdb7844fce [feladat @ 258]
rejo
parents: 151
diff changeset
   268
			echo htmlentities($config);
150
59c42a716f95 [feladat @ 256]
rejo
parents: 149
diff changeset
   269
			echo "</pre>";
59c42a716f95 [feladat @ 256]
rejo
parents: 149
diff changeset
   270
		};
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   271
		echo "<form method=\"post\">";
165
cc0763252b89 [feladat @ 271]
rejo
parents: 159
diff changeset
   272
		echo "<input type=\"hidden\" name=\"pa_pass\" value=\"" . $pa_pass . "\">";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   273
		echo "<input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   274
		echo "<input type=\"hidden\" name=\"language\" value=\"" . $language . "\">";
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   275
		echo "<input type=\"submit\" name=\"submit\" value=\"" . _('Go to step') . " " . $step . "\">";
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   276
		echo "</form>";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   277
		break;
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   278
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   279
	case 7:
142
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   280
		$step++;
151
b8adc3cf28c7 [feladat @ 257]
rejo
parents: 150
diff changeset
   281
		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
4f7540d1c07d [feladat @ 286]
peter
parents: 165
diff changeset
   282
		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
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   283
		break;
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   284
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   285
	default:
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   286
		break;
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   287
}
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   288
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   289
echo "<div class=\"footer\">";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   290
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>";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   291
echo "</div></body></html>";
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   292
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   293
?>
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   294
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   295
edd0c3ee3e1d [feladat @ 248]
rejo
parents:
diff changeset
   296