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