install/index.php
changeset 142 edd0c3ee3e1d
child 146 0756319df2d0
equal deleted inserted replaced
141:1ede5203910d 142:edd0c3ee3e1d
       
     1 <?php
       
     2 
       
     3 echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
       
     4 echo "<html>\n";
       
     5 echo " <head>\n";
       
     6 echo "  <title>Poweradmin</title>\n";
       
     7 echo "  <link rel=stylesheet href=\"../style/example.inc.php\" type=\"text/css\">\n";
       
     8 echo " </head>\n";
       
     9 echo " <body>\n";
       
    10 
       
    11 if (!isset($_POST['step']) || !is_numeric($_POST['step'])) {
       
    12 	$step = 1;
       
    13 } else {
       
    14 	$step = $_POST['step'];
       
    15 }
       
    16 
       
    17 echo "  <h1>Poweradmin</h1>";
       
    18 echo "  <h2>Installation step " . $step . "</h2>";
       
    19 
       
    20 switch($step) {
       
    21 	case 1:
       
    22 		$step++;
       
    23 		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:</p>\n";
       
    24 		echo "<ul><li>perm_items</li><li>perm_templ</li><li>perm_templ_items</li><li>users</li><li>zones</li></ul>\n";
       
    25 		echo "<p>This installer will, of course, not touch the data in the PowerDNS tables of the database. However, it is, of course, recommended you create a backup of your database before proceeding.</p>";
       
    26 		echo "<p>Finaly, if you see any errors during the installation process, a problem report would be. You can report problems (and ask for help) on the <a href=\"https://www.poweradmin.org/trac/wiki/Mailinglists\">poweradmin-users</a> mailinglist or you can create <a href=\"https://www.poweradmin.org/trac/newticket\">a ticket</a> in the ticketsystem.</p>";
       
    27 		echo "<p>Do you want to proceed now?</p>\n";
       
    28 		echo "<form method=\"post\">";
       
    29 		echo "<input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
       
    30 		echo "<input type=\"submit\" name=\"submit\" value=\"Go to step " . $step . "\">";
       
    31 		echo "</form>";
       
    32 		break;
       
    33 
       
    34 	case 2:	
       
    35 		$step++;
       
    36 		echo "<p>To prepare the database for using Poweradmin, the installer needs to modify the PowerDNS database. It'll add a number of tables and it'll fill these tables with some data. If the tables are already present, the installer will drop them first.</p>";
       
    37 		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>";
       
    38 		echo "<form method=\"post\">";
       
    39 		echo "<table>\n";
       
    40 		echo "<tr><td>Username</td><td><input type=\"text\" name=\"user\" value=\"\"></td><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 (e.g. \"root\").</td></tr>\n";
       
    41 		echo "<tr><td>Password</td><td><input type=\"password\" name=\"pass\" value=\"\"></td><td>The password for this username.</td></tr>\n";
       
    42 		echo "<tr><td>Hostname</td><td><input type=\"text\" name=\"host\" value=\"\"></td><td>The hostname on which the PowerDNS database resides. Frequently, this will be \"localhost\".</td></tr>\n";
       
    43 		echo "<tr><td>Database</td><td><input type=\"text\" name=\"name\" value=\"\"></td><td>The name of the PowerDNS database.</td></tr>\n";
       
    44 		echo "</table>\n";
       
    45 		echo "<input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
       
    46 		echo "<input type=\"submit\" name=\"submit\" value=\"Go to step " . $step . "\">";
       
    47 		echo "</form>";
       
    48 		break;
       
    49 
       
    50 	case 3:
       
    51 		$step++;
       
    52 		echo "<p>Updating database... ";
       
    53 		include_once("../inc/config-me.inc.php");
       
    54 		include_once("database-structure.inc.php");
       
    55 		$db_user = $_POST['user'];
       
    56 		$db_pass = $_POST['pass'];
       
    57 		$db_host = $_POST['host'];
       
    58 		$db_name = $_POST['name'];
       
    59 		$db_type = "mysql";
       
    60 		require_once("../inc/database.inc.php");
       
    61 		$db = dbConnect();
       
    62 		$db->loadModule('Manager');
       
    63 		$db->loadModule('Extended');
       
    64 
       
    65 		$current_tables = $db->listTables();
       
    66 
       
    67 		foreach ($def_tables as $table) {
       
    68 			if (in_array($table['table_name'], $current_tables)) $db->dropTable($table['table_name']);
       
    69 			$db->createTable($table['table_name'], $table['fields']);
       
    70 		}
       
    71 
       
    72 		$fill_perm_items = $db->prepare('INSERT INTO perm_items VALUES (?, ?, ?)');
       
    73 		$db->extended->executeMultiple($fill_perm_items, $def_permissions);
       
    74 		$fill_perm_items->free();
       
    75 
       
    76 		foreach ($def_remaining_queries as $query) {
       
    77 			$db->query($query);
       
    78 		}
       
    79 
       
    80 		echo "done!</p>";
       
    81 
       
    82 		echo "<p>We have now updated the PowerDNS database to work with Poweradmin. You now want to give limited rights to Poweraadmin 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. In MySQL should now perform the following command:</p>";
       
    83 		echo "<p><tt>GRANT SELECT, INSERT, UPDATE, DELETE<BR>ON powerdns-database.*<br>TO 'poweradmin-user'@'localhost'<br>IDENTIFIED BY 'poweradmin-password';</tt></p>";
       
    84 		echo "<p>On PgSQL you would use:</p>";
       
    85 		echo "<p><tt>$ createuser poweradmin-user<br>Shall the new role be a superuser? (y/n) n<br>Shall the new user be allowed to create databases? (y/n) n<br>Shall the new user be allowed to create more new users? (y/n) n<br>CREATE USER<br>$ psql powerdns-database<br>psql> GRANT  SELECT, INSERT, DELETE, UPDATE<br>ON powerdns-database<br>TO poweradmin-user;</tt></p>";
       
    86 		echo "<p>After you have added the new user, proceed with this installation procedure.</p>\n";
       
    87 		echo "<form method=\"post\">";
       
    88 		echo "<input type=\"hidden\" name=\"host\" value=\"" . $db_host . "\">";
       
    89 		echo "<input type=\"hidden\" name=\"name\" value=\"" . $db_name . "\">";
       
    90 		echo "<input type=\"hidden\" name=\"type\" value=\"" . $db_type . "\">";
       
    91 		echo "<input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
       
    92 		echo "<input type=\"submit\" name=\"submit\" value=\"Go to step " . $step . "\">";
       
    93 		echo "</form>";
       
    94 		break;
       
    95 	
       
    96 	case 4:
       
    97 		$step++;
       
    98 		$db_host = $_POST['host'];
       
    99 		$db_name = $_POST['name'];
       
   100 		$db_type = $_POST['type'];
       
   101 		echo "<p>Now we will put together the configuration. To do so, I need some details:</p>";
       
   102 		echo "<form method=\"post\">";
       
   103 		echo "<table>";
       
   104 		echo "<tr><td>Username</td><td><input type=\"text\" name=\"db_user\" value=\"\"></td><td>The username as created in the previous step.</td></tr>";
       
   105 		echo "<tr><td>Password</td><td><input type=\"text\" name=\"db_pass\" value=\"\"></td><td>The password for this username.</td></tr>";
       
   106 		echo "<tr><td>Hostmaster</td><td><input type=\"text\" name=\"dns_hostmaster\" value=\"\"></td><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></tr>";
       
   107 		echo "<tr><td>Primary nameserver</td><td><input type=\"text\" name=\"dns_ns1\" value=\"\"></td><td>When creating new zones using the template, this value will be used as primary nameserver. Should be like \"ns1.example.net\".</td></tr>";
       
   108 		echo "<tr><td>Secondary nameserver</td><td><input type=\"text\" name=\"dns_ns2\" value=\"\"></td><td>When creating new zones using the template, this value will be used as secondary nameserver. Should be like \"ns2.example.net\".</td></tr>";
       
   109 		echo "</table>";
       
   110 		echo "<input type=\"hidden\" name=\"db_host\" value=\"" . $db_host . "\">";
       
   111 		echo "<input type=\"hidden\" name=\"db_name\" value=\"" . $db_name . "\">";
       
   112 		echo "<input type=\"hidden\" name=\"db_type\" value=\"" . $db_type . "\">";
       
   113 		echo "<input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
       
   114 		echo "<input type=\"submit\" name=\"submit\" value=\"Go to step " . $step . "\">";
       
   115 		echo "</form>";
       
   116 		break;
       
   117 
       
   118 	case 5:
       
   119 		$step++;
       
   120 		echo "<p>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>";
       
   121 
       
   122 		echo "<pre>";
       
   123 		echo "\$db_host\t\t= \"" . $_POST['db_host'] . "\";\n" .
       
   124 			"\$db_user\t\t= \"" . $_POST['db_user'] . "\";\n" .
       
   125 			"\$db_pass\t\t= \"" . $_POST['db_pass'] . "\";\n" .
       
   126 			"\$db_name\t\t= \"" . $_POST['db_name'] . "\";\n" .
       
   127 			"\$db_type\t\t= \"" . $_POST['db_type'] . "\";\n" .
       
   128 			"\n" .
       
   129 			"\$dns_hostmaster\t\t= \"" . $_POST['dns_hostmaster'] . "\";\n" .
       
   130 			"\$dns_ns1\t\t= \"" . $_POST['dns_ns1'] . "\";\n" .
       
   131 			"\$dns_ns2\t\t= \"" . $_POST['dns_ns2'] . "\";\n" .
       
   132 			"\n";
       
   133 		echo "</pre>";
       
   134 		echo "<form method=\"post\">";
       
   135 		echo "<input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
       
   136 		echo "<input type=\"submit\" name=\"submit\" value=\"Go to step " . $step . "\">";
       
   137 		echo "</form>";
       
   138 		break;
       
   139 
       
   140 	case 6:
       
   141 		$step++;
       
   142 		echo "<p>Now we have finished the configuration, you should remove the directory \"install/\" from the Poweradmin root directory. You will not be able to use the file if it exists. Do it now.</p>";
       
   143 		echo "<p>After you have removed the file, 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>";
       
   144 		break;
       
   145 
       
   146 	default:
       
   147 		break;
       
   148 }
       
   149 
       
   150 echo "<div class=\"footer\">";
       
   151 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>";
       
   152 echo "</div></body></html>";
       
   153 
       
   154 ?>
       
   155 
       
   156 
       
   157