// (optimize, repair, analyze,..
                $msgType = isset($row['Msg_type']) ? $row['Msg_type'] : '';
                $msgTxt = isset($row['Msg_text']) ? $row['Msg_text'] : '';
                $tplSqlbrowserTableOperation->assign_block_vars('ROW', array('ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1', 'NR' => $i + 1, 'TABLENAME' => $table, 'ACTION' => isset($row['Op']) ? $row['Op'] : '', 'TYPE' => $msgType, 'MESSAGE' => $msgTxt));
            }
        } else {
            // error
            $tplSqlbrowserTableOperation->assign_block_vars('ERROR', array('ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1', 'NR' => $i + 1, 'TABLENAME' => $table, 'ERROR' => mysql_error(), 'QUERY' => sprintf($query, $db, $table)));
        }
        $i++;
    }
}
// Output list of tables of the selected database
$tableInfos = getTableInfo($db);
// extract sorted one-dimensional array with infos we need
$orderArray = get_orderarray($sortColumn . ',' . $sortDirection . '|name,a');
$sortedTableInfos = arfsort($tableInfos[$db]['tables'], $orderArray);
$tplSqlbrowserTableListTables = new MSDTemplate();
$tplSqlbrowserTableListTables->set_filenames(array('tplSqlbrowserTableListTables' => 'tpl/sqlbrowser/table/listTables.tpl'));
$numrows = $tableInfos[$db]['table_count'];
$up = $icon['arrow_up'];
$down = $icon['arrow_down'];
$sortName = $sortColumn == 'name' ? $sortDirection == 'd' ? $down : $up : '';
$sD = $sortDirection;
$sC = $sortColumn;
$tplSqlbrowserTableListTables->assign_vars(array('ICON_VIEW' => $icon['view'], 'ICON_EDIT' => $icon['edit'], 'ICON_OK' => $icon['ok'], 'ICON_NOT_OK' => $icon['not_ok'], 'ICON_DELETE' => $icon['delete'], 'ICON_TRUNCATE' => $icon['truncate'], 'ICON_UP' => $up, 'ICON_DOWN' => $down, 'ICON_PLUS' => $icon['plus'], 'ICON_MINUS' => $icon['minus'], 'ICON_CANCEL' => $icon['cancel'], 'DB_NAME' => $db, 'DB_NAME_URLENCODED' => base64_encode($db), 'TABLE_COUNT' => String::formatNumber($numrows), 'ICONPATH' => $config['files']['iconpath'], 'SORT_BY_COLUMN' => $sC, 'SORT_DIRECTION' => $sD, 'SORT_NAME' => $sortName, 'SORT_RECORDS' => $sC == 'records' ? $sD == 'D' ? $down : $up : '', 'SORT_DATA_LENGTH' => $sC == 'data_length' ? $sD == 'D' ? $down : $up : '', 'SORT_INDEX_LENGTH' => $sC == 'index_length' ? $sD == 'D' ? $down : $up : '', 'SORT_AUTO_INCREMENT' => $sC == 'auto_increment' ? $sD == 'D' ? $down : $up : '', 'SORT_DATA_FREE' => $sC == 'data_free' ? $sD == 'D' ? $down : $up : '', 'SORT_UPDATE_TIME' => $sC == 'update_time' ? $sD == 'd' ? $down : $up : '', 'SORT_ENGINE' => $sC == 'engine' ? $sD == 'd' ? $down : $up : '', 'SORT_COLLATION' => $sC == 'collation' ? $sD == 'd' ? $down : $up : '', 'SORT_COMMENT' => $sC == 'comment' ? $sD == 'd' ? $down : $up : '', 'CONFIRM_TRUNCATE_TABLES' => Html::getJsQuote($lang['L_CONFIRM_TRUNCATE_TABLES']), 'CONFIRM_DELETE_TABLES' => Html::getJsQuote($lang['L_CONFIRM_DELETE_TABLES'])));
if ($numrows > 1) {
    $tplSqlbrowserTableListTables->assign_block_vars('MORE_TABLES', array());
} elseif ($numrows == 1) {
    $tplSqlbrowserTableListTables->assign_block_vars('1_TABLE', array());
} elseif ($numrows == 0) {
/**
 * Read information from all backup files in folder work/backup and return multidimensional array
 * containing all info.
 *
 * @return array
 */
function getBackupfileInfo()
{
    global $config;
    clearstatcache();
    $files = array();
    $dh = opendir($config['paths']['backup']);
    while (false !== ($filename = readdir($dh))) {
        if ($filename != '.' && $filename != '..' && !is_dir($config['paths']['backup'] . $filename)) {
            $files[]['name'] = $filename;
        }
    }
    $arrayindex = 0;
    $total_filesize = 0;
    $db_backups = array();
    $db_summary_anzahl = array();
    $db_summary_last = array();
    if (count($files) > 0) {
        for ($i = 0; $i < sizeof($files); $i++) {
            // filesize
            $size = filesize($config['paths']['backup'] . $files[$i]['name']);
            $file_datum = date("d\\.m\\.Y H:i", filemtime($config['paths']['backup'] . $files[$i]['name']));
            $statusline = ReadStatusline($files[$i]['name']);
            $backup_timestamp = GetTimestampFromFilename($files[$i]['name']);
            $pathinfo = pathinfo($files[$i]['name']);
            $file_extension = $pathinfo['extension'];
            if ($backup_timestamp == '') {
                $backup_timestamp = $file_datum;
            }
            $database_name = $statusline['dbname'];
            // check for some special cases
            if ($database_name == 'unknown') {
                $database_name = '~unknown';
            }
            // needed for sorting - place unknown files at the end
            if ($statusline['comment'] == 'converted') {
                $database_name = '~converted';
            }
            // converted fiels
            //jetzt alle in ein Array packen
            if ($statusline['part'] == 'MP_0' || $statusline['part'] == '') {
                $db_backups[$arrayindex]['name'] = $files[$i]['name'];
                $db_backups[$arrayindex]['db'] = $database_name;
                $db_backups[$arrayindex]['extension'] = $file_extension;
                $db_backups[$arrayindex]['size'] = $size;
                $db_backups[$arrayindex]['date'] = $backup_timestamp;
                $db_backups[$arrayindex]['sort'] = getSortableDate($backup_timestamp);
                $db_backups[$arrayindex]['tables'] = $statusline['tables'];
                $db_backups[$arrayindex]['records'] = $statusline['records'];
                $db_backups[$arrayindex]['multipart'] = 0;
                $db_backups[$arrayindex]['comment'] = $statusline['comment'];
                $db_backups[$arrayindex]['script'] = $statusline['script'] != '' ? $statusline['script'] . '(' . $statusline['scriptversion'] . ')' : '';
                $db_backups[$arrayindex]['charset'] = $statusline['charset'];
                $db_backups[$arrayindex]['mysqlversion'] = $statusline['mysqlversion'];
                if (!isset($db_summary_last[$database_name])) {
                    $db_summary_last[$database_name] = $backup_timestamp;
                }
                $db_summary_anzahl[$database_name] = isset($db_summary_anzahl[$database_name]) ? $db_summary_anzahl[$database_name] + 1 : 1;
                $db_summary_size[$database_name] = isset($db_summary_size[$database_name]) ? $db_summary_size[$database_name] + $size : $size;
                if (getSortableDate($backup_timestamp) > getSortableDate($db_summary_last[$database_name])) {
                    $db_summary_last[$database_name] = $backup_timestamp;
                }
            } else {
                //v($statusline);
                //list multipart files only once but keep info how many files belong to this backup
                $done = 0;
                if (!isset($db_summary_size[$database_name])) {
                    $db_summary_size[$database_name] = 0;
                }
                for ($j = 0; $j < $arrayindex; $j++) {
                    if (isset($db_backups[$j])) {
                        if ($db_backups[$j]['date'] == $backup_timestamp && $db_backups[$j]['db'] == $database_name && $db_backups[$j]['extension'] == $file_extension) {
                            $db_backups[$j]['mysqlversion'] = $statusline['mysqlversion'];
                            $db_backups[$j]['multipart']++;
                            $db_backups[$j]['size'] += $size;
                            // calculate size for this multipart backup
                            $db_summary_size[$database_name] += $size;
                            // calculate total size for this database
                            $done = 1;
                            break;
                        }
                    }
                }
                if ($done == 1) {
                    $arrayindex--;
                }
                if ($done == 0) {
                    //new entry for this backup with this timestamp
                    $db_backups[$arrayindex]['name'] = $files[$i]['name'];
                    $db_backups[$arrayindex]['db'] = $database_name;
                    $db_backups[$arrayindex]['extension'] = $file_extension;
                    $db_backups[$arrayindex]['size'] = $size;
                    $db_backups[$arrayindex]['date'] = $backup_timestamp;
                    $db_backups[$arrayindex]['sort'] = getSortableDate($backup_timestamp);
                    $db_backups[$arrayindex]['tables'] = $statusline['tables'];
                    $db_backups[$arrayindex]['records'] = $statusline['records'];
                    $db_backups[$arrayindex]['multipart'] = 1;
                    $db_backups[$arrayindex]['comment'] = $statusline['comment'];
                    $db_backups[$arrayindex]['script'] = $statusline['script'] != "" ? $statusline['script'] . "(" . $statusline['scriptversion'] . ")" : "";
                    $db_backups[$arrayindex]['charset'] = $statusline['charset'];
                    if (!isset($db_summary_last[$database_name])) {
                        $db_summary_last[$database_name] = $backup_timestamp;
                    }
                    $db_summary_anzahl[$database_name] = isset($db_summary_anzahl[$database_name]) ? $db_summary_anzahl[$database_name] + 1 : 1;
                    $db_summary_size[$database_name] = isset($db_summary_size[$database_name]) ? $db_summary_size[$database_name] + $size : $size;
                    if (getSortableDate($backup_timestamp) > getSortableDate($db_summary_last[$database_name])) {
                        $db_summary_last[$database_name] = $backup_timestamp;
                    }
                }
            }
            $arrayindex++;
            $total_filesize += $size;
            // calculate overall file size
        }
    }
    if (isset($db_backups) && is_array($db_backups)) {
        $db_backups = arfsort($db_backups, get_orderarray('sort,d|name,A'));
    }
    // merge infos into one array
    $info = array();
    $info['filesize_total'] = $total_filesize;
    // total size of all files
    $info['files'] = $db_backups;
    // info per file
    unset($db_backups);
    $info['databases'] = array();
    foreach ($db_summary_anzahl as $db => $count) {
        $info['databases'][$db]['backup_count'] = $count;
        $info['databases'][$db]['backup_size_total'] = $db_summary_size[$db];
        $info['databases'][$db]['latest_backup_timestamp'] = $db_summary_last[$db];
    }
    return $info;
}