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