1, "revert_all_themes" => 1, "revert_all_settings" => 2, "requires_deactivated_plugins" => 1, ); @set_time_limit(0); function upgrade5_dbchanges() { global $db, $output, $mybb; $output->print_header("Performing Queries"); echo "
Performing necessary upgrade queries..
"; $db->write_query("ALTER TABLE ".TABLE_PREFIX."users CHANGE avatartype avatartype varchar(10) NOT NULL;"); if($db->field_exists('totalpms', "users")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP totalpms;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD totalpms int(10) NOT NULL default '0' AFTER showcodebuttons;"); if($db->field_exists('newpms', "users")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP newpms;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD newpms int(10) NOT NULL default '0' AFTER totalpms;"); if($db->field_exists('unreadpms', "users")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP unreadpms;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD unreadpms int(10) NOT NULL default '0' AFTER newpms;"); if($db->field_exists('showredirect', "users")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP showredirect;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD showredirect char(3) NOT NULL default '' AFTER showquickreply;"); if($db->field_exists('avatardimensions', "users")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP avatardimensions;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD avatardimensions varchar(10) NOT NULL default '' AFTER avatar;"); if($db->field_exists('unapprovedposts', "threads")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."threads DROP unapprovedposts;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."threads ADD unapprovedposts INT(10) unsigned NOT NULL default '0' AFTER visible;"); if($db->field_exists('unapprovedthreads', "forums")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums DROP unapprovedthreads;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums ADD unapprovedthreads INT(10) unsigned NOT NULL default '0' AFTER rules;"); if($db->field_exists('unapprovedposts', "forums")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums DROP unapprovedposts;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums ADD unapprovedposts INT(10) unsigned NOT NULL default '0' AFTER rules;"); if($db->field_exists('defaultdatecut', "forums")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums DROP defaultdatecut;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums ADD defaultdatecut smallint(4) unsigned NOT NULL default '0' AFTER unapprovedposts;"); if($db->field_exists('defaultsortby', "forums")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums DROP defaultsortby;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums ADD defaultsortby varchar(10) NOT NULL default '' AFTER defaultdatecut;"); if($db->field_exists('defaultsortorder', "forums")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums DROP defaultsortorder;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums ADD defaultsortorder varchar(4) NOT NULL default '' AFTER defaultsortby;"); if($db->field_exists('lastposteruid', "forums")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums DROP lastposteruid;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums ADD lastposteruid int(10) unsigned NOT NULL default '0' AFTER lastposter;"); if($db->field_exists('lastpostsubject', "forums")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums DROP lastpostsubject;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."forums ADD lastpostsubject varchar(120) NOT NULL default '' AFTER lastposttid"); if($db->field_exists('lastposteruid', "threads")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."threads DROP lastposteruid;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."threads ADD lastposteruid int unsigned NOT NULL default '0' AFTER lastposter"); if($db->field_exists('canmanagemembers', "groupleaders")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."groupleaders DROP canmanagemembers;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."groupleaders ADD canmanagemembers char(3) NOT NULL default '' AFTER uid;"); if($db->field_exists('canmanagerequests', "groupleaders")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."groupleaders DROP canmanagerequests;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."groupleaders ADD canmanagerequests char(3) NOT NULL default '' AFTER canmanagemembers;"); if($db->field_exists('caneditlangs', "adminoptions")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions DROP caneditlangs;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions ADD caneditlangs char(3) NOT NULL default '' AFTER canedithelp;"); if($db->field_exists('canrundbtools', "adminoptions")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions DROP canrundbtools;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions ADD canrundbtools char(3) NOT NULL default ''"); if($db->field_exists('allowedgroups', "themes")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP allowedgroups;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."themes ADD allowedgroups text NOT NULL AFTER extracss;"); if($db->field_exists('canmovetononmodforum', "moderators")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."moderators DROP canmovetononmodforum;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."moderators ADD canmovetononmodforum char(3) NOT NULL default '' AFTER canmanagethreads;"); if($db->field_exists('csscached', "themes")) { $db->write_query("ALTER TABLE ".TABLE_PREFIX."themes DROP csscached;"); } $db->write_query("ALTER TABLE ".TABLE_PREFIX."themes ADD csscached bigint(30) NOT NULL default '0'"); $db->write_query("UPDATE ".TABLE_PREFIX."adminoptions SET caneditlangs='yes' WHERE canrunmaint='yes'"); $db->write_query("UPDATE ".TABLE_PREFIX."adminoptions SET caneditlangs='no' WHERE canrunmaint='no'"); $db->write_query("UPDATE ".TABLE_PREFIX."adminoptions SET canrundbtools='yes' WHERE canrunmaint='yes'"); $db->write_query("UPDATE ".TABLE_PREFIX."adminoptions SET canrundbtools='no' WHERE canrunmaint='no'"); $db->write_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->write_query("UPDATE ".TABLE_PREFIX."users SET totalpms='-1', newpms='-1', unreadpms='-1'"); $db->write_query("UPDATE ".TABLE_PREFIX."settings SET name='maxmessagelength' WHERE name='messagelength'"); $collation = $db->build_create_table_collation(); $db->drop_table("mycode"); $db->write_query("CREATE TABLE ".TABLE_PREFIX."mycode ( cid int unsigned NOT NULL auto_increment, title varchar(100) NOT NULL default '', description text NOT NULL, regex text NOT NULL, replacement text NOT NULL, active char(3) NOT NULL default '', PRIMARY KEY(cid) ) ENGINE=MyISAM{$collation};"); $db->drop_table("templategroups"); $db->write_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) ) ENGINE=MyISAM{$collation};"); $db->write_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']) { $user = get_user_by_username($mybb->input['username']); $uid = (int)$user['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("threads", "COUNT(*) as num_threads", "closed NOT LIKE 'moved|%'"); $num_threads = $db->fetch_field($query, 'num_threads'); $tpp = (int)$_POST['tpp']; $start = (int)$_POST['start']; $end = $start+$tpp; if($end > $num_threads) { $end = $num_threads; } echo "Updating {$start} to {$end} of {$num_threads}...
"; $query = $db->simple_select("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)) { $recount_thread = get_thread($thread['tid']); $count = array(); $query = $db->simple_select("posts", "COUNT(pid) AS replies", "tid='{$thread['tid']}' AND pid!='{$recount_thread['firstpost']}' AND visible='1'"); $count['replies'] = $db->fetch_field($query, "replies"); // Unapproved posts $query = $db->simple_select("posts", "COUNT(pid) AS unapprovedposts", "tid='{$thread['tid']}' AND pid != '{$recount_thread['firstpost']}' AND visible='0'"); $count['unapprovedposts'] = $db->fetch_field($query, "unapprovedposts"); // Attachment count $query = $db->query(" SELECT COUNT(aid) AS attachment_count FROM ".TABLE_PREFIX."attachments a LEFT JOIN ".TABLE_PREFIX."posts p ON (a.pid=p.pid) WHERE p.tid='{$thread['tid']}' AND a.visible=1 "); $count['attachmentcount'] = $db->fetch_field($query, "attachment_count"); $db->update_query("threads", $count, "tid='{$thread['tid']}'"); update_thread_data($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("forums", "fid"); while($forum = $db->fetch_array($query)) { update_forum_lastpost($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("threads", "subject")) { $db->drop_index("threads", "subject"); } if($db->is_fulltext("threads", "subject_2")) { $db->drop_index("threads", "subject_2"); } if($db->supports_fulltext("threads")) { $db->create_fulltext_index("threads", "subject"); } if($db->supports_fulltext_boolean("posts")) { if(!$db->is_fulltext("posts", "message")) { $db->create_fulltext_index("posts", "message"); } } $contents .= "Click next to continue with the upgrade process."; $output->print_contents($contents); $output->print_footer("5_done"); }