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