[ Index ]

PHP Cross Reference of MyBB 1.6.5

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: optimizedb.php 5297 2010-12-28 22:01:14Z Tomm $
  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              $db->optimize_table($table);
  41              $db->analyze_table($table);
  42          }
  43          
  44          $db->set_table_prefix(TABLE_PREFIX);
  45          
  46          $plugins->run_hooks("admin_tools_optimizedb_start_begin");
  47          
  48          // Log admin action
  49          log_admin_action(serialize($mybb->input['tables']));
  50          
  51          flash_message($lang->success_tables_optimized, 'success');
  52          admin_redirect("index.php?module=tools-optimizedb");
  53      }
  54      
  55      $page->extra_header = "    <script type=\"text/javascript\">
  56  	function changeSelection(action, prefix)
  57      {
  58          var select_box = document.getElementById('table_select');
  59          
  60          for(var i = 0; i < select_box.length; i++)
  61          {
  62              if(action == 'select')
  63              {
  64                  select_box[i].selected = true;
  65              }
  66              else if(action == 'deselect')
  67              {
  68                  select_box[i].selected = false;
  69              }
  70              else if(action == 'forum' && prefix != 0)
  71              {
  72                  select_box[i].selected = false;
  73                  var row = select_box[i].value;
  74                  var subString = row.substring(prefix.length, 0);
  75                  if(subString == prefix)
  76                  {
  77                      select_box[i].selected = true;
  78                  }
  79              }
  80          }
  81      }
  82      </script>\n";
  83      
  84      $page->output_header($lang->optimize_database);
  85  
  86      $table = new Table;
  87      $table->construct_header($lang->table_selection);
  88      
  89      $table_selects = array();
  90      $table_list = $db->list_tables($config['database']['database']);
  91      foreach($table_list as $id => $table_name)
  92      {
  93          $table_selects[$table_name] = $table_name;
  94      }
  95      
  96      $form = new Form("index.php?module=tools-optimizedb", "post", "table_selection", 0, "table_selection");
  97      
  98      $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%'));
  99      $table->construct_row();
 100          
 101      $table->output($lang->optimize_database);
 102      
 103      $buttons[] = $form->generate_submit_button($lang->optimize_selected_tables);
 104      $form->output_submit_wrapper($buttons);
 105      
 106      $form->end();
 107          
 108      $page->output_footer();
 109  }
 110  
 111  ?>


Generated: Sun Dec 11 14:16:27 2011 Cross-referenced by PHPXref 0.7.1