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