0d6adf6edbac613f7380169d1aa9cb7fe417543c
[racktables] / install.php
1 <?php
2 $stepfunc[1] = 'not_already_installed';
3 $stepfunc[2] = 'platform_is_ok';
4 $stepfunc[3] = 'init_config';
5 $stepfunc[4] = 'init_database';
6 $stepfunc[5] = 'congrats';
7
8 if (isset ($_REQUEST['step']))
9 $step = $_REQUEST['step'];
10 else
11 $step = 1;
12
13 if ($step > count ($stepfunc))
14 {
15 require 'inc/init.php';
16 global $root;
17 header ("Location: " . $root);
18 exit;
19 }
20 $title = "RackTables installation: step ${step} of " . count ($stepfunc);
21 ?>
22 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
23 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
24 <head><title><?php echo $title; ?></title>
25 <link rel=stylesheet type='text/css' href=pi.css />
26 </head>
27 <body>
28 <center>
29 <?php
30 echo "<h1>${title}</h1>";
31 //
32 // Check if the software is already installed.
33 function not_already_installed()
34 {
35 return TRUE;
36 }
37
38 // Check for PHP extensions.
39 function platform_is_ok ()
40 {
41 $nerrs = 0;
42 echo "<table border=1><tr><th>check item</th><th>result</th></tr>\n";
43
44 echo '<tr><td>PDO extension</td>';
45 if (class_exists ('PDO'))
46 echo '<td class=msg_success>Ok';
47 else
48 {
49 echo '<td class=msg_error>not found';
50 $nerrs++;
51 }
52 echo '</td></tr>';
53
54 echo '<tr><td>PDO-MySQL</td>';
55 if (defined ('PDO::MYSQL_ATTR_READ_DEFAULT_FILE'))
56 echo '<td class=msg_success>Ok';
57 else
58 {
59 echo '<td class=msg_error>not found';
60 $nerrs++;
61 }
62 echo '</td></tr>';
63
64 echo '<tr><td>hash functions</td>';
65 if (function_exists ('hash_algos'))
66 echo '<td class=msg_success>Ok';
67 else
68 {
69 echo '<td class=msg_error>not found';
70 $nerrs++;
71 }
72 echo '</td></tr>';
73
74 echo '<tr><td>SNMP extension</td>';
75 if (defined ('SNMP_NULL'))
76 echo '<td class=msg_success>Ok';
77 else
78 echo '<td class=msg_warning>Not found. Live SNMP tab will not function properly until the extension is installed.';
79 echo '</td></tr>';
80
81 echo '<tr><td>GD functions</td>';
82 if (defined ('IMG_PNG'))
83 echo '<td class=msg_success>Ok';
84 else
85 {
86 echo '<td class=msg_error>not found';
87 $nerrs++;
88 }
89 echo '</td></tr>';
90
91 echo "</table>\n";
92 return !$nerrs;
93 }
94
95 // Check that we can write to configuration file.
96 // If so, ask for DB connection paramaters and test
97 // the connection. Neither save the parameters nor allow
98 // going further until we succeed with the given
99 // credentials.
100 function init_config ()
101 {
102 return TRUE;
103 }
104
105 function init_database ()
106 {
107 echo 'Initializing the database...<br>';
108 return TRUE;
109 }
110
111 function congrats ()
112 {
113 echo 'Congratulations! RackTables installation is complete. Press Next to open your main page.';
114 return TRUE;
115 }
116
117 if ($stepfunc[$step] ())
118 echo "<a href='?step=" . ($step + 1) . "'>next</a>";
119 else
120 echo "<a href='?step=${next_step}'>retry</a>";
121
122 ?>
123 </center>
124 </body>
125 </html>