/**
 * Send TRI or EVN editor via ajax or by echoing.
 *
 * @param string $type      TRI or EVN
 * @param string $mode      Editor mode 'add' or 'edit'
 * @param array  $item      Data necessary to create the editor
 * @param string $title     Title of the editor
 * @param string $db        Database
 * @param string $operation Operation 'change' or ''
 *
 * @return void
 */
function PMA_RTE_sendEditor($type, $mode, $item, $title, $db, $operation = null)
{
    if ($item !== false) {
        // Show form
        if ($type == 'TRI') {
            $editor = PMA_TRI_getEditorForm($mode, $item);
        } else {
            // EVN
            $editor = PMA_EVN_getEditorForm($mode, $operation, $item);
        }
        if ($GLOBALS['is_ajax_request']) {
            $response = PMA_Response::getInstance();
            $response->addJSON('message', $editor);
            $response->addJSON('title', $title);
        } else {
            echo "\n\n<h2>{$title}</h2>\n\n{$editor}";
            unset($_POST);
        }
        exit;
    } else {
        $message = __('Error in processing request:') . ' ';
        $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_Util::backquote($db)));
        $message = PMA_message::error($message);
        if ($GLOBALS['is_ajax_request']) {
            $response = PMA_Response::getInstance();
            $response->isSuccess(false);
            $response->addJSON('message', $message);
            exit;
        } else {
            $message->display();
        }
    }
}
/**
 * This function is called from one of the other functions in this file
 * and it completes the handling of the export functionality.
 *
 * @param string $item_name   The name of the item that we are exporting
 * @param string $export_data The SQL query to create the requested item
 *
 * @return void
 */
function PMA_RTE_handleExport($item_name, $export_data)
{
    global $db;
    $item_name = htmlspecialchars(PMA_Util::backquote($_GET['item_name']));
    if ($export_data !== false) {
        $export_data = '<textarea cols="40" rows="15" style="width: 100%;">' . htmlspecialchars(trim($export_data)) . '</textarea>';
        $title = sprintf(PMA_RTE_getWord('export'), $item_name);
        if ($GLOBALS['is_ajax_request'] == true) {
            $response = PMA_Response::getInstance();
            $response->addJSON('message', $export_data);
            $response->addJSON('title', $title);
            exit;
        } else {
            echo "<fieldset>\n" . "<legend>{$title}</legend>\n" . $export_data . "</fieldset>\n";
        }
    } else {
        $_db = htmlspecialchars(PMA_Util::backquote($db));
        $message = __('Error in processing request:') . ' ' . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db);
        $response = PMA_message::error($message);
        if ($GLOBALS['is_ajax_request'] == true) {
            $response = PMA_Response::getInstance();
            $response->isSuccess(false);
            $response->addJSON('message', $message);
            exit;
        } else {
            $response->display();
        }
    }
}
/**
 * This function is called from one of the other functions in this file
 * and it completes the handling of the export functionality.
 *
 * @param  string  $item_name    The name of the item that we are exporting
 * @param  string  $export_data  The SQL query to create the requested item
 */
function PMA_RTE_handleExport($item_name, $export_data)
{
    global $db;
    $item_name = htmlspecialchars(PMA_backquote($_GET['item_name']));
    if ($export_data !== false) {
        $export_data = '<textarea cols="40" rows="15" style="width: 100%;">' . htmlspecialchars(trim($export_data)) . '</textarea>';
        $title = sprintf(PMA_RTE_getWord('export'), $item_name);
        if ($GLOBALS['is_ajax_request'] == true) {
            $extra_data = array('title' => $title);
            PMA_ajaxResponse($export_data, true, $extra_data);
        } else {
            echo "<fieldset>\n" . "<legend>{$title}</legend>\n" . $export_data . "</fieldset>\n";
        }
    } else {
        $_db = htmlspecialchars(PMA_backquote($db));
        $response = __('Error in Processing Request') . ' : ' . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db);
        $response = PMA_message::error($response);
        if ($GLOBALS['is_ajax_request'] == true) {
            PMA_ajaxResponse($response, false);
        } else {
            $response->display();
        }
    }
}
示例#4
0
/**
 * Handles editor requests for adding or editing an item
 *
 * @return void
 */
function PMA_TRI_handleEditor()
{
    global $_REQUEST, $_POST, $errors, $db, $table;
    if (!empty($_REQUEST['editor_process_add']) || !empty($_REQUEST['editor_process_edit'])) {
        $sql_query = '';
        $item_query = PMA_TRI_getQueryFromRequest();
        if (!count($errors)) {
            // set by PMA_RTN_getQueryFromRequest()
            // Execute the created query
            if (!empty($_REQUEST['editor_process_edit'])) {
                // Backup the old trigger, in case something goes wrong
                $trigger = PMA_TRI_getDataFromName($_REQUEST['item_original_name']);
                $create_item = $trigger['create'];
                $drop_item = $trigger['drop'] . ';';
                $result = PMA_DBI_try_query($drop_item);
                if (!$result) {
                    $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($drop_item)) . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null);
                } else {
                    $result = PMA_DBI_try_query($item_query);
                    if (!$result) {
                        $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null);
                        // We dropped the old item, but were unable to create the new one
                        // Try to restore the backup query
                        $result = PMA_DBI_try_query($create_item);
                        if (!$result) {
                            // OMG, this is really bad! We dropped the query,
                            // failed to create a new one
                            // and now even the backup query does not execute!
                            // This should not happen, but we better handle
                            // this just in case.
                            $errors[] = __('Sorry, we failed to restore the dropped trigger.') . '<br />' . __('The backed up query was:') . "\"" . htmlspecialchars($create_item) . "\"" . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null);
                        }
                    } else {
                        $message = PMA_Message::success(__('Trigger %1$s has been modified.'));
                        $message->addParam(PMA_Util::backquote($_REQUEST['item_name']));
                        $sql_query = $drop_item . $item_query;
                    }
                }
            } else {
                // 'Add a new item' mode
                $result = PMA_DBI_try_query($item_query);
                if (!$result) {
                    $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br /><br />' . __('MySQL said: ') . PMA_DBI_getError(null);
                } else {
                    $message = PMA_Message::success(__('Trigger %1$s has been created.'));
                    $message->addParam(PMA_Util::backquote($_REQUEST['item_name']));
                    $sql_query = $item_query;
                }
            }
        }
        if (count($errors)) {
            $message = PMA_Message::error(__('<b>One or more errors have occured while processing your request:</b>'));
            $message->addString('<ul>');
            foreach ($errors as $string) {
                $message->addString('<li>' . $string . '</li>');
            }
            $message->addString('</ul>');
        }
        $output = PMA_Util::getMessage($message, $sql_query);
        if ($GLOBALS['is_ajax_request']) {
            $response = PMA_Response::getInstance();
            if ($message->isSuccess()) {
                $items = PMA_DBI_get_triggers($db, $table, '');
                $trigger = false;
                foreach ($items as $value) {
                    if ($value['name'] == $_REQUEST['item_name']) {
                        $trigger = $value;
                    }
                }
                $insert = false;
                if (empty($table) || $trigger !== false && $table == $trigger['table']) {
                    $insert = true;
                    $response->addJSON('new_row', PMA_TRI_getRowForList($trigger));
                    $response->addJSON('name', htmlspecialchars(strtoupper($_REQUEST['item_name'])));
                }
                $response->addJSON('insert', $insert);
                $response->addJSON('message', $output);
            } else {
                $response->addJSON('message', $message);
                $response->isSuccess(false);
            }
            exit;
        }
    }
    /**
     * Display a form used to add/edit a trigger, if necessary
     */
    if (count($errors) || empty($_REQUEST['editor_process_add']) && empty($_REQUEST['editor_process_edit']) && (!empty($_REQUEST['add_item']) || !empty($_REQUEST['edit_item']))) {
        // Get the data for the form (if any)
        if (!empty($_REQUEST['add_item'])) {
            $title = PMA_RTE_getWord('add');
            $item = PMA_TRI_getDataFromRequest();
            $mode = 'add';
        } else {
            if (!empty($_REQUEST['edit_item'])) {
                $title = __("Edit trigger");
                if (!empty($_REQUEST['item_name']) && empty($_REQUEST['editor_process_edit'])) {
                    $item = PMA_TRI_getDataFromName($_REQUEST['item_name']);
                    if ($item !== false) {
                        $item['item_original_name'] = $item['item_name'];
                    }
                } else {
                    $item = PMA_TRI_getDataFromRequest();
                }
                $mode = 'edit';
            }
        }
        if ($item !== false) {
            // Show form
            $editor = PMA_TRI_getEditorForm($mode, $item);
            if ($GLOBALS['is_ajax_request']) {
                $response = PMA_Response::getInstance();
                $response->addJSON('message', $editor);
                $response->addJSON('title', $title);
            } else {
                echo "\n\n<h2>{$title}</h2>\n\n{$editor}";
                unset($_POST);
            }
            exit;
        } else {
            $message = __('Error in processing request') . ' : ';
            $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_Util::backquote($db)));
            $message = PMA_message::error($message);
            if ($GLOBALS['is_ajax_request']) {
                $response = PMA_Response::getInstance();
                $response->isSuccess(false);
                $response->addJSON('message', $message);
                exit;
            } else {
                $message->display();
            }
        }
    }
}
示例#5
0
/**
 * Check column names for MySQL reserved words
 *
 * @param string $db    database name
 * @param string $table tablename
 *
 * @return array $messages      array of PMA_Messages
 */
function PMA_getReservedWordColumnNameMessages($db, $table)
{
    $messages = array();
    if ($GLOBALS['cfg']['ReservedWordDisableWarning'] === false) {
        $pma_table = new PMA_Table($table, $db);
        $columns = $pma_table->getReservedColumnNames();
        if (!empty($columns)) {
            foreach ($columns as $column) {
                $msg = PMA_message::notice(__('The column name \'%s\' is a MySQL reserved keyword.'));
                $msg->addParam($column);
                $messages[] = $msg;
            }
        }
    }
    return $messages;
}
示例#6
0
    }

    // Displays the results in a table
    if (empty($disp_mode)) {
        // see the "PMA_setDisplayMode()" function in
        // libraries/display_tbl.lib.php
        $disp_mode = 'urdr111101';
    }

    // hide edit and delete links for information_schema
    if (PMA_is_system_schema($db)) {
        $disp_mode = 'nnnn110111';
    }

    if (isset($label)) {
        $message = PMA_message::success(__('Bookmark %s created'));
        $message->addParam($label);
        $message->display();
    }

    PMA_displayTable($result, $disp_mode, $analyzed_sql);
    PMA_DBI_free_result($result);

    // BEGIN INDEX CHECK See if indexes should be checked.
    if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
        foreach ($selected as $idx => $tbl_name) {
            $check = PMA_Index::findDuplicates($tbl_name, $db);
            if (! empty($check)) {
                printf(__('Problems with indexes of table `%s`'), $tbl_name);
                echo $check;
            }
示例#7
0
/**
 * Displays authentication form
 *
 * this function MUST exit/quit the application
 *
 * @global  string    the last connection error
 *
 * @access  public
 */
function PMA_auth()
{
    global $conn_error;
    /* Perform logout to custom URL */
    if (!empty($_REQUEST['old_usr']) && !empty($GLOBALS['cfg']['Server']['LogoutURL'])) {
        PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']);
        exit;
    }
    /* No recall if blowfish secret is not configured as it would produce garbage */
    if ($GLOBALS['cfg']['LoginCookieRecall'] && !empty($GLOBALS['cfg']['blowfish_secret'])) {
        $default_user = $GLOBALS['PHP_AUTH_USER'];
        $default_server = $GLOBALS['pma_auth_server'];
        $autocomplete = '';
    } else {
        $default_user = '';
        $default_server = '';
        // skip the IE autocomplete feature.
        $autocomplete = ' autocomplete="off"';
    }
    $cell_align = $GLOBALS['text_dir'] == 'ltr' ? 'left' : 'right';
    // Defines the charset to be used
    header('Content-Type: text/html; charset=utf-8');
    /* HTML header; do not show here the PMA version to improve security */
    $page_title = 'phpMyAdmin ';
    include './libraries/header_meta_style.inc.php';
    // if $page_title is set, this script uses it as the title:
    include './libraries/header_scripts.inc.php';
    ?>
</head>

<body class="loginform">

    <?php 
    if (file_exists(CUSTOM_HEADER_FILE)) {
        include CUSTOM_HEADER_FILE;
    }
    ?>

<div class="container">
<a href="<?php 
    echo PMA_linkURL('http://www.phpmyadmin.net/');
    ?>
" target="_blank" class="logo"><?php 
    $logo_image = $GLOBALS['pmaThemeImage'] . 'logo_right.png';
    if (@file_exists($logo_image)) {
        echo '<img src="' . $logo_image . '" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />';
    } else {
        echo '<img name="imLogo" id="imLogo" src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo.png' . '" ' . 'border="0" width="88" height="31" alt="phpMyAdmin" />';
    }
    ?>
</a>
<h1>
    <?php 
    echo sprintf(__('Welcome to %s'), '<bdo dir="ltr" lang="en">' . $page_title . '</bdo>');
    ?>
</h1>
    <?php 
    // Show error message
    if (!empty($conn_error)) {
        PMA_Message::rawError($conn_error)->display();
    }
    echo "<noscript>\n";
    PMA_message::error(__("Javascript must be enabled past this point"))->display();
    echo "</noscript>\n";
    echo "<div class='hide js-show'>";
    // Displays the languages form
    if (empty($GLOBALS['cfg']['Lang'])) {
        include_once './libraries/display_select_lang.lib.php';
        // use fieldset, don't show doc link
        PMA_select_language(true, false);
    }
    echo "</div>";
    ?>
<br />
<!-- Login form -->
<form method="post" action="index.php" name="login_form"<?php 
    echo $autocomplete;
    ?>
 target="_top" class="login hide js-show">
    <fieldset>
    <legend>
<?php 
    echo __('Log in');
    echo PMA_showDocu('');
    ?>
</legend>

<?php 
    if ($GLOBALS['cfg']['AllowArbitraryServer']) {
        ?>
        <div class="item">
            <label for="input_servername" title="<?php 
        echo __('You can enter hostname/IP address and port separated by space.');
        ?>
"><?php 
        echo __('Server:');
        ?>
</label>
            <input type="text" name="pma_servername" id="input_servername" value="<?php 
        echo htmlspecialchars($default_server);
        ?>
" size="24" class="textfield" title="<?php 
        echo __('You can enter hostname/IP address and port separated by space.');
        ?>
" />
        </div>
<?php 
    }
    ?>
        <div class="item">
            <label for="input_username"><?php 
    echo __('Username:'******'Password:'******'cfg']['Servers']) > 1) {
        ?>
        <div class="item">
            <label for="select_server"><?php 
        echo __('Server Choice');
        ?>
:</label>
            <select name="server" id="select_server"
        <?php 
        if ($GLOBALS['cfg']['AllowArbitraryServer']) {
            echo ' onchange="document.forms[\'login_form\'].elements[\'pma_servername\'].value = \'\'" ';
        }
        echo '>';
        include_once './libraries/select_server.lib.php';
        PMA_select_server(false, false);
        echo '</select></div>';
    } else {
        echo '    <input type="hidden" name="server" value="' . $GLOBALS['server'] . '" />';
    }
    // end if (server choice)
    ?>
    </fieldset>
    <fieldset class="tblFooters">
        <input value="<?php 
    echo __('Go');
    ?>
" type="submit" id="input_go" />
    <?php 
    $_form_params = array();
    if (!empty($GLOBALS['target'])) {
        $_form_params['target'] = $GLOBALS['target'];
    }
    if (!empty($GLOBALS['db'])) {
        $_form_params['db'] = $GLOBALS['db'];
    }
    if (!empty($GLOBALS['table'])) {
        $_form_params['table'] = $GLOBALS['table'];
    }
    // do not generate a "server" hidden field as we want the "server"
    // drop-down to have priority
    echo PMA_generate_common_hidden_inputs($_form_params, '', 0, 'server');
    ?>
    </fieldset>
</form>

    <?php 
    // BEGIN Swekey Integration
    Swekey_login('input_username', 'input_go');
    // END Swekey Integration
    // show the "Cookies required" message only if cookies are disabled
    // (we previously tried to set some cookies)
    if (empty($_COOKIE)) {
        trigger_error(__('Cookies must be enabled past this point.'), E_USER_NOTICE);
    }
    if ($GLOBALS['error_handler']->hasDisplayErrors()) {
        echo '<div>';
        $GLOBALS['error_handler']->dispErrors();
        echo '</div>';
    }
    ?>
</div>
    <?php 
    if (file_exists(CUSTOM_FOOTER_FILE)) {
        include CUSTOM_FOOTER_FILE;
    }
    ?>
<script type="text/javascript">
//<![CDATA[
// show login form in top frame.
if (top != self || document.body.className != 'loginform') {
    window.top.location.href=location;
}
//]]>
</script>
</body>
</html>
    <?php 
    exit;
}
示例#8
0
/**
 * Handles requests for executing a routine
 *
 * @return Does not return
 */
function PMA_RTN_handleExecute()
{
    global $_GET, $_POST, $_REQUEST, $GLOBALS, $db;
    /**
     * Handle all user requests other than the default of listing routines
     */
    if (!empty($_REQUEST['execute_routine']) && !empty($_REQUEST['item_name'])) {
        // Build the queries
        $routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], $_REQUEST['item_type'], false);
        if ($routine !== false) {
            $queries = array();
            $end_query = array();
            $args = array();
            $all_functions = $GLOBALS['PMA_Types']->getAllFunctions();
            for ($i = 0; $i < $routine['item_num_params']; $i++) {
                if (isset($_REQUEST['params'][$routine['item_param_name'][$i]])) {
                    $value = $_REQUEST['params'][$routine['item_param_name'][$i]];
                    if (is_array($value)) {
                        // is SET type
                        $value = implode(',', $value);
                    }
                    $value = PMA_Util::sqlAddSlashes($value);
                    if (!empty($_REQUEST['funcs'][$routine['item_param_name'][$i]]) && in_array($_REQUEST['funcs'][$routine['item_param_name'][$i]], $all_functions)) {
                        $queries[] = "SET @p{$i}={$_REQUEST['funcs'][$routine['item_param_name'][$i]]}('{$value}');\n";
                    } else {
                        $queries[] = "SET @p{$i}='{$value}';\n";
                    }
                    $args[] = "@p{$i}";
                } else {
                    $args[] = "@p{$i}";
                }
                if ($routine['item_type'] == 'PROCEDURE') {
                    if ($routine['item_param_dir'][$i] == 'OUT' || $routine['item_param_dir'][$i] == 'INOUT') {
                        $end_query[] = "@p{$i} AS " . PMA_Util::backquote($routine['item_param_name'][$i]);
                    }
                }
            }
            if ($routine['item_type'] == 'PROCEDURE') {
                $queries[] = "CALL " . PMA_Util::backquote($routine['item_name']) . "(" . implode(', ', $args) . ");\n";
                if (count($end_query)) {
                    $queries[] = "SELECT " . implode(', ', $end_query) . ";\n";
                }
            } else {
                $queries[] = "SELECT " . PMA_Util::backquote($routine['item_name']) . "(" . implode(', ', $args) . ") " . "AS " . PMA_Util::backquote($routine['item_name']) . ";\n";
            }
            // Get all the queries as one SQL statement
            $multiple_query = implode("", $queries);
            $outcome = true;
            $affected = 0;
            // Execute query
            if (!PMA_DBI_try_multi_query($multiple_query)) {
                $outcome = false;
            }
            // Generate output
            if ($outcome) {
                // Pass the SQL queries through the "pretty printer"
                $output = '<code class="sql" style="margin-bottom: 1em;">';
                $output .= PMA_SQP_formatHtml(PMA_SQP_parse(implode($queries)));
                $output .= '</code>';
                // Display results
                $output .= "<fieldset><legend>";
                $output .= sprintf(__('Execution results of routine %s'), PMA_Util::backquote(htmlspecialchars($routine['item_name'])));
                $output .= "</legend>";
                $num_of_rusults_set_to_display = 0;
                do {
                    $result = PMA_DBI_store_result();
                    $num_rows = PMA_DBI_num_rows($result);
                    if ($result !== false && $num_rows > 0) {
                        $output .= "<table><tr>";
                        foreach (PMA_DBI_get_fields_meta($result) as $key => $field) {
                            $output .= "<th>";
                            $output .= htmlspecialchars($field->name);
                            $output .= "</th>";
                        }
                        $output .= "</tr>";
                        $color_class = 'odd';
                        while ($row = PMA_DBI_fetch_assoc($result)) {
                            $output .= "<tr>";
                            foreach ($row as $key => $value) {
                                if ($value === null) {
                                    $value = '<i>NULL</i>';
                                } else {
                                    $value = htmlspecialchars($value);
                                }
                                $output .= "<td class='" . $color_class . "'>" . $value . "</td>";
                            }
                            $output .= "</tr>";
                            $color_class = $color_class == 'odd' ? 'even' : 'odd';
                        }
                        $output .= "</table>";
                        $num_of_rusults_set_to_display++;
                        $affected = $num_rows;
                    }
                    if (!PMA_DBI_more_results()) {
                        break;
                    }
                    $output .= "<br/>";
                    PMA_DBI_free_result($result);
                } while (PMA_DBI_next_result());
                $output .= "</fieldset>";
                $message = __('Your SQL query has been executed successfully');
                if ($routine['item_type'] == 'PROCEDURE') {
                    $message .= '<br />';
                    // TODO : message need to be modified according to the
                    // output from the routine
                    $message .= sprintf(_ngettext('%d row affected by the last statement inside the procedure', '%d rows affected by the last statement inside the procedure', $affected), $affected);
                }
                $message = PMA_message::success($message);
                if ($num_of_rusults_set_to_display == 0) {
                    $notice = __('MySQL returned an empty result set (i.e. zero rows).');
                    $output .= PMA_message::notice($notice)->getDisplay();
                }
            } else {
                $output = '';
                $message = PMA_message::error(sprintf(__('The following query has failed: "%s"'), htmlspecialchars($query)) . '<br /><br />' . __('MySQL said: ') . PMA_DBI_getError(null));
            }
            // Print/send output
            if ($GLOBALS['is_ajax_request']) {
                $response = PMA_Response::getInstance();
                $response->isSuccess($message->isSuccess());
                $response->addJSON('message', $message->getDisplay() . $output);
                $response->addJSON('dialog', false);
                exit;
            } else {
                echo $message->getDisplay() . $output;
                if ($message->isError()) {
                    // At least one query has failed, so shouldn't
                    // execute any more queries, so we quit.
                    exit;
                }
                unset($_POST);
                // Now deliberately fall through to displaying the routines list
            }
        } else {
            $message = __('Error in processing request') . ' : ';
            $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_Util::backquote($db)));
            $message = PMA_message::error($message);
            if ($GLOBALS['is_ajax_request']) {
                $response = PMA_Response::getInstance();
                $response->isSuccess(false);
                $response->addJSON('message', $message);
                exit;
            } else {
                echo $message->getDisplay();
                unset($_POST);
            }
        }
    } else {
        if (!empty($_GET['execute_dialog']) && !empty($_GET['item_name'])) {
            /**
             * Display the execute form for a routine.
             */
            $routine = PMA_RTN_getDataFromName($_GET['item_name'], $_GET['item_type'], true);
            if ($routine !== false) {
                $form = PMA_RTN_getExecuteForm($routine);
                if ($GLOBALS['is_ajax_request'] == true) {
                    $title = __("Execute routine") . " " . PMA_Util::backquote(htmlentities($_GET['item_name'], ENT_QUOTES));
                    $response = PMA_Response::getInstance();
                    $response->addJSON('message', $form);
                    $response->addJSON('title', $title);
                    $response->addJSON('dialog', true);
                } else {
                    echo "\n\n<h2>" . __("Execute routine") . "</h2>\n\n";
                    echo $form;
                }
                exit;
            } else {
                if ($GLOBALS['is_ajax_request'] == true) {
                    $message = __('Error in processing request') . ' : ';
                    $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_Util::backquote($db)));
                    $message = PMA_message::error($message);
                    $response = PMA_Response::getInstance();
                    $response->isSuccess(false);
                    $response->addJSON('message', $message);
                    exit;
                }
            }
        }
    }
}
 /**
  * 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));
     }
 }
示例#10
0
/**
 * Handles editor requests for adding or editing an item
 */
function PMA_EVN_handleEditor()
{
    global $_REQUEST, $_POST, $errors, $db;
    if (!empty($_REQUEST['editor_process_add']) || !empty($_REQUEST['editor_process_edit'])) {
        $sql_query = '';
        $item_query = PMA_EVN_getQueryFromRequest();
        if (!count($errors)) {
            // set by PMA_RTN_getQueryFromRequest()
            // Execute the created query
            if (!empty($_REQUEST['editor_process_edit'])) {
                // Backup the old trigger, in case something goes wrong
                $create_item = PMA_DBI_get_definition($db, 'EVENT', $_REQUEST['item_original_name']);
                $drop_item = "DROP EVENT " . PMA_backquote($_REQUEST['item_original_name']) . ";\n";
                $result = PMA_DBI_try_query($drop_item);
                if (!$result) {
                    $errors[] = sprintf(__('The following query has failed: "%s"'), $drop_item) . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null);
                } else {
                    $result = PMA_DBI_try_query($item_query);
                    if (!$result) {
                        $errors[] = sprintf(__('The following query has failed: "%s"'), $item_query) . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null);
                        // We dropped the old item, but were unable to create the new one
                        // Try to restore the backup query
                        $result = PMA_DBI_try_query($create_item);
                        if (!$result) {
                            // OMG, this is really bad! We dropped the query, failed to create a new one
                            // and now even the backup query does not execute!
                            // This should not happen, but we better handle this just in case.
                            $errors[] = __('Sorry, we failed to restore the dropped event.') . '<br />' . __('The backed up query was:') . "\"{$create_item}\"" . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null);
                        }
                    } else {
                        $message = PMA_Message::success(__('Event %1$s has been modified.'));
                        $message->addParam(PMA_backquote($_REQUEST['item_name']));
                        $sql_query = $drop_item . $item_query;
                    }
                }
            } else {
                // 'Add a new item' mode
                $result = PMA_DBI_try_query($item_query);
                if (!$result) {
                    $errors[] = sprintf(__('The following query has failed: "%s"'), $item_query) . '<br /><br />' . __('MySQL said: ') . PMA_DBI_getError(null);
                } else {
                    $message = PMA_Message::success(__('Event %1$s has been created.'));
                    $message->addParam(PMA_backquote($_REQUEST['item_name']));
                    $sql_query = $item_query;
                }
            }
        }
        if (count($errors)) {
            $message = PMA_Message::error(__('<b>One or more errors have occured while processing your request:</b>'));
            $message->addString('<ul>');
            foreach ($errors as $string) {
                $message->addString('<li>' . $string . '</li>');
            }
            $message->addString('</ul>');
        }
        $output = PMA_showMessage($message, $sql_query);
        if ($GLOBALS['is_ajax_request']) {
            $extra_data = array();
            if ($message->isSuccess()) {
                $columns = "`EVENT_NAME`, `EVENT_TYPE`, `STATUS`";
                $where = "EVENT_SCHEMA='" . PMA_sqlAddSlashes($db) . "' " . "AND EVENT_NAME='" . PMA_sqlAddSlashes($_REQUEST['item_name']) . "'";
                $query = "SELECT {$columns} FROM `INFORMATION_SCHEMA`.`EVENTS` WHERE {$where};";
                $event = PMA_DBI_fetch_single_row($query);
                $extra_data['name'] = htmlspecialchars(strtoupper($_REQUEST['item_name']));
                $extra_data['new_row'] = PMA_EVN_getRowForList($event);
                $extra_data['insert'] = !empty($event);
                $response = $output;
            } else {
                $response = $message;
            }
            PMA_ajaxResponse($response, $message->isSuccess(), $extra_data);
        }
    }
    /**
     * Display a form used to add/edit a trigger, if necessary
     */
    if (count($errors) || empty($_REQUEST['editor_process_add']) && empty($_REQUEST['editor_process_edit']) && (!empty($_REQUEST['add_item']) || !empty($_REQUEST['edit_item']) || !empty($_REQUEST['item_changetype']))) {
        // FIXME: this must be simpler than that
        $operation = '';
        if (!empty($_REQUEST['item_changetype'])) {
            $operation = 'change';
        }
        // Get the data for the form (if any)
        if (!empty($_REQUEST['add_item'])) {
            $title = PMA_RTE_getWord('add');
            $item = PMA_EVN_getDataFromRequest();
            $mode = 'add';
        } else {
            if (!empty($_REQUEST['edit_item'])) {
                $title = __("Edit event");
                if (!empty($_REQUEST['item_name']) && empty($_REQUEST['editor_process_edit']) && empty($_REQUEST['item_changetype'])) {
                    $item = PMA_EVN_getDataFromName($_REQUEST['item_name']);
                    if ($item !== false) {
                        $item['item_original_name'] = $item['item_name'];
                    }
                } else {
                    $item = PMA_EVN_getDataFromRequest();
                }
                $mode = 'edit';
            }
        }
        if ($item !== false) {
            // Show form
            $editor = PMA_EVN_getEditorForm($mode, $operation, $item);
            if ($GLOBALS['is_ajax_request']) {
                $extra_data = array('title' => $title);
                PMA_ajaxResponse($editor, true, $extra_data);
            } else {
                echo "\n\n<h2>{$title}</h2>\n\n{$editor}";
                unset($_POST);
                include './libraries/footer.inc.php';
            }
            // exit;
        } else {
            $message = __('Error in processing request') . ' : ';
            $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_backquote($db)));
            $message = PMA_message::error($message);
            if ($GLOBALS['is_ajax_request']) {
                PMA_ajaxResponse($message, false);
            } else {
                $message->display();
            }
        }
    }
}
示例#11
0
 */
$cfgRelation = PMA_getRelationsParam();
/**
 * Runs common work
 */
require_once 'libraries/tbl_common.inc.php';
$url_query .= '&amp;goto=tbl_structure.php&amp;back=tbl_structure.php';
$url_params['goto'] = 'tbl_structure.php';
$url_params['back'] = 'tbl_structure.php';
// Check column names for MySQL reserved words
if ($cfg['ReservedWordDisableWarning'] === false) {
    $pma_table = new PMA_Table($table, $db);
    $columns = $pma_table->getReservedColumnNames();
    if (!empty($columns)) {
        foreach ($columns as $column) {
            $msg = PMA_message::notice(__('The column name \'%s\' is a MySQL reserved keyword.'));
            $msg->addParam($column);
            $response->addHTML($msg);
        }
    }
}
/**
 * Prepares the table structure display
 */
/**
 * Gets tables informations
 */
require_once 'libraries/tbl_info.inc.php';
require_once 'libraries/Index.class.php';
// 2. Gets table keys and retains them
// @todo should be: $server->db($db)->table($table)->primary()
示例#12
0
    </head>

    <body>
        <?php 
        // Include possible custom headers
        if (file_exists(CUSTOM_HEADER_FILE)) {
            include CUSTOM_HEADER_FILE;
        }
        // message of "Cookies required" displayed for auth_type http or config
        // note: here, the decoration won't work because without cookies,
        // our standard CSS is not operational
        if (empty($_COOKIE)) {
            PMA_Message::notice(__('Cookies must be enabled past this point.'))->display();
        }
        echo "<noscript>\n";
        PMA_message::error(__("Javascript must be enabled past this point"))->display();
        echo "</noscript>\n";
        // offer to load user preferences from localStorage
        if ($userprefs_offer_import) {
            include_once './libraries/user_preferences.lib.php';
            PMA_userprefs_autoload_header();
        }
        // add recently used table and reload the navigation
        if (strlen($GLOBALS['table']) && $GLOBALS['cfg']['LeftRecentTable'] > 0) {
            PMA_addRecentTable($GLOBALS['db'], $GLOBALS['table']);
        }
        if (!defined('PMA_DISPLAY_HEADING')) {
            define('PMA_DISPLAY_HEADING', 1);
        }
        // pass configuration for hint tooltip display
        // (to be used by PMA_createqTip in js/functions.js)
示例#13
0
if ($GLOBALS['is_ajax_request'] && isset($_REQUEST['real_row_count']) && $_REQUEST['real_row_count'] == true) {
    PMA_handleRealRowCountRequest();
    exit;
}
if (!PMA_DRIZZLE) {
    include_once 'libraries/replication.inc.php';
} else {
    $GLOBALS['replication_info']['slave']['status'] = false;
}
require_once 'libraries/bookmark.lib.php';
require_once 'libraries/mysql_charsets.inc.php';
$db_collation = PMA_getDbCollation($db);
$titles = PMA_Util::buildActionTitles();
// 1. No tables
if ($num_tables == 0) {
    $response->addHTML(PMA_message::notice(__('No tables found in database.')));
    PMA_possiblyShowCreateTableDialog($db, $db_is_system_schema, $response);
    exit;
}
// else
// 2. Shows table informations
/**
 * Displays the tables list
 */
$response->addHTML('<div id="tableslistcontainer">');
$_url_params = array('pos' => $pos, 'db' => $db);
// Add the sort options if they exists
if (isset($_REQUEST['sort'])) {
    $_url_params['sort'] = $_REQUEST['sort'];
}
if (isset($_REQUEST['sort_order'])) {
 /**
  * Displays authentication form
  *
  * this function MUST exit/quit the application
  *
  * @global string the last connection error
  *
  * @return void
  */
 public function auth()
 {
     global $conn_error;
     $response = PMA_Response::getInstance();
     if ($response->isAjax()) {
         $response->isSuccess(false);
         if (!empty($conn_error)) {
             $response->addJSON('message', PMA_Message::error($conn_error));
         } else {
             $response->addJSON('message', PMA_Message::error(__('Your session has expired. Please login again.')));
         }
         exit;
     }
     /* Perform logout to custom URL */
     if (!empty($_REQUEST['old_usr']) && !empty($GLOBALS['cfg']['Server']['LogoutURL'])) {
         PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']);
         exit;
     }
     // No recall if blowfish secret is not configured as it would produce
     // garbage
     if ($GLOBALS['cfg']['LoginCookieRecall'] && !empty($GLOBALS['cfg']['blowfish_secret'])) {
         $default_user = $GLOBALS['PHP_AUTH_USER'];
         $default_server = $GLOBALS['pma_auth_server'];
         $autocomplete = '';
     } else {
         $default_user = '';
         $default_server = '';
         // skip the IE autocomplete feature.
         $autocomplete = ' autocomplete="off"';
     }
     $cell_align = $GLOBALS['text_dir'] == 'ltr' ? 'left' : 'right';
     $response->getFooter()->setMinimal();
     $header = $response->getHeader();
     $header->setBodyId('loginform');
     $header->setTitle('phpMyAdmin');
     $header->disableMenu();
     $header->disableWarnings();
     if (file_exists(CUSTOM_HEADER_FILE)) {
         include CUSTOM_HEADER_FILE;
     }
     echo '
 <div class="container">
 <a href="';
     echo PMA_linkURL('http://www.phpmyadmin.net/');
     echo '" target="_blank" class="logo">';
     $logo_image = $GLOBALS['pmaThemeImage'] . 'logo_right.png';
     if (@file_exists($logo_image)) {
         echo '<img src="' . $logo_image . '" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />';
     } else {
         echo '<img name="imLogo" id="imLogo" src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo.png' . '" ' . 'border="0" width="88" height="31" alt="phpMyAdmin" />';
     }
     echo '</a>
    <h1>';
     echo sprintf(__('Welcome to %s'), '<bdo dir="ltr" lang="en">phpMyAdmin</bdo>');
     echo "</h1>";
     // Show error message
     if (!empty($conn_error)) {
         PMA_Message::rawError($conn_error)->display();
     }
     echo "<noscript>\n";
     PMA_message::error(__("Javascript must be enabled past this point"))->display();
     echo "</noscript>\n";
     echo "<div class='hide js-show'>";
     // Displays the languages form
     if (empty($GLOBALS['cfg']['Lang'])) {
         include_once './libraries/display_select_lang.lib.php';
         // use fieldset, don't show doc link
         PMA_Language_select(true, false);
     }
     echo '</div>
 <br />
 <!-- Login form -->
 <form method="post" action="index.php" name="login_form"' . $autocomplete . ' target="_top" class="login hide js-show">
     <fieldset>
     <legend>';
     echo __('Log in');
     echo PMA_Util::showDocu('');
     echo '</legend>';
     if ($GLOBALS['cfg']['AllowArbitraryServer']) {
         echo '
         <div class="item">
             <label for="input_servername" title="';
         echo __('You can enter hostname/IP address and port separated by space.');
         echo '">';
         echo __('Server:');
         echo '</label>
             <input type="text" name="pma_servername" id="input_servername"';
         echo ' value="';
         echo htmlspecialchars($default_server);
         echo '" size="24" class="textfield" title="';
         echo __('You can enter hostname/IP address and port separated by space.');
         echo '" />
         </div>';
     }
     echo '<div class="item">
             <label for="input_username">' . __('Username:'******'</label>
             <input type="text" name="pma_username" id="input_username" ' . 'value="' . htmlspecialchars($default_user) . '" size="24"' . ' class="textfield"/>
         </div>
         <div class="item">
             <label for="input_password">' . __('Password:'******'</label>
             <input type="password" name="pma_password" id="input_password"' . ' value="" size="24" class="textfield" />
         </div>';
     if (count($GLOBALS['cfg']['Servers']) > 1) {
         echo '<div class="item">
             <label for="select_server">' . __('Server Choice') . ':</label>
             <select name="server" id="select_server"';
         if ($GLOBALS['cfg']['AllowArbitraryServer']) {
             echo ' onchange="document.forms[\'login_form\'].' . 'elements[\'pma_servername\'].value = \'\'" ';
         }
         echo '>';
         include_once './libraries/select_server.lib.php';
         PMA_selectServer(false, false);
         echo '</select></div>';
     } else {
         echo '    <input type="hidden" name="server" value="' . $GLOBALS['server'] . '" />';
     }
     // end if (server choice)
     echo '</fieldset>
     <fieldset class="tblFooters">
         <input value="' . __('Go') . '" type="submit" id="input_go" />';
     $_form_params = array();
     if (!empty($GLOBALS['target'])) {
         $_form_params['target'] = $GLOBALS['target'];
     }
     if (!empty($GLOBALS['db'])) {
         $_form_params['db'] = $GLOBALS['db'];
     }
     if (!empty($GLOBALS['table'])) {
         $_form_params['table'] = $GLOBALS['table'];
     }
     // do not generate a "server" hidden field as we want the "server"
     // drop-down to have priority
     echo PMA_generate_common_hidden_inputs($_form_params, '', 0, 'server');
     echo '</fieldset>
 </form>';
     // BEGIN Swekey Integration
     Swekey_login('input_username', 'input_go');
     // END Swekey Integration
     // show the "Cookies required" message only if cookies are disabled
     // (we previously tried to set some cookies)
     if (empty($_COOKIE)) {
         trigger_error(__('Cookies must be enabled past this point.'), E_USER_NOTICE);
     }
     if ($GLOBALS['error_handler']->hasDisplayErrors()) {
         echo '<div>';
         $GLOBALS['error_handler']->dispErrors();
         echo '</div>';
     }
     echo '</div>';
     if (file_exists(CUSTOM_FOOTER_FILE)) {
         include CUSTOM_FOOTER_FILE;
     }
     echo '
 <script type="text/javascript">
 //<![CDATA[
 // show login form in top frame.
 if (top != self || ! $(\'body#loginform\').length) {
     window.top.location.href=location;
 }
 //]]>
 </script>';
     exit;
 }
示例#15
0
 /**
  * Returns some warnings to be displayed at the top of the page
  *
  * @return string The warnings
  */
 private function _getWarnings()
 {
     $retval = '';
     if ($this->_warningsEnabled) {
         // message of "Cookies required" displayed for auth_type http or config
         // note: here, the decoration won't work because without cookies,
         // our standard CSS is not operational
         if (empty($_COOKIE)) {
             $retval .= PMA_Message::notice(__('Cookies must be enabled past this point.'))->getDisplay();
         }
         $retval .= "<noscript>";
         $retval .= PMA_message::error(__("Javascript must be enabled past this point"))->getDisplay();
         $retval .= "</noscript>";
     }
     return $retval;
 }
示例#16
0
/**
 * Handles requests for executing a routine
 */
function PMA_RTN_handleExecute()
{
    global $_GET, $_POST, $_REQUEST, $GLOBALS, $db, $cfg;
    /**
     * Handle all user requests other than the default of listing routines
     */
    if (!empty($_REQUEST['execute_routine']) && !empty($_REQUEST['item_name'])) {
        // Build the queries
        $routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], $_REQUEST['item_type'], false);
        if ($routine !== false) {
            $queries = array();
            $end_query = array();
            $args = array();
            for ($i = 0; $i < $routine['item_num_params']; $i++) {
                if (isset($_REQUEST['params'][$routine['item_param_name'][$i]])) {
                    $value = $_REQUEST['params'][$routine['item_param_name'][$i]];
                    if (is_array($value)) {
                        // is SET type
                        $value = implode(',', $value);
                    }
                    $value = PMA_sqlAddSlashes($value);
                    if (!empty($_REQUEST['funcs'][$routine['item_param_name'][$i]]) && in_array($_REQUEST['funcs'][$routine['item_param_name'][$i]], $cfg['Functions'])) {
                        $queries[] = "SET @p{$i}={$_REQUEST['funcs'][$routine['item_param_name'][$i]]}('{$value}');\n";
                    } else {
                        $queries[] = "SET @p{$i}='{$value}';\n";
                    }
                    $args[] = "@p{$i}";
                } else {
                    $args[] = "@p{$i}";
                }
                if ($routine['item_type'] == 'PROCEDURE') {
                    if ($routine['item_param_dir'][$i] == 'OUT' || $routine['item_param_dir'][$i] == 'INOUT') {
                        $end_query[] = "@p{$i} AS " . PMA_backquote($routine['item_param_name'][$i]);
                    }
                }
            }
            if ($routine['item_type'] == 'PROCEDURE') {
                $queries[] = "CALL " . PMA_backquote($routine['item_name']) . "(" . implode(', ', $args) . ");\n";
                if (count($end_query)) {
                    $queries[] = "SELECT " . implode(', ', $end_query) . ";\n";
                }
            } else {
                $queries[] = "SELECT " . PMA_backquote($routine['item_name']) . "(" . implode(', ', $args) . ") " . "AS " . PMA_backquote($routine['item_name']) . ";\n";
            }
            // Execute the queries
            $affected = 0;
            $result = null;
            $outcome = true;
            foreach ($queries as $query) {
                $resource = PMA_DBI_try_query($query);
                if ($resource === false) {
                    $outcome = false;
                    break;
                }
                while (true) {
                    if (!PMA_DBI_more_results()) {
                        break;
                    }
                    PMA_DBI_next_result();
                }
                if (substr($query, 0, 6) == 'SELECT') {
                    $result = $resource;
                } else {
                    if (substr($query, 0, 4) == 'CALL') {
                        $result = $resource ? $resource : $result;
                        $affected = PMA_DBI_affected_rows() - PMA_DBI_num_rows($resource);
                    }
                }
            }
            // Generate output
            if ($outcome) {
                $message = __('Your SQL query has been executed successfully');
                if ($routine['item_type'] == 'PROCEDURE') {
                    $message .= '<br />';
                    $message .= sprintf(_ngettext('%d row affected by the last statement inside the procedure', '%d rows affected by the last statement inside the procedure', $affected), $affected);
                }
                $message = PMA_message::success($message);
                // Pass the SQL queries through the "pretty printer"
                $output = '<code class="sql" style="margin-bottom: 1em;">';
                $output .= PMA_SQP_formatHtml(PMA_SQP_parse(implode($queries)));
                $output .= '</code>';
                // Display results
                if ($result) {
                    $output .= "<fieldset><legend>";
                    $output .= sprintf(__('Execution results of routine %s'), PMA_backquote(htmlspecialchars($routine['item_name'])));
                    $output .= "</legend>";
                    $output .= "<table><tr>";
                    foreach (PMA_DBI_get_fields_meta($result) as $key => $field) {
                        $output .= "<th>";
                        $output .= htmlspecialchars($field->name);
                        $output .= "</th>";
                    }
                    $output .= "</tr>";
                    // Stored routines can only ever return ONE ROW.
                    $data = PMA_DBI_fetch_single_row($result);
                    foreach ($data as $key => $value) {
                        if ($value === null) {
                            $value = '<i>NULL</i>';
                        } else {
                            $value = htmlspecialchars($value);
                        }
                        $output .= "<td class='odd'>" . $value . "</td>";
                    }
                    $output .= "</table></fieldset>";
                } else {
                    $notice = __('MySQL returned an empty result set (i.e. zero rows).');
                    $output .= PMA_message::notice($notice)->getDisplay();
                }
            } else {
                $output = '';
                $message = PMA_message::error(sprintf(__('The following query has failed: "%s"'), $query) . '<br /><br />' . __('MySQL said: ') . PMA_DBI_getError(null));
            }
            // Print/send output
            if ($GLOBALS['is_ajax_request']) {
                $extra_data = array('dialog' => false);
                PMA_ajaxResponse($message->getDisplay() . $output, $message->isSuccess(), $extra_data);
            } else {
                echo $message->getDisplay() . $output;
                if ($message->isError()) {
                    // At least one query has failed, so shouldn't
                    // execute any more queries, so we quit.
                    exit;
                }
                unset($_POST);
                // Now deliberately fall through to displaying the routines list
            }
        } else {
            $message = __('Error in processing request') . ' : ';
            $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_backquote($db)));
            $message = PMA_message::error($message);
            if ($GLOBALS['is_ajax_request']) {
                PMA_ajaxResponse($message, $message->isSuccess());
            } else {
                echo $message->getDisplay();
                unset($_POST);
            }
        }
    } else {
        if (!empty($_GET['execute_dialog']) && !empty($_GET['item_name'])) {
            /**
             * Display the execute form for a routine.
             */
            $routine = PMA_RTN_getDataFromName($_GET['item_name'], $_GET['item_type'], true);
            if ($routine !== false) {
                $form = PMA_RTN_getExecuteForm($routine);
                if ($GLOBALS['is_ajax_request'] == true) {
                    $extra_data = array();
                    $extra_data['dialog'] = true;
                    $extra_data['title'] = __("Execute routine") . " ";
                    $extra_data['title'] .= PMA_backquote(htmlentities($_GET['item_name'], ENT_QUOTES));
                    PMA_ajaxResponse($form, true, $extra_data);
                } else {
                    echo "\n\n<h2>" . __("Execute routine") . "</h2>\n\n";
                    echo $form;
                    include './libraries/footer.inc.php';
                    // exit;
                }
            } else {
                if ($GLOBALS['is_ajax_request'] == true) {
                    $message = __('Error in processing request') . ' : ';
                    $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_backquote($db)));
                    $message = PMA_message::error($message);
                    PMA_ajaxResponse($message, false);
                }
            }
        }
    }
}
 /**
  * Displays authentication form
  *
  * this function MUST exit/quit the application
  *
  * @global string $conn_error the last connection error
  *
  * @return boolean|void
  */
 public function auth()
 {
     global $conn_error;
     $response = PMA_Response::getInstance();
     if ($response->isAjax()) {
         $response->setRequestStatus(false);
         // redirect_flag redirects to the login page
         $response->addJSON('redirect_flag', '1');
         if (defined('TESTSUITE')) {
             return true;
         } else {
             exit;
         }
     }
     /* Perform logout to custom URL */
     if (!empty($_REQUEST['old_usr']) && !empty($GLOBALS['cfg']['Server']['LogoutURL'])) {
         PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']);
         if (defined('TESTSUITE')) {
             return true;
         } else {
             exit;
         }
     }
     // No recall if blowfish secret is not configured as it would produce
     // garbage
     if ($GLOBALS['cfg']['LoginCookieRecall'] && !empty($GLOBALS['cfg']['blowfish_secret'])) {
         $default_user = $GLOBALS['PHP_AUTH_USER'];
         $default_server = $GLOBALS['pma_auth_server'];
         $autocomplete = '';
     } else {
         $default_user = '';
         $default_server = '';
         // skip the IE autocomplete feature.
         $autocomplete = ' autocomplete="off"';
     }
     $response->getFooter()->setMinimal();
     $header = $response->getHeader();
     $header->setBodyId('loginform');
     $header->setTitle('phpMyAdmin');
     $header->disableMenuAndConsole();
     $header->disableWarnings();
     if (file_exists(CUSTOM_HEADER_FILE)) {
         include CUSTOM_HEADER_FILE;
     }
     echo '
 <div class="container">
 <a href="';
     echo PMA_linkURL('https://www.phpmyadmin.net/');
     echo '" target="_blank" class="logo">';
     $logo_image = $GLOBALS['pmaThemeImage'] . 'logo_right.png';
     if (@file_exists($logo_image)) {
         echo '<img src="' . $logo_image . '" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />';
     } else {
         echo '<img name="imLogo" id="imLogo" src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo.png' . '" ' . 'border="0" width="88" height="31" alt="phpMyAdmin" />';
     }
     echo '</a>
    <h1>';
     echo sprintf(__('Welcome to %s'), '<bdo dir="ltr" lang="en">phpMyAdmin</bdo>');
     echo "</h1>";
     // Show error message
     if (!empty($conn_error)) {
         PMA_Message::rawError($conn_error)->display();
     } elseif (isset($_GET['session_expired']) && intval($_GET['session_expired']) == 1) {
         PMA_Message::rawError(__('Your session has expired. Please log in again.'))->display();
     }
     echo "<noscript>\n";
     PMA_message::error(__("Javascript must be enabled past this point!"))->display();
     echo "</noscript>\n";
     echo "<div class='hide js-show'>";
     // Displays the languages form
     if (empty($GLOBALS['cfg']['Lang'])) {
         include_once './libraries/display_select_lang.lib.php';
         // use fieldset, don't show doc link
         echo PMA_getLanguageSelectorHtml(true, false);
     }
     echo '</div>
 <br />
 <!-- Login form -->
 <form method="post" action="index.php" name="login_form"' . $autocomplete . ' class="disableAjax login hide js-show">
     <fieldset>
     <legend>';
     echo __('Log in');
     echo PMA_Util::showDocu('index');
     echo '</legend>';
     if ($GLOBALS['cfg']['AllowArbitraryServer']) {
         echo '
         <div class="item">
             <label for="input_servername" title="';
         echo __('You can enter hostname/IP address and port separated by space.');
         echo '">';
         echo __('Server:');
         echo '</label>
             <input type="text" name="pma_servername" id="input_servername"';
         echo ' value="';
         echo htmlspecialchars($default_server);
         echo '" size="24" class="textfield" title="';
         echo __('You can enter hostname/IP address and port separated by space.');
         echo '" />
         </div>';
     }
     echo '<div class="item">
             <label for="input_username">' . __('Username:'******'</label>
             <input type="text" name="pma_username" id="input_username" ' . 'value="' . htmlspecialchars($default_user) . '" size="24"' . ' class="textfield"/>
         </div>
         <div class="item">
             <label for="input_password">' . __('Password:'******'</label>
             <input type="password" name="pma_password" id="input_password"' . ' value="" size="24" class="textfield" />
         </div>';
     if (count($GLOBALS['cfg']['Servers']) > 1) {
         echo '<div class="item">
             <label for="select_server">' . __('Server Choice:') . '</label>
             <select name="server" id="select_server"';
         if ($GLOBALS['cfg']['AllowArbitraryServer']) {
             echo ' onchange="document.forms[\'login_form\'].' . 'elements[\'pma_servername\'].value = \'\'" ';
         }
         echo '>';
         include_once './libraries/select_server.lib.php';
         echo PMA_selectServer(false, false);
         echo '</select></div>';
     } else {
         echo '    <input type="hidden" name="server" value="' . $GLOBALS['server'] . '" />';
     }
     // end if (server choice)
     // Add captcha input field if reCaptcha is enabled
     if (!empty($GLOBALS['cfg']['CaptchaLoginPrivateKey']) && !empty($GLOBALS['cfg']['CaptchaLoginPublicKey'])) {
         // If enabled show captcha to the user on the login screen.
         echo '<script src="https://www.google.com/recaptcha/api.js?hl=' . $GLOBALS['lang'] . '" async defer></script>';
         echo '<div class="g-recaptcha" data-sitekey="' . $GLOBALS['cfg']['CaptchaLoginPublicKey'] . '"></div>';
     }
     echo '</fieldset>
     <fieldset class="tblFooters">
         <input value="' . __('Go') . '" type="submit" id="input_go" />';
     $_form_params = array();
     if (!empty($GLOBALS['target'])) {
         $_form_params['target'] = $GLOBALS['target'];
     }
     if (!empty($GLOBALS['db'])) {
         $_form_params['db'] = $GLOBALS['db'];
     }
     if (!empty($GLOBALS['table'])) {
         $_form_params['table'] = $GLOBALS['table'];
     }
     // do not generate a "server" hidden field as we want the "server"
     // drop-down to have priority
     echo PMA_URL_getHiddenInputs($_form_params, '', 0, 'server');
     echo '</fieldset>
 </form>';
     // BEGIN Swekey Integration
     Swekey_login('input_username', 'input_go');
     // END Swekey Integration
     if ($GLOBALS['error_handler']->hasDisplayErrors()) {
         echo '<div id="pma_errors">';
         $GLOBALS['error_handler']->dispErrors();
         echo '</div>';
     }
     echo '</div>';
     if (file_exists(CUSTOM_FOOTER_FILE)) {
         include CUSTOM_FOOTER_FILE;
     }
     if (!defined('TESTSUITE')) {
         exit;
     } else {
         return true;
     }
 }
示例#18
0
/**
 * To get the message if a column index is missing. If not will return null
 *
 * @param string  $table      current table
 * @param string  $db         current database
 * @param boolean $editable   whether the results table can be editable or not
 * @param boolean $has_unique whether there is a unique key
 *
 * @return PMA_message $message
 */
function PMA_getMessageIfMissingColumnIndex($table, $db, $editable, $has_unique)
{
    if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) || !$editable)) {
        $missing_unique_column_msg = PMA_message::notice(sprintf(__('Current selection does not contain a unique column.' . ' Grid edit, checkbox, Edit, Copy and Delete features' . ' are not available. %s'), PMA_Util::showDocu('config', 'cfg_RowActionLinksWithoutUnique')));
    } elseif (!empty($table) && !$has_unique) {
        $missing_unique_column_msg = PMA_message::notice(sprintf(__('Current selection does not contain a unique column.' . ' Grid edit, Edit, Copy and Delete features may result in' . ' undesired behavior. %s'), PMA_Util::showDocu('config', 'cfg_RowActionLinksWithoutUnique')));
    } else {
        $missing_unique_column_msg = null;
    }
    return $missing_unique_column_msg;
}
示例#19
0
/**
 * To get the message if a column index is missing. If not will return null
 *
 * @param string  $table    current table
 * @param string  $db       current database
 * @param boolean $editable whether the results table can be editable or not
 *
 * @return PMA_message $message
 */
function PMA_getMessageIfMissingColumnIndex($table, $db, $editable)
{
    if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) || !$editable)) {
        $missing_unique_column_msg = PMA_message::notice(__('Current selection does not contain a unique column.' . ' Grid edit, checkbox, Edit, Copy and Delete features' . ' are not available.'));
    } else {
        $missing_unique_column_msg = null;
    }
    return $missing_unique_column_msg;
}
示例#20
0
 }
 if (isset($profiling_results)) {
     PMA_profilingResults($profiling_results);
 }
 // Displays the results in a table
 if (empty($disp_mode)) {
     // see the "PMA_setDisplayMode()" function in
     // libraries/display_tbl.lib.php
     $disp_mode = 'urdr111101';
 }
 // hide edit and delete links for information_schema
 if ($db == 'information_schema') {
     $disp_mode = 'nnnn110111';
 }
 if (isset($label)) {
     $message = PMA_message::success('strBookmarkCreated');
     $message->addParam($label);
     $message->display();
 }
 PMA_displayTable($result, $disp_mode, $analyzed_sql);
 PMA_DBI_free_result($result);
 // BEGIN INDEX CHECK See if indexes should be checked.
 if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
     foreach ($selected as $idx => $tbl_name) {
         $check = PMA_Index::findDuplicates($tbl_name, $db);
         if (!empty($check)) {
             printf($strIndexWarningTable, $tbl_name);
             echo $check;
         }
     }
 }
 /**
  * Returns some warnings to be displayed at the top of the page
  *
  * @return string The warnings
  */
 private function _getWarnings()
 {
     $retval = '';
     if ($this->_warningsEnabled) {
         $retval .= "<noscript>";
         $retval .= PMA_message::error(__("Javascript must be enabled past this point!"))->getDisplay();
         $retval .= "</noscript>";
     }
     return $retval;
 }
 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     // Database structure
     if ($this->_type == 'db') {
         // Add/Remove favorite tables using Ajax request.
         if ($GLOBALS['is_ajax_request'] && !empty($_REQUEST['favorite_table'])) {
             $this->addRemoveFavoriteTables();
             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';
         // 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('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, $this->_db_is_system_schema, $this->_is_show_stats, $sum_size, $overhead_size);
             if (!$this->dbi->getTable($this->_db, $current_table['TABLE_NAME'])->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'])->sGetStatusInfo(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('structure/browse_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Browse'] : $titles['NoBrowse']));
             $search_table = Template::get('structure/search_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Search'] : $titles['NoSearch']));
             $browse_table_label = Template::get('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('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('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('structure/table_header')->render(array('db_is_system_schema' => false, 'replication' => $GLOBALS['replication_info']['slave']['status'])));
             }
             $do = $ignored = false;
             $server_slave_status = $GLOBALS['replication_info']['slave']['status'];
             include_once 'libraries/replication.inc.php';
             if ($server_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('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('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('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('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));
         }
     } elseif ($this->_type == 'table') {
         // Table structure
         PMA_PageSettings::showGroup('TableStructure');
         /**
          * Function implementations for this script
          */
         require_once 'libraries/check_user_privileges.lib.php';
         require_once 'libraries/index.lib.php';
         require_once 'libraries/sql.lib.php';
         require_once 'libraries/bookmark.lib.php';
         $this->response->getHeader()->getScripts()->addFiles(array('tbl_structure.js', 'indexes.js'));
         /**
          * Handle column moving
          */
         if (isset($_REQUEST['move_columns']) && is_array($_REQUEST['move_columns']) && $this->response->isAjax()) {
             $this->moveColumns();
             return;
         }
         /**
          * handle MySQL reserved words columns check
          */
         if (isset($_REQUEST['reserved_word_check'])) {
             if ($GLOBALS['cfg']['ReservedWordDisableWarning'] === false) {
                 $columns_names = $_REQUEST['field_name'];
                 $reserved_keywords_names = array();
                 foreach ($columns_names as $column) {
                     if (SqlParser\Context::isKeyword(trim($column), true)) {
                         $reserved_keywords_names[] = trim($column);
                     }
                 }
                 if (SqlParser\Context::isKeyword(trim($this->_table), true)) {
                     $reserved_keywords_names[] = trim($this->_table);
                 }
                 if (count($reserved_keywords_names) == 0) {
                     $this->response->isSuccess(false);
                 }
                 $this->response->addJSON('message', sprintf(_ngettext('The name \'%s\' is a MySQL reserved keyword.', 'The names \'%s\' are MySQL reserved keywords.', count($reserved_keywords_names)), implode(',', $reserved_keywords_names)));
             } else {
                 $this->response->isSuccess(false);
             }
             return;
         }
         /**
          * A click on Change has been made for one column
          */
         if (isset($_REQUEST['change_column'])) {
             $this->displayHtmlForColumnChange(null, 'tbl_structure.php');
             return;
         }
         /**
          * handle multiple field commands if required
          *
          * submit_mult_*_x comes from IE if <input type="img" ...> is used
          */
         $submit_mult = $this->getMultipleFieldCommandType();
         if (!empty($submit_mult)) {
             if (isset($_REQUEST['selected_fld'])) {
                 if ($submit_mult == 'browse') {
                     // browsing the table displaying only selected columns
                     $this->displayTableBrowseForSelectedColumns($GLOBALS['goto'], $GLOBALS['pmaThemeImage']);
                 } else {
                     // handle multiple field commands
                     // handle confirmation of deleting multiple columns
                     $action = 'tbl_structure.php';
                     $GLOBALS['selected'] = $_REQUEST['selected_fld'];
                     list($what_ret, $query_type_ret, $is_unset_submit_mult, $mult_btn_ret, $centralColsError) = $this->getDataForSubmitMult($submit_mult, $_REQUEST['selected_fld'], $action);
                     //update the existing variables
                     // todo: refactor mult_submits.inc.php such as
                     // below globals are not needed anymore
                     if (isset($what_ret)) {
                         $GLOBALS['what'] = $what_ret;
                         global $what;
                     }
                     if (isset($query_type_ret)) {
                         $GLOBALS['query_type'] = $query_type_ret;
                         global $query_type;
                     }
                     if ($is_unset_submit_mult) {
                         unset($submit_mult);
                     }
                     if (isset($mult_btn_ret)) {
                         $GLOBALS['mult_btn'] = $mult_btn_ret;
                         global $mult_btn;
                     }
                     include 'libraries/mult_submits.inc.php';
                     /**
                      * if $submit_mult == 'change', execution will have stopped
                      * at this point
                      */
                     if (empty($message)) {
                         $message = PMA_Message::success();
                     }
                     $this->response->addHTML(PMA_Util::getMessage($message, $sql_query));
                 }
             } else {
                 $this->response->isSuccess(false);
                 $this->response->addJSON('message', __('No column selected.'));
             }
         }
         // display secondary level tabs if necessary
         $engine = $this->_table_obj->sGetStatusInfo('ENGINE');
         $this->response->addHTML(Template::get('structure/secondary_tabs')->render(array('url_params' => array('db' => $this->_db, 'table' => $this->_table), 'engine' => $engine)));
         $this->response->addHTML('<div id="structure_content">');
         /**
          * Modifications have been submitted -> updates the table
          */
         if (isset($_REQUEST['do_save_data'])) {
             $regenerate = $this->updateColumns();
             if ($regenerate) {
                 // This happens when updating failed
                 // @todo: do something appropriate
             } else {
                 // continue to show the table's structure
                 unset($_REQUEST['selected']);
             }
         }
         /**
          * Adding indexes
          */
         if (isset($_REQUEST['add_key'])) {
             //todo: set some variables for sql.php include, to be eliminated
             //after refactoring sql.php
             $db = $this->_db;
             $table = $this->_table;
             $cfg = $GLOBALS['cfg'];
             $is_superuser = $GLOBALS['dbi']->isSuperuser();
             $pmaThemeImage = $GLOBALS['pmaThemeImage'];
             include 'sql.php';
             $GLOBALS['reload'] = true;
         }
         /**
          * Gets the relation settings
          */
         $cfgRelation = PMA_getRelationsParam();
         /**
          * Runs common work
          */
         // set db, table references, for require_once that follows
         // got to be eliminated in long run
         $db =& $this->_db;
         $table =& $this->_table;
         require_once 'libraries/tbl_common.inc.php';
         $this->_url_query = $url_query . '&amp;goto=tbl_structure.php&amp;back=tbl_structure.php';
         $url_params['goto'] = 'tbl_structure.php';
         $url_params['back'] = 'tbl_structure.php';
         /**
          * Gets tables information
          */
         require_once 'libraries/tbl_info.inc.php';
         require_once 'libraries/Index.class.php';
         // 2. Gets table keys and retains them
         // @todo should be: $server->db($db)->table($table)->primary()
         $primary = PMA_Index::getPrimary($this->_table, $this->_db);
         $columns_with_index = $this->dbi->getTable($this->_db, $this->_table)->getColumnsWithIndex(PMA_Index::UNIQUE | PMA_Index::INDEX | PMA_Index::SPATIAL | PMA_Index::FULLTEXT);
         $columns_with_unique_index = $this->dbi->getTable($this->_db, $this->_table)->getColumnsWithIndex(PMA_Index::UNIQUE);
         // 3. Get fields
         $fields = (array) $this->dbi->getColumns($this->_db, $this->_table, null, true);
         // Get more complete field information
         // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
         // but later, if the analyser returns more information, it
         // could be executed for any MySQL version and replace
         // the info given by SHOW FULL COLUMNS FROM.
         //
         // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
         // SHOW FULL COLUMNS or INFORMATION_SCHEMA incorrectly says NULL
         // and SHOW CREATE TABLE says NOT NULL (tested
         // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
         $show_create_table = $this->_table_obj->showCreate();
         $parser = new SqlParser\Parser($show_create_table);
         /**
          * @var CreateStatement $stmt
          */
         $stmt = $parser->statements[0];
         $create_table_fields = SqlParser\Utils\Table::getFields($stmt);
         //display table structure
         $this->response->addHTML($this->displayStructure($cfgRelation, $columns_with_unique_index, $url_params, $primary, $fields, $columns_with_index, $create_table_fields));
         $this->response->addHTML('</div>');
     }
 }