Beispiel #1
0
/**
 * Function to check over array of indexes and look for common problems
 *
 * @uses    $GLOBALS['strIndexesSeemEqual']
 * @uses    PMA_get_indexes()
 * @uses    is_string()
 * @uses    is_array()
 * @uses    count()
 * @uses    array_pop()
 * @uses    reset()
 * @uses    current()
 * @access  public
 * @param   mixed       array of indexes from PMA_get_indexes()
 *                      or name of table
 * @return  string      Output HTML
 */
function PMA_check_indexes($idx_collection)
{
    if (is_string($idx_collection)) {
        $idx_collection = PMA_get_indexes($idx_collection);
    }
    // count($idx_collection) < 2:
    //   there is no need to check if there less than two indexes
    if (!is_array($idx_collection) || count($idx_collection) < 2) {
        return false;
    }
    $indexes = array();
    foreach ($idx_collection as $index_field) {
        $indexes[$index_field['Key_name']][$index_field['Column_name']] = $index_field;
    }
    $output = '';
    // remove last index from stack and ...
    while ($while_index = array_pop($indexes)) {
        // ... compare with every remaining index in stack
        foreach ($indexes as $each_index_name => $each_index) {
            if (count($while_index) !== count($each_index)) {
                // number of fields are not equal
                continue;
            }
            // compare some key elements of every column in this two indexes
            foreach ($each_index as $col_name => $each_index_column) {
                if (!isset($while_index[$col_name]) || $while_index[$col_name]['Seq_in_index'] !== $each_index_column['Seq_in_index'] || $while_index[$col_name]['Collation'] !== $each_index_column['Collation'] || $while_index[$col_name]['Sub_part'] !== $each_index_column['Sub_part'] || $while_index[$col_name]['Index_type'] !== $each_index_column['Index_type']) {
                    continue 2;
                }
            }
            // did not find any difference
            // so it makes no sense to have this two equal indexes
            // use first column from index to fetch index name
            reset($while_index);
            $first_column = current($while_index);
            $output .= '<div class="warning">';
            $output .= $GLOBALS['strIndexesSeemEqual'] . ' ';
            $output .= $each_index_name . ', ' . $first_column['Key_name'];
            $output .= '</div>';
            // there is no need to check any further indexes if we have already
            // found that this one has a duplicate
            continue 2;
        }
    }
    if ($output) {
        $output = '<tr><td colspan=7">' . $output . '</td></tr>';
    }
    return $output;
}
/**
 * Displays the headers of the results table
 *
 * @param   array    which elements to display
 * @param   array    the list of fields properties
 * @param   integer  the total number of fields returned by the sql query
 * @param   array    the analyzed query
 *
 * @return  boolean  always true
 *
 * @global  string   $db               the database name
 * @global  string   $table            the table name
 * @global  string   $goto             the url to go back in case of errors
 * @global  boolean  $dontlimitchars   whether to limit the number of displayed
 *                                     characters of text type fields or not
 * @global  string   $sql_query        the sql query
 * @global  integer  $num_rows         the total number of rows returned by the
 *                                     sql query
 * @global  integer  $pos              the current position in results
 * @global  integer  $session_max_rows the maximum number of rows per page
 * @global  array    $vertical_display informations used with vertical display
 *                                     mode
 * @global  string   $disp_direction   the display mode
 *                                     (horizontal/vertical/horizontalflipped)
 * @global  integer  $repeat_cellsthe  number of row to display between two
 *                                     table headers
 *
 * @access  private
 *
 * @see     PMA_displayTable()
 */
function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '')
{
    global $db, $table, $goto, $dontlimitchars;
    global $sql_query, $num_rows, $pos, $session_max_rows;
    global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
    if ($analyzed_sql == '') {
        $analyzed_sql = array();
    }
    // can the result be sorted?
    if ($is_display['sort_lnk'] == '1') {
        // Just as fallback
        $unsorted_sql_query = $sql_query;
        if (isset($analyzed_sql[0]['unsorted_query'])) {
            $unsorted_sql_query = $analyzed_sql[0]['unsorted_query'];
        }
        // we need $sort_expression and $sort_expression_nodir
        // even if there are many table references
        $sort_expression = trim(str_replace('  ', ' ', $analyzed_sql[0]['order_by_clause']));
        // Get rid of ASC|DESC (TODO: analyzer)
        preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches);
        $sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
        // sorting by indexes, only if it makes sense (only one table ref)
        if (isset($analyzed_sql) && isset($analyzed_sql[0]) && isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' && isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) {
            // grab indexes data:
            PMA_DBI_select_db($db);
            if (!defined('PMA_IDX_INCLUDED')) {
                $ret_keys = PMA_get_indexes($table);
            }
            $prev_index = '';
            foreach ($ret_keys as $row) {
                if ($row['Key_name'] != $prev_index) {
                    $indexes[] = $row['Key_name'];
                    $prev_index = $row['Key_name'];
                }
                $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
                $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
                if (isset($row['Cardinality'])) {
                    $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
                }
                //    I don't know what does the following column mean....
                //    $indexes_info[$row['Key_name']]['Packed']          = $row['Packed'];
                $indexes_info[$row['Key_name']]['Comment'] = isset($row['Comment']) ? $row['Comment'] : '';
                $indexes_info[$row['Key_name']]['Index_type'] = isset($row['Index_type']) ? $row['Index_type'] : '';
                $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
                if (isset($row['Sub_part'])) {
                    $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
                }
            }
            // end while
            // do we have any index?
            if (isset($indexes_data)) {
                if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
                    $span = $fields_cnt;
                    if ($is_display['edit_lnk'] != 'nn') {
                        $span++;
                    }
                    if ($is_display['del_lnk'] != 'nn') {
                        $span++;
                    }
                    if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') {
                        $span++;
                    }
                } else {
                    $span = $num_rows + floor($num_rows / $repeat_cells) + 1;
                }
                echo '<form action="sql.php" method="post">' . "\n";
                echo PMA_generate_common_hidden_inputs($db, $table, 5);
                echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
                echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
                echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
                echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
                echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
                echo $GLOBALS['strSortByKey'] . ': <select name="sql_query">' . "\n";
                $used_index = false;
                $local_order = isset($sort_expression) ? $sort_expression : '';
                foreach ($indexes_data as $key => $val) {
                    $asc_sort = '';
                    $desc_sort = '';
                    foreach ($val as $key2 => $val2) {
                        $asc_sort .= PMA_backquote($val2['Column_name']) . ' ASC , ';
                        $desc_sort .= PMA_backquote($val2['Column_name']) . ' DESC , ';
                    }
                    $asc_sort = substr($asc_sort, 0, -3);
                    $desc_sort = substr($desc_sort, 0, -3);
                    $used_index = $used_index || $local_order == $asc_sort || $local_order == $desc_sort;
                    echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $asc_sort) . '"' . ($local_order == $asc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strAscending'] . ')</option>';
                    echo "\n";
                    echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $desc_sort) . '"' . ($local_order == $desc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strDescending'] . ')</option>';
                    echo "\n";
                }
                echo '<option value="' . htmlspecialchars($unsorted_sql_query) . '"' . ($used_index ? '' : ' selected="selected"') . '>' . $GLOBALS['strNone'] . '</option>';
                echo "\n";
                echo '</select>' . "\n";
                echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
                echo "\n";
                echo '</form>' . "\n";
            }
        }
    }
    $vertical_display['emptypre'] = 0;
    $vertical_display['emptyafter'] = 0;
    $vertical_display['textbtn'] = '';
    // Start of form for multi-rows delete
    if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp') {
        echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm" id="rowsDeleteForm">' . "\n";
        echo PMA_generate_common_hidden_inputs($db, $table, 1);
        echo '<input type="hidden" name="disp_direction"   value="' . $disp_direction . '" />' . "\n";
        echo '<input type="hidden" name="repeat_cells"     value="' . $repeat_cells . '" />' . "\n";
        echo '<input type="hidden" name="dontlimitchars"   value="' . $dontlimitchars . '" />' . "\n";
        echo '<input type="hidden" name="pos"              value="' . $pos . '" />' . "\n";
        echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
        echo '<input type="hidden" name="goto"             value="sql.php" />' . "\n";
    }
    echo '<table id="table_results" class="data">' . "\n";
    if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
        echo '<thead><tr>' . "\n";
    }
    // 1. Displays the full/partial text button (part 1)...
    if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
        $colspan = $is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn' ? ' colspan="3"' : '';
    } else {
        $rowspan = $is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn' ? ' rowspan="3"' : '';
    }
    $text_url = 'sql.php?' . PMA_generate_common_url($db, $table) . '&amp;sql_query=' . urlencode($sql_query) . '&amp;session_max_rows=' . $session_max_rows . '&amp;pos=' . $pos . '&amp;disp_direction=' . $disp_direction . '&amp;repeat_cells=' . $repeat_cells . '&amp;goto=' . $goto . '&amp;dontlimitchars=' . ($dontlimitchars ? 0 : 1);
    $text_message = '<img class="fulltext" src="' . $GLOBALS['pmaThemeImage'] . 's_' . ($dontlimitchars ? 'partialtext' : 'fulltext') . '.png" width="50" height="20" alt="' . ($dontlimitchars ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" title="' . ($dontlimitchars ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" />';
    $text_link = PMA_linkOrButton($text_url, $text_message, array(), false);
    //     ... before the result table
    if ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn' && $is_display['text_btn'] == '1') {
        $vertical_display['emptypre'] = $is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn' ? 3 : 0;
        if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
            ?>
    <th colspan="<?php 
            echo $fields_cnt;
            ?>
"><?php 
            echo $text_link;
            ?>
</th>
</tr>
<tr>
            <?php 
        } else {
            ?>
<tr>
    <th colspan="<?php 
            echo $num_rows + floor($num_rows / $repeat_cells) + 1;
            ?>
">
        <?php 
            echo $text_link;
            ?>
</th>
</tr>
            <?php 
        }
        // end vertical mode
    } elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && $is_display['text_btn'] == '1') {
        $vertical_display['emptypre'] = $is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn' ? 3 : 0;
        if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
            ?>
    <th <?php 
            echo $colspan;
            ?>
><?php 
            echo $text_link;
            ?>
</th>
            <?php 
        } else {
            $vertical_display['textbtn'] = '    <th ' . $rowspan . ' valign="middle">' . "\n" . '        ' . $text_link . "\n" . '    </th>' . "\n";
        }
        // end vertical mode
    } elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) {
        $vertical_display['emptypre'] = $is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn' ? 3 : 0;
        if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
            ?>
    <td<?php 
            echo $colspan;
            ?>
></td>
            <?php 
        } else {
            $vertical_display['textbtn'] = '    <td' . $rowspan . '></td>' . "\n";
        }
        // end vertical mode
    }
    // 2. Displays the fields' name
    // 2.0 If sorting links should be used, checks if the query is a "JOIN"
    //     statement (see 2.1.3)
    // 2.0.1 Prepare Display column comments if enabled ($GLOBALS['cfg']['ShowBrowseComments']).
    //       Do not show comments, if using horizontalflipped mode, because of space usage
    if ($GLOBALS['cfg']['ShowBrowseComments'] && ($GLOBALS['cfgRelation']['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) && $disp_direction != 'horizontalflipped') {
        $comments_map = array();
        if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) {
            foreach ($analyzed_sql[0]['table_ref'] as $tbl) {
                $tb = $tbl['table_true_name'];
                $comments_map[$tb] = PMA_getComments($db, $tb);
                unset($tb);
            }
        }
    }
    if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
        require_once './libraries/transformations.lib.php';
        $GLOBALS['mime_map'] = PMA_getMIME($db, $table);
    }
    if ($is_display['sort_lnk'] == '1') {
        //$is_join = preg_match('@(.*)[[:space:]]+FROM[[:space:]]+.*[[:space:]]+JOIN@im', $sql_query, $select_stt);
        $is_join = isset($analyzed_sql[0]['queryflags']['join']) ? true : false;
        $select_expr = $analyzed_sql[0]['select_expr_clause'];
    } else {
        $is_join = false;
    }
    // garvin: See if we have to highlight any header fields of a WHERE query.
    //  Uses SQL-Parser results.
    $highlight_columns = array();
    if (isset($analyzed_sql) && isset($analyzed_sql[0]) && isset($analyzed_sql[0]['where_clause_identifiers'])) {
        $wi = 0;
        if (isset($analyzed_sql[0]['where_clause_identifiers']) && is_array($analyzed_sql[0]['where_clause_identifiers'])) {
            foreach ($analyzed_sql[0]['where_clause_identifiers'] as $wci_nr => $wci) {
                $highlight_columns[$wci] = 'true';
            }
        }
    }
    for ($i = 0; $i < $fields_cnt; $i++) {
        // garvin: See if this column should get highlight because it's used in the
        //  where-query.
        if (isset($highlight_columns[$fields_meta[$i]->name]) || isset($highlight_columns[PMA_backquote($fields_meta[$i]->name)])) {
            $condition_field = true;
        } else {
            $condition_field = false;
        }
        // 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled.
        if (isset($comments_map) && isset($comments_map[$fields_meta[$i]->table]) && isset($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name])) {
            $comments = '<span class="tblcomment">' . htmlspecialchars($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name]) . '</span>';
        } else {
            $comments = '';
        }
        // 2.1 Results can be sorted
        if ($is_display['sort_lnk'] == '1') {
            // 2.1.1 Checks if the table name is required; it's the case
            //       for a query with a "JOIN" statement and if the column
            //       isn't aliased, or in queries like
            //       SELECT `1`.`master_field` , `2`.`master_field`
            //       FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
            /**
             * we prefer always using table if existing
             * and second this code does not correctly check $fields_meta[$i]->table
            if (($is_join
                && !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . strtr($fields_meta[$i]->name, array('[' => '\\[', '~' => '\\~', '\\' => '\\\\')) . '~i', $select_expr, $parts))
               || (isset($analyzed_sql[0]['select_expr'][$i]['expr'])
                   && isset($analyzed_sql[0]['select_expr'][$i]['column'])
                   && $analyzed_sql[0]['select_expr'][$i]['expr'] !=
                   $analyzed_sql[0]['select_expr'][$i]['column']
                  && isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table))) {
            */
            if (isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table)) {
                $sort_tbl = PMA_backquote($fields_meta[$i]->table) . '.';
            } else {
                $sort_tbl = '';
            }
            // 2.1.2 Checks if the current column is used to sort the
            //       results
            if (empty($sort_expression)) {
                $is_in_sort = false;
            } else {
                // field name may be preceded by a space, or any number
                // of characters followed by a dot (tablename.fieldname)
                // so do a direct comparison
                // for the sort expression (avoids problems with queries
                // like "SELECT id, count(id)..." and clicking to sort
                // on id or on count(id))
                $is_in_sort = $sort_tbl . PMA_backquote($fields_meta[$i]->name) == $sort_expression_nodir ? true : false;
            }
            // 2.1.3 Check the field name for backquotes.
            //       If it contains some, it's probably a function column
            //       like 'COUNT(`field`)'
            if (strpos($fields_meta[$i]->name, '`') !== false) {
                $sort_order = ' ORDER BY ' . PMA_backquote($fields_meta[$i]->name) . ' ';
            } else {
                $sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($fields_meta[$i]->name) . ' ';
            }
            // 2.1.4 Do define the sorting url
            if (!$is_in_sort) {
                // loic1: patch #455484 ("Smart" order)
                $GLOBALS['cfg']['Order'] = strtoupper($GLOBALS['cfg']['Order']);
                if ($GLOBALS['cfg']['Order'] == 'SMART') {
                    $GLOBALS['cfg']['Order'] = preg_match('@time|date@i', $fields_meta[$i]->type) ? 'DESC' : 'ASC';
                }
                $sort_order .= $GLOBALS['cfg']['Order'];
                $order_img = '';
            } elseif (preg_match('@[[:space:]]ASC$@i', $sort_expression)) {
                $sort_order .= ' DESC';
                $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="' . $GLOBALS['strAscending'] . '" title="' . $GLOBALS['strAscending'] . '" id="soimg' . $i . '" />';
            } elseif (preg_match('@[[:space:]]DESC$@i', $sort_expression)) {
                $sort_order .= ' ASC';
                $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_desc.png" width="11" height="9" alt="' . $GLOBALS['strDescending'] . '" title="' . $GLOBALS['strDescending'] . '" id="soimg' . $i . '" />';
            } else {
                $sort_order .= ' DESC';
                $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="' . $GLOBALS['strAscending'] . '" title="' . $GLOBALS['strAscending'] . '" id="soimg' . $i . '" />';
            }
            if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE))@i', $unsorted_sql_query, $regs3)) {
                $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
            } else {
                $sorted_sql_query = $unsorted_sql_query . $sort_order;
            }
            $url_query = PMA_generate_common_url($db, $table) . '&amp;pos=' . $pos . '&amp;session_max_rows=' . $session_max_rows . '&amp;disp_direction=' . $disp_direction . '&amp;repeat_cells=' . $repeat_cells . '&amp;dontlimitchars=' . $dontlimitchars . '&amp;sql_query=' . urlencode($sorted_sql_query);
            $order_url = 'sql.php?' . $url_query;
            // 2.1.5 Displays the sorting url
            // added 20004-06-09: Michael Keck <*****@*****.**>
            //                    enable sord order swapping for image
            $order_link_params = array();
            if (isset($order_img) && $order_img != '') {
                if (strstr($order_img, 'asc')) {
                    $order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
                    $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
                } elseif (strstr($order_img, 'desc')) {
                    $order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
                    $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
                }
            }
            if ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
                $order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;';
            }
            $order_link_params['title'] = $GLOBALS['strSort'];
            $order_link_content = $disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name);
            $order_link = PMA_linkOrButton($order_url, $order_link_content . $order_img, $order_link_params, false, true);
            if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
                echo '<th';
                if ($condition_field) {
                    echo ' class="condition"';
                }
                if ($disp_direction == 'horizontalflipped') {
                    echo ' valign="bottom"';
                }
                echo '>' . $order_link . $comments . '</th>';
            }
            $vertical_display['desc'][] = '    <th ' . ($condition_field ? ' class="condition"' : '') . '>' . "\n" . $order_link . $comments . '    </th>' . "\n";
        } else {
            if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
                echo '<th';
                if ($condition_field) {
                    echo ' class="condition"';
                }
                if ($disp_direction == 'horizontalflipped') {
                    echo ' valign="bottom"';
                }
                if ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
                    echo ' style="direction: ltr; writing-mode: tb-rl;"';
                }
                echo '>';
                if ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake') {
                    echo PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), '<br />');
                } else {
                    echo htmlspecialchars($fields_meta[$i]->name);
                }
                echo "\n" . $comments . '</th>';
            }
            $vertical_display['desc'][] = '    <th ' . ($condition_field ? ' class="condition"' : '') . '>' . "\n" . '        ' . htmlspecialchars($fields_meta[$i]->name) . "\n" . $comments . '    </th>';
        }
        // end else (2.2)
    }
    // end for
    // 3. Displays the full/partial text button (part 2) at the right
    //    column of the result table header if possible and required...
    if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') && $is_display['text_btn'] == '1') {
        $vertical_display['emptyafter'] = $is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn' ? 3 : 1;
        if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
            echo "\n";
            ?>
<th <?php 
            echo $colspan;
            ?>
>
    <?php 
            echo $text_link;
            ?>
</th>
            <?php 
        } else {
            $vertical_display['textbtn'] = '    <th ' . $rowspan . ' valign="middle">' . "\n" . '        ' . $text_link . "\n" . '    </th>' . "\n";
        }
        // end vertical mode
    } elseif ($GLOBALS['cfg']['ModifyDeleteAtRight'] && ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn') && !$GLOBALS['is_header_sent']) {
        $vertical_display['emptyafter'] = $is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn' ? 3 : 1;
        if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
            echo "\n";
            ?>
<td<?php 
            echo $colspan;
            ?>
></td>
            <?php 
        } else {
            $vertical_display['textbtn'] = '    <td' . $rowspan . '></td>' . "\n";
        }
        // end vertical mode
    }
    if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
        ?>
</tr>
</thead>
        <?php 
    }
    return true;
}
Beispiel #3
0
            $disp_mode = 'urdr111101';
        }
        if (!isset($dontlimitchars)) {
            $dontlimitchars = 0;
        }
        // hide edit and delete links for information_schema
        if (PMA_MYSQL_INT_VERSION >= 50002 && isset($db) && $db == 'information_schema') {
            $disp_mode = 'nnnn110111';
        }
        PMA_displayTable($result, $disp_mode, $analyzed_sql);
        PMA_DBI_free_result($result);
        // BEGIN INDEX CHECK See if indexes should be checked.
        if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
            foreach ($selected as $idx => $tbl_name) {
                $indexes = $indexes_info = $indexes_data = array();
                $tbl_ret_keys = PMA_get_indexes(urldecode($tbl_name), $err_url_0);
                PMA_extract_indexes($tbl_ret_keys, $indexes, $indexes_info, $indexes_data);
                $idx_collection = PMA_show_indexes(urldecode($tbl_name), $indexes, $indexes_info, $indexes_data, false);
                $check = PMA_check_indexes($idx_collection);
                if (!empty($check)) {
                    ?>
<table border="0" cellpadding="2" cellspacing="0">
    <tr>
        <td class="tblHeaders" colspan="7"><?php 
                    printf($strIndexWarningTable, urldecode($tbl_name));
                    ?>
</td>
    </tr>
    <?php 
                    echo $check;
                    ?>
    require_once './header.inc.php';
}
// end if
/**
 * Gets fields and indexes informations
 */
if (!defined('PMA_IDX_INCLUDED')) {
    $err_url_0 = 'db_details.php?' . PMA_generate_common_url($db);
}
//  Gets table keys and store them in arrays
$indexes = array();
$indexes_info = array();
$indexes_data = array();
// keys had already been grabbed in "tbl_properties.php"
if (!defined('PMA_IDX_INCLUDED')) {
    $ret_keys = PMA_get_indexes($table, $err_url_0);
}
PMA_extract_indexes($ret_keys, $indexes, $indexes_info, $indexes_data);
// Get fields and stores their name/type
// fields had already been grabbed in "tbl_properties.php"
if (!defined('PMA_IDX_INCLUDED')) {
    $fields_rs = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
    $save_row = array();
    while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
        $save_row[] = $row;
    }
}
$fields_names = array();
$fields_types = array();
foreach ($save_row as $saved_row_key => $row) {
    $fields_names[] = $row['Field'];
function get_all_keys()
{
    global $db;
    require_once './libs/tbl_indexes.lib.php';
    PMA_DBI_select_db($db);
    $tables_all_keys = array();
    for ($I = 0; $I < sizeof($GLOBALS['PMD']['TABLE_NAME_SMALL']); $I++) {
        $ret_keys = PMA_get_indexes($GLOBALS['PMD']['TABLE_NAME_SMALL'][$I]);
        if (!empty($ret_keys)) {
            // reset those as the function uses them by reference
            $indexes = $indexes_info = $indexes_data = array();
            PMA_extract_indexes($ret_keys, $indexes, $indexes_info, $indexes_data);
            // for now, take into account only the first index segment
            foreach ($indexes_data as $one_index) {
                $column_name = $one_index[1]['Column_name'];
                $tables_all_keys[$GLOBALS['PMD']['OWNER'][$I] . '.' . $GLOBALS['PMD']['TABLE_NAME_SMALL'][$I] . '.' . $column_name] = 1;
            }
        }
    }
    return $tables_all_keys;
}