[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/admin/modules/tools/ -> optimizedb.php (source)

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


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1