1
|
<?php
|
2
|
/**
|
3
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
4
|
*
|
5
|
* This program is free software: you can redistribute it and/or modify
|
6
|
* it under the terms of the GNU General Public License as published by
|
7
|
* the Free Software Foundation, either version 3 of the License, or
|
8
|
* (at your option) any later version.
|
9
|
*
|
10
|
* This program is distributed in the hope that it will be useful,
|
11
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
* GNU General Public License for more details.
|
14
|
*
|
15
|
* You should have received a copy of the GNU General Public License
|
16
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
*/
|
18
|
|
19
|
/**
|
20
|
*
|
21
|
*
|
22
|
* @category Core
|
23
|
* @package Core_package
|
24
|
* @subpackage upgrade-script
|
25
|
* @author Dietmar Wöllbrink <dietmar.woellbrink@websitebaker.org>
|
26
|
* @author Werner v.d.Decken <wkl@isteam.de>
|
27
|
* @copyright Werner v.d.Decken <wkl@isteam.de>
|
28
|
* @license http://www.gnu.org/licenses/gpl.html GPL License
|
29
|
* @version 0.0.1
|
30
|
* @revision $Revision: 1889 $
|
31
|
* @link $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/upgrade-script.php $
|
32
|
* @lastmodified $Date: 2013-03-19 10:34:11 +0100 (Tue, 19 Mar 2013) $
|
33
|
* @since File available since 17.01.2013
|
34
|
* @deprecated
|
35
|
* @description xyz
|
36
|
*/
|
37
|
// Include config file
|
38
|
$config_file = realpath('config.php');
|
39
|
if(file_exists($config_file) && !defined('WB_URL'))
|
40
|
{
|
41
|
require($config_file);
|
42
|
|
43
|
}
|
44
|
// solved wrong pages_directory value before creating access files
|
45
|
$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` '
|
46
|
. 'WHERE `name`=\'pages_directory\'';
|
47
|
$sPagesDirectory = WbDatabase::getInstance()->get_one($sql);
|
48
|
$sTmp = trim($sPagesDirectory, '/');
|
49
|
$sTmp = ($sTmp == '' ? '' : '/'.$sTmp);
|
50
|
if($sTmp != $sPagesDirectory) {
|
51
|
$sql = 'UPDATE `'.TABLE_PREFIX.'settings` '
|
52
|
. 'SET `value` = \''.$sTmpDir.'\' '
|
53
|
. 'WHERE `name`=\'pages_directory\' ';
|
54
|
WbDatabase::getInstance()->query($sql);
|
55
|
}
|
56
|
//require_once(WB_PATH.'/framework/class.admin.php');
|
57
|
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
|
58
|
require_once(WB_PATH.'/framework/functions.php');
|
59
|
// require_once(WB_PATH.'/framework/Database.php');
|
60
|
$admin = new admin('Addons', 'modules', false, false);
|
61
|
|
62
|
$oldVersion = 'Version '.WB_VERSION;
|
63
|
$oldVersion .= (defined('WB_SP') ? WB_SP : '');
|
64
|
$oldRevision = (defined('WB_REVISION') ? ' Revision ['.WB_REVISION.'] ' : '') ;
|
65
|
$newVersion = 'Version '.VERSION;
|
66
|
$newVersion .= (defined('SP') ? SP : '');
|
67
|
$newRevision = (defined('REVISION') ? ' Revision ['.REVISION.'] ' : '');
|
68
|
|
69
|
$bDebugModus = false;
|
70
|
|
71
|
// set addition settings if not exists, otherwise upgrade will be breaks
|
72
|
if(!defined('WB_SP')) { define('WB_SP',''); }
|
73
|
if(!defined('WB_REVISION')) { define('WB_REVISION',''); }
|
74
|
// database tables including in WB package
|
75
|
$aPackage = array (
|
76
|
'settings','groups','addons','pages','sections','search','users',
|
77
|
'mod_captcha_control','mod_jsadmin','mod_menu_link','mod_output_filter','mod_wrapper','mod_wysiwyg'
|
78
|
);
|
79
|
|
80
|
$OK = ' <span class="ok">OK</span> ';
|
81
|
$FAIL = ' <span class="error">FAILED</span> ';
|
82
|
$DEFAULT_THEME = 'wb_theme';
|
83
|
|
84
|
$stepID = 0;
|
85
|
$filesRemove = array();
|
86
|
$aFilesToRemove = array();
|
87
|
$dirRemove = array(
|
88
|
/*
|
89
|
'[TEMPLATE]/allcss/',
|
90
|
'[TEMPLATE]/blank/',
|
91
|
'[TEMPLATE]/round/',
|
92
|
'[TEMPLATE]/simple/',
|
93
|
*/
|
94
|
'[ADMIN]/themes/',
|
95
|
);
|
96
|
//
|
97
|
$filesRemove['0'] = array(
|
98
|
|
99
|
'[ADMIN]/preferences/details.php',
|
100
|
'[ADMIN]/preferences/email.php',
|
101
|
'[ADMIN]/preferences/password.php',
|
102
|
'[ADMIN]/pages/settings2.php',
|
103
|
'[ADMIN]/users/users.php',
|
104
|
'[ADMIN]/groups/add.php',
|
105
|
'[ADMIN]/groups/groups.php',
|
106
|
'[ADMIN]/groups/save.php',
|
107
|
'[ADMIN]/skel/themes/htt/groups.htt',
|
108
|
|
109
|
'[FRAMEWORK]/class.msg_queue.php',
|
110
|
'[FRAMEWORK]/class.logfile.php',
|
111
|
'[MODULES]/droplets/js/mdcr.js',
|
112
|
|
113
|
);
|
114
|
$aFilesToRemove = array_merge($filesRemove['0']);
|
115
|
|
116
|
// deleting files below only from less 2.8.4 stable
|
117
|
if(version_compare(WB_VERSION, '2.8.4', '<'))
|
118
|
{
|
119
|
$filesRemove['1'] = array(
|
120
|
|
121
|
'[TEMPLATE]/argos_theme/templates/access.htt',
|
122
|
'[TEMPLATE]/argos_theme/templates/addons.htt',
|
123
|
'[TEMPLATE]/argos_theme/templates/admintools.htt',
|
124
|
'[TEMPLATE]/argos_theme/templates/error.htt',
|
125
|
'[TEMPLATE]/argos_theme/templates/groups.htt',
|
126
|
'[TEMPLATE]/argos_theme/templates/groups_form.htt',
|
127
|
'[TEMPLATE]/argos_theme/templates/languages.htt',
|
128
|
'[TEMPLATE]/argos_theme/templates/languages_details.htt',
|
129
|
'[TEMPLATE]/argos_theme/templates/login.htt',
|
130
|
'[TEMPLATE]/argos_theme/templates/login_forgot.htt',
|
131
|
'[TEMPLATE]/argos_theme/templates/media.htt',
|
132
|
'[TEMPLATE]/argos_theme/templates/media_browse.htt',
|
133
|
'[TEMPLATE]/argos_theme/templates/media_rename.htt',
|
134
|
'[TEMPLATE]/argos_theme/templates/modules.htt',
|
135
|
'[TEMPLATE]/argos_theme/templates/modules_details.htt',
|
136
|
'[TEMPLATE]/argos_theme/templates/pages.htt',
|
137
|
'[TEMPLATE]/argos_theme/templates/pages_modify.htt',
|
138
|
'[TEMPLATE]/argos_theme/templates/pages_sections.htt',
|
139
|
'[TEMPLATE]/argos_theme/templates/pages_settings.htt',
|
140
|
'[TEMPLATE]/argos_theme/templates/preferences.htt',
|
141
|
'[TEMPLATE]/argos_theme/templates/setparameter.htt',
|
142
|
'[TEMPLATE]/argos_theme/templates/settings.htt',
|
143
|
'[TEMPLATE]/argos_theme/templates/start.htt',
|
144
|
'[TEMPLATE]/argos_theme/templates/success.htt',
|
145
|
'[TEMPLATE]/argos_theme/templates/templates.htt',
|
146
|
'[TEMPLATE]/argos_theme/templates/templates_details.htt',
|
147
|
'[TEMPLATE]/argos_theme/templates/users.htt',
|
148
|
'[TEMPLATE]/argos_theme/templates/users_form.htt',
|
149
|
|
150
|
'[TEMPLATE]/wb_theme/templates/access.htt',
|
151
|
'[TEMPLATE]/wb_theme/templates/addons.htt',
|
152
|
'[TEMPLATE]/wb_theme/templates/admintools.htt',
|
153
|
'[TEMPLATE]/wb_theme/templates/error.htt',
|
154
|
'[TEMPLATE]/wb_theme/templates/groups.htt',
|
155
|
'[TEMPLATE]/wb_theme/templates/groups_form.htt',
|
156
|
'[TEMPLATE]/wb_theme/templates/languages.htt',
|
157
|
'[TEMPLATE]/wb_theme/templates/languages_details.htt',
|
158
|
'[TEMPLATE]/wb_theme/templates/login.htt',
|
159
|
'[TEMPLATE]/wb_theme/templates/login_forgot.htt',
|
160
|
'[TEMPLATE]/wb_theme/templates/media.htt',
|
161
|
'[TEMPLATE]/wb_theme/templates/media_browse.htt',
|
162
|
'[TEMPLATE]/wb_theme/templates/media_rename.htt',
|
163
|
'[TEMPLATE]/wb_theme/templates/modules.htt',
|
164
|
'[TEMPLATE]/wb_theme/templates/modules_details.htt',
|
165
|
'[TEMPLATE]/wb_theme/templates/pages.htt',
|
166
|
'[TEMPLATE]/wb_theme/templates/pages_modify.htt',
|
167
|
'[TEMPLATE]/wb_theme/templates/pages_sections.htt',
|
168
|
'[TEMPLATE]/wb_theme/templates/pages_settings.htt',
|
169
|
'[TEMPLATE]/wb_theme/templates/preferences.htt',
|
170
|
'[TEMPLATE]/wb_theme/templates/setparameter.htt',
|
171
|
'[TEMPLATE]/wb_theme/templates/settings.htt',
|
172
|
'[TEMPLATE]/wb_theme/templates/start.htt',
|
173
|
'[TEMPLATE]/wb_theme/templates/success.htt',
|
174
|
'[TEMPLATE]/wb_theme/templates/templates.htt',
|
175
|
'[TEMPLATE]/wb_theme/templates/templates_details.htt',
|
176
|
'[TEMPLATE]/wb_theme/templates/users.htt',
|
177
|
'[TEMPLATE]/wb_theme/templates/users_form.htt'
|
178
|
);
|
179
|
|
180
|
$aFilesToRemove = array_merge($aFilesToRemove,$filesRemove['1']);
|
181
|
|
182
|
}
|
183
|
/* display a status message on the screen **************************************
|
184
|
* @param string $message: the message to show
|
185
|
* @param string $class: kind of message as a css-class
|
186
|
* @param string $element: witch HTML-tag use to cover the message
|
187
|
* @return void
|
188
|
*/
|
189
|
function status_msg($message, $class='check', $element='div')
|
190
|
{
|
191
|
// returns a status message
|
192
|
$msg = '<'.$element.' class="'.$class.'">';
|
193
|
$msg .= '<strong>'.strtoupper(strtok($class, ' ')).'</strong>';
|
194
|
$msg .= $message.'</'.$element.'>';
|
195
|
echo $msg;
|
196
|
}
|
197
|
|
198
|
/**
|
199
|
* add_modify_field_in_database()
|
200
|
*
|
201
|
* @param mixed $sTable
|
202
|
* @param mixed $sField
|
203
|
* @param mixed $sDescription
|
204
|
* @return
|
205
|
*/
|
206
|
function add_modify_field_in_database($sTable,$sField,$sDescription){
|
207
|
global $OK,$FAIL,$bDebugModus;
|
208
|
$database=WbDatabase::getInstance();
|
209
|
$aDebugMessage = array();
|
210
|
if(!$database->field_exists($sTable,$sField)) {
|
211
|
$aDebugMessage[] = "<span>Adding field $sField to $sTable table</span>";
|
212
|
$aDebugMessage[] = ($database->field_add($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
|
213
|
} else {
|
214
|
$aDebugMessage[] = "<span>Modify field $sField to $sTable table</span>";
|
215
|
$aDebugMessage[] = ($database->field_modify($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
|
216
|
}
|
217
|
if($bDebugModus) {
|
218
|
echo implode(PHP_EOL,$aDebugMessage);
|
219
|
}
|
220
|
return;
|
221
|
}
|
222
|
|
223
|
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
224
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
225
|
<head>
|
226
|
<title>Upgrade script</title>
|
227
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
228
|
<style type="text/css">
|
229
|
html { overflow-y: scroll; /* Force firefox to always show room for a vertical scrollbar */ }
|
230
|
|
231
|
body {
|
232
|
margin:0;
|
233
|
padding:0;
|
234
|
border:0;
|
235
|
background: #EBF7FC;
|
236
|
color:#000;
|
237
|
font-family: 'Trebuchet MS', Verdana, Arial, Helvetica, Sans-Serif;
|
238
|
font-size: small;
|
239
|
height:101%;
|
240
|
}
|
241
|
|
242
|
#container {
|
243
|
min-width:48em;
|
244
|
width: 70%;
|
245
|
background: #A8BCCB url(<?php echo WB_URL; ?>/templates/wb_theme/images/background.png) repeat-x;
|
246
|
border:1px solid #000;
|
247
|
color:#000;
|
248
|
margin:2em auto;
|
249
|
padding:0 20px;
|
250
|
min-height: 500px;
|
251
|
text-align:left;
|
252
|
}
|
253
|
.page {
|
254
|
width:100%;
|
255
|
overflow: hidden;
|
256
|
}
|
257
|
.content {
|
258
|
padding: 10px;
|
259
|
}
|
260
|
p { line-height:1.5em; }
|
261
|
|
262
|
form {
|
263
|
display: inline-block;
|
264
|
line-height: 20px;
|
265
|
vertical-align: baseline;
|
266
|
}
|
267
|
input[type="submit"].restart {
|
268
|
background-color: #FFDBDB;
|
269
|
font-weight: bold;
|
270
|
}
|
271
|
|
272
|
h1,h2,h3,h4,h5,h6 {
|
273
|
font-family: Verdana, Arial, Helvetica, sans-serif;
|
274
|
color: #26527D;
|
275
|
margin-top: 1.0em;
|
276
|
margin-bottom: 0.1em;
|
277
|
}
|
278
|
|
279
|
h1 { font-size:150%; }
|
280
|
h2 { font-size: 130%; border-bottom: 1px #CCC solid; }
|
281
|
h3 { font-size: 110%; font-weight: bold; }
|
282
|
|
283
|
textarea {
|
284
|
width:100%;
|
285
|
border: 2px groove #0F1D44;
|
286
|
padding: 2px;
|
287
|
color: #000;
|
288
|
font-weight: normal;
|
289
|
}
|
290
|
.ok, .error { font-weight:bold; }
|
291
|
.ok { color:green; }
|
292
|
.error { color:red; }
|
293
|
.check { color:#555; }
|
294
|
|
295
|
span.ok,
|
296
|
span.error {
|
297
|
margin-left: 0em;
|
298
|
}
|
299
|
|
300
|
.warning {
|
301
|
background:#FFDBDB;
|
302
|
padding:1em;
|
303
|
margin-top:0.5em;
|
304
|
border: 1px solid #DB0909;
|
305
|
}
|
306
|
.info {
|
307
|
background:#C7F4C7;
|
308
|
padding:1em;
|
309
|
margin-top:0.5em;
|
310
|
border: 1px solid #277A29;
|
311
|
}
|
312
|
|
313
|
</style>
|
314
|
</head>
|
315
|
<body>
|
316
|
<div id="container">
|
317
|
<div class="page">
|
318
|
<img src="<?php echo WB_URL; ?>/templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" />
|
319
|
<div class="content">
|
320
|
<h1>WebsiteBaker Upgrade</h1>
|
321
|
<?php
|
322
|
if( version_compare( WB_VERSION, '2.7', '<' )) {
|
323
|
status_msg('<strong>Warning:</strong><br />It is not possible to upgrade from WebsiteBaker Versions before 2.7.<br />For upgrading to version '.VERSION.' you must upgrade first to v.2.7 at least!!!', 'warning', 'div');
|
324
|
echo '<br /><br />';
|
325
|
echo "</div>
|
326
|
</div>
|
327
|
</div>
|
328
|
</body>
|
329
|
</html>
|
330
|
";
|
331
|
exit();
|
332
|
}
|
333
|
|
334
|
?>
|
335
|
<p class="info">This script upgrades an existing WebsiteBaker <strong> <?php echo $oldRevision; ?></strong> installation to the <strong> <?php echo $newRevision ?> </strong>.<br />The upgrade script alters the existing WB database to reflect the changes introduced with WB 2.8.x</p>
|
336
|
|
337
|
<?php
|
338
|
|
339
|
/**
|
340
|
* Check if disclaimer was accepted
|
341
|
*/
|
342
|
$bDebugModus = false;
|
343
|
$bDebugModus = ( (isset($_POST['debug_confirmed']) && $_POST['debug_confirmed'] == 'debug') ? true : false);
|
344
|
if (!(isset($_POST['backup_confirmed']) && $_POST['backup_confirmed'] == 'confirmed')) { ?>
|
345
|
<h2>Step 1: Backup your files</h2>
|
346
|
<h5 class="warning">It is highly recommended to <strong>create a manual backup</strong> of the entire <strong class="error"><?php echo PAGES_DIRECTORY ?>/</strong> folder and the <strong>MySQL database</strong> before proceeding.</h5>
|
347
|
<p><strong class="error">Note: </strong>The upgrade script alters some settings of your existing database!!! You need to confirm the disclaimer before proceeding.</p>
|
348
|
|
349
|
<form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
|
350
|
<textarea cols="92" rows="5">DISCLAIMER: The WebsiteBaker upgrade script is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. One needs to confirm that a manual backup of the <?php echo PAGES_DIRECTORY ?>/ folder (including all files and subfolders contained in it) and backup of the entire WebsiteBaker MySQL database was created before you can proceed.</textarea>
|
351
|
<br /><br /><input name="backup_confirmed" type="checkbox" value="confirmed" /> <strong>I confirm that a manual backup of the <?php echo PAGES_DIRECTORY ?>/ folder and the MySQL database was created.</strong>
|
352
|
<br /><br /><input name="debug_confirmed" type="checkbox" value="debug" /> <strong>Here you can get more details during running upgrade.</strong>
|
353
|
<br /><br /><input name="send" type="submit" value="Start upgrade script" />
|
354
|
</form>
|
355
|
<br />
|
356
|
|
357
|
<?php
|
358
|
status_msg('<strong> Notice:</strong><br />You need to confirm that you have created a manual backup of the '.PAGES_DIRECTORY.'/ directory and the MySQL database before you can proceed.', 'warning', 'div');
|
359
|
echo "<br /><br /></div>
|
360
|
</div>
|
361
|
</div>
|
362
|
</body>
|
363
|
</html>";
|
364
|
exit();
|
365
|
}
|
366
|
|
367
|
/**********************************************************
|
368
|
* - check tables coming with WebsiteBaker
|
369
|
*/
|
370
|
$aMissingTables = UpgradeHelper::existsAllTables($aPackage);
|
371
|
if( sizeof($aMissingTables) == 0){
|
372
|
echo '<h4 style="margin-left:0;">NOTICE: '.sizeof($aPackage).' total tables included in package are successful installed your database `'.$database->DbName.'` '.$OK.'</h4>';
|
373
|
} else {
|
374
|
status_msg('<strong>:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div');
|
375
|
echo '<h4>Missing required tables. You can install them in backend->addons->modules.<br />';
|
376
|
echo 'Or if you uploaded per FTP install possible by backend->addons->modules->advanced.<br />';
|
377
|
echo 'First rename or delete the upgrade-script.php, so the script can\'t start automatically by backend<br />';
|
378
|
echo 'After installing missing tables upload and run again upgrade-script.php<br /><br /></h4>';
|
379
|
echo '<h4 class="warning">';
|
380
|
echo 'Missing required tables.<br /><br />';
|
381
|
echo 'TABLE `'.implode('` missing! '.$FAIL.'<br />TABLE `',$aMissingTables).'` missing! '.$FAIL;
|
382
|
echo '<br /><br /></h4>';
|
383
|
echo '<br /><br />';
|
384
|
if(isset($_SERVER['SCRIPT_NAME'])) {
|
385
|
echo '<form action="'.$_SERVER['SCRIPT_NAME'].'/">';
|
386
|
echo ' <input type="submit" value="Start upgrade again" />';
|
387
|
echo '</form>';
|
388
|
}
|
389
|
if(defined('ADMIN_URL')) {
|
390
|
echo '<form action="'.ADMIN_URL.'/index.php" method="post">';
|
391
|
echo ' <input name="backend_send" type="submit" value="kick me to the Backend" />';
|
392
|
echo '</form>';
|
393
|
}
|
394
|
echo "<br /><br /></div>
|
395
|
</div>
|
396
|
</div>
|
397
|
</body>
|
398
|
</html>";
|
399
|
|
400
|
exit();
|
401
|
}
|
402
|
|
403
|
echo '<h3>Step '.(++$stepID).': Setting default_theme</h3>';
|
404
|
$aDebugMessage = array();
|
405
|
/**********************************************************
|
406
|
* - Adding field default_theme to settings table
|
407
|
*/
|
408
|
$aDebugMessage[] = '<div style="margin-left:2em;">';
|
409
|
$aDebugMessage[] = "<br /><span><strong>Adding default_theme to settings table</strong></span>";
|
410
|
// db_update_key_value('settings', 'default_theme', $DEFAULT_THEME);
|
411
|
$cfg = array(
|
412
|
'default_theme' => defined('DEFAULT_THEME')&& (DEFAULT_THEME!='') ? DEFAULT_THEME : $DEFAULT_THEME
|
413
|
);
|
414
|
$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
415
|
$aDebugMessage[] = '</div>';
|
416
|
|
417
|
if($bDebugModus) {
|
418
|
echo implode(PHP_EOL,$aDebugMessage);
|
419
|
}
|
420
|
$aDebugMessage = array();
|
421
|
echo'<h3>Step '.(++$stepID).': Updating core table included in package</h3>';
|
422
|
/**********************************************************
|
423
|
* - Adding field sec_anchor to settings table
|
424
|
*/
|
425
|
echo '<div style="margin-left:2em;">';
|
426
|
echo "<h4>Adding/updating entries on table settings</h4>";
|
427
|
$aDebugMessage[] = "<span>Adding/updating sec_anchor to settings table</span>";
|
428
|
$cfg = array(
|
429
|
'sec_anchor' => defined('SEC_ANCHOR')&& (SEC_ANCHOR!='') ? SEC_ANCHOR : 'section_'
|
430
|
);
|
431
|
$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
432
|
|
433
|
/**********************************************************
|
434
|
* - Adding redirect timer to settings table
|
435
|
*/
|
436
|
$aDebugMessage[] = "<span>Adding/updating redirect timer to settings table</span>";
|
437
|
$cfg = array(
|
438
|
'redirect_timer' => defined('REDIRECT_TIMER')&& (REDIRECT_TIMER!='') ? REDIRECT_TIMER : '1500'
|
439
|
);
|
440
|
$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
441
|
|
442
|
/**********************************************************
|
443
|
* - Adding default_time_formatr to settings table
|
444
|
*/
|
445
|
$aDebugMessage[] = "<span>Adding/updating default_time_format to settings table</span>";
|
446
|
$cfg = array(
|
447
|
'default_time_format' => defined('DEFAULT_TIME_FORMAT')&& (DEFAULT_TIME_FORMAT!='') ? DEFAULT_TIME_FORMAT : 'h:i A'
|
448
|
);
|
449
|
$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
450
|
|
451
|
/**********************************************************
|
452
|
* - Adding rename_files_on_upload to settings table
|
453
|
*/
|
454
|
$aDebugMessage[] = "<span>Adding/Updating rename_files_on_upload to settings table</span>";
|
455
|
$cfg = array(
|
456
|
'rename_files_on_upload' => (defined('RENAME_FILES_ON_UPLOAD')&& (RENAME_FILES_ON_UPLOAD!='') ? RENAME_FILES_ON_UPLOAD : 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js')
|
457
|
);
|
458
|
$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
459
|
|
460
|
/**********************************************************
|
461
|
* - Adding mediasettings to settings table
|
462
|
*/
|
463
|
$aDebugMessage[] = "<span>Adding/updating mediasettings to settings table</span>";
|
464
|
$cfg = array(
|
465
|
'mediasettings' => (defined('MEDIASETTINGS')&& (MEDIASETTINGS!='') ? MEDIASETTINGS : ''),
|
466
|
);
|
467
|
|
468
|
$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
469
|
|
470
|
/**********************************************************
|
471
|
* - Adding fingerprint_with_ip_octets to settings table
|
472
|
*/
|
473
|
$aDebugMessage[] = "<span>Adding/updating fingerprint_with_ip_octets to settings table</span>";
|
474
|
$cfg = array(
|
475
|
'fingerprint_with_ip_octets' => (defined('FINGERPRINT_WITH_IP_OCTETS') ? FINGERPRINT_WITH_IP_OCTETS : '2'),
|
476
|
'secure_form_module' => (defined('SECURE_FORM_MODULE') ? SECURE_FORM_MODULE : '')
|
477
|
);
|
478
|
|
479
|
$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
480
|
|
481
|
/**********************************************************
|
482
|
* - Adding page_icon_dir to settings table
|
483
|
*/
|
484
|
$aDebugMessage[] = "<span>Adding/updating page_icon_dir to settings table</span>";
|
485
|
$cfg = array(
|
486
|
'page_icon_dir' => (defined('PAGE_ICON_DIR')&& (PAGE_ICON_DIR!='') ? PAGE_ICON_DIR : '/templates/*/title_images'),
|
487
|
);
|
488
|
|
489
|
$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
490
|
/**********************************************************
|
491
|
* - Adding page_extended to settings table
|
492
|
*/
|
493
|
$aDebugMessage[] = "<span>Adding/updating page_extendet to settings table</span>";
|
494
|
$cfg = array(
|
495
|
'page_extendet' => (defined('PAGE_EXTENDET') ? PAGE_EXTENDET : 'true'),
|
496
|
);
|
497
|
|
498
|
$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
499
|
|
500
|
/**********************************************************
|
501
|
* - Adding wbmail_signature to settings table
|
502
|
*/
|
503
|
$aDebugMessage[] = "<span>Adding/updating wbmail_signature to settings table</span>";
|
504
|
$cfg = array(
|
505
|
'wbmail_signature' => (defined('WBMAIL_SIGNATURE')&& (WBMAIL_SIGNATURE!='') ? WBMAIL_SIGNATURE : '')
|
506
|
);
|
507
|
|
508
|
$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
509
|
|
510
|
/**********************************************************
|
511
|
* - Adding confirmed_registration to settings table
|
512
|
*/
|
513
|
$aDebugMessage[] = "<span>Adding/updating confirmed_registration to settings table</span>";
|
514
|
$cfg = array(
|
515
|
'confirmed_registration' => (defined('CONFIRMED_REGISTRATION') ? CONFIRMED_REGISTRATION : '0')
|
516
|
);
|
517
|
|
518
|
$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
519
|
|
520
|
/**********************************************************
|
521
|
* - Adding dev_infos to settings table
|
522
|
*/
|
523
|
$aDebugMessage[] = "<span>Adding/updating dev_infos to settings table</span>";
|
524
|
$cfg = array(
|
525
|
'dev_infos' => (defined('DEV_INFOS') ? DEV_INFOS : 'false')
|
526
|
);
|
527
|
|
528
|
$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
529
|
|
530
|
if($bDebugModus) {
|
531
|
echo implode(PHP_EOL,$aDebugMessage);
|
532
|
}
|
533
|
echo '</div>';
|
534
|
|
535
|
$aDebugMessage = array();
|
536
|
if(version_compare(WB_REVISION, REVISION, '<='))
|
537
|
{
|
538
|
echo '<div style="margin-left:2em;">';
|
539
|
/**********************************************************
|
540
|
* - Update search no results database filed to create
|
541
|
* valid XHTML if search is empty
|
542
|
*/
|
543
|
if (version_compare(WB_VERSION, '2.8', '<'))
|
544
|
{
|
545
|
echo "<h4>Adding/updating fields on table search</h4>";
|
546
|
echo "Updating database field `no_results` on search table: ";
|
547
|
$search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>');
|
548
|
$sql = 'UPDATE `'.TABLE_PREFIX.'search` ';
|
549
|
$sql .= 'SET `value`=\''.$search_no_results.'\' ';
|
550
|
$sql .= 'WHERE `name`=\'no_results\'';
|
551
|
echo ($database->query($sql)) ? " $OK<br />" : " $FAIL!<br />";
|
552
|
}
|
553
|
|
554
|
echo "<h4>Adding/updating field on table mod_menu_link</h4>";
|
555
|
/**********************************************************
|
556
|
* - Add field "redirect_type" to table "mod_menu_link"
|
557
|
* has to be moved later to upgrade.php in modul menu_link, because modul can be removed
|
558
|
*/
|
559
|
$table_name = TABLE_PREFIX.'mod_menu_link';
|
560
|
$field_name = 'redirect_type';
|
561
|
$description = "INT NOT NULL DEFAULT '301' AFTER `target_page_id`";
|
562
|
add_modify_field_in_database($table_name,$field_name,$description);
|
563
|
|
564
|
if($bDebugModus) {
|
565
|
echo implode(PHP_EOL,$aDebugMessage);
|
566
|
}
|
567
|
|
568
|
$aDebugMessage = array();
|
569
|
echo "<h4>Adding/updating field on table pages</h4>";
|
570
|
/**********************************************************
|
571
|
* - Add field "page_trail" to table "pages"
|
572
|
*/
|
573
|
$table_name = TABLE_PREFIX.'pages';
|
574
|
$field_name = 'page_trail';
|
575
|
$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
|
576
|
add_modify_field_in_database($table_name,$field_name,$description);
|
577
|
|
578
|
/**********************************************************
|
579
|
* - Add field "page_icon" to table "pages"
|
580
|
*/
|
581
|
$table_name = TABLE_PREFIX.'pages';
|
582
|
$field_name = 'page_icon';
|
583
|
$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `page_title`";
|
584
|
add_modify_field_in_database($table_name,$field_name,$description);
|
585
|
|
586
|
/**********************************************************
|
587
|
* - Add field "page_code" to table "pages"
|
588
|
*/
|
589
|
$table_name = TABLE_PREFIX.'pages';
|
590
|
$field_name = 'page_code';
|
591
|
$description = "INT NOT NULL DEFAULT '0' AFTER `language`";
|
592
|
add_modify_field_in_database($table_name,$field_name,$description);
|
593
|
|
594
|
/**********************************************************
|
595
|
* - Add field "menu_icon_0" to table "pages"
|
596
|
*/
|
597
|
$table_name = TABLE_PREFIX.'pages';
|
598
|
$field_name = 'menu_icon_0';
|
599
|
$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_title`";
|
600
|
add_modify_field_in_database($table_name,$field_name,$description);
|
601
|
|
602
|
/**********************************************************
|
603
|
* - Add field "menu_icon_1" to table "pages"
|
604
|
*/
|
605
|
$table_name = TABLE_PREFIX.'pages';
|
606
|
$field_name = 'menu_icon_1';
|
607
|
$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_0`";
|
608
|
add_modify_field_in_database($table_name,$field_name,$description);
|
609
|
|
610
|
/**********************************************************
|
611
|
* - Add field "tooltip" to table "pages"
|
612
|
*/
|
613
|
$table_name = TABLE_PREFIX.'pages';
|
614
|
$field_name = 'tooltip';
|
615
|
$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_1`";
|
616
|
add_modify_field_in_database($table_name,$field_name,$description);
|
617
|
|
618
|
/**********************************************************
|
619
|
* - Add field "admin_groups" to table "pages"
|
620
|
*/
|
621
|
$table_name = TABLE_PREFIX.'pages';
|
622
|
$field_name = 'admin_groups';
|
623
|
$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
|
624
|
add_modify_field_in_database($table_name,$field_name,$description);
|
625
|
|
626
|
/**********************************************************
|
627
|
* - Add field "admin_users" to table "pages"
|
628
|
*/
|
629
|
$table_name = TABLE_PREFIX.'pages';
|
630
|
$field_name = 'admin_users';
|
631
|
$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
|
632
|
add_modify_field_in_database($table_name,$field_name,$description);
|
633
|
|
634
|
/**********************************************************
|
635
|
* - Add field "viewing_groups" to table "pages"
|
636
|
*/
|
637
|
$table_name = TABLE_PREFIX.'pages';
|
638
|
$field_name = 'viewing_groups';
|
639
|
$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
|
640
|
// echo "<span>Modify field viewing_groups to pages table</span>";
|
641
|
// echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
|
642
|
add_modify_field_in_database($table_name,$field_name,$description);
|
643
|
|
644
|
/**********************************************************
|
645
|
* - Add field "viewing_users" to table "pages"
|
646
|
*/
|
647
|
$table_name = TABLE_PREFIX.'pages';
|
648
|
$field_name = 'viewing_users';
|
649
|
$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
|
650
|
add_modify_field_in_database($table_name,$field_name,$description);
|
651
|
|
652
|
/**********************************************************
|
653
|
* - Add field "custom01" to table "pages"
|
654
|
*/
|
655
|
$table_name = TABLE_PREFIX.'pages';
|
656
|
$field_name = 'custom01';
|
657
|
$description = "VARCHAR( 255 ) NOT NULL DEFAULT '' ";
|
658
|
add_modify_field_in_database($table_name,$field_name,$description);
|
659
|
|
660
|
/**********************************************************
|
661
|
* - Add field "custom02" to table "pages"
|
662
|
*/
|
663
|
$table_name = TABLE_PREFIX.'pages';
|
664
|
$field_name = 'custom02';
|
665
|
$description = "VARCHAR( 255 ) NOT NULL DEFAULT '' ";
|
666
|
add_modify_field_in_database($table_name,$field_name,$description);
|
667
|
|
668
|
if($bDebugModus) {
|
669
|
echo implode(PHP_EOL,$aDebugMessage);
|
670
|
}
|
671
|
|
672
|
$aDebugMessage = array();
|
673
|
/**********************************************************
|
674
|
* modify wrong strucre on table sections
|
675
|
* wrong structure let crash wb
|
676
|
*/
|
677
|
echo "<h4>Change field structure on table sections</h4>";
|
678
|
$table_name = TABLE_PREFIX.'sections';
|
679
|
$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
|
680
|
$aDebugMessage[] = "<span>Modify field module on sections table</span>";
|
681
|
$aDebugMessage[] = ($database->field_modify($table_name, 'module', $description) ? " $OK<br />" : " $FAIL!<br />");
|
682
|
$aDebugMessage[] = "<span>Modify field block on sections table</span>";
|
683
|
$description = "int(11) NOT NULL DEFAULT '1'";
|
684
|
$aDebugMessage[] = ($database->field_modify($table_name, 'block', $description) ? " $OK<br />" : " $FAIL!<br />");
|
685
|
$description = "int(11) NOT NULL DEFAULT '0'";
|
686
|
$aDebugMessage[] = "<span>Modify field publ_start on sections table</span>";
|
687
|
$aDebugMessage[] = ($database->field_modify($table_name, 'publ_start', $description) ? " $OK<br />" : " $FAIL!<br />");
|
688
|
$aDebugMessage[] = "<span>Modify field publ_end on sections table</span>";
|
689
|
$aDebugMessage[] = ($database->field_modify($table_name, 'publ_end', $description) ? " $OK<br />" : " $FAIL!<br />");
|
690
|
|
691
|
if($bDebugModus) {
|
692
|
echo implode(PHP_EOL,$aDebugMessage);
|
693
|
}
|
694
|
|
695
|
$aDebugMessage = array();
|
696
|
/**********************************************************
|
697
|
* `confirm_code` VARCHAR(32) NOT NULL DEFAULT '',
|
698
|
* `confirm_timeout` INT(11) NOT NULL DEFAULT '0',
|
699
|
*/
|
700
|
echo "<h4>Change field structure on table users</h4>";
|
701
|
$table_name = TABLE_PREFIX.'users';
|
702
|
$field_name = 'confirm_code';
|
703
|
$description = "VARCHAR( 32 ) NOT NULL DEFAULT '' AFTER `password` ";
|
704
|
add_modify_field_in_database($table_name,$field_name,$description);
|
705
|
|
706
|
$table_name = TABLE_PREFIX.'users';
|
707
|
$field_name = 'confirm_timeout';
|
708
|
$description = "INT(11) NOT NULL DEFAULT '0' AFTER `confirm_code` ";
|
709
|
add_modify_field_in_database($table_name,$field_name,$description);
|
710
|
|
711
|
if($bDebugModus) {
|
712
|
echo implode(PHP_EOL,$aDebugMessage);
|
713
|
}
|
714
|
|
715
|
$aDebugMessage = array();
|
716
|
/**********************************************************
|
717
|
* Modify Administrator on groups table
|
718
|
*/
|
719
|
echo "<h4>Update group Administrator on table groups</h4>";
|
720
|
$aDebugMessage[] = "<span>Modify Administrator on groups table</span>";
|
721
|
$sModulePermissions = '';
|
722
|
$sTemplatePermissions = '';
|
723
|
$sSystemPermissions = 'access,addons,admintools,admintools_view,groups,groups_add,groups_delete,groups_modify,groups_view,';
|
724
|
$sSystemPermissions .= 'languages,languages_install,languages_uninstall,languages_view,media,media_create,media_delete,media_rename,media_upload,media_view,';
|
725
|
$sSystemPermissions .= 'modules,modules_advanced,modules_install,modules_uninstall,modules_view,pages,pages_add,pages_add_l0,pages_delete,pages_intro,pages_modify,pages_settings,pages_view,';
|
726
|
$sSystemPermissions .= 'preferences,preferences_view,settings,settings_advanced,settings_basic,settings_view,templates,templates_install,templates_uninstall,templates_view,users,users_add,users_delete,users_modify,users_view';
|
727
|
|
728
|
$sql = 'UPDATE `'.TABLE_PREFIX.'groups` ';
|
729
|
$sql .= 'SET `name` = \'Administrators\', ';
|
730
|
$sql .= '`system_permissions` = \''.$sSystemPermissions.'\', ';
|
731
|
$sql .= '`module_permissions` = \''.$sModulePermissions.'\', ';
|
732
|
$sql .= '`template_permissions` = \''.$sTemplatePermissions.'\' ';
|
733
|
$sql .= 'WHERE `group_id` = \'1\' ';
|
734
|
$aDebugMessage[] = ($database->query($sql)) ? " $OK<br />" : " $FAIL!<br />";
|
735
|
if( ($admin->is_authenticated() == true) && ($admin->ami_group_member('1') ) ) {
|
736
|
$_SESSION['SYSTEM_PERMISSIONS'] = array_merge($_SESSION['SYSTEM_PERMISSIONS'], explode(',', $sSystemPermissions));
|
737
|
}
|
738
|
|
739
|
if($bDebugModus) {
|
740
|
echo implode(PHP_EOL,$aDebugMessage);
|
741
|
}
|
742
|
echo '</div>';
|
743
|
|
744
|
}
|
745
|
|
746
|
if(version_compare(WB_REVISION, REVISION, '<'))
|
747
|
{
|
748
|
$aDebugMessage = array();
|
749
|
echo '<h3>Step '.(++$stepID).': Updating group_id in table users</h3>';
|
750
|
/**********************************************************
|
751
|
* Updating group_id in table users
|
752
|
*/
|
753
|
echo '<div style="margin-left:2em;">';
|
754
|
$aUsers = array();
|
755
|
// Get existing values
|
756
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'users` ' ;
|
757
|
$sql .= 'WHERE `user_id` != 1 ';
|
758
|
if($oUser = $database->query($sql)){
|
759
|
$iTotalUsers = $oUser->numRows();
|
760
|
while($Users = $oUser->fetchRow(MYSQL_ASSOC)) {
|
761
|
|
762
|
$aUsers[$Users['user_id']]['groups_id'] = $Users['groups_id'];
|
763
|
$aUsers[$Users['user_id']]['display_name'] = $Users['display_name'];
|
764
|
}
|
765
|
} else {
|
766
|
$aDebugMessage[] = $database->is_error()==false ? " $OK<br />" : " $FAIL!<br />";
|
767
|
}
|
768
|
|
769
|
foreach($aUsers AS $user_id => $value){
|
770
|
// choose group_id from groups_id - workaround for still remaining calls to group_id (to be cleaned-up)
|
771
|
$aGroups_id = explode(',', $aUsers[$user_id]['groups_id']);
|
772
|
$groups_id = $aUsers[$user_id]['groups_id'];
|
773
|
$group_id = 0;
|
774
|
//if user is in administrator-group, get this group else just get the first one
|
775
|
if($admin->is_group_match($aGroups_id,'1')) { $group_id = 1; $groups_id = '1'; } else { $group_id = intval($aGroups_id[0]); }
|
776
|
|
777
|
$sMessage = "<span>Updating group_id ".$TEXT['DISPLAY_NAME']." " .$aUsers[$user_id]['display_name']."</span>";
|
778
|
$sql = 'UPDATE `'.TABLE_PREFIX.'users` ';
|
779
|
$sql .= 'SET `group_id` = '.$group_id.', ';
|
780
|
$sql .= '`groups_id` = \''.$groups_id.'\' ';
|
781
|
$sql .= 'WHERE `user_id` = '.intval($user_id);
|
782
|
|
783
|
if($oRes = $database->query($sql)){ }
|
784
|
$aDebugMessage[] = $database->is_error()==false ? $sMessage." $OK<br />" : $sMessage." $FAIL!<br />";
|
785
|
}
|
786
|
unset($aUsers);
|
787
|
|
788
|
$aDebugMessage[] = '</div>';
|
789
|
|
790
|
if($bDebugModus) {
|
791
|
// $aDebugMessage[] =
|
792
|
echo implode(PHP_EOL,$aDebugMessage);
|
793
|
}else {
|
794
|
echo '<span><strong>'.$iTotalUsers.' users updating the group_id</strong></span>'." $OK<br />";
|
795
|
echo '</div>';
|
796
|
}
|
797
|
}
|
798
|
|
799
|
$aDebugMessage = array();
|
800
|
echo '<h3>Step '.(++$stepID).': Updating access and protected files in folders</h3>';
|
801
|
|
802
|
echo '<div style="margin-left:2em;">';
|
803
|
/**********************************************************
|
804
|
* upgrade media directory index protect files
|
805
|
*/
|
806
|
$dir = (WB_PATH.MEDIA_DIRECTORY);
|
807
|
echo '<h4>Upgrade media directory '.MEDIA_DIRECTORY.'/ index.php protect files</h4>';
|
808
|
$aDebugMessage = rebuildFolderProtectFile($dir);
|
809
|
if( sizeof( $aDebugMessage ) ){
|
810
|
echo '<span><strong>Upgrade '.sizeof( $aDebugMessage ).' directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $OK<br />";
|
811
|
} else {
|
812
|
echo '<span><strong>Upgrade directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $FAIL!<br />";
|
813
|
echo implode ('<br />',$aDebugMessage);
|
814
|
}
|
815
|
|
816
|
$aDebugMessage = array();
|
817
|
/**********************************************************
|
818
|
* upgrade pages directory index access files
|
819
|
*/
|
820
|
echo '<h4>Upgrade pages directory '.PAGES_DIRECTORY.'/ protect and access files</h4>';
|
821
|
|
822
|
/**********************************************************
|
823
|
* - Reformat/rebuild all existing access files
|
824
|
*/
|
825
|
$sPagePath = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '');
|
826
|
$msg = rebuild_all_accessfiles();
|
827
|
|
828
|
echo '<strong>'.implode ('<br />',$msg).'</strong>';
|
829
|
echo '</div>';
|
830
|
|
831
|
/* *****************************************************************************
|
832
|
* - check for deprecated / never needed files
|
833
|
*/
|
834
|
$iLoaded = sizeof($aFilesToRemove);
|
835
|
if($iLoaded) {
|
836
|
echo '<h3>Step '.(++$stepID).': Remove deprecated and outdated files</h3>';
|
837
|
$iFailed = 0;
|
838
|
$iFound = 0;
|
839
|
$searches = array(
|
840
|
'[ADMIN]',
|
841
|
'[MEDIA]',
|
842
|
'[PAGES]',
|
843
|
'[FRAMEWORK]',
|
844
|
'[MODULES]',
|
845
|
'[TEMPLATE]'
|
846
|
);
|
847
|
$replacements = array(
|
848
|
'/'.substr(ADMIN_PATH, strlen(WB_PATH)+1),
|
849
|
MEDIA_DIRECTORY,
|
850
|
PAGES_DIRECTORY,
|
851
|
'/framework',
|
852
|
'/modules',
|
853
|
'/templates'
|
854
|
);
|
855
|
|
856
|
$msg = '';
|
857
|
echo '<div style="margin-left:2em;">';
|
858
|
echo '<h4>Search '.$iLoaded.' deprecated and outdated files</h4>';
|
859
|
foreach( $aFilesToRemove as $file )
|
860
|
{
|
861
|
$file = str_replace($searches, $replacements, $file);
|
862
|
if( is_writable(WB_PATH.'/'.$file) ) {
|
863
|
$iFound++;
|
864
|
// try to unlink file
|
865
|
if(!unlink(WB_PATH.$file)) {
|
866
|
$iFailed++;
|
867
|
}
|
868
|
}
|
869
|
if( is_readable(WB_PATH.'/'.$file) ) {
|
870
|
// save in err-list, if failed
|
871
|
$msg .= $file.'<br />';
|
872
|
}
|
873
|
}
|
874
|
$iRemove = $iFound-$iFailed;
|
875
|
echo '<strong>Remove '.$iRemove.' from '.$iFound.' founded</strong> ';
|
876
|
echo ($iFailed == 0) ? $OK : $FAIL;
|
877
|
echo '</div>';
|
878
|
|
879
|
if($msg != '')
|
880
|
{
|
881
|
$msg = '<br /><br />Following files are deprecated, outdated or a security risk and
|
882
|
can not be removed automatically.<br /><br />Please delete them
|
883
|
using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
|
884
|
status_msg($msg, 'error warning', 'div');
|
885
|
echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
|
886
|
|
887
|
echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
|
888
|
echo ' <input name="send" type="submit" value="Restart upgrade script" />';
|
889
|
echo '</form>';
|
890
|
echo "<br /><br /></div>
|
891
|
</div>
|
892
|
</div>
|
893
|
</body>
|
894
|
</html>";
|
895
|
exit;
|
896
|
}
|
897
|
}
|
898
|
|
899
|
|
900
|
/**********************************************************
|
901
|
* - check for deprecated / never needed files
|
902
|
*/
|
903
|
$iLoaded = sizeof($dirRemove);
|
904
|
if($iLoaded) {
|
905
|
echo '<h3>Step '.(++$stepID).': Remove deprecated and outdated folders</h3>';
|
906
|
$iFailed = 0;
|
907
|
$iFound = 0;
|
908
|
$searches = array(
|
909
|
'[ADMIN]',
|
910
|
'[MEDIA]',
|
911
|
'[PAGES]',
|
912
|
'[TEMPLATE]'
|
913
|
);
|
914
|
$replacements = array(
|
915
|
substr(ADMIN_PATH, strlen(WB_PATH)+1),
|
916
|
MEDIA_DIRECTORY,
|
917
|
PAGES_DIRECTORY,
|
918
|
'/templates',
|
919
|
);
|
920
|
$msg = '';
|
921
|
echo '<div style="margin-left:2em;">';
|
922
|
echo '<h4>Search '.$iLoaded.' deprecated and outdated folders</h4>';
|
923
|
foreach( $dirRemove as $dir ) {
|
924
|
$dir = str_replace($searches, $replacements, $dir);
|
925
|
$dir = WB_PATH.'/'.$dir;
|
926
|
if( is_dir( $dir )) {
|
927
|
$iFound++;
|
928
|
// try to delete dir
|
929
|
if(!is_writable( $dir ) || !rm_full_dir($dir)) {
|
930
|
// save in err-list, if failed
|
931
|
$iFailed++;
|
932
|
}
|
933
|
}
|
934
|
if( is_readable(WB_PATH.'/'.$dir) ) {
|
935
|
$msg .= str_replace(WB_PATH,'',$dir).'<br />';
|
936
|
}
|
937
|
}
|
938
|
|
939
|
$iRemove = $iFound-$iFailed;
|
940
|
echo '<strong>Remove '.$iRemove.' from '.$iFound.' founded</strong> ';
|
941
|
echo ($iFailed == 0) ? $OK : $FAIL;
|
942
|
echo '</div>';
|
943
|
|
944
|
if($msg != '') {
|
945
|
$msg = '<br /><br />Following directories are deprecated, outdated or a security risk and
|
946
|
can not be removed automatically.<br /><br />Please delete them
|
947
|
using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
|
948
|
status_msg($msg, 'error warning', 'div');
|
949
|
echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
|
950
|
echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
|
951
|
echo ' <input name="send" type="submit" value="Restart upgrade script" />';
|
952
|
echo '</form>';
|
953
|
echo "<br /><br /></div>
|
954
|
</div>
|
955
|
</div>
|
956
|
</body>
|
957
|
</html>";
|
958
|
exit;
|
959
|
}
|
960
|
|
961
|
|
962
|
}
|
963
|
|
964
|
/**********************************************************
|
965
|
* upgrade modules if newer version is available
|
966
|
* $aModuleList list of proofed modules
|
967
|
*/
|
968
|
// $aModuleList = array('wysiwyg','news','form','captcha_control','output_filter');
|
969
|
$aModuleList = array('wysiwyg','form');
|
970
|
if(sizeof($aModuleList))
|
971
|
{
|
972
|
echo '<h3>Step '.(++$stepID).': Upgrade proofed modules</h3>';
|
973
|
foreach($aModuleList as $sModul) {
|
974
|
if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
|
975
|
$currModulVersion = get_modul_version ($sModul, false);
|
976
|
$newModulVersion = get_modul_version ($sModul, true);
|
977
|
if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
|
978
|
echo '<div style="margin-left:2em;">';
|
979
|
echo '<h4>'.'Upgrade module \''.$sModul.'\' version '.$newModulVersion.'</h4>';
|
980
|
require(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
|
981
|
echo '</div>';
|
982
|
}
|
983
|
}
|
984
|
}
|
985
|
}
|
986
|
|
987
|
/**********************************************************
|
988
|
* Reformat/rebuild all existing moules access files
|
989
|
* $aModuleList list of modules
|
990
|
*/
|
991
|
$aModuleList = array('bakery','topics','news');
|
992
|
if(sizeof($aModuleList))
|
993
|
{
|
994
|
echo '<h3>Step '.(++$stepID).': Create/Reorg Accessfiles from modules</h3>';
|
995
|
foreach($aModuleList as $sModul) {
|
996
|
$aReturnMsg = array();
|
997
|
$sModulReorg = 'm_'.$sModul.'_Reorg';
|
998
|
if(class_exists($sModulReorg)) {
|
999
|
$sModulVersion = get_modul_version ($sModul, true);
|
1000
|
echo '<div style="margin-left:2em;">';
|
1001
|
echo '<h4>'.'Create/Reorg Accesfiles for module \''.$sModul.'\' version '.$sModulVersion.'</h4>';
|
1002
|
$oReorg = new $sModulReorg();
|
1003
|
$aReturnMsg = $oReorg->execute(); // show details
|
1004
|
if(is_array($aReturnMsg)) {
|
1005
|
foreach($aReturnMsg as $title) {
|
1006
|
echo '<strong>'.$title.'</strong><br />';
|
1007
|
}
|
1008
|
}
|
1009
|
echo '</div>';
|
1010
|
}
|
1011
|
}
|
1012
|
}
|
1013
|
/**********************************************************
|
1014
|
* - Reload all addons
|
1015
|
*/
|
1016
|
|
1017
|
echo '<h3>Step '.(++$stepID).' : Reload all addons database entry (no upgrade)</h3><br />';
|
1018
|
echo '<div style="margin-left:2em;">';
|
1019
|
$iFound = 0;
|
1020
|
$iLoaded = 0;
|
1021
|
////delete modules
|
1022
|
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
|
1023
|
// Load all modules
|
1024
|
if( ($handle = opendir(WB_PATH.'/modules/')) ) {
|
1025
|
while(false !== ($file = readdir($handle))) {
|
1026
|
if($file != '' && substr($file, 0, 1) != '.' && is_dir(WB_PATH.'/modules/'.$file) ) {
|
1027
|
$iFound++;
|
1028
|
$iLoaded = load_module(WB_PATH.'/modules/'.$file ) ? $iLoaded+1 : $iLoaded;
|
1029
|
// upgrade_module($file, true);
|
1030
|
}
|
1031
|
}
|
1032
|
closedir($handle);
|
1033
|
}
|
1034
|
echo '<strong><span>'.$iLoaded.' Modules reloaded,</span> found '.$iFound.' directories in folder /modules/</strong><br />';
|
1035
|
|
1036
|
$iFound = 0;
|
1037
|
$iLoaded = 0;
|
1038
|
////delete templates
|
1039
|
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
|
1040
|
// Load all templates
|
1041
|
if( ($handle = opendir(WB_PATH.'/templates/')) ) {
|
1042
|
while(false !== ($file = readdir($handle))) {
|
1043
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
|
1044
|
|
1045
|
$iFound++;
|
1046
|
$iLoaded = (load_template(WB_PATH.'/templates/'.$file)==true) ? $iLoaded+1 : $iLoaded;
|
1047
|
|
1048
|
}
|
1049
|
}
|
1050
|
closedir($handle);
|
1051
|
}
|
1052
|
echo '<strong><span>'.$iLoaded.' Templates reloaded,</span> found '.$iFound.' directories in folder /templates/</strong><br />';
|
1053
|
|
1054
|
$iFound = 0;
|
1055
|
$iLoaded = 0;
|
1056
|
////delete languages
|
1057
|
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
|
1058
|
// Load all languages
|
1059
|
if( ($handle = opendir(WB_PATH.'/languages/')) ) {
|
1060
|
while(false !== ($file = readdir($handle))) {
|
1061
|
if($file != '' AND (preg_match('#^([A-Z]{2}.php)#', basename($file)))) {
|
1062
|
$iFound++;
|
1063
|
$iLoaded = load_language(WB_PATH.'/languages/'.$file) ? $iLoaded+1 : $iLoaded;
|
1064
|
}
|
1065
|
}
|
1066
|
closedir($handle);
|
1067
|
}
|
1068
|
echo '<strong><span>'.$iLoaded.' Languages reloaded,</span> found '.$iFound.' files in folder /languages/</strong><br />';
|
1069
|
echo '</div>';
|
1070
|
|
1071
|
/**********************************************************
|
1072
|
* - install new droplets
|
1073
|
$drops = (!in_array ( "mod_droplets", $all_tables)) ? "<br />Install droplets<br />" : "<br />Upgrade droplets<br />";
|
1074
|
echo $drops;
|
1075
|
$file_name = (!in_array ( "mod_droplets", $all_tables) ? "install.php" : "upgrade.php");
|
1076
|
require_once (WB_PATH."/modules/droplets/".$file_name);
|
1077
|
********************************************************** */
|
1078
|
|
1079
|
/**********************************************************
|
1080
|
* - End of upgrade script
|
1081
|
*/
|
1082
|
if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', $DEFAULT_THEME); }
|
1083
|
if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
|
1084
|
/**********************************************************
|
1085
|
* - Set Version to new Version
|
1086
|
*/
|
1087
|
echo '<h3>Step '.(++$stepID).': Update database version number </h3>';
|
1088
|
echo '<div style="margin-left:2em;">';
|
1089
|
|
1090
|
$cfg = array(
|
1091
|
'wb_version' => VERSION,
|
1092
|
'wb_revision' => REVISION,
|
1093
|
'wb_sp' => SP
|
1094
|
);
|
1095
|
echo '<br /><span><strong>Set WebsiteBaker version number to '.VERSION.' '.SP.' '.' Revision ['.REVISION.'] : </strong></span>';
|
1096
|
echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
|
1097
|
echo '</div>';
|
1098
|
|
1099
|
echo '<p style="font-size:140%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
|
1100
|
status_msg('<strong>:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
|
1101
|
// show buttons to go to the backend or frontend
|
1102
|
echo '<br />';
|
1103
|
|
1104
|
if(defined('WB_URL')) {
|
1105
|
echo '<form action="'.WB_URL.'/">';
|
1106
|
echo ' <input type="submit" value="kick me to the Frontend" />';
|
1107
|
echo '</form>';
|
1108
|
}
|
1109
|
if(defined('ADMIN_URL')) {
|
1110
|
echo '<form action="'.ADMIN_URL.'/">';
|
1111
|
echo ' <input type="submit" value="kick me to the Backend" />';
|
1112
|
echo '</form>';
|
1113
|
}
|
1114
|
|
1115
|
echo "<br /><br /></div>
|
1116
|
</div>
|
1117
|
</div>
|
1118
|
</body>
|
1119
|
</html>
|
1120
|
";
|
1121
|
exit();
|