/* Copyright (C) 2003-2005 UseBB Team http://www.usebb.net $Header: /cvsroot/usebb/UseBB/install/upgrade-0-4.php,v 1.24 2005/08/22 17:52:17 pc_freak Exp $ This file is part of UseBB. UseBB is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. UseBB 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with UseBB; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ define('INCLUDED', true); include('../config.php'); class functions { function usebb_die($errno, $error, $file, $line) { global $connerror; // // Don't show various errors on PHP5 // if ( intval(substr(phpversion(), 0, 1)) > 4 ) { $ignore_warnings = array( 'var: Deprecated. Please use the public/private/protected modifiers', 'Trying to get property of non-object', ); if ( in_array($error, $ignore_warnings) ) return; } $connerror = $error; } function get_config($setting) { global $conf; if ( isset($conf[$setting]) ) return $conf[$setting]; else return ''; } } $functions = new functions; function error_handler($errno, $error, $file, $line) { global $functions; $functions->usebb_die($errno, $error, $file, $line); } set_error_handler('error_handler'); if ( !empty($_POST['step']) && intval($_POST['step']) > 1 ) { include('../sources/db_'.$dbs['type'].'.php'); $db = new db; $db->connect($dbs); } function to_step($step) { return ''; } ?> UseBB Upgrade 0.4.x body { font-family: sans-serif; text-align: center; font-size: 10pt; } #logo { margin-bottom: 0px; } h1 { color: #336699; font-size: 18pt; font-weight: bold; margin-top: 0px; } #wrap { width: 600px; margin: 0px auto 0px auto; background-color: #EFEFEF; border: 1px solid silver; padding: 10px; text-align: left; } h2 { color: #336699; font-size: 12pt; font-weight: bold; text-align: center; } form { text-align: center; } address { color: #333333; margin: 10px 0px 0px 0px; } Upgrade 0.4.x if ( empty($_POST['step']) ) { echo 'Welcome'; echo 'Welcome to the UseBB upgrade 0.4.x wizard. This wizard will help you upgrade UseBB 0.4.x to version 0.5.'; echo to_step(1); } elseif ( intval($_POST['step']) === 1 ) { echo 'Step 1'; if ( !function_exists('version_compare') ) { echo 'We\'re sorry. UseBB does not work on the PHP version running on this server (PHP '.phpversion().'). You need at least 4.1.0. Get a recent version from PHP.net.'; } else { echo 'First, upload UseBB 0.5 to the same location as 0.4.x, overwriting the old files. Then edit the database configuration values in config.php. Make sure the database settings match with those for your host. If in doubt, please contact your web host for information regarding accessing databases.'; echo 'Tip: if you already use MySQL 4.1, it might be interesting to set $dbs[\'type\'] to \'mysqli\'. If you don\'t know which version you are running, leave the default value.'; echo 'Another tip: you might want to check this document out to change config.php.'; echo to_step(2); } } elseif ( intval($_POST['step']) === 2 ) { echo 'Step 2'; if ( !empty($connerror) ) { echo 'An error was encountered while trying to access the database. The error was:'; echo ''.$connerror.''; echo 'Please check your database settings in config.php!'; echo to_step(2); } else { echo 'The database settings are OK!'; echo to_step(3); } } elseif ( intval($_POST['step']) === 3 ) { echo 'Step 3'; $result = $db->query("SELECT regdate FROM ".$dbs['prefix']."members ORDER BY regdate ASC LIMIT 1"); $userinfo = $db->fetch_result($result); $queries = array( "ALTER TABLE `".$dbs['prefix']."members` ADD `displayed_name` VARCHAR( 255 ) NOT NULL AFTER `avatar_remote`", "UPDATE ".$dbs['prefix']."members SET displayed_name = name WHERE displayed_name = ''", "CREATE TABLE `".$dbs['prefix']."badwords` ( `word` VARCHAR( 255 ) NOT NULL , `replacement` VARCHAR( 255 ) NOT NULL , PRIMARY KEY ( `word` ) )", "ALTER TABLE `".$dbs['prefix']."members` ADD `auto_subscribe_topic` INT( 1 ) NOT NULL AFTER `hide_signatures`, ADD `auto_subscribe_reply` INT( 1 ) NOT NULL AFTER `auto_subscribe_topic`", "ALTER TABLE `".$dbs['prefix']."forums` ADD `hide_mods_list` INT( 1 ) NOT NULL", "ALTER TABLE `".$dbs['prefix']."members` ADD `birthday` INT( 8 ) NOT NULL AFTER `signature`", "DELETE FROM ".$dbs['prefix']."stats WHERE name = 'forums'", "INSERT INTO ".$dbs['prefix']."stats VALUES ('started', '".$userinfo['regdate']."')", "CREATE TABLE ".$dbs['prefix']."searches ( sess_id varchar(32) NOT NULL default '', time int(10) NOT NULL default '0', results text NOT NULL, PRIMARY KEY (sess_id) )" ); $error = false; foreach ( $queries as $query ) { if ( !($db->query($query)) ) { $error = true; break; } } $db->disconnect(); if ( $error ) { echo 'An error occured while executing the SQL queries.'; echo to_step(3); } else { echo 'The update queries have been executed succesfully!'; echo 'Important note: since UseBB 0.5, some important changes have happened to the member system. From now on, a username can only contain alphanumeric characters (a-zA-Z0-9), "_" and "-". Any other characters will be stripped out of the username (spaces will be transformed to "_"). If no characters are left after stripping, the username will be set to "user". If any duplicate usernames are created during this process, the duplicate username will be followed by a 2, the next one by a 3, and so on.'; echo 'Please inform your users if this change affects the users on your board! You might want to change usernames afterwards via your database management tool. Also note a user can now set a publicly displayed name which can contain any characters, including Cyrillic ones. Each user\'s displayed name has already been set to his original username. A user\'s real username (with which he/she needs to log in and which is not shown publicly on the board) can be found between brackets on his/her profile when looking with an admin account.'; echo to_step(4); } } elseif ( intval($_POST['step']) === 4 ) { echo 'Step 4'; set_magic_quotes_runtime(0); $usernames = array(); $result = $db->query("SELECT id, name FROM ".$dbs['prefix']."members ORDER BY id ASC"); while ( $out = $db->fetch_result($result) ) { $original_name = $out['name']; $out['name'] = preg_replace('#[^A-Za-z0-9_\-]#', '', str_replace(' ', '_', $out['name'])); $out['name'] = ( !empty($out['name']) ) ? $out['name'] : 'user'; if ( in_array($out['name'], $usernames) ) { for ( $i = 2; ; $i++ ) { $testname = $out['name'].$i; if ( !in_array($testname, $usernames) ) { $usernames[] = $out['name'] = $testname; break; } } } else { $usernames[] = $out['name']; } if ( $original_name != $out['name'] ) $db->query("UPDATE ".$dbs['prefix']."members SET name = '".addslashes($out['name'])."' WHERE id = ".$out['id']); } $db->disconnect(); echo 'All SQL queries have been executed. Your board has now been updated to version 0.5. If the latest release is newer, you might need to run other wizards too. See the UPGRADE document. Otherwise, please delete the directory install/ for security reasons. You can now go to your UseBB board and continue using it.'; echo 'Tip: you might want to use this manual to further set up your forum.'; echo 'Thanks for choosing UseBB! We wish you a lot of fun with your board!'; } ?> Copyright © 2003-2005 UseBB Team