Fixed bug: call method in object instead of global function
[vanilla-miry.git] / setup / upgrader.php
blobc776abbadf6513f69efdddc2fd3343074b33abf2
1 <?php
2 // REPORT ALL ERRORS
3 error_reporting(E_ALL);
4 // DO NOT ALLOW PHP_SESS_ID TO BE PASSED IN THE QUERYSTRING
5 ini_set('session.use_only_cookies', 1);
6 // Track errors so explicit error messages can be reported should errors be encountered
7 ini_set('track_errors', 1);
8 // Define constant for magic_quotes
9 define('MAGIC_QUOTES_ON', get_magic_quotes_gpc());
11 // INCLUDE NECESSARY CLASSES & FUNCTIONS
12 include('../library/Framework/Framework.Functions.php');
13 include('../library/Framework/Framework.Class.Select.php');
14 include('../library/Framework/Framework.Class.SqlBuilder.php');
15 include('../library/Framework/Framework.Class.MessageCollector.php');
16 include('../library/Framework/Framework.Class.ErrorManager.php');
17 include('../library/Framework/Framework.Class.ConfigurationManager.php');
19 // Include database structure
20 include('../appg/database.php');
22 // Set application name and version
23 include('../appg/version.php');
25 // Set up some configuration defaults to override
26 $Configuration['DATABASE_HOST'] = '';
27 $Configuration['DATABASE_NAME'] = '';
28 $Configuration['DATABASE_USER'] = '';
29 $Configuration['DATABASE_PASSWORD'] = '';
30 $Configuration['APPLICATION_PATH'] = '';
31 $Configuration['DATABASE_PATH'] = '';
32 $Configuration['LIBRARY_PATH'] = '';
33 $Configuration['EXTENSIONS_PATH'] = '';
34 $Configuration['LANGUAGES_PATH'] = '';
35 $Configuration['THEME_PATH'] = '';
36 $Configuration['BASE_URL'] = '';
37 $Configuration['DEFAULT_STYLE'] = '';
38 $Configuration['WEB_ROOT'] = '';
39 $Configuration['COOKIE_DOMAIN'] = '';
40 $Configuration['COOKIE_PATH'] = '';
41 $Configuration['SUPPORT_EMAIL'] = '';
42 $Configuration['SUPPORT_NAME'] = '';
43 $Configuration['FORWARD_VALIDATED_USER_URL'] = '';
44 $Configuration['CHARSET'] = 'utf-8';
45 $Configuration['DATABASE_TABLE_PREFIX'] = 'LUM_';
46 $Configuration['SETUP_COMPLETE'] = '0';
47 $Configuration['SETUP_TEST'] = '0';
49 $Configuration['APPLICATION_TITLE'] = '';
50 $Configuration['BANNER_TITLE'] = '';
51 $Configuration['APPLICATION_TITLE'] = '';
52 $Configuration['APPLICATION_TITLE'] = '';
53 $Configuration['DISCUSSIONS_PER_PAGE'] = '';
54 $Configuration['COMMENTS_PER_PAGE'] = '';
55 $Configuration['SEARCH_RESULTS_PER_PAGE'] = '';
56 $Configuration['ALLOW_NAME_CHANGE'] = '';
57 $Configuration['PUBLIC_BROWSING'] = '';
58 $Configuration['USE_CATEGORIES'] = '';
59 $Configuration['LOG_ALL_IPS'] = '';
60 $Configuration['PANEL_BOOKMARK_COUNT'] = '';
61 $Configuration['PANEL_PRIVATE_COUNT'] = '';
62 $Configuration['PANEL_HISTORY_COUNT'] = '';
63 $Configuration['PANEL_USERDISCUSSIONS_COUNT'] = '';
64 $Configuration['PANEL_SEARCH_COUNT'] = '';
65 $Configuration['MAX_COMMENT_LENGTH'] = '';
66 $Configuration['DISCUSSION_POST_THRESHOLD'] = '';
67 $Configuration['DISCUSSION_TIME_THRESHOLD'] = '';
68 $Configuration['DISCUSSION_THRESHOLD_PUNISHMENT'] = '';
69 $Configuration['COMMENT_POST_THRESHOLD'] = '';
70 $Configuration['COMMENT_TIME_THRESHOLD'] = '';
71 $Configuration['COMMENT_THRESHOLD_PUNISHMENT'] = '';
72 $Configuration['DEFAULT_ROLE'] = '';
73 $Configuration['ALLOW_IMMEDIATE_ACCESS'] = '';
74 $Configuration['APPROVAL_ROLE'] = '';
76 class FauxContext {
77 var $WarningCollector;
78 var $ErrorManager;
79 var $SqlCollector;
80 var $Configuration;
81 var $Dictionary;
82 var $DatabaseTables;
83 var $DatabaseColumns;
84 var $Session;
85 function GetDefinition($Code) {
86 if (array_key_exists($Code, $this->Dictionary)) {
87 return $this->Dictionary[$Code];
88 } else {
89 return $Code;
94 class FauxSession {
95 var $User = false;
98 // Retrieves an array of column names in the specified table
99 function GetColumns(&$Connection, $Table) {
100 $Data = @mysql_query('show columns from '.$Table, $Connection);
101 $FoundColumns = array();
102 if (!$Data) {
103 $Context->WarningCollector->Add("Failed to identify existing '.$Table.' columns. MySQL reported the following error: <code>".mysql_error($Connection)."</code>");
104 } else {
105 while ($Row = mysql_fetch_array($Data)) {
106 $FoundColumns[] = $Row[0];
109 return $FoundColumns;
111 function ApplySetting(&$SettingsManager, $NewConfiguration, $Setting) {
112 if (array_key_exists($Setting, $NewConfiguration)) {
113 $SettingsManager->DefineSetting($Setting, $NewConfiguration[$Setting], 1);
117 // Create warning & error handlers
118 $Context = new FauxContext();
119 $Context->Session = new FauxSession();
120 $Context->WarningCollector = new MessageCollector();
121 $Context->ErrorManager = new ErrorManager();
122 $Context->SqlCollector = new MessageCollector();
123 $Context->Configuration = $Configuration;
124 $Context->DatabaseTables = $DatabaseTables;
125 $Context->DatabaseColumns = $DatabaseColumns;
126 $Context->Dictionary = array();
128 // Dictionary Definitions
129 $Context->Dictionary['ErrReadFileSettings'] = 'An error occurred while attempting to read settings from the configuration file: ';
130 $Context->Dictionary['ErrOpenFile'] = 'The file could not be opened. Please make sure that PHP has write access to the //1 file.';
131 $Context->Dictionary['ErrWriteFile'] = 'The file could not be written.';
133 // Define application settings
134 $WorkingDirectory = str_replace('\\', '/', getcwd()).'/';
135 $RootDirectory = str_replace('setup/', '', $WorkingDirectory);
136 $WebRoot = dirname(ForceString(@$_SERVER['PHP_SELF'], ''));
137 $WebRoot = substr($WebRoot, 0, strlen($WebRoot) - 5); // strips the "setup" off the end of the path.
138 $BaseUrl = 'http://'.ForceString(@$_SERVER['HTTP_HOST'], '').$WebRoot;
139 $ThemeDirectory = $WebRoot . 'themes/';
140 $AllowNext = 0;
141 $NewConfiguration = array();
143 // Assign some default values to the postback parameters
144 $DBHost = '';
145 $DBName = '';
146 $DBUser = '';
147 $DBPass = '';
148 $SupportEmail = '';
149 $SupportName = '';
150 $ApplicationTitle = '';
152 // Include the old settings file if it is present (it just contains constants)
153 if (file_exists($RootDirectory.'conf/old_settings.php')) {
154 include($RootDirectory.'conf/old_settings.php');
156 // Now re-assign the default configuration settings to the ones defined as constants in the old version
157 if (defined('dbHOST')) {
158 $NewConfiguration['DATABASE_HOST'] = dbHOST;
159 $DBHost = dbHOST;
161 if (defined('dbNAME')) {
162 $NewConfiguration['DATABASE_NAME'] = dbNAME;
163 $DBName = dbNAME;
165 if (defined('dbUSER')) {
166 $NewConfiguration['DATABASE_USER'] = dbUSER;
167 $DBUser = dbUSER;
169 if (defined('dbPASSWORD')) {
170 $NewConfiguration['DATABASE_PASSWORD'] = dbPASSWORD;
171 $DBPass = dbPASSWORD;
173 if (defined('agAPPLICATION_TITLE')) {
174 $NewConfiguration['APPLICATION_TITLE'] = agAPPLICATION_TITLE;
175 $ApplicationTitle = agAPPLICATION_TITLE;
177 if (defined('agBANNER_TITLE')) $NewConfiguration['BANNER_TITLE'] = agBANNER_TITLE;
178 if (defined('agDISCUSSIONS_PER_PAGE')) $NewConfiguration['DISCUSSIONS_PER_PAGE'] = agDISCUSSIONS_PER_PAGE;
179 if (defined('agCOMMENTS_PER_PAGE')) $NewConfiguration['COMMENTS_PER_PAGE'] = agCOMMENTS_PER_PAGE;
180 if (defined('agSEARCH_RESULTS_PER_PAGE')) $NewConfiguration['SEARCH_RESULTS_PER_PAGE'] = agSEARCH_RESULTS_PER_PAGE;
181 if (defined('agSUPPORT_EMAIL')) {
182 $NewConfiguration['SUPPORT_EMAIL'] = agSUPPORT_EMAIL;
183 $SupportEmail = agSUPPORT_EMAIL;
185 if (defined('agSUPPORT_NAME')) {
186 $NewConfiguration['SUPPORT_NAME'] = agSUPPORT_NAME;
187 $SupportName = agSUPPORT_NAME;
189 if (defined('agALLOW_NAME_CHANGE')) $NewConfiguration['ALLOW_NAME_CHANGE'] = agALLOW_NAME_CHANGE;
190 if (defined('agPUBLIC_BROWSING')) $NewConfiguration['PUBLIC_BROWSING'] = agPUBLIC_BROWSING;
191 if (defined('agUSE_CATEGORIES')) $NewConfiguration['USE_CATEGORIES'] = agUSE_CATEGORIES;
192 if (defined('agLOG_ALL_IPS')) $NewConfiguration['LOG_ALL_IPS'] = agLOG_ALL_IPS;
193 if (defined('agPANEL_BOOKMARK_COUNT')) $NewConfiguration['PANEL_BOOKMARK_COUNT'] = agPANEL_BOOKMARK_COUNT;
194 if (defined('agPANEL_PRIVATE_COUNT')) $NewConfiguration['PANEL_PRIVATE_COUNT'] = agPANEL_PRIVATE_COUNT;
195 if (defined('agPANEL_HISTORY_COUNT')) $NewConfiguration['PANEL_HISTORY_COUNT'] = agPANEL_HISTORY_COUNT;
196 if (defined('agPANEL_USERDISCUSSIONS_COUNT')) $NewConfiguration['PANEL_USERDISCUSSIONS_COUNT'] = agPANEL_USERDISCUSSIONS_COUNT;
197 if (defined('agPANEL_SEARCH_COUNT')) $NewConfiguration['PANEL_SEARCH_COUNT'] = agPANEL_SEARCH_COUNT;
198 if (defined('agMAX_COMMENT_LENGTH')) $NewConfiguration['MAX_COMMENT_LENGTH'] = agMAX_COMMENT_LENGTH;
199 if (defined('agDISCUSSION_POST_THRESHOLD')) $NewConfiguration['DISCUSSION_POST_THRESHOLD'] = agDISCUSSION_POST_THRESHOLD;
200 if (defined('agDISCUSSION_TIME_THRESHOLD')) $NewConfiguration['DISCUSSION_TIME_THRESHOLD'] = agDISCUSSION_TIME_THRESHOLD;
201 if (defined('agDISCUSSION_THRESHOLD_PUNISHMENT')) $NewConfiguration['DISCUSSION_THRESHOLD_PUNISHMENT'] = agDISCUSSION_THRESHOLD_PUNISHMENT;
202 if (defined('agCOMMENT_POST_THRESHOLD')) $NewConfiguration['COMMENT_POST_THRESHOLD'] = agCOMMENT_POST_THRESHOLD;
203 if (defined('agCOMMENT_TIME_THRESHOLD')) $NewConfiguration['COMMENT_TIME_THRESHOLD'] = agCOMMENT_TIME_THRESHOLD;
204 if (defined('agCOMMENT_THRESHOLD_PUNISHMENT')) $NewConfiguration['COMMENT_THRESHOLD_PUNISHMENT'] = agCOMMENT_THRESHOLD_PUNISHMENT;
205 if (defined('agDEFAULT_ROLE')) $NewConfiguration['DEFAULT_ROLE'] = agDEFAULT_ROLE;
206 if (defined('agALLOW_IMMEDIATE_ACCESS')) $NewConfiguration['ALLOW_IMMEDIATE_ACCESS'] = agALLOW_IMMEDIATE_ACCESS;
207 if (defined('agAPPROVAL_ROLE')) $NewConfiguration['APPROVAL_ROLE'] = agAPPROVAL_ROLE;
210 // Retrieve all postback parameters
211 $CurrentStep = ForceIncomingInt("Step", 0);
212 $PostBackAction = ForceIncomingString('PostBackAction', '');
213 $DBHost = ForceIncomingString('DBHost', $DBHost);
214 $DBName = ForceIncomingString('DBName', $DBName);
215 $DBUser = ForceIncomingString('DBUser', $DBUser);
216 $DBPass = ForceIncomingString('DBPass', $DBPass);
217 $SupportEmail = ForceIncomingString('SupportEmail', $SupportEmail);
218 $SupportName = ForceIncomingString('SupportName', $SupportName);
219 $ApplicationTitle = ForceIncomingString('ApplicationTitle', $ApplicationTitle);
220 $CookieDomain = ForceIncomingString('CookieDomain', '');
221 $CookieDomain = FormatCookieDomain($CookieDomain);
222 $CookiePath = ForceIncomingString('CookiePath', '');
224 function CreateFile($File, $Contents, &$Context) {
225 if (!file_exists($File)) {
226 $Handle = @fopen($File, 'wb');
227 if (!$Handle) {
228 $Error = $php_errormsg;
229 if ($Error != '') $Error = 'The system reported the following message:<code>'.$Error.'</code>';
230 $Context->WarningCollector->Add("Failed to create the '".$File."' configuration file. ".$Error);
231 } else {
232 if (fwrite($Handle, $Contents) === FALSE) {
233 $Context->WarningCollector->Add("Failed to write to the '".$File."' file. Make sure that PHP has write access to the file.");
235 fclose($Handle);
240 // Step 1. Check for correct PHP, MySQL, and permissions
241 if ($PostBackAction == "Permissions") {
243 // Make sure we are running at least PHP 4.1.0
244 if (intval(str_replace('.', '', phpversion())) < 410) $Context->WarningCollector->Add("It appears as though you are running PHP version ".phpversion().". Vanilla requires at least version 4.1.0 of PHP. You will need to upgrade your version of PHP before you can continue.");
245 // Make sure MySQL is available
246 if (!function_exists('mysql_connect')) $Context->WarningCollector->Add("It appears as though you do not have MySQL enabled for PHP. You will need a working copy of MySQL and PHP's MySQL extensions enabled in order to run Vanilla.");
247 // Make sure the conf folder is readable
248 if (!is_readable('../conf/')) $Context->WarningCollector->Add("Vanilla needs to have read permission enabled on the conf folder.");
249 // Make sure the conf folder is writeable
250 if (!is_writable('../conf/')) $Context->WarningCollector->Add("Vanilla needs to have write permission enabled on the conf folder.");
252 // Make sure other folders are readable
253 if (!is_readable('../extensions/')) $Context->WarningCollector->Add("Vanilla needs to have read permission enabled on the extensions folder.");
254 if (!is_readable('../languages/')) $Context->WarningCollector->Add("Vanilla needs to have read permission enabled on the languages folder.");
255 if (!is_readable('../themes/')) $Context->WarningCollector->Add("Vanilla needs to have read permission enabled on the themes folder.");
256 if (!is_readable('../setup/')) $Context->WarningCollector->Add("Vanilla needs to have read permission enabled on the setup folder.");
258 // Make sure the files don't exist already (ie. the site is already up and running);
259 if (file_exists('../conf/settings.php')) $Context->WarningCollector->Add("Vanilla seems to have been upgraded already. You will need to remove the conf/settings.php and conf/database.php files to run the upgrade utility again.");
261 if ($Context->WarningCollector->Count() == 0) {
262 $Contents = '<?php
263 // Database Configuration Settings
264 ?>';
265 CreateFile($RootDirectory.'conf/database.php', $Contents, $Context);
266 $Contents = "<?php
267 // Make sure this file was not accessed directly and prevent register_globals configuration array attack
268 if (!defined('IN_VANILLA')) exit();
269 // Enabled Extensions
270 ?>";
271 CreateFile($RootDirectory.'conf/extensions.php', $Contents, $Context);
272 $Contents = "<?php
273 // Custom Language Definitions
274 ?>";
275 CreateFile($RootDirectory.'conf/language.php', $Contents, $Context);
276 $Contents = '<?php
277 // Application Settings
278 ?>';
279 CreateFile($RootDirectory.'conf/settings.php', $Contents, $Context);
282 // Save a test configuration option to the conf/settings.php file (This is inconsequential and is only done to make sure we have read access).
283 if ($Context->WarningCollector->Count() == 0) {
284 $SettingsFile = $RootDirectory . 'conf/settings.php';
285 $SettingsManager = new ConfigurationManager($Context);
286 $SettingsManager->DefineSetting('SETUP_TEST', '1', 1);
287 if (!$SettingsManager->SaveSettingsToFile($SettingsFile)) {
288 $Context->WarningCollector->Clear();
289 $Context->WarningCollector->Add("For some reason we couldn't save your general settings to the '".$SettingsFile."' file.");
293 if ($Context->WarningCollector->Count() == 0) {
294 // Redirect to the next step (this is done so that refreshes don't cause steps to be redone)
295 Redirect($WebRoot.'setup/upgrader.php?Step=2&PostBackAction=None');
297 } elseif ($PostBackAction == "Database") {
298 $CurrentStep = 2;
299 // Test the database params provided by the user
300 $Connection = @mysql_connect($DBHost, $DBUser, $DBPass);
301 if (!$Connection) {
302 $Response = '';
303 if ($php_errormsg != '') $Response = ' The database responded with the following message: '.$php_errormsg;
304 $Context->WarningCollector->Add("We couldn't connect to the server you provided (".$DBHost.").".$Response);
305 } elseif (!mysql_select_db($DBName, $Connection)) {
306 $Context->WarningCollector->Add("We connected to the server, but we couldn't access the \"".$DBName."\" database. Are you sure it exists and that the specified user has access to it?");
309 // If the database connection worked...
310 if ($Context->WarningCollector->Count() == 0 && $Connection) {
312 // Make sure all of the required tables are there for upgrading
313 $TableData = @mysql_query('show tables', $Connection);
314 if (!$TableData) {
315 $Context->WarningCollector->Add("We had some problems identifying the tables already in your database: ". mysql_error($Connection));
316 } else {
317 $TableMatches = array();
318 $TableToCompare = '';
319 $MissingTables = '';
320 while ($Row = mysql_fetch_array($TableData)) {
321 $TableToCompare = $Row[0];
322 $TableToCompare = str_replace('lum_', '', strtolower($TableToCompare));
323 // Make sure that the required tables exist
324 while (list($TableKey, $TableName) = each($DatabaseTables)) {
325 if (strtolower($TableKey) == $TableToCompare) {
326 // Make sure to update the DatabaseTables array with the actual table names (case-corrected for buggy windows machines)
327 $DatabaseTables[$TableKey] = $Row[0];
328 $TableMatches[$TableToCompare] = $Row[0];
331 reset($DatabaseTables);
333 if (count($TableMatches) != count($DatabaseTables)) {
334 $MissingTables = '';
335 while (list($TableKey, $TableName) = each($DatabaseTables)) {
336 $Found = 0;
337 while (list ($MatchKey, $MatchName) = each ($TableMatches)) {
338 if (strtolower($TableName) != $MatchKey) $Found = 1;
340 if (!$Found) {
341 if ($MissingTables != '') $MissingTables .= ', ';
342 $MissingTables .= $TableName;
345 $Context->WarningCollector->Add("It appears as though your Vanilla installation is missing some tables: <code>".$MissingTables."</code>");
346 } else {
347 // 1. Upgrade Role Table (The hard part first)
349 // Check for current columns in the table
350 $RoleData = @mysql_query('show columns from '.$DatabaseTables['Role'], $Connection);
351 $RoleColumns = GetColumns($Connection, $DatabaseTables['Role']);
353 // 1a. Rename columns
354 if ($Context->WarningCollector->Count() == 0) {
355 if (in_array('CanLogin', $RoleColumns) && !in_array('PERMISSION_SIGN_IN', $RoleColumns)) {
356 $AlterSQL = "alter table ".$DatabaseTables['Role']." change CanLogin PERMISSION_SIGN_IN enum('1','0') not null default '0'";
357 if (!@mysql_query($AlterSQL, $Connection)) $Context->WarningCollector->Add("An error occurred renaming LUM_Role.CanLogin to LUM_Role.PERMISSION_SIGN_IN. MySQL reported the following error: <code>".mysql_error($Connection).'</code>');
361 if ($Context->WarningCollector->Count() == 0) {
362 if (in_array('CanPostHTML', $RoleColumns) && !in_array('PERMISSION_HTML_ALLOWED', $RoleColumns)) {
363 $AlterSQL = "alter table ".$DatabaseTables['Role']." change CanPostHTML PERMISSION_HTML_ALLOWED enum('1','0') not null default '0'";
364 if (!@mysql_query($AlterSQL, $Connection)) $Context->WarningCollector->Add("An error occurred renaming LUM_Role.CanPostHTML to LUM_Role.PERMISSION_HTML_ALLOWED. MySQL reported the following error: <code>".mysql_error($Connection).'</code>');
368 // 1b. Add new columns
369 if ($Context->WarningCollector->Count() == 0) {
370 if (!in_array('PERMISSION_RECEIVE_APPLICATION_NOTIFICATION', $RoleColumns)) {
371 $AlterSQL = "alter table ".$DatabaseTables['Role']." add PERMISSION_RECEIVE_APPLICATION_NOTIFICATION enum('1','0') not null default '0'";
372 if (!@mysql_query($AlterSQL, $Connection)) $Context->WarningCollector->Add("An error occurred while adding LUM_Role.PERMISSION_RECEIVE_APPLICATION_NOTIFICATION. MySQL reported the following error: <code>".mysql_error($Connection).'</code>');
376 if ($Context->WarningCollector->Count() == 0) {
377 if (!in_array('Permissions', $RoleColumns)) {
378 $AlterSQL = "alter table ".$DatabaseTables['Role']." add Permissions text";
379 if (!@mysql_query($AlterSQL, $Connection)) $Context->WarningCollector->Add("An error occurred while adding LUM_Role.Permissions. MySQL reported the following error: <code>".mysql_error($Connection).'</code>');
382 if ($Context->WarningCollector->Count() == 0) {
383 if (!in_array('Priority', $RoleColumns)) {
384 $AlterSQL = "alter table ".$DatabaseTables['Role']." add Priority int not null default '0'";
385 if (!@mysql_query($AlterSQL, $Connection)) $Context->WarningCollector->Add("An error occurred while adding LUM_Role.Priority. MySQL reported the following error: <code>".mysql_error($Connection).'</code>');
388 if ($Context->WarningCollector->Count() == 0) {
389 if (!in_array('UnAuthenticated', $RoleColumns)) {
390 $AlterSQL = "alter table ".$DatabaseTables['Role']." add UnAuthenticated enum('1','0') not null default '0'";
391 if (!@mysql_query($AlterSQL, $Connection)) $Context->WarningCollector->Add("An error occurred while adding LUM_Role.UnAuthenticated. MySQL reported the following error: <code>".mysql_error($Connection).'</code>');
395 // 1c. Retrieve current permissions, serialize, and resave as long as the MasterAdmin column was present
396 if (in_array('MasterAdmin', $RoleColumns)) {
397 // Get an updated version of the columns in the database (Because some were changed above)
398 $RoleColumns = GetColumns($Connection, $DatabaseTables['Role']);
399 $SelectSQL = "select ".implode(',', $RoleColumns)." from ".$DatabaseTables['Role'];
400 $RoleData = @mysql_query($SelectSQL, $Connection);
401 if (!$RoleData) {
402 $Context->WarningCollector->Add("An error occurred while retrieving existing role data. MySQL reported the following error: <code>".mysql_error($Connection)."</code>");
403 } else {
404 $Permissions = array();
405 while ($Row = mysql_fetch_array($RoleData)) {
406 $RoleID = ForceInt($Row['RoleID'], 0);
407 $Permissions['PERMISSION_ADD_COMMENTS'] = ForceBool(@$Row['CanPostComment'], 0);
408 $Permissions['PERMISSION_START_DISCUSSION'] = ForceBool(@$Row['CanPostDiscussion'], 0);
409 // Discussion Moderator Permissions
410 $Permissions['PERMISSION_SINK_DISCUSSIONS'] = ForceBool(@$Row['AdminCategories'], 0);
411 $Permissions['PERMISSION_STICK_DISCUSSIONS'] = ForceBool(@$Row['AdminCategories'], 0);
412 $Permissions['PERMISSION_HIDE_DISCUSSIONS'] = ForceBool(@$Row['AdminCategories'], 0);
413 $Permissions['PERMISSION_CLOSE_DISCUSSIONS'] = ForceBool(@$Row['AdminCategories'], 0);
414 $Permissions['PERMISSION_EDIT_DISCUSSIONS'] = ForceBool(@$Row['AdminCategories'], 0);
415 $Permissions['PERMISSION_VIEW_HIDDEN_DISCUSSIONS'] = ForceBool(@$Row['ShowAllWhispers'], 0);
416 $Permissions['PERMISSION_EDIT_COMMENTS'] = ForceBool(@$Row['AdminCategories'], 0);
417 $Permissions['PERMISSION_HIDE_COMMENTS'] = ForceBool(@$Row['AdminCategories'], 0);
418 $Permissions['PERMISSION_VIEW_HIDDEN_COMMENTS'] = ForceBool(@$Row['ShowAllWhispers'], 0);
419 $Permissions['PERMISSION_ADD_COMMENTS_TO_CLOSED_DISCUSSION'] = ForceBool(@$Row['AdminCategories'], 0);
420 $Permissions['PERMISSION_ADD_CATEGORIES'] = ForceBool(@$Row['AdminCategories'], 0);
421 $Permissions['PERMISSION_EDIT_CATEGORIES'] = ForceBool(@$Row['AdminCategories'], 0);
422 $Permissions['PERMISSION_REMOVE_CATEGORIES'] = ForceBool(@$Row['AdminCategories'], 0);
423 $Permissions['PERMISSION_SORT_CATEGORIES'] = ForceBool(@$Row['AdminCategories'], 0);
424 $Permissions['PERMISSION_VIEW_ALL_WHISPERS'] = ForceBool(@$Row['AdminCategories'], 0);
425 // User Moderator Permissions
426 $Permissions['PERMISSION_APPROVE_APPLICANTS'] = ForceBool(@$Row['AdminUsers'], 0);
427 $Permissions['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION'] = ForceBool(@$Row['AdminUsers'], 0);
428 $Permissions['PERMISSION_CHANGE_USER_ROLE'] = ForceBool(@$Row['AdminUsers'], 0);
429 $Permissions['PERMISSION_EDIT_USERS'] = ForceBool(@$Row['AdminUsers'], 0);
430 $Permissions['PERMISSION_IP_ADDRESSES_VISIBLE'] = ForceBool(@$Row['CanViewIps'], 0);
431 $Permissions['PERMISSION_MANAGE_REGISTRATION'] = ForceBool(@$Row['AdminUsers'], 0);
432 $Permissions['PERMISSION_SORT_ROLES'] = ForceBool(@$Row['AdminUsers'], 0);
433 $Permissions['PERMISSION_ADD_ROLES'] = ForceBool(@$Row['AdminUsers'], 0);
434 $Permissions['PERMISSION_EDIT_ROLES'] = ForceBool(@$Row['AdminUsers'], 0);
435 $Permissions['PERMISSION_REMOVE_ROLES'] = ForceBool(@$Row['AdminUsers'], 0);
436 // Administrative Permissions
437 $Permissions['PERMISSION_CHECK_FOR_UPDATES'] = ForceBool(@$Row['MasterAdmin'], 0);
438 $Permissions['PERMISSION_CHANGE_APPLICATION_SETTINGS'] = ForceBool(@$Row['MasterAdmin'], 0);
439 $Permissions['PERMISSION_MANAGE_EXTENSIONS'] = ForceBool(@$Row['MasterAdmin'], 0);
440 $Permissions['PERMISSION_MANAGE_LANGUAGE'] = ForceBool(@$Row['MasterAdmin'], 0);
441 $Permissions['PERMISSION_MANAGE_THEMES'] = ForceBool(@$Row['MasterAdmin'], 0);
442 $Permissions['PERMISSION_MANAGE_STYLES'] = ForceBool(@$Row['MasterAdmin'], 0);
443 $Permissions['PERMISSION_ALLOW_DEBUG_INFO'] = ForceBool(@$Row['MasterAdmin'], 0);
446 $UpdateSQL = "update ".$DatabaseTables['Role']." set Permissions = '".SerializeArray($Permissions)."' where RoleID = ".$RoleID;
447 if (!@mysql_query($UpdateSQL, $Connection)) {
448 $Context->WarningCollector->Add("An error occurred while updating LUM_Role data. MySQL reported the following error: <code>".mysql_error($Connection).'</code>');
449 break;
451 // Clear out the permissions array
452 $Permissions = array();
457 // 1d. Remove old permission columns
458 if ($Context->WarningCollector->Count() == 0) {
459 // Silently drop these columns. If any errors occur, it doesn't
460 // really slow anything down to leave them behind. It's just clutter.
461 if (in_array('CanPostDiscussion', $RoleColumns)) {
462 $AlterSQL = "alter table ".$DatabaseTables['Role']." drop column CanPostDiscussion";
463 @mysql_query($AlterSQL, $Connection);
465 if (in_array('CanPostComment', $RoleColumns)) {
466 $AlterSQL = "alter table ".$DatabaseTables['Role']." drop column CanPostComment";
467 @mysql_query($AlterSQL, $Connection);
469 if (in_array('AdminUsers', $RoleColumns)) {
470 $AlterSQL = "alter table ".$DatabaseTables['Role']." drop column AdminUsers";
471 @mysql_query($AlterSQL, $Connection);
473 if (in_array('AdminCategories', $RoleColumns)) {
474 $AlterSQL = "alter table ".$DatabaseTables['Role']." drop column AdminCategories";
475 @mysql_query($AlterSQL, $Connection);
477 if (in_array('ShowAllWhispers', $RoleColumns)) {
478 $AlterSQL = "alter table ".$DatabaseTables['Role']." drop column ShowAllWhispers";
479 @mysql_query($AlterSQL, $Connection);
481 if (in_array('MasterAdmin', $RoleColumns)) {
482 $AlterSQL = "alter table ".$DatabaseTables['Role']." drop column MasterAdmin";
483 @mysql_query($AlterSQL, $Connection);
485 if (in_array('CanViewIps', $RoleColumns)) {
486 $AlterSQL = "alter table ".$DatabaseTables['Role']." drop column CanViewIps";
487 @mysql_query($AlterSQL, $Connection);
491 // 1e. Make sure that there is an unauthenticated role.
492 if ($Context->WarningCollector->Count() == 0) {
493 $SelectSQL = "select RoleID from ".$DatabaseTables['Role']." where UnAuthenticated = '1'";
494 $RoleData = @mysql_query($SelectSQL, $Connection);
495 if (!$RoleData) {
496 $Context->WarningCollector->Add("An error occurred while querying for an unauthenticated role. MySQL returned the following error message: <code>".mysql_error($Context)."</code>");
497 } else {
498 if (mysql_num_rows($RoleData) == 0) {
499 // Insert a new unauthenticated role
500 $InsertSQL = "insert into ".$DatabaseTables['Role']."
501 (`Name`, `Active`, `PERMISSION_SIGN_IN`, `PERMISSION_HTML_ALLOWED`, `PERMISSION_RECEIVE_APPLICATION_NOTIFICATION`, `Permissions`, `Priority`, `UnAuthenticated`)
502 VALUES ('Unauthenticated','1','1','1','1','a:32:{s:23:\"PERMISSION_ADD_COMMENTS\";N;s:27:\"PERMISSION_START_DISCUSSION\";N;s:28:\"PERMISSION_STICK_DISCUSSIONS\";N;s:27:\"PERMISSION_HIDE_DISCUSSIONS\";N;s:28:\"PERMISSION_CLOSE_DISCUSSIONS\";N;s:27:\"PERMISSION_EDIT_DISCUSSIONS\";N;s:34:\"PERMISSION_VIEW_HIDDEN_DISCUSSIONS\";N;s:24:\"PERMISSION_EDIT_COMMENTS\";N;s:24:\"PERMISSION_HIDE_COMMENTS\";N;s:31:\"PERMISSION_VIEW_HIDDEN_COMMENTS\";N;s:44:\"PERMISSION_ADD_COMMENTS_TO_CLOSED_DISCUSSION\";N;s:25:\"PERMISSION_ADD_CATEGORIES\";N;s:26:\"PERMISSION_EDIT_CATEGORIES\";N;s:28:\"PERMISSION_REMOVE_CATEGORIES\";N;s:26:\"PERMISSION_SORT_CATEGORIES\";N;s:28:\"PERMISSION_VIEW_ALL_WHISPERS\";N;s:29:\"PERMISSION_APPROVE_APPLICANTS\";N;s:27:\"PERMISSION_CHANGE_USER_ROLE\";N;s:21:\"PERMISSION_EDIT_USERS\";N;s:31:\"PERMISSION_IP_ADDRESSES_VISIBLE\";N;s:30:\"PERMISSION_MANAGE_REGISTRATION\";N;s:21:\"PERMISSION_SORT_ROLES\";N;s:20:\"PERMISSION_ADD_ROLES\";N;s:21:\"PERMISSION_EDIT_ROLES\";N;s:23:\"PERMISSION_REMOVE_ROLES\";N;s:28:\"PERMISSION_CHECK_FOR_UPDATES\";N;s:38:\"PERMISSION_CHANGE_APPLICATION_SETTINGS\";N;s:28:\"PERMISSION_MANAGE_EXTENSIONS\";N;s:26:\"PERMISSION_MANAGE_LANGUAGE\";N;s:24:\"PERMISSION_MANAGE_STYLES\";N;s:27:\"PERMISSION_ALLOW_DEBUG_INFO\";N;s:27:\"PERMISSION_DATABASE_CLEANUP\";N;}',0,'1')";
503 if (!@mysql_query($InsertSQL, $Connection)) {
504 $Context->WarningCollector->Add("An error occurred while inserting a new unauthenticated role. MySQL returned the following error message: <code>".mysql_error($Context)."</code>");
510 if ($Context->WarningCollector->Count() == 0) {
511 // Retrieve Category Columns
512 $CategoryColumns = GetColumns($Connection, $DatabaseTables['Category']);
513 $DiscussionColumns = GetColumns($Connection, $DatabaseTables['Discussion']);
514 $UserColumns = GetColumns($Connection, $DatabaseTables['User']);
516 // Make remaining table alterations
517 if (in_array('Order', $CategoryColumns) && !in_array('Priority', $CategoryColumns)) {
518 $AlterSQL = "alter table ".$DatabaseTables['Category']." change `Order` Priority int not null default '0'";
519 if (!@mysql_query($AlterSQL, $Connection)) $Context->WarningCollector->Add("An error occurred renaming LUM_Category.Order to LUM_Category.Priority. MySQL reported the following error: <code>".mysql_error($Connection).'</code>');
522 if ($Context->WarningCollector->Count() == 0) {
523 if (in_array('Settings', $UserColumns) && !in_array('Preferences', $UserColumns)) {
524 $AlterSQL = "alter table ".$DatabaseTables['User']." change Settings Preferences text";
525 if (!@mysql_query($AlterSQL, $Connection)) $Context->WarningCollector->Add("An error occurred renaming LUM_User.Settings to LUM_User.Preferences. MySQL reported the following error: <code>".mysql_error($Connection).'</code>');
528 if ($Context->WarningCollector->Count() == 0) {
529 if (!in_array('Sink', $DiscussionColumns)) {
530 $AlterSQL = "alter table ".$DatabaseTables['Discussion']." add Sink enum('1','0') not null default '0'";
531 if (!@mysql_query($AlterSQL, $Connection)) $Context->WarningCollector->Add("An error occurred adding LUM_Discussion.Sink. MySQL reported the following error: <code>".mysql_error($Connection).'</code>');
534 if (in_array('ToolsOn', $UserColumns)) {
535 $AlterSQL = "alter table ".$DatabaseTables['User']." drop column ToolsOn";
536 @mysql_query($AlterSQL, $Connection);
538 if (in_array('UseQuickKeys', $UserColumns)) {
539 $AlterSQL = "alter table ".$DatabaseTables['User']." drop column UseQuickKeys";
540 @mysql_query($AlterSQL, $Connection);
545 // Close the database connection
546 @mysql_close($Connection);
549 // If the database was upgraded successfully, save all parameters to the conf/database.php file
550 if ($Context->WarningCollector->Count() == 0) {
551 // Save database settings
552 $DBFile = $RootDirectory . 'conf/database.php';
553 $DBManager = new ConfigurationManager($Context);
554 $DBManager->GetSettingsFromFile($DBFile);
555 // Only make these changes if the settings haven't been defined already
556 if ($DBManager->GetSetting('DATABASE_HOST') == '') {
557 $DBManager->DefineSetting("DATABASE_HOST", $DBHost, 1);
558 $DBManager->DefineSetting("DATABASE_NAME", $DBName, 1);
559 $DBManager->DefineSetting("DATABASE_USER", $DBUser, 1);
560 $DBManager->DefineSetting("DATABASE_PASSWORD", $DBPass, 1);
561 $DBManager->SaveSettingsToFile($DBFile);
563 // Save the general settings as well (now that we know this person is authenticated to
564 // a degree - knowing the database access params).
565 $SettingsFile = $RootDirectory . 'conf/settings.php';
566 $SettingsManager = new ConfigurationManager($Context);
567 $SettingsManager->DefineSetting('APPLICATION_PATH', $RootDirectory, 1);
568 $SettingsManager->DefineSetting('DATABASE_PATH', $RootDirectory . 'conf/database.php', 1);
569 $SettingsManager->DefineSetting('LIBRARY_PATH', $RootDirectory . 'library/', 1);
570 $SettingsManager->DefineSetting('EXTENSIONS_PATH', $RootDirectory . 'extensions/', 1);
571 $SettingsManager->DefineSetting('LANGUAGES_PATH', $RootDirectory . 'languages/', 1);
572 $SettingsManager->DefineSetting('THEME_PATH', $RootDirectory . 'themes/vanilla/', 1);
573 $SettingsManager->DefineSetting("DEFAULT_STYLE", $ThemeDirectory.'vanilla/styles/default/', 1);
574 $SettingsManager->DefineSetting("WEB_ROOT", $WebRoot, 1);
575 $SettingsManager->DefineSetting("BASE_URL", $BaseUrl, 1);
576 $SettingsManager->DefineSetting("FORWARD_VALIDATED_USER_URL", $BaseUrl, 1);
577 $SettingsManager->SaveSettingsToFile($SettingsFile);
578 } else {
579 $Context->WarningCollector->Add("Vanilla seems to have been upgraded already. You will need to remove the conf/settings.php and conf/database.php files to run the upgrade utility again.");
582 if ($Context->WarningCollector->Count() == 0) {
583 // Redirect to the next step (this is done so that refreshes don't cause steps to be redone)
584 Redirect($WebRoot.'setup/upgrader.php?Step=3&PostBackAction=None');
586 } elseif ($PostBackAction == "User") {
587 $CurrentStep = 3;
588 // Validate user inputs
589 if (strip_tags($ApplicationTitle) != $ApplicationTitle) $Context->WarningCollector->Add("You can't have any html in your forum name.");
590 if ($SupportName == "") $Context->WarningCollector->Add("You must provide a support contact name.");
591 if (!eregi('(.+)@(.+)\.(.+)', $SupportEmail)) $Context->WarningCollector->Add("The email address you entered doesn't appear to be valid.");
592 if ($ApplicationTitle == "") $Context->WarningCollector->Add("You must provide an application title.");
594 $SettingsFile = $RootDirectory . 'conf/settings.php';
595 $SettingsManager = new ConfigurationManager($Context);
596 $SettingsManager->GetSettingsFromFile($SettingsFile);
597 if ($SettingsManager->GetSetting('SETUP_COMPLETE') != '1') {
598 // Include the db settings defined in the previous step
599 include($RootDirectory.'conf/database.php');
601 // Open the database connection
602 $Connection = false;
603 if ($Context->WarningCollector->Count() == 0) {
604 $DBHost = $Configuration['DATABASE_HOST'];
605 $DBName = $Configuration['DATABASE_NAME'];
606 $DBUser = $Configuration['DATABASE_USER'];
607 $DBPass = $Configuration['DATABASE_PASSWORD'];
608 $Connection = @mysql_connect($DBHost, $DBUser, $DBPass);
609 if (!$Connection) {
610 $Context->WarningCollector->Add("We couldn't connect to the server you provided (".$DBHost."). Are you sure you entered the right server, username and password?");
611 } elseif (!mysql_select_db($DBName, $Connection)) {
612 $Context->WarningCollector->Add("We connected to the server, but we couldn't access the \"".$DBName."\" database. Are you sure it exists and that the specified user has access to it?");
616 // Insert the new Style and assign to all users
617 if ($Context->WarningCollector->Count() == 0 && $Connection) {
618 // Truncate all old styles (They can't work with the new Vanilla)
619 $LowerCaseTableNames = 0;
620 if (!@mysql_query('truncate table LUM_Style', $Connection)) {
621 // Try doing it with a lowercase table name before erroring out
622 if (!@mysql_query('truncate table lum_style', $Connection)) {
623 $Context->WarningCollector->Add('Failed to clean out LUM_Style table. MySQL reported the following error: <code>'.mysql_error($Connection).'</code>');
624 } else {
625 $LowerCaseTableNames = 1;
628 if ($Context->WarningCollector->Count() == 0) {
629 // Insert the new style
630 if (!@mysql_query("insert into ".($LowerCaseTableNames ? "lum_style" : "LUM_Style")." (Name, Url) values ('Vanilla', '".$ThemeDirectory."vanilla/styles/default/')", $Connection)) {
631 $Context->WarningCollector->Add("Failed to insert new default Vanilla style into LUM_Style table. MySQL reported the following error: <code>".mysql_error($Connection)."</code>");
632 } else {
633 // Assign the new style to everyone
634 if (!@mysql_query("update ".($LowerCaseTableNames ? "lum_user" : "LUM_User")." set StyleID = 1", $Connection)) {
635 $Context->WarningCollector->Add("Failed to assign new style to all users. MySQL reported the following error: <code>".mysql_error($Connection)."</code>");
641 // Close the database connection
642 @mysql_close($Connection);
644 // Save the application constants
645 if ($Context->WarningCollector->Count() == 0) {
646 $SettingsManager->DefineSetting("SUPPORT_EMAIL", $SupportEmail, 1);
647 $SettingsManager->DefineSetting("SUPPORT_NAME", $SupportName, 1);
648 $SettingsManager->DefineSetting("APPLICATION_TITLE", $ApplicationTitle, 1);
649 $SettingsManager->DefineSetting("COOKIE_DOMAIN", $CookieDomain, 1);
650 $SettingsManager->DefineSetting("COOKIE_PATH", $CookiePath, 1);
651 if (array_key_exists('BANNER_TITLE', $NewConfiguration)) {
652 $SettingsManager->DefineSetting("BANNER_TITLE", $NewConfiguration['BANNER_TITLE'], 1);
653 } else {
654 $SettingsManager->DefineSetting("BANNER_TITLE", $ApplicationTitle, 1);
657 // Apply old settings if they were provided
658 ApplySetting($SettingsManager, $NewConfiguration, 'DISCUSSIONS_PER_PAGE');
659 ApplySetting($SettingsManager, $NewConfiguration, 'COMMENTS_PER_PAGE');
660 ApplySetting($SettingsManager, $NewConfiguration, 'SEARCH_RESULTS_PER_PAGE');
661 ApplySetting($SettingsManager, $NewConfiguration, 'ALLOW_NAME_CHANGE');
662 ApplySetting($SettingsManager, $NewConfiguration, 'PUBLIC_BROWSING');
663 ApplySetting($SettingsManager, $NewConfiguration, 'USE_CATEGORIES');
664 ApplySetting($SettingsManager, $NewConfiguration, 'LOG_ALL_IPS');
665 ApplySetting($SettingsManager, $NewConfiguration, 'PANEL_BOOKMARK_COUNT');
666 ApplySetting($SettingsManager, $NewConfiguration, 'PANEL_PRIVATE_COUNT');
667 ApplySetting($SettingsManager, $NewConfiguration, 'PANEL_HISTORY_COUNT');
668 ApplySetting($SettingsManager, $NewConfiguration, 'PANEL_USERDISCUSSIONS_COUNT');
669 ApplySetting($SettingsManager, $NewConfiguration, 'PANEL_SEARCH_COUNT');
670 ApplySetting($SettingsManager, $NewConfiguration, 'MAX_COMMENT_LENGTH');
671 ApplySetting($SettingsManager, $NewConfiguration, 'DISCUSSION_POST_THRESHOLD');
672 ApplySetting($SettingsManager, $NewConfiguration, 'DISCUSSION_TIME_THRESHOLD');
673 ApplySetting($SettingsManager, $NewConfiguration, 'DISCUSSION_THRESHOLD_PUNISHMENT');
674 ApplySetting($SettingsManager, $NewConfiguration, 'COMMENT_POST_THRESHOLD');
675 ApplySetting($SettingsManager, $NewConfiguration, 'COMMENT_TIME_THRESHOLD');
676 ApplySetting($SettingsManager, $NewConfiguration, 'COMMENT_THRESHOLD_PUNISHMENT');
677 ApplySetting($SettingsManager, $NewConfiguration, 'DEFAULT_ROLE');
678 ApplySetting($SettingsManager, $NewConfiguration, 'ALLOW_IMMEDIATE_ACCESS');
679 ApplySetting($SettingsManager, $NewConfiguration, 'APPROVAL_ROLE');
680 $SettingsManager->DefineSetting("SETUP_COMPLETE", '1', 1);
681 $SettingsManager->SaveSettingsToFile($SettingsFile);
683 } else {
684 $Context->WarningCollector->Add("Vanilla seems to have been upgraded already. You will need to remove the conf/settings.php and conf/database.php files to run the upgrade utility again.");
687 if ($Context->WarningCollector->Count() == 0) {
688 // Redirect to the next step (this is done so that refreshes don't cause steps to be redone)
689 Redirect($WebRoot.'setup/upgrader.php?Step=4&PostBackAction=None');
693 // Write the page
695 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
696 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-ca">
697 <head>
698 <title><?php echo APPLICATION . ' ' . APPLICATION_VERSION; ?> Upgrader</title>
699 <link rel="stylesheet" type="text/css" href="./style.css" />
700 </head>
701 <body>
702 <h1>
703 <span><strong><?php echo APPLICATION . ' ' . APPLICATION_VERSION; ?></strong> Upgrader</span>
704 </h1>
705 <div class="Container">
706 <div class="Content">
707 <?php
708 if ($CurrentStep < 2 || $CurrentStep > 4) {
709 echo '<h2>Vanilla Upgrade Wizard (Step 1 of 3)</h2>
711 <p><strong>Only use this upgrader if you are upgrading from Vanilla 0.9.2.x</strong></p>';
713 if ($Context->WarningCollector->Count() > 0) {
714 echo "<div class=\"Warnings\">
715 <strong>We came across some problems while checking your permissions...</strong>
716 ".$Context->WarningCollector->GetMessages()."
717 </div>";
719 echo "<p>Navigate the filesystem of your server to the Vanilla folder. If you have your old appg/settings.php file from your previous installation of Vanilla, rename it <strong>old_settings.php</strong> and upload it to the /conf folder of your new Vanilla installation.</p>
721 <p>Vanilla will need read AND write access to the <strong>conf</strong> folder.</p>
723 <p>There are many ways to set these permissions. One way is to execute the following from the root Vanilla folder:</p>
725 <code>chmod 777 ./conf</code>
727 <p>You will also need to grant read access to the extensions, languages, setup, and themes folders. Typically these permissions are granted by default, but if not you can achieve them with the following commands:</p>
729 <code>chmod --recursive 755 ./extensions
730 <br />chmod --recursive 755 ./languages
731 <br />chmod --recursive 755 ./setup
732 <br />chmod --recursive 755 ./themes</code>
734 <form id=\"frmPermissions\" method=\"post\" action=\"upgrader.php\">
735 <input type=\"hidden\" name=\"PostBackAction\" value=\"Permissions\" />
736 <div class=\"Button\"><input type=\"submit\" value=\"Click here to check your permissions and proceed to the next step\" /></div>
737 </form>";
738 } elseif ($CurrentStep == 2) {
739 echo "<h2>Vanilla Upgrade Wizard (Step 2 of 3)</h2>";
740 if ($Context->WarningCollector->Count() > 0) {
741 echo "<div class=\"Warnings\">
742 <strong>We came across some problems while upgrading Vanilla...</strong>
743 ".$Context->WarningCollector->GetMessages()."
744 </div>";
746 echo "<p>Below you can provide the connection parameters for the mysql server where your existing Vanilla database is set up so it can be upgraded. If you haven't done it yet, <strong>back up your existing Vanilla database before continuing</strong>.</p>
747 <fieldset>
748 <form id=\"frmDatabase\" method=\"post\" action=\"upgrader.php\">
749 <input type=\"hidden\" name=\"PostBackAction\" value=\"Database\" />
750 <ul>
751 <li>
752 <label for=\"tDBHost\">MySQL Server</label>
753 <input type=\"text\" id=\"tDBHost\" name=\"DBHost\" value=\"".FormatStringForDisplay($DBHost, 1)."\" />
754 </li>
755 <li>
756 <label for=\"tDBName\">MySQL Database Name</label>
757 <input type=\"text\" id=\"tDBName\" name=\"DBName\" value=\"".FormatStringForDisplay($DBName, 1)."\" />
758 </li>
759 <li>
760 <label for=\"tDBUser\">MySQL User</label>
761 <input type=\"text\" id=\"tDBUser\" name=\"DBUser\" value=\"".FormatStringForDisplay($DBUser, 1)."\" />
762 </li>
763 <li>
764 <label for=\"tDBPass\">MySQL Password</label>
765 <input type=\"password\" id=\"tDBPass\" name=\"DBPass\" value=\"".FormatStringForDisplay($DBPass, 1)."\" />
766 </li>
767 </ul>
768 <div class=\"Button\"><input type=\"submit\" value=\"Click here to create Vanilla's database and proceed to the next step\" /></div>
769 </form>
770 </fieldset>";
771 } elseif ($CurrentStep == 3) {
772 if ($PostBackAction != "User") {
773 $CookieDomain = ForceString(@$_SERVER['HTTP_HOST'], "");
774 $CookieDomain = FormatCookieDomain($CookieDomain);
775 $CookiePath = $WebRoot;
777 echo "<h2>Vanilla Upgrade Wizard (Step 3 of 3)</h2>";
778 if ($Context->WarningCollector->Count() > 0) {
779 echo "<div class=\"Warnings\">
780 <strong>We came across some problems while setting up Vanilla...</strong>
781 ".$Context->WarningCollector->GetMessages()."
782 </div>";
784 echo "<p>Now we've got to set up the support contact information for your forum. This is what people will see when emails go out from the system for things like password retrieval and role changes.</p>
785 <fieldset>"
786 .'<form name="frmUser" method="post" action="upgrader.php">
787 <input type="hidden" name="PostBackAction" value="User" />
788 <ul>
789 <li>
790 <label for="tSupportName">Support Contact Name</label>
791 <input id="tSupportName" type="text" name="SupportName" value="'.FormatStringForDisplay($SupportName, 1).'" />
792 </li>
793 <li>
794 <label for="tSupportEmail">Support Email Address</label>
795 <input id="tSupportEmail" type="text" name="SupportEmail" value="'.FormatStringForDisplay($SupportEmail, 1).'" />
796 </li>
797 </ul>
798 <p>What do you want to call your forum?</p>
799 <ul>
800 <li>
801 <label for="tApplicationTitle">Forum Name</label>
802 <input id="tApplicationTitle" type="text" name="ApplicationTitle" value="'.FormatStringForDisplay($ApplicationTitle, 1).'" />
803 </li>
804 </ul>'
805 ."<p>The cookie domain is where you want cookies assigned to for Vanilla. Typically the cookie domain will be something like www.yourdomain.com. Cookies can be further defined to a particular path on your website using the \"Cookie Path\" setting. (TIP: If you want your Vanilla cookies to apply to all subdomains of your domain, use \".yourdomain.com\" as the cookie domain).</p>"
806 .'<ul>
807 <li>
808 <label for="tCookieDomain">Cookie Domain</label>
809 <input id="tCookieDomain" type="text" name="CookieDomain" value="'.FormatStringForDisplay($CookieDomain, 1).'" />
810 </li>
811 <li>
812 <label for="tCookiePath">Cookie Path</label>
813 <input id="tCookiePath" type="text" name="CookiePath" value="'.FormatStringForDisplay($CookiePath, 1).'" />
814 </li>
815 </ul>
816 <div class="Button"><input type="submit" value="Click here to complete the setup process!" /></div>
817 </form>
818 </fieldset>';
819 } else {
820 echo "<h2>Vanilla Upgrade Wizard (Complete)</h2>
821 <p><strong>That's it! Vanilla has been upgraded.</strong></p>
822 <p>Things in Vanilla 1 are quite different to what you're used to. The best new feature is, without a doubt, the new extension engine. You should definitely head over to the <a href=\"http://lussumo.com/addons/\" target=\"Lussumo\">Vanilla Add-on directory</a> right away to find all of your favourite old extensions, plus a bunch of new ones.</p>
823 <p>Of course you will also want to go make sure your application was upgraded properly. Here are a few things you should take a look at:</p>
824 <ul>
825 <li>Public &amp; Private browsing on the Registration Management Form</li>
826 <li>On public forums, make sure that the unauthenticated role has access to all public discussion categories</li>
827 </ul>
829 <p>If you find that there was some unforseen problem with the upgrade procedure, visit <a href=\"http://lussumo.com/community/\" target=\"Lussumo\">Lussumo Community Forum</a> for help.</p>
830 <div class=\"Button\"><a href=\"../people.php\">Go sign in and have some fun!</a></div>";
833 </div>
834 </div>
835 </body>
836 </html>