r1532 + redid the steps array
authorDenis Ovsienko <infrastation@yandex.ru>
Tue, 15 Jan 2008 00:25:10 +0000 (00:25 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Tue, 15 Jan 2008 00:25:10 +0000 (00:25 +0000)
+ replace GD_VERSION with IMG_PNG, because the former is available in PHP 5.2.4+ only

install.php

index f46cb56697ed6b5a28ef252ebbde7379b421886d..0d6adf6edbac613f7380169d1aa9cb7fe417543c 100644 (file)
+<?php
+$stepfunc[1] = 'not_already_installed';
+$stepfunc[2] = 'platform_is_ok';
+$stepfunc[3] = 'init_config';
+$stepfunc[4] = 'init_database';
+$stepfunc[5] = 'congrats';
+
+if (isset ($_REQUEST['step']))
+       $step = $_REQUEST['step'];
+else
+       $step = 1;
+
+if ($step > count ($stepfunc))
+{
+       require 'inc/init.php';
+       global $root;
+       header ("Location: " . $root);
+       exit;
+}
+$title = "RackTables installation: step ${step} of " . count ($stepfunc);
+?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head><title>RackTables installation</title>
+<head><title><?php echo $title; ?></title>
 <link rel=stylesheet type='text/css' href=pi.css />
 </head>
 <body>
+<center>
 <?php
-
-function already_installed()
+echo "<h1>${title}</h1>";
+//
+// Check if the software is already installed.
+function not_already_installed()
 {
-       return FALSE;
+       return TRUE;
 }
 
-function test_install_step ($stepno)
+// Check for PHP extensions.
+function platform_is_ok ()
 {
-       switch ($stepno)
+       $nerrs = 0;
+       echo "<table border=1><tr><th>check item</th><th>result</th></tr>\n";
+
+       echo '<tr><td>PDO extension</td>';
+       if (class_exists ('PDO'))
+               echo '<td class=msg_success>Ok';
+       else
        {
-               // Step 0. Check if the software is already installed.
-               case 0:
-                       return 1;
-                       break;
-               // Step 1. Check for PHP extensions.
-               case 1:
-                       $nerrs = 0;
-                       echo "<table border=1><tr><th>check item</th><th>result</th></tr>\n";
+               echo '<td class=msg_error>not found';
+               $nerrs++;
+       }
+       echo '</td></tr>';
 
-                       echo '<tr><td>PDO extension</td>';
-                       if (class_exists ('PDO'))
-                               echo '<td class=msg_success>Ok';
-                       else
-                       {
-                               echo '<td class=msg_error>not found';
-                               $nerrs++;
-                       }
-                       echo '</td></tr>';
+       echo '<tr><td>PDO-MySQL</td>';
+       if (defined ('PDO::MYSQL_ATTR_READ_DEFAULT_FILE'))
+               echo '<td class=msg_success>Ok';
+       else
+       {
+               echo '<td class=msg_error>not found';
+               $nerrs++;
+       }
+       echo '</td></tr>';
 
-                       echo '<tr><td>PDO-MySQL</td>';
-                       if (defined ('PDO::MYSQL_ATTR_READ_DEFAULT_FILE'))
-                               echo '<td class=msg_success>Ok';
-                       else
-                       {
-                               echo '<td class=msg_error>not found';
-                               $nerrs++;
-                       }
-                       echo '</td></tr>';
+       echo '<tr><td>hash functions</td>';
+       if (function_exists ('hash_algos'))
+               echo '<td class=msg_success>Ok';
+       else
+       {
+               echo '<td class=msg_error>not found';
+               $nerrs++;
+       }
+       echo '</td></tr>';
 
-                       echo '<tr><td>hash functions</td>';
-                       if (function_exists ('hash_algos'))
-                               echo '<td class=msg_success>Ok';
-                       else
-                       {
-                               echo '<td class=msg_error>not found';
-                               $nerrs++;
-                       }
-                       echo '</td></tr>';
+       echo '<tr><td>SNMP extension</td>';
+       if (defined ('SNMP_NULL'))
+               echo '<td class=msg_success>Ok';
+       else
+               echo '<td class=msg_warning>Not found. Live SNMP tab will not function properly until the extension is installed.';
+       echo '</td></tr>';
 
-                       echo '<tr><td>SNMP extension</td>';
-                       if (defined ('SNMP_NULL'))
-                               echo '<td class=msg_success>Ok';
-                       else
-                               echo '<td class=msg_warning>Not found. Live SNMP tab will not function properly until the extension is installed.';
-                       echo '</td></tr>';
+       echo '<tr><td>GD functions</td>';
+       if (defined ('IMG_PNG'))
+               echo '<td class=msg_success>Ok';
+       else
+       {
+               echo '<td class=msg_error>not found';
+               $nerrs++;
+       }
+       echo '</td></tr>';
 
-                       echo '<tr><td>GD functions</td>';
-                       if (defined ('GD_VERSION'))
-                               echo '<td class=msg_success>Ok';
-                       else
-                       {
-                               echo '<td class=msg_error>not found';
-                               $nerrs++;
-                       }
-                       echo '</td></tr>';
+       echo "</table>\n";
+       return !$nerrs;
+}
 
-                       echo "</table>\n";
-                       return !$nerrs;
-                       break;
-               // Step 2. Check that we can write to configuration file.
-               case 2:
-                       return 1;
-                       break;
-               // Step 3. Ask for DB connection paramaters and test
-               // the connection. Neither save the parameters nor allow
-               // going further until we succeed with the given 
-               // credentials.
-               case 3:
-                       return 1;
-                       break;
-               default:
-                       die ("Unexpected argument '${stepno}'");
-       }
+// Check that we can write to configuration file.
+// If so, ask for DB connection paramaters and test
+// the connection. Neither save the parameters nor allow
+// going further until we succeed with the given 
+// credentials.
+function init_config ()
+{
+       return TRUE;
 }
 
-//********************************** START **************
-if (isset ($_REQUEST['step']))
-       $next_step = $_REQUEST['step'];
-elseif (!already_installed())
-       $next_step = 1;
-else
-       die ('Already installed.');
+function init_database ()
+{
+       echo 'Initializing the database...<br>';
+       return TRUE;
+}
 
-$result = test_install_step ($next_step);
-switch ($result)
+function congrats ()
 {
-       case -1: // fail
-               
-               break;
-       case 0: // retry
-               break;
-       case 1: // advance
+       echo 'Congratulations! RackTables installation is complete. Press Next to open your main page.';
+       return TRUE;
 }
 
+if ($stepfunc[$step] ())
+       echo "<a href='?step=" . ($step + 1) . "'>next</a>";
+else
+       echo "<a href='?step=${next_step}'>retry</a>";
+
 ?>
+</center>
 </body>
 </html>