[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/admin/modules/tools/ -> optimizedb.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  // Disallow direct access to this file for security reasons
  12  if(!defined("IN_MYBB"))
  13  {
  14      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  15  }
  16  
  17  $page->add_breadcrumb_item($lang->optimize_database, "index.php?module=tools-optimizedb");
  18  
  19  $plugins->run_hooks("admin_tools_optimizedb_begin");
  20  
  21  if(!$mybb->input['action'])
  22  {
  23      $plugins->run_hooks("admin_tools_optimizedb_start");
  24  
  25      if($mybb->request_method == "post")
  26      {
  27          if(empty($mybb->input['tables']) || !is_array($mybb->input['tables']))
  28          {
  29              flash_message($lang->error_no_tables_selected, 'error');
  30              admin_redirect("index.php?module=tools-optimizedb");
  31          }
  32  
  33          @set_time_limit(0);
  34  
  35          $db->set_table_prefix('');
  36  
  37          foreach($mybb->input['tables'] as $table)
  38          {
  39              if($db->table_exists($db->escape_string($table)))
  40              {
  41                  $db->optimize_table($table);
  42                  $db->analyze_table($table);
  43              }
  44          }
  45  
  46          $db->set_table_prefix(TABLE_PREFIX);
  47  
  48          $plugins->run_hooks("admin_tools_optimizedb_start_begin");
  49  
  50          // Log admin action
  51          log_admin_action(my_serialize($mybb->input['tables']));
  52  
  53          flash_message($lang->success_tables_optimized, 'success');
  54          admin_redirect("index.php?module=tools-optimizedb");
  55      }
  56  
  57      $page->extra_header = "    <script type=\"text/javascript\">
  58  	function changeSelection(action, prefix)
  59      {
  60          var select_box = document.getElementById('table_select');
  61  
  62          for(var i = 0; i < select_box.length; i++)
  63          {
  64              if(action == 'select')
  65              {
  66                  select_box[i].selected = true;
  67              }
  68              else if(action == 'deselect')
  69              {
  70                  select_box[i].selected = false;
  71              }
  72              else if(action == 'forum' && prefix != 0)
  73              {
  74                  select_box[i].selected = false;
  75                  var row = select_box[i].value;
  76                  var subString = row.substring(prefix.length, 0);
  77                  if(subString == prefix)
  78                  {
  79                      select_box[i].selected = true;
  80                  }
  81              }
  82          }
  83      }
  84      </script>\n";
  85  
  86      $page->output_header($lang->optimize_database);
  87  
  88      $table = new Table;
  89      $table->construct_header($lang->table_selection);
  90  
  91      $table_selects = array();
  92      $table_list = $db->list_tables($config['database']['database']);
  93      foreach($table_list as $id => $table_name)
  94      {
  95          $table_selects[$table_name] = $table_name;
  96      }
  97  
  98      $form = new Form("index.php?module=tools-optimizedb", "post", "table_selection", 0, "table_selection");
  99  
 100      $table->construct_cell("{$lang->tables_select_desc}\n<br /><br />\n<a href=\"javascript:changeSelection('select', 0);\">{$lang->select_all}</a><br />\n<a href=\"javascript:changeSelection('deselect', 0);\">{$lang->deselect_all}</a><br />\n<a href=\"javascript:changeSelection('forum', '".TABLE_PREFIX."');\">{$lang->select_forum_tables}</a>\n<br /><br />\n<div class=\"form_row\">".$form->generate_select_box("tables[]", $table_selects, false, array('multiple' => true, 'id' => 'table_select', 'size' => 20))."</div>", array('rowspan' => 5, 'width' => '50%'));
 101      $table->construct_row();
 102  
 103      $table->output($lang->optimize_database);
 104  
 105      $buttons[] = $form->generate_submit_button($lang->optimize_selected_tables);
 106      $form->output_submit_wrapper($buttons);
 107  
 108      $form->end();
 109  
 110      $page->output_footer();
 111  }
 112  


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