-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate.php
352 lines (312 loc) · 7.8 KB
/
update.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<?php
/**
* Lilac Installer Script
*/
require_once('includes/config.inc');
$config_exists = false;
if(false === ($fp = @fopen(dirname(__FILE__) . "/includes/lilac-conf.php", "r+"))) {
$config_exists = false;
}
else {
$config_exists = true;
}
if($fp)
fclose($fp);
if(!isset($_POST['stage'])) {
$stage = "1";
}
else {
$stage = $_POST['stage'];
}
if($config_exists !== true)
$stage = "99";
$cUpdate = new lilacUpdate();
if($stage == 1 && $_POST['update'] == "execute") {
$error = false;
$success = false;
if(!$error) {
$objUpdate = &$cUpdate->getUpdateObject();
$error = $objUpdate->executeUpdate();
if(empty($error))
$success = "Update applied without errors!";
}
}
print_uheader("lilac-reloaded updater");
if($stage == 1 && $success) {
print_window_uheader("Update Complete");
?>
<b>Congratulations!</b>
<p style="margin: 15px;">Your lilac-reloaded update is now complete.</p>
<p>
<a href="update.php">Launch lilac-reloaded update site again to check for more updates.</a>
</p>
<?php
print_window_ufooter();
}
else if($stage == 1) {
$fatalErrors = false;
// Dependency checking
print_window_uheader("Update check");
?>
<div class="checks">
<?php
if($cUpdate->getCurrentDBVersion() <= 0) {
$fail = true;
}
else {
$fail = false;
}
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
Database Build-Version: <?php echo $cUpdate->getCurrentDBVersion();?></div>
<?php
if($fail) {
?>
<div class="error">
Your database seems to have a old structure, updates are required.
</div>
<?php
}
?>
<div class="success">
Application Build-Version: <?php echo $cUpdate->getCurrentAPPVersion();?>
</div>
<?php
if($cUpdate->getCurrentDBVersion() != $cUpdate->getCurrentAPPVersion()) {
$fail = true;
}
else {
$fail = false;
}
?>
<div class="<?php if($fail) echo "failure"; else echo "success";?>">
Update required: <?php if($fail) echo "yes"; else echo "no";?></div>
<?php
if($fail) {
?>
<div class="notice">
<p>It is required to update your lilac-reloaded installation to build-version <?php echo $cUpdate->getNextUpdateStep(); ?> to work properly.</p>
<p>Following updates will be applied for your installation:</p>
<p>
<?php
$updateToVersion = $cUpdate->getNextUpdateStep();
if($updateToVersion != -1)
{
$objUpdate = &$cUpdate->getUpdateObject();
$arrUpdates = $objUpdate->getUpdates();
foreach($arrUpdates as $updateInfo)
{
printf("- %s<br>", $updateInfo);
}
}
else
{
echo "- Update not available, no update found";
}
?>
</p>
<p>Click the button "Update installation" to beginn update process. Please backup your data first if you feel unwell at this point.</p>
</div>
<?php
}
else
{
?>
<div class="notice">
<p>No update ist required. Click <a href="index.php">here</a> to go back to the main navigation.</p>
</div>
<?php
}
?>
</div>
<?php
if($fatalErrors) {
?>
<div class="error">
You must resolve the issues above before continuing the installation. <a href="update.php">Refresh The Page</a> to perform the checks again.
</div>
<?php
}
else {
?>
<form action="update.php" method="post">
<input type="hidden" name="update" value="execute" />
<input <?php if(!$fail) echo "disabled "; ?> class="submit" type="submit" value="Update installation..." />
</form>
<?php
}
print_window_ufooter();
?>
<?php
}
else if($stage == 99) {
// Dependency checking
print_window_uheader("Update check failed");
?>
<div class="checks">
<div class="error">
<p>The Lilac updater requires that the current configuration file at <em><?php echo dirname(__FILE__) . "/includes/lilac-conf.php";?></em> is writeable. It is
recommended that you change the permissions of the file so the web user can write to it. Following steps are possible:</p>
<p>
- Temporary set the file permission of file <em><?php echo dirname(__FILE__) . "/includes/lilac-conf.php";?></em> to 777. After installation set back to defaults.<br />
- Temporary set the owner permission of file <em><?php echo dirname(__FILE__) . "/includes/lilac-conf.php";?></em> to the webserveruser. After installation set back to defaults.<br />
</p>
</div>
</div>
<?php
}
print_ufooter();
// Install utility functions
function print_window_uheader($title = null, $type = "top") {
?>
<div class="roundedcorner_lilac_box">
<div class="roundedcorner_lilac_top">
<div></div>
</div>
<div class="roundedcorner_lilac_content">
<?php
if(!empty($title)) {
?>
<h2>
<?php echo $title;?>
</h2>
<?php
}
?>
<div class="roundedcorner_inner_box">
<div class="roundedcorner_inner_top">
<div></div>
</div>
<div class="roundedcorner_inner_content">
<?php
}
function print_window_ufooter() {
?>
</div>
<div class="roundedcorner_inner_bottom">
<div></div>
</div>
</div>
</div>
<div class="roundedcorner_lilac_bottom">
<div></div>
</div>
</div>
<?php
}
// Used if frames not used
function print_uheader($title = null) {
global $success;
global $error;
global $warning;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo LILAC_NAME . " "; echo LILAC_VERSION;?> <?php if($title) print(" - " . $title);?>
</title>
<link rel="stylesheet" type="text/css" href="style/reset.css">
<link rel="stylesheet" type="text/css" href="style/lilac.css">
<link rel="stylesheet" type="text/css" href="style/install.css">
<link rel="stylesheet" type="text/css" href="style/flexigrid.css">
<link rel="stylesheet" type="text/css" href="style/jquery.tooltip.css">
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery.tooltip.min.js"></script>
<script type="text/javascript" src="js/jquery.timers.js"></script>
<script type="text/javascript" src="js/flexigrid.js"></script>
</head>
<body>
<script language="javascript">
function form_element_switch(element, checkbox) {
if(checkbox.checked) {
element.readOnly = false;
element.disabled = false;
}
else {
element.readOnly = true;
element.disabled = true;
}
}
function confirmDelete() {
return confirm("Do you really want to delete this Object?");
}
</script>
<div id="header">
<h1>
<div class="title">
<?php echo LILAC_NAME; ?>
</div>
</h1>
</div>
<div id="main">
<?php
if(!empty($success) || !empty($error) || !empty($warning)) {
?>
<script type="text/javascript">
$(document).ready(function() {
$("#statusmsg").show("slow").fadeIn("slow");
});
</script>
<?php
}
if(!empty($success)) {
// We want to show a success state.
?>
<div id="statusmsg" class="roundedcorner_success_box"
style="display: none;">
<div class="roundedcorner_success_top">
<div></div>
</div>
<div class="roundedcorner_success_content">
<?php echo $success; ?>
</div>
<div class="roundedcorner_success_bottom">
<div></div>
</div>
</div>
<?php
}
else if(!empty($error)) {
// We want to show a error state.
?>
<div id="statusmsg" class="roundedcorner_error_box"
style="display: none;">
<div class="roundedcorner_error_top">
<div></div>
</div>
<div class="roundedcorner_error_content">
<?php echo $error; ?>
</div>
<div class="roundedcorner_error_bottom">
<div></div>
</div>
</div>
<?php
}
else if(!empty($warning)) {
// We want to show a warning state.
?>
<div id="statusmsg" class="roundedcorner_warning_box"
style="display: none;">
<div class="roundedcorner_warning_top">
<div></div>
</div>
<div class="roundedcorner_warning_content">
<?php echo $warning; ?>
</div>
<div class="roundedcorner_warning_bottom">
<div></div>
</div>
</div>
<?php
}
}
function print_ufooter() {
global $output_config;
?>
</div>
</body>
</html>
<?php
}