| [ 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.8.7 13 */ 14 15 $upgrade_detail = array( 16 "revert_all_templates" => 0, 17 "revert_all_themes" => 0, 18 "revert_all_settings" => 0 19 ); 20 21 function upgrade36_dbchanges() 22 { 23 global $db, $output, $mybb; 24 25 $output->print_header("Updating Database"); 26 echo "<p>Performing necessary upgrade queries...</p>"; 27 flush(); 28 29 if($db->field_exists('enabled', 'attachtypes')) 30 { 31 $db->drop_column('attachtypes', 'enabled'); 32 } 33 34 if($db->field_exists('groups', 'attachtypes')) 35 { 36 $db->drop_column('attachtypes', 'groups'); 37 } 38 39 if($db->field_exists('forums', 'attachtypes')) 40 { 41 $db->drop_column('attachtypes', 'forums'); 42 } 43 44 if($db->field_exists('avatarfile', 'attachtypes')) 45 { 46 $db->drop_column('attachtypes', 'avatarfile'); 47 } 48 49 switch($db->type) 50 { 51 case "pgsql": 52 $db->add_column('attachtypes', 'enabled', "smallint NOT NULL default '1'"); 53 $db->add_column('attachtypes', 'groups', "text NOT NULL default '-1'"); 54 $db->add_column('attachtypes', 'forums', "text NOT NULL default '-1'"); 55 $db->add_column('attachtypes', 'avatarfile', "smallint NOT NULL default '0'"); 56 break; 57 default: 58 $db->add_column('attachtypes', 'enabled', "tinyint(1) NOT NULL default '1'"); 59 $db->add_column('attachtypes', 'groups', "TEXT NOT NULL"); 60 $db->add_column('attachtypes', 'forums', "TEXT NOT NULL"); 61 $db->add_column('attachtypes', 'avatarfile', "tinyint(1) NOT NULL default '0'"); 62 63 $db->update_query('attachtypes', array('groups' => '-1', 'forums' => '-1')); 64 break; 65 } 66 67 $db->update_query('attachtypes', array('avatarfile' => 1), "atid IN (2, 4, 7, 11)"); 68 69 if($mybb->settings['username_method'] == 1 || $mybb->settings['username_method'] == 2) 70 { 71 $query = $db->simple_select('users', 'email, COUNT(email) AS duplicates', "email!=''", array('group_by' => 'email HAVING duplicates>1')); 72 if($db->num_rows($query)) 73 { 74 $db->update_query('settings', array('value' => 0), "name='username_method'"); 75 } 76 else 77 { 78 $db->update_query('settings', array('value' => 0), "name='allowmultipleemails'"); 79 } 80 } 81 82 $query = $db->simple_select("templategroups", "COUNT(*) as numexists", "prefix='mycode'"); 83 if($db->fetch_field($query, "numexists") == 0) 84 { 85 $db->insert_query("templategroups", array('prefix' => 'mycode', 'title' => '<lang:group_mycode>', 'isdefault' => '1')); 86 } 87 88 $output->print_contents("<p>Click next to continue with the upgrade process.</p>"); 89 $output->print_footer("36_dbchanges2"); 90 } 91 92 function upgrade36_dbchanges2() 93 { 94 global $output, $db, $cache; 95 96 $output->print_header("Updating Database"); 97 echo "<p>Performing necessary upgrade queries...</p>"; 98 flush(); 99 100 if($db->field_exists('reasonid', 'reportedcontent')) 101 { 102 $db->drop_column("reportedcontent", "reasonid"); 103 } 104 105 switch($db->type) 106 { 107 case "pgsql": 108 case "sqlite": 109 $db->add_column("reportedcontent", "reasonid", "smallint NOT NULL default '0' AFTER reportstatus"); 110 break; 111 default: 112 $db->add_column("reportedcontent", "reasonid", "smallint unsigned NOT NULL default '0' AFTER reportstatus"); 113 break; 114 } 115 116 117 if($db->table_exists("reportreasons")) 118 { 119 $db->drop_table("reportreasons"); 120 } 121 122 $collation = $db->build_create_table_collation(); 123 124 switch($db->type) 125 { 126 case "pgsql": 127 $db->write_query("CREATE TABLE ".TABLE_PREFIX."reportreasons ( 128 rid serial, 129 title varchar(250) NOT NULL default '', 130 appliesto varchar(250) NOT NULL default '', 131 extra smallint NOT NULL default '0', 132 disporder smallint NOT NULL default '0', 133 PRIMARY KEY (rid) 134 );"); 135 break; 136 case "sqlite": 137 $db->write_query("CREATE TABLE ".TABLE_PREFIX."reportreasons ( 138 rid INTEGER PRIMARY KEY, 139 title varchar(250) NOT NULL default '', 140 appliesto varchar(250) NOT NULL default '', 141 extra tinyint(1) NOT NULL default '0', 142 disporder smallint NOT NULL default '0', 143 );"); 144 break; 145 default: 146 $db->write_query("CREATE TABLE ".TABLE_PREFIX."reportreasons ( 147 rid int unsigned NOT NULL auto_increment, 148 title varchar(250) NOT NULL default '', 149 appliesto varchar(250) NOT NULL default '', 150 extra tinyint(1) NOT NULL default '0', 151 disporder smallint unsigned NOT NULL default '0', 152 PRIMARY KEY (rid) 153 ) ENGINE=MyISAM{$collation};"); 154 break; 155 } 156 157 $reportreasons = array( 158 array( 159 'rid' => 1, 160 'title' => "<lang:report_reason_other>", 161 'appliesto' => "all", 162 'extra' => 1, 163 'disporder' => 99 164 ), 165 array( 166 'rid' => 2, 167 'title' => "<lang:report_reason_rules>", 168 'appliesto' => "all", 169 'extra' => 0, 170 'disporder' => 1 171 ), 172 array( 173 'rid' => 3, 174 'title' => "<lang:report_reason_bad>", 175 'appliesto' => "all", 176 'extra' => 0, 177 'disporder' => 2 178 ), 179 array( 180 'rid' => 4, 181 'title' => "<lang:report_reason_spam>", 182 'appliesto' => "all", 183 'extra' => 0, 184 'disporder' => 3 185 ), 186 array( 187 'rid' => 5, 188 'title' => "<lang:report_reason_wrong>", 189 'appliesto' => "post", 190 'extra' => 0, 191 'disporder' => 4 192 ) 193 ); 194 195 $db->insert_query_multiple('reportreasons', $reportreasons); 196 197 $templang = new MyLanguage(); 198 $templang->set_path(MYBB_ROOT."inc/languages"); 199 200 $langs = array_keys($templang->get_languages()); 201 202 foreach($langs as $langname) 203 { 204 unset($templang); 205 $templang = new MyLanguage(); 206 $templang->set_path(MYBB_ROOT."inc/languages"); 207 $templang->set_language($langname); 208 $templang->load("report"); 209 210 if(!empty($templang->report_reason_rules) && $templang->report_reason_rules != '') 211 { 212 $db->update_query("reportedcontent", array("reasonid" => 2, "reason" => ''), "reason = '".$db->escape_string("\n".$templang->report_reason_rules)."'"); 213 } 214 if(!empty($templang->report_reason_bad) && $templang->report_reason_bad != '') 215 { 216 $db->update_query("reportedcontent", array("reasonid" => 3, "reason" => ''), "reason = '".$db->escape_string("\n".$templang->report_reason_bad)."'"); 217 } 218 if(!empty($templang->report_reason_spam) && $templang->report_reason_spam != '') 219 { 220 $db->update_query("reportedcontent", array("reasonid" => 4, "reason" => ''), "reason = '".$db->escape_string("\n".$templang->report_reason_spam)."'"); 221 } 222 if(!empty($templang->report_reason_wrong) && $templang->report_reason_wrong != '') 223 { 224 $db->update_query("reportedcontent", array("reasonid" => 5, "reason" => ''), "reason = '".$db->escape_string("\n".$templang->report_reason_wrong)."'"); 225 } 226 } 227 228 // Any reason not converted is treated as "Other" with extra text specified 229 $db->update_query("reportedcontent", array('reasonid' => 1), "reason != ''"); 230 231 $output->print_contents("<p>Click next to continue with the upgrade process.</p>"); 232 $output->print_footer("36_done"); 233 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| 2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |