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