[ Index ] |
PHP Cross Reference of MyBB |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.6 4 * Copyright 2010 MyBB Group, All Rights Reserved 5 * 6 * Website: http://www.mybboard.com 7 * License: http://mybb.com/about/license 8 * 9 * $Id$ 10 */ 11 12 /** 13 * Upgrade Script: 1.4.2 or 1.4.3 14 */ 15 16 17 $upgrade_detail = array( 18 "revert_all_templates" => 0, 19 "revert_all_themes" => 0, 20 "revert_all_settings" => 0 21 ); 22 23 @set_time_limit(0); 24 25 function upgrade14_dbchanges() 26 { 27 global $db, $output, $mybb; 28 29 $output->print_header("Performing Queries"); 30 31 echo "<p>Performing necessary upgrade queries..</p>"; 32 flush(); 33 34 // TODO: Need to check for PostgreSQL / SQLite support 35 36 if($db->field_exists('codepress', "adminoptions")) 37 { 38 $db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions DROP codepress;"); 39 } 40 41 if($db->type == "pgsql") 42 { 43 $db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions ADD codepress int NOT NULL default '1' AFTER cpstyle"); 44 } 45 else 46 { 47 $db->write_query("ALTER TABLE ".TABLE_PREFIX."adminoptions ADD codepress int(1) NOT NULL default '1' AFTER cpstyle"); 48 } 49 50 if($db->type != "sqlite") 51 { 52 $longregip_index = $db->index_exists("users", "longregip"); 53 $longlastip_index = $db->index_exists("users", "longlastip"); 54 55 if($longlastip_index == true) 56 { 57 $db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP KEY longlastip"); 58 } 59 60 if($longregip_index == true) 61 { 62 $db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP KEY longregip"); 63 } 64 65 $longipaddress_index = $db->index_exists("posts", "longipaddress"); 66 if($longipaddress_index == true) 67 { 68 $db->write_query("ALTER TABLE ".TABLE_PREFIX."posts DROP KEY longipaddress"); 69 } 70 } 71 72 if($db->field_exists('loginattempts', "sessions")) 73 { 74 $db->write_query("ALTER TABLE ".TABLE_PREFIX."sessions DROP loginattempts;"); 75 } 76 77 if($db->field_exists('loginattempts', "users")) 78 { 79 $db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP loginattempts;"); 80 } 81 82 if($db->type == "pgsql") 83 { 84 $db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD loginattempts smallint NOT NULL default '1';"); 85 } 86 else 87 { 88 $db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD loginattempts tinyint(2) NOT NULL default '1';"); 89 } 90 91 if($db->field_exists('failedlogin', "sessions")) 92 { 93 $db->write_query("ALTER TABLE ".TABLE_PREFIX."sessions DROP failedlogin;"); 94 } 95 96 if($db->field_exists('failedlogin', "users")) 97 { 98 $db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP failedlogin;"); 99 } 100 101 if($db->type == "pgsql") 102 { 103 $db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD failedlogin bigint NOT NULL default '0';"); 104 } 105 else 106 { 107 $db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD failedlogin bigint(30) NOT NULL default '0';"); 108 } 109 110 if($db->type == "mysql" || $db->type == "mysqli") 111 { 112 $db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD INDEX longregip (longregip)"); 113 $db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD INDEX longlastip (longlastip)"); 114 } 115 116 if($db->type == "sqlite") 117 { 118 // Because SQLite 2 nor 3 allows changing a column with a primary key constraint we have to completely rebuild the entire table 119 // *sigh* This is the 21st century, right? 120 $query = $db->simple_select("datacache"); 121 while($datacache = $db->fetch_array($query)) 122 { 123 $temp_datacache[$datacache['title']] = array('title' => $db->escape_string($datacache['title']), 'cache' => $db->escape_string($datacache['cache'])); 124 } 125 126 $db->write_query("DROP TABLE ".TABLE_PREFIX."datacache"); 127 128 $db->write_query("CREATE TABLE ".TABLE_PREFIX."datacache ( 129 title varchar(50) NOT NULL default '' PRIMARY KEY, 130 cache mediumTEXT NOT NULL 131 );"); 132 133 reset($temp_datacache); 134 foreach($temp_datacache as $data) 135 { 136 $db->insert_query("datacache", $data); 137 } 138 } 139 else if($db->type == "pgsql") 140 { 141 if(!$db->index_exists("datacache", "title")) 142 { 143 $db->write_query("ALTER TABLE ".TABLE_PREFIX."datacache ADD PRIMARY KEY (title)"); 144 } 145 } 146 147 $contents .= "Click next to continue with the upgrade process.</p>"; 148 $output->print_contents($contents); 149 $output->print_footer("14_dbchanges1"); 150 } 151 152 function upgrade14_dbchanges1() 153 { 154 global $db, $output; 155 156 $output->print_header("Performing Queries"); 157 158 echo "<p>Performing necessary upgrade queries..</p>"; 159 flush(); 160 161 if($db->type == "mysql" || $db->type == "mysqli") 162 { 163 $db->write_query("ALTER TABLE ".TABLE_PREFIX."posts ADD INDEX longipaddress (longipaddress)"); 164 } 165 166 $contents .= "Click next to continue with the upgrade process.</p>"; 167 $output->print_contents($contents); 168 $output->print_footer("14_dbchanges2"); 169 } 170 171 function upgrade14_dbchanges2() 172 { 173 global $db, $output; 174 175 $output->print_header("Cleaning up old Settings & Groups"); 176 177 echo "<p>Performing necessary upgrade queries..</p>"; 178 flush(); 179 180 $db->delete_query("settinggroups", "name='banning' AND isdefault='0'", 1); 181 182 $db->delete_query("settings", "name='bannedusernames'", 1); 183 $db->delete_query("settings", "name='bannedips'", 1); 184 $db->delete_query("settings", "name='bannedemails'", 1); 185 $db->delete_query("settings", "name='publiceventcolor'", 1); 186 $db->delete_query("settings", "name='privateeventcolor'", 1); 187 $db->delete_query("settings", "name='cssmedium'", 1); 188 189 $db->delete_query("templates", "title='usercp_options_timezoneselect' AND sid != '-1'"); 190 $db->delete_query("templates", "title='moderation_reports' AND sid != '-1'"); 191 $db->delete_query("templates", "title='moderation_reports_report' AND sid != '-1'"); 192 $db->delete_query("templates", "title='moderation_reports_multipage' AND sid != '-1'"); 193 $db->delete_query("templates", "title='moderation_allreports' AND sid != '-1'"); 194 $db->delete_query("templates", "title='showthread_ratingdisplay' AND sid != '-1'"); 195 $db->delete_query("templates", "title='moderation_getip_adminoptions' AND sid != '-1'"); 196 $db->delete_query("templates", "title='calendar_eventbit_public' AND sid != '-1'"); 197 $db->delete_query("templates", "title='calendar_daybit_today' AND sid != '-1'"); 198 $db->delete_query("templates", "title='calendar_daybit' AND sid != '-1'"); 199 $db->delete_query("templates", "title='online_iplookup' AND sid != '-1'"); 200 $db->delete_query("templates", "title='online_iplookup_adminoptions' AND sid != '-1'"); 201 $db->delete_query("templates", "title='online_row_ip' AND sid != '-1'"); 202 $db->delete_query("templates", "title='calendar_eventbit_dates' AND sid != '-1'"); 203 $db->delete_query("templates", "title='calendar_eventbit_dates_recurring' AND sid != '-1'"); 204 $db->delete_query("templates", "title='calendar_eventbit_times' AND sid != '-1'"); 205 $db->delete_query("templates", "title='calendar_editevent_normal' AND sid != '-1'"); 206 $db->delete_query("templates", "title='calendar_editevent_recurring' AND sid != '-1'"); 207 208 $db->update_query("helpdocs", array('document' => $db->escape_string("MyBB makes use of cookies to store your login information if you are registered, and your last visit if you are not. 209 <br /><br />Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. 210 <br /><br />Cookies on this forum also track the specific topics you have read and when you last read them. 211 <br /><br />To clear all cookies set by this forum, you can click <a href=\"misc.php?action=clearcookies&key={1}\">here</a>.")), "hid='3'", 1); 212 213 $contents .= "Click next to continue with the upgrade process.</p>"; 214 $output->print_contents($contents); 215 $output->print_footer("14_done"); 216 } 217 218 219 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 19:19:50 2013 | Cross-referenced by PHPXref 0.7.1 |