-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.php
82 lines (62 loc) · 2.84 KB
/
setup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**********************************************************************/
/* RESUME THE SESSION
/**********************************************************************/
session_start();
/**********************************************************************/
/* FILE NAME & ACCESS RULE FOR PAGE
/**********************************************************************/
$CURRENT_PAGE_NAME = basename(__FILE__, '.php');
// $USER_TYPE_REQUIREMENT not defined here - see below
/**********************************************************************/
/* REUIREMENTS
/**********************************************************************/
require('php/sql-config.php');
require('php/global.php');
/**********************************************************************/
/* MAIN
/**********************************************************************/
specialRedirect();
displayPage("setup");
// The reason why $USER_TYPE_REQUIREMENT is not defined here and why this page uses a seperate function
// is because if the admin is not setup yet, a user should be able to set it up.
// They must however go directly to this page. There is no menu item for it
function specialRedirect()
{
if
(
(!loggedin()) ||
(!empty(GLOBALS["admin"]) && !admin())
)
{
header("Location: /home.php");
exit();
}
}
/**********************************************************************/
// DISPLAY PAGE
function setup()
{
$blockContent = "<form action='/php/form-processor.php' method='POST' id='setupForm'>";
foreach (GLOBALS as $key => $value)
{
$blockContent .=
"<p>
<label for='{$key}'>{$key}:</label>
<input type='text' name='{$key}' value='{$value}'/>
</p>";
}
// add the error is there was one
$blockContent .= getError();
// add the form submit button to the block contnent
$blockContent .= "<p><input name='setup-form-submitted' type='hidden'/><input name='form-submitted' type='hidden'/><input type='submit' value='submit'/></p>";
$info =
[
"row" => ["extraClasses" => ["blue", "rowPerfectWidth", "vericallyCenteredRow"]],
"rowColumn" => [ [] ],
"blockContent" => [$blockContent]
];
createRow($info);
$blockContent .= "</form>";
}
?>