r1569 + adjust the missing config message to have a link to the installer
[racktables] / install.php
CommitLineData
0e7f2155
DO
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
8if (isset ($_REQUEST['step']))
9 $step = $_REQUEST['step'];
10else
11 $step = 1;
12
13if ($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?>
f48dc2cc
DO
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">
0e7f2155 24<head><title><?php echo $title; ?></title>
f48dc2cc
DO
25<link rel=stylesheet type='text/css' href=pi.css />
26</head>
27<body>
0e7f2155 28<center>
f48dc2cc 29<?php
0e7f2155
DO
30echo "<h1>${title}</h1>";
31//
32// Check if the software is already installed.
33function not_already_installed()
f48dc2cc 34{
0e7f2155 35 return TRUE;
f48dc2cc
DO
36}
37
0e7f2155
DO
38// Check for PHP extensions.
39function platform_is_ok ()
f48dc2cc 40{
0e7f2155
DO
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
f48dc2cc 48 {
0e7f2155
DO
49 echo '<td class=msg_error>not found';
50 $nerrs++;
51 }
52 echo '</td></tr>';
f48dc2cc 53
0e7f2155
DO
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>';
f48dc2cc 63
0e7f2155
DO
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>';
f48dc2cc 73
0e7f2155
DO
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>';
f48dc2cc 80
0e7f2155
DO
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>';
f48dc2cc 90
0e7f2155
DO
91 echo "</table>\n";
92 return !$nerrs;
93}
f48dc2cc 94
0e7f2155
DO
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.
100function init_config ()
101{
102 return TRUE;
f48dc2cc
DO
103}
104
0e7f2155
DO
105function init_database ()
106{
107 echo 'Initializing the database...<br>';
108 return TRUE;
109}
f48dc2cc 110
0e7f2155 111function congrats ()
f48dc2cc 112{
0e7f2155
DO
113 echo 'Congratulations! RackTables installation is complete. Press Next to open your main page.';
114 return TRUE;
f48dc2cc
DO
115}
116
0e7f2155
DO
117if ($stepfunc[$step] ())
118 echo "<a href='?step=" . ($step + 1) . "'>next</a>";
119else
120 echo "<a href='?step=${next_step}'>retry</a>";
121
f48dc2cc 122?>
0e7f2155 123</center>
f48dc2cc
DO
124</body>
125</html>