Project

General

Profile

« Previous | Next » 

Revision 715

Added by doc over 16 years ago

Updated upgrade script (added WB2.7 basic styles, pre-checks and disclaimer)

View differences:

upgrade-script.php
23 23

  
24 24
*/
25 25

  
26
//
27
// upgrade-script for Website Baker from version 2.6.7 to 2.7
28
//
26
/** 
27
	PHP ROUTINES FOR THE UPGRADE SCRIPT
28
**/
29
// this function checks the basic configurations of an existing WB intallation
30
function status_msg($message, $class='check', $element='span') {
31
	// returns a status message
32
	echo '<'.$element .' class="' .$class .'">' .$message .'</' .$element.'>';
33
}
29 34

  
30
require('config.php');
31
require(WB_PATH.'/framework/functions.php');
35
function check_baseline_configuration() {
36
	// check if config.php file exists and contains values
37
	status_msg('config.php: ');
38
	@include('config.php');
39
	if(defined('WB_PATH')) {
40
		status_msg('OK', 'ok');
41
	} else {
42
		// output error message and return error status
43
		status_msg('FAILED', 'error');
44
		status_msg('<strong>Error:</strong><br />No valid config.php found in: "<em>'
45
			.dirname(__FILE__).'</em>"<br />Please check if this script is placed in the WB root directory '
46
			.'and check/correct the config.php file before proceeding.<br /><br />You can not proceed before this error is fixed!!!'
47
			, 'warning', 'div');
48
		return -1;
49
	}
32 50

  
51
	// check if the WB 2.7 installation files were already uploaded via FTP
52
	status_msg(', WB 2.7 core files uploaded: ');
53
	@include(WB_PATH .'/framework/functions.php');
54
	@include(WB_PATH .'/admin/interface/version.php');
55
	if(defined('VERSION') && VERSION == '2.7'
56
		&& function_exists('get_variable_content') 
57
		&& file_exists(WB_PATH .'/modules/menu_link/languages/DE.php') 
58
		&& file_exists(WB_PATH .'/modules/output_filter/filter-routines.php') 
59
		&& file_exists(WB_PATH .'/modules/captcha_control/languages/DE.php')
60
		&& file_exists(WB_PATH .'/modules/jsadmin/jsadmin_backend_include.php')
61
		&& file_exists(WB_PATH .'/admin/admintools/tool.php')
62
		&& file_exists(WB_PATH .'/admin/interface/er_levels.php')) {
63
		status_msg('OK','ok');
64
	} else {
65
		// output a warning and return error status
66
		status_msg('FAILED','error');
67
		status_msg('<strong>Error:</strong><br />Some of the Website Baker 2.7 core files were not found.'
68
			.'<br />Please upload all core files (except config.php and folder /install) contained in the WB 2.7 installation package first.'
69
			.'<br /><br />You can not proceed before this error is fixed!!!'
70
			, 'warning', 'div');
71
		return -1;
72
	}
73

  
74
	// check database connection
75
	$wb_version = '';
76
	status_msg(', Database connection: ');
77
	if(class_exists('database')) {
78
		$db = new database;
79
		$table = TABLE_PREFIX .'settings';
80
		$wb_version = @$db->get_one("SELECT value FROM $table WHERE name = 'wb_version' LIMIT 1");
81
	}
82
	if($wb_version) {
83
		status_msg('OK', 'ok');
84
	} else {
85
		// output error message and return error status
86
		status_msg('FAILED', 'error');
87
		status_msg('<strong>Error:</strong><br />Unable to obtain the WB version stored in the database of your existing installation.'
88
			.'<br />Make sure that the database class is available and the connection data in the config.php file is correct '
89
			.'and your database is not corrupted.<br />To check if your database is corrupted, you can use a tool like '
90
			.'<a href="http://www.phpmyadmin.net/" target="_blank">phpMyAdmin</a>.'
91
			.'<br /><br />You can not proceed before this error is fixed!!!'
92
			, 'warning', 'div');
93
		return -1;
94
	}
95

  
96
	// check WB version in database is 2.6.7
97
	status_msg(', WB version (database): ');
98
	if($wb_version == '2.6.7') {
99
		status_msg('2.6.7 (OK)', 'ok');
100
	} else {
101
		// output a warning
102
		status_msg($wb_version .' (required 2.6.7)', 'error');
103
		status_msg('<strong>Warning:</strong><br />The extracted version number from the database is ' .$wb_version .' (required 2.6.7).'
104
			.'<br />If the extracted database version is lower than 2.6.7, please upgrade first to Website Baker 2.6.7 and then to 2.7.'
105
			.'<br />If the obtained database version is higher or equal to 2.7, you do not need to execute this script.'
106
			.'<br /><br />You can not proceed before this error is fixed!!!'
107
			, 'warning', 'div');
108
		return -1;
109
	}
110
	return 0;
111
}
112

  
33 113
?>
34 114

  
35 115
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
36 116
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
37 117
<head>
38
<title>Upgrade-Script</title>
39
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
118
<title>Upgrade script from Website Baker v2.6.7 to Website Baker v2.7</title>
40 119

  
41 120
<style type="text/css">
42
.red { background-color:#FF0000 }
43
.green { background-color:#00FF00 }
121
body {
122
	margin:0;
123
	padding:0;
124
	border:0;
125
	background: #EBF7FC;
126
	color:#000;
127
  font-family: 'Trebuchet MS', Verdana, Arial, Helvetica, Sans-Serif;
128
	font-size: small;
129
	height:101%;
130
}
44 131

  
45
#warning {
46
width: 90%; 
47
padding: 10px; 
48
margin-left: 5%; 
49
margin-bottom: 5px; 
50
border: 1px solid #FF0000; 
51
background-color: #FFDBDB;
132
#container {
133
	width:85%;
134
	background: #9ACBF1 url(admin/interface/background.png) repeat-x;
135
	border:1px solid #000;
136
	color:#000;
137
	margin:2em auto;
138
	padding:0 15px;
139
	min-height: 500px;
140
	text-align:left;
52 141
}
53 142

  
54 143
p { line-height:1.5em; }
55 144

  
145
h1,h2,h3,h4,h5,h6 {
146
	font-family: Verdana, Arial, Helvetica, sans-serif;
147
	color: #369;
148
	margin-top: 1.0em;
149
	margin-bottom: 0.1em;
150
}
151

  
152
h1 { font-size:150%; }
153
h2 { font-size: 130%; border-bottom: 1px #CCC solid; }
154
h3 { font-size: 120%; }
155

  
156
.ok, .error { font-weight:bold; }
157
.ok { color:green; }
158
.error { color:red; }
159
.check { color:#555; }
160

  
161
.red { background-color:#FF0000 }
162
.green { background-color:#00FF00 }
163

  
164
.warning {
165
	width: 98%;
166
	background:#FFDBDB;
167
	padding:0.2em;
168
	margin-top:0.5em;
169
	border: 1px solid black;
170
}
56 171
</style>
57 172
</head>
58 173
<body>
174
<div id="container">
175
<img src="admin/interface/logo.png" alt="Website Baker Logo" />
176

  
177
<h1>Website Baker Upgrade</h1>
178
<p>This script is for <strong>upgrading an existing v2.6.7</strong> installation to the latest Website Baker <strong>version 2.7</strong>. The upgrade script checks the configuration of your installed Website Baker system and alters the existing WB database to reflect the changes introduced with WB 2.7.</p>
179

  
59 180
<?php
181
if(!isset($_POST['backup_confirmed'])) { 
182
?>
183
<h2>Step 1: Check existing installation</h2>
184
<p>Checking the configuration of your existing Website Baker installation:<br />
185
<?php
186
// check the basic Website Baker installation before proceeding
187
if(check_baseline_configuration() != 0) die;
188
status_msg('<p>Congratulations: You have passed all the required pre-checks.', 'ok');
189
?>
190

  
191
<h2>Step 2: Create a backup of your existing data</h2>
192
<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. The upgrade script is not sufficiently tested at the moment and should therefore only be used for testing purposes!!! Please confirm the disclaimer before starting this script.</p>
193

  
194
<form name="send" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
195
<textarea cols="80" rows="5">DISCLAIMER: The Website Baker 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 Website Baker MySQL database was created before you can proceed.</textarea>
196
<br /><br /><input name="backup_confirmed" type="checkbox" value="confirmed" />&nbsp;I confirm that a manual backup of the /pages folder and the MySQL database was created.
197
<br /><br /><input name="send" type="submit" value="Start upgrade script" />
198
</form>
199
<br />
200

  
201
<?php
202
if(isset($_POST['send'])) {
203
	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');
204
} 
205
?>
206
<br /><br />
207
<?php
208
} else {
60 209
/**
61
	AT THIS POINT IN TIME THE UPGRADE SCRIPT IS NOT MATURE ENOUGH
62
	SO PROVIDE A WARNING TO BACKUP THE DATABASE AND THE PAGES DIRECTORY
63
	BEFORE EXECUTING THIS SCRIPT (doc)
64
*/
65
if(!isset($_GET['action']) || $_GET['action'] != 'upgrade') {
210
	THE WEBSITE BAKER UPGRADE SCRIPT STARTS HERE
211
**/
212
require('config.php');
213
require(WB_PATH.'/framework/functions.php');
66 214
?>
67
<div id="warning">
68
<strong>WARNING:</strong>
69
<p>The actual WB 2.7 version is still a developer version. <strong>It is not recommended to use this release in a
70
productive environment</strong>.<p>The upgrade-script is not sufficiently tested yet, so please <strong>backup your database and /pages directory before executing the upgrade script</strong>.<br />You may loose all your data if something goes wrong!!</p><p>If you want to start the upgrade-script, please click on: <a href="upgrade-script.php?action=upgrade" target="_self">execute upgrade-script</a></p>
71
</div>
215
<h2>Step 3: Upgrading the existing Website Baker installation to WB 2.7</h2>
216
<p>will upgrade Website Baker 2.6.5 / 2.6.7 to version 2.7</p>
72 217
<?php
73
die;
74
} ?>
75
	
76
<h2>Upgrade-script</h2>
77
<p>
78
will upgrade Website Baker 2.6.5 / 2.6.7 to version 2.7
79
</p>
80
<?php
81 218

  
82 219
$OK   = '<span class="green">OK</span>';
83 220
$FAIL = '<span class="red">failed</span>';
......
126 263
	}
127 264
}
128 265

  
129

  
130 266
echo "<br /><u>Adding module_order and max_excerpt to search-table</u><br />";
131 267
// module_order - in which order to show the search-results
132 268
// max_excerpt - how many lines of excerpt to print per matching page
......
712 848
 */
713 849
echo "<br /><br />Done<br />";
714 850

  
851
}
715 852
?>
716

  
853
</div>
717 854
</body>
718 855
</html>

Also available in: Unified diff