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