1, "revert_all_themes" => 1, "revert_all_settings" => 2 ); @set_time_limit(0); function upgrade5_dbchanges() { global $db, $output, $mybb; $output->print_header("Performing Queries"); echo "
Performing necessary upgrade queries..
"; $db->query("ALTER TABLE ".TABLE_PREFIX."users CHANGE avatartype avatartype varchar(10) NOT NULL;"); if(!$db->field_exists('totalpms', TABLE_PREFIX."users")) { $db->query("ALTER TABLE ".TABLE_PREFIX."users ADD totalpms int(10) NOT NULL default '0' AFTER showcodebuttons;"); } if(!$db->field_exists('newpms', TABLE_PREFIX."users")) { $db->query("ALTER TABLE ".TABLE_PREFIX."users ADD newpms int(10) NOT NULL default '0' AFTER totalpms;"); } if(!$db->field_exists('unreadpms', TABLE_PREFIX."users")) { $db->query("ALTER TABLE ".TABLE_PREFIX."users ADD unreadpms int(10) NOT NULL default '0' AFTER newpms;"); } if(!$db->field_exists('showredirect', TABLE_PREFIX."users")) { $db->query("ALTER TABLE ".TABLE_PREFIX."users ADD showredirect char(3) NOT NULL default '' AFTER showquickreply;"); } if(!$db->field_exists('avatardimensions', TABLE_PREFIX."users")) { $db->query("ALTER TABLE ".TABLE_PREFIX."users ADD avatardimensions varchar(10) NOT NULL default '' AFTER avatar;"); } if(!$db->field_exists('unapprovedposts', TABLE_PREFIX."threads")) { $db->query("ALTER TABLE ".TABLE_PREFIX."threads ADD unapprovedposts INT(10) unsigned NOT NULL default '0' AFTER visible;"); } if(!$db->field_exists('unapprovedthreads', TABLE_PREFIX."forums")) { $db->query("ALTER TABLE ".TABLE_PREFIX."forums ADD unapprovedthreads INT(10) unsigned NOT NULL default '0' AFTER rules;"); } if(!$db->field_exists('unapprovedposts', TABLE_PREFIX."forums")) { $db->query("ALTER TABLE ".TABLE_PREFIX."forums ADD unapprovedposts INT(10) unsigned NOT NULL default '0' AFTER rules;"); } if(!$db->field_exists('defaultdatecut', TABLE_PREFIX."forums")) { $db->query("ALTER TABLE ".TABLE_PREFIX."forums ADD defaultdatecut smallint(4) unsigned NOT NULL default '0' AFTER unapprovedposts;"); } if(!$db->field_exists('defaultsortby', TABLE_PREFIX."forums")) { $db->query("ALTER TABLE ".TABLE_PREFIX."forums ADD defaultsortby varchar(10) NOT NULL default '' AFTER defaultdatecut;"); } if(!$db->field_exists('defaultsortorder', TABLE_PREFIX."forums")) { $db->query("ALTER TABLE ".TABLE_PREFIX."forums ADD defaultsortorder varchar(4) NOT NULL default '' AFTER defaultsortby;"); } if(!$db->field_exists('lastposteruid', TABLE_PREFIX."forums")) { $db->query("ALTER TABLE ".TABLE_PREFIX."forums ADD lastposteruid int(10) unsigned NOT NULL default '0' AFTER lastposter;"); } if(!$db->field_exists('lastpostsubject', TABLE_PREFIX."forums")) { $db->query("ALTER TABLE ".TABLE_PREFIX."forums ADD lastpostsubject varchar(120) NOT NULL default '' AFTER lastposttid"); } if(!$db->field_exists('lastposteruid', TABLE_PREFIX."threads")) { $db->query("ALTER TABLE ".TABLE_PREFIX."threads ADD lastposteruid int unsigned NOT NULL default '0' AFTER lastposter"); } if(!$db->field_exists('canmanagemembers', TABLE_PREFIX."groupleaders")) { $db->query("ALTER TABLE ".TABLE_PREFIX."groupleaders ADD canmanagemembers char(3) NOT NULL default '' AFTER uid;"); } if(!$db->field_exists('canmanagerequests', TABLE_PREFIX."groupleaders")) { $db->query("ALTER TABLE ".TABLE_PREFIX."groupleaders ADD canmanagerequests char(3) NOT NULL default '' AFTER canmanagemembers;"); } if(!$db->field_exists('caneditlangs', TABLE_PREFIX."adminoptions")) { $db->query("ALTER TABLE ".TABLE_PREFIX."adminoptions ADD caneditlangs char(3) NOT NULL default '' AFTER canedithelp;"); } if(!$db->field_exists('canrundbtools', TABLE_PREFIX."adminoptions")) { $db->query("ALTER TABLE ".TABLE_PREFIX."adminoptions ADD canrundbtools char(3) NOT NULL default ''"); } if(!$db->field_exists('allowedgroups', TABLE_PREFIX."themes")) { $db->query("ALTER TABLE ".TABLE_PREFIX."themes ADD allowedgroups text NOT NULL default '' AFTER extracss;"); } if(!$db->field_exists('canmovetononmodforum', TABLE_PREFIX."moderators")) { $db->query("ALTER TABLE ".TABLE_PREFIX."moderators ADD canmovetononmodforum char(3) NOT NULL default '' AFTER canmanagethreads;"); } if(!$db->field_exists('csscached', TABLE_PREFIX."themes")) { $db->query("ALTER TABLE ".TABLE_PREFIX."themes ADD csscached bigint(30) NOT NULL default '0'"); } $db->query("UPDATE ".TABLE_PREFIX."adminoptions SET caneditlangs='yes' WHERE canrunmaint='yes'"); $db->query("UPDATE ".TABLE_PREFIX."adminoptions SET caneditlangs='no' WHERE canrunmaint='no'"); $db->query("UPDATE ".TABLE_PREFIX."adminoptions SET canrundbtools='yes' WHERE canrunmaint='yes'"); $db->query("UPDATE ".TABLE_PREFIX."adminoptions SET canrundbtools='no' WHERE canrunmaint='no'"); $db->query("UPDATE ".TABLE_PREFIX."settings SET optionscode='select\r\ninstant=Instant Activation\r\nverify=Send Email Verification\r\nrandompass=Send Random Password\r\nadmin=Administrator Activation' WHERE name = 'regtype'"); $db->query("UPDATE ".TABLE_PREFIX."users SET totalpms='-1', newpms='-1', unreadpms='-1'"); $db->query("UPDATE ".TABLE_PREFIX."settings SET name='maxmessagelength' WHERE name='messagelength'"); $db->query("DROP TABLE IF EXISTS ".TABLE_PREFIX."mycode"); $db->query("CREATE TABLE ".TABLE_PREFIX."mycode ( cid int unsigned NOT NULL auto_increment, title varchar(100) NOT NULL default '', description text NOT NULL default '', regex text NOT NULL default '', replacement text NOT NULL default '', active char(3) NOT NULL default '', PRIMARY KEY(cid) ) TYPE=MyISAM;"); $db->query("DROP TABLE IF EXISTS ".TABLE_PREFIX."templategroups"); $db->query("CREATE TABLE ".TABLE_PREFIX."templategroups ( gid int unsigned NOT NULL auto_increment, prefix varchar(50) NOT NULL default '', title varchar(100) NOT NULL default '', PRIMARY KEY (gid) ) TYPE=MyISAM;"); $db->query("INSERT INTO ".TABLE_PREFIX."templategroups (gid,prefix,title) VALUES ('1','calendar','Click next to continue with the upgrade process.
"; $output->print_contents($contents); $output->print_footer("5_redoconfig"); } function upgrade5_redoconfig() { global $db, $output, $config, $mybb; $output->print_header("Rewriting config.php"); $uid = 0; if($mybb->input['username'] != '' && !$mybb->input['uid']) { $query = $db->simple_select(TABLE_PREFIX."users", "uid", "username='".$db->escape_string($mybb->input['username'])."'"); $uid = $db->fetch_field($query, "uid"); if(!$uid) { echo "The username you entered could not be found.
Please ensure you corectly enter a valid username.
Please enter your primary administrator username. The user ID of the username you enter here will be written in to the new configuration file which will prevent this account from being banned, edited or deleted.
"; echo "Username:
"; echo ""; $output->print_footer("5_redoconfig"); exit; } $fh = @fopen(MYBB_ROOT."/inc/config.php", "w"); if(!$fh) { echo "
Unable to open inc/config.php
Before the upgrade process can continue, you need to changes the permissions of inc/config.php so it is writable.
The configuration file has successfully been rewritten.
"; echo "Click next to continue with the upgrade process.
"; $output->print_footer("5_lastposts"); } function upgrade5_lastposts() { global $db, $output; $output->print_header("Rebuilding Last Post Columns"); if(!$_POST['tpp']) { echo "The next step in the upgrade process involves rebuilding the last post information for every thread in your forum. Below, please enter the number of threads to process per page.
"; echo "Threads Per Page:
"; echo "Once you're ready, press next to begin the rebuild process.
"; $output->print_footer("5_lastposts"); } else { $query = $db->simple_select(TABLE_PREFIX."threads", "COUNT(*) as num_threads", "closed NOT LIKE 'moved|%'"); $num_threads = $db->fetch_field($query, 'num_threads'); $tpp = intval($_POST['tpp']); $start = intval($_POST['start']); $end = $start+$tpp; if($end > $num_threads) { $end = $num_threads; } echo "Updating {$start} to {$end} of {$num_threads}...
"; $query = $db->simple_select(TABLE_PREFIX."threads", "tid, firstpost", "closed NOT LIKE 'moved|%'", array("order_by" => "tid", "order_dir" => "asc", "limit" => $tpp, "limit_start" => $start)); while($thread = $db->fetch_array($query)) { update_thread_count($thread['tid']); if($thread['firstpost'] == 0) { update_first_post($thread['tid']); } } echo "Done
"; if($end >= $num_threads) { echo "The rebuild process has completed successfully. Click next to continue with the upgrade."; $output->print_footer("5_forumlastposts"); } else { echo "
Click Next to continue with the build process.
"; echo ""; echo ""; $output->print_footer("5_lastposts"); } } } function upgrade5_forumlastposts() { global $db, $output; $output->print_header("Rebuilding Forum Last Posts"); echo "Rebuilding last post information for forums..
"; $query = $db->simple_select(TABLE_PREFIX."forums", "fid"); while($forum = $db->fetch_array($query)) { update_forum_count($forum['fid']); } echo "Done"; echo "
Click next to continue with the upgrade process.
"; $output->print_footer("5_indexes"); } function upgrade5_indexes() { global $db, $output; $output->print_header("Indexing"); echo "Checking and creating fulltext database indexes..
"; if($db->is_fulltext(TABLE_PREFIX."threads", "subject")) { $db->drop_index(TABLE_PREFIX."threads", "subject"); } if($db->is_fulltext(TABLE_PREFIX."threads", "subject_2")) { $db->drop_index(TABLE_PREFIX."threads", "subject_2"); } if($db->supports_fulltext(TABLE_PREFIX."threads")) { $db->create_fulltext_index(TABLE_PREFIX."threads", "subject"); } if($db->supports_fulltext_boolean(TABLE_PREFIX."posts")) { if(!$db->is_fulltext(TABLE_PREFIX."posts", "message")) { $db->create_fulltext_index(TABLE_PREFIX."posts", "message"); } } // Register a shutdown function which actually tests if this functionality is working add_shutdown('test_shutdown_function'); $contents .= "Click next to continue with the upgrade process."; $output->print_contents($contents); $output->print_footer("5_done"); } function test_shutdown_function() { global $db; $db->query("UPDATE ".TABLE_PREFIX."settings SET value='yes' WHERE name='useshutdownfunc'"); write_settings(); } ?>