[ Index ]

PHP Cross Reference of MyBB 1.8.37

title

Body

[close]

/install/resources/ -> upgrade50.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.8.22
  13   */
  14  
  15  $upgrade_detail = array(
  16      "revert_all_templates" => 0,
  17      "revert_all_themes" => 0,
  18      "revert_all_settings" => 0
  19  );
  20  
  21  @set_time_limit(0);
  22  
  23  function upgrade50_dbchanges()
  24  {
  25      global $output, $cache, $db, $mybb;
  26  
  27      $output->print_header("Updating Database");
  28  
  29      echo "<p>Updating cache...</p>";
  30  
  31      $cache->delete("banned");
  32  
  33      // Moved PM wrong folder correction
  34      $db->update_query("privatemessages", array('folder' => 1), "folder='0'");
  35  
  36      // PM folder structure conversion
  37      $db->update_query('users', array('pmfolders' => "0**$%%$1**$%%$2**$%%$3**$%%$4**"), "pmfolders = ''");
  38      switch($db->type)
  39      {
  40          case "pgsql":
  41          case "sqlite":
  42              $update = "'0**$%%$' || pmfolders";
  43              break;
  44          default:
  45              $update = "CONCAT('0**$%%$', pmfolders)";
  46      }
  47      $db->write_query("UPDATE ".TABLE_PREFIX."users SET pmfolders=".$update." WHERE pmfolders NOT LIKE '0%'");
  48  
  49      $db->update_query('settings', array('value' => 1), "name='nocacheheaders'");
  50  
  51      // Add hCaptcha support
  52      echo "<p>Updating settings...</p>";
  53      $db->update_query("settings", array('name' => 'recaptchapublickey'), "name='captchapublickey'");
  54      $db->update_query("settings", array('name' => 'recaptchaprivatekey'), "name='captchaprivatekey'");
  55      $db->update_query("settings", array('optionscode' => 'select\r\n0=No CAPTCHA\r\n1=MyBB Default CAPTCHA\r\n2=reCAPTCHA\r\n3=NoCAPTCHA reCAPTCHA\r\n4=reCAPTCHA invisible\r\n5=hCAPTCHA\r\n6=hCAPTCHA invisible\r\n7=reCAPTCHA v3'), "name='captchaimage'");
  56  
  57      // If using fulltext then enforce minimum word length given by database
  58      if($mybb->settings['minsearchword'] > 0 && $mybb->settings['searchtype'] == "fulltext" && $db->supports_fulltext_boolean("posts") && $db->supports_fulltext("threads"))
  59      {
  60          // Attempt to determine minimum word length from MySQL for fulltext searches
  61          $query = $db->query("SHOW VARIABLES LIKE 'ft_min_word_len';");
  62          $min_length = $db->fetch_field($query, 'Value');
  63          if(is_numeric($min_length) && $mybb->settings['minsearchword'] < $min_length)
  64          {
  65              $min_length = (int) $min_length;
  66              $old_min_length = (int) $mybb->settings['minsearchword'];
  67              echo "<p>Updating Minimum Search Word Length setting to match the database system configuration (was {$old_min_length}, now {$min_length})</p>";
  68              $db->update_query("settings", array('value' => $min_length), "name='minsearchword'");
  69          }
  70      }
  71  
  72      $output->print_contents("<p>Click next to continue with the upgrade process.</p>");
  73      $output->print_footer("50_verify_email");
  74  }
  75  
  76  function upgrade50_verify_email()
  77  {
  78      global $output, $mybb, $errors, $checked;
  79  
  80      $output->print_header("Admin Email");
  81  
  82      if(!is_array($errors))
  83      {
  84          echo "<p>Checking if Admin Email setting is set correctly...</p>";
  85          flush();
  86      }
  87      
  88      if(empty($mybb->settings['adminemail']))
  89      {
  90          if(is_array($errors))
  91          {
  92              $error_list = "<ul>\n";
  93              foreach($errors as $error)
  94              {
  95                  $error_list .= "<li>{$error}</li>\n";
  96              }
  97              $error_list .= "</ul>\n";
  98              echo '<div class="error">
  99  <h3>Error</h3>
 100  <p>There seems to be one or more errors with the configuration you supplied:</p>
 101  '.$error_list.'
 102  <p>Once the above are corrected, continue with the upgrade.</p>
 103  </div>';
 104          }
 105          else
 106          {
 107              $checked = array();
 108          }
 109  
 110          echo '
 111  <div class="border_wrapper">
 112          <div class="title">Admin Email</div>
 113  
 114      <table class="general" cellspacing="0">
 115      <thead>
 116      <tr>
 117          <th colspan="2" class="first last">Please select an option to use for the board\'s outgoing email address.</th>
 118      </tr>
 119      </thead>
 120      <tr class="first" id="userpresetemail_row">
 121          <td class="first"><label for="usepresetemail">Select an option:</label></td>
 122          <td class="alt_col last" width="70%">
 123              <input type="radio" name="usepresetemail" value="current_user"'.$checked['current_user'].' />Use current user email: '.htmlspecialchars_uni($mybb->user['email']).'<br />';
 124          
 125          if($mybb->settings['mail_handler'] == 'smtp' && !empty($mybb->settings['smtp_user']) && filter_var($mybb->settings['smtp_user'], FILTER_VALIDATE_EMAIL) !== false)
 126          {
 127              echo '
 128              <input type="radio" name="usepresetemail" value="smtp"'.$checked['smtp'].' />Use SMTP username: '.htmlspecialchars_uni($mybb->settings['smtp_user']).'<br />';
 129          }
 130          
 131          echo '
 132              <input type="radio" name="usepresetemail" value="custom"'.$checked['custom'].' />Use custom
 133          </td>
 134      </tr>
 135      <tr class="last" id="custom_adminemail">
 136          <td class="first"><label for="adminemail">Custom Email Address:</label></td>
 137          <td class="alt_col last"><input type="text" class="text_input" name="adminemail" id="adminemail" value="'.htmlspecialchars_uni($mybb->input['adminemail']).'" /></td>
 138      </tr>
 139  </table>
 140  </div>
 141  <script type="text/javascript">
 142  $("#userpresetemail_row input").change(function()
 143  {
 144      if(this.checked && this.value == "custom")
 145      {
 146          $("#custom_adminemail").show();
 147          $("#userpresetemail_row").removeClass("last");
 148      }
 149      else
 150      {
 151          $("#custom_adminemail").hide();
 152          $("#userpresetemail_row").addClass("last");
 153      }
 154  });
 155  </script>
 156  <p>Once you\'ve correctly entered the details above and are ready to proceed, click Next.</p>';
 157  
 158          $output->print_footer("50_submit_email");
 159      }
 160      else
 161      {
 162          echo "<p>Admin email verified success...</p>";        
 163          $output->print_contents("<p>Click next to continue with the upgrade process.</p>");
 164          $output->print_footer("50_done");
 165      }
 166  }
 167  
 168  function upgrade50_submit_email()
 169  {
 170      global $output, $db, $mybb, $cache, $errors, $checked;
 171      
 172      if(empty($mybb->input['usepresetemail']) || !in_array($mybb->input['usepresetemail'], array('current_user', 'smtp', 'custom')))
 173       {
 174          $errors[] = "Please select an option for the admin email.";
 175      }
 176      
 177      if($mybb->input['usepresetemail'] == 'smtp' && !($mybb->settings['mail_handler'] == 'smtp' && !empty($mybb->settings['smtp_user'])))
 178      {
 179          $errors[] = "Please select a different option. SMTP user setting is not configured.";
 180      }
 181      
 182      switch ($mybb->input['usepresetemail'])
 183      {
 184          case 'current_user':
 185              $email = $mybb->user['email'];
 186              break;
 187          case 'smtp':
 188              $email = $mybb->settings['smtp_user'];
 189              break;
 190          case 'custom':
 191              $email = $mybb->input['adminemail'];
 192              break;
 193      }
 194      
 195      $checked = array(
 196          $mybb->input['usepresetemail'] => ' checked="checked"'
 197      );
 198      
 199      if(empty($errors) && filter_var($email, FILTER_VALIDATE_EMAIL) === false)
 200      {
 201          $errors[] = "The email address given was invalid. Please enter a valid email address.";
 202      }
 203      
 204      if(!empty($errors))
 205      {
 206          upgrade50_verify_email();
 207          return;
 208       }
 209  
 210      $output->print_header("Updating Database");
 211  
 212      echo "<p>Performing necessary upgrade queries...</p>";
 213      flush();
 214  
 215      $db->update_query('settings', array('value' => $db->escape_string($email)), "name='adminemail'");
 216  
 217      $output->print_contents("<p>Click next to continue with the upgrade process.</p>");
 218      $output->print_footer("50_done");
 219  }


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