[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/inc/tasks/ -> checktables.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  function task_checktables($task)
  12  {
  13      global $db, $mybb, $lang, $plugins;
  14  
  15      if(!in_array($db->type, array('mysql', 'mysqli')))
  16      {
  17          return;
  18      }
  19  
  20      @set_time_limit(0);
  21  
  22      $ok = array(
  23          "The storage engine for the table doesn't support check",
  24          "Table is already up to date",
  25          "OK"
  26      );
  27  
  28      $comma = "";
  29      $tables_list = "";
  30      $repaired = array();
  31      $setting_done = false;
  32  
  33      $tables = $db->list_tables($mybb->config['database']['database'], $mybb->config['database']['table_prefix']);
  34      foreach($tables as $key => $table)
  35      {
  36          $tables_list .= "{$comma}{$table} ";
  37          $comma = ",";
  38      }
  39  
  40      if($tables_list)
  41      {
  42          $query = $db->query("CHECK TABLE {$tables_list}CHANGED;");
  43          while($table = $db->fetch_array($query))
  44          {
  45              if(!in_array($table['Msg_text'], $ok))
  46              {
  47                  if($table['Table'] != $mybb->config['database']['database'].".".TABLE_PREFIX."settings" && $setting_done != true)
  48                  {
  49                      $boardclosed = $mybb->settings['boardclosed'];
  50                      $boardclosed_reason = $mybb->settings['boardclosed_reason'];
  51  
  52                      $db->update_query("settings", array('value' => 1), "name='boardclosed'", 1);
  53                      $db->update_query("settings", array('value' => $db->escape_string($lang->error_database_repair)), "name='boardclosed_reason'", 1);
  54                      rebuild_settings();
  55  
  56                      $setting_done = true;
  57                  }
  58  
  59                  $db->query("REPAIR TABLE {$table['Table']}");
  60                  $repaired[] = $table['Table'];
  61              }
  62          }
  63  
  64          if($setting_done == true)
  65          {
  66              $db->update_query("settings", array('value' => (int)$boardclosed), "name='boardclosed'", 1);
  67              $db->update_query("settings", array('value' => $db->escape_string($boardclosed_reason)), "name='boardclosed_reason'", 1);
  68  
  69              rebuild_settings();
  70          }
  71  
  72      }
  73  
  74      if(is_object($plugins))
  75      {
  76          $plugins->run_hooks('task_checktables', $task);
  77      }
  78  
  79      if(!empty($repaired))
  80      {
  81          add_task_log($task, $lang->sprintf($lang->task_checktables_ran_found, implode(', ', $repaired)));
  82      }
  83      else
  84      {
  85          add_task_log($task, $lang->task_checktables_ran);
  86      }
  87  }


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