| [ Index ] |
PHP Cross Reference of MyBB 1.8.40 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.8 4 * Copyright 2014 MyBB Group, All Rights Reserved 5 * 6 * Website: http://www.mybb.com 7 * License: http://www.mybb.com/about/license 8 * 9 */ 10 11 /** 12 * Upgrade Script: 1.4.4 13 */ 14 15 16 $upgrade_detail = array( 17 "revert_all_templates" => 0, 18 "revert_all_themes" => 0, 19 "revert_all_settings" => 0 20 ); 21 22 function upgrade15_dbchanges() 23 { 24 global $db, $output, $mybb, $cache; 25 26 $output->print_header("Performing Queries"); 27 28 echo "<p>Performing necessary upgrade queries..</p>"; 29 flush(); 30 31 if($db->type != "pgsql") 32 { 33 $db->update_query("settinggroups", array('isdefault' => '1'), "isdefault='yes'"); 34 $db->update_query("settinggroups", array('isdefault' => '0'), "isdefault='no'"); 35 36 $db->write_query("ALTER TABLE ".TABLE_PREFIX."events CHANGE timezone timezone varchar(4) NOT NULL default '0'"); 37 } 38 39 if($db->type == "pgsql") 40 { 41 $db->write_query("ALTER TABLE ".TABLE_PREFIX."warnings ALTER COLUMN revokereason SET default ''"); 42 $db->write_query("ALTER TABLE ".TABLE_PREFIX."warnings ALTER COLUMN notes SET default ''"); 43 } 44 45 $cache->update("internal_settings", array('encryption_key' => random_str(32))); 46 47 if($db->type != "sqlite") 48 { 49 $ip_index = $db->index_exists("sessions", "ip"); 50 51 if($ip_index == false) 52 { 53 if($db->type == "pgsql") 54 { 55 $db->write_query("CREATE INDEX ip ON ".TABLE_PREFIX."sessions (ip)"); 56 } 57 else 58 { 59 $db->write_query("ALTER TABLE ".TABLE_PREFIX."sessions ADD INDEX (`ip`)"); 60 } 61 } 62 } 63 64 $contents .= "Click next to continue with the upgrade process.</p>"; 65 $output->print_contents($contents); 66 $output->print_footer("15_usernameverify"); 67 } 68 69 function upgrade15_usernameverify() 70 { 71 global $db, $output, $mybb; 72 73 $output->print_header("Performing Queries"); 74 75 echo "<p><span style=\"font-size: xx-large\">WARNING - PLEASE READ THE FOLLOWING:</span> The next step of this process will remove <strong>ALL</strong> commas (,) from the <i>usernames</i> of your forum whom contain them. The reason for this change is commas in usernames can make the private messages in MyBB return errors when sending to these users.</p>"; 76 flush(); 77 78 $contents .= "Click next to continue with the upgrade process once you have read the warning.</p>"; 79 $output->print_contents($contents); 80 $output->print_footer("15_usernameupdate"); 81 } 82 83 function upgrade15_usernameupdate() 84 { 85 global $db, $output, $mybb, $plugins; 86 87 $output->print_header("Performing Queries"); 88 89 echo "<p>Performing username updates..</p>"; 90 flush(); 91 92 require_once MYBB_ROOT."inc/datahandler.php"; 93 require_once MYBB_ROOT."inc/datahandlers/user.php"; 94 // Load plugin system for datahandler 95 require_once MYBB_ROOT."inc/class_plugins.php"; 96 $plugins = new pluginSystem; 97 98 $not_renameable = array(); 99 100 // Because commas can cause some problems with private message sending in usernames we have to remove them 101 $query = $db->simple_select("users", "uid, username", "username LIKE '%,%'"); 102 while($user = $db->fetch_array($query)) 103 { 104 $prefix = ''; 105 $userhandler = new UserDataHandler('update'); 106 107 do 108 { 109 $username = str_replace(',', '', $user['username']).'_'.$prefix; 110 111 $updated_user = array( 112 "uid" => $user['uid'], 113 "username" => $username 114 ); 115 $userhandler->set_data($updated_user); 116 117 ++$prefix; 118 } 119 while(!$userhandler->verify_username() || $userhandler->verify_username_exists()); 120 121 if(!$userhandler->validate_user()) 122 { 123 $not_renameable[] = htmlspecialchars_uni($user['username']); 124 } 125 else 126 { 127 $db->update_query("users", array('username' => $db->escape_string($username)), "uid='{$user['uid']}'"); 128 $db->update_query("posts", array('username' => $db->escape_string($username)), "uid='{$user['uid']}'"); 129 $db->update_query("threads", array('username' => $db->escape_string($username)), "uid='{$user['uid']}'"); 130 $db->update_query("threads", array('lastposter' => $db->escape_string($username)), "lastposteruid='{$user['uid']}'"); 131 $db->update_query("forums", array('lastposter' => $db->escape_string($username)), "lastposteruid='{$user['uid']}'"); 132 133 update_stats(array("numusers" => "+0")); 134 } 135 } 136 137 if(!empty($not_renameable)) 138 { 139 echo "<span style=\"color: red;\">NOTICE:</span> The following users could not be renamed automatically. Please rename these users in the Admin CP manually after the upgrade process has finished completing:<br /> 140 <ul> 141 <li>"; 142 echo implode('</li>\n<li>', $not_renameable); 143 echo "</li> 144 </ul>"; 145 } 146 147 $contents .= "Click next to continue with the upgrade process.</p>"; 148 $output->print_contents($contents); 149 $output->print_footer("15_done"); 150 } 151
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| 2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |