[ Index ]

PHP Cross Reference of MyBB 1.8.37

title

Body

[close]

/install/resources/ -> upgrade17.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.13 or 1.4.14
  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 upgrade17_dbchanges()
  25  {
  26      global $db, $output, $mybb, $cache;
  27  
  28      $output->print_header("Performing Queries");
  29  
  30      echo "<p>Performing necessary upgrade queries..</p>";
  31      echo "<p>Adding index to private messages table ... ";
  32      flush();
  33  
  34      if($db->type == "mysql" || $db->type == "mysqli")
  35      {
  36          $db->write_query("ALTER TABLE ".TABLE_PREFIX."privatemessages ADD INDEX ( `toid` )");
  37      }
  38  
  39      global $footer_extra;
  40      $footer_extra = "<script type=\"text/javascript\">$(function() { var button = $('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>";
  41  
  42      $contents .= "Click next to continue with the upgrade process.</p>";
  43      $output->print_contents($contents);
  44      $output->print_footer("17_dbchanges2");
  45  }
  46  
  47  function upgrade17_dbchanges2()
  48  {
  49      global $db, $output, $mybb, $cache;
  50  
  51      $output->print_header("Performing Queries");
  52  
  53      echo "<p>Performing necessary upgrade queries..</p>";
  54      flush();
  55  
  56      // Update our version history first
  57      $version_history = array();
  58      $dh = opendir(INSTALL_ROOT."resources");
  59      while(($file = readdir($dh)) !== false)
  60      {
  61          if(preg_match("#upgrade([0-9]+).php$#i", $file, $match))
  62          {
  63              $version_history[$match[1]] = $match[1];
  64          }
  65      }
  66      sort($version_history, SORT_NUMERIC);
  67  
  68      // This script isn't done yet!
  69      unset($version_history['17']);
  70  
  71      $cache->update("version_history", $version_history);
  72  
  73      if($db->field_exists('prefix', 'threads'))
  74      {
  75          $db->drop_column("threads", "prefix");
  76      }
  77  
  78      if($db->field_exists('loginattempts', "adminoptions"))
  79      {
  80          $db->drop_column("adminoptions", "loginattempts");
  81      }
  82  
  83      if($db->field_exists('loginlockoutexpiry', "adminoptions"))
  84      {
  85          $db->drop_column("adminoptions", "loginlockoutexpiry");
  86      }
  87  
  88      if($db->field_exists('canonlyviewownthreads', "forumpermissions"))
  89      {
  90          $db->drop_column("forumpermissions", "canonlyviewownthreads");
  91      }
  92  
  93      if($db->field_exists('isgroup', 'moderators'))
  94      {
  95          $db->drop_column("moderators", "isgroup");
  96      }
  97  
  98      if($db->field_exists('referrals', 'promotions'))
  99      {
 100          $db->drop_column("promotions", "referrals");
 101      }
 102  
 103      if($db->field_exists('referralstype', 'promotions'))
 104      {
 105          $db->drop_column("promotions", "referralstype");
 106      }
 107  
 108      if($db->field_exists('pid', 'reputation'))
 109      {
 110          $db->drop_column("reputation", "pid");
 111      }
 112  
 113      if($db->field_exists('allowvideocode', 'calendars'))
 114      {
 115          $db->drop_column("calendars", "allowvideocode");
 116      }
 117  
 118      if($db->field_exists('allowvideocode', 'forums'))
 119      {
 120          $db->drop_column("forums", "allowvideocode");
 121      }
 122  
 123      switch($db->type)
 124      {
 125          case "pgsql":
 126              $db->add_column("threads", "prefix", "smallint NOT NULL default '0' AFTER subject");
 127              $db->add_column("adminoptions", "loginattempts", "int NOT NULL default '0'");
 128              $db->add_column("adminoptions", "loginlockoutexpiry", "int NOT NULL default '0'");
 129              $db->add_column("forumpermissions", "canonlyviewownthreads", "int NOT NULL default '0' AFTER canviewthreads");
 130              $db->add_column("moderators", "isgroup", "int NOT NULL default '0'");
 131              $db->add_column("promotions", "referrals", "int NOT NULL default '0' AFTER reputationtype");
 132              $db->add_column("promotions", "referralstype", "char(2) NOT NULL default '' AFTER referrals");
 133              $db->add_column("reputation", "pid", "int NOT NULL default '0'");
 134              $db->add_column("calendars", "allowvideocode", "int NOT NULL default '0' AFTER allowimgcode");
 135              $db->add_column("forums", "allowvideocode", "int NOT NULL default '0' AFTER allowimgcode");
 136              break;
 137          case "sqlite":
 138              $db->add_column("threads", "prefix", "smallint NOT NULL default '0' AFTER subject");
 139              $db->add_column("adminoptions", "loginattempts", "int NOT NULL default '0'");
 140              $db->add_column("adminoptions", "loginlockoutexpiry", "int NOT NULL default '0'");
 141              $db->add_column("forumpermissions", "canonlyviewownthreads", "int NOT NULL default '0' AFTER canviewthreads");
 142              $db->add_column("moderators", "isgroup", "int NOT NULL default '0'");
 143              $db->add_column("promotions", "referrals", "int NOT NULL default '0' AFTER reputationtype");
 144              $db->add_column("promotions", "referralstype", "varchar(2) NOT NULL default '' AFTER referrals");
 145              $db->add_column("reputation", "pid", "int NOT NULL default '0'");
 146              $db->add_column("calendars", "allowvideocode", "int(1) NOT NULL default '0' AFTER allowimgcode");
 147              $db->add_column("forums", "allowvideocode", "int(1) NOT NULL default '0' AFTER allowimgcode");
 148              break;
 149          default:
 150              $db->add_column("threads", "prefix", "smallint unsigned NOT NULL default '0' AFTER subject");
 151              $db->add_column("adminoptions", "loginattempts", "int unsigned NOT NULL default '0'");
 152              $db->add_column("adminoptions", "loginlockoutexpiry", "int unsigned NOT NULL default '0'");
 153              $db->add_column("forumpermissions", "canonlyviewownthreads", "int(1) NOT NULL default '0' AFTER canviewthreads");
 154              $db->add_column("moderators", "isgroup", "int(1) unsigned NOT NULL default '0'");
 155              $db->add_column("promotions", "referrals", "int NOT NULL default '0' AFTER reputationtype");
 156              $db->add_column("promotions", "referralstype", "varchar(2) NOT NULL default '' AFTER referrals");
 157              $db->add_column("reputation", "pid", "int unsigned NOT NULL default '0'");
 158              $db->add_column("calendars", "allowvideocode", "int(1) NOT NULL default '0' AFTER allowimgcode");
 159              $db->add_column("forums", "allowvideocode", "int(1) NOT NULL default '0' AFTER allowimgcode");
 160      }
 161  
 162      $db->update_query("forums", array('allowvideocode' => '1'));
 163      $db->update_query("calendars", array('allowvideocode' => '1'));
 164  
 165      global $footer_extra;
 166      $footer_extra = "<script type=\"text/javascript\">$(function() { var button = $('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>";
 167  
 168      $contents .= "Click next to continue with the upgrade process.</p>";
 169      $output->print_contents($contents);
 170      $output->print_footer("17_dbchanges3");
 171  }
 172  
 173  function upgrade17_dbchanges3()
 174  {
 175      global $db, $output, $mybb;
 176  
 177      $output->print_header("Performing Queries");
 178  
 179      echo "<p>Performing necessary upgrade queries..</p>";
 180      flush();
 181  
 182      if($db->field_exists('canundovotes', 'usergroups'))
 183      {
 184          $db->drop_column("usergroups", "canundovotes");
 185      }
 186  
 187      if($db->field_exists('maxreputationsperuser', 'usergroups'))
 188      {
 189          $db->drop_column("usergroups", "maxreputationsperuser");
 190      }
 191  
 192      if($db->field_exists('maxreputationsperthread', 'usergroups'))
 193      {
 194          $db->drop_column("usergroups", "maxreputationsperthread");
 195      }
 196  
 197      if($db->field_exists('receivefrombuddy', 'users'))
 198      {
 199          $db->drop_column("users", "receivefrombuddy");
 200      }
 201  
 202      if($db->field_exists('suspendsignature', 'users'))
 203      {
 204          $db->drop_column("users", "suspendsignature");
 205      }
 206  
 207      if($db->field_exists('suspendsigtime', 'users'))
 208      {
 209          $db->drop_column("users", "suspendsigtime");
 210      }
 211  
 212      if($db->field_exists('loginattempts', 'users'))
 213      {
 214          $db->drop_column("users", "loginattempts");
 215      }
 216  
 217      if($db->field_exists('failedlogin', 'users'))
 218      {
 219          $db->drop_column("users", "failedlogin");
 220      }
 221  
 222      if($db->field_exists('usernotes', "users"))
 223      {
 224          $db->drop_column("users", "usernotes");
 225      }
 226  
 227      if($db->field_exists('referrals', 'users'))
 228      {
 229          $db->drop_column("users", "referrals");
 230      }
 231  
 232      switch($db->type)
 233      {
 234          case "pgsql":
 235              $db->add_column("usergroups", "canundovotes", "int NOT NULL default '0' AFTER canvotepolls");
 236              $db->add_column("usergroups", "maxreputationsperuser", "bigint NOT NULL default '0' AFTER maxreputationsday");
 237              $db->add_column("usergroups", "maxreputationsperthread", "bigint NOT NULL default '0' AFTER maxreputationsperuser");
 238              $db->add_column("users", "receivefrombuddy", "int NOT NULL default '0'");
 239              $db->add_column("users", "suspendsignature", "int NOT NULL default '0'");
 240              $db->add_column("users", "suspendsigtime", "bigint NOT NULL default '0'");
 241              $db->add_column("users", "loginattempts", "smallint NOT NULL default '1'");
 242              $db->add_column("users", "failedlogin", "bigint NOT NULL default '0'");
 243              $db->add_column("users", "usernotes", "text NOT NULL default ''");
 244              $db->add_column("users", "referrals", "int NOT NULL default '0' AFTER referrer");
 245              break;
 246          case "sqlite":
 247              $db->add_column("usergroups", "canundovotes", "int NOT NULL default '0' AFTER canvotepolls");
 248              $db->add_column("usergroups", "maxreputationsperuser", "bigint NOT NULL default '0' AFTER maxreputationsday");
 249              $db->add_column("usergroups", "maxreputationsperthread", "bigint NOT NULL default '0' AFTER maxreputationsperuser");
 250              $db->add_column("users", "receivefrombuddy", "int NOT NULL default '0'");
 251              $db->add_column("users", "suspendsignature", "int NOT NULL default '0'");
 252              $db->add_column("users", "suspendsigtime", "bigint NOT NULL default '0'");
 253              $db->add_column("users", "loginattempts", "tinyint NOT NULL default '1'");
 254              $db->add_column("users", "failedlogin", "bigint NOT NULL default '0'");
 255              $db->add_column("users", "usernotes", "text NOT NULL default ''");
 256              $db->add_column("users", "referrals", "int NOT NULL default '0' AFTER referrer");
 257              break;
 258          default:
 259              $db->add_column("usergroups", "canundovotes", "int(1) NOT NULL default '0' AFTER canvotepolls");
 260              $db->add_column("usergroups", "maxreputationsperuser", "bigint(30) NOT NULL default '0' AFTER maxreputationsday");
 261              $db->add_column("usergroups", "maxreputationsperthread", "bigint(30) NOT NULL default '0' AFTER maxreputationsperuser");
 262              $db->add_column("users", "receivefrombuddy", "int(1) NOT NULL default '0'");
 263              $db->add_column("users", "suspendsignature", "int(1) NOT NULL default '0'");
 264              $db->add_column("users", "suspendsigtime", "bigint(30) NOT NULL default '0'");
 265              $db->add_column("users", "loginattempts", "tinyint(2) NOT NULL default '1'");
 266              $db->add_column("users", "failedlogin", "bigint(30) NOT NULL default '0'");
 267              $db->add_column("users", "usernotes", "text NOT NULL");
 268              $db->add_column("users", "referrals", "int unsigned NOT NULL default '0' AFTER referrer");
 269      }
 270  
 271      $contents .= "Click next to continue with the upgrade process.</p>";
 272      $output->print_contents($contents);
 273  
 274      global $footer_extra;
 275      $footer_extra = "<script type=\"text/javascript\">$(function() { var button = $('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>";
 276  
 277      $output->print_footer("17_dbchanges4");
 278  }
 279  
 280  function upgrade17_dbchanges4()
 281  {
 282      global $db, $output, $mybb;
 283  
 284      $output->print_header("Performing Queries");
 285  
 286      echo "<p>Performing necessary upgrade queries..</p>";
 287      flush();
 288  
 289      if($db->field_exists('remember', 'users'))
 290      {
 291          $db->drop_column("users", "remember");
 292      }
 293  
 294      if($db->type != "pgsql")
 295      {
 296          // PgSQL doesn't support longtext
 297          $db->modify_column("searchlog", "threads", "longtext NOT NULL");
 298          $db->modify_column("searchlog", "posts", "longtext NOT NULL");
 299      }
 300  
 301      if($db->field_exists("uid", "moderators") && !$db->field_exists("id", "moderators"))
 302      {
 303          switch($db->type)
 304          {
 305              case "pgsql":
 306                  $db->rename_column("moderators", "uid", "id", "int", true, "'0'");
 307                  break;
 308              default:
 309                  $db->rename_column("moderators", "uid", "id", "int unsigned NOT NULL default '0'");
 310          }
 311      }
 312  
 313      if($db->table_exists("threadprefixes"))
 314      {
 315          $db->drop_table("threadprefixes");
 316      }
 317  
 318      if($db->table_exists("delayedmoderation"))
 319      {
 320          $db->drop_table("delayedmoderation");
 321      }
 322  
 323      switch($db->type)
 324      {
 325          case "sqlite":
 326              $db->write_query("CREATE TABLE ".TABLE_PREFIX."threadprefixes (
 327                  rid INTEGER PRIMARY KEY,
 328                  tid int NOT NULL default '0',
 329                  uid int NOT NULL default '0',
 330                  rating smallint NOT NULL default '0',
 331                  ipaddress varchar(30) NOT NULL default ''
 332              );");
 333              $db->write_query("CREATE TABLE ".TABLE_PREFIX."delayedmoderation (
 334                  did integer PRIMARY KEY,
 335                  type varchar(30) NOT NULL default '',
 336                  delaydateline bigint(30) NOT NULL default '0',
 337                  uid int(10) NOT NULL default '0',
 338                  fid smallint(5) NOT NULL default '0',
 339                  tids text NOT NULL,
 340                  dateline bigint(30) NOT NULL default '0',
 341                  inputs text NOT NULL
 342              );");
 343              break;
 344          case "pgsql":
 345              $db->write_query("CREATE TABLE ".TABLE_PREFIX."threadprefixes (
 346                  pid serial,
 347                  prefix varchar(120) NOT NULL default '',
 348                  displaystyle varchar(200) NOT NULL default '',
 349                  forums text NOT NULL,
 350                  groups text NOT NULL,
 351                  PRIMARY KEY(pid)
 352              );");
 353              $db->write_query("CREATE TABLE ".TABLE_PREFIX."delayedmoderation (
 354                  did serial,
 355                  type varchar(30) NOT NULL default '',
 356                  delaydateline bigint NOT NULL default '0',
 357                  uid int NOT NULL default '0',
 358                  fid smallint NOT NULL default '0',
 359                  tids text NOT NULL,
 360                  dateline bigint NOT NULL default '0',
 361                  inputs text NOT NULL default '',
 362                  PRIMARY KEY (did)
 363              );");
 364              break;
 365          default:
 366              $db->write_query("CREATE TABLE ".TABLE_PREFIX."threadprefixes (
 367                  pid int unsigned NOT NULL auto_increment,
 368                  prefix varchar(120) NOT NULL default '',
 369                  displaystyle varchar(200) NOT NULL default '',
 370                  forums text NOT NULL,
 371                  `groups` text NOT NULL,
 372                  PRIMARY KEY(pid)
 373              ) ENGINE=MyISAM;");
 374              $db->write_query("CREATE TABLE ".TABLE_PREFIX."delayedmoderation (
 375                  did int unsigned NOT NULL auto_increment,
 376                  type varchar(30) NOT NULL default '',
 377                  delaydateline bigint(30) unsigned NOT NULL default '0',
 378                  uid int(10) unsigned NOT NULL default '0',
 379                  fid smallint(5) unsigned NOT NULL default '0',
 380                  tids text NOT NULL,
 381                  dateline bigint(30) NOT NULL default '0',
 382                  inputs text NOT NULL,
 383                  PRIMARY KEY (did)
 384              ) ENGINE=MyISAM;");
 385      }
 386  
 387      $added_tasks = sync_tasks();
 388  
 389      echo "<p>Added {$added_tasks} new tasks.</p>";
 390  
 391      $contents .= "Click next to continue with the upgrade process.</p>";
 392      $output->print_contents($contents);
 393  
 394      global $footer_extra;
 395      $footer_extra = "<script type=\"text/javascript\">$(function() { var button = $('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>";
 396  
 397      $output->print_footer("17_dbchanges5");
 398  }
 399  
 400  function upgrade17_dbchanges5()
 401  {
 402      global $db, $output, $mybb, $cache;
 403  
 404      if(file_exists(MYBB_ROOT.$mybb->config['admin_dir']."/inc/functions.php"))
 405      {
 406          require_once MYBB_ROOT.$mybb->config['admin_dir']."/inc/functions.php";
 407      }
 408      else if(file_exists(MYBB_ROOT."admin/inc/functions.php"))
 409      {
 410          require_once  MYBB_ROOT."admin/inc/functions.php";
 411      }
 412      else
 413      {
 414          $output->print_error("Please make sure your admin directory is uploaded correctly.");
 415      }
 416  
 417      $output->print_header("Performing Queries");
 418  
 419      echo "<p>Performing necessary upgrade queries..</p>";
 420      flush();
 421  
 422      $db->update_query("spiders", array('name' => 'Bing'), "name='MSN Search'");
 423      $db->update_query("spiders", array('useragent' => 'Googlebot', 'name' => 'Google'), "useragent='google'");
 424      $db->update_query("spiders", array('useragent' => 'Teoma', 'name' => 'Ask.com'), "useragent='ask jeeves'");
 425      $db->delete_query("spiders", "name='Hot Bot'");
 426      $db->update_query("spiders", array('useragent' => 'archive_crawler', 'name' => 'Internet Archive'), "name='Archive.org'");
 427      $db->update_query("spiders", array('name' => 'Alexa Internet'), "useragent='ia_archiver'");
 428      $db->delete_query("spiders", "useragent='scooter'");
 429      $db->update_query("spiders", array('useragent' => 'Slurp'), "name='Yahoo!'");
 430  
 431      $query = $db->simple_select("spiders", "COUNT(*) as numexists", "useragent='twiceler'");
 432      if($db->fetch_field($query, "numexists") == 0)
 433      {
 434          $db->insert_query("spiders", array('name' => "Cuil", 'useragent' => 'twiceler'));
 435      }
 436  
 437      $query = $db->simple_select("spiders", "COUNT(*) as numexists", "useragent='Baiduspider'");
 438      if($db->fetch_field($query, "numexists") == 0)
 439      {
 440          $db->insert_query("spiders", array('name' => "Baidu", 'useragent' => 'Baiduspider'));
 441      }
 442  
 443      $db->update_query("attachtypes", array('mimetype' => 'application/x-httpd-php'), "extension='php'");
 444      $db->update_query("attachtypes", array('mimetype' => 'text/html'), "extension='htm'");
 445      $db->update_query("attachtypes", array('mimetype' => 'text/html'), "extension='html'");
 446      $db->update_query("attachtypes", array('mimetype' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'), "extension='docx'");
 447      $db->update_query("attachtypes", array('mimetype' => 'application/vnd.ms-excel'), "extension='xls'");
 448      $db->update_query("attachtypes", array('mimetype' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'), "extension='xlsx'");
 449      $db->update_query("attachtypes", array('mimetype' => 'application/vnd.ms-powerpoint'), "extension='ppt'");
 450      $db->update_query("attachtypes", array('mimetype' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation'), "extension='pptx'");
 451  
 452      $cache->update_moderators();
 453  
 454      $db->update_query("themes", array('allowedgroups' => 'all'), "allowedgroups='' OR allowedgroups IS NULL");
 455  
 456      // Add permissions for all of our new ACP pages
 457      change_admin_permission('config', 'thread_prefixes');
 458      change_admin_permission('tools', 'file_verification');
 459      change_admin_permission('tools', 'statistics');
 460  
 461      $contents .= "Click next to continue with the upgrade process.</p>";
 462      $output->print_contents($contents);
 463  
 464      global $footer_extra;
 465      $footer_extra = "<script type=\"text/javascript\">$(function() { var button = $('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>";
 466  
 467      $output->print_footer("17_dbchanges6");
 468  }
 469  
 470  function upgrade17_dbchanges6()
 471  {
 472      global $db, $output;
 473  
 474      $output->print_header("Post IP Repair Conversion");
 475  
 476      if(!$_POST['ipspage'])
 477      {
 478          $ipp = 5000;
 479      }
 480      else
 481      {
 482          $ipp = (int)$_POST['ipspage'];
 483      }
 484  
 485      if($_POST['ipstart'])
 486      {
 487          $startat = (int)$_POST['ipstart'];
 488          $upper = $startat+$ipp;
 489          $lower = $startat;
 490      }
 491      else
 492      {
 493          $startat = 0;
 494          $upper = $ipp;
 495          $lower = 1;
 496      }
 497  
 498      $query = $db->simple_select("posts", "COUNT(pid) AS ipcount");
 499      $cnt = $db->fetch_array($query);
 500  
 501      if($upper > $cnt['ipcount'])
 502      {
 503          $upper = $cnt['ipcount'];
 504      }
 505  
 506      echo "<p>Repairing ip {$lower} to {$upper} ({$cnt['ipcount']} Total)</p>";
 507      flush();
 508  
 509      $ipaddress = false;
 510  
 511      $query = $db->simple_select("posts", "ipaddress, pid", "", array('limit_start' => $lower, 'limit' => $ipp));
 512      while($post = $db->fetch_array($query))
 513      {
 514          $db->update_query("posts", array('longipaddress' => (int)my_ip2long($post['ipaddress'])), "pid = '{$post['pid']}'");
 515          $ipaddress = true;
 516      }
 517  
 518      $remaining = $upper-$cnt['ipcount'];
 519      if($remaining && $ipaddress)
 520      {
 521          $nextact = "17_dbchanges6";
 522          $startat = $startat+$ipp;
 523          $contents = "<p><input type=\"hidden\" name=\"ipspage\" value=\"$ipp\" /><input type=\"hidden\" name=\"ipstart\" value=\"$startat\" />Done. Click Next to move on to the next set of post ips.</p>";
 524      }
 525      else
 526      {
 527          $nextact = "17_dbchanges7";
 528          $contents = "<p>Done</p><p>All post ips have been successfully repaired. Click next to continue.</p>";
 529      }
 530      $output->print_contents($contents);
 531  
 532      global $footer_extra;
 533      $footer_extra = "<script type=\"text/javascript\">$(function() { var button = $('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>";
 534  
 535      $output->print_footer($nextact);
 536  }
 537  
 538  function upgrade17_dbchanges7()
 539  {
 540      global $db, $output;
 541  
 542      $output->print_header("User IP Repair Conversion");
 543  
 544      if(!$_POST['ipspage'])
 545      {
 546          $ipp = 5000;
 547      }
 548      else
 549      {
 550          $ipp = (int)$_POST['ipspage'];
 551      }
 552  
 553      if($_POST['ipstart'])
 554      {
 555          $startat = (int)$_POST['ipstart'];
 556          $upper = $startat+$ipp;
 557          $lower = $startat;
 558      }
 559      else
 560      {
 561          $startat = 0;
 562          $upper = $ipp;
 563          $lower = 1;
 564      }
 565  
 566      $query = $db->simple_select("users", "COUNT(uid) AS ipcount");
 567      $cnt = $db->fetch_array($query);
 568  
 569      if($upper > $cnt['ipcount'])
 570      {
 571          $upper = $cnt['ipcount'];
 572      }
 573  
 574      $contents .= "<p>Repairing ip {$lower} to {$upper} ({$cnt['ipcount']} Total)</p>";
 575  
 576      $ipaddress = false;
 577      $update_array = array();
 578  
 579      $query = $db->simple_select("users", "regip, lastip, uid", "", array('limit_start' => $lower, 'limit' => $ipp));
 580      while($user = $db->fetch_array($query))
 581      {
 582          $update_array = array(
 583              'longregip' => (int)my_ip2long($user['regip']),
 584              'longlastip' => (int)my_ip2long($user['lastip'])
 585          );
 586  
 587          $db->update_query("users", $update_array, "uid = '{$user['uid']}'");
 588  
 589          $update_array = array();
 590          $ipaddress = true;
 591      }
 592  
 593      $remaining = $upper-$cnt['ipcount'];
 594      if($remaining && $ipaddress)
 595      {
 596          $nextact = "17_dbchanges7";
 597          $startat = $startat+$ipp;
 598          $contents .= "<p><input type=\"hidden\" name=\"ipspage\" value=\"$ipp\" /><input type=\"hidden\" name=\"ipstart\" value=\"$startat\" />Done. Click Next to move on to the next set of user ips.</p>";
 599      }
 600      else
 601      {
 602          $nextact = "17_redoconfig";
 603          $contents .= "<p>Done</p><p>All user ips have been successfully repaired. Click next to continue.</p>";
 604      }
 605      $output->print_contents($contents);
 606  
 607      global $footer_extra;
 608      $footer_extra = "<script type=\"text/javascript\">$(function() { var button = $('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>";
 609  
 610      $output->print_footer($nextact);
 611  }
 612  
 613  function upgrade17_redoconfig()
 614  {
 615      global $db, $output, $orig_config, $mybb;
 616  
 617      $config = $orig_config;
 618  
 619      $output->print_header("Rewriting config.php");
 620  
 621      if(!is_array($config['memcache']))
 622      {
 623          // Backup our old Config file
 624          @copy(MYBB_ROOT."inc/config.php", MYBB_ROOT."inc/config.backup.php");
 625  
 626          $fh = @fopen(MYBB_ROOT."inc/config.php", "w");
 627          if(!$fh)
 628          {
 629              echo "<p><span style=\"color: red; font-weight: bold;\">Unable to open inc/config.php</span><br />Before the upgrade process can continue, you need to changes the permissions of inc/config.php so it is writable.</p>";
 630              $output->print_footer("17_redoconfig");
 631              exit;
 632          }
 633  
 634          if(!$config['memcache_host'])
 635          {
 636              $config['memcache_host'] = "localhost";
 637          }
 638  
 639          if(!$config['memcache_port'])
 640          {
 641              $config['memcache_port'] = 11211;
 642          }
 643  
 644          $comment = "";
 645  
 646          if(!$db->db_encoding || !$config['database']['encoding'])
 647          {
 648              $comment = " // ";
 649          }
 650  
 651          if(!$config['database']['encoding'])
 652          {
 653              $config['database']['encoding'] = "utf8";
 654          }
 655  
 656          // Update SQLite selection. SQLite 2 is depreciated.
 657          if($config['database']['type'] == 'sqlite2' || $config['database']['type'] == 'sqlite3')
 658          {
 659              $config['database']['type'] = 'sqlite';
 660          }
 661  
 662          // Do we have a read or a write database?
 663          if($config['database']['read'])
 664          {
 665              $database_config = "\$config['database']['type'] = '{$config['database']['type']}';";
 666              foreach(array('read', 'write') as $type)
 667              {
 668                  // Multiple read/write databases?
 669                  if($config['database'][$type][0]['database'])
 670                  {
 671                      $i = 0;
 672                      foreach($config['database'][$type] as $database_connection)
 673                      {
 674                          $database_config .= "
 675  \$config['database']['{$type}'][{$i}]['database'] = '{$database_connection['database']}';
 676  \$config['database']['{$type}'][{$i}]['table_prefix'] = '{$database_connection['table_prefix']}';
 677  \$config['database']['{$type}'][{$i}]['hostname'] = '{$database_connection['hostname']}';
 678  \$config['database']['{$type}'][{$i}]['username'] = '{$database_connection['username']}';
 679  \$config['database']['{$type}'][{$i}]['password'] = '{$database_connection['password']}';";
 680                          ++$i;
 681                      }
 682                  }
 683                  // Just a single database read/write connection
 684                  else
 685                  {
 686                      $database_config .= "
 687  \$config['database']['{$type}']['database'] = '{$config['database'][$type]['database']}';
 688  \$config['database']['{$type}']['table_prefix'] = '{$config['database'][$type]['table_prefix']}';
 689  
 690  \$config['database']['{$type}']['hostname'] = '{$config['database'][$type]['hostname']}';
 691  \$config['database']['{$type}']['username'] = '{$config['database'][$type]['username']}';
 692  \$config['database']['{$type}']['password'] = '{$config['database'][$type]['password']}';";
 693                  }
 694              }
 695          }
 696          // Standard database connection stuff
 697          else
 698          {
 699              $database_config = "\$config['database']['type'] = '{$config['database']['type']}';
 700  \$config['database']['database'] = '{$config['database']['database']}';
 701  \$config['database']['table_prefix'] = '{$config['database']['table_prefix']}';
 702  
 703  \$config['database']['hostname'] = '{$config['database']['hostname']}';
 704  \$config['database']['username'] = '{$config['database']['username']}';
 705  \$config['database']['password'] = '{$config['database']['password']}';
 706  ";
 707          }
 708  
 709          $configdata = "<?php
 710  /**
 711   * Database configuration
 712   *
 713   * Please see the MyBB Docs for advanced
 714   * database configuration for larger installations
 715   * https://docs.mybb.com/
 716   */
 717  
 718  {$database_config}
 719  
 720  /**
 721   * Admin CP directory
 722   *  For security reasons, it is recommended you
 723   *  rename your Admin CP directory. You then need
 724   *  to adjust the value below to point to the
 725   *  new directory.
 726   */
 727  
 728  \$config['admin_dir'] = '{$config['admin_dir']}';
 729  
 730  /**
 731   * Hide all Admin CP links
 732   *  If you wish to hide all Admin CP links
 733   *  on the front end of the board after
 734   *  renaming your Admin CP directory, set this
 735   *  to 1.
 736   */
 737  
 738  \$config['hide_admin_links'] = {$config['hide_admin_links']};
 739  
 740  /**
 741   * Data-cache configuration
 742   *  The data cache is a temporary cache
 743   *  of the most commonly accessed data in MyBB.
 744   *  By default, the database is used to store this data.
 745   *
 746   *  If you wish to use the file system (cache/ directory), MemCache, xcache, or eAccelerator
 747   *  you can change the value below to 'files', 'memcache', 'xcache' or 'eaccelerator' from 'db'.
 748   */
 749  
 750  \$config['cache_store'] = '{$config['cache_store']}';
 751  
 752  /**
 753   * Memcache configuration
 754   *  If you are using memcache as your data-cache,
 755   *  you need to configure the hostname and port
 756   *  of your memcache server below.
 757   *
 758   * If not using memcache, ignore this section.
 759   */
 760  
 761  \$config['memcache']['host'] = '{$config['memcache_host']}';
 762  \$config['memcache']['port'] = {$config['memcache_port']};
 763  
 764  /**
 765   * Super Administrators
 766   *  A comma separated list of user IDs who cannot
 767   *  be edited, deleted or banned in the Admin CP.
 768   *  The administrator permissions for these users
 769   *  cannot be altered either.
 770   */
 771  
 772  \$config['super_admins'] = '{$config['super_admins']}';
 773  
 774  /**
 775   * Database Encoding
 776   *  If you wish to set an encoding for MyBB uncomment
 777   *  the line below (if it isn't already) and change
 778   *  the current value to the mysql charset:
 779   *  http://dev.mysql.com/doc/refman/5.1/en/charset-mysql.html
 780   */
 781  
 782  {$comment}\$config['database']['encoding'] = '{$config['database']['encoding']}';
 783  
 784  /**
 785   * Automatic Log Pruning
 786   *  The MyBB task system can automatically prune
 787   *  various log files created by MyBB.
 788   *  To enable this functionality for the logs below, set the
 789   *  the number of days before each log should be pruned.
 790   *  If you set the value to 0, the logs will not be pruned.
 791   */
 792  
 793  \$config['log_pruning'] = array(
 794      'admin_logs' => {$config['log_pruning']['admin_logs']}, // Administrator logs
 795      'mod_logs' => {$config['log_pruning']['mod_logs']}, // Moderator logs
 796      'task_logs' => {$config['log_pruning']['task_logs']}, // Scheduled task logs
 797      'mail_logs' => {$config['log_pruning']['mail_logs']}, // Mail error logs
 798      'user_mail_logs' => {$config['log_pruning']['user_mail_logs']}, // User mail logs
 799      'promotion_logs' => {$config['log_pruning']['promotion_logs']} // Promotion logs
 800  );
 801  
 802  ?".">";
 803          fwrite($fh, $configdata);
 804          fclose($fh);
 805      }
 806      echo "<p>The configuration file has been successfully rewritten.</p>";
 807      echo "<p>Click next to continue with the upgrade process.</p>";
 808  
 809      global $footer_extra;
 810      $footer_extra = "<script type=\"text/javascript\">$(function() { var button = $('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>";
 811  
 812      $output->print_footer("17_updatecss");
 813  }
 814  function upgrade17_updatecss()
 815  {
 816      global $db, $output, $orig_config, $mybb;
 817  
 818      if(file_exists(MYBB_ROOT.$mybb->config['admin_dir']."/inc/functions_themes.php"))
 819      {
 820          require_once MYBB_ROOT.$mybb->config['admin_dir']."/inc/functions_themes.php";
 821      }
 822      else if(file_exists(MYBB_ROOT."admin/inc/functions_themes.php"))
 823      {
 824          require_once  MYBB_ROOT."admin/inc/functions_themes.php";
 825      }
 826      else
 827      {
 828          $output->print_error("Please make sure your admin directory is uploaded correctly.");
 829      }
 830  
 831      $output->print_header("Updating CSS");
 832  
 833      $query = $db->simple_select("themestylesheets", "*", "name='global.css' OR name='usercp.css'");
 834      while($theme = $db->fetch_array($query))
 835      {
 836          resync_stylesheet($theme);
 837      }
 838  
 839      $query = $db->simple_select("themestylesheets", "*", "name='global.css' OR name='usercp.css'");
 840      while($theme = $db->fetch_array($query))
 841      {
 842          $theme['stylesheet'] = upgrade_css_140_to_160($theme['name'], $theme['stylesheet']);
 843  
 844          // Create stylesheets
 845          cache_stylesheet($theme['tid'], $theme['cachefile'], $theme['stylesheet']);
 846  
 847          $update_stylesheet = array(
 848              "stylesheet" => $db->escape_string($theme['stylesheet']),
 849              "lastmodified" => TIME_NOW
 850          );
 851          $db->update_query("themestylesheets", $update_stylesheet, "sid='{$theme['sid']}'");
 852      }
 853  
 854      echo "<p>The CSS has been successfully updated.</p>";
 855      echo "<p>Click next to continue with the upgrade process.</p>";
 856  
 857      global $footer_extra;
 858      //$footer_extra = "<script type=\"text/javascript\">$(function() { var button = $('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>";
 859  
 860      $output->print_footer("17_done");
 861  }
 862  
 863  function upgrade_css_140_to_160($name, $css)
 864  {
 865      // Update our CSS to the new stuff in 1.6
 866      $parsed_css = css_to_array($css);
 867  
 868      if($name == "global.css")
 869      {
 870          if(is_array($parsed_css))
 871          {
 872              foreach($parsed_css as $class_id => $array)
 873              {
 874                  switch($array['class_name'])
 875                  {
 876                      case '.navigation .active':
 877                          $parsed_css[$class_id]['values'] = str_replace('font-size: small;', 'font-size: 13px;', $array['values']);
 878                          break;
 879                      case '.highlight':
 880                          $parsed_css[$class_id]['values'] = str_replace('padding: 3px;', "padding-top: 3px;\n\tpadding-bottom: 3px;", $array['values']);
 881                          break;
 882                      case '.pm_alert':
 883                      case '.red_alert':
 884                          $parsed_css[$class_id]['values'] .= "\n\tmargin-bottom: 15px;";
 885                          break;
 886                      case '.pagination .pagination_current':
 887                          $parsed_css[$class_id]['values'] .= "\n\tcolor: #000;";
 888                          break;
 889                      default:
 890                  }
 891              }
 892          }
 893  
 894          $to_add = array(
 895              md5('#panel .remember_me input') => array("class_name" => '#panel .remember_me input', "values" => "vertical-align: middle;\n\tmargin-top: -1px;"),
 896              md5('.hiddenrow') => array("class_name" => '.hiddenrow', "values" => 'display: none;'),
 897              md5('.selectall') => array("class_name" => '.selectall', "values" => "background-color: #FFFBD9;\n\tfont-weight: bold;\n\ttext-align: center;"),
 898              md5('.repbox') => array("class_name" => '.repbox', "values" => "font-size:16px;\n\tfont-weight: bold;\n\tpadding:5px 7px 5px 7px;"),
 899              md5('._neutral') => array("class_name" => '._neutral', "values" => "background-color:#FAFAFA;\n\tcolor: #999999;\n\tborder:1px solid #CCCCCC;"),
 900              md5('._minus') => array("class_name" => '._minus', "values" => "background-color: #FDD2D1;\n\tcolor: #CB0200;\n\tborder:1px solid #980201;"),
 901              md5('._plus') => array("class_name" => '._plus', "values" => "background-color:#E8FCDC;\n\tcolor: #008800;\n\tborder:1px solid #008800;"),
 902              md5('.pagination_breadcrumb') => array("class_name" => '.pagination_breadcrumb', "values" => "background-color: #f5f5f5;\n\tborder: 1px solid #fff;\n\toutline: 1px solid #ccc;\n\tpadding: 5px;\n\tmargin-top: 5px;\n\tfont-weight: normal;"),
 903              md5('.pagination_breadcrumb_link') => array("class_name" => '.pagination_breadcrumb_link', "values" => "vertical-align: middle;\n\tcursor: pointer;"),
 904          );
 905      }
 906      else if($name == "usercp.css")
 907      {
 908          $to_add = array(
 909              md5('.usercp_notepad') => array("class_name" => '.usercp_notepad', "values" => "width: 99%;"),
 910              md5('.usercp_container') => array("class_name" => '.usercp_container', "values" => "margin: 5px;\n\tpadding: 8px;\n\tborder:1px solid #CCCCCC;"),
 911          );
 912      }
 913  
 914      foreach($to_add as $class_id => $array)
 915      {
 916          if(isset($already_parsed[$class_id]))
 917          {
 918              $already_parsed[$class_id]++;
 919              $class_id .= "_".$already_parsed[$class_id];
 920          }
 921          else
 922          {
 923              $already_parsed[$class_id] = 1;
 924          }
 925  
 926          $array['name'] = "";
 927          $array['description'] = "";
 928  
 929          $parsed_css[$class_id] = $array;
 930      }
 931  
 932      $css = "";
 933      foreach($parsed_css as $class_id => $array)
 934      {
 935          if($array['name'] || $array['description'])
 936          {
 937              $theme['css'] .= "/* ";
 938              if($array['name'])
 939              {
 940                  $array['css'] .= "Name: {$array['name']}";
 941  
 942                  if($array['description'])
 943                  {
 944                      $array['css'] .= "\n";
 945                  }
 946              }
 947  
 948              if($array['description'])
 949              {
 950                  $array['css'] .= "Description: {$array['description']}";
 951              }
 952  
 953              $array['css'] .= " */\n";
 954          }
 955  
 956          $css .= "{$array['class_name']} {\n\t{$array['values']}\n}\n";
 957      }
 958  
 959      return $css;
 960  }
 961  


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