1 |
1457
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category backend
|
5 |
|
|
* @package installation
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
|
|
* @copyright 2009-2011, Website Baker 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$
|
13 |
|
|
* @filesource $HeadURL$
|
14 |
|
|
* @lastmodified $Date$
|
15 |
|
|
*
|
16 |
|
|
*/
|
17 |
|
|
|
18 |
|
|
@require_once('config.php');
|
19 |
|
|
|
20 |
1484
|
Luisehahne
|
require_once(WB_PATH.'/framework/functions.php');
|
21 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
22 |
|
|
$admin = new admin('Addons', 'modules', false, false);
|
23 |
|
|
|
24 |
|
|
/* display a status message on the screen **************************************
|
25 |
|
|
* @param string $message: the message to show
|
26 |
|
|
* @param string $class: kind of message as a css-class
|
27 |
|
|
* @param string $element: witch HTML-tag use to cover the message
|
28 |
|
|
* @return void
|
29 |
|
|
*/
|
30 |
|
|
function status_msg($message, $class='check', $element='span')
|
31 |
|
|
{
|
32 |
1457
|
Luisehahne
|
// returns a status message
|
33 |
1484
|
Luisehahne
|
$msg = '<'.$element.' class="'.$class.'">';
|
34 |
1532
|
Luisehahne
|
$msg .= '<strong>'.strtoupper(strtok($class, ' ')).'</strong>';
|
35 |
1484
|
Luisehahne
|
$msg .= $message.'</'.$element.'>';
|
36 |
|
|
echo $msg;
|
37 |
1457
|
Luisehahne
|
}
|
38 |
|
|
|
39 |
|
|
// database tables including in WB package
|
40 |
|
|
$table_list = array (
|
41 |
|
|
'settings','groups','addons','pages','sections','search','users',
|
42 |
|
|
'mod_captcha_control','mod_code','mod_droplets','mod_form_fields',
|
43 |
|
|
'mod_form_settings','mod_form_submissions','mod_jsadmin','mod_menu_link',
|
44 |
|
|
'mod_news_comments','mod_news_groups','mod_news_posts','mod_news_settings',
|
45 |
|
|
'mod_output_filter','mod_wrapper','mod_wysiwyg'
|
46 |
|
|
);
|
47 |
|
|
|
48 |
1484
|
Luisehahne
|
$OK = ' <span class="ok">OK</span> ';
|
49 |
|
|
$FAIL = ' <span class="error">FAILED</span> ';
|
50 |
|
|
$DEFAULT_THEME = 'wb_theme';
|
51 |
1532
|
Luisehahne
|
$stepID = 1;
|
52 |
|
|
$dirRemove = array(
|
53 |
1484
|
Luisehahne
|
/*
|
54 |
|
|
'[TEMPLATE]/allcss/',
|
55 |
|
|
'[TEMPLATE]/blank/',
|
56 |
|
|
'[TEMPLATE]/round/',
|
57 |
|
|
'[TEMPLATE]/simple/',
|
58 |
|
|
*/
|
59 |
1641
|
Luisehahne
|
'[ADMIN]/themes/',
|
60 |
1484
|
Luisehahne
|
);
|
61 |
|
|
|
62 |
1532
|
Luisehahne
|
$filesRemove['0'] = array(
|
63 |
1484
|
Luisehahne
|
|
64 |
1525
|
Luisehahne
|
'[ADMIN]/preferences/details.php',
|
65 |
|
|
'[ADMIN]/preferences/email.php',
|
66 |
1532
|
Luisehahne
|
'[ADMIN]/preferences/password.php'
|
67 |
1525
|
Luisehahne
|
|
68 |
1532
|
Luisehahne
|
);
|
69 |
|
|
|
70 |
|
|
$filesRemove['1'] = array(
|
71 |
|
|
|
72 |
1529
|
Luisehahne
|
'[TEMPLATE]/argos_theme/templates/access.htt',
|
73 |
|
|
'[TEMPLATE]/argos_theme/templates/addons.htt',
|
74 |
|
|
'[TEMPLATE]/argos_theme/templates/admintools.htt',
|
75 |
|
|
'[TEMPLATE]/argos_theme/templates/error.htt',
|
76 |
|
|
'[TEMPLATE]/argos_theme/templates/groups.htt',
|
77 |
|
|
'[TEMPLATE]/argos_theme/templates/groups_form.htt',
|
78 |
|
|
'[TEMPLATE]/argos_theme/templates/languages.htt',
|
79 |
|
|
'[TEMPLATE]/argos_theme/templates/languages_details.htt',
|
80 |
1625
|
Luisehahne
|
/*
|
81 |
1529
|
Luisehahne
|
'[TEMPLATE]/argos_theme/templates/login.htt',
|
82 |
|
|
'[TEMPLATE]/argos_theme/templates/login_forgot.htt',
|
83 |
1625
|
Luisehahne
|
*/
|
84 |
1529
|
Luisehahne
|
'[TEMPLATE]/argos_theme/templates/media.htt',
|
85 |
|
|
'[TEMPLATE]/argos_theme/templates/media_browse.htt',
|
86 |
|
|
'[TEMPLATE]/argos_theme/templates/media_rename.htt',
|
87 |
|
|
'[TEMPLATE]/argos_theme/templates/modules.htt',
|
88 |
|
|
'[TEMPLATE]/argos_theme/templates/modules_details.htt',
|
89 |
|
|
'[TEMPLATE]/argos_theme/templates/pages.htt',
|
90 |
|
|
'[TEMPLATE]/argos_theme/templates/pages_modify.htt',
|
91 |
|
|
'[TEMPLATE]/argos_theme/templates/pages_sections.htt',
|
92 |
|
|
'[TEMPLATE]/argos_theme/templates/pages_settings.htt',
|
93 |
|
|
'[TEMPLATE]/argos_theme/templates/preferences.htt',
|
94 |
|
|
'[TEMPLATE]/argos_theme/templates/setparameter.htt',
|
95 |
|
|
'[TEMPLATE]/argos_theme/templates/settings.htt',
|
96 |
|
|
'[TEMPLATE]/argos_theme/templates/start.htt',
|
97 |
|
|
'[TEMPLATE]/argos_theme/templates/success.htt',
|
98 |
|
|
'[TEMPLATE]/argos_theme/templates/templates.htt',
|
99 |
|
|
'[TEMPLATE]/argos_theme/templates/templates_details.htt',
|
100 |
|
|
'[TEMPLATE]/argos_theme/templates/users.htt',
|
101 |
|
|
'[TEMPLATE]/argos_theme/templates/users_form.htt',
|
102 |
|
|
|
103 |
|
|
'[TEMPLATE]/wb_theme/templates/access.htt',
|
104 |
|
|
'[TEMPLATE]/wb_theme/templates/addons.htt',
|
105 |
|
|
'[TEMPLATE]/wb_theme/templates/admintools.htt',
|
106 |
|
|
'[TEMPLATE]/wb_theme/templates/error.htt',
|
107 |
|
|
'[TEMPLATE]/wb_theme/templates/groups.htt',
|
108 |
|
|
'[TEMPLATE]/wb_theme/templates/groups_form.htt',
|
109 |
|
|
'[TEMPLATE]/wb_theme/templates/languages.htt',
|
110 |
|
|
'[TEMPLATE]/wb_theme/templates/languages_details.htt',
|
111 |
1625
|
Luisehahne
|
|
112 |
1641
|
Luisehahne
|
/*
|
113 |
1529
|
Luisehahne
|
'[TEMPLATE]/wb_theme/templates/login.htt',
|
114 |
|
|
'[TEMPLATE]/wb_theme/templates/login_forgot.htt',
|
115 |
1641
|
Luisehahne
|
*/
|
116 |
1625
|
Luisehahne
|
|
117 |
1529
|
Luisehahne
|
'[TEMPLATE]/wb_theme/templates/media.htt',
|
118 |
|
|
'[TEMPLATE]/wb_theme/templates/media_browse.htt',
|
119 |
|
|
'[TEMPLATE]/wb_theme/templates/media_rename.htt',
|
120 |
|
|
'[TEMPLATE]/wb_theme/templates/modules.htt',
|
121 |
|
|
'[TEMPLATE]/wb_theme/templates/modules_details.htt',
|
122 |
|
|
'[TEMPLATE]/wb_theme/templates/pages.htt',
|
123 |
|
|
'[TEMPLATE]/wb_theme/templates/pages_modify.htt',
|
124 |
|
|
'[TEMPLATE]/wb_theme/templates/pages_sections.htt',
|
125 |
|
|
'[TEMPLATE]/wb_theme/templates/pages_settings.htt',
|
126 |
|
|
'[TEMPLATE]/wb_theme/templates/preferences.htt',
|
127 |
|
|
'[TEMPLATE]/wb_theme/templates/setparameter.htt',
|
128 |
|
|
'[TEMPLATE]/wb_theme/templates/settings.htt',
|
129 |
|
|
'[TEMPLATE]/wb_theme/templates/start.htt',
|
130 |
|
|
'[TEMPLATE]/wb_theme/templates/success.htt',
|
131 |
|
|
'[TEMPLATE]/wb_theme/templates/templates.htt',
|
132 |
|
|
'[TEMPLATE]/wb_theme/templates/templates_details.htt',
|
133 |
|
|
'[TEMPLATE]/wb_theme/templates/users.htt',
|
134 |
|
|
'[TEMPLATE]/wb_theme/templates/users_form.htt',
|
135 |
1525
|
Luisehahne
|
);
|
136 |
|
|
|
137 |
1457
|
Luisehahne
|
// analyze/check database tables
|
138 |
|
|
function mysqlCheckTables( $dbName )
|
139 |
|
|
{
|
140 |
|
|
global $table_list;
|
141 |
|
|
$table_prefix = TABLE_PREFIX;
|
142 |
|
|
$sql = "SHOW TABLES FROM " . $dbName;
|
143 |
|
|
$result = @mysql_query( $sql );
|
144 |
|
|
$data = array();
|
145 |
|
|
$x = 0;
|
146 |
|
|
|
147 |
|
|
while( ( $row = @mysql_fetch_array( $result, MYSQL_NUM ) ) == true )
|
148 |
|
|
{
|
149 |
|
|
$tmp = str_replace($table_prefix, '', $row[0]);
|
150 |
|
|
|
151 |
|
|
if( stristr( $row[0], $table_prefix )&& in_array($tmp,$table_list) )
|
152 |
|
|
{
|
153 |
|
|
$sql = "CHECK TABLE " . $dbName . '.' . $row[0];
|
154 |
|
|
$analyze = @mysql_query( $sql );
|
155 |
|
|
$rowFetch = @mysql_fetch_array( $analyze, MYSQL_ASSOC );
|
156 |
|
|
$data[$x]['Op'] = $rowFetch["Op"];
|
157 |
|
|
$data[$x]['Msg_type'] = $rowFetch["Msg_type"];
|
158 |
|
|
$msgColor = '<span class="error">';
|
159 |
|
|
$data[$x]['Table'] = $row[0];
|
160 |
|
|
// print " ";
|
161 |
|
|
$msgColor = ($rowFetch["Msg_text"] == 'OK') ? '<span class="ok">' : '<span class="error">';
|
162 |
|
|
$data[$x]['Msg_text'] = $msgColor.$rowFetch["Msg_text"].'</span>';
|
163 |
|
|
// print "<br />";
|
164 |
|
|
$x++;
|
165 |
|
|
}
|
166 |
|
|
}
|
167 |
|
|
return $data;
|
168 |
|
|
}
|
169 |
|
|
|
170 |
|
|
// check existings tables for upgrade or install
|
171 |
|
|
function check_wb_tables()
|
172 |
|
|
{
|
173 |
|
|
global $database,$table_list;
|
174 |
|
|
|
175 |
|
|
// if prefix inludes '_' or '%'
|
176 |
|
|
$search_for = addcslashes ( TABLE_PREFIX, '%_' );
|
177 |
|
|
$get_result = $database->query( 'SHOW TABLES LIKE "'.$search_for.'%"');
|
178 |
|
|
|
179 |
|
|
// $get_result = $database->query( "SHOW TABLES FROM ".DB_NAME);
|
180 |
|
|
$all_tables = array();
|
181 |
|
|
if($get_result->numRows() > 0)
|
182 |
|
|
{
|
183 |
|
|
while ($data = $get_result->fetchRow())
|
184 |
|
|
{
|
185 |
|
|
$tmp = str_replace(TABLE_PREFIX, '', $data[0]);
|
186 |
|
|
if(in_array($tmp,$table_list))
|
187 |
|
|
{
|
188 |
|
|
$all_tables[] = $tmp;
|
189 |
|
|
}
|
190 |
|
|
}
|
191 |
|
|
}
|
192 |
|
|
return $all_tables;
|
193 |
|
|
}
|
194 |
|
|
|
195 |
|
|
// check existing tables
|
196 |
|
|
$all_tables = check_wb_tables();
|
197 |
|
|
|
198 |
|
|
?>
|
199 |
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
200 |
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
201 |
|
|
<head>
|
202 |
|
|
<title>Upgrade script</title>
|
203 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
204 |
|
|
<style type="text/css">
|
205 |
|
|
html { overflow: -moz-scrollbars-vertical; /* Force firefox to always show room for a vertical scrollbar */ }
|
206 |
|
|
|
207 |
|
|
body {
|
208 |
|
|
margin:0;
|
209 |
|
|
padding:0;
|
210 |
|
|
border:0;
|
211 |
|
|
background: #EBF7FC;
|
212 |
|
|
color:#000;
|
213 |
|
|
font-family: 'Trebuchet MS', Verdana, Arial, Helvetica, Sans-Serif;
|
214 |
|
|
font-size: small;
|
215 |
|
|
height:101%;
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
#container {
|
219 |
|
|
width:85%;
|
220 |
|
|
background: #A8BCCB url(templates/wb_theme/images/background.png) repeat-x;
|
221 |
|
|
border:1px solid #000;
|
222 |
|
|
color:#000;
|
223 |
|
|
margin:2em auto;
|
224 |
|
|
padding:0 15px;
|
225 |
|
|
min-height: 500px;
|
226 |
|
|
text-align:left;
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
p { line-height:1.5em; }
|
230 |
|
|
|
231 |
1532
|
Luisehahne
|
form {
|
232 |
|
|
display: inline-block;
|
233 |
|
|
line-height: 20px;
|
234 |
|
|
vertical-align: baseline;
|
235 |
|
|
}
|
236 |
|
|
input[type="submit"].restart {
|
237 |
|
|
background-color: #FFDBDB;
|
238 |
|
|
font-weight: bold;
|
239 |
|
|
}
|
240 |
|
|
|
241 |
1457
|
Luisehahne
|
h1,h2,h3,h4,h5,h6 {
|
242 |
|
|
font-family: Verdana, Arial, Helvetica, sans-serif;
|
243 |
|
|
color: #369;
|
244 |
|
|
margin-top: 1.0em;
|
245 |
|
|
margin-bottom: 0.1em;
|
246 |
|
|
}
|
247 |
|
|
|
248 |
|
|
h1 { font-size:150%; }
|
249 |
|
|
h2 { font-size: 130%; border-bottom: 1px #CCC solid; }
|
250 |
|
|
h3 { font-size: 120%; }
|
251 |
|
|
|
252 |
|
|
.ok, .error { font-weight:bold; }
|
253 |
|
|
.ok { color:green; }
|
254 |
|
|
.error { color:red; }
|
255 |
|
|
.check { color:#555; }
|
256 |
|
|
|
257 |
|
|
.warning {
|
258 |
|
|
width: 98%;
|
259 |
|
|
background:#FFDBDB;
|
260 |
|
|
padding:0.2em;
|
261 |
|
|
margin-top:0.5em;
|
262 |
|
|
border: 1px solid black;
|
263 |
|
|
}
|
264 |
|
|
.info {
|
265 |
|
|
width: 98%;
|
266 |
|
|
background:#99CC99;
|
267 |
|
|
padding:0.2em;
|
268 |
|
|
margin-top:0.5em;
|
269 |
|
|
border: 1px solid black;
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
</style>
|
273 |
|
|
</head>
|
274 |
|
|
<body>
|
275 |
|
|
<div id="container">
|
276 |
|
|
<img src="templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" />
|
277 |
|
|
<h1>WebsiteBaker Upgrade</h1>
|
278 |
|
|
<?php
|
279 |
1525
|
Luisehahne
|
if( version_compare( WB_VERSION, '2.7', '<' )) {
|
280 |
1529
|
Luisehahne
|
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');
|
281 |
1457
|
Luisehahne
|
echo '<br /><br />';
|
282 |
|
|
echo "</div>
|
283 |
|
|
</body>
|
284 |
|
|
</html>
|
285 |
|
|
";
|
286 |
|
|
exit();
|
287 |
|
|
}
|
288 |
1532
|
Luisehahne
|
|
289 |
|
|
$oldVersion = 'Version '.WB_VERSION;
|
290 |
|
|
$oldVersion .= (defined('WB_SP') ? ' '.WB_SP : '');
|
291 |
|
|
$oldVersion .= (defined('WB_REVISION') ? ' Revision ['.WB_REVISION.'] ' : '') ;
|
292 |
|
|
$newVersion = 'Version '.VERSION;
|
293 |
|
|
$newVersion .= (defined('SP') ? ' '.SP : '');
|
294 |
|
|
$newVersion .= (defined('REVISION') ? ' Revision ['.REVISION.'] ' : '');
|
295 |
|
|
// set addition settings if not exists, otherwise upgrade will be breaks
|
296 |
|
|
if(!defined('WB_SP')) { define('WB_SP',''); }
|
297 |
|
|
if(!defined('WB_REVISION')) { define('WB_REVISION',''); }
|
298 |
|
|
|
299 |
1457
|
Luisehahne
|
?>
|
300 |
1532
|
Luisehahne
|
<p>This script upgrades an existing WebsiteBaker <strong> <?php echo $oldVersion; ?></strong> installation to the <strong> <?php echo $newVersion ?> </strong>.<br />The upgrade script alters the existing WB database to reflect the changes introduced with WB 2.8.x</p>
|
301 |
1457
|
Luisehahne
|
|
302 |
|
|
<?php
|
303 |
|
|
/**
|
304 |
|
|
* Check if disclaimer was accepted
|
305 |
|
|
*/
|
306 |
|
|
if (!(isset($_POST['backup_confirmed']) && $_POST['backup_confirmed'] == 'confirmed')) { ?>
|
307 |
|
|
<h2>Step 1: Backup your files</h2>
|
308 |
|
|
<p>It is highly recommended to <strong>create a manual backup</strong> of the entire <strong>/pages folder</strong> and the <strong>MySQL database</strong> before proceeding.<br /><strong class="error">Note: </strong>The upgrade script alters some settings of your existing database!!! You need to confirm the disclaimer before proceeding.</p>
|
309 |
|
|
|
310 |
1532
|
Luisehahne
|
<form name="send" action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
|
311 |
1457
|
Luisehahne
|
<textarea cols="80" 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 /pages folder (including all files and subfolders contained in it) and backup of the entire WebsiteBaker MySQL database was created before you can proceed.</textarea>
|
312 |
|
|
<br /><br /><input name="backup_confirmed" type="checkbox" value="confirmed" /> I confirm that a manual backup of the /pages folder and the MySQL database was created.
|
313 |
|
|
<br /><br /><input name="send" type="submit" value="Start upgrade script" />
|
314 |
|
|
</form>
|
315 |
|
|
<br />
|
316 |
|
|
|
317 |
|
|
<?php
|
318 |
|
|
status_msg('<strong>Notice:</strong><br />You need to confirm that you have created a manual backup of the /pages directory and the MySQL database before you can proceed.', 'warning', 'div');
|
319 |
|
|
echo '<br /><br />';
|
320 |
|
|
echo "</div>
|
321 |
|
|
</body>
|
322 |
|
|
</html>
|
323 |
|
|
";
|
324 |
|
|
exit();
|
325 |
|
|
}
|
326 |
|
|
|
327 |
1532
|
Luisehahne
|
echo '<h2>Step '.(++$stepID).' : Updating database entries</h2>';
|
328 |
|
|
|
329 |
1457
|
Luisehahne
|
// function to add a var/value-pair into settings-table
|
330 |
|
|
function db_add_key_value($key, $value) {
|
331 |
|
|
global $database; global $OK; global $FAIL;
|
332 |
|
|
$table = TABLE_PREFIX.'settings';
|
333 |
|
|
$query = $database->query("SELECT value FROM $table WHERE name = '$key' LIMIT 1");
|
334 |
|
|
if($query->numRows() > 0) {
|
335 |
|
|
echo "$key: already exists. $OK.<br />";
|
336 |
|
|
return true;
|
337 |
|
|
} else {
|
338 |
|
|
$database->query("INSERT INTO $table (name,value) VALUES ('$key', '$value')");
|
339 |
|
|
echo (mysql_error()?mysql_error().'<br />':'');
|
340 |
|
|
$query = $database->query("SELECT value FROM $table WHERE name = '$key' LIMIT 1");
|
341 |
|
|
if($query->numRows() > 0) {
|
342 |
|
|
echo "$key: $OK.<br />";
|
343 |
|
|
return true;
|
344 |
|
|
} else {
|
345 |
|
|
echo "$key: $FAIL!<br />";
|
346 |
|
|
return false;
|
347 |
|
|
}
|
348 |
|
|
}
|
349 |
|
|
}
|
350 |
|
|
|
351 |
|
|
// function to add a new field into a table
|
352 |
|
|
function db_add_field($field, $table, $desc) {
|
353 |
|
|
global $database; global $OK; global $FAIL;
|
354 |
|
|
$table = TABLE_PREFIX.$table;
|
355 |
|
|
$query = $database->query("DESCRIBE $table '$field'");
|
356 |
|
|
if($query->numRows() == 0) { // add field
|
357 |
|
|
$query = $database->query("ALTER TABLE $table ADD $field $desc");
|
358 |
|
|
echo (mysql_error()?mysql_error().'<br />':'');
|
359 |
|
|
$query = $database->query("DESCRIBE $table '$field'");
|
360 |
|
|
echo (mysql_error()?mysql_error().'<br />':'');
|
361 |
|
|
if($query->numRows() > 0) {
|
362 |
|
|
echo "'$field' added. $OK.<br />";
|
363 |
|
|
} else {
|
364 |
|
|
echo "adding '$field' $FAIL!<br />";
|
365 |
|
|
}
|
366 |
|
|
} else {
|
367 |
|
|
echo "'$field' already exists. $OK.<br />";
|
368 |
|
|
}
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
/**********************************************************
|
372 |
|
|
* - Adding field default_theme to settings table
|
373 |
|
|
*/
|
374 |
|
|
echo "<br />Adding default_theme to settings table<br />";
|
375 |
1484
|
Luisehahne
|
db_update_key_value('settings', 'default_theme', $DEFAULT_THEME);
|
376 |
1457
|
Luisehahne
|
/**********************************************************
|
377 |
|
|
* - install droplets
|
378 |
|
|
*/
|
379 |
|
|
$drops = (!in_array ( "mod_droplets", $all_tables)) ? "<br />Install droplets<br />" : "<br />Upgrade droplets<br />";
|
380 |
|
|
echo $drops;
|
381 |
|
|
|
382 |
1533
|
Luisehahne
|
$file_name = (!in_array ( "mod_droplets", $all_tables) ? "install.php" : "upgrade.php");
|
383 |
1457
|
Luisehahne
|
require_once (WB_PATH."/modules/droplets/".$file_name);
|
384 |
|
|
|
385 |
|
|
// check again all tables, to get a new array
|
386 |
|
|
if(sizeof($all_tables) < 22) { $all_tables = check_wb_tables(); }
|
387 |
|
|
/**********************************************************
|
388 |
|
|
* - check tables comin with WebsiteBaker
|
389 |
|
|
*/
|
390 |
|
|
$check_text = 'total ';
|
391 |
|
|
// $check_tables = mysqlCheckTables( DB_NAME ) ;
|
392 |
|
|
|
393 |
|
|
if(sizeof($all_tables) == 22)
|
394 |
|
|
{
|
395 |
|
|
echo '<h4>NOTICE: Your database '.DB_NAME.' has '.sizeof($all_tables).' '.$check_text.' tables from '.sizeof($table_list).' included in package '.$OK.'</h4>';
|
396 |
|
|
}
|
397 |
|
|
else
|
398 |
|
|
{
|
399 |
|
|
status_msg('<strong>WARNING:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div');
|
400 |
|
|
echo '<h4>Missing required tables. You can install them in backend->addons->modules->advanced. Then again run upgrade-script.php</h4>';
|
401 |
|
|
$result = array_diff ( $table_list, $all_tables );
|
402 |
|
|
echo '<h4 class="warning"><br />';
|
403 |
|
|
while ( list ( $key, $val ) = each ( $result ) )
|
404 |
|
|
{
|
405 |
|
|
echo TABLE_PREFIX.$val.' '.$FAIL.'<br>';
|
406 |
|
|
}
|
407 |
|
|
echo '<br /></h4>';
|
408 |
|
|
echo '<br /><form action="'. $_SERVER['PHP_SELF'] .'">';
|
409 |
|
|
echo '<input type="submit" value="kick me back" style="float:left;" />';
|
410 |
|
|
echo '</form>';
|
411 |
|
|
if(defined('ADMIN_URL'))
|
412 |
|
|
{
|
413 |
|
|
echo '<form action="'.ADMIN_URL.'" target="_self">';
|
414 |
|
|
echo ' <input type="submit" value="kick me to the Backend" />';
|
415 |
|
|
echo '</form>';
|
416 |
|
|
}
|
417 |
|
|
echo "<br /><br /></div>
|
418 |
|
|
</body>
|
419 |
|
|
</html>
|
420 |
|
|
";
|
421 |
|
|
exit();
|
422 |
|
|
}
|
423 |
|
|
|
424 |
|
|
/**********************************************************
|
425 |
|
|
* - Adding field sec_anchor to settings table
|
426 |
|
|
*/
|
427 |
|
|
echo "<br />Adding sec_anchor to settings table<br />";
|
428 |
|
|
$cfg = array(
|
429 |
|
|
'sec_anchor' => 'wb_'
|
430 |
|
|
);
|
431 |
|
|
foreach($cfg as $key=>$value) {
|
432 |
|
|
db_add_key_value($key, $value);
|
433 |
|
|
}
|
434 |
|
|
|
435 |
|
|
/**********************************************************
|
436 |
|
|
* - Adding redirect timer to settings table
|
437 |
|
|
*/
|
438 |
|
|
echo "<br />Adding redirect timer to settings table<br />";
|
439 |
|
|
$cfg = array(
|
440 |
|
|
'redirect_timer' => '1500'
|
441 |
|
|
);
|
442 |
|
|
foreach($cfg as $key=>$value) {
|
443 |
|
|
db_add_key_value($key, $value);
|
444 |
|
|
}
|
445 |
|
|
|
446 |
|
|
/**********************************************************
|
447 |
1532
|
Luisehahne
|
* - Adding rename_files_on_upload to settings table
|
448 |
|
|
*/
|
449 |
|
|
echo "<br />Updating rename_files_on_upload to settings table<br />";
|
450 |
|
|
$cfg = array(
|
451 |
|
|
'rename_files_on_upload' => 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js'
|
452 |
|
|
);
|
453 |
|
|
db_update_key_value('settings', 'rename_files_on_upload', $cfg['rename_files_on_upload']);
|
454 |
|
|
|
455 |
|
|
/**********************************************************
|
456 |
1457
|
Luisehahne
|
* - Adding mediasettings to settings table
|
457 |
|
|
*/
|
458 |
|
|
echo "<br />Adding mediasettings to settings table<br />";
|
459 |
|
|
$cfg = array(
|
460 |
1476
|
Luisehahne
|
'mediasettings' => '',
|
461 |
1457
|
Luisehahne
|
);
|
462 |
1484
|
Luisehahne
|
|
463 |
1457
|
Luisehahne
|
foreach($cfg as $key=>$value) {
|
464 |
|
|
db_add_key_value($key, $value);
|
465 |
|
|
}
|
466 |
|
|
|
467 |
|
|
/**********************************************************
|
468 |
|
|
* - Adding fingerprint_with_ip_octets to settings table
|
469 |
|
|
*/
|
470 |
|
|
echo "<br />Adding fingerprint_with_ip_octets to settings table<br />";
|
471 |
|
|
$cfg = array(
|
472 |
1476
|
Luisehahne
|
'fingerprint_with_ip_octets' => '2',
|
473 |
|
|
'secure_form_module' => ''
|
474 |
1457
|
Luisehahne
|
);
|
475 |
|
|
foreach($cfg as $key=>$value) {
|
476 |
|
|
db_add_key_value($key, $value);
|
477 |
|
|
}
|
478 |
|
|
|
479 |
|
|
/**********************************************************
|
480 |
|
|
* - Add field "redirect_type" to table "mod_menu_link"
|
481 |
|
|
*/
|
482 |
|
|
echo "<br />Adding field redirect_type to mod_menu_link table<br />";
|
483 |
|
|
db_add_field('redirect_type', 'mod_menu_link', "INT NOT NULL DEFAULT '302' AFTER `target_page_id`");
|
484 |
|
|
|
485 |
1588
|
darkviper
|
/**********************************************************
|
486 |
|
|
* - Update search no results database filed to create
|
487 |
|
|
* valid XHTML if search is empty
|
488 |
|
|
*/
|
489 |
|
|
if (version_compare(WB_VERSION, '2.8', '<'))
|
490 |
1457
|
Luisehahne
|
{
|
491 |
|
|
echo "<br />Updating database field `no_results` of search table: ";
|
492 |
|
|
$search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>');
|
493 |
1588
|
darkviper
|
$sql = 'UPDATE `'.TABLE_PREFIX.'search` ';
|
494 |
|
|
$sql .= 'SET `value`=\''.$search_no_results.'\' ';
|
495 |
|
|
$sql .= 'WHERE `name`=\'no_results\'';
|
496 |
|
|
echo ($database->query($sql)) ? ' $OK<br />' : ' $FAIL<br />';
|
497 |
1457
|
Luisehahne
|
}
|
498 |
|
|
/**********************************************************
|
499 |
|
|
* upgrade media folder index protect files
|
500 |
|
|
*/
|
501 |
1588
|
darkviper
|
$dir = (WB_PATH.MEDIA_DIRECTORY);
|
502 |
|
|
echo '<h4>Upgrade '.MEDIA_DIRECTORY.'/ index.php protect files</h4><br />';
|
503 |
|
|
$array = rebuildFolderProtectFile($dir);
|
504 |
|
|
if( sizeof( $array ) ){
|
505 |
|
|
print '<br /><strong>Upgrade '.sizeof( $array ).' '.MEDIA_DIRECTORY.'/ protect files</strong>'." $OK<br />";
|
506 |
|
|
} else {
|
507 |
|
|
print '<br /><strong>Upgrade '.MEDIA_DIRECTORY.'/ protect files</strong>'." $FAIL!<br />";
|
508 |
|
|
print implode ('<br />',$array);
|
509 |
1457
|
Luisehahne
|
}
|
510 |
1593
|
Luisehahne
|
/**********************************************************
|
511 |
|
|
* upgrade posts folder index protect files
|
512 |
|
|
*/
|
513 |
|
|
$sPostsPath = WB_PATH.PAGES_DIRECTORY.'/posts';
|
514 |
|
|
echo '<h4>Upgrade /posts/ index.php protect files</h4><br />';
|
515 |
|
|
$array = rebuildFolderProtectFile($sPostsPath);
|
516 |
|
|
if( sizeof( $array ) ){
|
517 |
|
|
print '<br /><strong>Upgrade '.sizeof( $array ).' /posts/ protect files</strong>'." $OK<br />";
|
518 |
|
|
} else {
|
519 |
|
|
print '<br /><strong>Upgrade /posts/ protect files</strong>'." $FAIL!<br />";
|
520 |
|
|
print implode ('<br />',$array);
|
521 |
|
|
}
|
522 |
1484
|
Luisehahne
|
/* *****************************************************************************
|
523 |
|
|
* - check for deprecated / never needed files
|
524 |
|
|
*/
|
525 |
1588
|
darkviper
|
if(sizeof($filesRemove)) {
|
526 |
|
|
echo '<h2>Step '.(++$stepID).': Remove deprecated and old files</h2>';
|
527 |
|
|
}
|
528 |
1484
|
Luisehahne
|
$searches = array(
|
529 |
|
|
'[ADMIN]',
|
530 |
|
|
'[MEDIA]',
|
531 |
1525
|
Luisehahne
|
'[PAGES]',
|
532 |
1533
|
Luisehahne
|
'[FRAMEWORK]',
|
533 |
|
|
'[MODULES]',
|
534 |
1525
|
Luisehahne
|
'[TEMPLATE]'
|
535 |
1484
|
Luisehahne
|
);
|
536 |
|
|
$replacements = array(
|
537 |
1525
|
Luisehahne
|
substr(ADMIN_PATH, strlen(WB_PATH)+1),
|
538 |
1484
|
Luisehahne
|
MEDIA_DIRECTORY,
|
539 |
1525
|
Luisehahne
|
PAGES_DIRECTORY,
|
540 |
1533
|
Luisehahne
|
'/framework',
|
541 |
|
|
'/modules',
|
542 |
|
|
'/templates'
|
543 |
1484
|
Luisehahne
|
);
|
544 |
|
|
|
545 |
1532
|
Luisehahne
|
foreach( $filesRemove as $filesId )
|
546 |
1484
|
Luisehahne
|
{
|
547 |
1532
|
Luisehahne
|
$msg = '';
|
548 |
|
|
foreach( $filesId as $file )
|
549 |
|
|
{
|
550 |
|
|
$file = str_replace($searches, $replacements, $file);
|
551 |
|
|
$file = WB_PATH.'/'.$file;
|
552 |
1588
|
darkviper
|
if( file_exists($file) ) {
|
553 |
|
|
// try to unlink file
|
554 |
|
|
if(!is_writable( $file ) || !unlink($file)) {
|
555 |
|
|
// save in err-list, if failed
|
556 |
1532
|
Luisehahne
|
$msg .= $file.'<br />';
|
557 |
|
|
}
|
558 |
1484
|
Luisehahne
|
}
|
559 |
|
|
}
|
560 |
1532
|
Luisehahne
|
|
561 |
|
|
if($msg != '')
|
562 |
|
|
{
|
563 |
|
|
$msg = '<br /><br />Following files are deprecated, outdated or a security risk and
|
564 |
|
|
can not be removed automatically.<br /><br />Please delete them
|
565 |
|
|
using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
|
566 |
|
|
status_msg($msg, 'error warning', 'div');
|
567 |
|
|
echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
|
568 |
|
|
|
569 |
|
|
echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
|
570 |
|
|
echo ' <input name="send" type="submit" value="Restart upgrade script" />';
|
571 |
|
|
echo '</form>';
|
572 |
|
|
echo '<br /><br /></div></body></html>';
|
573 |
|
|
exit;
|
574 |
|
|
}
|
575 |
1484
|
Luisehahne
|
}
|
576 |
|
|
|
577 |
1532
|
Luisehahne
|
|
578 |
1457
|
Luisehahne
|
/**********************************************************
|
579 |
1525
|
Luisehahne
|
* - check for deprecated / never needed files
|
580 |
|
|
*/
|
581 |
1588
|
darkviper
|
if(sizeof($dirRemove)) {
|
582 |
|
|
echo '<h2>Step '.(++$stepID).': Remove deprecated and old folders</h2>';
|
583 |
|
|
$searches = array(
|
584 |
|
|
'[ADMIN]',
|
585 |
|
|
'[MEDIA]',
|
586 |
|
|
'[PAGES]',
|
587 |
|
|
'[TEMPLATE]'
|
588 |
|
|
);
|
589 |
|
|
$replacements = array(
|
590 |
|
|
substr(ADMIN_PATH, strlen(WB_PATH)+1),
|
591 |
|
|
MEDIA_DIRECTORY,
|
592 |
|
|
PAGES_DIRECTORY,
|
593 |
|
|
'/templates',
|
594 |
|
|
);
|
595 |
|
|
$msg = '';
|
596 |
|
|
foreach( $dirRemove as $dir ) {
|
597 |
|
|
$dir = str_replace($searches, $replacements, $dir);
|
598 |
|
|
$dir = WB_PATH.'/'.$dir;
|
599 |
|
|
if( is_dir( $dir )) {
|
600 |
|
|
// try to delete dir
|
601 |
1641
|
Luisehahne
|
if(!is_writable( $dir ) || !rm_full_dir($dir)) {
|
602 |
1588
|
darkviper
|
// save in err-list, if failed
|
603 |
1641
|
Luisehahne
|
$msg .= str_replace(WB_PATH,'',$dir).'<br />';
|
604 |
1588
|
darkviper
|
}
|
605 |
1525
|
Luisehahne
|
}
|
606 |
|
|
}
|
607 |
1588
|
darkviper
|
if($msg != '') {
|
608 |
1641
|
Luisehahne
|
$msg = '<br /><br />Following directories are deprecated, outdated or a security risk and
|
609 |
1588
|
darkviper
|
can not be removed automatically.<br /><br />Please delete them
|
610 |
|
|
using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
|
611 |
|
|
status_msg($msg, 'error warning', 'div');
|
612 |
|
|
echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
|
613 |
|
|
echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
|
614 |
|
|
echo ' <input name="send" type="submit" value="Restart upgrade script" />';
|
615 |
|
|
echo '</form>';
|
616 |
|
|
echo '<br /><br /></div></body></html>';
|
617 |
|
|
exit;
|
618 |
|
|
}
|
619 |
1525
|
Luisehahne
|
}
|
620 |
1532
|
Luisehahne
|
|
621 |
1588
|
darkviper
|
/**********************************************************
|
622 |
|
|
* upgrade modules if newer version is available
|
623 |
|
|
*/
|
624 |
|
|
$aModuleList = array('news');
|
625 |
|
|
foreach($aModuleList as $sModul) {
|
626 |
|
|
if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
|
627 |
|
|
$currModulVersion = get_modul_version ($sModul, false);
|
628 |
|
|
$newModulVersion = get_modul_version ($sModul, true);
|
629 |
|
|
if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
|
630 |
|
|
echo '<h2>Step '.(++$stepID).' : Upgrade module \''.$sModul.'\' to version '.$newModulVersion.'</h2>';
|
631 |
|
|
require_once(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
|
632 |
|
|
}
|
633 |
|
|
}
|
634 |
1525
|
Luisehahne
|
}
|
635 |
|
|
/**********************************************************
|
636 |
1457
|
Luisehahne
|
* - Reload all addons
|
637 |
|
|
*/
|
638 |
|
|
|
639 |
1588
|
darkviper
|
echo '<h2>Step '.(++$stepID).' : Reload all addons database entry (no upgrade)</h2>';
|
640 |
|
|
////delete modules
|
641 |
|
|
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
|
642 |
|
|
// Load all modules
|
643 |
|
|
if( ($handle = opendir(WB_PATH.'/modules/')) ) {
|
644 |
|
|
while(false !== ($file = readdir($handle))) {
|
645 |
|
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
|
646 |
|
|
load_module(WB_PATH.'/modules/'.$file );
|
647 |
|
|
// upgrade_module($file, true);
|
648 |
|
|
}
|
649 |
1457
|
Luisehahne
|
}
|
650 |
1588
|
darkviper
|
closedir($handle);
|
651 |
1457
|
Luisehahne
|
}
|
652 |
1588
|
darkviper
|
echo '<br />Modules reloaded<br />';
|
653 |
1457
|
Luisehahne
|
|
654 |
1588
|
darkviper
|
////delete templates
|
655 |
|
|
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
|
656 |
|
|
// Load all templates
|
657 |
|
|
if( ($handle = opendir(WB_PATH.'/templates/')) ) {
|
658 |
|
|
while(false !== ($file = readdir($handle))) {
|
659 |
|
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
|
660 |
|
|
load_template(WB_PATH.'/templates/'.$file);
|
661 |
|
|
}
|
662 |
1457
|
Luisehahne
|
}
|
663 |
1588
|
darkviper
|
closedir($handle);
|
664 |
1457
|
Luisehahne
|
}
|
665 |
1588
|
darkviper
|
echo '<br />Templates reloaded<br />';
|
666 |
1457
|
Luisehahne
|
|
667 |
1588
|
darkviper
|
////delete languages
|
668 |
|
|
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
|
669 |
|
|
// Load all languages
|
670 |
|
|
if( ($handle = opendir(WB_PATH.'/languages/')) ) {
|
671 |
|
|
while(false !== ($file = readdir($handle))) {
|
672 |
|
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
|
673 |
|
|
load_language(WB_PATH.'/languages/'.$file);
|
674 |
|
|
}
|
675 |
1457
|
Luisehahne
|
}
|
676 |
1588
|
darkviper
|
closedir($handle);
|
677 |
1457
|
Luisehahne
|
}
|
678 |
1588
|
darkviper
|
echo '<br />Languages reloaded<br />';
|
679 |
1457
|
Luisehahne
|
|
680 |
|
|
/**********************************************************
|
681 |
|
|
* - End of upgrade script
|
682 |
|
|
*/
|
683 |
|
|
|
684 |
|
|
// require(WB_PATH.'/framework/initialize.php');
|
685 |
|
|
|
686 |
1588
|
darkviper
|
if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', $DEFAULT_THEME); }
|
687 |
|
|
if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
|
688 |
1532
|
Luisehahne
|
/**********************************************************
|
689 |
|
|
* - Set Version to new Version
|
690 |
|
|
*/
|
691 |
1588
|
darkviper
|
echo '<br />Update database version number to '.VERSION.' '.SP.' '.' Revision ['.REVISION.'] : ';
|
692 |
|
|
// echo ($database->query("UPDATE `".TABLE_PREFIX."settings` SET `value`='".VERSION."' WHERE `name` = 'wb_version'")) ? " $OK<br />" : " $FAIL<br />";
|
693 |
|
|
db_update_key_value('settings', 'wb_version', VERSION);
|
694 |
|
|
db_update_key_value('settings', 'wb_revision', REVISION);
|
695 |
|
|
db_update_key_value('settings', 'wb_sp', SP);
|
696 |
1457
|
Luisehahne
|
|
697 |
1588
|
darkviper
|
echo '<p style="font-size:120%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
|
698 |
|
|
status_msg('<strong>Warning:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
|
699 |
|
|
// show buttons to go to the backend or frontend
|
700 |
|
|
echo '<br />';
|
701 |
1532
|
Luisehahne
|
|
702 |
1588
|
darkviper
|
if(defined('WB_URL')) {
|
703 |
|
|
echo '<form action="'.WB_URL.'/">';
|
704 |
|
|
echo ' <input type="submit" value="kick me to the Frontend" />';
|
705 |
|
|
echo '</form>';
|
706 |
|
|
}
|
707 |
|
|
if(defined('ADMIN_URL')) {
|
708 |
|
|
echo '<form action="'.ADMIN_URL.'/">';
|
709 |
|
|
echo ' <input type="submit" value="kick me to the Backend" />';
|
710 |
|
|
echo '</form>';
|
711 |
|
|
}
|
712 |
1457
|
Luisehahne
|
|
713 |
1588
|
darkviper
|
echo '<br /><br /></div></body></html>';
|