/**
  * Validate all tables in the database
  */
 function tables()
 {
     global $table_prefix, $template, $user;
     $tables_confirm = request_var('tables_confirm', false);
     if (!$tables_confirm) {
         $found_tables = get_phpbb_tables();
         $req_tables = $this->db_cleaner->data->tables;
         $tables = array_unique(array_merge(array_keys($req_tables), $found_tables));
         sort($tables);
         $this->_section_data['tables'] = array('NAME' => 'DATABASE_TABLES', 'TITLE' => 'DATABASE_TABLES');
         foreach ($tables as $table) {
             // Table was added or removed
             if (!isset($req_tables[$table]) && in_array($table, $found_tables) || isset($req_tables[$table]) && !in_array($table, $found_tables)) {
                 $this->_section_data['tables']['ITEMS'][] = array('NAME' => $table, 'FIELD_NAME' => $table, 'MISSING' => isset($req_tables[$table]) ? true : false, 'FIND' => append_sid("" . STK_ROOT_PATH . "finder." . PHP_EXT . "", 't=' . $table . ''));
                 if ($this->_has_changes === false) {
                     $this->_has_changes = true;
                 }
             }
         }
         $template->assign_vars(array('NO_CHANGES_TEXT' => $user->lang['SECTION_NOT_CHANGED_EXPLAIN'][$this->db_cleaner->step_to_action[$this->db_cleaner->step]], 'NO_CHANGES_TITLE' => $user->lang['SECTION_NOT_CHANGED_TITLE'][$this->db_cleaner->step_to_action[$this->db_cleaner->step]]));
         // A bit nasty but the only real work around at this moment
         if (empty($table_prefix) && $this->_has_changes) {
             $this->_u_next_step = append_sid(STK_INDEX, array('c' => 'support', 't' => 'database_cleaner', 'step' => $this->db_cleaner->step, 'submit' => false, 'tables_confirm' => true));
         }
         $this->success_message = 'BOARD_DISABLE_SUCCESS';
     } else {
         // I'n not sure why request_var doesn't work here so we'll do it a bit different
         $tables = array();
         $tems = request_var('items', array(''));
         foreach ($tems as $table => $value) {
             set_var($table, $table, 'string', true);
             set_var($value, $value, 'string', true);
             $tables["items[{$table}]"] = $value;
         }
         $this->_hidden_fields = $tables;
         $this->_confirm_box = array('title' => 'EMPTY_PREFIX', 'message' => 'EMPTY_PREFIX_CONFIRM');
     }
 }
 /**
  * Correct the database tables based upon the selection
  * the user made before.
  *
  * - Add removed tables
  * - Removed added tables
  */
 function tables(&$error, $selected)
 {
     global $umil;
     $found_tables = get_phpbb_tables();
     $req_tables = $this->db_cleaner->data->tables;
     $tables = array_unique(array_merge(array_keys($req_tables), $found_tables));
     sort($tables);
     // Loop through selected and fix them
     foreach (array_keys($selected) as $table) {
         if (isset($req_tables[$table]) && !in_array($table, $found_tables)) {
             $result = $umil->table_add($table, $req_tables[$table]);
             if (stripos($result, 'SQL ERROR')) {
                 $error[] = $result;
             }
         } else {
             if (!isset($req_tables[$table]) && in_array($table, $found_tables)) {
                 $result = $umil->table_remove($table);
                 if (stripos($result, 'SQL ERROR')) {
                     $error[] = $result;
                 }
             }
         }
     }
 }
 /**
  * Validate all tables in the database
  */
 function tables()
 {
     global $table_prefix;
     if (!isset($_REQUEST['tables_confirm'])) {
         $found_tables = get_phpbb_tables();
         $req_tables = $this->db_cleaner->data->tables;
         $tables = array_unique(array_merge(array_keys($req_tables), $found_tables));
         sort($tables);
         $this->_section_data['tables'] = array('NAME' => 'DATABASE_TABLES', 'TITLE' => 'DATABASE_TABLES');
         foreach ($tables as $table) {
             // Table was added or removed
             if (!isset($req_tables[$table]) && in_array($table, $found_tables) || isset($req_tables[$table]) && !in_array($table, $found_tables)) {
                 $this->_section_data['tables']['ITEMS'][] = array('NAME' => $table, 'FIELD_NAME' => $table, 'MISSING' => isset($req_tables[$table]) ? true : false);
                 if ($this->_has_changes === false) {
                     $this->_has_changes = true;
                 }
             }
         }
         // A bit nasty but the only real work around at this moment
         if (empty($table_prefix) && $this->_has_changes) {
             $this->_u_next_step = append_sid(STK_INDEX, array('c' => 'support', 't' => 'database_cleaner', 'step' => $this->db_cleaner->step, 'submit' => false, 'tables_confirm' => true));
         }
         $this->success_message = 'BOARD_DISABLE_SUCCESS';
     } else {
         // I'n not sure why request_var doesn't work here so we'll do it a bit different
         $tables = array();
         foreach ($_REQUEST['items'] as $table => $value) {
             set_var($table, $table, 'string', true);
             set_var($value, $value, 'string', true);
             $tables["items[{$table}]"] = $value;
         }
         $this->_hidden_fields = $tables;
         $this->_confirm_box = array('title' => 'EMPTY_PREFIX', 'message' => 'EMPTY_PREFIX_CONFIRM');
     }
 }