コード例 #1
0
        // uses SHOW CREATE
        $definition = 'DROP ' . $routine['ROUTINE_TYPE'] . ' ' . PMA_backquote($routine['SPECIFIC_NAME']) . $delimiter . "\n" . PMA_DBI_get_definition($db, $routine['ROUTINE_TYPE'], $routine['SPECIFIC_NAME']) . "\n";
        //if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') {
        //    $sqlUseProc  = 'CALL ' . $routine['SPECIFIC_NAME'] . '()';
        //} else {
        //    $sqlUseProc = 'SELECT ' . $routine['SPECIFIC_NAME'] . '()';
        /* this won't get us far: to really use the function
           i'd need to know how many parameters the function needs and then create
           something to ask for them. As i don't see this directly in
           the table i am afraid that requires parsing the ROUTINE_DEFINITION
           and i don't really need that now so i simply don't offer
           a method for running the function*/
        //}
        if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') {
            $sqlDropProc = 'DROP PROCEDURE ' . PMA_backquote($routine['SPECIFIC_NAME']);
        } else {
            $sqlDropProc = 'DROP FUNCTION ' . PMA_backquote($routine['SPECIFIC_NAME']);
        }
        echo sprintf('<tr class="%s">
                          <td><input type="hidden" class="drop_procedure_sql" value="%s" /><strong>%s</strong></td>
                          <td>%s</td>
                          <td>%s</td>
                          <td>%s</td>
                          <td>%s</td>
                     </tr>', $ct % 2 == 0 ? 'even' : 'odd', $sqlDropProc, $routine['ROUTINE_NAME'], !empty($definition) ? PMA_linkOrButton('db_sql.php?' . $url_query . '&amp;sql_query=' . urlencode($definition) . '&amp;show_query=1&amp;db_query_force=1&amp;delimiter=' . urlencode($delimiter), $titles['Edit']) : '&nbsp;', '<a ' . $conditional_class . ' href="sql.php?' . $url_query . '&amp;sql_query=' . urlencode($sqlDropProc) . '" >' . $titles['Drop'] . '</a>', $routine['ROUTINE_TYPE'], $routine['DTD_IDENTIFIER']);
        $ct++;
    }
    echo '</table>';
    echo '</fieldset>' . "\n";
    echo '</div>' . "\n";
}
コード例 #2
0
/**
 * Displays operations that are available on results.
 *
 * @param   array   the display mode
 * @param   array   the analyzed query
 *
 * @uses    $_SESSION['tmp_user_values']['pos']
 * @uses    $_SESSION['tmp_user_values']['display_text']
 * @global  string   $db                the database name
 * @global  string   $table             the table name
 * @global  string   $sql_query         the current SQL query
 * @global  integer  $unlim_num_rows    the total number of rows returned by the
 *                                      SQL query without any programmatically
 *                                      appended "LIMIT" clause
 *
 * @access  private
 *
 * @see     PMA_showMessage(), PMA_setDisplayMode(),
 *          PMA_displayTableNavigation(), PMA_displayTableHeaders(),
 *          PMA_displayTableBody(), PMA_displayResultsOperations()
 */
function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql)
{
    global $db, $table, $sql_query, $unlim_num_rows;
    $header_shown = FALSE;
    $header = '<fieldset><legend>' . $GLOBALS['strQueryResultsOperations'] . '</legend>';
    if ($the_disp_mode[6] == '1' || $the_disp_mode[9] == '1') {
        // Displays "printable view" link if required
        if ($the_disp_mode[9] == '1') {
            if (!$header_shown) {
                echo $header;
                $header_shown = TRUE;
            }
            $_url_params = array('db' => $db, 'table' => $table, 'printview' => '1', 'sql_query' => $sql_query);
            $url_query = PMA_generate_common_url($_url_params);
            echo PMA_linkOrButton('sql.php' . $url_query, PMA_getIcon('b_print.png', $GLOBALS['strPrintView'], false, true), '', true, true, 'print_view') . "\n";
            if ($_SESSION['tmp_user_values']['display_text']) {
                $_url_params['display_text'] = 'F';
                echo PMA_linkOrButton('sql.php' . PMA_generate_common_url($_url_params), PMA_getIcon('b_print.png', $GLOBALS['strPrintViewFull'], false, true), '', true, true, 'print_view') . "\n";
                unset($_url_params['display_text']);
            }
        }
        // end displays "printable view"
    }
    // Export link
    // (the url_query has extra parameters that won't be used to export)
    // (the single_table parameter is used in display_export.lib.php
    //  to hide the SQL and the structure export dialogs)
    // If the parser found a PROCEDURE clause
    // (most probably PROCEDURE ANALYSE()) it makes no sense to
    // display the Export link).
    if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT' && !isset($printview) && !isset($analyzed_sql[0]['queryflags']['procedure'])) {
        if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
            $_url_params['single_table'] = 'true';
        }
        if (!$header_shown) {
            echo $header;
            $header_shown = TRUE;
        }
        $_url_params['unlim_num_rows'] = $unlim_num_rows;
        /**
         * At this point we don't know the table name; this can happen
         * for example with a query like
         * SELECT bike_code FROM (SELECT bike_code FROM bikes) tmp
         * As a workaround we set in the table parameter the name of the
         * first table of this database, so that tbl_export.php and
         * the script it calls do not fail
         */
        if (empty($_url_params['table'])) {
            $_url_params['table'] = PMA_DBI_fetch_value("SHOW TABLES");
        }
        echo PMA_linkOrButton('tbl_export.php' . PMA_generate_common_url($_url_params), PMA_getIcon('b_tblexport.png', $GLOBALS['strExport'], false, true), '', true, true, '') . "\n";
    }
    // CREATE VIEW
    /**
     *
     * @todo detect privileges to create a view
     *       (but see 2006-01-19 note in display_create_table.lib.php,
     *        I think we cannot detect db-specific privileges reliably)
     * Note: we don't display a Create view link if we found a PROCEDURE clause
     */
    if (!$header_shown) {
        echo $header;
        $header_shown = TRUE;
    }
    if (!isset($analyzed_sql[0]['queryflags']['procedure'])) {
        echo PMA_linkOrButton('view_create.php' . $url_query, PMA_getIcon('b_views.png', 'CREATE VIEW', false, true), '', true, true, '') . "\n";
    }
    if ($header_shown) {
        echo '</fieldset><br />';
    }
}
コード例 #3
0
/**
 * Displays operations that are available on results.
 *
 * @param   array   the display mode
 * @param   array   the analyzed query
 *
 * @global  string   $db                the database name
 * @global  string   $table             the table name
 * @global  boolean  $dontlimitchars    whether to limit the number of displayed
 *                                      characters of text type fields or not
 * @global  integer  $pos               the current postion of the first record
 *                                      to be displayed
 * @global  string   $sql_query         the current sql query
 * @global  integer  $unlim_num_rows    the total number of rows returned by the
 *                                      sql query without any programmatically
 *                                      appended "LIMIT" clause
 * @global  string   $disp_direction    the display mode
 *                                      (horizontal/vertical/horizontalflipped)
 * @global  integer  $repeat_cells      the number of row to display between two
 *                                      table headers
 *
 * @access  private
 *
 * @see     PMA_showMessage(), PMA_setDisplayMode(),
 *          PMA_displayTableNavigation(), PMA_displayTableHeaders(),
 *          PMA_displayTableBody(), PMA_displayResultsOperations()
 */
function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql)
{
    global $db, $table, $dontlimitchars, $pos, $sql_query, $unlim_num_rows, $disp_direction, $repeat_cells;
    $header_shown = FALSE;
    $header = '<fieldset><legend>' . $GLOBALS['strQueryResultsOperations'] . '</legend>';
    if ($the_disp_mode[6] == '1' || $the_disp_mode[9] == '1') {
        // Displays "printable view" link if required
        if ($the_disp_mode[9] == '1') {
            if (!$header_shown) {
                echo $header;
                $header_shown = TRUE;
            }
            $url_query = '?' . PMA_generate_common_url($db, $table) . '&amp;pos=' . $pos . '&amp;session_max_rows=' . $GLOBALS['session_max_rows'] . '&amp;disp_direction=' . $disp_direction . '&amp;repeat_cells=' . $repeat_cells . '&amp;printview=1' . '&amp;sql_query=' . urlencode($sql_query);
            echo '    <!-- Print view -->' . "\n";
            echo PMA_linkOrButton('sql.php' . $url_query . (isset($dontlimitchars) && $dontlimitchars == '1' ? '&amp;dontlimitchars=1' : ''), ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_print.png" height="16" width="16" alt="' . $GLOBALS['strPrintView'] . '"/>' : '') . $GLOBALS['strPrintView'], '', true, true, 'print_view') . "\n";
            if (!$dontlimitchars) {
                echo '    &nbsp;&nbsp;' . "\n";
                echo PMA_linkOrButton('sql.php' . $url_query . '&amp;dontlimitchars=1', ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_print.png" height="16" width="16" alt="' . $GLOBALS['strPrintViewFull'] . '"/>' : '') . $GLOBALS['strPrintViewFull'], '', true, true, 'print_view') . "\n";
            }
        }
        // end displays "printable view"
        echo "\n";
    }
    // Export link
    // (the url_query has extra parameters that won't be used to export)
    // (the single_table parameter is used in display_export.lib.php
    //  to hide the SQL and the structure export dialogs)
    if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT' && !isset($printview)) {
        if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
            $single_table = '&amp;single_table=true';
        } else {
            $single_table = '';
        }
        if (!$header_shown) {
            echo $header;
            $header_shown = TRUE;
        }
        echo '    <!-- Export -->' . "\n";
        echo '    &nbsp;&nbsp;' . "\n";
        echo PMA_linkOrButton('tbl_properties_export.php' . $url_query . '&amp;unlim_num_rows=' . $unlim_num_rows . $single_table, ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_tblexport.png" height="16" width="16" alt="' . $GLOBALS['strExport'] . '" />' : '') . $GLOBALS['strExport'], '', true, true, '') . "\n";
    }
    if ($header_shown) {
        echo '</fieldset><br />';
    }
}
コード例 #4
0
/**
 * Generates a Delete link
 *
 * @uses    PMA_linkOrButton()
 * @param   string  $del_url
 * @param   string  $del_str
 * @param   string  $js_conf
 * @param   string  $class
 * @return  string  the generated HTML
 */
function PMA_generateDeleteLink($del_url, $del_str, $js_conf, $class)
{
    $ret = '';
    if (!empty($del_url)) {
        $ret .= '<td ';
        if (!empty($class)) {
            $ret .= 'class="' . $class . '" ';
        }
        $ret .= 'align="center" ' . ' >' . PMA_linkOrButton($del_url, $del_str, $js_conf, FALSE) . '</td>';
    }
    return $ret;
}
コード例 #5
0
/**
 * Creates a clickable column header for table information
 *
 * @param   string  title to use for the link
 * @param   string  corresponds to sortable data name mapped in libraries/db_info.inc.php  
 * @param   string  initial sort order
 * @returns string  link to be displayed in the table header
 */
function PMA_SortableTableHeader($title, $sort, $initial_sort_order = 'ASC')
{
    // Set some defaults
    $requested_sort = 'table';
    $requested_sort_order = $future_sort_order = $initial_sort_order;
    // If the user requested a sort
    if (isset($_REQUEST['sort'])) {
        $requested_sort = $_REQUEST['sort'];
        if (isset($_REQUEST['sort_order'])) {
            $requested_sort_order = $_REQUEST['sort_order'];
        }
    }
    $order_img = '';
    $order_link_params = array();
    $order_link_params['title'] = __('Sort');
    // If this column was requested to be sorted.
    if ($requested_sort == $sort) {
        if ($requested_sort_order == 'ASC') {
            $future_sort_order = 'DESC';
            // current sort order is ASC
            $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="' . __('Ascending') . '" title="' . __('Ascending') . '" id="sort_arrow" />';
            // but on mouse over, show the reverse order (DESC)
            $order_link_params['onmouseover'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
            // on mouse out, show current sort order (ASC)
            $order_link_params['onmouseout'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
        } else {
            $future_sort_order = 'ASC';
            // current sort order is DESC
            $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_desc.png" width="11" height="9" alt="' . __('Descending') . '" title="' . __('Descending') . '" id="sort_arrow" />';
            // but on mouse over, show the reverse order (ASC)
            $order_link_params['onmouseover'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
            // on mouse out, show current sort order (DESC)
            $order_link_params['onmouseout'] = 'if(document.getElementById(\'sort_arrow\')){ document.getElementById(\'sort_arrow\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
        }
    }
    $_url_params = array('db' => $_REQUEST['db']);
    $url = 'db_structure.php' . PMA_generate_common_url($_url_params);
    // We set the position back to 0 every time they sort.
    $url .= "&amp;pos=0&amp;sort={$sort}&amp;sort_order={$future_sort_order}";
    return PMA_linkOrButton($url, $title . $order_img, $order_link_params);
}
コード例 #6
0
    echo '<br />' . "\n" . '<table class="data">' . "\n" . '<caption class="tblHeaders">' . "\n" . sprintf($GLOBALS['strSearchResultsFor'], $searched, $option_str) . "\n" . '</caption>' . "\n";
    $num_search_result_total = 0;
    $odd_row = true;
    foreach ($tables_selected as $each_table) {
        // Gets the SQL statements
        $newsearchsqls = PMA_getSearchSqls($each_table, !empty($field_str) ? $field_str : '', $search_str, $search_option);
        // Executes the "COUNT" statement
        $res_cnt = PMA_DBI_fetch_value($newsearchsqls['select_count']);
        $num_search_result_total += $res_cnt;
        $sql_query .= $newsearchsqls['select_count'];
        echo '<tr class="' . ($odd_row ? 'odd' : 'even') . '">' . '<td>' . sprintf($GLOBALS['strNumSearchResultsInTable'], $res_cnt, htmlspecialchars($each_table)) . "</td>\n";
        if ($res_cnt > 0) {
            $this_url_params['sql_query'] = $newsearchsqls['select_fields'];
            echo '<td>' . PMA_linkOrButton('sql.php' . PMA_generate_common_url($this_url_params), $GLOBALS['strBrowse'], '') . "</td>\n";
            $this_url_params['sql_query'] = $newsearchsqls['delete'];
            echo '<td>' . PMA_linkOrButton('sql.php' . PMA_generate_common_url($this_url_params), $GLOBALS['strDelete'], $newsearchsqls['delete']) . "</td>\n";
        } else {
            echo '<td>&nbsp;</td>' . "\n" . '<td>&nbsp;</td>' . "\n";
        }
        // end if else
        $odd_row = !$odd_row;
        echo '</tr>' . "\n";
    }
    // end for
    echo '</table>' . "\n";
    if (count($tables_selected) > 1) {
        echo '<p>' . sprintf($GLOBALS['strNumSearchResultsTotal'], $num_search_result_total) . '</p>' . "\n";
    }
}
// end 1.
/**
コード例 #7
0
ファイル: common.lib.php プロジェクト: kebyn/apache_workspace
/**
 * displays the message and the query
 * usually the message is the result of the query executed
 *
 * @param   string  $message    the message to display
 * @param   string  $sql_query  the query to display
 * @param   string  $type       the type (level) of the message
 * @global  array   the configuration array
 * @uses    $cfg
 * @access  public
 */
function PMA_showMessage($message, $sql_query = null, $type = 'notice')
{
    global $cfg;
    if (null === $sql_query) {
        if (!empty($GLOBALS['display_query'])) {
            $sql_query = $GLOBALS['display_query'];
        } elseif ($cfg['SQP']['fmtType'] == 'none' && !empty($GLOBALS['unparsed_sql'])) {
            $sql_query = $GLOBALS['unparsed_sql'];
        } elseif (!empty($GLOBALS['sql_query'])) {
            $sql_query = $GLOBALS['sql_query'];
        } else {
            $sql_query = '';
        }
    }
    // Corrects the tooltip text via JS if required
    // @todo this is REALLY the wrong place to do this - very unexpected here
    if (strlen($GLOBALS['table']) && $cfg['ShowTooltip']) {
        $tooltip = PMA_Table::sGetToolTip($GLOBALS['db'], $GLOBALS['table']);
        $uni_tbl = PMA_jsFormat($GLOBALS['db'] . '.' . $GLOBALS['table'], false);
        echo "\n";
        echo '<script type="text/javascript">' . "\n";
        echo '//<![CDATA[' . "\n";
        echo "if (window.parent.updateTableTitle) window.parent.updateTableTitle('" . $uni_tbl . "', '" . PMA_jsFormat($tooltip, false) . "');" . "\n";
        echo '//]]>' . "\n";
        echo '</script>' . "\n";
    }
    // end if ... elseif
    // Checks if the table needs to be repaired after a TRUNCATE query.
    // @todo what about $GLOBALS['display_query']???
    // @todo this is REALLY the wrong place to do this - very unexpected here
    if (strlen($GLOBALS['table']) && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
        if (PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Index_length') > 1024) {
            PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table']));
        }
    }
    unset($tbl_status);
    echo '<div align="' . $GLOBALS['cell_align_left'] . '">' . "\n";
    if ($message instanceof PMA_Message) {
        if (isset($GLOBALS['special_message'])) {
            $message->addMessage($GLOBALS['special_message']);
            unset($GLOBALS['special_message']);
        }
        $message->display();
        $type = $message->getLevel();
    } else {
        echo '<div class="' . $type . '">';
        echo PMA_sanitize($message);
        if (isset($GLOBALS['special_message'])) {
            echo PMA_sanitize($GLOBALS['special_message']);
            unset($GLOBALS['special_message']);
        }
        echo '</div>';
    }
    if ($cfg['ShowSQL'] == true && !empty($sql_query)) {
        // Html format the query to be displayed
        // If we want to show some sql code it is easiest to create it here
        /* SQL-Parser-Analyzer */
        if (!empty($GLOBALS['show_as_php'])) {
            $new_line = '\\n"<br />' . "\n" . '&nbsp;&nbsp;&nbsp;&nbsp;. "';
            $query_base = htmlspecialchars(addslashes($sql_query));
            $query_base = preg_replace('/((\\015\\012)|(\\015)|(\\012))/', $new_line, $query_base);
        } else {
            $query_base = $sql_query;
        }
        $query_too_big = false;
        if (strlen($query_base) > $cfg['MaxCharactersInDisplayedSQL']) {
            // when the query is large (for example an INSERT of binary
            // data), the parser chokes; so avoid parsing the query
            $query_too_big = true;
            $shortened_query_base = nl2br(htmlspecialchars(substr($sql_query, 0, $cfg['MaxCharactersInDisplayedSQL']) . '[...]'));
        } elseif (!empty($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) {
            // (here, use "! empty" because when deleting a bookmark,
            // $GLOBALS['parsed_sql'] is set but empty
            $parsed_sql = $GLOBALS['parsed_sql'];
        } else {
            // Parse SQL if needed
            $parsed_sql = PMA_SQP_parse($query_base);
        }
        // Analyze it
        if (isset($parsed_sql)) {
            $analyzed_display_query = PMA_SQP_analyze($parsed_sql);
            // Here we append the LIMIT added for navigation, to
            // enable its display. Adding it higher in the code
            // to $sql_query would create a problem when
            // using the Refresh or Edit links.
            // Only append it on SELECTs.
            /**
             * @todo what would be the best to do when someone hits Refresh:
             * use the current LIMITs ?
             */
            if (isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_limit_to_append'])) {
                $query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit'];
                // Need to reparse query
                $parsed_sql = PMA_SQP_parse($query_base);
            }
        }
        if (!empty($GLOBALS['show_as_php'])) {
            $query_base = '$sql  = "' . $query_base;
        } elseif (!empty($GLOBALS['validatequery'])) {
            $query_base = PMA_validateSQL($query_base);
        } elseif (isset($parsed_sql)) {
            $query_base = PMA_formatSql($parsed_sql, $query_base);
        }
        // Prepares links that may be displayed to edit/explain the query
        // (don't go to default pages, we must go to the page
        // where the query box is available)
        // Basic url query part
        $url_params = array();
        if (strlen($GLOBALS['db'])) {
            $url_params['db'] = $GLOBALS['db'];
            if (strlen($GLOBALS['table'])) {
                $url_params['table'] = $GLOBALS['table'];
                $edit_link = 'tbl_sql.php';
            } else {
                $edit_link = 'db_sql.php';
            }
        } else {
            $edit_link = 'server_sql.php';
        }
        // Want to have the query explained (Mike Beck 2002-05-22)
        // but only explain a SELECT (that has not been explained)
        /* SQL-Parser-Analyzer */
        $explain_link = '';
        if (!empty($cfg['SQLQuery']['Explain']) && !$query_too_big) {
            $explain_params = $url_params;
            // Detect if we are validating as well
            // To preserve the validate uRL data
            if (!empty($GLOBALS['validatequery'])) {
                $explain_params['validatequery'] = 1;
            }
            if (preg_match('@^SELECT[[:space:]]+@i', $sql_query)) {
                $explain_params['sql_query'] = 'EXPLAIN ' . $sql_query;
                $_message = $GLOBALS['strExplain'];
            } elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query)) {
                $explain_params['sql_query'] = substr($sql_query, 8);
                $_message = $GLOBALS['strNoExplain'];
            }
            if (isset($explain_params['sql_query'])) {
                $explain_link = 'import.php' . PMA_generate_common_url($explain_params);
                $explain_link = ' [' . PMA_linkOrButton($explain_link, $_message) . ']';
            }
        }
        //show explain
        $url_params['sql_query'] = $sql_query;
        $url_params['show_query'] = 1;
        if (!empty($cfg['SQLQuery']['Edit']) && !$query_too_big) {
            if ($cfg['EditInWindow'] == true) {
                $onclick = 'window.parent.focus_querywindow(\'' . PMA_jsFormat($sql_query, false) . '\'); return false;';
            } else {
                $onclick = '';
            }
            $edit_link .= PMA_generate_common_url($url_params) . '#querybox';
            $edit_link = ' [' . PMA_linkOrButton($edit_link, $GLOBALS['strEdit'], array('onclick' => $onclick)) . ']';
        } else {
            $edit_link = '';
        }
        $url_qpart = PMA_generate_common_url($url_params);
        // Also we would like to get the SQL formed in some nice
        // php-code (Mike Beck 2002-05-22)
        if (!empty($cfg['SQLQuery']['ShowAsPHP']) && !$query_too_big) {
            $php_params = $url_params;
            if (!empty($GLOBALS['show_as_php'])) {
                $_message = $GLOBALS['strNoPhp'];
            } else {
                $php_params['show_as_php'] = 1;
                $_message = $GLOBALS['strPhp'];
            }
            $php_link = 'import.php' . PMA_generate_common_url($php_params);
            $php_link = ' [' . PMA_linkOrButton($php_link, $_message) . ']';
            if (isset($GLOBALS['show_as_php'])) {
                $runquery_link = 'import.php' . PMA_generate_common_url($url_params);
                $php_link .= ' [' . PMA_linkOrButton($runquery_link, $GLOBALS['strRunQuery']) . ']';
            }
        } else {
            $php_link = '';
        }
        //show as php
        // Refresh query
        if (!empty($cfg['SQLQuery']['Refresh']) && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)) {
            $refresh_link = 'import.php' . PMA_generate_common_url($url_params);
            $refresh_link = ' [' . PMA_linkOrButton($refresh_link, $GLOBALS['strRefresh']) . ']';
        } else {
            $refresh_link = '';
        }
        //show as php
        if (!empty($cfg['SQLValidator']['use']) && !empty($cfg['SQLQuery']['Validate'])) {
            $validate_params = $url_params;
            if (!empty($GLOBALS['validatequery'])) {
                $validate_message = $GLOBALS['strNoValidateSQL'];
            } else {
                $validate_params['validatequery'] = 1;
                $validate_message = $GLOBALS['strValidateSQL'];
            }
            $validate_link = 'import.php' . PMA_generate_common_url($validate_params);
            $validate_link = ' [' . PMA_linkOrButton($validate_link, $validate_message) . ']';
        } else {
            $validate_link = '';
        }
        //validator
        echo '<code class="sql">';
        if ($query_too_big) {
            echo $shortened_query_base;
        } else {
            echo $query_base;
        }
        //Clean up the end of the PHP
        if (!empty($GLOBALS['show_as_php'])) {
            echo '";';
        }
        echo '</code>';
        echo '<div class="tools">';
        // avoid displaying a Profiling checkbox that could
        // be checked, which would reexecute an INSERT, for example
        if (!empty($refresh_link)) {
            PMA_profilingCheckbox($sql_query);
        }
        echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link;
        echo '</div>';
    }
    echo '</div><br />' . "\n";
}
コード例 #8
0
    echo sprintf('<tr>
                      <th>%s</th>
                      <th>&nbsp;</th>
                      <th>&nbsp;</th>
                      <th>%s</th>
                </tr>', __('Name'), __('Type'));
    $ct = 0;
    $delimiter = '//';
    if ($GLOBALS['cfg']['AjaxEnable']) {
        $conditional_class = 'class="drop_event_anchor"';
    } else {
        $conditional_class = '';
    }
    foreach ($events as $event) {
        // information_schema (at least in MySQL 5.1.22) does not return
        // the full CREATE EVENT statement in a way that could be useful for us
        // so we rely on PMA_DBI_get_definition() which uses SHOW CREATE EVENT
        $definition = 'DROP EVENT ' . PMA_backquote($event['EVENT_NAME']) . $delimiter . "\n" . PMA_DBI_get_definition($db, 'EVENT', $event['EVENT_NAME']) . "\n";
        $sqlDrop = 'DROP EVENT ' . PMA_backquote($event['EVENT_NAME']);
        echo sprintf('<tr class="%s">
                          <td><strong>%s</strong></td>
                          <td>%s</td>
                          <td>%s</td>
                          <td>%s</td>
                     </tr>', $ct % 2 == 0 ? 'even' : 'odd', $event['EVENT_NAME'], !empty($definition) ? PMA_linkOrButton('db_sql.php?' . $url_query . '&amp;sql_query=' . urlencode($definition) . '&amp;show_query=1&amp;db_query_force=1&amp;delimiter=' . urlencode($delimiter), $titles['Structure']) : '&nbsp;', '<a ' . $conditional_class . ' href="sql.php?' . $url_query . '&amp;sql_query=' . urlencode($sqlDrop) . '" >' . $titles['Drop'] . '</a>', $event['EVENT_TYPE']);
        $ct++;
    }
    echo '</table>';
    echo '</fieldset>' . "\n";
    echo '</div>' . "\n";
}
コード例 #9
0
    if (!empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'ARIA' || $tbl_type == 'MARIA')) {
        PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', __('Fulltext'), 'b_ftext.png', 'ftext');
    }
}
?>
</form>
<hr />

<?php 
/**
 * Work on the table
 */
if ($tbl_is_view) {
    $create_view = PMA_DBI_get_definition($db, 'VIEW', $table);
    $create_view = preg_replace('@^CREATE@', 'ALTER', $create_view);
    echo PMA_linkOrButton('tbl_sql.php' . PMA_generate_common_url($url_params + array('sql_query' => $create_view, 'show_query' => '1')), PMA_getIcon('b_edit.png', __('Edit view'), true));
}
?>

<a href="tbl_printview.php?<?php 
echo $url_query;
?>
"><?php 
echo PMA_getIcon('b_print.png', __('Print view'), true);
?>
</a>

<?php 
if (!$tbl_is_view && !$db_is_information_schema) {
    // if internal relations are available, or foreign keys are supported
    // ($tbl_type comes from libraries/tbl_info.inc.php)
コード例 #10
0
           . PMA_linkOrButton($edit_url, $edit_str, '', FALSE)
           . $bookmark_go
           . '    </td>' . "\n";
    }
    if (!empty($del_url)) {
        echo '    <td align="center">' . "\n"
           . PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), FALSE)
           . '    </td>' . "\n";
    }
} elseif ($doWriteModifyAt == 'right') {
    if (!empty($del_url)) {
        echo '    <td align="center">' . "\n"
           . PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), FALSE)
           . '    </td>' . "\n";
    }
    if (!empty($edit_url)) {
        echo '    <td align="center">' . "\n"
           . PMA_linkOrButton($edit_url, $edit_str, '', FALSE)
           . $bookmark_go
           . '    </td>' . "\n";
    }
    if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
        echo '    <td align="center">' . "\n"
           . '        <input type="checkbox" id="id_rows_to_delete' . $row_no . 'r" name="rows_to_delete[' . $where_clause_html . ']"'
           . ' onclick="copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'r\');"'
           . ' value="' . htmlspecialchars($del_query) . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n"
           . '    </td>' . "\n";
    }
}
?>
コード例 #11
0
    echo '<div id="tabletriggers">' . "\n";
    echo '<table class="data">' . "\n";
    echo ' <caption class="tblHeaders">' . __('Triggers') . '</caption>' . "\n";
    echo sprintf('<tr>
                          <th>%s</th>
                          <th>&nbsp;</th>
                          <th>&nbsp;</th>
                          <th>%s</th>
                          <th>%s</th>
                    </tr>', __('Name'), __('Time'), __('Event'));
    $ct = 0;
    $delimiter = '//';
    if ($GLOBALS['cfg']['AjaxEnable']) {
        $conditional_class = 'class="drop_trigger_anchor"';
    } else {
        $conditional_class = '';
    }
    foreach ($triggers as $trigger) {
        $drop_and_create = $trigger['drop'] . $delimiter . "\n" . $trigger['create'] . "\n";
        echo sprintf('<tr class="noclick %s">
                              <td><strong>%s</strong></td>
                              <td>%s</td>
                              <td>%s</td>
                              <td>%s</td>
                              <td>%s</td>
                         </tr>', $ct % 2 == 0 ? 'even' : 'odd', $trigger['name'], PMA_linkOrButton('tbl_sql.php?' . $url_query . '&amp;sql_query=' . urlencode($drop_and_create) . '&amp;show_query=1&amp;delimiter=' . urlencode($delimiter), $titles['Change']), '<a ' . $conditional_class . ' href="sql.php?' . $url_query . '&sql_query=' . urlencode($trigger['drop']) . '" >' . $titles['Drop'] . '</a>', $trigger['action_timing'], $trigger['event_manipulation']);
        $ct++;
    }
    echo '</table>';
    echo '</div>' . "\n";
}
コード例 #12
0
/**
 * Displays a table of results returned by a sql query.
 * This function is called by the "sql.php" script.
 *
 * @param   integer the link id associated to the query which results have
 *                  to be displayed
 * @param   array   the display mode
 * @param   array   the analyzed query
 *
 * @global  string   $db                the database name
 * @global  string   $table             the table name
 * @global  string   $goto              the url to go back in case of errors
 * @global  boolean  $dontlimitchars    whether to limit the number of displayed
 *                                      characters of text type fields or not
 * @global  string   $sql_query         the current sql query
 * @global  integer  $num_rows          the total number of rows returned by the
 *                                      sql query
 * @global  integer  $unlim_num_rows    the total number of rows returned by the
 *                                      sql query without any programmatically
 *                                      appended "LIMIT" clause
 * @global  integer  $pos               the current postion of the first record
 *                                      to be displayed
 * @global  array    $fields_meta       the list of fields properties
 * @global  integer  $fields_cnt        the total number of fields returned by
 *                                      the sql query
 * @global  array    $vertical_display  informations used with vertical display
 *                                      mode
 * @global  string   $disp_direction    the display mode
 *                                      (horizontal/vertical/horizontalflipped)
 * @global  integer  $repeat_cells      the number of row to display between two
 *                                      table headers
 * @global  array    $highlight_columns collumn names to highlight
 * @global  array    $cfgRelation       the relation settings
 *
 * @access  private
 *
 * @see     PMA_showMessage(), PMA_setDisplayMode(),
 *          PMA_displayTableNavigation(), PMA_displayTableHeaders(),
 *          PMA_displayTableBody()
 */
function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
{
    global $db, $table, $goto, $dontlimitchars;
    global $sql_query, $num_rows, $unlim_num_rows, $pos, $fields_meta, $fields_cnt;
    global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
    global $cfgRelation;
    // 1. ----- Prepares the work -----
    // 1.1 Gets the informations about which functionnalities should be
    //     displayed
    $total = '';
    $is_display = PMA_setDisplayMode($the_disp_mode, $total);
    if ($total == '') {
        unset($total);
    }
    // 1.2 Defines offsets for the next and previous pages
    if ($is_display['nav_bar'] == '1') {
        if (!isset($pos)) {
            $pos = 0;
        }
        if ($GLOBALS['session_max_rows'] == 'all') {
            $pos_next = 0;
            $pos_prev = 0;
        } else {
            $pos_next = $pos + $GLOBALS['cfg']['MaxRows'];
            $pos_prev = $pos - $GLOBALS['cfg']['MaxRows'];
            if ($pos_prev < 0) {
                $pos_prev = 0;
            }
        }
    }
    // end if
    // 1.3 Urlencodes the query to use in input form fields
    $encoded_sql_query = urlencode($sql_query);
    // 2. ----- Displays the top of the page -----
    // 2.1 Displays a messages with position informations
    if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
        if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
            $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
        } else {
            $selectstring = '';
        }
        $last_shown_rec = $GLOBALS['session_max_rows'] == 'all' || $pos_next > $total ? $total - 1 : $pos_next - 1;
        PMA_showMessage($GLOBALS['strShowingRecords'] . " {$pos} - {$last_shown_rec} (" . PMA_formatNumber($total, 0) . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
    } else {
        if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
            PMA_showMessage($GLOBALS['strSQLQuery']);
        }
    }
    // 2.3 Displays the navigation bars
    if (!isset($table) || strlen(trim($table)) == 0) {
        if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == 'SELECT') {
            // table does not always contain a real table name,
            // for example in MySQL 5.0.x, the query SHOW STATUS
            // returns STATUS as a table name
            $table = $fields_meta[0]->table;
        } else {
            $table = '';
        }
    }
    if ($is_display['nav_bar'] == '1') {
        PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
        echo "\n";
    } else {
        if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
            echo "\n" . '<br /><br />' . "\n";
        }
    }
    // 2b ----- Get field references from Database -----
    // (see the 'relation' config variable)
    // loic1, 2002-03-02: extended to php3
    // init map
    $map = array();
    // find tables
    $target = array();
    if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
        foreach ($analyzed_sql[0]['table_ref'] as $table_ref_position => $table_ref) {
            $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
        }
    }
    $tabs = '(\'' . join('\',\'', $target) . '\')';
    if ($cfgRelation['displaywork']) {
        if (empty($table)) {
            $exist_rel = FALSE;
        } else {
            $exist_rel = PMA_getForeigners($db, $table, '', 'both');
            if ($exist_rel) {
                foreach ($exist_rel as $master_field => $rel) {
                    $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
                    $map[$master_field] = array($rel['foreign_table'], $rel['foreign_field'], $display_field, $rel['foreign_db']);
                }
                // end while
            }
            // end if
        }
        // end if
    }
    // end if
    // end 2b
    // 3. ----- Displays the results table -----
    PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql);
    $url_query = '';
    echo '<tbody>' . "\n";
    PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
    echo '</tbody>' . "\n";
    // vertical output case
    if ($disp_direction == 'vertical') {
        PMA_displayVerticalTable();
    }
    // end if
    unset($vertical_display);
    ?>
</table>

    <?php 
    // 4. ----- Displays the link for multi-fields delete
    if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') {
        $delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill'];
        $uncheckall_url = 'sql.php?' . PMA_generate_common_url($db, $table) . '&amp;sql_query=' . urlencode($sql_query) . '&amp;pos=' . $pos . '&amp;session_max_rows=' . $GLOBALS['session_max_rows'] . '&amp;pos=' . $pos . '&amp;disp_direction=' . $disp_direction . '&amp;repeat_cells=' . $repeat_cells . '&amp;goto=' . $goto . '&amp;dontlimitchars=' . $dontlimitchars;
        $checkall_url = $uncheckall_url . '&amp;checkall=1';
        if ($disp_direction == 'vertical') {
            $checkall_params['onclick'] = 'if ( setCheckboxes(\'rowsDeleteForm\', true) ) return false;';
            $uncheckall_params['onclick'] = 'if ( setCheckboxes(\'rowsDeleteForm\', false) ) return false;';
        } else {
            $checkall_params['onclick'] = 'if ( markAllRows(\'rowsDeleteForm\') ) return false;';
            $uncheckall_params['onclick'] = 'if ( unMarkAllRows(\'rowsDeleteForm\') ) return false;';
        }
        $checkall_link = PMA_linkOrButton($checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false);
        $uncheckall_link = PMA_linkOrButton($uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false);
        if ($disp_direction != 'vertical') {
            echo '<img class="selectallarrow" width="38" height="22"' . ' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"' . ' alt="' . $GLOBALS['strWithChecked'] . '" />';
        }
        echo $checkall_link . "\n" . ' / ' . "\n" . $uncheckall_link . "\n" . '<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n";
        if ($GLOBALS['cfg']['PropertiesIconic']) {
            PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png');
            PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_delete', $delete_text, 'b_drop.png');
            if ($analyzed_sql[0]['querytype'] == 'SELECT') {
                PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', $GLOBALS['strExport'], 'b_tblexport.png');
            }
            echo "\n";
        } else {
            echo ' <input type="submit" name="submit_mult"' . ' value="' . htmlspecialchars($GLOBALS['strEdit']) . '"' . ' title="' . $GLOBALS['strEdit'] . '" />' . "\n";
            echo ' <input type="submit" name="submit_mult"' . ' value="' . htmlspecialchars($delete_text) . '"' . ' title="' . $delete_text . '" />' . "\n";
            if ($analyzed_sql[0]['querytype'] == 'SELECT') {
                echo ' <input type="submit" name="submit_mult"' . ' value="' . htmlspecialchars($GLOBALS['strExport']) . '"' . ' title="' . $GLOBALS['strExport'] . '" />' . "\n";
            }
        }
        echo '<input type="hidden" name="sql_query"' . ' value="' . htmlspecialchars($sql_query) . '" />' . "\n";
        echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
        echo '<input type="hidden" name="url_query"' . ' value="' . $GLOBALS['url_query'] . '" />' . "\n";
        echo '</form>' . "\n";
    }
    // 5. ----- Displays the navigation bar at the bottom if required -----
    if ($is_display['nav_bar'] == '1') {
        echo '<br />' . "\n";
        PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
    } else {
        if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
            echo "\n" . '<br /><br />' . "\n";
        }
    }
}
コード例 #13
0
ファイル: sql.php プロジェクト: mike503/phpmyadmin
            // end displays "printable view"
            echo "\n";
        }
        // Export link
        // (the url_query has extra parameters that won't be used to export)
        // (the single_table parameter is used in display_export.lib.php
        //  to hide the SQL and the structure export dialogs)
        if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT' && !isset($printview)) {
            if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
                $single_table = '&amp;single_table=true';
            } else {
                $single_table = '';
            }
            echo '    <!-- Export -->' . "\n";
            echo '    &nbsp;&nbsp;' . "\n";
            echo PMA_linkOrButton('tbl_properties_export.php' . $url_query . '&amp;unlim_num_rows=' . $unlim_num_rows . $single_table, ($cfg['PropertiesIconic'] ? '<img src="' . $pmaThemeImage . 'b_tblexport.png" border="0" height="16" width="16" align="middle" hspace="2" alt="' . $strExport . '" />' : '') . $strExport, '', TRUE, TRUE, '') . "\n";
        }
        // Bookmark Support if required
        if ($disp_mode[7] == '1' && ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark)) && !empty($sql_query)) {
            echo "\n";
            $goto = 'sql.php?' . PMA_generate_common_url($db, $table) . '&amp;pos=' . $pos . '&amp;session_max_rows=' . $session_max_rows . '&amp;disp_direction=' . $disp_direction . '&amp;repeat_cells=' . $repeat_cells . '&amp;dontlimitchars=' . $dontlimitchars . '&amp;sql_query=' . urlencode($sql_query) . '&amp;id_bookmark=1';
            ?>
<!-- Bookmark the query -->
            <?php 
            echo "\n";
            if ($disp_mode[3] == '1') {
                echo '    <i>' . $strOr . '</i>' . "\n";
            } else {
                echo '<br /><br />';
            }
            ?>
コード例 #14
0
    $delimiter = '//';
    foreach ($events as $event) {

        // information_schema (at least in MySQL 5.1.22) does not return
        // the full CREATE EVENT statement in a way that could be useful for us
        // so we rely on PMA_DBI_get_definition() which uses SHOW CREATE EVENT

        $definition = 'DROP EVENT ' . PMA_backquote($event['EVENT_NAME']) . $delimiter . "\n"
            .  PMA_DBI_get_definition($db, 'EVENT', $event['EVENT_NAME'])
            . "\n";

        $sqlDrop = 'DROP EVENT ' . PMA_backquote($event['EVENT_NAME']);
        echo sprintf('<tr class="%s">
                          <td><strong>%s</strong></td>
                          <td>%s</td>
                          <td>%s</td>
                          <td>%s</td>
                     </tr>',
                     ($ct%2 == 0) ? 'even' : 'odd',
                     $event['EVENT_NAME'],
                     ! empty($definition) ? PMA_linkOrButton('db_sql.php?' . $url_query . '&amp;sql_query=' . urlencode($definition) . '&amp;show_query=1&amp;delimiter=' . urlencode($delimiter), $titles['Structure']) : '&nbsp;',
                     '<a href="sql.php?' . $url_query . '&sql_query=' . urlencode($sqlDrop) . '" onclick="return confirmLink(this, \'' . PMA_jsFormat($sqlDrop, false) . '\')">' . $titles['Drop'] . '</a>',
                     $event['EVENT_TYPE']);
        $ct++;
    }
    echo '</table>';
    echo '</fieldset>' . "\n";
    echo '</div>' . "\n";
}
?>
コード例 #15
0
/* $Id: display_tbl_links.lib.php,v 1.1 2005/02/03 06:03:51 nuhpardon Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
// modified 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
// - bugfix for select all checkboxes
// - copy right to left (or left to right) if user click on a check box
// - reversed the right modify links: 1. drop, 2. edit, 3. checkbox
// - also changes made in libraries/functions.js
if ($doWriteModifyAt == 'left') {
    if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
        echo '    <td width="16" align="center" valign="top" bgcolor="' . $bgcolor . '">' . "\n" . '        <input type="checkbox" id="id_rows_to_delete' . $row_no . '" name="rows_to_delete[' . $uva_condition . ']"' . ' onclick="copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'l\');"' . ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n" . '    </td>' . "\n";
    }
    if (!empty($edit_url)) {
        echo '    <td width="16" align="center" valign="top" bgcolor="' . $bgcolor . '">' . "\n" . PMA_linkOrButton($edit_url, $edit_str, '', FALSE) . $bookmark_go . '    </td>' . "\n";
    }
    if (!empty($del_url)) {
        echo '    <td width="16" align="center" valign="top" bgcolor="' . $bgcolor . '">' . "\n" . PMA_linkOrButton($del_url, $del_str, isset($js_conf) ? $js_conf : '', FALSE) . '    </td>' . "\n";
    }
} else {
    if ($doWriteModifyAt == 'right') {
        if (!empty($del_url)) {
            echo '    <td width="16" align="center" valign="top" bgcolor="' . $bgcolor . '">' . "\n" . PMA_linkOrButton($del_url, $del_str, isset($js_conf) ? $js_conf : '', FALSE) . '    </td>' . "\n";
        }
        if (!empty($edit_url)) {
            echo '    <td width="16" align="center" valign="top" bgcolor="' . $bgcolor . '">' . "\n" . PMA_linkOrButton($edit_url, $edit_str, '', FALSE) . $bookmark_go . '    </td>' . "\n";
        }
        if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
            echo '    <td width="16" align="center" valign="top" bgcolor="' . $bgcolor . '">' . "\n" . '        <input type="checkbox" id="id_rows_to_delete' . $row_no . 'r" name="rows_to_delete[' . $uva_condition . ']"' . ' onclick="copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'r\');"' . ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n" . '    </td>' . "\n";
        }
    }
}
コード例 #16
0
                if ($field['pma_type'] == 'date' || $field['pma_type'] == 'datetime' || substr($field['pma_type'], 0, 9) == 'timestamp') {
                    // the _3 suffix points to the date field
                    // the _2 suffix points to the corresponding NULL checkbox
                    // in dateFormat, 'yy' means the year with 4 digits
                }
            }
        }
        if (in_array($field['pma_type'], $gis_data_types)) {
            $data_val = isset($vrow[$field['Field']]) ? $vrow[$field['Field']] : '';
            $_url_params = array('field' => $field['Field_title'], 'value' => $data_val);
            if ($field['pma_type'] != 'geometry') {
                $_url_params = $_url_params + array('gis_data[gis_type]' => strtoupper($field['pma_type']));
            }
            $edit_str = PMA_getIcon('b_edit.png', __('Edit/Insert'));
            echo '<span class="open_gis_editor">';
            echo PMA_linkOrButton('#', $edit_str, array(), false, false, '_blank');
            echo '</span>';
        }
        ?>
            </td>
        </tr>
        <?php 
        $odd_row = !$odd_row;
    }
    // end for
    $o_rows++;
    echo '  </tbody></table><br />';
}
// end foreach on multi-edit
?>
    <div id="gis_editor"></div><div id="popup_background"></div>
コード例 #17
0
<?php

/* $Id: display_tbl_links.lib.php,v 2.6 2004/01/07 18:11:29 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
    echo '    <td width="10" align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n" . '        <input type="checkbox" id="id_rows_to_delete' . $row_no . '" name="rows_to_delete[' . $uva_condition . ']" value="' . $del_query . '" />' . "\n" . '    </td>' . "\n";
}
if (!empty($edit_url)) {
    echo '    <td width="10" align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n" . PMA_linkOrButton($edit_url, $edit_str, '') . $bookmark_go . '    </td>' . "\n";
}
if (!empty($del_url)) {
    echo '    <td width="10" align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n" . PMA_linkOrButton($del_url, $del_str, isset($js_conf) ? $js_conf : '') . '    </td>' . "\n";
}
コード例 #18
0
    exit;
}
$url_query .= '&amp;goto=tbl_structure.php';
$triggers = PMA_DBI_get_triggers($db, $table);
if ($triggers) {
    echo '<div id="tabletriggers">' . "\n";
    echo '<table class="data">' . "\n";
    echo ' <caption class="tblHeaders">' . $strTriggers . '</caption>' . "\n";
    echo sprintf('<tr>
                          <th>%s</th>
                          <th>&nbsp;</th>
                          <th>&nbsp;</th>
                          <th>%s</th>
                          <th>%s</th>
                    </tr>', $strName, $strTime, $strEvent);
    $ct = 0;
    $delimiter = '//';
    foreach ($triggers as $trigger) {
        $drop_and_create = $trigger['drop'] . $delimiter . "\n" . $trigger['create'] . "\n";
        echo sprintf('<tr class="%s">
                              <td><strong>%s</strong></td>
                              <td>%s</td>
                              <td>%s</td>
                              <td>%s</td>
                              <td>%s</td>
                         </tr>', $ct % 2 == 0 ? 'even' : 'odd', $trigger['name'], PMA_linkOrButton('tbl_sql.php?' . $url_query . '&amp;sql_query=' . urlencode($drop_and_create) . '&amp;show_query=1&amp;delimiter=' . urlencode($delimiter), $titles['Change']), '<a href="sql.php?' . $url_query . '&sql_query=' . urlencode($trigger['drop']) . '" onclick="return confirmLink(this, \'' . PMA_jsFormat($trigger['drop'], false) . '\')">' . $titles['Drop'] . '</a>', $trigger['action_timing'], $trigger['event_manipulation']);
        $ct++;
    }
    echo '</table>';
    echo '</div>' . "\n";
}
コード例 #19
0
ファイル: tbl_select.lib.php プロジェクト: tolsasha/Forum_PO
/**
 * Creates the HTML content for:
 * 1) Browsing foreign data for a field.
 * 2) Creating elements for search criteria input on fields.
 *
 * @param array  $foreigners      Array of foreign keys
 * @param array  $foreignData     Foreign keys data
 * @param string $field           Column name
 * @param string $tbl_fields_type Column type
 * @param int    $i               Column index
 * @param string $db              Selected database
 * @param string $table           Selected table
 * @param array  $titles          Selected title
 * @param int    $foreignMaxLimit Max limit of displaying foreign elements
 * @param array  $fields          Array of search criteria inputs
 * @param bool   $in_fbs          Whether we are in 'function based search'
 * @param bool   $in_zoom_search_edit  Whether we are in zoom search edit 
 *
 * @return string HTML content for viewing foreing data and elements
 * for search criteria input.
 */
function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i, $db, $table, $titles, $foreignMaxLimit, $fields, $in_fbs = false, $in_zoom_search_edit = false)
{
    $str = '';
    if ($foreigners && isset($foreigners[$field]) && is_array($foreignData['disp_row'])) {
        // f o r e i g n    k e y s
        $str .= '<select name="fields[' . $i . ']" id="fieldID_' . $i . '">' . "\n";
        // go back to first row
        // here, the 4th parameter is empty because there is no current
        // value of data for the dropdown (the search page initial values
        // are displayed empty)
        $str .= PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], '', $foreignMaxLimit);
        $str .= '</select>' . "\n";
    } elseif ($foreignData['foreign_link'] == true) {
        if (isset($fields[$i]) && is_string($fields[$i])) {
            $str .= '<input type="text" id="fieldID_' . $i . '" name="fields[' . $i . ']" value="' . $fields[$i] . '" id="field_' . md5($field) . '[' . $i . ']" class="textfield" />';
        } else {
            $str .= '<input type="text" id="fieldID_' . $i . '" name="fields[' . $i . ']" id="field_' . md5($field) . '[' . $i . ']" class="textfield" />';
        }
        $str .= <<<EOT
<a target="_blank" onclick="window.open(this.href, 'foreigners', 'width=640,height=240,scrollbars=yes'); return false" href="browse_foreigners.php?
EOT;
        $str .= '' . PMA_generate_common_url($db, $table) . '&amp;field=' . urlencode($field) . '&amp;fieldkey=' . $i . '"';
        if ($in_zoom_search_edit) {
            $str .= ' class="browse_foreign"';
        }
        $str .= '>' . str_replace("'", "\\'", $titles['Browse']) . '</a>';
    } elseif (in_array($tbl_fields_type[$i], PMA_getGISDatatypes())) {
        // g e o m e t r y
        $str .= '<input type="text" name="fields[' . $i . ']"' . ' size="40" class="textfield" id="field_' . $i . '" />' . "\n";
        if ($in_fbs) {
            $edit_url = 'gis_data_editor.php?' . PMA_generate_common_url();
            $edit_str = PMA_getIcon('b_edit.png', __('Edit/Insert'));
            $str .= '<span class="open_search_gis_editor">';
            $str .= PMA_linkOrButton($edit_url, $edit_str, array(), false, false, '_blank');
            $str .= '</span>';
        }
    } elseif (strncasecmp($tbl_fields_type[$i], 'enum', 4) == 0 || strncasecmp($tbl_fields_type[$i], 'set', 3) == 0 && $in_zoom_search_edit) {
        // e n u m s   a n d   s e t s
        // Enum in edit mode   --> dropdown
        // Enum in search mode --> multiselect
        // Set in edit mode    --> multiselect
        // Set in search mode  --> input (skipped here, so the 'else'
        //                                 section would handle it)
        $value = explode(', ', str_replace("'", '', substr($tbl_fields_type[$i], 5, -1)));
        $cnt_value = count($value);
        if (strncasecmp($tbl_fields_type[$i], 'enum', 4) && !$in_zoom_search_edit || strncasecmp($tbl_fields_type[$i], 'set', 3) && $in_zoom_search_edit) {
            $str .= '<select name="fields[' . $i . '][]" id="fieldID_' . $i . '">' . "\n";
        } else {
            $str .= '<select name="fields[' . $i . '][]" id="fieldID_' . $i . '"' . ' multiple="multiple" size="' . min(3, $cnt_value) . '">' . "\n";
        }
        for ($j = 0; $j < $cnt_value; $j++) {
            if (isset($fields[$i]) && is_array($fields[$i]) && in_array($value[$j], $fields[$i])) {
                $str .= '<option value="' . $value[$j] . '" Selected>' . $value[$j] . '</option>';
            } else {
                $str .= '<option value="' . $value[$j] . '">' . $value[$j] . '</option>';
            }
        }
        // end for
        $str .= '</select>' . "\n";
    } else {
        // o t h e r   c a s e s
        $the_class = 'textfield';
        $type = $tbl_fields_type[$i];
        if ($type == 'date') {
            $the_class .= ' datefield';
        } elseif ($type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
            $the_class .= ' datetimefield';
        } elseif (substr($type, 0, 3) == 'bit') {
            $the_class .= ' bit';
        }
        if (isset($fields[$i]) && is_string($fields[$i])) {
            $str .= '<input type="text" name="fields[' . $i . ']"' . ' size="40" class="' . $the_class . '" id="fieldID_' . $i . '" value = "' . $fields[$i] . '"/>' . "\n";
        } else {
            $str .= '<input type="text" name="fields[' . $i . ']"' . ' size="40" class="' . $the_class . '" id="fieldID_' . $i . '" />' . "\n";
        }
    }
    return $str;
}
コード例 #20
0
/**
 * Creates a clickable column header for table information
 *
 * @param string $title              title to use for the link
 * @param string $sort               corresponds to sortable data name mapped in libraries/db_info.inc.php
 * @param string $initial_sort_order initial sort order
 *
 * @return string link to be displayed in the table header
 */
function PMA_SortableTableHeader($title, $sort, $initial_sort_order = 'ASC')
{
    // Set some defaults
    $requested_sort = 'table';
    $requested_sort_order = $future_sort_order = $initial_sort_order;
    // If the user requested a sort
    if (isset($_REQUEST['sort'])) {
        $requested_sort = $_REQUEST['sort'];
        if (isset($_REQUEST['sort_order'])) {
            $requested_sort_order = $_REQUEST['sort_order'];
        }
    }
    $order_img = '';
    $order_link_params = array();
    $order_link_params['title'] = __('Sort');
    // If this column was requested to be sorted.
    if ($requested_sort == $sort) {
        if ($requested_sort_order == 'ASC') {
            $future_sort_order = 'DESC';
            // current sort order is ASC
            $order_img = ' ' . PMA_getImage('s_asc.png', __('Ascending'), array('class' => 'sort_arrow', 'title' => ''));
            $order_img .= ' ' . PMA_getImage('s_desc.png', __('Descending'), array('class' => 'sort_arrow hide', 'title' => ''));
            // but on mouse over, show the reverse order (DESC)
            $order_link_params['onmouseover'] = "\$('.sort_arrow').toggle();";
            // on mouse out, show current sort order (ASC)
            $order_link_params['onmouseout'] = "\$('.sort_arrow').toggle();";
        } else {
            $future_sort_order = 'ASC';
            // current sort order is DESC
            $order_img = ' ' . PMA_getImage('s_asc.png', __('Ascending'), array('class' => 'sort_arrow hide', 'title' => ''));
            $order_img .= ' ' . PMA_getImage('s_desc.png', __('Descending'), array('class' => 'sort_arrow', 'title' => ''));
            // but on mouse over, show the reverse order (ASC)
            $order_link_params['onmouseover'] = "\$('.sort_arrow').toggle();";
            // on mouse out, show current sort order (DESC)
            $order_link_params['onmouseout'] = "\$('.sort_arrow').toggle();";
        }
    }
    $_url_params = array('db' => $_REQUEST['db']);
    $url = 'db_structure.php' . PMA_generate_common_url($_url_params);
    // We set the position back to 0 every time they sort.
    $url .= "&amp;pos=0&amp;sort={$sort}&amp;sort_order={$future_sort_order}";
    return PMA_linkOrButton($url, $title . $order_img, $order_link_params);
}
コード例 #21
0
 * - also changes made in js/functions.js
 *
 * @version $Id$
 */
if (!defined('PHPMYADMIN')) {
    exit;
}
/**
 *
 */
if ($doWriteModifyAt == 'left') {
    if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
        echo '    <td align="center">' . "\n" . '        <input type="checkbox" id="id_rows_to_delete' . $row_no . '" name="rows_to_delete[' . $unique_condition . ']"' . ' onclick="copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'l\');"' . ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n" . '    </td>' . "\n";
    }
    if (!empty($edit_url)) {
        echo '    <td align="center">' . "\n" . PMA_linkOrButton($edit_url, $edit_str, '', FALSE) . $bookmark_go . '    </td>' . "\n";
    }
    if (!empty($del_url)) {
        echo '    <td align="center">' . "\n" . PMA_linkOrButton($del_url, $del_str, isset($js_conf) ? $js_conf : '', FALSE) . '    </td>' . "\n";
    }
} elseif ($doWriteModifyAt == 'right') {
    if (!empty($del_url)) {
        echo '    <td align="center">' . "\n" . PMA_linkOrButton($del_url, $del_str, isset($js_conf) ? $js_conf : '', FALSE) . '    </td>' . "\n";
    }
    if (!empty($edit_url)) {
        echo '    <td align="center">' . "\n" . PMA_linkOrButton($edit_url, $edit_str, '', FALSE) . $bookmark_go . '    </td>' . "\n";
    }
    if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
        echo '    <td align="center">' . "\n" . '        <input type="checkbox" id="id_rows_to_delete' . $row_no . 'r" name="rows_to_delete[' . $unique_condition . ']"' . ' onclick="copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'r\');"' . ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n" . '    </td>' . "\n";
    }
}
コード例 #22
0
ファイル: common.lib.php プロジェクト: a195474368/ejiawang
    /**
     * Displays a message at the top of the "main" (right) frame
     *
     * @param   string  the message to display
     *
     * @global  array   the configuration array
     *
     * @access  public
     */
    function PMA_showMessage($message)
    {
        global $cfg;
        // Sanitizes $message
        $message = PMA_sanitize($message);
        // Corrects the tooltip text via JS if required
        if (isset($GLOBALS['table']) && strlen($GLOBALS['table']) && $cfg['ShowTooltip']) {
            $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');
            if ($result) {
                $tbl_status = PMA_DBI_fetch_assoc($result);
                $tooltip = empty($tbl_status['Comment']) ? '' : $tbl_status['Comment'] . ' ';
                $tooltip .= '(' . PMA_formatNumber($tbl_status['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')';
                PMA_DBI_free_result($result);
                $uni_tbl = PMA_jsFormat($GLOBALS['db'] . '.' . $GLOBALS['table'], false);
                echo "\n";
                ?>
<script type="text/javascript" language="javascript">
//<![CDATA[
window.parent.updateTableTitle('<?php 
                echo $uni_tbl;
                ?>
', '<?php 
                echo PMA_jsFormat($tooltip, false);
                ?>
');
//]]>
</script>
                <?php 
            }
            // end if
        }
        // end if ... elseif
        // Checks if the table needs to be repaired after a TRUNCATE query.
        if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query']) && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
            if (!isset($tbl_status)) {
                $result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');
                if ($result) {
                    $tbl_status = PMA_DBI_fetch_assoc($result);
                    PMA_DBI_free_result($result);
                }
            }
            if (isset($tbl_status) && (int) $tbl_status['Index_length'] > 1024) {
                PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table']));
            }
        }
        unset($tbl_status);
        ?>
<br />
<div align="<?php 
        echo $GLOBALS['cell_align_left'];
        ?>
">
        <?php 
        if (!empty($GLOBALS['show_error_header'])) {
            ?>
    <div class="error">
        <h1><?php 
            echo $GLOBALS['strError'];
            ?>
</h1>
            <?php 
        }
        echo $message;
        if (isset($GLOBALS['special_message'])) {
            echo PMA_sanitize($GLOBALS['special_message']);
            unset($GLOBALS['special_message']);
        }
        if (!empty($GLOBALS['show_error_header'])) {
            echo '</div>';
        }
        if ($cfg['ShowSQL'] == true && (!empty($GLOBALS['sql_query']) || !empty($GLOBALS['display_query']))) {
            $local_query = !empty($GLOBALS['display_query']) ? $GLOBALS['display_query'] : ($cfg['SQP']['fmtType'] == 'none' && isset($GLOBALS['unparsed_sql']) && $GLOBALS['unparsed_sql'] != '' ? $GLOBALS['unparsed_sql'] : $GLOBALS['sql_query']);
            // Basic url query part
            $url_qpart = '?' . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : '');
            // Html format the query to be displayed
            // The nl2br function isn't used because its result isn't a valid
            // xhtml1.0 statement before php4.0.5 ("<br>" and not "<br />")
            // If we want to show some sql code it is easiest to create it here
            /* SQL-Parser-Analyzer */
            if (!empty($GLOBALS['show_as_php'])) {
                $new_line = '\'<br />' . "\n" . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. \' ';
            }
            if (isset($new_line)) {
                /* SQL-Parser-Analyzer */
                $query_base = PMA_sqlAddslashes(htmlspecialchars($local_query), false, false, true);
                /* SQL-Parser-Analyzer */
                $query_base = preg_replace("@((\r\n)|(\r)|(\n))+@", $new_line, $query_base);
            } else {
                $query_base = $local_query;
            }
            // Parse SQL if needed
            if (isset($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) {
                $parsed_sql = $GLOBALS['parsed_sql'];
            } else {
                // when the query is large (for example an INSERT of binary
                // data), the parser chokes; so avoid parsing the query
                if (strlen($query_base) < 1000) {
                    $parsed_sql = PMA_SQP_parse($query_base);
                }
            }
            // Analyze it
            if (isset($parsed_sql)) {
                $analyzed_display_query = PMA_SQP_analyze($parsed_sql);
            }
            // Here we append the LIMIT added for navigation, to
            // enable its display. Adding it higher in the code
            // to $local_query would create a problem when
            // using the Refresh or Edit links.
            // Only append it on SELECTs.
            // FIXME: what would be the best to do when someone
            // hits Refresh: use the current LIMITs ?
            if (isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_limit_to_append'])) {
                $query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit'];
                // Need to reparse query
                $parsed_sql = PMA_SQP_parse($query_base);
            }
            if (!empty($GLOBALS['show_as_php'])) {
                $query_base = '$sql  = \'' . $query_base;
            } elseif (!empty($GLOBALS['validatequery'])) {
                $query_base = PMA_validateSQL($query_base);
            } else {
                if (isset($parsed_sql)) {
                    $query_base = PMA_formatSql($parsed_sql, $query_base);
                }
            }
            // Prepares links that may be displayed to edit/explain the query
            // (don't go to default pages, we must go to the page
            // where the query box is available)
            // (also, I don't see why we should check the goto variable)
            //if (!isset($GLOBALS['goto'])) {
            //$edit_target = (isset($GLOBALS['table'])) ? $cfg['DefaultTabTable'] : $cfg['DefaultTabDatabase'];
            $edit_target = isset($GLOBALS['db']) ? isset($GLOBALS['table']) ? 'tbl_properties.php' : 'db_details.php' : 'server_sql.php';
            //} elseif ($GLOBALS['goto'] != 'main.php') {
            //    $edit_target = $GLOBALS['goto'];
            //} else {
            //    $edit_target = '';
            //}
            if (isset($cfg['SQLQuery']['Edit']) && $cfg['SQLQuery']['Edit'] == true && !empty($edit_target)) {
                if ($cfg['EditInWindow'] == true) {
                    $onclick = 'window.parent.focus_querywindow(\'' . PMA_jsFormat($local_query, false) . '\'); return false;';
                } else {
                    $onclick = '';
                }
                $edit_link = $edit_target . $url_qpart . '&amp;sql_query=' . urlencode($local_query) . '&amp;show_query=1#querybox';
                $edit_link = ' [' . PMA_linkOrButton($edit_link, $GLOBALS['strEdit'], array('onclick' => $onclick)) . ']';
            } else {
                $edit_link = '';
            }
            // Want to have the query explained (Mike Beck 2002-05-22)
            // but only explain a SELECT (that has not been explained)
            /* SQL-Parser-Analyzer */
            if (isset($cfg['SQLQuery']['Explain']) && $cfg['SQLQuery']['Explain'] == true) {
                // Detect if we are validating as well
                // To preserve the validate uRL data
                if (!empty($GLOBALS['validatequery'])) {
                    $explain_link_validate = '&amp;validatequery=1';
                } else {
                    $explain_link_validate = '';
                }
                $explain_link = 'import.php' . $url_qpart . $explain_link_validate . '&amp;sql_query=';
                if (preg_match('@^SELECT[[:space:]]+@i', $local_query)) {
                    $explain_link .= urlencode('EXPLAIN ' . $local_query);
                    $message = $GLOBALS['strExplain'];
                } elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $local_query)) {
                    $explain_link .= urlencode(substr($local_query, 8));
                    $message = $GLOBALS['strNoExplain'];
                } else {
                    $explain_link = '';
                }
                if (!empty($explain_link)) {
                    $explain_link = ' [' . PMA_linkOrButton($explain_link, $message) . ']';
                }
            } else {
                $explain_link = '';
            }
            //show explain
            // Also we would like to get the SQL formed in some nice
            // php-code (Mike Beck 2002-05-22)
            if (isset($cfg['SQLQuery']['ShowAsPHP']) && $cfg['SQLQuery']['ShowAsPHP'] == true) {
                $php_link = 'import.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($local_query) . '&amp;show_as_php=';
                if (!empty($GLOBALS['show_as_php'])) {
                    $php_link .= '0';
                    $message = $GLOBALS['strNoPhp'];
                } else {
                    $php_link .= '1';
                    $message = $GLOBALS['strPhp'];
                }
                $php_link = ' [' . PMA_linkOrButton($php_link, $message) . ']';
                if (isset($GLOBALS['show_as_php']) && $GLOBALS['show_as_php'] == '1') {
                    $runquery_link = 'import.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($local_query);
                    $php_link .= ' [' . PMA_linkOrButton($runquery_link, $GLOBALS['strRunQuery']) . ']';
                }
            } else {
                $php_link = '';
            }
            //show as php
            // Refresh query
            if (isset($cfg['SQLQuery']['Refresh']) && $cfg['SQLQuery']['Refresh'] && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $local_query)) {
                $refresh_link = 'import.php' . $url_qpart . '&amp;show_query=1' . (isset($_GET['pos']) ? '&amp;pos=' . $_GET['pos'] : '') . '&amp;sql_query=' . urlencode($local_query);
                $refresh_link = ' [' . PMA_linkOrButton($refresh_link, $GLOBALS['strRefresh']) . ']';
            } else {
                $refresh_link = '';
            }
            //show as php
            if (isset($cfg['SQLValidator']['use']) && $cfg['SQLValidator']['use'] == true && isset($cfg['SQLQuery']['Validate']) && $cfg['SQLQuery']['Validate'] == true) {
                $validate_link = 'import.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($local_query) . '&amp;validatequery=';
                if (!empty($GLOBALS['validatequery'])) {
                    $validate_link .= '0';
                    $validate_message = $GLOBALS['strNoValidateSQL'];
                } else {
                    $validate_link .= '1';
                    $validate_message = $GLOBALS['strValidateSQL'];
                }
                $validate_link = ' [' . PMA_linkOrButton($validate_link, $validate_message) . ']';
            } else {
                $validate_link = '';
            }
            //validator
            unset($local_query);
            // Displays the message
            echo '<fieldset class="">' . "\n";
            echo '    <legend>' . $GLOBALS['strSQLQuery'] . ':</legend>';
            echo '    ' . $query_base;
            //Clean up the end of the PHP
            if (!empty($GLOBALS['show_as_php'])) {
                echo '\';';
            }
            echo '</fieldset>' . "\n";
            if (!empty($edit_target)) {
                echo '<fieldset class="tblFooters">';
                echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link;
                echo '</fieldset>';
            }
        }
        ?>
</div><br />
        <?php 
    }
コード例 #23
0
/**
 * Displays operations that are available on results.
 *
 * @param   array   the display mode
 * @param   array   the analyzed query
 *
 * @uses    $_SESSION['userconf']['pos']
 * @uses    $_SESSION['userconf']['dontlimitchars']
 * @global  string   $db                the database name
 * @global  string   $table             the table name
 * @global  string   $sql_query         the current SQL query
 * @global  integer  $unlim_num_rows    the total number of rows returned by the
 *                                      SQL query without any programmatically
 *                                      appended "LIMIT" clause
 *
 * @access  private
 *
 * @see     PMA_showMessage(), PMA_setDisplayMode(),
 *          PMA_displayTableNavigation(), PMA_displayTableHeaders(),
 *          PMA_displayTableBody(), PMA_displayResultsOperations()
 */
function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql)
{
    global $db, $table, $sql_query, $unlim_num_rows;
    $header_shown = FALSE;
    $header = '<fieldset><legend>' . $GLOBALS['strQueryResultsOperations'] . '</legend>';
    if ($the_disp_mode[6] == '1' || $the_disp_mode[9] == '1') {
        // Displays "printable view" link if required
        if ($the_disp_mode[9] == '1') {
            if (!$header_shown) {
                echo $header;
                $header_shown = TRUE;
            }
            $url_query = '?' . PMA_generate_common_url($db, $table) . '&amp;printview=1' . '&amp;sql_query=' . urlencode($sql_query);
            echo '    <!-- Print view -->' . "\n";
            echo PMA_linkOrButton('sql.php' . $url_query, ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_print.png" height="16" width="16" alt="' . $GLOBALS['strPrintView'] . '"/>' : '') . $GLOBALS['strPrintView'], '', true, true, 'print_view') . "\n";
            if (!$_SESSION['userconf']['dontlimitchars']) {
                echo '    &nbsp;&nbsp;' . "\n";
                echo PMA_linkOrButton('sql.php' . $url_query . '&amp;dontlimitchars=1', ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_print.png" height="16" width="16" alt="' . $GLOBALS['strPrintViewFull'] . '"/>' : '') . $GLOBALS['strPrintViewFull'], '', true, true, 'print_view') . "\n";
            }
        }
        // end displays "printable view"
        echo "\n";
    }
    // Export link
    // (the url_query has extra parameters that won't be used to export)
    // (the single_table parameter is used in display_export.lib.php
    //  to hide the SQL and the structure export dialogs)
    // If the parser found a PROCEDURE clause
    // (most probably PROCEDURE ANALYSE()) it makes no sense to
    // display the Export link).
    if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT' && !isset($printview) && !isset($analyzed_sql[0]['queryflags']['procedure'])) {
        if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
            $single_table = '&amp;single_table=true';
        } else {
            $single_table = '';
        }
        if (!$header_shown) {
            echo $header;
            $header_shown = TRUE;
        }
        echo '    <!-- Export -->' . "\n";
        echo '    &nbsp;&nbsp;' . "\n";
        echo PMA_linkOrButton('tbl_export.php' . $url_query . '&amp;unlim_num_rows=' . $unlim_num_rows . $single_table, ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_tblexport.png" height="16" width="16" alt="' . $GLOBALS['strExport'] . '" />' : '') . $GLOBALS['strExport'], '', true, true, '') . "\n";
    }
    // CREATE VIEW
    /**
     *
     * @todo detect privileges to create a view
     *       (but see 2006-01-19 note in display_create_table.lib.php,
     *        I think we cannot detect db-specific privileges reliably)
     * Note: we don't display a Create view link if we found a PROCEDURE clause
     */
    if (PMA_MYSQL_INT_VERSION >= 50000 && !isset($analyzed_sql[0]['queryflags']['procedure'])) {
        if (!$header_shown) {
            echo $header;
            $header_shown = TRUE;
        }
        echo '    <!-- Create View -->' . "\n";
        echo '    &nbsp;&nbsp;' . "\n";
        echo PMA_linkOrButton('view_create.php' . $url_query, ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_views.png" height="16" width="16" alt="CREATE VIEW" />' : '') . 'CREATE VIEW', '', true, true, '') . "\n";
    }
    if ($header_shown) {
        echo '</fieldset><br />';
    }
}
コード例 #24
0
                echo '    <ul>' . "\n";
                $num_search_result_total = 0;
                for ($i = 0; $i < $num_selectedtables; $i++) {
                    // Gets the SQL statements
                    $newsearchsqls = PMA_getSearchSqls($table_select[$i], $search_str, $search_option);
                    // Executes the "COUNT" statement
                    $res = PMA_DBI_query($newsearchsqls['select_count']);
                    $res_cnt = PMA_DBI_fetch_assoc($res);
                    $res_cnt = $res_cnt['count'];
                    PMA_DBI_free_result($res);
                    unset($res);
                    $num_search_result_total += $res_cnt;
                    echo '        <!-- Search results in table ' . $table_select[$i] . ' (' . $res_cnt . ') -->' . "\n" . '        <li>' . "\n" . '            <table><tr><td>' . sprintf($strNumSearchResultsInTable, $res_cnt, htmlspecialchars($table_select[$i])) . "</td>\n";
                    if ($res_cnt > 0) {
                        echo '<td>' . PMA_linkOrButton('sql.php?' . $url_sql_query . '&amp;sql_query=' . urlencode($newsearchsqls['select_fields']), $strBrowse, '') . "</td>\n";
                        echo '<td>' . PMA_linkOrButton('sql.php?' . $url_sql_query . '&amp;sql_query=' . urlencode($newsearchsqls['delete']), $strDelete, $newsearchsqls['delete']) . "</td>\n";
                    }
                    // end if
                    echo '        </tr></table></li>' . "\n";
                }
                // end for
                echo '    </ul>' . "\n";
                echo '    <p>' . sprintf($strNumSearchResultsTotal, $num_search_result_total) . '</p>' . "\n";
            }
        }
        // end several tables
        echo "\n";
        ?>
<hr width="100%">
        <?php 
    }
コード例 #25
0
/**
 * Displays the body of the results table
 *
 * @param   integer  the link id associated to the query which results have
 *                   to be displayed
 * @param   array    which elements to display
 * @param   array    the list of relations
 * @param   array    the analyzed query
 *
 * @return  boolean  always true
 *
 * @global  string   the current language
 * @global  string   the current charset for MySQL
 * @global  integer  the server to use (refers to the number in the
 *                   configuration file)
 * @global  string   the database name
 * @global  string   the table name
 * @global  string   the sql query
 * @global  string   the url to go back in case of errors
 * @global  integer  the current position in results
 * @global  integer  the maximum number of rows per page
 * @global  array    the list of fields properties
 * @global  integer  the total number of fields returned by the sql query
 * @global  array    informations used with vertical display mode
 * @global  string   the display mode (horizontal/vertical/horizontalflipped)
 * @global  integer  the number of row to display between two table headers
 * @global  boolean  whether to limit the number of displayed characters of
 *                   text type fields or not
 *
 * @access  private
 *
 * @see     PMA_displayTable()
 */
function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
{
    global $lang, $convcharset, $server, $db, $table;
    global $goto;
    global $sql_query, $pos, $session_max_rows, $fields_meta, $fields_cnt;
    global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
    global $dontlimitchars;
    global $row;
    // mostly because of browser transformations, to make the row-data accessible in a plugin
    $url_sql_query = $sql_query;
    // query without conditions to shorten urls when needed, 200 is just
    // guess, it should depend on remaining url length
    if (isset($analyzed_sql) && isset($analyzed_sql[0]) && isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' && strlen($sql_query) > 200) {
        $url_sql_query = 'SELECT ';
        if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
            $url_sql_query .= ' DISTINCT ';
        }
        $url_sql_query .= $analyzed_sql[0]['select_expr_clause'];
        if (!empty($analyzed_sql[0]['from_clause'])) {
            $url_sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
        }
    }
    if (!is_array($map)) {
        $map = array();
    }
    ?>
<!-- Results table body -->
    <?php 
    echo "\n";
    $row_no = 0;
    $vertical_display['edit'] = array();
    $vertical_display['delete'] = array();
    $vertical_display['data'] = array();
    $vertical_display['row_delete'] = array();
    // Correction uva 19991216 in the while below
    // Previous code assumed that all tables have keys, specifically that
    // the phpMyAdmin GUI should support row delete/edit only for such
    // tables.
    // Although always using keys is arguably the prescribed way of
    // defining a relational table, it is not required. This will in
    // particular be violated by the novice.
    // We want to encourage phpMyAdmin usage by such novices. So the code
    // below has been changed to conditionally work as before when the
    // table being displayed has one or more keys; but to display
    // delete/edit options correctly for tables without keys.
    // loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row'
    //        to get the NULL values
    // rabus: This function needs a little rework.
    //        Using MYSQL_BOTH just pollutes the memory!
    // ne0x:  Use function PMA_DBI_fetch_array() due to mysqli
    //        compatibility. Now this function is wrapped.
    while ($row = PMA_DBI_fetch_row($dt_result)) {
        // lem9: "vertical display" mode stuff
        if ($row_no != 0 && $repeat_cells != 0 && !($row_no % $repeat_cells) && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
            echo '<tr>' . "\n";
            for ($foo_i = 0; $foo_i < $vertical_display['emptypre']; $foo_i++) {
                echo '    <th class="td">&nbsp;</th>' . "\n";
            }
            foreach ($vertical_display['desc'] as $key => $val) {
                echo $val;
            }
            for ($foo_i = 0; $foo_i < $vertical_display['emptyafter']; $foo_i++) {
                echo '    <th class="td">&nbsp;</th>' . "\n";
            }
            echo '</tr>' . "\n";
        }
        // end if
        if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
            $bgcolor = '#ffffff';
        } else {
            $bgcolor = $row_no % 2 ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
        }
        if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
            // loic1: pointer code part
            $on_mouse = '';
            if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
                if ($GLOBALS['cfg']['BrowsePointerEnable'] == TRUE) {
                    $on_mouse = ' onmouseover="setPointer(this, ' . $row_no . ', \'over\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"' . ' onmouseout="setPointer(this, ' . $row_no . ', \'out\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
                } else {
                    $on_mouse = '';
                }
                if ($GLOBALS['cfg']['BrowseMarkerEnable'] == TRUE) {
                    $on_mouse .= ' onmousedown="setPointer(this, ' . $row_no . ', \'click\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
                }
            }
            // end if
            ?>
<tr<?php 
            echo $on_mouse;
            ?>
>
            <?php 
            echo "\n";
        }
        // 1. Prepares the row (gets primary keys to use)
        if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') {
            // 1.1 Results from a "SELECT" statement -> builds the
            //     "primary" key to use in links
            if ($is_display['edit_lnk'] == 'ur') {
                $uva_condition = urlencode(PMA_getUvaCondition($dt_result, $fields_cnt, $fields_meta, $row));
            }
            // end if (1.1)
            // 1.2 Defines the urls for the modify/delete link(s)
            $url_query = PMA_generate_common_url($db, $table) . '&amp;pos=' . $pos . '&amp;session_max_rows=' . $session_max_rows . '&amp;disp_direction=' . $disp_direction . '&amp;repeat_cells=' . $repeat_cells . '&amp;dontlimitchars=' . $dontlimitchars;
            // We need to copy the value or else the == 'both' check will always return true
            $propicon = (string) $GLOBALS['cfg']['PropertiesIconic'];
            if ($propicon == 'both') {
                $iconic_spacer = '<div class="nowrap">';
            } else {
                $iconic_spacer = '';
            }
            // 1.2.1 Modify link(s)
            if ($is_display['edit_lnk'] == 'ur') {
                // update row case
                //                    $lnk_goto = 'sql.php'
                //                             . '?' . str_replace('&amp;', '&', $url_query)
                //                              . '&sql_query=' . urlencode($sql_query)
                //                              . '&goto=' . (empty($goto) ? 'tbl_properties.php' : $goto);
                // to reduce the length of the URL, because of some browsers limitations:
                $lnk_goto = 'sql.php';
                $edit_url = 'tbl_change.php' . '?' . $url_query . '&amp;primary_key=' . $uva_condition . '&amp;sql_query=' . urlencode($url_sql_query) . '&amp;goto=' . urlencode($lnk_goto);
                if ($GLOBALS['cfg']['PropertiesIconic'] == FALSE) {
                    $edit_str = $GLOBALS['strEdit'];
                } else {
                    $edit_str = $iconic_spacer . '<img width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" alt="' . $GLOBALS['strEdit'] . '" title="' . $GLOBALS['strEdit'] . '" border="0" />';
                    if ($propicon == 'both') {
                        $edit_str .= '&nbsp;' . $GLOBALS['strEdit'] . '</div>';
                    }
                }
            }
            // end if (1.2.1)
            if ($table == $GLOBALS['cfg']['Bookmark']['table'] && $db == $GLOBALS['cfg']['Bookmark']['db'] && isset($row[1]) && isset($row[0])) {
                $bookmark_go = '<a href="read_dump.php?' . PMA_generate_common_url($row[1], '') . '&amp;id_bookmark=' . $row[0] . '&amp;action_bookmark=0' . '&amp;action_bookmark_all=1' . '&amp;SQL=' . $GLOBALS['strExecuteBookmarked'] . ' " title="' . $GLOBALS['strExecuteBookmarked'] . '">';
                if ($GLOBALS['cfg']['PropertiesIconic'] == FALSE) {
                    $bookmark_go .= $GLOBALS['strExecuteBookmarked'];
                } else {
                    $bookmark_go .= $iconic_spacer . '<img width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_bookmark.png" alt="' . $GLOBALS['strExecuteBookmarked'] . '" title="' . $GLOBALS['strExecuteBookmarked'] . '" border="0" />';
                    if ($propicon == 'both') {
                        $bookmark_go .= '&nbsp;' . $GLOBALS['strExecuteBookmarked'] . '</div>';
                    }
                }
                $bookmark_go .= '</a>';
            } else {
                $bookmark_go = '';
            }
            // 1.2.2 Delete/Kill link(s)
            if ($is_display['del_lnk'] == 'dr') {
                // delete row case
                $lnk_goto = 'sql.php' . '?' . str_replace('&amp;', '&', $url_query) . '&sql_query=' . urlencode($url_sql_query) . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&goto=' . (empty($goto) ? 'tbl_properties.php' : $goto);
                $del_query = urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $uva_condition . '+LIMIT+1';
                $del_url = 'sql.php' . '?' . $url_query . '&amp;sql_query=' . $del_query . '&amp;zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&amp;goto=' . urlencode($lnk_goto);
                $js_conf = 'DELETE FROM ' . PMA_jsFormat($table) . ' WHERE ' . trim(PMA_jsFormat(urldecode($uva_condition), FALSE)) . ' LIMIT 1';
                if ($GLOBALS['cfg']['PropertiesIconic'] == FALSE) {
                    $del_str = $GLOBALS['strDelete'];
                } else {
                    $del_str = $iconic_spacer . '<img width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strDelete'] . '" title="' . $GLOBALS['strDelete'] . '" border="0" />';
                    if ($propicon == 'both') {
                        $del_str .= '&nbsp;' . $GLOBALS['strDelete'] . '</div>';
                    }
                }
            } else {
                if ($is_display['del_lnk'] == 'kp') {
                    // kill process case
                    $lnk_goto = 'sql.php' . '?' . str_replace('&amp;', '&', $url_query) . '&sql_query=' . urlencode($url_sql_query) . '&goto=main.php';
                    $del_url = 'sql.php?' . PMA_generate_common_url('mysql') . '&amp;sql_query=' . urlencode('KILL ' . $row[0]) . '&amp;goto=' . urlencode($lnk_goto);
                    $del_query = urlencode('KILL ' . $row[0]);
                    $js_conf = 'KILL ' . $row[0];
                    if ($GLOBALS['cfg']['PropertiesIconic'] == FALSE) {
                        $del_str = $GLOBALS['strKill'];
                    } else {
                        $del_str = $iconic_spacer . '<img width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strKill'] . '" title="' . $GLOBALS['strKill'] . '" border="0" />';
                        if ($propicon == 'both') {
                            $del_str .= '&nbsp;' . $GLOBALS['strKill'] . '</div>';
                        }
                    }
                }
            }
            // end if (1.2.2)
            // 1.3 Displays the links at left if required
            if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
                $doWriteModifyAt = 'left';
                require './libraries/display_tbl_links.lib.php';
            }
            // end if (1.3)
            echo $disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped' ? "\n" : '';
        }
        // end if (1)
        // 2. Displays the rows' values
        for ($i = 0; $i < $fields_cnt; ++$i) {
            $meta = $fields_meta[$i];
            // loic1: To fix bug #474943 under php4, the row pointer will
            //        depend on whether the "is_null" php4 function is
            //        available or not
            $pointer = function_exists('is_null') ? $i : $meta->name;
            // garvin: See if this column should get highlight because it's used in the
            //  where-query.
            if (isset($highlight_columns) && (isset($highlight_columns[$meta->name]) || isset($highlight_columns[PMA_backquote($meta->name)]))) {
                $column_style = 'style="border: 1px solid ' . $GLOBALS['cfg']['BrowseMarkerColor'] . '"';
            } else {
                $column_style = '';
            }
            if ($disp_direction == 'vertical' && (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1')) {
                if ($GLOBALS['cfg']['BrowsePointerColor'] == TRUE) {
                    $column_style .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"' . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
                }
                if ($GLOBALS['cfg']['BrowseMarkerEnable'] == TRUE) {
                    $column_style .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\'); setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');"';
                } else {
                    $column_style .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
                }
            } else {
                $column_style .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
            }
            // end if
            // garvin: Wrap MIME-transformations. [MIME]
            $default_function = 'default_function';
            // default_function
            $transform_function = $default_function;
            $transform_options = array();
            if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
                if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation']) && !empty($GLOBALS['mime_map'][$meta->name]['transformation'])) {
                    $include_file = PMA_sanitizeTransformationFile($GLOBALS['mime_map'][$meta->name]['transformation']);
                    if (file_exists('./libraries/transformations/' . $include_file)) {
                        $transformfunction_name = preg_replace('@(\\.inc\\.php3?)$@i', '', $GLOBALS['mime_map'][$meta->name]['transformation']);
                        require_once './libraries/transformations/' . $include_file;
                        if (function_exists('PMA_transformation_' . $transformfunction_name)) {
                            $transform_function = 'PMA_transformation_' . $transformfunction_name;
                            $transform_options = PMA_transformation_getOptions(isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : '');
                            $meta->mimetype = str_replace('_', '/', $GLOBALS['mime_map'][$meta->name]['mimetype']);
                        }
                    }
                    // end if file_exists
                }
                // end if transformation is set
            }
            // end if mime/transformation works.
            $transform_options['wrapper_link'] = '?' . (isset($url_query) ? $url_query : '') . '&amp;primary_key=' . (isset($uva_condition) ? $uva_condition : '') . '&amp;sql_query=' . (isset($sql_query) ? urlencode($url_sql_query) : '') . '&amp;goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '') . '&amp;transform_key=' . urlencode($meta->name);
            // n u m e r i c
            if ($meta->numeric == 1) {
                // lem9: if two fields have the same name (this is possible
                //       with self-join queries, for example), using $meta->name
                //       will show both fields NULL even if only one is NULL,
                //       so use the $pointer
                //      (works only if function_exists('is_null')
                // PS:   why not always work with the number ($i), since
                //       the default second parameter of
                //       mysql_fetch_array() is MYSQL_BOTH, so we always get
                //       associative and numeric indices?
                //if (!isset($row[$meta->name])
                if (!isset($row[$i]) || is_null($row[$i])) {
                    $vertical_display['data'][$row_no][$i] = '    <td align="right" valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
                } else {
                    if ($row[$i] != '') {
                        $vertical_display['data'][$row_no][$i] = '    <td align="right" valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '" class="nowrap">';
                        if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
                            foreach ($analyzed_sql[0]['select_expr'] as $select_expr_position => $select_expr) {
                                $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
                                if (!empty($alias)) {
                                    $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
                                    if ($alias == $meta->name) {
                                        $meta->name = $true_column;
                                    }
                                    // end if
                                }
                                // end if
                            }
                            // end while
                        }
                        if (isset($map[$meta->name])) {
                            // Field to display from the foreign table?
                            if (!empty($map[$meta->name][2])) {
                                $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i];
                                $dispresult = PMA_DBI_try_query($dispsql, NULL, PMA_DBI_QUERY_STORE);
                                if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
                                    list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
                                } else {
                                    $dispval = $GLOBALS['strLinkNotFound'];
                                }
                                @PMA_DBI_free_result($dispresult);
                            } else {
                                $dispval = '';
                            }
                            // end if... else...
                            if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
                                $vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . ' <code>[-&gt;' . $dispval . ']</code>';
                            } else {
                                $title = !empty($dispval) ? ' title="' . htmlspecialchars($dispval) . '"' : '';
                                $vertical_display['data'][$row_no][$i] .= '<a href="sql.php?' . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0]) . '&amp;pos=0&amp;session_max_rows=' . $session_max_rows . '&amp;dontlimitchars=' . $dontlimitchars . '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i]) . '"' . $title . '>' . ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . '</a>';
                            }
                        } else {
                            $vertical_display['data'][$row_no][$i] .= $transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta);
                        }
                        $vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
                    } else {
                        $vertical_display['data'][$row_no][$i] = '    <td align="right" ' . $column_style . ' valign="top" bgcolor="' . $bgcolor . '" class="nowrap">&nbsp;</td>' . "\n";
                    }
                }
                //  b l o b
            } else {
                if ($GLOBALS['cfg']['ShowBlob'] == FALSE && stristr($meta->type, 'BLOB')) {
                    // loic1 : PMA_mysql_fetch_fields returns BLOB in place of
                    // TEXT fields type, however TEXT fields must be displayed
                    // even if $cfg['ShowBlob'] is false -> get the true type
                    // of the fields.
                    $field_flags = PMA_DBI_field_flags($dt_result, $i);
                    if (stristr($field_flags, 'BINARY')) {
                        $blobtext = '[BLOB';
                        if (!isset($row[$i]) || is_null($row[$i])) {
                            $blobtext .= ' - NULL';
                        } elseif (isset($row[$i])) {
                            $blob_size = PMA_formatByteDown(strlen($row[$i]), 3, 1);
                            $blobtext .= ' - ' . $blob_size[0] . ' ' . $blob_size[1];
                            unset($blob_size);
                        }
                        $blobtext .= ']';
                        $blobtext = $default_function != $transform_function ? $transform_function($blobtext, $transform_options, $meta) : $default_function($blobtext, array(), $meta);
                        $vertical_display['data'][$row_no][$i] = '    <td align="center" ' . $column_style . ' valign="top" bgcolor="' . $bgcolor . '">' . $blobtext . '</td>';
                    } else {
                        if (!isset($row[$i]) || is_null($row[$i])) {
                            $vertical_display['data'][$row_no][$i] = '    <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
                        } else {
                            if ($row[$i] != '') {
                                // garvin: if a transform function for blob is set, none of these replacements will be made
                                if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $dontlimitchars != 1) {
                                    $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
                                }
                                // loic1: displays all space characters, 4 space
                                // characters for tabulations and <cr>/<lf>
                                $row[$i] = $default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta);
                                $vertical_display['data'][$row_no][$i] = '    <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '">' . $row[$i] . '</td>' . "\n";
                            } else {
                                $vertical_display['data'][$row_no][$i] = '    <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '">&nbsp;</td>' . "\n";
                            }
                        }
                    }
                } else {
                    if (!isset($row[$i]) || is_null($row[$i])) {
                        $vertical_display['data'][$row_no][$i] = '    <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
                    } else {
                        if ($row[$i] != '') {
                            // loic1: support blanks in the key
                            $relation_id = $row[$i];
                            // nijel: Cut all fields to $cfg['LimitChars']
                            if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $dontlimitchars != 1) {
                                $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
                            }
                            // loic1: displays special characters from binaries
                            $field_flags = PMA_DBI_field_flags($dt_result, $i);
                            if (stristr($field_flags, 'BINARY')) {
                                $row[$i] = str_replace("", '\\0', $row[$i]);
                                $row[$i] = str_replace("", '\\b', $row[$i]);
                                $row[$i] = str_replace("\n", '\\n', $row[$i]);
                                $row[$i] = str_replace("\r", '\\r', $row[$i]);
                                $row[$i] = str_replace("", '\\Z', $row[$i]);
                                $row[$i] = $default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta);
                            } else {
                                $row[$i] = $default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta);
                            }
                            // garvin: transform functions may enable nowrapping:
                            $function_nowrap = $transform_function . '_nowrap';
                            $bool_nowrap = $default_function != $transform_function && function_exists($function_nowrap) ? $function_nowrap($transform_options) : false;
                            // loic1: do not wrap if date field type
                            $nowrap = preg_match('@DATE|TIME@i', $meta->type) || $bool_nowrap ? ' nowrap="nowrap"' : '';
                            $vertical_display['data'][$row_no][$i] = '    <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"' . $nowrap . '>';
                            if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
                                foreach ($analyzed_sql[0]['select_expr'] as $select_expr_position => $select_expr) {
                                    $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
                                    if (!empty($alias)) {
                                        $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
                                        if ($alias == $meta->name) {
                                            $meta->name = $true_column;
                                        }
                                        // end if
                                    }
                                    // end if
                                }
                                // end while
                            }
                            if (isset($map[$meta->name])) {
                                // Field to display from the foreign table?
                                if (!empty($map[$meta->name][2])) {
                                    $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($row[$i]) . '\'';
                                    $dispresult = PMA_DBI_try_query($dispsql, NULL, PMA_DBI_QUERY_STORE);
                                    if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
                                        list($dispval) = PMA_DBI_fetch_row($dispresult);
                                        @PMA_DBI_free_result($dispresult);
                                    } else {
                                        $dispval = $GLOBALS['strLinkNotFound'];
                                    }
                                } else {
                                    $dispval = '';
                                }
                                $title = !empty($dispval) ? ' title="' . htmlspecialchars($dispval) . '"' : '';
                                $vertical_display['data'][$row_no][$i] .= '<a href="sql.php?' . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0]) . '&amp;pos=0&amp;session_max_rows=' . $session_max_rows . '&amp;dontlimitchars=' . $dontlimitchars . '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($relation_id) . '\'') . '"' . $title . '>' . $row[$i] . '</a>';
                            } else {
                                $vertical_display['data'][$row_no][$i] .= $row[$i];
                            }
                            $vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
                        } else {
                            $vertical_display['data'][$row_no][$i] = '    <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '">&nbsp;</td>' . "\n";
                        }
                    }
                }
            }
            // lem9: output stored cell
            if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
                echo $vertical_display['data'][$row_no][$i];
            }
            if (isset($vertical_display['rowdata'][$i][$row_no])) {
                $vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i];
            } else {
                $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i];
            }
        }
        // end for (2)
        // 3. Displays the modify/delete links on the right if required
        if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
            $doWriteModifyAt = 'right';
            require './libraries/display_tbl_links.lib.php';
        }
        // end if (3)
        if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
            echo "\n";
            ?>
</tr>
            <?php 
        }
        // end if
        // 4. Gather links of del_urls and edit_urls in an array for later
        //    output
        if (!isset($vertical_display['edit'][$row_no])) {
            $vertical_display['edit'][$row_no] = '';
            $vertical_display['delete'][$row_no] = '';
            $vertical_display['row_delete'][$row_no] = '';
        }
        $column_style_vertical = '';
        if ($GLOBALS['cfg']['BrowsePointerEnable'] == TRUE) {
            $column_style_vertical .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"' . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
        }
        $column_marker_vertical = '';
        if ($GLOBALS['cfg']['BrowseMarkerEnable'] == TRUE) {
            $column_marker_vertical .= 'setVerticalPointer(this, ' . $row_no . ', \'click\', \'' . $GLOBALS['cfg']['BgcolorOne'] . '\', \'' . $GLOBALS['cfg']['BgcolorTwo'] . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');';
        }
        if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
            $vertical_display['row_delete'][$row_no] .= '    <td align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '"' . $column_style_vertical . '>' . "\n" . '        <input type="checkbox" id="id_rows_to_delete' . $row_no . '[%_PMA_CHECKBOX_DIR_%]" name="rows_to_delete[' . $uva_condition . ']"' . ' onclick="' . $column_marker_vertical . 'copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'[%_PMA_CHECKBOX_DIR_%]\');"' . ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n" . '    </td>' . "\n";
        } else {
            unset($vertical_display['row_delete'][$row_no]);
        }
        if (isset($edit_url)) {
            $vertical_display['edit'][$row_no] .= '    <td align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '"' . $column_style_vertical . '>' . "\n" . PMA_linkOrButton($edit_url, $edit_str, '', FALSE) . $bookmark_go . '    </td>' . "\n";
        } else {
            unset($vertical_display['edit'][$row_no]);
        }
        if (isset($del_url)) {
            $vertical_display['delete'][$row_no] .= '    <td align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '"' . $column_style_vertical . '>' . "\n" . PMA_linkOrButton($del_url, $del_str, isset($js_conf) ? $js_conf : '', FALSE) . '    </td>' . "\n";
        } else {
            unset($vertical_display['delete'][$row_no]);
        }
        echo $disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped' ? "\n" : '';
        $row_no++;
    }
    // end while
    if (isset($url_query)) {
        $GLOBALS['url_query'] = $url_query;
    }
    return TRUE;
}
コード例 #26
0
if ($events) {
    PMA_generate_slider_effect('events', $strEvents);
    echo '<fieldset>' . "\n";
    echo ' <legend>' . $strEvents . '</legend>' . "\n";
    echo '<table border="0">';
    echo sprintf('<tr>
                      <th>%s</th>
                      <th>&nbsp;</th>
                      <th>&nbsp;</th>
                      <th>%s</th>
                </tr>', $strName, $strType);
    $ct = 0;
    $delimiter = '//';
    foreach ($events as $event) {
        // information_schema (at least in MySQL 5.1.22) does not return
        // the full CREATE EVENT statement in a way that could be useful for us
        // so we rely on PMA_DBI_get_definition() which uses SHOW CREATE EVENT
        $definition = 'DROP EVENT ' . PMA_backquote($event['EVENT_NAME']) . $delimiter . "\n" . PMA_DBI_get_definition($db, 'EVENT', $event['EVENT_NAME']) . "\n";
        $sqlDrop = 'DROP EVENT ' . PMA_backquote($event['EVENT_NAME']);
        echo sprintf('<tr class="%s">
                          <td><strong>%s</strong></td>
                          <td>%s</td>
                          <td>%s</td>
                          <td>%s</td>
                     </tr>', $ct % 2 == 0 ? 'even' : 'odd', $event['EVENT_NAME'], !empty($definition) ? PMA_linkOrButton('db_sql.php?' . $url_query . '&amp;sql_query=' . urlencode($definition) . '&amp;show_query=1&amp;delimiter=' . urlencode($delimiter), $titles['Structure']) : '&nbsp;', '<a href="sql.php?' . $url_query . '&sql_query=' . urlencode($sqlDrop) . '" onclick="return confirmLink(this, \'' . PMA_jsFormat($sqlDrop, false) . '\')">' . $titles['Drop'] . '</a>', $event['EVENT_TYPE']);
        $ct++;
    }
    echo '</table>';
    echo '</fieldset>' . "\n";
    echo '</div>' . "\n";
}
コード例 #27
0
ファイル: common.lib.php プロジェクト: AmberWish/laba_web
/**
 * displays the message and the query
 * usually the message is the result of the query executed
 *
 * @param string  $message   the message to display
 * @param string  $sql_query the query to display
 * @param string  $type      the type (level) of the message
 * @param boolean $is_view   is this a message after a VIEW operation?
 *
 * @return  string
 *
 * @access  public
 */
function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view = false)
{
    /*
     * PMA_ajaxResponse uses this function to collect the string of HTML generated
     * for showing the message.  Use output buffering to collect it and return it
     * in a string.  In some special cases on sql.php, buffering has to be disabled
     * and hence we check with $GLOBALS['buffer_message']
     */
    if ($GLOBALS['is_ajax_request'] == true && !isset($GLOBALS['buffer_message'])) {
        ob_start();
    }
    global $cfg;
    if (null === $sql_query) {
        if (!empty($GLOBALS['display_query'])) {
            $sql_query = $GLOBALS['display_query'];
        } elseif ($cfg['SQP']['fmtType'] == 'none' && !empty($GLOBALS['unparsed_sql'])) {
            $sql_query = $GLOBALS['unparsed_sql'];
        } elseif (!empty($GLOBALS['sql_query'])) {
            $sql_query = $GLOBALS['sql_query'];
        } else {
            $sql_query = '';
        }
    }
    if (isset($GLOBALS['using_bookmark_message'])) {
        $GLOBALS['using_bookmark_message']->display();
        unset($GLOBALS['using_bookmark_message']);
    }
    // Corrects the tooltip text via JS if required
    // @todo this is REALLY the wrong place to do this - very unexpected here
    if (!$is_view && strlen($GLOBALS['table']) && $cfg['ShowTooltip']) {
        $tooltip = PMA_Table::sGetToolTip($GLOBALS['db'], $GLOBALS['table']);
        $uni_tbl = PMA_jsFormat($GLOBALS['db'] . '.' . $GLOBALS['table'], false);
        echo "\n";
        echo '<script type="text/javascript">' . "\n";
        echo '//<![CDATA[' . "\n";
        echo "if (window.parent.updateTableTitle) window.parent.updateTableTitle('" . $uni_tbl . "', '" . PMA_jsFormat($tooltip, false) . "');" . "\n";
        echo '//]]>' . "\n";
        echo '</script>' . "\n";
    }
    // end if ... elseif
    // Checks if the table needs to be repaired after a TRUNCATE query.
    // @todo what about $GLOBALS['display_query']???
    // @todo this is REALLY the wrong place to do this - very unexpected here
    if (strlen($GLOBALS['table']) && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
        if (PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Index_length') > 1024 && !PMA_DRIZZLE) {
            PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table']));
        }
    }
    unset($tbl_status);
    // In an Ajax request, $GLOBALS['cell_align_left'] may not be defined. Hence,
    // check for it's presence before using it
    echo '<div id="result_query" align="' . (isset($GLOBALS['cell_align_left']) ? $GLOBALS['cell_align_left'] : '') . '">' . "\n";
    if ($message instanceof PMA_Message) {
        if (isset($GLOBALS['special_message'])) {
            $message->addMessage($GLOBALS['special_message']);
            unset($GLOBALS['special_message']);
        }
        $message->display();
        $type = $message->getLevel();
    } else {
        echo '<div class="' . $type . '">';
        echo PMA_sanitize($message);
        if (isset($GLOBALS['special_message'])) {
            echo PMA_sanitize($GLOBALS['special_message']);
            unset($GLOBALS['special_message']);
        }
        echo '</div>';
    }
    if ($cfg['ShowSQL'] == true && !empty($sql_query)) {
        // Html format the query to be displayed
        // If we want to show some sql code it is easiest to create it here
        /* SQL-Parser-Analyzer */
        if (!empty($GLOBALS['show_as_php'])) {
            $new_line = '\\n"<br />' . "\n" . '&nbsp;&nbsp;&nbsp;&nbsp;. "';
            $query_base = htmlspecialchars(addslashes($sql_query));
            $query_base = preg_replace('/((\\015\\012)|(\\015)|(\\012))/', $new_line, $query_base);
        } else {
            $query_base = $sql_query;
        }
        $query_too_big = false;
        if (strlen($query_base) > $cfg['MaxCharactersInDisplayedSQL']) {
            // when the query is large (for example an INSERT of binary
            // data), the parser chokes; so avoid parsing the query
            $query_too_big = true;
            $shortened_query_base = nl2br(htmlspecialchars(substr($sql_query, 0, $cfg['MaxCharactersInDisplayedSQL']) . '[...]'));
        } elseif (!empty($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) {
            // (here, use "! empty" because when deleting a bookmark,
            // $GLOBALS['parsed_sql'] is set but empty
            $parsed_sql = $GLOBALS['parsed_sql'];
        } else {
            // Parse SQL if needed
            $parsed_sql = PMA_SQP_parse($query_base);
        }
        // Analyze it
        if (isset($parsed_sql) && !PMA_SQP_isError()) {
            $analyzed_display_query = PMA_SQP_analyze($parsed_sql);
            // Same as below (append LIMIT), append the remembered ORDER BY
            if ($GLOBALS['cfg']['RememberSorting'] && isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_order_to_append'])) {
                $query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_order_to_append'] . $analyzed_display_query[0]['limit_clause'] . ' ' . $analyzed_display_query[0]['section_after_limit'];
                // Need to reparse query
                $parsed_sql = PMA_SQP_parse($query_base);
                // update the $analyzed_display_query
                $analyzed_display_query[0]['section_before_limit'] .= $GLOBALS['sql_order_to_append'];
                $analyzed_display_query[0]['order_by_clause'] = $GLOBALS['sorted_col'];
            }
            // Here we append the LIMIT added for navigation, to
            // enable its display. Adding it higher in the code
            // to $sql_query would create a problem when
            // using the Refresh or Edit links.
            // Only append it on SELECTs.
            /**
             * @todo what would be the best to do when someone hits Refresh:
             * use the current LIMITs ?
             */
            if (isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_limit_to_append'])) {
                $query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit'];
                // Need to reparse query
                $parsed_sql = PMA_SQP_parse($query_base);
            }
        }
        if (!empty($GLOBALS['show_as_php'])) {
            $query_base = '$sql  = "' . $query_base;
        } elseif (!empty($GLOBALS['validatequery'])) {
            try {
                $query_base = PMA_validateSQL($query_base);
            } catch (Exception $e) {
                PMA_Message::error(__('Failed to connect to SQL validator!'))->display();
            }
        } elseif (isset($parsed_sql)) {
            $query_base = PMA_formatSql($parsed_sql, $query_base);
        }
        // Prepares links that may be displayed to edit/explain the query
        // (don't go to default pages, we must go to the page
        // where the query box is available)
        // Basic url query part
        $url_params = array();
        if (!isset($GLOBALS['db'])) {
            $GLOBALS['db'] = '';
        }
        if (strlen($GLOBALS['db'])) {
            $url_params['db'] = $GLOBALS['db'];
            if (strlen($GLOBALS['table'])) {
                $url_params['table'] = $GLOBALS['table'];
                $edit_link = 'tbl_sql.php';
            } else {
                $edit_link = 'db_sql.php';
            }
        } else {
            $edit_link = 'server_sql.php';
        }
        // Want to have the query explained
        // but only explain a SELECT (that has not been explained)
        /* SQL-Parser-Analyzer */
        $explain_link = '';
        $is_select = false;
        if (!empty($cfg['SQLQuery']['Explain']) && !$query_too_big) {
            $explain_params = $url_params;
            // Detect if we are validating as well
            // To preserve the validate uRL data
            if (!empty($GLOBALS['validatequery'])) {
                $explain_params['validatequery'] = 1;
            }
            if (preg_match('@^SELECT[[:space:]]+@i', $sql_query)) {
                $explain_params['sql_query'] = 'EXPLAIN ' . $sql_query;
                $_message = __('Explain SQL');
                $is_select = true;
            } elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query)) {
                $explain_params['sql_query'] = substr($sql_query, 8);
                $_message = __('Skip Explain SQL');
            }
            if (isset($explain_params['sql_query'])) {
                $explain_link = 'import.php' . PMA_generate_common_url($explain_params);
                $explain_link = ' [' . PMA_linkOrButton($explain_link, $_message) . ']';
            }
        }
        //show explain
        $url_params['sql_query'] = $sql_query;
        $url_params['show_query'] = 1;
        // even if the query is big and was truncated, offer the chance
        // to edit it (unless it's enormous, see PMA_linkOrButton() )
        if (!empty($cfg['SQLQuery']['Edit'])) {
            if ($cfg['EditInWindow'] == true) {
                $onclick = 'window.parent.focus_querywindow(\'' . PMA_jsFormat($sql_query, false) . '\'); return false;';
            } else {
                $onclick = '';
            }
            $edit_link .= PMA_generate_common_url($url_params) . '#querybox';
            $edit_link = ' [' . PMA_linkOrButton($edit_link, __('Edit'), array('onclick' => $onclick)) . ']';
        } else {
            $edit_link = '';
        }
        $url_qpart = PMA_generate_common_url($url_params);
        // Also we would like to get the SQL formed in some nice
        // php-code
        if (!empty($cfg['SQLQuery']['ShowAsPHP']) && !$query_too_big) {
            $php_params = $url_params;
            if (!empty($GLOBALS['show_as_php'])) {
                $_message = __('Without PHP Code');
            } else {
                $php_params['show_as_php'] = 1;
                $_message = __('Create PHP Code');
            }
            $php_link = 'import.php' . PMA_generate_common_url($php_params);
            $php_link = ' [' . PMA_linkOrButton($php_link, $_message) . ']';
            if (isset($GLOBALS['show_as_php'])) {
                $runquery_link = 'import.php' . PMA_generate_common_url($url_params);
                $php_link .= ' [' . PMA_linkOrButton($runquery_link, __('Submit Query')) . ']';
            }
        } else {
            $php_link = '';
        }
        //show as php
        // Refresh query
        if (!empty($cfg['SQLQuery']['Refresh']) && !isset($GLOBALS['show_as_php']) && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)) {
            $refresh_link = 'import.php' . PMA_generate_common_url($url_params);
            $refresh_link = ' [' . PMA_linkOrButton($refresh_link, __('Refresh')) . ']';
        } else {
            $refresh_link = '';
        }
        //refresh
        if (!empty($cfg['SQLValidator']['use']) && !empty($cfg['SQLQuery']['Validate'])) {
            $validate_params = $url_params;
            if (!empty($GLOBALS['validatequery'])) {
                $validate_message = __('Skip Validate SQL');
            } else {
                $validate_params['validatequery'] = 1;
                $validate_message = __('Validate SQL');
            }
            $validate_link = 'import.php' . PMA_generate_common_url($validate_params);
            $validate_link = ' [' . PMA_linkOrButton($validate_link, $validate_message) . ']';
        } else {
            $validate_link = '';
        }
        //validator
        if (!empty($GLOBALS['validatequery'])) {
            echo '<div class="sqlvalidate">';
        } else {
            echo '<code class="sql">';
        }
        if ($query_too_big) {
            echo $shortened_query_base;
        } else {
            echo $query_base;
        }
        //Clean up the end of the PHP
        if (!empty($GLOBALS['show_as_php'])) {
            echo '";';
        }
        if (!empty($GLOBALS['validatequery'])) {
            echo '</div>';
        } else {
            echo '</code>';
        }
        echo '<div class="tools">';
        // avoid displaying a Profiling checkbox that could
        // be checked, which would reexecute an INSERT, for example
        if (!empty($refresh_link)) {
            PMA_profilingCheckbox($sql_query);
        }
        // if needed, generate an invisible form that contains controls for the
        // Inline link; this way, the behavior of the Inline link does not
        // depend on the profiling support or on the refresh link
        if (empty($refresh_link) || !PMA_profilingSupported()) {
            echo '<form action="sql.php" method="post">';
            echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']);
            echo '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />';
            echo '</form>';
        }
        // in the tools div, only display the Inline link when not in ajax
        // mode because 1) it currently does not work and 2) we would
        // have two similar mechanisms on the page for the same goal
        if ($is_select || $GLOBALS['is_ajax_request'] === false && !$query_too_big) {
            // see in js/functions.js the jQuery code attached to id inline_edit
            // document.write conflicts with jQuery, hence used $().append()
            echo "<script type=\"text/javascript\">\n" . "//<![CDATA[\n" . "\$('.tools form').last().after('[<a href=\"#\" title=\"" . PMA_escapeJsString(__('Inline edit of this query')) . "\" class=\"inline_edit_sql\">" . PMA_escapeJsString(_pgettext('Inline edit query', 'Inline')) . "</a>]');\n" . "//]]>\n" . "</script>";
        }
        echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link;
        echo '</div>';
    }
    echo '</div>';
    if ($GLOBALS['is_ajax_request'] === false) {
        echo '<br class="clearfloat" />';
    }
    // If we are in an Ajax request, we have most probably been called in
    // PMA_ajaxResponse().  Hence, collect the buffer contents and return it
    // to PMA_ajaxResponse(), which will encode it for JSON.
    if ($GLOBALS['is_ajax_request'] == true && !isset($GLOBALS['buffer_message'])) {
        $buffer_contents = ob_get_contents();
        ob_end_clean();
        return $buffer_contents;
    }
    return null;
}
コード例 #28
0
ファイル: common.lib.php プロジェクト: bharathi26/openemr
/**
 * displays the message and the query
 * usually the message is the result of the query executed
 *
 * @param   string  $message    the message to display
 * @param   string  $sql_query  the query to display
 * @global  array   the configuration array
 * @uses    $cfg
 * @access  public
 */
function PMA_showMessage($message, $sql_query = null)
{
    global $cfg;
    $query_too_big = false;
    if (null === $sql_query) {
        if (!empty($GLOBALS['display_query'])) {
            $sql_query = $GLOBALS['display_query'];
        } elseif ($cfg['SQP']['fmtType'] == 'none' && !empty($GLOBALS['unparsed_sql'])) {
            $sql_query = $GLOBALS['unparsed_sql'];
        } elseif (!empty($GLOBALS['sql_query'])) {
            $sql_query = $GLOBALS['sql_query'];
        } else {
            $sql_query = '';
        }
    }
    // Corrects the tooltip text via JS if required
    // @todo this is REALLY the wrong place to do this - very unexpected here
    if (strlen($GLOBALS['table']) && $cfg['ShowTooltip']) {
        $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');
        if ($result) {
            $tbl_status = PMA_DBI_fetch_assoc($result);
            $tooltip = empty($tbl_status['Comment']) ? '' : $tbl_status['Comment'] . ' ';
            $tooltip .= '(' . PMA_formatNumber($tbl_status['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')';
            PMA_DBI_free_result($result);
            $uni_tbl = PMA_jsFormat($GLOBALS['db'] . '.' . $GLOBALS['table'], false);
            echo "\n";
            echo '<script type="text/javascript">' . "\n";
            echo '//<![CDATA[' . "\n";
            echo "window.parent.updateTableTitle('" . $uni_tbl . "', '" . PMA_jsFormat($tooltip, false) . "');" . "\n";
            echo '//]]>' . "\n";
            echo '</script>' . "\n";
        }
        // end if
    }
    // end if ... elseif
    // Checks if the table needs to be repaired after a TRUNCATE query.
    // @todo what about $GLOBALS['display_query']???
    // @todo this is REALLY the wrong place to do this - very unexpected here
    if (strlen($GLOBALS['table']) && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
        if (!isset($tbl_status)) {
            $result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');
            if ($result) {
                $tbl_status = PMA_DBI_fetch_assoc($result);
                PMA_DBI_free_result($result);
            }
        }
        if (isset($tbl_status) && (int) $tbl_status['Index_length'] > 1024) {
            PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table']));
        }
    }
    unset($tbl_status);
    echo '<br />' . "\n";
    echo '<div align="' . $GLOBALS['cell_align_left'] . '">' . "\n";
    if (!empty($GLOBALS['show_error_header'])) {
        echo '<div class="error">' . "\n";
        echo '<h1>' . $GLOBALS['strError'] . '</h1>' . "\n";
    }
    echo '<div class="notice">';
    echo PMA_sanitize($message);
    if (isset($GLOBALS['special_message'])) {
        echo PMA_sanitize($GLOBALS['special_message']);
        unset($GLOBALS['special_message']);
    }
    echo '</div>';
    if (!empty($GLOBALS['show_error_header'])) {
        echo '</div>';
    }
    if ($cfg['ShowSQL'] == true && !empty($sql_query)) {
        // Basic url query part
        $url_qpart = '?' . PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']);
        // Html format the query to be displayed
        // The nl2br function isn't used because its result isn't a valid
        // xhtml1.0 statement before php4.0.5 ("<br>" and not "<br />")
        // If we want to show some sql code it is easiest to create it here
        /* SQL-Parser-Analyzer */
        if (!empty($GLOBALS['show_as_php'])) {
            $new_line = '\'<br />' . "\n" . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. \' ';
        }
        if (isset($new_line)) {
            /* SQL-Parser-Analyzer */
            $query_base = PMA_sqlAddslashes(htmlspecialchars($sql_query), false, false, true);
            /* SQL-Parser-Analyzer */
            $query_base = preg_replace("@((\r\n)|(\r)|(\n))+@", $new_line, $query_base);
        } else {
            $query_base = $sql_query;
        }
        if (strlen($query_base) > $cfg['MaxCharactersInDisplayedSQL']) {
            $query_too_big = true;
            $query_base = nl2br(htmlspecialchars($sql_query));
            unset($GLOBALS['parsed_sql']);
        }
        // Parse SQL if needed
        // (here, use "! empty" because when deleting a bookmark,
        // $GLOBALS['parsed_sql'] is set but empty
        if (!empty($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) {
            $parsed_sql = $GLOBALS['parsed_sql'];
        } else {
            // when the query is large (for example an INSERT of binary
            // data), the parser chokes; so avoid parsing the query
            if (!$query_too_big) {
                $parsed_sql = PMA_SQP_parse($query_base);
            }
        }
        // Analyze it
        if (isset($parsed_sql)) {
            $analyzed_display_query = PMA_SQP_analyze($parsed_sql);
        }
        // Here we append the LIMIT added for navigation, to
        // enable its display. Adding it higher in the code
        // to $sql_query would create a problem when
        // using the Refresh or Edit links.
        // Only append it on SELECTs.
        /**
         * @todo what would be the best to do when someone hits Refresh:
         * use the current LIMITs ?
         */
        if (isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_limit_to_append'])) {
            $query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit'];
            // Need to reparse query
            $parsed_sql = PMA_SQP_parse($query_base);
        }
        if (!empty($GLOBALS['show_as_php'])) {
            $query_base = '$sql  = \'' . $query_base;
        } elseif (!empty($GLOBALS['validatequery'])) {
            $query_base = PMA_validateSQL($query_base);
        } else {
            if (isset($parsed_sql)) {
                $query_base = PMA_formatSql($parsed_sql, $query_base);
            }
        }
        // Prepares links that may be displayed to edit/explain the query
        // (don't go to default pages, we must go to the page
        // where the query box is available)
        $edit_target = strlen($GLOBALS['db']) ? strlen($GLOBALS['table']) ? 'tbl_sql.php' : 'db_sql.php' : 'server_sql.php';
        if (isset($cfg['SQLQuery']['Edit']) && $cfg['SQLQuery']['Edit'] == true && !empty($edit_target) && !$query_too_big) {
            if ($cfg['EditInWindow'] == true) {
                $onclick = 'window.parent.focus_querywindow(\'' . PMA_jsFormat($sql_query, false) . '\'); return false;';
            } else {
                $onclick = '';
            }
            $edit_link = $edit_target . $url_qpart . '&amp;sql_query=' . urlencode($sql_query) . '&amp;show_query=1#querybox';
            $edit_link = ' [' . PMA_linkOrButton($edit_link, $GLOBALS['strEdit'], array('onclick' => $onclick)) . ']';
        } else {
            $edit_link = '';
        }
        // Want to have the query explained (Mike Beck 2002-05-22)
        // but only explain a SELECT (that has not been explained)
        /* SQL-Parser-Analyzer */
        if (isset($cfg['SQLQuery']['Explain']) && $cfg['SQLQuery']['Explain'] == true && !$query_too_big) {
            // Detect if we are validating as well
            // To preserve the validate uRL data
            if (!empty($GLOBALS['validatequery'])) {
                $explain_link_validate = '&amp;validatequery=1';
            } else {
                $explain_link_validate = '';
            }
            $explain_link = 'import.php' . $url_qpart . $explain_link_validate . '&amp;sql_query=';
            if (preg_match('@^SELECT[[:space:]]+@i', $sql_query)) {
                $explain_link .= urlencode('EXPLAIN ' . $sql_query);
                $message = $GLOBALS['strExplain'];
            } elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query)) {
                $explain_link .= urlencode(substr($sql_query, 8));
                $message = $GLOBALS['strNoExplain'];
            } else {
                $explain_link = '';
            }
            if (!empty($explain_link)) {
                $explain_link = ' [' . PMA_linkOrButton($explain_link, $message) . ']';
            }
        } else {
            $explain_link = '';
        }
        //show explain
        // Also we would like to get the SQL formed in some nice
        // php-code (Mike Beck 2002-05-22)
        if (isset($cfg['SQLQuery']['ShowAsPHP']) && $cfg['SQLQuery']['ShowAsPHP'] == true && !$query_too_big) {
            $php_link = 'import.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($sql_query) . '&amp;show_as_php=';
            if (!empty($GLOBALS['show_as_php'])) {
                $php_link .= '0';
                $message = $GLOBALS['strNoPhp'];
            } else {
                $php_link .= '1';
                $message = $GLOBALS['strPhp'];
            }
            $php_link = ' [' . PMA_linkOrButton($php_link, $message) . ']';
            if (isset($GLOBALS['show_as_php'])) {
                $runquery_link = 'import.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($sql_query);
                $php_link .= ' [' . PMA_linkOrButton($runquery_link, $GLOBALS['strRunQuery']) . ']';
            }
        } else {
            $php_link = '';
        }
        //show as php
        // Refresh query
        if (isset($cfg['SQLQuery']['Refresh']) && $cfg['SQLQuery']['Refresh'] && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)) {
            $refresh_link = 'import.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($sql_query);
            $refresh_link = ' [' . PMA_linkOrButton($refresh_link, $GLOBALS['strRefresh']) . ']';
        } else {
            $refresh_link = '';
        }
        //show as php
        if (isset($cfg['SQLValidator']['use']) && $cfg['SQLValidator']['use'] == true && isset($cfg['SQLQuery']['Validate']) && $cfg['SQLQuery']['Validate'] == true) {
            $validate_link = 'import.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($sql_query) . '&amp;validatequery=';
            if (!empty($GLOBALS['validatequery'])) {
                $validate_link .= '0';
                $validate_message = $GLOBALS['strNoValidateSQL'];
            } else {
                $validate_link .= '1';
                $validate_message = $GLOBALS['strValidateSQL'];
            }
            $validate_link = ' [' . PMA_linkOrButton($validate_link, $validate_message) . ']';
        } else {
            $validate_link = '';
        }
        //validator
        // why this?
        //unset($sql_query);
        // Displays the message
        echo '<fieldset class="">' . "\n";
        echo '    <legend>' . $GLOBALS['strSQLQuery'] . ':</legend>';
        echo '    <div>';
        // when uploading a 700 Kio binary file into a LONGBLOB,
        // I get a white page, strlen($query_base) is 2 x 700 Kio
        // so put a hard limit here (let's say 1000)
        if ($query_too_big) {
            echo '    ' . substr($query_base, 0, $cfg['MaxCharactersInDisplayedSQL']) . '[...]';
        } else {
            echo '    ' . $query_base;
        }
        //Clean up the end of the PHP
        if (!empty($GLOBALS['show_as_php'])) {
            echo '\';';
        }
        echo '    </div>';
        echo '</fieldset>' . "\n";
        if (!empty($edit_target)) {
            echo '<fieldset class="tblFooters">';
            // avoid displaying a Profiling checkbox that could
            // be checked, which would reexecute an INSERT, for example
            if (!empty($refresh_link)) {
                PMA_profilingCheckbox($sql_query);
            }
            echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link;
            echo '</fieldset>';
        }
    }
    echo '</div><br />' . "\n";
}
コード例 #29
0
        // uses SHOW CREATE
        $definition = 'DROP ' . $routine['ROUTINE_TYPE'] . ' ' . PMA_backquote($routine['SPECIFIC_NAME']) . $delimiter . "\n" . PMA_DBI_get_definition($db, $routine['ROUTINE_TYPE'], $routine['SPECIFIC_NAME']) . "\n";
        //if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') {
        //    $sqlUseProc  = 'CALL ' . $routine['SPECIFIC_NAME'] . '()';
        //} else {
        //    $sqlUseProc = 'SELECT ' . $routine['SPECIFIC_NAME'] . '()';
        /* this won't get us far: to really use the function
           i'd need to know how many parameters the function needs and then create
           something to ask for them. As i don't see this directly in
           the table i am afraid that requires parsing the ROUTINE_DEFINITION
           and i don't really need that now so i simply don't offer
           a method for running the function*/
        //}
        if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') {
            $sqlDropProc = 'DROP PROCEDURE ' . PMA_backquote($routine['SPECIFIC_NAME']);
        } else {
            $sqlDropProc = 'DROP FUNCTION ' . PMA_backquote($routine['SPECIFIC_NAME']);
        }
        echo sprintf('<tr class="%s">
                          <td><strong>%s</strong></td>
                          <td>%s</td>
                          <td>%s</td>
                          <td>%s</td>
                          <td>%s</td>
                     </tr>', $ct % 2 == 0 ? 'even' : 'odd', $routine['ROUTINE_NAME'], !empty($definition) ? PMA_linkOrButton('db_sql.php?' . $url_query . '&amp;sql_query=' . urlencode($definition) . '&amp;show_query=1&amp;db_query_force=1&amp;delimiter=' . urlencode($delimiter), $titles['Structure']) : '&nbsp;', '<a href="sql.php?' . $url_query . '&amp;sql_query=' . urlencode($sqlDropProc) . '" onclick="return confirmLink(this, \'' . PMA_jsFormat($sqlDropProc, false) . '\')">' . $titles['Drop'] . '</a>', $routine['ROUTINE_TYPE'], $routine['DTD_IDENTIFIER']);
        $ct++;
    }
    echo '</table>';
    echo '</fieldset>' . "\n";
    echo '</div>' . "\n";
}
コード例 #30
0
ファイル: common.lib.php プロジェクト: mike503/phpmyadmin
    /**
     * Displays a message at the top of the "main" (right) frame
     *
     * @param   string  the message to display
     *
     * @global  array   the configuration array
     *
     * @access  public
     */
    function PMA_showMessage($message)
    {
        global $cfg;
        // Sanitizes $message
        $message = PMA_sanitize($message);
        // Corrects the tooltip text via JS if required
        if (!empty($GLOBALS['table']) && $cfg['ShowTooltip']) {
            $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\'');
            if ($result) {
                $tbl_status = PMA_DBI_fetch_assoc($result);
                $tooltip = empty($tbl_status['Comment']) ? '' : $tbl_status['Comment'] . ' ';
                $tooltip .= '(' . $tbl_status['Rows'] . ' ' . $GLOBALS['strRows'] . ')';
                PMA_DBI_free_result($result);
                $md5_tbl = md5($GLOBALS['table']);
                echo "\n";
                ?>
<script type="text/javascript" language="javascript1.2">
<!--
if (typeof(document.getElementById) != 'undefined'
    && typeof(window.parent.frames['nav']) != 'undefined'
    && typeof(window.parent.frames['nav'].document) != 'undefined' && typeof(window.parent.frames['nav'].document) != 'unknown'
    && (window.parent.frames['nav'].document.getElementById('<?php 
                echo 'tbl_' . $md5_tbl;
                ?>
'))
    && typeof(window.parent.frames['nav'].document.getElementById('<?php 
                echo 'tbl_' . $md5_tbl;
                ?>
')) != 'undefined'
    && typeof(window.parent.frames['nav'].document.getElementById('<?php 
                echo 'tbl_' . $md5_tbl;
                ?>
').title) == 'string') {
    window.parent.frames['nav'].document.getElementById('<?php 
                echo 'tbl_' . $md5_tbl;
                ?>
').title = '<?php 
                echo PMA_jsFormat($tooltip, FALSE);
                ?>
';
}
//-->
</script>
                <?php 
            }
            // end if
        }
        // end if... else if
        // Checks if the table needs to be repaired after a TRUNCATE query.
        if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query']) && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
            if (!isset($tbl_status)) {
                $result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\'');
                if ($result) {
                    $tbl_status = PMA_DBI_fetch_assoc($result);
                    PMA_DBI_free_result($result);
                }
            }
            if (isset($tbl_status) && (int) $tbl_status['Index_length'] > 1024) {
                PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table']));
            }
        }
        unset($tbl_status);
        echo "\n";
        ?>
<br />
<div align="<?php 
        echo $GLOBALS['cell_align_left'];
        ?>
">
    <table border="<?php 
        echo $cfg['Border'];
        ?>
" cellpadding="5" cellspacing="1">
    <?php 
        if (isset($GLOBALS['show_error_header']) && $GLOBALS['show_error_header']) {
            ?>
    <tr><th class="tblHeadError"><div class="errorhead"><?php 
            echo $GLOBALS['strError'];
            ?>
</div></th></tr>
    <?php 
        }
        ?>
    <tr>
        <th<?php 
        echo $GLOBALS['theme'] != 'original' ? ' class="tblHeaders"' : ' bgcolor="' . $cfg['ThBgcolor'] . '"';
        ?>
>
            <b><?php 
        echo $message;
        ?>
</b>
        </th>
    </tr>
        <?php 
        if ($cfg['ShowSQL'] == TRUE && (!empty($GLOBALS['sql_query']) || !empty($GLOBALS['display_query']))) {
            $local_query = !empty($GLOBALS['display_query']) ? $GLOBALS['display_query'] : ($cfg['SQP']['fmtType'] == 'none' && isset($GLOBALS['unparsed_sql']) && $GLOBALS['unparsed_sql'] != '' ? $GLOBALS['unparsed_sql'] : $GLOBALS['sql_query']);
            // Basic url query part
            $url_qpart = '?' . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : '');
            echo "\n";
            ?>
    <tr>
        <td bgcolor="<?php 
            echo $cfg['BgcolorOne'];
            ?>
">
            <?php 
            echo "\n";
            // Html format the query to be displayed
            // The nl2br function isn't used because its result isn't a valid
            // xhtml1.0 statement before php4.0.5 ("<br>" and not "<br />")
            // If we want to show some sql code it is easiest to create it here
            /* SQL-Parser-Analyzer */
            if (!empty($GLOBALS['show_as_php'])) {
                $new_line = '\'<br />' . "\n" . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;. \' ';
            }
            if (isset($new_line)) {
                /* SQL-Parser-Analyzer */
                $query_base = PMA_sqlAddslashes(htmlspecialchars($local_query), FALSE, FALSE, TRUE);
                /* SQL-Parser-Analyzer */
                $query_base = preg_replace("@((\r\n)|(\r)|(\n))+@", $new_line, $query_base);
            } else {
                $query_base = $local_query;
            }
            // Here we append the LIMIT added for navigation, to
            // enable its display. Adding it higher in the code
            // to $local_query would create a problem when
            // using the Refresh or Edit links.
            // Only append it on SELECTs.
            // FIXME: what would be the best to do when someone
            // hits Refresh: use the current LIMITs ?
            // TODO: use the parser instead of preg_match()
            if (preg_match('@^SELECT[[:space:]]+@i', $query_base) && isset($GLOBALS['sql_limit_to_append'])) {
                $query_base .= $GLOBALS['sql_limit_to_append'];
            }
            if (!empty($GLOBALS['show_as_php'])) {
                $query_base = '$sql  = \'' . $query_base;
            } else {
                if (!empty($GLOBALS['validatequery'])) {
                    $query_base = PMA_validateSQL($query_base);
                } else {
                    // avoid reparsing query:
                    if (isset($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) {
                        $parsed_sql = $GLOBALS['parsed_sql'];
                    } else {
                        $parsed_sql = PMA_SQP_parse($query_base);
                    }
                    $query_base = PMA_formatSql($parsed_sql, $query_base);
                }
            }
            // Prepares links that may be displayed to edit/explain the query
            // (don't go to default pages, we must go to the page
            // where the query box is available)
            // (also, I don't see why we should check the goto variable)
            //if (!isset($GLOBALS['goto'])) {
            //$edit_target = (isset($GLOBALS['table'])) ? $cfg['DefaultTabTable'] : $cfg['DefaultTabDatabase'];
            $edit_target = isset($GLOBALS['db']) ? isset($GLOBALS['table']) ? 'tbl_properties.php' : 'db_details.php' : '';
            //} else if ($GLOBALS['goto'] != 'main.php') {
            //    $edit_target = $GLOBALS['goto'];
            //} else {
            //    $edit_target = '';
            //}
            if (isset($cfg['SQLQuery']['Edit']) && $cfg['SQLQuery']['Edit'] == TRUE && !empty($edit_target)) {
                $onclick = '';
                if ($cfg['QueryFrameJS'] && $cfg['QueryFrame']) {
                    $onclick = 'focus_querywindow(\'' . urlencode($local_query) . '\'); return false;';
                }
                $edit_link = $edit_target . $url_qpart . '&amp;sql_query=' . urlencode($local_query) . '&amp;show_query=1#querybox"';
                $edit_link = ' [' . PMA_linkOrButton($edit_link, $GLOBALS['strEdit'], array('onclick' => $onclick)) . ']';
            } else {
                $edit_link = '';
            }
            // Want to have the query explained (Mike Beck 2002-05-22)
            // but only explain a SELECT (that has not been explained)
            /* SQL-Parser-Analyzer */
            if (isset($cfg['SQLQuery']['Explain']) && $cfg['SQLQuery']['Explain'] == TRUE) {
                // Detect if we are validating as well
                // To preserve the validate uRL data
                if (!empty($GLOBALS['validatequery'])) {
                    $explain_link_validate = '&amp;validatequery=1';
                } else {
                    $explain_link_validate = '';
                }
                $explain_link = 'read_dump.php' . $url_qpart . $explain_link_validate . '&amp;sql_query=';
                if (preg_match('@^SELECT[[:space:]]+@i', $local_query)) {
                    $explain_link .= urlencode('EXPLAIN ' . $local_query);
                    $message = $GLOBALS['strExplain'];
                } else {
                    if (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $local_query)) {
                        $explain_link .= urlencode(substr($local_query, 8));
                        $message = $GLOBALS['strNoExplain'];
                    } else {
                        $explain_link = '';
                    }
                }
                if (!empty($explain_link)) {
                    $explain_link = ' [' . PMA_linkOrButton($explain_link, $message) . ']';
                }
            } else {
                $explain_link = '';
            }
            //show explain
            // Also we would like to get the SQL formed in some nice
            // php-code (Mike Beck 2002-05-22)
            if (isset($cfg['SQLQuery']['ShowAsPHP']) && $cfg['SQLQuery']['ShowAsPHP'] == TRUE) {
                $php_link = 'read_dump.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($local_query) . '&amp;show_as_php=';
                if (!empty($GLOBALS['show_as_php'])) {
                    $php_link .= '0';
                    $message = $GLOBALS['strNoPhp'];
                } else {
                    $php_link .= '1';
                    $message = $GLOBALS['strPhp'];
                }
                $php_link = ' [' . PMA_linkOrButton($php_link, $message) . ']';
                if (isset($GLOBALS['show_as_php']) && $GLOBALS['show_as_php'] == '1') {
                    $runquery_link = 'read_dump.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($local_query);
                    $php_link .= ' [' . PMA_linkOrButton($runquery_link, $GLOBALS['strRunQuery']) . ']';
                }
            } else {
                $php_link = '';
            }
            //show as php
            // Refresh query
            if (isset($cfg['SQLQuery']['Refresh']) && $cfg['SQLQuery']['Refresh'] && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $local_query)) {
                $refresh_link = 'read_dump.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($local_query);
                $refresh_link = ' [' . PMA_linkOrButton($refresh_link, $GLOBALS['strRefresh']) . ']';
            } else {
                $refresh_link = '';
            }
            //show as php
            if (isset($cfg['SQLValidator']['use']) && $cfg['SQLValidator']['use'] == TRUE && isset($cfg['SQLQuery']['Validate']) && $cfg['SQLQuery']['Validate'] == TRUE) {
                $validate_link = 'read_dump.php' . $url_qpart . '&amp;show_query=1' . '&amp;sql_query=' . urlencode($local_query) . '&amp;validatequery=';
                if (!empty($GLOBALS['validatequery'])) {
                    $validate_link .= '0';
                    $message = $GLOBALS['strNoValidateSQL'];
                } else {
                    $validate_link .= '1';
                    $message = $GLOBALS['strValidateSQL'];
                }
                $validate_link = ' [' . PMA_linkOrButton($validate_link, $GLOBALS['strRefresh']) . ']';
            } else {
                $validate_link = '';
            }
            //validator
            // Displays the message
            echo '            <b>' . $GLOBALS['strSQLQuery'] . ':</b>&nbsp;';
            echo '<br />' . "\n";
            echo '            ' . $query_base;
            unset($local_query);
            //Clean up the end of the PHP
            if (!empty($GLOBALS['show_as_php'])) {
                echo '\';';
            }
            echo "\n";
            ?>
        </td>
    </tr>
    <?php 
            if (!empty($edit_target)) {
                echo '<tr><td class="tblFooters">';
                echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link;
                echo '</td></tr>' . "\n";
            }
        }
        echo "\n";
        ?>
    </table>
</div><br />
        <?php 
    }