示例#1
1
/**
 * display table header (<table><thead>...</thead><tbody>)
 *
 * @param boolean $db_is_system_schema whether db is information schema or not
 * @param boolean $replication         whether to sho replication status
 *
 * @return string html data
 */
function PMA_tableHeader($db_is_system_schema = false, $replication = false)
{
    $cnt = 0;
    // Let's count the columns...
    if ($db_is_system_schema) {
        $action_colspan = 4;
    } else {
        $action_colspan = 7;
    }
    $html_output = '<table class="data">' . "\n" . '<thead>' . "\n" . '<tr><th></th>' . "\n" . '<th>' . PMA_sortableTableHeader(__('Table'), 'table') . '</th>' . "\n";
    if ($replication) {
        $html_output .= '<th>' . "\n" . '        ' . __('Replication') . "\n" . '</th>';
    }
    $html_output .= '<th colspan="' . $action_colspan . '">' . "\n" . '        ' . __('Action') . "\n" . '</th>' . '<th>' . PMA_sortableTableHeader(__('Rows'), 'records', 'DESC') . PMA_Util::showHint(PMA_sanitize(__('May be approximate. See [doc@faq3-11]FAQ 3.11[/doc].'))) . "\n" . '</th>' . "\n";
    if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
        $html_output .= '<th>' . PMA_sortableTableHeader(__('Type'), 'type') . '</th>' . "\n";
        $cnt++;
        $html_output .= '<th>' . PMA_sortableTableHeader(__('Collation'), 'collation') . '</th>' . "\n";
        $cnt++;
    }
    if ($GLOBALS['is_show_stats']) {
        // larger values are more interesting so default sort order is DESC
        $html_output .= '<th>' . PMA_sortableTableHeader(__('Size'), 'size', 'DESC') . '</th>' . "\n" . '<th>' . PMA_sortableTableHeader(__('Overhead'), 'overhead', 'DESC') . '</th>' . "\n";
        $cnt += 2;
    }
    if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
        // larger values are more interesting so default sort order is DESC
        $html_output .= '<th>' . PMA_sortableTableHeader(__('Creation'), 'creation', 'DESC') . '</th>' . "\n";
        $cnt += 2;
    }
    if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
        // larger values are more interesting so default sort order is DESC
        $html_output .= '<th>' . PMA_sortableTableHeader(__('Last update'), 'last_update', 'DESC') . '</th>' . "\n";
        $cnt += 2;
    }
    if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
        // larger values are more interesting so default sort order is DESC
        $html_output .= '<th>' . PMA_sortableTableHeader(__('Last check'), 'last_check', 'DESC') . '</th>' . "\n";
        $cnt += 2;
    }
    $html_output .= '</tr>' . "\n";
    $html_output .= '</thead>' . "\n";
    $html_output .= '<tbody>' . "\n";
    $GLOBALS['colspan_for_structure'] = $cnt + $action_colspan + 3;
    return $html_output;
}
/**
 * void PMA_TableHeader([bool $db_is_information_schema = false])
 * display table header (<table><thead>...</thead><tbody>)
 *
 * @uses    PMA_showHint()
 * @uses    $GLOBALS['cfg']['PropertiesNumColumns']
 * @uses    $GLOBALS['is_show_stats']
 * @uses    $GLOBALS['colspan_for_structure']
 * @uses    PMA_SortableTableHeader()
 * @param   boolean $db_is_information_schema
 * @param   boolean $replication
 */
function PMA_TableHeader($db_is_information_schema = false, $replication = false)
{
    $cnt = 0;
    // Let's count the columns...
    if ($db_is_information_schema) {
        $action_colspan = 3;
    } else {
        $action_colspan = 6;
    }
    echo '<table class="data">' . "\n" . '<thead>' . "\n" . '<tr><th></th>' . "\n" . '    <th>' . PMA_SortableTableHeader(__('Table'), 'table') . '</th>' . "\n";
    if ($replication) {
        echo '    <th>' . "\n" . '        ' . __('Replication') . "\n" . '    </th>';
    }
    echo '    <th colspan="' . $action_colspan . '">' . "\n" . '        ' . __('Action') . "\n" . '    </th>' . '    <th>' . PMA_SortableTableHeader(__('Rows'), 'records', 'DESC') . PMA_showHint(PMA_sanitize(__('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]'))) . "\n" . '    </th>' . "\n";
    if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
        echo '    <th>' . PMA_SortableTableHeader(__('Type'), 'type') . '</th>' . "\n";
        $cnt++;
        echo '    <th>' . PMA_SortableTableHeader(__('Collation'), 'collation') . '</th>' . "\n";
        $cnt++;
    }
    if ($GLOBALS['is_show_stats']) {
        // larger values are more interesting so default sort order is DESC
        echo '    <th>' . PMA_SortableTableHeader(__('Size'), 'size', 'DESC') . '</th>' . "\n" . '    <th>' . PMA_SortableTableHeader(__('Overhead'), 'overhead', 'DESC') . '</th>' . "\n";
        $cnt += 2;
    }
    echo '</tr>' . "\n";
    echo '</thead>' . "\n";
    echo '<tbody>' . "\n";
    $GLOBALS['colspan_for_structure'] = $cnt + $action_colspan + 3;
}
示例#3
0
/**
 * void PMA_TableHeader([bool $db_is_information_schema = false])
 * display table header (<table><thead>...</thead><tbody>)
 *
 * @uses    PMA_showHint()
 * @uses    $GLOBALS['cfg']['PropertiesNumColumns']
 * @uses    $GLOBALS['is_show_stats']
 * @uses    $GLOBALS['strTable']
 * @uses    $GLOBALS['strAction']
 * @uses    $GLOBALS['strRecords']
 * @uses    $GLOBALS['strApproximateCount']
 * @uses    $GLOBALS['strType']
 * @uses    $GLOBALS['strCollation']
 * @uses    $GLOBALS['strSize']
 * @uses    $GLOBALS['strOverhead']
 * @uses    $GLOBALS['structure_tbl_col_cnt']
 * @uses    PMA_SortableTableHeader()
 * @param   boolean $db_is_information_schema
 * @param   boolean $replication
 */
function PMA_TableHeader($db_is_information_schema = false, $replication = false)
{
    $cnt = 0;
    // Let's count the columns...
    if ($db_is_information_schema) {
        $action_colspan = 3;
    } else {
        $action_colspan = 6;
    }
    echo '<table class="data" style="float: left;">' . "\n" . '<thead>' . "\n" . '<tr><th></th>' . "\n" . '    <th>' . PMA_SortableTableHeader($GLOBALS['strTable'], 'table') . '</th>' . "\n";
    if ($replication) {
        echo '    <th>' . "\n" . '        ' . $GLOBALS['strReplication'] . "\n" . '    </th>';
    }
    echo '    <th colspan="' . $action_colspan . '">' . "\n" . '        ' . $GLOBALS['strAction'] . "\n" . '    </th>' . '    <th>' . PMA_SortableTableHeader($GLOBALS['strRecords'], 'records', 'DESC') . PMA_showHint(PMA_sanitize($GLOBALS['strApproximateCount'])) . "\n" . '    </th>' . "\n";
    if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
        echo '    <th>' . PMA_SortableTableHeader($GLOBALS['strType'], 'type') . '</th>' . "\n";
        $cnt++;
        echo '    <th>' . PMA_SortableTableHeader($GLOBALS['strCollation'], 'collation') . '</th>' . "\n";
        $cnt++;
    }
    if ($GLOBALS['is_show_stats']) {
        // larger values are more interesting so default sort order is DESC
        echo '    <th>' . PMA_SortableTableHeader($GLOBALS['strSize'], 'size', 'DESC') . '</th>' . "\n" . '    <th>' . PMA_SortableTableHeader($GLOBALS['strOverhead'], 'overhead', 'DESC') . '</th>' . "\n";
        $cnt += 2;
    }
    echo '</tr>' . "\n";
    echo '</thead>' . "\n";
    echo '<tbody>' . "\n";
    $GLOBALS['structure_tbl_col_cnt'] = $cnt + $action_colspan + 3;
}
/**
 * void PMA_TableHeader([bool $db_is_information_schema = false])
 * display table header (<table><thead>...</thead><tbody>)
 *
 * @uses    PMA_showHint()
 * @uses    $GLOBALS['cfg']['PropertiesNumColumns']
 * @uses    $GLOBALS['is_show_stats']
 * @uses    $GLOBALS['strTable']
 * @uses    $GLOBALS['strAction']
 * @uses    $GLOBALS['strRecords']
 * @uses    $GLOBALS['strApproximateCount']
 * @uses    $GLOBALS['strType']
 * @uses    $GLOBALS['strCollation']
 * @uses    $GLOBALS['strSize']
 * @uses    $GLOBALS['strOverhead']
 * @uses    $GLOBALS['structure_tbl_col_cnt']
 * @param   boolean $db_is_information_schema
 */
function PMA_TableHeader($db_is_information_schema = false)
{
    $cnt = 0;
    // Let's count the columns...
    if ($db_is_information_schema) {
        $action_colspan = 3;
    } else {
        $action_colspan = 6;
    }
    echo '<table class="data" style="float: left;">' . "\n" . '<thead>' . "\n" . '<tr><td></td>' . "\n" . '    <th>' . $GLOBALS['strTable'] . '</th>' . "\n" . '    <th colspan="' . $action_colspan . '">' . "\n" . '        ' . $GLOBALS['strAction'] . "\n" . '    </th>' . '    <th>' . $GLOBALS['strRecords'] . PMA_showHint(PMA_sanitize($GLOBALS['strApproximateCount'])) . "\n" . '    </th>' . "\n";
    if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
        echo '    <th>' . $GLOBALS['strType'] . '</th>' . "\n";
        $cnt++;
        echo '    <th>' . $GLOBALS['strCollation'] . '</th>' . "\n";
        $cnt++;
    }
    if ($GLOBALS['is_show_stats']) {
        echo '    <th>' . $GLOBALS['strSize'] . '</th>' . "\n" . '    <th>' . $GLOBALS['strOverhead'] . '</th>' . "\n";
        $cnt += 2;
    }
    echo '</tr>' . "\n";
    echo '</thead>' . "\n";
    echo '<tbody>' . "\n";
    $GLOBALS['structure_tbl_col_cnt'] = $cnt + $action_colspan + 3;
}
/**
 * Returns sanitized language string, taking into account our special codes
 * for formatting. Takes variable number of arguments.
 * Based on PMA_sanitize from sanitize.lib.php.
 *
 * @param string $lang_key key in $GLOBALS WITHOUT 'strSetup' prefix
 *
 * @return string
 */
function PMA_lang($lang_key)
{
    $message = isset($GLOBALS["strConfig{$lang_key}"]) ? $GLOBALS["strConfig{$lang_key}"] : $lang_key;
    $message = PMA_sanitize($message);
    if (func_num_args() == 1) {
        return $message;
    } else {
        $args = func_get_args();
        array_shift($args);
        return vsprintf($message, $args);
    }
}
 /**
  * Returns error message for failed authentication.
  *
  * @return string
  */
 public function getErrorMessage()
 {
     if (!empty($GLOBALS['login_without_password_is_forbidden'])) {
         return __('Login without a password is forbidden by configuration' . ' (see AllowNoPassword)');
     } elseif (!empty($GLOBALS['allowDeny_forbidden'])) {
         return __('Access denied!');
     } elseif (!empty($GLOBALS['no_activity'])) {
         return sprintf(__('No activity within %s seconds; please log in again.'), $GLOBALS['cfg']['LoginCookieValidity']);
     } else {
         $dbi_error = $GLOBALS['dbi']->getError();
         if (!empty($dbi_error)) {
             return PMA_sanitize($dbi_error);
         } elseif (isset($GLOBALS['errno'])) {
             return '#' . $GLOBALS['errno'] . ' ' . __('Cannot log in to the MySQL server');
         } else {
             return __('Cannot log in to the MySQL server');
         }
     }
 }
示例#7
0
        ?>
</a></td>
    <?php 
    }
    // end if (! $db_is_information_schema)
    // there is a null value in the ENGINE
    // - when the table needs to be repaired, or
    // - when it's a view
    //  so ensure that we'll display "in use" below for a table
    //  that needs to be repaired
    if (isset($each_table['TABLE_ROWS']) && ($each_table['ENGINE'] != null || $table_is_view)) {
        if ($table_is_view) {
            if ($each_table['TABLE_ROWS'] >= $GLOBALS['cfg']['MaxExactCountViews']) {
                $row_count_pre = '~';
                $sum_row_count_pre = '~';
                $show_superscript = PMA_showHint(PMA_sanitize(sprintf(__('This view has at least this number of rows. Please refer to %sdocumentation%s.'), '[a@./Documentation.html#cfg_MaxExactCountViews@_blank]', '[/a]')));
            }
        } elseif ($each_table['ENGINE'] == 'InnoDB' && !$each_table['COUNTED']) {
            // InnoDB table: we did not get an accurate row count
            $row_count_pre = '~';
            $sum_row_count_pre = '~';
            $show_superscript = '';
        } else {
            $row_count_pre = '';
            $show_superscript = '';
        }
        ?>
    <td class="value tbl_rows"><?php 
        echo $row_count_pre . PMA_formatNumber($each_table['TABLE_ROWS'], 0) . $show_superscript;
        ?>
</td>
示例#8
0
 /**
  * Prepare a table of results returned by a SQL query.
  *
  * @param integer &$dt_result           the link id associated to the query
  *                                      which results have to be displayed
  * @param array   &$displayParts        the parts to display
  * @param array   $analyzed_sql_results analyzed sql results
  * @param boolean $is_limited_display   With limited operations or not
  *
  * @return  string   $table_html   Generated HTML content for resulted table
  *
  * @access  public
  *
  * @see     sql.php file
  */
 public function getTable(&$dt_result, &$displayParts, $analyzed_sql_results, $is_limited_display = false)
 {
     /**
      * The statement this table is built for.
      * @var \SqlParser\Statements\SelectStatement
      */
     $statement = $analyzed_sql_results['statement'];
     $table_html = '';
     // Following variable are needed for use in isset/empty or
     // use with array indexes/safe use in foreach
     $fields_meta = $this->__get('fields_meta');
     $showtable = $this->__get('showtable');
     $printview = $this->__get('printview');
     // why was this called here? (already called from sql.php)
     //$this->setConfigParamsForDisplayTable();
     /**
      * @todo move this to a central place
      * @todo for other future table types
      */
     $is_innodb = isset($showtable['Type']) && $showtable['Type'] == self::TABLE_TYPE_INNO_DB;
     if ($is_innodb && PMA_isJustBrowsing($analyzed_sql_results, true)) {
         // "j u s t   b r o w s i n g"
         $pre_count = '~';
         $after_count = Util::showHint(PMA_sanitize(__('May be approximate. See [doc@faq3-11]FAQ 3.11[/doc].')));
     } else {
         $pre_count = '';
         $after_count = '';
     }
     // 1. ----- Prepares the work -----
     // 1.1 Gets the information about which functionalities should be
     //     displayed
     list($displayParts, $total) = $this->_setDisplayPartsAndTotal($displayParts);
     // 1.2 Defines offsets for the next and previous pages
     if ($displayParts['nav_bar'] == '1') {
         list($pos_next, $pos_prev) = $this->_getOffsets();
     }
     // end if
     // 1.3 Extract sorting expressions.
     //     we need $sort_expression and $sort_expression_nodirection
     //     even if there are many table references
     $sort_expression = array();
     $sort_expression_nodirection = array();
     $sort_direction = array();
     if (!empty($statement->order)) {
         foreach ($statement->order as $o) {
             $sort_expression[] = $o->expr->expr . ' ' . $o->type;
             $sort_expression_nodirection[] = $o->expr->expr;
             $sort_direction[] = $o->type;
         }
     } else {
         $sort_expression[] = '';
         $sort_expression_nodirection[] = '';
         $sort_direction[] = '';
     }
     $number_of_columns = count($sort_expression_nodirection);
     // 1.4 Prepares display of first and last value of the sorted column
     $sorted_column_message = '';
     for ($i = 0; $i < $number_of_columns; $i++) {
         $sorted_column_message .= $this->_getSortedColumnMessage($dt_result, $sort_expression_nodirection[$i]);
     }
     // 2. ----- Prepare to display the top of the page -----
     // 2.1 Prepares a messages with position information
     if ($displayParts['nav_bar'] == '1' && isset($pos_next)) {
         $message = $this->_setMessageInformation($sorted_column_message, $analyzed_sql_results, $total, $pos_next, $pre_count, $after_count);
         $table_html .= Util::getMessage($message, $this->__get('sql_query'), 'success');
     } elseif (!isset($printview) || $printview != '1') {
         $table_html .= Util::getMessage(__('Your SQL query has been executed successfully.'), $this->__get('sql_query'), 'success');
     }
     // 2.3 Prepare the navigation bars
     if (!mb_strlen($this->__get('table'))) {
         if ($analyzed_sql_results['querytype'] == 'SELECT') {
             // table does not always contain a real table name,
             // for example in MySQL 5.0.x, the query SHOW STATUS
             // returns STATUS as a table name
             $this->__set('table', $fields_meta[0]->table);
         } else {
             $this->__set('table', '');
         }
     }
     // can the result be sorted?
     if ($displayParts['sort_lnk'] == '1') {
         // At this point, $sort_expression is an array but we only verify
         // the first element in case we could find that the table is
         // sorted by one of the choices listed in the
         // "Sort by key" drop-down
         list($unsorted_sql_query, $sort_by_key_html) = $this->_getUnsortedSqlAndSortByKeyDropDown($analyzed_sql_results, $sort_expression[0]);
     } else {
         $sort_by_key_html = $unsorted_sql_query = '';
     }
     if ($displayParts['nav_bar'] == '1' && empty($statement->limit)) {
         $table_html .= $this->_getPlacedTableNavigations($pos_next, $pos_prev, self::PLACE_TOP_DIRECTION_DROPDOWN, $is_innodb, $sort_by_key_html);
     }
     // 2b ----- Get field references from Database -----
     // (see the 'relation' configuration variable)
     // initialize map
     $map = array();
     $target = array();
     if (!empty($statement->from)) {
         foreach ($statement->from as $field) {
             if (!empty($field->table)) {
                 $target[] = $field->table;
             }
         }
     }
     if (mb_strlen($this->__get('table'))) {
         // This method set the values for $map array
         $this->_setParamForLinkForeignKeyRelatedTables($map);
         // Coming from 'Distinct values' action of structure page
         // We manipulate relations mechanism to show a link to related rows.
         if ($this->__get('is_browse_distinct')) {
             $map[$fields_meta[1]->name] = array($this->__get('table'), $fields_meta[1]->name, '', $this->__get('db'));
         }
     }
     // end if
     // end 2b
     // 3. ----- Prepare the results table -----
     $table_html .= $this->_getTableHeaders($displayParts, $analyzed_sql_results, $unsorted_sql_query, $sort_expression, $sort_expression_nodirection, $sort_direction, $is_limited_display);
     $table_html .= '<tbody>' . "\n";
     $table_html .= $this->_getTableBody($dt_result, $displayParts, $map, $analyzed_sql_results, $is_limited_display);
     $this->__set('display_params', null);
     $table_html .= '</tbody>' . "\n" . '</table>';
     // 4. ----- Prepares the link for multi-fields edit and delete
     if ($displayParts['del_lnk'] == self::DELETE_ROW && $displayParts['del_lnk'] != self::KILL_PROCESS) {
         $table_html .= $this->_getMultiRowOperationLinks($dt_result, $analyzed_sql_results, $displayParts['del_lnk']);
     }
     // 5. ----- Get the navigation bar at the bottom if required -----
     if ($displayParts['nav_bar'] == '1' && empty($statement->limit)) {
         $table_html .= $this->_getPlacedTableNavigations($pos_next, $pos_prev, self::PLACE_BOTTOM_DIRECTION_DROPDOWN, $is_innodb, $sort_by_key_html);
     } elseif (!isset($printview) || $printview != '1') {
         $table_html .= "\n" . '<br /><br />' . "\n";
     }
     // 6. ----- Prepare "Query results operations"
     if ((!isset($printview) || $printview != '1') && !$is_limited_display) {
         $table_html .= $this->_getResultsOperations($displayParts, $analyzed_sql_results);
     }
     return $table_html;
 }
示例#9
0
/* $Id: server_databases.php 10421 2007-06-04 17:03:26Z lem9 $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
 * Does the common work
 */
require_once './libraries/common.lib.php';
$js_to_run = 'functions.js';
require './libraries/server_common.inc.php';
/**
 * avoids 'undefined index' errors
 */
if (empty($_REQUEST['sort_by'])) {
    $sort_by = 'SCHEMA_NAME';
} else {
    $sort_by = PMA_sanitize($_REQUEST['sort_by']);
}
if (isset($_REQUEST['sort_order']) && strtolower($_REQUEST['sort_order']) == 'desc') {
    $sort_order = 'desc';
} else {
    $sort_order = 'asc';
}
$dbstats = empty($_REQUEST['dbstats']) ? 0 : 1;
$pos = empty($_REQUEST['pos']) ? 0 : (int) $_REQUEST['pos'];
/**
 * Drops multiple databases
 */
// workaround for IE behavior (it returns some coordinates based on where
// the mouse was on the Drop image):
if (isset($_REQUEST['drop_selected_dbs_x'])) {
    $_REQUEST['drop_selected_dbs'] = true;
示例#10
0
" method="post">
<input type="hidden" name="query_type" value="<?php 
    echo $what;
    ?>
" />
    <?php 
    if (strpos(' ' . $action, 'db_') == 1) {
        echo PMA_generate_common_hidden_inputs($db);
    } elseif (strpos(' ' . $action, 'tbl_') == 1 || $what == 'row_delete') {
        echo PMA_generate_common_hidden_inputs($db, $table);
    } else {
        echo PMA_generate_common_hidden_inputs();
    }
    ?>
<input type="hidden" name="reload" value="<?php 
    echo isset($reload) ? PMA_sanitize($reload) : 0;
    ?>
" />
<?php 
    foreach ($selected as $idx => $sval) {
        echo '<input type="hidden" name="selected[]" value="' . htmlspecialchars($sval) . '" />' . "\n";
    }
    if ($what == 'drop_tbl' && !empty($views)) {
        foreach ($views as $current) {
            echo '<input type="hidden" name="views[]" value="' . htmlspecialchars($current) . '" />' . "\n";
        }
    }
    if ($what == 'row_delete') {
        echo '<input type="hidden" name="original_sql_query" value="' . htmlspecialchars($original_sql_query) . '" />' . "\n";
        echo '<input type="hidden" name="original_url_query" value="' . htmlspecialchars($original_url_query) . '" />' . "\n";
    }
示例#11
0
    ?>
" />
    <input type="hidden" name="purge" value="<?php 
    echo isset($purge) ? PMA_sanitize($purge) : '';
    ?>
" />
    <input type="hidden" name="cpurge" value="<?php 
    echo isset($cpurge) ? PMA_sanitize($cpurge) : '';
    ?>
" />
    <input type="hidden" name="purgekey" value="<?php 
    echo isset($purgekey) ? PMA_sanitize($purgekey) : '';
    ?>
" />
    <input type="hidden" name="show_query" value="<?php 
    echo isset($show_query) ? PMA_sanitize($show_query) : '';
    ?>
" />
    <?php 
    echo '<fieldset class="confirmation">' . "\n" . '    <legend>' . $strDoYouReally . '</legend>' . '    <tt>' . htmlspecialchars($stripped_sql_query) . '</tt>' . "\n" . '</fieldset>' . "\n" . '<fieldset class="tblFooters">' . "\n";
    ?>
    <input type="submit" name="btnDrop" value="<?php 
    echo $strYes;
    ?>
" id="buttonYes" />
    <input type="submit" name="btnDrop" value="<?php 
    echo $strNo;
    ?>
" id="buttonNo" />
    <?php 
    echo '</fieldset>' . "\n" . '</form>' . "\n";
<?php

/* $Id: tbl_create.php 10144 2007-03-20 11:22:31Z cybot_tm $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
 * Get some core libs
 */
require_once './libs/common.lib.php';
require_once './libs/Table.class.php';
$js_to_run = 'functions.js';
if (isset($table)) {
    $table = PMA_sanitize($table);
}
require_once './libs/header.inc.php';
// Check parameters
PMA_checkParameters(array('db', 'table'));
/**
 * Defines the url to return to in case of error in a sql statement
 */
$err_url = $cfg['DefaultTabTable'] . '?' . PMA_generate_common_url($db, $table);
/**
 * Selects the database to work with
 */
PMA_DBI_select_db($db);
/**
 * The form used to define the structure of the table has been submitted
 */
$abort = false;
if (isset($submit_num_fields)) {
    $regenerate = true;
    $num_fields = $orig_num_fields + $added_fields;
示例#13
0
/**
 * displays the message and the query
 * usually the message is the result of the query executed
 *
 * @param string  $message   the message to display
 * @param string  $sql_query the query to display
 * @param string  $type      the type (level) of the message
 * @param boolean $is_view   is this a message after a VIEW operation?
 *
 * @return  string
 *
 * @access  public
 */
function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view = false)
{
    /*
     * PMA_ajaxResponse uses this function to collect the string of HTML generated
     * for showing the message.  Use output buffering to collect it and return it
     * in a string.  In some special cases on sql.php, buffering has to be disabled
     * and hence we check with $GLOBALS['buffer_message']
     */
    if ($GLOBALS['is_ajax_request'] == true && !isset($GLOBALS['buffer_message'])) {
        ob_start();
    }
    global $cfg;
    if (null === $sql_query) {
        if (!empty($GLOBALS['display_query'])) {
            $sql_query = $GLOBALS['display_query'];
        } elseif ($cfg['SQP']['fmtType'] == 'none' && !empty($GLOBALS['unparsed_sql'])) {
            $sql_query = $GLOBALS['unparsed_sql'];
        } elseif (!empty($GLOBALS['sql_query'])) {
            $sql_query = $GLOBALS['sql_query'];
        } else {
            $sql_query = '';
        }
    }
    if (isset($GLOBALS['using_bookmark_message'])) {
        $GLOBALS['using_bookmark_message']->display();
        unset($GLOBALS['using_bookmark_message']);
    }
    // Corrects the tooltip text via JS if required
    // @todo this is REALLY the wrong place to do this - very unexpected here
    if (!$is_view && strlen($GLOBALS['table']) && $cfg['ShowTooltip']) {
        $tooltip = PMA_Table::sGetToolTip($GLOBALS['db'], $GLOBALS['table']);
        $uni_tbl = PMA_jsFormat($GLOBALS['db'] . '.' . $GLOBALS['table'], false);
        echo "\n";
        echo '<script type="text/javascript">' . "\n";
        echo '//<![CDATA[' . "\n";
        echo "if (window.parent.updateTableTitle) window.parent.updateTableTitle('" . $uni_tbl . "', '" . PMA_jsFormat($tooltip, false) . "');" . "\n";
        echo '//]]>' . "\n";
        echo '</script>' . "\n";
    }
    // end if ... elseif
    // Checks if the table needs to be repaired after a TRUNCATE query.
    // @todo what about $GLOBALS['display_query']???
    // @todo this is REALLY the wrong place to do this - very unexpected here
    if (strlen($GLOBALS['table']) && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
        if (PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Index_length') > 1024 && !PMA_DRIZZLE) {
            PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table']));
        }
    }
    unset($tbl_status);
    // In an Ajax request, $GLOBALS['cell_align_left'] may not be defined. Hence,
    // check for it's presence before using it
    echo '<div id="result_query" align="' . (isset($GLOBALS['cell_align_left']) ? $GLOBALS['cell_align_left'] : '') . '">' . "\n";
    if ($message instanceof PMA_Message) {
        if (isset($GLOBALS['special_message'])) {
            $message->addMessage($GLOBALS['special_message']);
            unset($GLOBALS['special_message']);
        }
        $message->display();
        $type = $message->getLevel();
    } else {
        echo '<div class="' . $type . '">';
        echo PMA_sanitize($message);
        if (isset($GLOBALS['special_message'])) {
            echo PMA_sanitize($GLOBALS['special_message']);
            unset($GLOBALS['special_message']);
        }
        echo '</div>';
    }
    if ($cfg['ShowSQL'] == true && !empty($sql_query)) {
        // Html format the query to be displayed
        // If we want to show some sql code it is easiest to create it here
        /* SQL-Parser-Analyzer */
        if (!empty($GLOBALS['show_as_php'])) {
            $new_line = '\\n"<br />' . "\n" . '&nbsp;&nbsp;&nbsp;&nbsp;. "';
            $query_base = htmlspecialchars(addslashes($sql_query));
            $query_base = preg_replace('/((\\015\\012)|(\\015)|(\\012))/', $new_line, $query_base);
        } else {
            $query_base = $sql_query;
        }
        $query_too_big = false;
        if (strlen($query_base) > $cfg['MaxCharactersInDisplayedSQL']) {
            // when the query is large (for example an INSERT of binary
            // data), the parser chokes; so avoid parsing the query
            $query_too_big = true;
            $shortened_query_base = nl2br(htmlspecialchars(substr($sql_query, 0, $cfg['MaxCharactersInDisplayedSQL']) . '[...]'));
        } elseif (!empty($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) {
            // (here, use "! empty" because when deleting a bookmark,
            // $GLOBALS['parsed_sql'] is set but empty
            $parsed_sql = $GLOBALS['parsed_sql'];
        } else {
            // Parse SQL if needed
            $parsed_sql = PMA_SQP_parse($query_base);
        }
        // Analyze it
        if (isset($parsed_sql) && !PMA_SQP_isError()) {
            $analyzed_display_query = PMA_SQP_analyze($parsed_sql);
            // Same as below (append LIMIT), append the remembered ORDER BY
            if ($GLOBALS['cfg']['RememberSorting'] && isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_order_to_append'])) {
                $query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_order_to_append'] . $analyzed_display_query[0]['limit_clause'] . ' ' . $analyzed_display_query[0]['section_after_limit'];
                // Need to reparse query
                $parsed_sql = PMA_SQP_parse($query_base);
                // update the $analyzed_display_query
                $analyzed_display_query[0]['section_before_limit'] .= $GLOBALS['sql_order_to_append'];
                $analyzed_display_query[0]['order_by_clause'] = $GLOBALS['sorted_col'];
            }
            // Here we append the LIMIT added for navigation, to
            // enable its display. Adding it higher in the code
            // to $sql_query would create a problem when
            // using the Refresh or Edit links.
            // Only append it on SELECTs.
            /**
             * @todo what would be the best to do when someone hits Refresh:
             * use the current LIMITs ?
             */
            if (isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_limit_to_append'])) {
                $query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit'];
                // Need to reparse query
                $parsed_sql = PMA_SQP_parse($query_base);
            }
        }
        if (!empty($GLOBALS['show_as_php'])) {
            $query_base = '$sql  = "' . $query_base;
        } elseif (!empty($GLOBALS['validatequery'])) {
            try {
                $query_base = PMA_validateSQL($query_base);
            } catch (Exception $e) {
                PMA_Message::error(__('Failed to connect to SQL validator!'))->display();
            }
        } elseif (isset($parsed_sql)) {
            $query_base = PMA_formatSql($parsed_sql, $query_base);
        }
        // Prepares links that may be displayed to edit/explain the query
        // (don't go to default pages, we must go to the page
        // where the query box is available)
        // Basic url query part
        $url_params = array();
        if (!isset($GLOBALS['db'])) {
            $GLOBALS['db'] = '';
        }
        if (strlen($GLOBALS['db'])) {
            $url_params['db'] = $GLOBALS['db'];
            if (strlen($GLOBALS['table'])) {
                $url_params['table'] = $GLOBALS['table'];
                $edit_link = 'tbl_sql.php';
            } else {
                $edit_link = 'db_sql.php';
            }
        } else {
            $edit_link = 'server_sql.php';
        }
        // Want to have the query explained
        // but only explain a SELECT (that has not been explained)
        /* SQL-Parser-Analyzer */
        $explain_link = '';
        $is_select = false;
        if (!empty($cfg['SQLQuery']['Explain']) && !$query_too_big) {
            $explain_params = $url_params;
            // Detect if we are validating as well
            // To preserve the validate uRL data
            if (!empty($GLOBALS['validatequery'])) {
                $explain_params['validatequery'] = 1;
            }
            if (preg_match('@^SELECT[[:space:]]+@i', $sql_query)) {
                $explain_params['sql_query'] = 'EXPLAIN ' . $sql_query;
                $_message = __('Explain SQL');
                $is_select = true;
            } elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query)) {
                $explain_params['sql_query'] = substr($sql_query, 8);
                $_message = __('Skip Explain SQL');
            }
            if (isset($explain_params['sql_query'])) {
                $explain_link = 'import.php' . PMA_generate_common_url($explain_params);
                $explain_link = ' [' . PMA_linkOrButton($explain_link, $_message) . ']';
            }
        }
        //show explain
        $url_params['sql_query'] = $sql_query;
        $url_params['show_query'] = 1;
        // even if the query is big and was truncated, offer the chance
        // to edit it (unless it's enormous, see PMA_linkOrButton() )
        if (!empty($cfg['SQLQuery']['Edit'])) {
            if ($cfg['EditInWindow'] == true) {
                $onclick = 'window.parent.focus_querywindow(\'' . PMA_jsFormat($sql_query, false) . '\'); return false;';
            } else {
                $onclick = '';
            }
            $edit_link .= PMA_generate_common_url($url_params) . '#querybox';
            $edit_link = ' [' . PMA_linkOrButton($edit_link, __('Edit'), array('onclick' => $onclick)) . ']';
        } else {
            $edit_link = '';
        }
        $url_qpart = PMA_generate_common_url($url_params);
        // Also we would like to get the SQL formed in some nice
        // php-code
        if (!empty($cfg['SQLQuery']['ShowAsPHP']) && !$query_too_big) {
            $php_params = $url_params;
            if (!empty($GLOBALS['show_as_php'])) {
                $_message = __('Without PHP Code');
            } else {
                $php_params['show_as_php'] = 1;
                $_message = __('Create PHP Code');
            }
            $php_link = 'import.php' . PMA_generate_common_url($php_params);
            $php_link = ' [' . PMA_linkOrButton($php_link, $_message) . ']';
            if (isset($GLOBALS['show_as_php'])) {
                $runquery_link = 'import.php' . PMA_generate_common_url($url_params);
                $php_link .= ' [' . PMA_linkOrButton($runquery_link, __('Submit Query')) . ']';
            }
        } else {
            $php_link = '';
        }
        //show as php
        // Refresh query
        if (!empty($cfg['SQLQuery']['Refresh']) && !isset($GLOBALS['show_as_php']) && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)) {
            $refresh_link = 'import.php' . PMA_generate_common_url($url_params);
            $refresh_link = ' [' . PMA_linkOrButton($refresh_link, __('Refresh')) . ']';
        } else {
            $refresh_link = '';
        }
        //refresh
        if (!empty($cfg['SQLValidator']['use']) && !empty($cfg['SQLQuery']['Validate'])) {
            $validate_params = $url_params;
            if (!empty($GLOBALS['validatequery'])) {
                $validate_message = __('Skip Validate SQL');
            } else {
                $validate_params['validatequery'] = 1;
                $validate_message = __('Validate SQL');
            }
            $validate_link = 'import.php' . PMA_generate_common_url($validate_params);
            $validate_link = ' [' . PMA_linkOrButton($validate_link, $validate_message) . ']';
        } else {
            $validate_link = '';
        }
        //validator
        if (!empty($GLOBALS['validatequery'])) {
            echo '<div class="sqlvalidate">';
        } else {
            echo '<code class="sql">';
        }
        if ($query_too_big) {
            echo $shortened_query_base;
        } else {
            echo $query_base;
        }
        //Clean up the end of the PHP
        if (!empty($GLOBALS['show_as_php'])) {
            echo '";';
        }
        if (!empty($GLOBALS['validatequery'])) {
            echo '</div>';
        } else {
            echo '</code>';
        }
        echo '<div class="tools">';
        // avoid displaying a Profiling checkbox that could
        // be checked, which would reexecute an INSERT, for example
        if (!empty($refresh_link)) {
            PMA_profilingCheckbox($sql_query);
        }
        // if needed, generate an invisible form that contains controls for the
        // Inline link; this way, the behavior of the Inline link does not
        // depend on the profiling support or on the refresh link
        if (empty($refresh_link) || !PMA_profilingSupported()) {
            echo '<form action="sql.php" method="post">';
            echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']);
            echo '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />';
            echo '</form>';
        }
        // in the tools div, only display the Inline link when not in ajax
        // mode because 1) it currently does not work and 2) we would
        // have two similar mechanisms on the page for the same goal
        if ($is_select || $GLOBALS['is_ajax_request'] === false && !$query_too_big) {
            // see in js/functions.js the jQuery code attached to id inline_edit
            // document.write conflicts with jQuery, hence used $().append()
            echo "<script type=\"text/javascript\">\n" . "//<![CDATA[\n" . "\$('.tools form').last().after('[<a href=\"#\" title=\"" . PMA_escapeJsString(__('Inline edit of this query')) . "\" class=\"inline_edit_sql\">" . PMA_escapeJsString(_pgettext('Inline edit query', 'Inline')) . "</a>]');\n" . "//]]>\n" . "</script>";
        }
        echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link;
        echo '</div>';
    }
    echo '</div>';
    if ($GLOBALS['is_ajax_request'] === false) {
        echo '<br class="clearfloat" />';
    }
    // If we are in an Ajax request, we have most probably been called in
    // PMA_ajaxResponse().  Hence, collect the buffer contents and return it
    // to PMA_ajaxResponse(), which will encode it for JSON.
    if ($GLOBALS['is_ajax_request'] == true && !isset($GLOBALS['buffer_message'])) {
        $buffer_contents = ob_get_contents();
        ob_end_clean();
        return $buffer_contents;
    }
    return null;
}
示例#14
0
 /**
  * decode $message, taking into account our special codes
  * for formatting
  *
  * @param string $message the message
  *
  * @return string  the decoded message
  * @access  public
  * @static
  */
 public static function decodeBB($message)
 {
     return PMA_sanitize($message, false, true);
 }
示例#15
0
/**
 * User is not allowed to login to MySQL -> authentication failed
 *
 * @return  boolean   always true (no return indeed)
 *
 * @access  public
 */
function PMA_auth_fails()
{
    /* Session name */
    $session_name = $GLOBALS['cfg']['Server']['SignonSession'];
    /* Does session exist? */
    if (isset($_COOKIE[$session_name])) {
        /* End current session */
        $old_session = session_name();
        $old_id = session_id();
        session_write_close();
        /* Load single signon session */
        session_name($session_name);
        session_id($_COOKIE[$session_name]);
        session_start();
        /* Set error message */
        if (!empty($GLOBALS['login_without_password_is_forbidden'])) {
            $_SESSION['PMA_single_signon_error_message'] = __('Login without a password is forbidden by configuration (see AllowNoPassword)');
        } elseif (!empty($GLOBALS['allowDeny_forbidden'])) {
            $_SESSION['PMA_single_signon_error_message'] = __('Access denied');
        } elseif (!empty($GLOBALS['no_activity'])) {
            $_SESSION['PMA_single_signon_error_message'] = sprintf(__('No activity within %s seconds; please log in again'), $GLOBALS['cfg']['LoginCookieValidity']);
        } elseif (PMA_DBI_getError()) {
            $_SESSION['PMA_single_signon_error_message'] = PMA_sanitize(PMA_DBI_getError());
        } elseif (isset($php_errormsg)) {
            $_SESSION['PMA_single_signon_error_message'] = $php_errormsg;
        } else {
            $_SESSION['PMA_single_signon_error_message'] = __('Cannot log in to the MySQL server');
        }
    }
    PMA_auth();
}
示例#16
0
        padding: 0.3em;
        font-size: 1.4em;
        font-weight: bold;
        color: #ffffff;
        background-color: #ff0000;
    }
    p {
        margin: 0;
        padding: 0.5em;
        border: 0.1em solid red;
        background-color: #ffeeee;
    }
    //-->
    </style>
</head>
<body>
<h1>phpMyAdmin - <?php 
echo $type;
?>
</h1>
<p><?php 
if (get_magic_quotes_gpc()) {
    echo PMA_sanitize(stripslashes($_REQUEST['error']));
} else {
    echo PMA_sanitize($_REQUEST['error']);
}
?>
</p>
</body>
</html>
示例#17
0
echo '<select id="lang" name="lang" class="autosubmit" lang="en" dir="ltr">';
// create language list
$lang_list = array();
foreach ($all_languages as $each_lang_key => $each_lang) {
    $lang_name = PMA_languageName($each_lang);
    //Is current one active?
    $selected = $GLOBALS['lang'] == $each_lang_key ? ' selected="selected"' : '';
    echo '<option value="' . $each_lang_key . '"' . $selected . '>' . $lang_name . '</option>' . "\n";
}
echo '</select>';
echo '</form>';
// Check for done action info and set notice message if present
switch ($action_done) {
    case 'config_saved':
        /* Use uniqid to display this message every time configuration is saved */
        PMA_messagesSet('notice', uniqid('config_saved'), __('Configuration saved.'), PMA_sanitize(__('Configuration saved to file config/config.inc.php in phpMyAdmin ' . 'top level directory, copy it to top level one and delete ' . 'directory config to use it.')));
        break;
    default:
        break;
}
echo '<h2>' . __('Overview') . '</h2>';
// message handling
PMA_messagesEnd();
PMA_messagesShowHtml();
echo '<a href="#" id="show_hidden_messages" style="display:none">';
echo __('Show hidden messages (#MSG_COUNT)');
echo '</a>';
echo '<fieldset class="simple"><legend>';
echo __('Servers');
echo '</legend>';
//
示例#18
0
 * If someday there is a constant that we can check about mysqlnd, we can use it instead
 * of strpos().
 * If no default server is set, PMA_DBI_get_client_info() is not defined yet.
 */
if (function_exists('PMA_DBI_get_client_info')) {
    $_client_info = PMA_DBI_get_client_info();
    if ($server > 0 && strpos($_client_info, 'mysqlnd') === false && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)) {
        trigger_error(PMA_sanitize(sprintf(__('Your PHP MySQL library version %s differs from your MySQL server version %s. This may cause unpredictable behavior.'), $_client_info, substr(PMA_MYSQL_STR_VERSION, 0, strpos(PMA_MYSQL_STR_VERSION . '-', '-')))), E_USER_NOTICE);
    }
    unset($_client_info);
}
/**
 * Warning about Suhosin
 */
if ($cfg['SuhosinDisableWarning'] == false && @ini_get('suhosin.request.max_value_length')) {
    trigger_error(PMA_sanitize(sprintf(__('Server running with Suhosin. Please refer to %sdocumentation%s for possible issues.'), '[a@./Documentation.html#faq1_38@_blank]', '[/a]')), E_USER_WARNING);
}
/**
 * Warning about incomplete translations.
 *
 * The data file is created while creating release by ./scripts/remove-incomplete-mo
 */
if (file_exists('./libraries/language_stats.inc.php')) {
    include './libraries/language_stats.inc.php';
    /*
     * This message is intentionally not translated, because we're
     * handling incomplete translations here and focus on english
     * speaking users.
     */
    if (isset($GLOBALS['language_stats'][$lang]) && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']) {
        trigger_error('You are using an incomplete translation, please help to make it better by <a href="http://www.phpmyadmin.net/home_page/improve.php#translate" target="_blank">contributing</a>.', E_USER_NOTICE);
示例#19
0
    $stripped_sql_query = $sql_query;
    include_once 'libraries/header.inc.php';
    if ($is_drop_database) {
        echo '<h1 class="error">' . __('You are about to DESTROY a complete database!') . '</h1>';
    }
    echo '<form action="sql.php" method="post">' . "\n"
        .PMA_generate_common_hidden_inputs($db, $table);
    ?>
    <input type="hidden" name="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
    <input type="hidden" name="message_to_show" value="<?php echo isset($message_to_show) ? PMA_sanitize($message_to_show, true) : ''; ?>" />
    <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
    <input type="hidden" name="back" value="<?php echo isset($back) ? PMA_sanitize($back, true) : ''; ?>" />
    <input type="hidden" name="reload" value="<?php echo isset($reload) ? PMA_sanitize($reload, true) : 0; ?>" />
    <input type="hidden" name="purge" value="<?php echo isset($purge) ? PMA_sanitize($purge, true) : ''; ?>" />
    <input type="hidden" name="dropped_column" value="<?php echo isset($dropped_column) ? PMA_sanitize($dropped_column, true) : ''; ?>" />
    <input type="hidden" name="show_query" value="<?php echo isset($show_query) ? PMA_sanitize($show_query, true) : ''; ?>" />
    <?php
    echo '<fieldset class="confirmation">' . "\n"
        .'    <legend>' . __('Do you really want to execute following query?') . '</legend>'
        .'    <code>' . htmlspecialchars($stripped_sql_query) . '</code>' . "\n"
        .'</fieldset>' . "\n"
        .'<fieldset class="tblFooters">' . "\n";
    ?>
    <input type="submit" name="btnDrop" value="<?php echo __('Yes'); ?>" id="buttonYes" />
    <input type="submit" name="btnDrop" value="<?php echo __('No'); ?>" id="buttonNo" />
    <?php
    echo '</fieldset>' . "\n"
       . '</form>' . "\n";

    /**
     * Displays the footer and exit
示例#20
0
/**
 * Displays a table of results returned by a SQL query.
 * This function is called by the "sql.php" script.
 *
 * @param   integer the link id associated to the query which results have
 *                  to be displayed
 * @param   array   the display mode
 * @param   array   the analyzed query
 *
 * @uses    $_SESSION['tmp_user_values']['pos']
 * @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  string   $sql_query         the current SQL query
 * @global  integer  $num_rows          the total number of rows returned by the
 *                                      SQL query
 * @global  integer  $unlim_num_rows    the total number of rows returned by the
 *                                      SQL query without any programmatically
 *                                      appended "LIMIT" clause
 * @global  array    $fields_meta       the list of fields properties
 * @global  integer  $fields_cnt        the total number of fields returned by
 *                                      the SQL query
 * @global  array    $vertical_display  informations used with vertical display
 *                                      mode
 * @global  array    $highlight_columns column names to highlight
 * @global  array    $cfgRelation       the relation settings
 *
 * @access  private
 *
 * @see     PMA_showMessage(), PMA_setDisplayMode(),
 *          PMA_displayTableNavigation(), PMA_displayTableHeaders(),
 *          PMA_displayTableBody(), PMA_displayResultsOperations()
 */
function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
{
    global $db, $table, $goto;
    global $sql_query, $num_rows, $unlim_num_rows, $fields_meta, $fields_cnt;
    global $vertical_display, $highlight_columns;
    global $cfgRelation;
    global $showtable;
    // why was this called here? (already called from sql.php)
    //PMA_displayTable_checkConfigParams();
    /**
     * @todo move this to a central place
     * @todo for other future table types
     */
    $is_innodb = isset($showtable['Type']) && $showtable['Type'] == 'InnoDB';
    if ($is_innodb && !isset($analyzed_sql[0]['queryflags']['union']) && !isset($analyzed_sql[0]['table_ref'][1]['table_name']) && (empty($analyzed_sql[0]['where_clause']) || $analyzed_sql[0]['where_clause'] == '1 ')) {
        // "j u s t   b r o w s i n g"
        $pre_count = '~';
        $after_count = PMA_showHint(PMA_sanitize($GLOBALS['strApproximateCount']), true);
    } else {
        $pre_count = '';
        $after_count = '';
    }
    // 1. ----- Prepares the work -----
    // 1.1 Gets the informations about which functionalities should be
    //     displayed
    $total = '';
    $is_display = PMA_setDisplayMode($the_disp_mode, $total);
    // 1.2 Defines offsets for the next and previous pages
    if ($is_display['nav_bar'] == '1') {
        if ($_SESSION['tmp_user_values']['max_rows'] == 'all') {
            $pos_next = 0;
            $pos_prev = 0;
        } else {
            $pos_next = $_SESSION['tmp_user_values']['pos'] + $_SESSION['tmp_user_values']['max_rows'];
            $pos_prev = $_SESSION['tmp_user_values']['pos'] - $_SESSION['tmp_user_values']['max_rows'];
            if ($pos_prev < 0) {
                $pos_prev = 0;
            }
        }
    }
    // end if
    // 1.3 Find the sort expression
    // we need $sort_expression and $sort_expression_nodirection
    // even if there are many table references
    if (!empty($analyzed_sql[0]['order_by_clause'])) {
        $sort_expression = trim(str_replace('  ', ' ', $analyzed_sql[0]['order_by_clause']));
        /**
         * Get rid of ASC|DESC
         */
        preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches);
        $sort_expression_nodirection = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
        $sort_direction = isset($matches[2]) ? trim($matches[2]) : '';
        unset($matches);
    } else {
        $sort_expression = $sort_expression_nodirection = $sort_direction = '';
    }
    // 1.4 Prepares display of first and last value of the sorted column
    if (!empty($sort_expression_nodirection)) {
        list($sort_table, $sort_column) = explode('.', $sort_expression_nodirection);
        $sort_table = PMA_unQuote($sort_table);
        $sort_column = PMA_unQuote($sort_column);
        // find the sorted column index in row result
        // (this might be a multi-table query)
        $sorted_column_index = false;
        foreach ($fields_meta as $key => $meta) {
            if ($meta->table == $sort_table && $meta->name == $sort_column) {
                $sorted_column_index = $key;
                break;
            }
        }
        if ($sorted_column_index !== false) {
            // fetch first row of the result set
            $row = PMA_DBI_fetch_row($dt_result);
            $column_for_first_row = substr($row[$sorted_column_index], 0, $GLOBALS['cfg']['LimitChars']);
            // fetch last row of the result set
            PMA_DBI_data_seek($dt_result, $num_rows - 1);
            $row = PMA_DBI_fetch_row($dt_result);
            $column_for_last_row = substr($row[$sorted_column_index], 0, $GLOBALS['cfg']['LimitChars']);
            // reset to first row for the loop in PMA_displayTableBody()
            PMA_DBI_data_seek($dt_result, 0);
            // we could also use here $sort_expression_nodirection
            $sorted_column_message = ' [' . htmlspecialchars($sort_column) . ': <strong>' . htmlspecialchars($column_for_first_row) . ' - ' . htmlspecialchars($column_for_last_row) . '</strong>]';
            unset($row, $column_for_first_row, $column_for_last_row);
        }
        unset($sorted_column_index, $sort_table, $sort_column);
    }
    // 2. ----- Displays the top of the page -----
    // 2.1 Displays a messages with position informations
    if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
        if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
            $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
        } else {
            $selectstring = '';
        }
        $last_shown_rec = $_SESSION['tmp_user_values']['max_rows'] == 'all' || $pos_next > $total ? $total - 1 : $pos_next - 1;
        if (PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCountViews']) {
            $message = PMA_Message::notice('strViewHasAtLeast');
            $message->addParam('[a@./Documentation.html#cfg_MaxExactCount@_blank]');
            $message->addParam('[/a]');
            $message_view_warning = PMA_showHint($message);
        } else {
            $message_view_warning = false;
        }
        $message = PMA_Message::success('strShowingRecords');
        $message->addMessage($_SESSION['tmp_user_values']['pos']);
        if ($message_view_warning) {
            $message->addMessage('...', ' - ');
            $message->addMessage($message_view_warning);
            $message->addMessage('(');
        } else {
            $message->addMessage($last_shown_rec, ' - ');
            $message->addMessage($pre_count . PMA_formatNumber($total, 0) . $after_count, ' (');
            $message->addString('strTotal');
            $message->addMessage($selectstring, '');
            $message->addMessage(', ', '');
        }
        $messagge_qt = PMA_Message::notice('strQueryTime');
        $messagge_qt->addParam($GLOBALS['querytime']);
        $message->addMessage($messagge_qt, '');
        $message->addMessage(')', '');
        $message->addMessage(isset($sorted_column_message) ? $sorted_column_message : '', '');
        PMA_showMessage($message, $sql_query, 'success');
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        PMA_showMessage($GLOBALS['strSuccess'], $sql_query, 'success');
    }
    // 2.3 Displays the navigation bars
    if (!strlen($table)) {
        if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == 'SELECT') {
            // table does not always contain a real table name,
            // for example in MySQL 5.0.x, the query SHOW STATUS
            // returns STATUS as a table name
            $table = $fields_meta[0]->table;
        } else {
            $table = '';
        }
    }
    if ($is_display['nav_bar'] == '1') {
        PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, 'top_direction_dropdown');
        echo "\n";
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        echo "\n" . '<br /><br />' . "\n";
    }
    // 2b ----- Get field references from Database -----
    // (see the 'relation' configuration variable)
    // loic1, 2002-03-02: extended to php3
    // initialize map
    $map = array();
    // find tables
    $target = array();
    if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
        foreach ($analyzed_sql[0]['table_ref'] as $table_ref_position => $table_ref) {
            $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
        }
    }
    $tabs = '(\'' . join('\',\'', $target) . '\')';
    if ($cfgRelation['displaywork']) {
        if (!strlen($table)) {
            $exist_rel = false;
        } else {
            $exist_rel = PMA_getForeigners($db, $table, '', 'both');
            if ($exist_rel) {
                foreach ($exist_rel as $master_field => $rel) {
                    $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
                    $map[$master_field] = array($rel['foreign_table'], $rel['foreign_field'], $display_field, $rel['foreign_db']);
                }
                // end while
            }
            // end if
        }
        // end if
    }
    // end if
    // end 2b
    // 3. ----- Displays the results table -----
    PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql, $sort_expression, $sort_expression_nodirection, $sort_direction);
    $url_query = '';
    echo '<tbody>' . "\n";
    $clause_is_unique = PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
    // vertical output case
    if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') {
        PMA_displayVerticalTable();
    }
    // end if
    unset($vertical_display);
    echo '</tbody>' . "\n";
    ?>
</table>

    <?php 
    // 4. ----- Displays the link for multi-fields edit and delete
    if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') {
        $delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill'];
        $_url_params = array('db' => $db, 'table' => $table, 'sql_query' => $sql_query, 'goto' => $goto);
        $uncheckall_url = 'sql.php' . PMA_generate_common_url($_url_params);
        $_url_params['checkall'] = '1';
        $checkall_url = 'sql.php' . PMA_generate_common_url($_url_params);
        if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') {
            $checkall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', true)) return false;';
            $uncheckall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', false)) return false;';
        } else {
            $checkall_params['onclick'] = 'if (markAllRows(\'rowsDeleteForm\')) return false;';
            $uncheckall_params['onclick'] = 'if (unMarkAllRows(\'rowsDeleteForm\')) return false;';
        }
        $checkall_link = PMA_linkOrButton($checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false);
        $uncheckall_link = PMA_linkOrButton($uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false);
        if ($_SESSION['tmp_user_values']['disp_direction'] != 'vertical') {
            echo '<img class="selectallarrow" width="38" height="22"' . ' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"' . ' alt="' . $GLOBALS['strWithChecked'] . '" />';
        }
        echo $checkall_link . "\n" . ' / ' . "\n" . $uncheckall_link . "\n" . '<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n";
        PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png');
        PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_delete', $delete_text, 'b_drop.png');
        if ($analyzed_sql[0]['querytype'] == 'SELECT') {
            PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', $GLOBALS['strExport'], 'b_tblexport.png');
        }
        echo "\n";
        echo '<input type="hidden" name="sql_query"' . ' value="' . htmlspecialchars($sql_query) . '" />' . "\n";
        echo '<input type="hidden" name="url_query"' . ' value="' . $GLOBALS['url_query'] . '" />' . "\n";
        echo '<input type="hidden" name="clause_is_unique"' . ' value="' . $clause_is_unique . '" />' . "\n";
        echo '</form>' . "\n";
    }
    // 5. ----- Displays the navigation bar at the bottom if required -----
    if ($is_display['nav_bar'] == '1') {
        echo '<br />' . "\n";
        PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, 'bottom_direction_dropdown');
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        echo "\n" . '<br /><br />' . "\n";
    }
    // 6. ----- Displays "Query results operations"
    if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        PMA_displayResultsOperations($the_disp_mode, $analyzed_sql);
    }
}
 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     // Add/Remove favorite tables using Ajax request.
     if ($GLOBALS['is_ajax_request'] && !empty($_REQUEST['favorite_table'])) {
         $this->addRemoveFavoriteTablesAction();
         return;
     }
     $this->response->getHeader()->getScripts()->addFiles(array('db_structure.js', 'tbl_change.js', 'jquery/jquery-ui-timepicker-addon.js'));
     // Drops/deletes/etc. multiple tables if required
     if (!empty($_POST['submit_mult']) && isset($_POST['selected_tbl']) || isset($_POST['mult_btn'])) {
         $action = 'db_structure.php';
         $err_url = 'db_structure.php' . PMA_URL_getCommon(array('db' => $this->db));
         // see bug #2794840; in this case, code path is:
         // db_structure.php -> libraries/mult_submits.inc.php -> sql.php
         // -> db_structure.php and if we got an error on the multi submit,
         // we must display it here and not call again mult_submits.inc.php
         if (!isset($_POST['error']) || false === $_POST['error']) {
             include 'libraries/mult_submits.inc.php';
         }
         if (empty($_POST['message'])) {
             $_POST['message'] = PMA_Message::success();
         }
     }
     $this->_url_query .= '&amp;goto=db_structure.php';
     // Gets the database structure
     $sub_part = '_structure';
     list($tables, $num_tables, $total_num_tables, $sub_part, $is_show_stats, $db_is_system_schema, $tooltip_truename, $tooltip_aliasname, $pos) = PMA_Util::getDbInfo($GLOBALS['db'], isset($sub_part) ? $sub_part : '');
     $this->_tables = $tables;
     // updating $tables seems enough for #11376, but updating other
     // variables too in case they may cause some other problem.
     $this->_num_tables = $num_tables;
     $this->_pos = $pos;
     $this->_db_is_system_schema = $db_is_system_schema;
     $this->_total_num_tables = $total_num_tables;
     $this->_is_show_stats = $is_show_stats;
     // If there is an Ajax request for real row count of a table.
     if ($GLOBALS['is_ajax_request'] && isset($_REQUEST['real_row_count']) && $_REQUEST['real_row_count'] == true) {
         $this->handleRealRowCountRequestAction();
         return;
     }
     if (!PMA_DRIZZLE) {
         include_once 'libraries/replication.inc.php';
     } else {
         $GLOBALS['replication_info']['slave']['status'] = false;
     }
     PMA_PageSettings::showGroup('DbStructure');
     $db_collation = PMA_getDbCollation($this->db);
     $titles = PMA_Util::buildActionTitles();
     // 1. No tables
     if ($this->_num_tables == 0) {
         $this->response->addHTML(PMA_message::notice(__('No tables found in database.')));
         if (empty($db_is_system_schema)) {
             $this->response->addHTML(PMA_getHtmlForCreateTable($this->db));
         }
         return;
     }
     // else
     // 2. Shows table information
     /**
      * Displays the tables list
      */
     $this->response->addHTML('<div id="tableslistcontainer">');
     $_url_params = array('pos' => $this->_pos, 'db' => $this->db);
     // Add the sort options if they exists
     if (isset($_REQUEST['sort'])) {
         $_url_params['sort'] = $_REQUEST['sort'];
     }
     if (isset($_REQUEST['sort_order'])) {
         $_url_params['sort_order'] = $_REQUEST['sort_order'];
     }
     $this->response->addHTML(PMA_Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']));
     // table form
     $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
     $i = $sum_entries = 0;
     $overhead_check = '';
     $create_time_all = '';
     $update_time_all = '';
     $check_time_all = '';
     $num_columns = $GLOBALS['cfg']['PropertiesNumColumns'] > 1 ? ceil($this->_num_tables / $GLOBALS['cfg']['PropertiesNumColumns']) + 1 : 0;
     $row_count = 0;
     $sum_size = (double) 0;
     $overhead_size = (double) 0;
     $hidden_fields = array();
     $odd_row = true;
     $overall_approx_rows = false;
     // Instance of PMA_RecentFavoriteTable class.
     $fav_instance = PMA_RecentFavoriteTable::getInstance('favorite');
     foreach ($this->_tables as $keyname => $current_table) {
         // Get valid statistics whatever is the table type
         $drop_query = '';
         $drop_message = '';
         $already_favorite = false;
         $overhead = '';
         $table_is_view = false;
         $table_encoded = urlencode($current_table['TABLE_NAME']);
         // Sets parameters for links
         $tbl_url_query = $this->_url_query . '&amp;table=' . $table_encoded;
         // do not list the previous table's size info for a view
         list($current_table, $formatted_size, $unit, $formatted_overhead, $overhead_unit, $overhead_size, $table_is_view, $sum_size) = $this->getStuffForEngineTypeTable($current_table, $sum_size, $overhead_size);
         $curTable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME']);
         if (!$curTable->isMerge()) {
             $sum_entries += $current_table['TABLE_ROWS'];
         }
         if (isset($current_table['Collation'])) {
             $collation = '<dfn title="' . PMA_getCollationDescr($current_table['Collation']) . '">' . $current_table['Collation'] . '</dfn>';
         } else {
             $collation = '---';
         }
         if ($this->_is_show_stats) {
             if ($formatted_overhead != '') {
                 $overhead = '<a href="tbl_structure.php' . $tbl_url_query . '#showusage">' . '<span>' . $formatted_overhead . '</span>&nbsp;' . '<span class="unit">' . $overhead_unit . '</span>' . '</a>' . "\n";
                 $overhead_check .= "markAllRows('row_tbl_" . ($i + 1) . "');";
             } else {
                 $overhead = '-';
             }
         }
         // end if
         $showtable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME'])->getStatusInfo(null, true);
         if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
             $create_time = isset($showtable['Create_time']) ? $showtable['Create_time'] : '';
             if ($create_time && (!$create_time_all || $create_time < $create_time_all)) {
                 $create_time_all = $create_time;
             }
         }
         if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
             // $showtable might already be set from ShowDbStructureCreation,
             // see above
             $update_time = isset($showtable['Update_time']) ? $showtable['Update_time'] : '';
             if ($update_time && (!$update_time_all || $update_time < $update_time_all)) {
                 $update_time_all = $update_time;
             }
         }
         if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
             // $showtable might already be set from ShowDbStructureCreation,
             // see above
             $check_time = isset($showtable['Check_time']) ? $showtable['Check_time'] : '';
             if ($check_time && (!$check_time_all || $check_time < $check_time_all)) {
                 $check_time_all = $check_time;
             }
         }
         $alias = htmlspecialchars(!empty($tooltip_aliasname) && isset($tooltip_aliasname[$current_table['TABLE_NAME']]) ? $tooltip_aliasname[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']);
         $alias = str_replace(' ', '&nbsp;', $alias);
         $truename = htmlspecialchars(!empty($tooltip_truename) && isset($tooltip_truename[$current_table['TABLE_NAME']]) ? $tooltip_truename[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']);
         $truename = str_replace(' ', '&nbsp;', $truename);
         $i++;
         $row_count++;
         if ($table_is_view) {
             $hidden_fields[] = '<input type="hidden" name="views[]" value="' . htmlspecialchars($current_table['TABLE_NAME']) . '" />';
         }
         /*
          * Always activate links for Browse, Search and Empty, even if
          * the icons are greyed, because
          * 1. for views, we don't know the number of rows at this point
          * 2. for tables, another source could have populated them since the
          *    page was generated
          *
          * I could have used the PHP ternary conditional operator but I find
          * the code easier to read without this operator.
          */
         $may_have_rows = $current_table['TABLE_ROWS'] > 0 || $table_is_view;
         $browse_table = Template::get('database/structure/browse_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Browse'] : $titles['NoBrowse']));
         $search_table = Template::get('database/structure/search_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Search'] : $titles['NoSearch']));
         $browse_table_label = Template::get('database/structure/browse_table_label')->render(array('tbl_url_query' => $tbl_url_query, 'title' => htmlspecialchars($current_table['TABLE_COMMENT']), 'truename' => $truename));
         $empty_table = '';
         if (!$this->_db_is_system_schema) {
             $empty_table = '&nbsp;';
             if (!$table_is_view) {
                 $empty_table = Template::get('database/structure/empty_table')->render(array('tbl_url_query' => $tbl_url_query, 'sql_query' => urlencode('TRUNCATE ' . PMA_Util::backquote($current_table['TABLE_NAME'])), 'message_to_show' => urlencode(sprintf(__('Table %s has been emptied.'), htmlspecialchars($current_table['TABLE_NAME']))), 'title' => $may_have_rows ? $titles['Empty'] : $titles['NoEmpty']));
             }
             $drop_query = sprintf('DROP %s %s', $table_is_view || $current_table['ENGINE'] == null ? 'VIEW' : 'TABLE', PMA_Util::backquote($current_table['TABLE_NAME']));
             $drop_message = sprintf($table_is_view || $current_table['ENGINE'] == null ? __('View %s has been dropped.') : __('Table %s has been dropped.'), str_replace(' ', '&nbsp;', htmlspecialchars($current_table['TABLE_NAME'])));
         }
         $tracking_icon = '';
         if (PMA_Tracker::isActive()) {
             $is_tracked = PMA_Tracker::isTracked($GLOBALS["db"], $truename);
             if ($is_tracked || PMA_Tracker::getVersion($GLOBALS["db"], $truename) > 0) {
                 $tracking_icon = Template::get('database/structure/tracking_icon')->render(array('url_query' => $this->_url_query, 'truename' => $truename, 'is_tracked' => $is_tracked));
             }
         }
         if ($num_columns > 0 && $this->_num_tables > $num_columns && $row_count % $num_columns == 0) {
             $row_count = 1;
             $odd_row = true;
             $this->response->addHTML('</tr></tbody></table>');
             $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db_is_system_schema' => false, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
         }
         $do = $ignored = false;
         if ($GLOBALS['replication_info']['slave']['status']) {
             $nbServSlaveDoDb = count($GLOBALS['replication_info']['slave']['Do_DB']);
             $nbServSlaveIgnoreDb = count($GLOBALS['replication_info']['slave']['Ignore_DB']);
             $searchDoDBInTruename = array_search($truename, $GLOBALS['replication_info']['slave']['Do_DB']);
             $searchDoDBInDB = array_search($this->db, $GLOBALS['replication_info']['slave']['Do_DB']);
             $do = strlen($searchDoDBInTruename) > 0 || strlen($searchDoDBInDB) > 0 || $nbServSlaveDoDb == 1 && $nbServSlaveIgnoreDb == 1 || $this->hasTable($GLOBALS['replication_info']['slave']['Wild_Do_Table'], $truename);
             $searchDb = array_search($this->db, $GLOBALS['replication_info']['slave']['Ignore_DB']);
             $searchTable = array_search($truename, $GLOBALS['replication_info']['slave']['Ignore_Table']);
             $ignored = strlen($searchTable) > 0 || strlen($searchDb) > 0 || $this->hasTable($GLOBALS['replication_info']['slave']['Wild_Ignore_Table'], $truename);
         }
         // Handle favorite table list. ----START----
         $already_favorite = $this->checkFavoriteTable($current_table['TABLE_NAME']);
         if (isset($_REQUEST['remove_favorite'])) {
             if ($already_favorite) {
                 // If already in favorite list, remove it.
                 $favorite_table = $_REQUEST['favorite_table'];
                 $fav_instance->remove($this->db, $favorite_table);
             }
         }
         if (isset($_REQUEST['add_favorite'])) {
             if (!$already_favorite) {
                 // Otherwise add to favorite list.
                 $favorite_table = $_REQUEST['favorite_table'];
                 $fav_instance->add($this->db, $favorite_table);
             }
         }
         // Handle favorite table list. ----ENDS----
         $show_superscript = '';
         // there is a null value in the ENGINE
         // - when the table needs to be repaired, or
         // - when it's a view
         //  so ensure that we'll display "in use" below for a table
         //  that needs to be repaired
         $approx_rows = false;
         if (isset($current_table['TABLE_ROWS']) && ($current_table['ENGINE'] != null || $table_is_view)) {
             // InnoDB table: we did not get an accurate row count
             $approx_rows = !$table_is_view && $current_table['ENGINE'] == 'InnoDB' && !$current_table['COUNTED'];
             // Drizzle views use FunctionEngine, and the only place where
             // they are available are I_S and D_D schemas, where we do exact
             // counting
             if ($table_is_view && $current_table['TABLE_ROWS'] >= $GLOBALS['cfg']['MaxExactCountViews'] && $current_table['ENGINE'] != 'FunctionEngine') {
                 $approx_rows = true;
                 $show_superscript = PMA_Util::showHint(PMA_sanitize(sprintf(__('This view has at least this number of ' . 'rows. Please refer to %sdocumentation%s.'), '[doc@cfg_MaxExactCountViews]', '[/doc]')));
             }
         }
         $this->response->addHTML(Template::get('database/structure/structure_table_row')->render(array('db' => $this->db, 'curr' => $i, 'odd_row' => $odd_row, 'table_is_view' => $table_is_view, 'current_table' => $current_table, 'browse_table_label' => $browse_table_label, 'tracking_icon' => $tracking_icon, 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'browse_table' => $browse_table, 'tbl_url_query' => $tbl_url_query, 'search_table' => $search_table, 'db_is_system_schema' => $this->_db_is_system_schema, 'titles' => $titles, 'empty_table' => $empty_table, 'drop_query' => $drop_query, 'drop_message' => $drop_message, 'collation' => $collation, 'formatted_size' => $formatted_size, 'unit' => $unit, 'overhead' => $overhead, 'create_time' => isset($create_time) ? $create_time : '', 'update_time' => isset($update_time) ? $update_time : '', 'check_time' => isset($check_time) ? $check_time : '', 'is_show_stats' => $this->_is_show_stats, 'ignored' => $ignored, 'do' => $do, 'colspan_for_structure' => $GLOBALS['colspan_for_structure'], 'approx_rows' => $approx_rows, 'show_superscript' => $show_superscript, 'already_favorite' => $this->checkFavoriteTable($current_table['TABLE_NAME']))));
         $odd_row = !$odd_row;
         $overall_approx_rows = $overall_approx_rows || $approx_rows;
     }
     // end foreach
     // Show Summary
     $this->response->addHTML('</tbody>');
     $this->response->addHTML(Template::get('database/structure/body_for_table_summary')->render(array('num_tables' => $this->_num_tables, 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'db_is_system_schema' => $this->_db_is_system_schema, 'sum_entries' => $sum_entries, 'db_collation' => $db_collation, 'is_show_stats' => $this->_is_show_stats, 'sum_size' => $sum_size, 'overhead_size' => $overhead_size, 'create_time_all' => $create_time_all, 'update_time_all' => $update_time_all, 'check_time_all' => $check_time_all, 'approx_rows' => $overall_approx_rows)));
     $this->response->addHTML('</table>');
     //check all
     $this->response->addHTML(Template::get('database/structure/check_all_tables')->render(array('pmaThemeImage' => $GLOBALS['pmaThemeImage'], 'text_dir' => $GLOBALS['text_dir'], 'overhead_check' => $overhead_check, 'db_is_system_schema' => $this->_db_is_system_schema, 'hidden_fields' => $hidden_fields)));
     $this->response->addHTML('</form>');
     //end of form
     // display again the table list navigator
     $this->response->addHTML(PMA_Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']));
     $this->response->addHTML('</div><hr />');
     /**
      * Work on the database
      */
     /* DATABASE WORK */
     /* Printable view of a table */
     $this->response->addHTML(Template::get('database/structure/print_view_data_dictionary_link')->render(array('url_query' => $this->_url_query)));
     if (empty($db_is_system_schema)) {
         $this->response->addHTML(PMA_getHtmlForCreateTable($this->db));
     }
 }
示例#22
0
    }
    h1 {
        margin: 0;
        padding: 0.3em;
        font-size: 1.4em;
        font-weight: bold;
        color: #ffffff;
        background-color: #ff0000;
    }
    p {
        margin: 0;
        padding: 0.5em;
        border: 0.1em solid red;
        background-color: #ffeeee;
    }
    //-->
    </style>
</head>
<body>
<h1>phpMyAdmin - <?php 
echo $error_header;
?>
</h1>
<p><?php 
echo PMA_sanitize($error_message);
?>
</p>
</body>
</html>

示例#23
0
/**
 * Displays a table of results returned by a sql query.
 * This function is called by the "sql.php" script.
 *
 * @param   integer the link id associated to the query which results have
 *                  to be displayed
 * @param   array   the display mode
 * @param   array   the analyzed query
 *
 * @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 current sql query
 * @global  integer  $num_rows          the total number of rows returned by the
 *                                      sql query
 * @global  integer  $unlim_num_rows    the total number of rows returned by the
 *                                      sql query without any programmatically
 *                                      appended "LIMIT" clause
 * @global  integer  $pos               the current postion of the first record
 *                                      to be displayed
 * @global  array    $fields_meta       the list of fields properties
 * @global  integer  $fields_cnt        the total number of fields returned by
 *                                      the sql query
 * @global  array    $vertical_display  informations used with vertical display
 *                                      mode
 * @global  string   $disp_direction    the display mode
 *                                      (horizontal/vertical/horizontalflipped)
 * @global  integer  $repeat_cells      the number of row to display between two
 *                                      table headers
 * @global  array    $highlight_columns collumn names to highlight
 * @global  array    $cfgRelation       the relation settings
 *
 * @access  private
 *
 * @see     PMA_showMessage(), PMA_setDisplayMode(),
 *          PMA_displayTableNavigation(), PMA_displayTableHeaders(),
 *          PMA_displayTableBody(), PMA_displayResultsOperations()
 */
function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
{
    global $db, $table, $goto, $dontlimitchars;
    global $sql_query, $num_rows, $unlim_num_rows, $pos, $fields_meta, $fields_cnt;
    global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
    global $cfgRelation;
    // 1. ----- Prepares the work -----
    // 1.1 Gets the informations about which functionnalities should be
    //     displayed
    $total = '';
    $is_display = PMA_setDisplayMode($the_disp_mode, $total);
    if ($total == '') {
        unset($total);
    }
    // 1.2 Defines offsets for the next and previous pages
    if ($is_display['nav_bar'] == '1') {
        if (!isset($pos)) {
            $pos = 0;
        }
        if ($GLOBALS['session_max_rows'] == 'all') {
            $pos_next = 0;
            $pos_prev = 0;
        } else {
            $pos_next = $pos + $GLOBALS['cfg']['MaxRows'];
            $pos_prev = $pos - $GLOBALS['cfg']['MaxRows'];
            if ($pos_prev < 0) {
                $pos_prev = 0;
            }
        }
    }
    // end if
    // 1.3 Urlencodes the query to use in input form fields
    $encoded_sql_query = urlencode($sql_query);
    // 2. ----- Displays the top of the page -----
    // 2.1 Displays a messages with position informations
    if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
        if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
            $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
        } else {
            $selectstring = '';
        }
        $last_shown_rec = $GLOBALS['session_max_rows'] == 'all' || $pos_next > $total ? $total - 1 : $pos_next - 1;
        PMA_showMessage($GLOBALS['strShowingRecords'] . " {$pos} - {$last_shown_rec} (" . PMA_formatNumber($total, 0) . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
        if (isset($table) && PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCount']) {
            echo '<div class="notice">' . "\n";
            echo PMA_sanitize(sprintf($GLOBALS['strViewMaxExactCount'], PMA_formatNumber($GLOBALS['cfg']['MaxExactCount'], 0), '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]')) . "\n";
            echo '</div>' . "\n";
        }
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        PMA_showMessage($GLOBALS['strSQLQuery']);
    }
    // 2.3 Displays the navigation bars
    if (!isset($table) || strlen(trim($table)) == 0) {
        if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == 'SELECT') {
            // table does not always contain a real table name,
            // for example in MySQL 5.0.x, the query SHOW STATUS
            // returns STATUS as a table name
            $table = $fields_meta[0]->table;
        } else {
            $table = '';
        }
    }
    if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        PMA_displayResultsOperations($the_disp_mode, $analyzed_sql);
    }
    if ($is_display['nav_bar'] == '1') {
        PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
        echo "\n";
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        echo "\n" . '<br /><br />' . "\n";
    }
    // 2b ----- Get field references from Database -----
    // (see the 'relation' config variable)
    // loic1, 2002-03-02: extended to php3
    // init map
    $map = array();
    // find tables
    $target = array();
    if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
        foreach ($analyzed_sql[0]['table_ref'] as $table_ref_position => $table_ref) {
            $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
        }
    }
    $tabs = '(\'' . join('\',\'', $target) . '\')';
    if ($cfgRelation['displaywork']) {
        if (!isset($table) || !strlen($table)) {
            $exist_rel = false;
        } else {
            $exist_rel = PMA_getForeigners($db, $table, '', 'both');
            if ($exist_rel) {
                foreach ($exist_rel as $master_field => $rel) {
                    $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
                    $map[$master_field] = array($rel['foreign_table'], $rel['foreign_field'], $display_field, $rel['foreign_db']);
                }
                // end while
            }
            // end if
        }
        // end if
    }
    // end if
    // end 2b
    // 3. ----- Displays the results table -----
    PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql);
    $url_query = '';
    echo '<tbody>' . "\n";
    PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
    echo '</tbody>' . "\n";
    // vertical output case
    if ($disp_direction == 'vertical') {
        PMA_displayVerticalTable();
    }
    // end if
    unset($vertical_display);
    ?>
</table>

    <?php 
    // 4. ----- Displays the link for multi-fields delete
    if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') {
        $delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill'];
        $uncheckall_url = 'sql.php?' . PMA_generate_common_url($db, $table) . '&amp;sql_query=' . urlencode($sql_query) . '&amp;pos=' . $pos . '&amp;session_max_rows=' . $GLOBALS['session_max_rows'] . '&amp;pos=' . $pos . '&amp;disp_direction=' . $disp_direction . '&amp;repeat_cells=' . $repeat_cells . '&amp;goto=' . $goto . '&amp;dontlimitchars=' . $dontlimitchars;
        $checkall_url = $uncheckall_url . '&amp;checkall=1';
        if ($disp_direction == 'vertical') {
            $checkall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', true)) return false;';
            $uncheckall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', false)) return false;';
        } else {
            $checkall_params['onclick'] = 'if (markAllRows(\'rowsDeleteForm\')) return false;';
            $uncheckall_params['onclick'] = 'if (unMarkAllRows(\'rowsDeleteForm\')) return false;';
        }
        $checkall_link = PMA_linkOrButton($checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false);
        $uncheckall_link = PMA_linkOrButton($uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false);
        if ($disp_direction != 'vertical') {
            echo '<img class="selectallarrow" width="38" height="22"' . ' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"' . ' alt="' . $GLOBALS['strWithChecked'] . '" />';
        }
        echo $checkall_link . "\n" . ' / ' . "\n" . $uncheckall_link . "\n" . '<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n";
        if ($GLOBALS['cfg']['PropertiesIconic']) {
            PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png');
            PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_delete', $delete_text, 'b_drop.png');
            if ($analyzed_sql[0]['querytype'] == 'SELECT') {
                PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', $GLOBALS['strExport'], 'b_tblexport.png');
            }
            echo "\n";
        } else {
            echo ' <input type="submit" name="submit_mult"' . ' value="' . htmlspecialchars($GLOBALS['strEdit']) . '"' . ' title="' . $GLOBALS['strEdit'] . '" />' . "\n";
            echo ' <input type="submit" name="submit_mult"' . ' value="' . htmlspecialchars($delete_text) . '"' . ' title="' . $delete_text . '" />' . "\n";
            if ($analyzed_sql[0]['querytype'] == 'SELECT') {
                echo ' <input type="submit" name="submit_mult"' . ' value="' . htmlspecialchars($GLOBALS['strExport']) . '"' . ' title="' . $GLOBALS['strExport'] . '" />' . "\n";
            }
        }
        echo '<input type="hidden" name="sql_query"' . ' value="' . htmlspecialchars($sql_query) . '" />' . "\n";
        echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
        echo '<input type="hidden" name="url_query"' . ' value="' . $GLOBALS['url_query'] . '" />' . "\n";
        echo '</form>' . "\n";
    }
    // 5. ----- Displays the navigation bar at the bottom if required -----
    if ($is_display['nav_bar'] == '1') {
        echo '<br />' . "\n";
        PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        echo "\n" . '<br /><br />' . "\n";
    }
}
示例#24
0
    /**
     * Displays a message at the top of the "main" (right) frame
     *
     * @param   string  the message to display
     *
     * @global  array   the configuration array
     *
     * @access  public
     */
    function PMA_showMessage($message)
    {
        global $cfg;
        // Sanitizes $message
        $message = PMA_sanitize($message);
        // Corrects the tooltip text via JS if required
        if (!empty($GLOBALS['table']) && $cfg['ShowTooltip']) {
            $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\'');
            if ($result) {
                $tbl_status = PMA_DBI_fetch_assoc($result);
                $tooltip = empty($tbl_status['Comment']) ? '' : $tbl_status['Comment'] . ' ';
                $tooltip .= '(' . $tbl_status['Rows'] . ' ' . $GLOBALS['strRows'] . ')';
                PMA_DBI_free_result($result);
                $md5_tbl = md5($GLOBALS['table']);
                echo "\n";
                ?>
<script type="text/javascript" language="javascript1.2">
<!--
if (typeof(document.getElementById) != 'undefined'
    && typeof(window.parent.frames['nav']) != 'undefined'
    && typeof(window.parent.frames['nav'].document) != 'undefined' && typeof(window.parent.frames['nav'].document) != 'unknown'
    && (window.parent.frames['nav'].document.getElementById('<?php 
                echo 'tbl_' . $md5_tbl;
                ?>
'))
    && typeof(window.parent.frames['nav'].document.getElementById('<?php 
                echo 'tbl_' . $md5_tbl;
                ?>
')) != 'undefined'
    && typeof(window.parent.frames['nav'].document.getElementById('<?php 
                echo 'tbl_' . $md5_tbl;
                ?>
').title) == 'string') {
    window.parent.frames['nav'].document.getElementById('<?php 
                echo 'tbl_' . $md5_tbl;
                ?>
').title = '<?php 
                echo PMA_jsFormat($tooltip, FALSE);
                ?>
';
}
//-->
</script>
                <?php 
            }
            // end if
        }
        // end if... else if
        // Checks if the table needs to be repaired after a TRUNCATE query.
        if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query']) && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
            if (!isset($tbl_status)) {
                $result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\'');
                if ($result) {
                    $tbl_status = PMA_DBI_fetch_assoc($result);
                    PMA_DBI_free_result($result);
                }
            }
            if (isset($tbl_status) && (int) $tbl_status['Index_length'] > 1024) {
                PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table']));
            }
        }
        unset($tbl_status);
        echo "\n";
        ?>
<br />
<div align="<?php 
        echo $GLOBALS['cell_align_left'];
        ?>
">
    <table border="<?php 
        echo $cfg['Border'];
        ?>
" cellpadding="5" cellspacing="1">
    <tr>
        <th<?php 
        echo $GLOBALS['theme'] != 'original' ? ' class="tblHeaders"' : ' bgcolor="' . $cfg['ThBgcolor'] . '"';
        ?>
>
            <b><?php 
        echo $message;
        ?>
</b>
        </th>
    </tr>
        <?php 
        if ($cfg['ShowSQL'] == TRUE && (!empty($GLOBALS['sql_query']) || !empty($GLOBALS['display_query']))) {
            $local_query = !empty($GLOBALS['display_query']) ? $GLOBALS['display_query'] : ($cfg['SQP']['fmtType'] == 'none' && isset($GLOBALS['unparsed_sql']) && $GLOBALS['unparsed_sql'] != '' ? $GLOBALS['unparsed_sql'] : $GLOBALS['sql_query']);
            // Basic url query part
            $url_qpart = '?' . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : '');
            echo "\n";
            ?>
    <tr>
        <td bgcolor="<?php 
            echo $cfg['BgcolorOne'];
            ?>
">
            <?php 
            echo "\n";
            // Html format the query to be displayed
            // The nl2br function isn't used because its result isn't a valid
            // xhtml1.0 statement before php4.0.5 ("<br>" and not "<br />")
            // If we want to show some sql code it is easiest to create it here
            /* SQL-Parser-Analyzer */
            $sqlnr = 1;
            if (!empty($GLOBALS['show_as_php'])) {
                $new_line = '\'<br />' . "\n" . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. \' ';
            }
            if (isset($new_line)) {
                /* SQL-Parser-Analyzer */
                $query_base = PMA_sqlAddslashes(htmlspecialchars($local_query));
                /* SQL-Parser-Analyzer */
                $query_base = preg_replace("@((\r\n)|(\r)|(\n))+@", $new_line, $query_base);
            } else {
                $query_base = $local_query;
            }
            // Here we append the LIMIT added for navigation, to
            // enable its display. Adding it higher in the code
            // to $local_query would create a problem when
            // using the Refresh or Edit links.
            // Only append it on SELECTs.
            // FIXME: what would be the best to do when someone
            // hits Refresh: use the current LIMITs ?
            // TODO: use the parser instead of preg_match()
            if (preg_match('@^SELECT[[:space:]]+@i', $query_base) && isset($GLOBALS['sql_limit_to_append'])) {
                $query_base .= $GLOBALS['sql_limit_to_append'];
            }
            if (!empty($GLOBALS['show_as_php'])) {
                $query_base = '$sql  = \'' . $query_base;
            } else {
                if (!empty($GLOBALS['validatequery'])) {
                    $query_base = PMA_validateSQL($query_base);
                } else {
                    // avoid reparsing query:
                    if (isset($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) {
                        $parsed_sql = $GLOBALS['parsed_sql'];
                    } else {
                        $parsed_sql = PMA_SQP_parse($query_base);
                    }
                    $query_base = PMA_formatSql($parsed_sql, $query_base);
                }
            }
            // Prepares links that may be displayed to edit/explain the query
            // (don't go to default pages, we must go to the page
            // where the query box is available)
            // (also, I don't see why we should check the goto variable)
            //if (!isset($GLOBALS['goto'])) {
            //$edit_target = (isset($GLOBALS['table'])) ? $cfg['DefaultTabTable'] : $cfg['DefaultTabDatabase'];
            $edit_target = isset($GLOBALS['db']) ? isset($GLOBALS['table']) ? 'tbl_properties.php' : 'db_details.php' : '';
            //} else if ($GLOBALS['goto'] != 'main.php') {
            //    $edit_target = $GLOBALS['goto'];
            //} else {
            //    $edit_target = '';
            //}
            if (isset($cfg['SQLQuery']['Edit']) && $cfg['SQLQuery']['Edit'] == TRUE && !empty($edit_target)) {
                $onclick = '';
                if ($cfg['QueryFrameJS'] && $cfg['QueryFrame']) {
                    $onclick = 'onclick="focus_querywindow(\'' . urlencode($local_query) . '\'); return false;"';
                }
                $edit_link = '&nbsp;[<a href="' . $edit_target . $url_qpart . '&amp;sql_query=' . urlencode($local_query) . '&amp;show_query=1#querybox" ' . $onclick . '>' . $GLOBALS['strEdit'] . '</a>]';
            } else {
                $edit_link = '';
            }
            // Want to have the query explained (Mike Beck 2002-05-22)
            // but only explain a SELECT (that has not been explained)
            /* SQL-Parser-Analyzer */
            if (isset($cfg['SQLQuery']['Explain']) && $cfg['SQLQuery']['Explain'] == TRUE) {
                // Detect if we are validating as well
                // To preserve the validate uRL data
                if (!empty($GLOBALS['validatequery'])) {
                    $explain_link_validate = '&amp;validatequery=1';
                } else {
                    $explain_link_validate = '';
                }
                $explain_link = '&nbsp;[<a href="read_dump.php' . $url_qpart . $explain_link_validate . '&amp;sql_query=';
                if (preg_match('@^SELECT[[:space:]]+@i', $local_query)) {
                    $explain_link .= urlencode('EXPLAIN ' . $local_query) . '">' . $GLOBALS['strExplain'];
                } else {
                    if (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $local_query)) {
                        $explain_link .= urlencode(substr($local_query, 8)) . '">' . $GLOBALS['strNoExplain'];
                    } else {
                        $explain_link = '';
                    }
                }
                if (!empty($explain_link)) {
                    $explain_link .= '</a>]';
                }
            } else {
                $explain_link = '';
            }
            //show explain
            // Also we would like to get the SQL formed in some nice
            // php-code (Mike Beck 2002-05-22)
            if (isset($cfg['SQLQuery']['ShowAsPHP']) && $cfg['SQLQuery']['ShowAsPHP'] == TRUE) {
                $php_link = '&nbsp;[<a href="read_dump.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($local_query) . '&amp;show_as_php=';
                if (!empty($GLOBALS['show_as_php'])) {
                    $php_link .= '0">' . $GLOBALS['strNoPhp'];
                } else {
                    $php_link .= '1">' . $GLOBALS['strPhp'];
                }
                $php_link .= '</a>]';
                if (isset($GLOBALS['show_as_php']) && $GLOBALS['show_as_php'] == '1') {
                    $php_link .= '&nbsp;[<a href="read_dump.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($local_query) . '">' . $GLOBALS['strRunQuery'] . '</a>]';
                }
            } else {
                $php_link = '';
            }
            //show as php
            // Refresh query
            if (isset($cfg['SQLQuery']['Refresh']) && $cfg['SQLQuery']['Refresh'] && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $local_query)) {
                $refresh_link = '&nbsp;[<a href="read_dump.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($local_query) . '">';
                $refresh_link .= $GLOBALS['strRefresh'];
                $refresh_link .= '</a>]';
            } else {
                $refresh_link = '';
            }
            //show as php
            if (isset($cfg['SQLValidator']['use']) && $cfg['SQLValidator']['use'] == TRUE && isset($cfg['SQLQuery']['Validate']) && $cfg['SQLQuery']['Validate'] == TRUE) {
                $validate_link = '&nbsp;[<a href="read_dump.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($local_query) . '&amp;validatequery=';
                if (!empty($GLOBALS['validatequery'])) {
                    $validate_link .= '0">' . $GLOBALS['strNoValidateSQL'];
                } else {
                    $validate_link .= '1">' . $GLOBALS['strValidateSQL'];
                }
                $validate_link .= '</a>]';
            } else {
                $validate_link = '';
            }
            //validator
            // Displays the message
            echo '            <b>' . $GLOBALS['strSQLQuery'] . ':</b>&nbsp;';
            echo '<br />' . "\n";
            echo '            ' . $query_base;
            unset($local_query);
            //Clean up the end of the PHP
            if (!empty($GLOBALS['show_as_php'])) {
                echo '\';';
            }
            echo "\n";
            ?>
        </td>
    </tr>
    <?php 
            if (!empty($edit_target)) {
                echo '<tr><td bgcolor="' . $cfg['BgcolorOne'] . '" align="center">';
                echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link;
                echo '</td></tr>' . "\n";
            }
        }
        echo "\n";
        ?>
    </table>
</div><br />
        <?php 
    }
    if (!function_exists($extension . '_connect')) {
        return false;
    }
    return true;
}
/**
 * check for requested extension
 */
if (!PMA_DBI_checkMysqlExtension($GLOBALS['cfg']['Server']['extension'])) {
    // if it fails try alternative extension ...
    // and display an error ...
    /**
     * @todo add different messages for alternative extension
     * and complete fail (no alternative extension too)
     */
    $error = sprintf(PMA_sanitize($GLOBALS['strCantLoad']), $GLOBALS['cfg']['Server']['extension']) . ' - <a href="./Documentation.html#faqmysql" target="documentation">' . $GLOBALS['strDocu'] . '</a>';
    trigger_error($error, E_USER_ERROR);
    if ($GLOBALS['cfg']['Server']['extension'] === 'mysql') {
        $alternativ_extension = 'mysqli';
    } else {
        $alternativ_extension = 'mysql';
    }
    if (!PMA_DBI_checkMysqlExtension($alternativ_extension)) {
        // if alternative fails too ...
        PMA_fatalError(sprintf($GLOBALS['strCantLoad'], $GLOBALS['cfg']['Server']['extension']) . ' - [a@./Documentation.html#faqmysql@documentation]' . $GLOBALS['strDocu'] . '[/a]');
    }
    $GLOBALS['cfg']['Server']['extension'] = $alternativ_extension;
    unset($alternativ_extension);
}
/**
 * Including The DBI Plugin
示例#26
0
 /**
  * Prepare the message and the query
  * usually the message is the result of the query executed
  *
  * @param PMA_Message|string $message   the message to display
  * @param string             $sql_query the query to display
  * @param string             $type      the type (level) of the message
  *
  * @return string
  *
  * @access  public
  */
 public static function getMessage($message, $sql_query = null, $type = 'notice')
 {
     global $cfg;
     $retval = '';
     if (null === $sql_query) {
         if (!empty($GLOBALS['display_query'])) {
             $sql_query = $GLOBALS['display_query'];
         } elseif (!empty($GLOBALS['unparsed_sql'])) {
             $sql_query = $GLOBALS['unparsed_sql'];
         } elseif (!empty($GLOBALS['sql_query'])) {
             $sql_query = $GLOBALS['sql_query'];
         } else {
             $sql_query = '';
         }
     }
     if (isset($GLOBALS['using_bookmark_message'])) {
         $retval .= $GLOBALS['using_bookmark_message']->getDisplay();
         unset($GLOBALS['using_bookmark_message']);
     }
     // In an Ajax request, $GLOBALS['cell_align_left'] may not be defined. Hence,
     // check for it's presence before using it
     $retval .= '<div class="result_query"' . (isset($GLOBALS['cell_align_left']) ? ' style="text-align: ' . $GLOBALS['cell_align_left'] . '"' : '') . '>' . "\n";
     if ($message instanceof PMA_Message) {
         if (isset($GLOBALS['special_message'])) {
             $message->addMessage($GLOBALS['special_message']);
             unset($GLOBALS['special_message']);
         }
         $retval .= $message->getDisplay();
     } else {
         $retval .= '<div class="' . $type . '">';
         $retval .= PMA_sanitize($message);
         if (isset($GLOBALS['special_message'])) {
             $retval .= PMA_sanitize($GLOBALS['special_message']);
             unset($GLOBALS['special_message']);
         }
         $retval .= '</div>';
     }
     if ($cfg['ShowSQL'] == true && !empty($sql_query) && $sql_query !== ';') {
         // Html format the query to be displayed
         // If we want to show some sql code it is easiest to create it here
         /* SQL-Parser-Analyzer */
         if (!empty($GLOBALS['show_as_php'])) {
             $new_line = '\\n"<br />' . "\n" . '&nbsp;&nbsp;&nbsp;&nbsp;. "';
             $query_base = htmlspecialchars(addslashes($sql_query));
             $query_base = preg_replace('/((\\015\\012)|(\\015)|(\\012))/', $new_line, $query_base);
         } else {
             $query_base = $sql_query;
         }
         $query_too_big = false;
         $queryLength = mb_strlen($query_base);
         if ($queryLength > $cfg['MaxCharactersInDisplayedSQL']) {
             // when the query is large (for example an INSERT of binary
             // data), the parser chokes; so avoid parsing the query
             $query_too_big = true;
             $shortened_query_base = nl2br(htmlspecialchars(mb_substr($sql_query, 0, $cfg['MaxCharactersInDisplayedSQL']) . '[...]'));
         }
         if (!empty($GLOBALS['show_as_php'])) {
             $query_base = '$sql  = "' . $query_base;
         } elseif (isset($query_base)) {
             $query_base = self::formatSql($query_base);
         }
         // Prepares links that may be displayed to edit/explain the query
         // (don't go to default pages, we must go to the page
         // where the query box is available)
         // Basic url query part
         $url_params = array();
         if (!isset($GLOBALS['db'])) {
             $GLOBALS['db'] = '';
         }
         if (mb_strlen($GLOBALS['db'])) {
             $url_params['db'] = $GLOBALS['db'];
             if (mb_strlen($GLOBALS['table'])) {
                 $url_params['table'] = $GLOBALS['table'];
                 $edit_link = 'tbl_sql.php';
             } else {
                 $edit_link = 'db_sql.php';
             }
         } else {
             $edit_link = 'server_sql.php';
         }
         // Want to have the query explained
         // but only explain a SELECT (that has not been explained)
         /* SQL-Parser-Analyzer */
         $explain_link = '';
         $is_select = preg_match('@^SELECT[[:space:]]+@i', $sql_query);
         if (!empty($cfg['SQLQuery']['Explain']) && !$query_too_big) {
             $explain_params = $url_params;
             if ($is_select) {
                 $explain_params['sql_query'] = 'EXPLAIN ' . $sql_query;
                 $explain_link = ' [' . self::linkOrButton('import.php' . PMA_URL_getCommon($explain_params), __('Explain SQL')) . ']';
             } elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query)) {
                 $explain_params['sql_query'] = mb_substr($sql_query, 8);
                 $explain_link = ' [' . self::linkOrButton('import.php' . PMA_URL_getCommon($explain_params), __('Skip Explain SQL')) . ']';
                 $url = 'https://mariadb.org/explain_analyzer/analyze/' . '?client=phpMyAdmin&raw_explain=' . urlencode(self::_generateRowQueryOutput($sql_query));
                 $explain_link .= ' [' . self::linkOrButton('url.php?url=' . urlencode($url), sprintf(__('Analyze Explain at %s'), 'mariadb.org'), array(), true, false, '_blank') . ']';
             }
         }
         //show explain
         $url_params['sql_query'] = $sql_query;
         $url_params['show_query'] = 1;
         // even if the query is big and was truncated, offer the chance
         // to edit it (unless it's enormous, see linkOrButton() )
         if (!empty($cfg['SQLQuery']['Edit'])) {
             $edit_link .= PMA_URL_getCommon($url_params) . '#querybox';
             $edit_link = ' [' . self::linkOrButton($edit_link, __('Edit')) . ']';
         } else {
             $edit_link = '';
         }
         // Also we would like to get the SQL formed in some nice
         // php-code
         if (!empty($cfg['SQLQuery']['ShowAsPHP']) && !$query_too_big) {
             $php_params = $url_params;
             if (!empty($GLOBALS['show_as_php'])) {
                 $_message = __('Without PHP Code');
             } else {
                 $php_params['show_as_php'] = 1;
                 $_message = __('Create PHP code');
             }
             $php_link = 'import.php' . PMA_URL_getCommon($php_params);
             $php_link = ' [' . self::linkOrButton($php_link, $_message) . ']';
             if (isset($GLOBALS['show_as_php'])) {
                 $runquery_link = 'import.php' . PMA_URL_getCommon($url_params);
                 $php_link .= ' [' . self::linkOrButton($runquery_link, __('Submit Query')) . ']';
             }
         } else {
             $php_link = '';
         }
         //show as php
         // Refresh query
         if (!empty($cfg['SQLQuery']['Refresh']) && !isset($GLOBALS['show_as_php']) && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)) {
             $refresh_link = 'import.php' . PMA_URL_getCommon($url_params);
             $refresh_link = ' [' . self::linkOrButton($refresh_link, __('Refresh')) . ']';
         } else {
             $refresh_link = '';
         }
         //refresh
         $retval .= '<div class="sqlOuter">';
         if ($query_too_big) {
             $retval .= $shortened_query_base;
         } else {
             $retval .= $query_base;
         }
         //Clean up the end of the PHP
         if (!empty($GLOBALS['show_as_php'])) {
             $retval .= '";';
         }
         $retval .= '</div>';
         $retval .= '<div class="tools print_ignore">';
         $retval .= '<form action="sql.php" method="post">';
         $retval .= PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']);
         $retval .= '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />';
         // avoid displaying a Profiling checkbox that could
         // be checked, which would reexecute an INSERT, for example
         if (!empty($refresh_link) && self::profilingSupported()) {
             $retval .= '<input type="hidden" name="profiling_form" value="1" />';
             $retval .= self::getCheckbox('profiling', __('Profiling'), isset($_SESSION['profiling']), true);
         }
         $retval .= '</form>';
         /**
          * TODO: Should we have $cfg['SQLQuery']['InlineEdit']?
          */
         if (!empty($cfg['SQLQuery']['Edit']) && !$query_too_big) {
             $inline_edit_link = ' [' . self::linkOrButton('#', _pgettext('Inline edit query', 'Edit inline'), array('class' => 'inline_edit_sql')) . ']';
         } else {
             $inline_edit_link = '';
         }
         $retval .= $inline_edit_link . $edit_link . $explain_link . $php_link . $refresh_link;
         $retval .= '</div>';
     }
     $retval .= '</div>';
     if ($GLOBALS['is_ajax_request'] === false) {
         $retval .= '<br class="clearfloat" />';
     }
     return $retval;
 }
示例#27
0
 /**
  * Prepare a table of results returned by a SQL query.
  *
  * @param integer &$dt_result         the link id associated to the query
  *                                    which results have to be displayed
  * @param array   &$displayParts      the parts to display
  * @param array   $analyzed_sql       the analyzed query
  * @param boolean $is_limited_display With limited operations or not
  *
  * @return  string   $table_html   Generated HTML content for resulted table
  *
  * @access  public
  *
  * @see     sql.php file
  */
 public function getTable(&$dt_result, &$displayParts, $analyzed_sql, $is_limited_display = false)
 {
     $table_html = '';
     // Following variable are needed for use in isset/empty or
     // use with array indexes/safe use in foreach
     $fields_meta = $this->__get('fields_meta');
     $showtable = $this->__get('showtable');
     $printview = $this->__get('printview');
     // why was this called here? (already called from sql.php)
     //$this->setConfigParamsForDisplayTable();
     /**
      * @todo move this to a central place
      * @todo for other future table types
      */
     $is_innodb = isset($showtable['Type']) && $showtable['Type'] == self::TABLE_TYPE_INNO_DB;
     if ($is_innodb && !isset($analyzed_sql[0]['queryflags']['union']) && !isset($analyzed_sql[0]['table_ref'][1]['table_name']) && (empty($analyzed_sql[0]['where_clause']) || $analyzed_sql[0]['where_clause'] == '1 ')) {
         // "j u s t   b r o w s i n g"
         $pre_count = '~';
         $after_count = PMA_Util::showHint(PMA_sanitize(__('May be approximate. See [doc@faq3-11]FAQ 3.11[/doc].')));
     } else {
         $pre_count = '';
         $after_count = '';
     }
     // 1. ----- Prepares the work -----
     // 1.1 Gets the information about which functionalities should be
     //     displayed
     $total = '';
     $displayParts = $this->_setDisplayParts($displayParts, $total);
     // 1.2 Defines offsets for the next and previous pages
     if ($displayParts['nav_bar'] == '1') {
         list($pos_next, $pos_prev) = $this->_getOffsets();
     }
     // end if
     if (!isset($analyzed_sql[0]['order_by_clause'])) {
         $analyzed_sql[0]['order_by_clause'] = "";
     }
     // 1.3 Find the sort expression
     // we need $sort_expression and $sort_expression_nodirection
     // even if there are many table references
     list($sort_expression, $sort_expression_nodirection, $sort_direction) = $this->_getSortParams($analyzed_sql[0]['order_by_clause']);
     $number_of_columns = count($sort_expression_nodirection);
     // 1.4 Prepares display of first and last value of the sorted column
     $sorted_column_message = '';
     for ($i = 0; $i < $number_of_columns; $i++) {
         $sorted_column_message .= $this->_getSortedColumnMessage($dt_result, $sort_expression_nodirection[$i]);
     }
     // 2. ----- Prepare to display the top of the page -----
     // 2.1 Prepares a messages with position information
     if ($displayParts['nav_bar'] == '1' && isset($pos_next)) {
         $message = $this->_setMessageInformation($sorted_column_message, $analyzed_sql[0]['limit_clause'], $total, $pos_next, $pre_count, $after_count);
         $table_html .= PMA_Util::getMessage($message, $this->__get('sql_query'), 'success');
     } elseif (!isset($printview) || $printview != '1') {
         $table_html .= PMA_Util::getMessage(__('Your SQL query has been executed successfully.'), $this->__get('sql_query'), 'success');
     }
     // 2.3 Prepare the navigation bars
     if (!mb_strlen($this->__get('table'))) {
         if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == self::QUERY_TYPE_SELECT) {
             // table does not always contain a real table name,
             // for example in MySQL 5.0.x, the query SHOW STATUS
             // returns STATUS as a table name
             $this->__set('table', $fields_meta[0]->table);
         } else {
             $this->__set('table', '');
         }
     }
     if ($displayParts['nav_bar'] == '1' && empty($analyzed_sql[0]['limit_clause'])) {
         $table_html .= $this->_getPlacedTableNavigations($pos_next, $pos_prev, self::PLACE_TOP_DIRECTION_DROPDOWN, $is_innodb);
     } elseif (!isset($printview) || $printview != '1') {
         $table_html .= "\n" . '<br /><br />' . "\n";
     }
     // 2b ----- Get field references from Database -----
     // (see the 'relation' configuration variable)
     // initialize map
     $map = array();
     // find tables
     $target = array();
     if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
         foreach ($analyzed_sql[0]['table_ref'] as $table_ref_position => $table_ref) {
             $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
         }
     }
     if (mb_strlen($this->__get('table'))) {
         // This method set the values for $map array
         $this->_setParamForLinkForeignKeyRelatedTables($map);
         // Coming from 'Distinct values' action of structure page
         // We manipulate relations mechanism to show a link to related rows.
         if ($this->__get('is_browse_distinct')) {
             $map[$fields_meta[1]->name] = array($this->__get('table'), $fields_meta[1]->name, '', $this->__get('db'));
         }
     }
     // end if
     // end 2b
     // 3. ----- Prepare the results table -----
     $table_html .= $this->_getTableHeaders($displayParts, $analyzed_sql, $sort_expression, $sort_expression_nodirection, $sort_direction, $is_limited_display) . '<tbody>' . "\n";
     $table_html .= $this->_getTableBody($dt_result, $displayParts, $map, $analyzed_sql, $is_limited_display);
     $this->__set('vertical_display', null);
     $table_html .= '</tbody>' . "\n" . '</table>';
     // 4. ----- Prepares the link for multi-fields edit and delete
     if ($displayParts['del_lnk'] == self::DELETE_ROW && $displayParts['del_lnk'] != self::KILL_PROCESS) {
         $table_html .= $this->_getMultiRowOperationLinks($dt_result, $analyzed_sql, $displayParts['del_lnk']);
     }
     // 5. ----- Get the navigation bar at the bottom if required -----
     if ($displayParts['nav_bar'] == '1' && empty($analyzed_sql[0]['limit_clause'])) {
         $table_html .= $this->_getPlacedTableNavigations($pos_next, $pos_prev, self::PLACE_BOTTOM_DIRECTION_DROPDOWN, $is_innodb);
     } elseif (!isset($printview) || $printview != '1') {
         $table_html .= "\n" . '<br /><br />' . "\n";
     }
     // 6. ----- Prepare "Query results operations"
     if ((!isset($printview) || $printview != '1') && !$is_limited_display) {
         $table_html .= $this->_getResultsOperations($displayParts, $analyzed_sql);
     }
     return $table_html;
 }
示例#28
0
    $GLOBALS['js_messages']['strPasswordEmpty'] = $GLOBALS['strPasswordEmpty'];
    $GLOBALS['js_messages']['strPasswordNotSame'] = $GLOBALS['strPasswordNotSame'];
}
$GLOBALS['js_include'][] = 'tooltip.js';
$GLOBALS['js_events'][] = array('object' => 'window', 'event' => 'load', 'function' => 'PMA_TT_init');
foreach ($GLOBALS['js_include'] as $js_script_file) {
    echo '<script src="./js/' . $js_script_file . '" type="text/javascript"></script>' . "\n";
}
?>
<script type="text/javascript">
// <![CDATA[
// Updates the title of the frameset if possible (ns4 does not allow this)
if (typeof(parent.document) != 'undefined' && typeof(parent.document) != 'unknown'
    && typeof(parent.document.title) == 'string') {
    parent.document.title = '<?php 
echo PMA_sanitize(PMA_escapeJsString($title));
?>
';
}

var PMA_messages = new Array();
<?php 
foreach ($GLOBALS['js_messages'] as $name => $js_message) {
    echo "PMA_messages['" . $name . "'] = '" . PMA_escapeJsString($js_message) . "';\n";
}
foreach ($GLOBALS['js_events'] as $js_event) {
    echo "window.parent.addEvent(" . $js_event['object'] . ", '" . $js_event['event'] . "', " . $js_event['function'] . ");\n";
}
?>
// ]]>
</script>
示例#29
0
    }
    // end if
}
/**
 * Warning about different MySQL library and server version
 * (a difference on the third digit does not count).
 * If someday there is a constant that we can check about mysqlnd,
 * we can use it instead of strpos().
 * If no default server is set, $GLOBALS['dbi'] is not defined yet.
 * We also do not warn if MariaDB is detected, as it has its own version
 * numbering.
 */
if (isset($GLOBALS['dbi']) && $cfg['ServerLibraryDifference_DisableWarning'] == false) {
    $_client_info = $GLOBALS['dbi']->getClientInfo();
    if ($server > 0 && mb_strpos($_client_info, 'mysqlnd') === false && mb_strpos(PMA_MYSQL_STR_VERSION, 'MariaDB') === false && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)) {
        trigger_error(PMA_sanitize(sprintf(__('Your PHP MySQL library version %s differs from your ' . 'MySQL server version %s. This may cause unpredictable ' . 'behavior.'), $_client_info, substr(PMA_MYSQL_STR_VERSION, 0, strpos(PMA_MYSQL_STR_VERSION . '-', '-')))), E_USER_NOTICE);
    }
    unset($_client_info);
}
/**
 * Warning about Suhosin only if its simulation mode is not enabled
 */
if ($cfg['SuhosinDisableWarning'] == false && @ini_get('suhosin.request.max_value_length') && @ini_get('suhosin.simulation') == '0') {
    trigger_error(sprintf(__('Server running with Suhosin. Please refer to %sdocumentation%s ' . 'for possible issues.'), '[doc@faq1-38]', '[/doc]'), E_USER_WARNING);
}
/**
 * Warning about incomplete translations.
 *
 * The data file is created while creating release by ./scripts/remove-incomplete-mo
 */
if (file_exists('libraries/language_stats.inc.php')) {
 /**
  * Returns whether the row count is approximated
  *
  * @param array   $current_table array containing details about the table
  * @param boolean $table_is_view whether the table is a view
  *
  * @return array
  */
 protected function isRowCountApproximated($current_table, $table_is_view)
 {
     $approx_rows = false;
     $show_superscript = '';
     // there is a null value in the ENGINE
     // - when the table needs to be repaired, or
     // - when it's a view
     //  so ensure that we'll display "in use" below for a table
     //  that needs to be repaired
     if (isset($current_table['TABLE_ROWS']) && ($current_table['ENGINE'] != null || $table_is_view)) {
         // InnoDB table: we did not get an accurate row count
         $approx_rows = !$table_is_view && $current_table['ENGINE'] == 'InnoDB' && !$current_table['COUNTED'];
         if ($table_is_view && $current_table['TABLE_ROWS'] >= $GLOBALS['cfg']['MaxExactCountViews']) {
             $approx_rows = true;
             $show_superscript = Util::showHint(PMA_sanitize(sprintf(__('This view has at least this number of ' . 'rows. Please refer to %sdocumentation%s.'), '[doc@cfg_MaxExactCountViews]', '[/doc]')));
         }
     }
     return array($approx_rows, $show_superscript);
 }