[ Index ]

PHP Cross Reference of MyBB 1.8.37

title

Body

[close]

/install/resources/ -> upgrade14.php (source)

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


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref