Пример #1
0
/**
 * Creates a fieldset for adding a new item, if the user has the privileges.
 *
 * @param    string   $docu   String used to create a link to the MySQL docs
 * @param    string   $priv   Privilege to check for adding a new item
 * @param    string   $name   MySQL name of the item
 *
 * @return   string   An HTML snippet with the link to add a new item
 */
function PMA_RTE_getFooterLinks($docu, $priv, $name)
{
    global $db, $url_query, $ajax_class;
    $icon = 'b_' . strtolower($name) . '_add.png';
    $retval = "";
    $retval .= "<!-- ADD " . $name . " FORM START -->\n";
    $retval .= "<fieldset class='left'>\n";
    $retval .= "    <legend>" . __('New') . "</legend>\n";
    $retval .= "        <div class='wrap'>\n";
    if (PMA_currentUserHasPrivilege($priv, $db)) {
        $retval .= "            <a {$ajax_class['add']} ";
        $retval .= "href='db_" . strtolower($name) . "s.php";
        $retval .= "?{$url_query}&amp;add_item=1'>";
        $retval .= PMA_getIcon($icon);
        $retval .= PMA_RTE_getWord('add') . "</a>\n";
    } else {
        $retval .= "            " . PMA_getIcon($icon);
        $retval .= PMA_RTE_getWord('no_create') . "\n";
    }
    $retval .= "            " . PMA_showMySQLDocu('SQL-Syntax', $docu) . "\n";
    $retval .= "        </div>\n";
    $retval .= "</fieldset>\n";
    $retval .= "<!-- ADD " . $name . " FORM END -->\n\n";
    return $retval;
}
Пример #2
0
function printVariablesTable()
{
    global $server_status, $server_variables, $allocationMap, $links;
    /**
     * Messages are built using the message name
     */
    $strShowStatus = array('Aborted_clients' => __('The number of connections that were aborted because the client died without closing the connection properly.'), 'Aborted_connects' => __('The number of failed attempts to connect to the MySQL server.'), 'Binlog_cache_disk_use' => __('The number of transactions that used the temporary binary log cache but that exceeded the value of binlog_cache_size and used a temporary file to store statements from the transaction.'), 'Binlog_cache_use' => __('The number of transactions that used the temporary binary log cache.'), 'Connections' => __('The number of connection attempts (successful or not) to the MySQL server.'), 'Created_tmp_disk_tables' => __('The number of temporary tables on disk created automatically by the server while executing statements. If Created_tmp_disk_tables is big, you may want to increase the tmp_table_size  value to cause temporary tables to be memory-based instead of disk-based.'), 'Created_tmp_files' => __('How many temporary files mysqld has created.'), 'Created_tmp_tables' => __('The number of in-memory temporary tables created automatically by the server while executing statements.'), 'Delayed_errors' => __('The number of rows written with INSERT DELAYED for which some error occurred (probably duplicate key).'), 'Delayed_insert_threads' => __('The number of INSERT DELAYED handler threads in use. Every different table on which one uses INSERT DELAYED gets its own thread.'), 'Delayed_writes' => __('The number of INSERT DELAYED rows written.'), 'Flush_commands' => __('The number of executed FLUSH statements.'), 'Handler_commit' => __('The number of internal COMMIT statements.'), 'Handler_delete' => __('The number of times a row was deleted from a table.'), 'Handler_discover' => __('The MySQL server can ask the NDB Cluster storage engine if it knows about a table with a given name. This is called discovery. Handler_discover indicates the number of time tables have been discovered.'), 'Handler_read_first' => __('The number of times the first entry was read from an index. If this is high, it suggests that the server is doing a lot of full index scans; for example, SELECT col1 FROM foo, assuming that col1 is indexed.'), 'Handler_read_key' => __('The number of requests to read a row based on a key. If this is high, it is a good indication that your queries and tables are properly indexed.'), 'Handler_read_next' => __('The number of requests to read the next row in key order. This is incremented if you are querying an index column with a range constraint or if you are doing an index scan.'), 'Handler_read_prev' => __('The number of requests to read the previous row in key order. This read method is mainly used to optimize ORDER BY ... DESC.'), 'Handler_read_rnd' => __('The number of requests to read a row based on a fixed position. This is high if you are doing a lot of queries that require sorting of the result. You probably have a lot of queries that require MySQL to scan whole tables or you have joins that don\'t use keys properly.'), 'Handler_read_rnd_next' => __('The number of requests to read the next row in the data file. This is high if you are doing a lot of table scans. Generally this suggests that your tables are not properly indexed or that your queries are not written to take advantage of the indexes you have.'), 'Handler_rollback' => __('The number of internal ROLLBACK statements.'), 'Handler_update' => __('The number of requests to update a row in a table.'), 'Handler_write' => __('The number of requests to insert a row in a table.'), 'Innodb_buffer_pool_pages_data' => __('The number of pages containing data (dirty or clean).'), 'Innodb_buffer_pool_pages_dirty' => __('The number of pages currently dirty.'), 'Innodb_buffer_pool_pages_flushed' => __('The number of buffer pool pages that have been requested to be flushed.'), 'Innodb_buffer_pool_pages_free' => __('The number of free pages.'), 'Innodb_buffer_pool_pages_latched' => __('The number of latched pages in InnoDB buffer pool. These are pages currently being read or written or that can\'t be flushed or removed for some other reason.'), 'Innodb_buffer_pool_pages_misc' => __('The number of pages busy because they have been allocated for administrative overhead such as row locks or the adaptive hash index. This value can also be calculated as Innodb_buffer_pool_pages_total - Innodb_buffer_pool_pages_free - Innodb_buffer_pool_pages_data.'), 'Innodb_buffer_pool_pages_total' => __('Total size of buffer pool, in pages.'), 'Innodb_buffer_pool_read_ahead_rnd' => __('The number of "random" read-aheads InnoDB initiated. This happens when a query is to scan a large portion of a table but in random order.'), 'Innodb_buffer_pool_read_ahead_seq' => __('The number of sequential read-aheads InnoDB initiated. This happens when InnoDB does a sequential full table scan.'), 'Innodb_buffer_pool_read_requests' => __('The number of logical read requests InnoDB has done.'), 'Innodb_buffer_pool_reads' => __('The number of logical reads that InnoDB could not satisfy from buffer pool and had to do a single-page read.'), 'Innodb_buffer_pool_wait_free' => __('Normally, writes to the InnoDB buffer pool happen in the background. However, if it\'s necessary to read or create a page and no clean pages are available, it\'s necessary to wait for pages to be flushed first. This counter counts instances of these waits. If the buffer pool size was set properly, this value should be small.'), 'Innodb_buffer_pool_write_requests' => __('The number writes done to the InnoDB buffer pool.'), 'Innodb_data_fsyncs' => __('The number of fsync() operations so far.'), 'Innodb_data_pending_fsyncs' => __('The current number of pending fsync() operations.'), 'Innodb_data_pending_reads' => __('The current number of pending reads.'), 'Innodb_data_pending_writes' => __('The current number of pending writes.'), 'Innodb_data_read' => __('The amount of data read so far, in bytes.'), 'Innodb_data_reads' => __('The total number of data reads.'), 'Innodb_data_writes' => __('The total number of data writes.'), 'Innodb_data_written' => __('The amount of data written so far, in bytes.'), 'Innodb_dblwr_pages_written' => __('The number of pages that have been written for doublewrite operations.'), 'Innodb_dblwr_writes' => __('The number of doublewrite operations that have been performed.'), 'Innodb_log_waits' => __('The number of waits we had because log buffer was too small and we had to wait for it to be flushed before continuing.'), 'Innodb_log_write_requests' => __('The number of log write requests.'), 'Innodb_log_writes' => __('The number of physical writes to the log file.'), 'Innodb_os_log_fsyncs' => __('The number of fsync() writes done to the log file.'), 'Innodb_os_log_pending_fsyncs' => __('The number of pending log file fsyncs.'), 'Innodb_os_log_pending_writes' => __('Pending log file writes.'), 'Innodb_os_log_written' => __('The number of bytes written to the log file.'), 'Innodb_pages_created' => __('The number of pages created.'), 'Innodb_page_size' => __('The compiled-in InnoDB page size (default 16KB). Many values are counted in pages; the page size allows them to be easily converted to bytes.'), 'Innodb_pages_read' => __('The number of pages read.'), 'Innodb_pages_written' => __('The number of pages written.'), 'Innodb_row_lock_current_waits' => __('The number of row locks currently being waited for.'), 'Innodb_row_lock_time_avg' => __('The average time to acquire a row lock, in milliseconds.'), 'Innodb_row_lock_time' => __('The total time spent in acquiring row locks, in milliseconds.'), 'Innodb_row_lock_time_max' => __('The maximum time to acquire a row lock, in milliseconds.'), 'Innodb_row_lock_waits' => __('The number of times a row lock had to be waited for.'), 'Innodb_rows_deleted' => __('The number of rows deleted from InnoDB tables.'), 'Innodb_rows_inserted' => __('The number of rows inserted in InnoDB tables.'), 'Innodb_rows_read' => __('The number of rows read from InnoDB tables.'), 'Innodb_rows_updated' => __('The number of rows updated in InnoDB tables.'), 'Key_blocks_not_flushed' => __('The number of key blocks in the key cache that have changed but haven\'t yet been flushed to disk. It used to be known as Not_flushed_key_blocks.'), 'Key_blocks_unused' => __('The number of unused blocks in the key cache. You can use this value to determine how much of the key cache is in use.'), 'Key_blocks_used' => __('The number of used blocks in the key cache. This value is a high-water mark that indicates the maximum number of blocks that have ever been in use at one time.'), 'Key_read_requests' => __('The number of requests to read a key block from the cache.'), 'Key_reads' => __('The number of physical reads of a key block from disk. If Key_reads is big, then your key_buffer_size value is probably too small. The cache miss rate can be calculated as Key_reads/Key_read_requests.'), 'Key_write_requests' => __('The number of requests to write a key block to the cache.'), 'Key_writes' => __('The number of physical writes of a key block to disk.'), 'Last_query_cost' => __('The total cost of the last compiled query as computed by the query optimizer. Useful for comparing the cost of different query plans for the same query. The default value of 0 means that no query has been compiled yet.'), 'Max_used_connections' => __('The maximum number of connections that have been in use simultaneously since the server started.'), 'Not_flushed_delayed_rows' => __('The number of rows waiting to be written in INSERT DELAYED queues.'), 'Opened_tables' => __('The number of tables that have been opened. If opened tables is big, your table cache value is probably too small.'), 'Open_files' => __('The number of files that are open.'), 'Open_streams' => __('The number of streams that are open (used mainly for logging).'), 'Open_tables' => __('The number of tables that are open.'), 'Qcache_free_blocks' => __('The number of free memory blocks in query cache. High numbers can indicate fragmentation issues, which may be solved by issuing a FLUSH QUERY CACHE statement.'), 'Qcache_free_memory' => __('The amount of free memory for query cache.'), 'Qcache_hits' => __('The number of cache hits.'), 'Qcache_inserts' => __('The number of queries added to the cache.'), 'Qcache_lowmem_prunes' => __('The number of queries that have been removed from the cache to free up memory for caching new queries. This information can help you tune the query cache size. The query cache uses a least recently used (LRU) strategy to decide which queries to remove from the cache.'), 'Qcache_not_cached' => __('The number of non-cached queries (not cachable, or not cached due to the query_cache_type setting).'), 'Qcache_queries_in_cache' => __('The number of queries registered in the cache.'), 'Qcache_total_blocks' => __('The total number of blocks in the query cache.'), 'Rpl_status' => __('The status of failsafe replication (not yet implemented).'), 'Select_full_join' => __('The number of joins that do not use indexes. If this value is not 0, you should carefully check the indexes of your tables.'), 'Select_full_range_join' => __('The number of joins that used a range search on a reference table.'), 'Select_range_check' => __('The number of joins without keys that check for key usage after each row. (If this is not 0, you should carefully check the indexes of your tables.)'), 'Select_range' => __('The number of joins that used ranges on the first table. (It\'s normally not critical even if this is big.)'), 'Select_scan' => __('The number of joins that did a full scan of the first table.'), 'Slave_open_temp_tables' => __('The number of temporary tables currently open by the slave SQL thread.'), 'Slave_retried_transactions' => __('Total (since startup) number of times the replication slave SQL thread has retried transactions.'), 'Slave_running' => __('This is ON if this server is a slave that is connected to a master.'), 'Slow_launch_threads' => __('The number of threads that have taken more than slow_launch_time seconds to create.'), 'Slow_queries' => __('The number of queries that have taken more than long_query_time seconds.'), 'Sort_merge_passes' => __('The number of merge passes the sort algorithm has had to do. If this value is large, you should consider increasing the value of the sort_buffer_size system variable.'), 'Sort_range' => __('The number of sorts that were done with ranges.'), 'Sort_rows' => __('The number of sorted rows.'), 'Sort_scan' => __('The number of sorts that were done by scanning the table.'), 'Table_locks_immediate' => __('The number of times that a table lock was acquired immediately.'), 'Table_locks_waited' => __('The number of times that a table lock could not be acquired immediately and a wait was needed. If this is high, and you have performance problems, you should first optimize your queries, and then either split your table or tables or use replication.'), 'Threads_cached' => __('The number of threads in the thread cache. The cache hit rate can be calculated as Threads_created/Connections. If this value is red you should raise your thread_cache_size.'), 'Threads_connected' => __('The number of currently open connections.'), 'Threads_created' => __('The number of threads created to handle connections. If Threads_created is big, you may want to increase the thread_cache_size value. (Normally this doesn\'t give a notable performance improvement if you have a good thread implementation.)'), 'Threads_running' => __('The number of threads that are not sleeping.'));
    /**
     * define some alerts
     */
    // name => max value before alert
    $alerts = array('Aborted_clients' => 0, 'Aborted_connects' => 0, 'Binlog_cache_disk_use' => 0, 'Created_tmp_disk_tables' => 0, 'Handler_read_rnd' => 0, 'Handler_read_rnd_next' => 0, 'Innodb_buffer_pool_pages_dirty' => 0, 'Innodb_buffer_pool_reads' => 0, 'Innodb_buffer_pool_wait_free' => 0, 'Innodb_log_waits' => 0, 'Innodb_row_lock_time_avg' => 10, 'Innodb_row_lock_time_max' => 50, 'Innodb_row_lock_waits' => 0, 'Slow_queries' => 0, 'Delayed_errors' => 0, 'Select_full_join' => 0, 'Select_range_check' => 0, 'Sort_merge_passes' => 0, 'Opened_tables' => 0, 'Table_locks_waited' => 0, 'Qcache_lowmem_prunes' => 0, 'Qcache_free_blocks' => isset($server_status['Qcache_total_blocks']) ? $server_status['Qcache_total_blocks'] / 5 : 0, 'Slow_launch_threads' => 0, 'Key_reads' => isset($server_status['Key_read_requests']) ? 0.01 * $server_status['Key_read_requests'] : 0, 'Key_writes' => isset($server_status['Key_write_requests']) ? 0.9 * $server_status['Key_write_requests'] : 0, 'Key_buffer_fraction' => 0.5, 'Threads_cached' => isset($server_variables['thread_cache_size']) ? 0.95 * $server_variables['thread_cache_size'] : 0);
    ?>
<table class="data sortable noclick" id="serverstatusvariables">
    <col class="namecol" />
    <col class="valuecol" />
    <col class="descrcol" />
    <thead>
        <tr>
            <th><?php 
    echo __('Variable');
    ?>
</th>
            <th><?php 
    echo __('Value');
    ?>
</th>
            <th><?php 
    echo __('Description');
    ?>
</th>
        </tr>
    </thead>
    <tbody>
    <?php 
    $odd_row = false;
    foreach ($server_status as $name => $value) {
        $odd_row = !$odd_row;
        ?>
        <tr class="<?php 
        echo $odd_row ? 'odd' : 'even';
        echo isset($allocationMap[$name]) ? ' s_' . $allocationMap[$name] : '';
        ?>
">
            <th class="name"><?php 
        echo htmlspecialchars(str_replace('_', ' ', $name));
        /* Fields containing % are calculated, they can not be described in MySQL documentation */
        if (strpos($name, '%') === FALSE) {
            echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name);
        }
        ?>
            </th>
            <td class="value"><span class="formatted"><?php 
        if (isset($alerts[$name])) {
            if ($value > $alerts[$name]) {
                echo '<span class="attention">';
            } else {
                echo '<span class="allfine">';
            }
        }
        if ('%' === substr($name, -1, 1)) {
            echo htmlspecialchars(PMA_formatNumber($value, 0, 2)) . ' %';
        } elseif (strpos($name, 'Uptime') !== false) {
            echo htmlspecialchars(PMA_timespanFormat($value));
        } elseif (is_numeric($value) && $value == (int) $value && $value > 1000) {
            echo htmlspecialchars(PMA_formatNumber($value, 3, 1));
        } elseif (is_numeric($value) && $value == (int) $value) {
            echo htmlspecialchars(PMA_formatNumber($value, 3, 0));
        } elseif (is_numeric($value)) {
            echo htmlspecialchars(PMA_formatNumber($value, 3, 1));
        } else {
            echo htmlspecialchars($value);
        }
        if (isset($alerts[$name])) {
            echo '</span>';
        }
        ?>
</span><span style="display:none;" class="original"><?php 
        echo $value;
        ?>
</span>
            </td>
            <td class="descr">
            <?php 
        if (isset($strShowStatus[$name])) {
            echo $strShowStatus[$name];
        }
        if (isset($links[$name])) {
            foreach ($links[$name] as $link_name => $link_url) {
                if ('doc' == $link_name) {
                    echo PMA_showMySQLDocu($link_url, $link_url);
                } else {
                    echo ' <a href="' . $link_url . '">' . $link_name . '</a>' . "\n";
                }
            }
            unset($link_url, $link_name);
        }
        ?>
            </td>
        </tr>
    <?php 
    }
    ?>
    </tbody>
    </table>
    <?php 
}
Пример #3
0
 /**
  * Displays a MySQL error message in the right frame.
  *
  * @param   string   the error message
  * @param   string   the sql query that failed
  * @param   boolean  whether to show a "modify" link or not
  * @param   string   the "back" link url (full path is not required)
  * @param   boolean  EXIT the page?
  *
  * @global  array    the configuration array
  *
  * @access  public
  */
 function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = TRUE, $back_url = '', $exit = TRUE)
 {
     global $cfg, $table, $db, $sql_query;
     require_once './header.inc.php';
     if (!$error_message) {
         $error_message = PMA_DBI_getError();
     }
     if (!$the_query && !empty($GLOBALS['sql_query'])) {
         $the_query = $GLOBALS['sql_query'];
     }
     // --- Added to solve bug #641765
     // Robbat2 - 12 January 2003, 9:46PM
     // Revised, Robbat2 - 13 Janurary 2003, 2:59PM
     if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
         $formatted_sql = htmlspecialchars($the_query);
     } else {
         $formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
     }
     // ---
     echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
     echo '    <table border="0" cellpadding="2" cellspacing="1">' . '        <tr>' . "\n" . '            <th class="tblHeadError"><div class="errorhead">' . $GLOBALS['strError'] . '</div></th>' . "\n" . '        </tr>' . "\n" . '        <tr>' . "\n" . '            <td>';
     // if the config password is wrong, or the MySQL server does not
     // respond, do not show the query that would reveal the
     // username/password
     if (!empty($the_query) && !strstr($the_query, 'connect')) {
         // --- Added to solve bug #641765
         // Robbat2 - 12 January 2003, 9:46PM
         // Revised, Robbat2 - 13 Janurary 2003, 2:59PM
         if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
             echo PMA_SQP_getErrorString();
         }
         // ---
         // modified to show me the help on sql errors (Michael Keck)
         echo '<div class="tblWarn"><p>' . "\n";
         echo '    <b>' . $GLOBALS['strSQLQuery'] . ':</b>' . "\n";
         if (strstr(strtolower($formatted_sql), 'select')) {
             // please show me help to the error on select
             echo PMA_showMySQLDocu('Reference', 'SELECT');
         }
         if ($is_modify_link && isset($db)) {
             if (isset($table)) {
                 $doedit_goto = '<a href="tbl_properties.php?' . PMA_generate_common_url($db, $table) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">';
             } else {
                 $doedit_goto = '<a href="db_details.php?' . PMA_generate_common_url($db) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">';
             }
             if ($GLOBALS['cfg']['PropertiesIconic']) {
                 echo $doedit_goto . '<img src=" ' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" width="16" height="16" border="0" hspace="2" align="middle" alt="' . $GLOBALS['strEdit'] . '" />' . '</a>';
             } else {
                 echo '    [' . $doedit_goto . $GLOBALS['strEdit'] . '</a>' . ']' . "\n";
             }
         }
         // end if
         echo '</p>' . "\n" . '<p>' . "\n" . '    ' . $formatted_sql . "\n" . '</p></div>' . "\n";
     }
     // end if
     $tmp_mysql_error = '';
     // for saving the original $error_message
     if (!empty($error_message)) {
         $tmp_mysql_error = strtolower($error_message);
         // save the original $error_message
         $error_message = htmlspecialchars($error_message);
         $error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
     }
     // modified to show me the help on error-returns (Michael Keck)
     echo '<div class="tblWarn"><p>' . "\n" . '    <b>' . $GLOBALS['strMySQLSaid'] . '</b>' . PMA_showMySQLDocu('Error-returns', 'Error-returns') . "\n" . '</p>' . "\n";
     // The error message will be displayed within a CODE segment.
     // To preserve original formatting, but allow wordwrapping, we do a couple of replacements
     // Replace all non-single blanks with their HTML-counterpart
     $error_message = str_replace('  ', '&nbsp;&nbsp;', $error_message);
     // Replace TAB-characters with their HTML-counterpart
     $error_message = str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $error_message);
     // Replace linebreaks
     $error_message = nl2br($error_message);
     echo '<code>' . "\n" . $error_message . "\n" . '</code><br />' . "\n";
     // feature request #1036254:
     // Add a link by MySQL-Error #1062 - Duplicate entry
     // 2004-10-20 by mk.keck
     if (substr($error_message, 1, 4) == '1062') {
         // TODO: do not assume that the error message is in English
         // and do not use mysql_result()
         // explode the entry and the column
         $arr_mysql_val_key = explode('entry \'', $tmp_mysql_error);
         $arr_mysql_val_key = explode('\' for key', $arr_mysql_val_key[1]);
         // get the duplicate value
         $string_duplicate_val = trim(strtolower($arr_mysql_val_key[0]));
         // get the field name ...
         $string_duplicate_key = mysql_result(mysql_query("SHOW FIELDS FROM " . $table), $arr_mysql_val_key[1] - 1, 0);
         $duplicate_sql_query = "SELECT * FROM " . $table . " WHERE " . $string_duplicate_key . " LIKE '" . $string_duplicate_val . "'";
         echo '        <form method="post" action="read_dump.php" style="padding: 0px; margin: 0px">' . "\n" . '            <input type="hidden" name="sql_query" value="' . $duplicate_sql_query . '" />' . "\n" . '            ' . PMA_generate_common_hidden_inputs($db, $table) . "\n" . '            <input type="submit" name="submit" value="' . $GLOBALS['strBrowse'] . '" />' . "\n" . '        </form>' . "\n";
     }
     // end of show duplicate entry
     echo '</div>';
     if (!empty($back_url) && $exit) {
         $goto_back_url = '<a href="' . (strstr($back_url, '?') ? $back_url . '&amp;no_history=true' : $back_url . '?no_history=true') . '">&nbsp;';
         echo '            </td> ' . "\n" . '        </tr>' . "\n" . '        <tr><td class="tblHeaders" align="center">';
         echo '[' . $goto_back_url . $GLOBALS['strBack'] . '&nbsp;</a>]';
     }
     echo '            </td>' . "\n" . '        </tr>' . "\n" . '    </table>' . "\n\n";
     if ($exit) {
         require_once './footer.inc.php';
     }
 }
        <td width="25">&nbsp;</td>
        <td>
    <?php 
    echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, isset($_REQUEST['tbl_collation']) ? $_REQUEST['tbl_collation'] : null, false, 3);
    ?>
        </td>
    </tr>
    <?php 
    if (PMA_Partition::havePartitioning()) {
        ?>
    <tr valign="top">
        <th><?php 
        echo __('PARTITION definition');
        ?>
:&nbsp;<?php 
        echo PMA_showMySQLDocu('Partitioning', 'Partitioning');
        ?>
        </th>
    </tr>
    <tr>
        <td>
            <textarea name="partition_definition" id="partitiondefinition"
                cols="<?php 
        echo $GLOBALS['cfg']['TextareaCols'];
        ?>
"
                rows="<?php 
        echo $GLOBALS['cfg']['TextareaRows'];
        ?>
"
                dir="<?php 
Пример #5
0
/**
 * Displays a MySQL error message in the right frame.
 *
 * @param string $error_message  the error message
 * @param string $the_query      the sql query that failed
 * @param bool   $is_modify_link whether to show a "modify" link or not
 * @param string $back_url       the "back" link url (full path is not required)
 * @param bool   $exit           EXIT the page?
 *
 * @global  string    the curent table
 * @global  string    the current db
 *
 * @access  public
 */
function PMA_mysqlDie($error_message = '', $the_query = '', $is_modify_link = true, $back_url = '', $exit = true)
{
    global $table, $db;
    /**
     * start http output, display html headers
     */
    include_once './libraries/header.inc.php';
    $error_msg_output = '';
    if (!$error_message) {
        $error_message = PMA_DBI_getError();
    }
    if (!$the_query && !empty($GLOBALS['sql_query'])) {
        $the_query = $GLOBALS['sql_query'];
    }
    // --- Added to solve bug #641765
    if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {
        $formatted_sql = htmlspecialchars($the_query);
    } elseif (empty($the_query) || trim($the_query) == '') {
        $formatted_sql = '';
    } else {
        if (strlen($the_query) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
            $formatted_sql = htmlspecialchars(substr($the_query, 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
        } else {
            $formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
        }
    }
    // ---
    $error_msg_output .= "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
    $error_msg_output .= '    <div class="error"><h1>' . __('Error') . '</h1>' . "\n";
    // if the config password is wrong, or the MySQL server does not
    // respond, do not show the query that would reveal the
    // username/password
    if (!empty($the_query) && !strstr($the_query, 'connect')) {
        // --- Added to solve bug #641765
        if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
            $error_msg_output .= PMA_SQP_getErrorString() . "\n";
            $error_msg_output .= '<br />' . "\n";
        }
        // ---
        // modified to show the help on sql errors
        $error_msg_output .= '    <p><strong>' . __('SQL query') . ':</strong>' . "\n";
        if (strstr(strtolower($formatted_sql), 'select')) {
            // please show me help to the error on select
            $error_msg_output .= PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
        }
        if ($is_modify_link) {
            $_url_params = array('sql_query' => $the_query, 'show_query' => 1);
            if (strlen($table)) {
                $_url_params['db'] = $db;
                $_url_params['table'] = $table;
                $doedit_goto = '<a href="tbl_sql.php' . PMA_generate_common_url($_url_params) . '">';
            } elseif (strlen($db)) {
                $_url_params['db'] = $db;
                $doedit_goto = '<a href="db_sql.php' . PMA_generate_common_url($_url_params) . '">';
            } else {
                $doedit_goto = '<a href="server_sql.php' . PMA_generate_common_url($_url_params) . '">';
            }
            $error_msg_output .= $doedit_goto . PMA_getIcon('b_edit.png', __('Edit')) . '</a>';
        }
        // end if
        $error_msg_output .= '    </p>' . "\n" . '    <p>' . "\n" . '        ' . $formatted_sql . "\n" . '    </p>' . "\n";
    }
    // end if
    if (!empty($error_message)) {
        $error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
    }
    // modified to show the help on error-returns
    // (now error-messages-server)
    $error_msg_output .= '<p>' . "\n" . '    <strong>' . __('MySQL said: ') . '</strong>' . PMA_showMySQLDocu('Error-messages-server', 'Error-messages-server') . "\n" . '</p>' . "\n";
    // The error message will be displayed within a CODE segment.
    // To preserve original formatting, but allow wordwrapping,
    // we do a couple of replacements
    // Replace all non-single blanks with their HTML-counterpart
    $error_message = str_replace('  ', '&nbsp;&nbsp;', $error_message);
    // Replace TAB-characters with their HTML-counterpart
    $error_message = str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $error_message);
    // Replace linebreaks
    $error_message = nl2br($error_message);
    $error_msg_output .= '<code>' . "\n" . $error_message . "\n" . '</code><br />' . "\n";
    $error_msg_output .= '</div>';
    $_SESSION['Import_message']['message'] = $error_msg_output;
    if ($exit) {
        /**
         * If in an Ajax request
         * - avoid displaying a Back link
         * - use PMA_ajaxResponse() to transmit the message and exit
         */
        if ($GLOBALS['is_ajax_request'] == true) {
            PMA_ajaxResponse($error_msg_output, false);
        }
        if (!empty($back_url)) {
            if (strstr($back_url, '?')) {
                $back_url .= '&amp;no_history=true';
            } else {
                $back_url .= '?no_history=true';
            }
            $_SESSION['Import_message']['go_back_url'] = $back_url;
            $error_msg_output .= '<fieldset class="tblFooters">';
            $error_msg_output .= '[ <a href="' . $back_url . '">' . __('Back') . '</a> ]';
            $error_msg_output .= '</fieldset>' . "\n\n";
        }
        echo $error_msg_output;
        /**
         * display footer and exit
         */
        include './libraries/footer.inc.php';
    } else {
        echo $error_msg_output;
    }
}
        echo $GLOBALS['cfg']['MainPageIconic'] ? '' : ' - ';
        echo '<a href="index.php?' . $query_url . '&amp;old_usr='******'" target="_parent"' . ' title="' . $strLogout . '" >' . ($GLOBALS['cfg']['MainPageIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 's_loggoff.png" ' . ' width="16" height="16" alt="' . $strLogout . '" />' : $strLogout) . '</a>' . "\n";
    }
    // end if ($GLOBALS['cfg']['Server']['auth_type'] != 'config'
    $anchor = 'querywindow.php?' . PMA_generate_common_url($db, $table);
    if ($GLOBALS['cfg']['MainPageIconic']) {
        $query_frame_link_text = '<img class="icon" src="' . $pmaThemeImage . 'b_selboard.png"' . ' width="16" height="16" alt="' . $strQueryFrame . '" />';
    } else {
        echo '<br />' . "\n";
        $query_frame_link_text = $strQueryFrame;
    }
    echo '<a href="' . $anchor . '&amp;no_js=true"' . ' title="' . $strQueryFrame . '"';
    echo ' onclick="javascript:if (window.parent.open_querywindow()) return false;"';
    echo '>' . $query_frame_link_text . '</a>' . "\n";
}
// end if ($server != 0)
if ($GLOBALS['cfg']['MainPageIconic']) {
    echo '    <a href="Documentation.html" target="documentation"' . ' title="' . $strPmaDocumentation . '" >' . '<img class="icon" src="' . $pmaThemeImage . 'b_docs.png" width="16" height="16"' . ' alt="' . $strPmaDocumentation . '" /></a>' . "\n";
    echo '    ' . PMA_showMySQLDocu('', '', TRUE) . "\n";
}
echo '</div>' . "\n";
/**
 * Displays the MySQL servers choice form
 */
if ($GLOBALS['cfg']['LeftDisplayServers'] && (count($GLOBALS['cfg']['Servers']) > 1 || $server == 0 && count($GLOBALS['cfg']['Servers']) == 1)) {
    echo '<div id="serverinfo">';
    include './libraries/select_server.lib.php';
    PMA_select_server(true, true);
    echo '</div><br />';
}
// end if LeftDisplayServers
Пример #7
0
/**
 * prints querybox fieldset
 *
 * @usedby  PMA_sqlQueryForm()
 * @uses    $GLOBALS['text_dir']
 * @uses    $GLOBALS['cfg']['TextareaAutoSelect']
 * @uses    $GLOBALS['cfg']['TextareaCols']
 * @uses    $GLOBALS['cfg']['TextareaRows']
 * @uses    $GLOBALS['strShowThisQuery']
 * @uses    $GLOBALS['strGo']
 * @uses    PMA_availableDatabases()
 * @uses    PMA_USR_OS
 * @uses    PMA_USR_BROWSER_AGENT
 * @uses    PMA_USR_BROWSER_VER
 * @uses    PMA_availableDatabases()
 * @uses    htmlspecialchars()
 * @param   string      $query          query to display in the textarea
 * @param   boolean     $is_querywindow if inside querywindow or not
 */
function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false)
{
    // enable auto select text in textarea
    if ($GLOBALS['cfg']['TextareaAutoSelect']) {
        $auto_sel = ' onfocus="selectContent( this, sql_box_locked, true )"';
    } else {
        $auto_sel = '';
    }
    // enable locking if inside query window
    if ($is_querywindow) {
        $locking = ' onkeypress="document.sqlform.elements[\'LockFromUpdate\'].' . 'checked = true;"';
    } else {
        $locking = '';
    }
    $table = '';
    $db = '';
    $fields_list = array();
    if (!isset($GLOBALS['db']) || !strlen($GLOBALS['db'])) {
        // prepare for server related
        $legend = sprintf($GLOBALS['strRunSQLQueryOnServer'], htmlspecialchars($GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host']));
    } elseif (!isset($GLOBALS['table']) || !strlen($GLOBALS['table'])) {
        // prepare for db related
        $db = $GLOBALS['db'];
        // if you want navigation:
        $strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db) . '"';
        if ($is_querywindow) {
            $strDBLink .= ' target="_self"' . ' onclick="this.target=window.opener.frames[1].name"';
        }
        $strDBLink .= '>' . htmlspecialchars($db) . '</a>';
        // else use
        // $strDBLink = htmlspecialchars($db);
        $legend = sprintf($GLOBALS['strRunSQLQuery'], $strDBLink);
        if (empty($query)) {
            $query = str_replace('%d', PMA_backquote($db), $GLOBALS['cfg']['DefaultQueryDatabase']);
        }
    } else {
        $table = $GLOBALS['table'];
        $db = $GLOBALS['db'];
        // Get the list and number of fields
        // we do a try_query here, because we could be in the query window,
        // trying to synchonize and the table has not yet been created
        $fields_list = PMA_DBI_fetch_result('SHOW FULL COLUMNS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($GLOBALS['table']));
        $strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db) . '"';
        if ($is_querywindow) {
            $strDBLink .= ' target="_self"' . ' onclick="this.target=window.opener.frames[1].name"';
        }
        $strDBLink .= '>' . htmlspecialchars($db) . '</a>';
        // else use
        // $strDBLink = htmlspecialchars($db);
        $legend = sprintf($GLOBALS['strRunSQLQuery'], $strDBLink);
        if (empty($query) && count($fields_list)) {
            $field_names = array();
            foreach ($fields_list as $field) {
                $field_names[] = PMA_backquote($field['Field']);
            }
            $query = str_replace('%d', PMA_backquote($db), str_replace('%t', PMA_backquote($table), str_replace('%f', implode(', ', $field_names), $GLOBALS['cfg']['DefaultQueryTable'])));
            unset($field_names);
        }
    }
    $legend .= ': ' . PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
    if (count($fields_list)) {
        $sqlquerycontainer_id = 'sqlquerycontainer';
    } else {
        $sqlquerycontainer_id = 'sqlquerycontainerfull';
    }
    echo '<a name="querybox"></a>' . "\n" . '<div id="queryboxcontainer">' . "\n" . '<fieldset id="querybox">' . "\n";
    echo '<legend>' . $legend . '</legend>' . "\n";
    echo '<div id="queryfieldscontainer">' . "\n";
    echo '<div id="' . $sqlquerycontainer_id . '">' . "\n" . '<textarea name="sql_query" id="sqlquery"' . '  cols="' . $GLOBALS['cfg']['TextareaCols'] . '"' . '  rows="' . $GLOBALS['cfg']['TextareaRows'] . '"' . '  dir="' . $GLOBALS['text_dir'] . '"' . $auto_sel . $locking . '>' . htmlspecialchars($query) . '</textarea>' . "\n";
    echo '</div>' . "\n";
    if (count($fields_list)) {
        echo '<div id="tablefieldscontainer">' . "\n" . '<label>' . $GLOBALS['strFields'] . '</label>' . "\n" . '<select id="tablefields" name="dummy" ' . 'size="' . ($GLOBALS['cfg']['TextareaRows'] - 2) . '" ' . 'multiple="multiple" ondblclick="insertValueQuery()">' . "\n";
        foreach ($fields_list as $field) {
            echo '<option value="' . PMA_backquote(htmlspecialchars($field['Field'])) . '"';
            if (isset($field['Field']) && strlen($field['Field']) && isset($field['Comment'])) {
                echo ' title="' . htmlspecialchars($field['Comment']) . '"';
            }
            echo '>' . htmlspecialchars($field['Field']) . '</option>' . "\n";
        }
        echo '</select>' . "\n" . '<div id="tablefieldinsertbuttoncontainer">' . "\n";
        if ($GLOBALS['cfg']['PropertiesIconic']) {
            echo '<input type="button" name="insert" value="&lt;&lt;"' . ' onclick="insertValueQuery()"' . ' title="' . $GLOBALS['strInsert'] . '" />' . "\n";
        } else {
            echo '<input type="button" name="insert"' . ' value="' . $GLOBALS['strInsert'] . '"' . ' onclick="insertValueQuery()" />' . "\n";
        }
        echo '</div>' . "\n" . '</div>' . "\n";
    }
    echo '<div class="clearfloat"></div>' . "\n";
    echo '</div>' . "\n";
    if (!empty($GLOBALS['cfg']['Bookmark']) && $GLOBALS['cfg']['Bookmark']['db'] && $GLOBALS['cfg']['Bookmark']['table']) {
        ?>
        <div id="bookmarkoptions">
        <div class="formelement">
        <label for="bkm_label">
            <?php 
        echo $GLOBALS['strBookmarkThis'];
        ?>
:</label>
        <input type="text" name="bkm_label" id="bkm_label" value="" />
        </div>
        <div class="formelement">
        <input type="checkbox" name="bkm_all_users" id="id_bkm_all_users"
            value="true" />
        <label for="id_bkm_all_users">
            <?php 
        echo $GLOBALS['strBookmarkAllUsers'];
        ?>
</label>
        </div>
        <div class="formelement">
        <input type="checkbox" name="bkm_replace" id="id_bkm_replace"
            value="true" />
        <label for="id_bkm_replace">
            <?php 
        echo $GLOBALS['strBookmarkReplace'];
        ?>
</label>
        </div>
        </div>
        <?php 
    }
    echo '<div class="clearfloat"></div>' . "\n";
    echo '</fieldset>' . "\n" . '</div>' . "\n";
    echo '<fieldset id="queryboxfooter" class="tblFooters">' . "\n";
    echo '<div class="formelement">' . "\n";
    if ($is_querywindow) {
        ?>
        <script type="text/javascript" language="javascript">
        //<![CDATA[
            document.writeln(' <input type="checkbox" name="LockFromUpdate" value="1" id="checkbox_lock" /> <label for="checkbox_lock"><?php 
        echo $GLOBALS['strQueryWindowLock'];
        ?>
</label> ');
        //]]>
        </script>
        <?php 
    }
    echo '</div>' . "\n";
    echo '<div class="formelement">' . "\n";
    echo '<input type="checkbox" name="show_query" value="1" ' . 'id="checkbox_show_query" checked="checked" />' . "\n" . '<label for="checkbox_show_query">' . $GLOBALS['strShowThisQuery'] . '</label>' . "\n";
    echo '</div>' . "\n";
    echo '<input type="submit" name="SQL" value="' . $GLOBALS['strGo'] . '" />' . "\n";
    echo '<div class="clearfloat"></div>' . "\n";
    echo '</fieldset>' . "\n";
}
Пример #8
0
    }

    if (isset($profiling_results)) {
        // pma_token/url_query needed for chart export
?>
<script type="text/javascript">
pma_token = '<?php echo $_SESSION[' PMA_token ']; ?>';
url_query = '<?php echo isset($url_query)?$url_query:PMA_generate_common_url($db);?>';
$(document).ready(makeProfilingChart);
</script>
<?php
        echo '<fieldset><legend>' . __('Profiling') . '</legend>' . "\n";
        echo '<div style="float: left;">';
        echo '<table>' . "\n";
        echo ' <tr>' .  "\n";
        echo '  <th>' . __('Status') . PMA_showMySQLDocu('general-thread-states', 'general-thread-states') .  '</th>' . "\n";
        echo '  <th>' . __('Time') . '</th>' . "\n";
        echo ' </tr>' .  "\n";

        $chart_json = Array();
        foreach ($profiling_results as $one_result) {
            echo ' <tr>' .  "\n";
            echo '<td>' . ucwords($one_result['Status']) . '</td>' .  "\n";
            echo '<td class="right">' . (PMA_formatNumber($one_result['Duration'], 3, 1)) . 's</td>' .  "\n";
            $chart_json[ucwords($one_result['Status'])] = $one_result['Duration'];
        }

        echo '</table>' . "\n";
        echo '</div>';
        //require_once 'libraries/chart.lib.php';
        echo '<div id="profilingchart" style="display:none;">';
Пример #9
0
         */
        ?>
    <!-- Indexes form -->
    <form action="./tbl_indexes.php" method="post" onsubmit="return checkFormElementInRange(this, 'idx_num_fields', '<?php 
        echo str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']);
        ?>
', 1)">
    <table border="0" cellpadding="2" cellspacing="1">
    <tr><td class="tblHeaders" colspan="7">
        <?php 
        echo PMA_generate_common_hidden_inputs($db, $table);
        ?>
    <?php 
        echo "\n";
        echo '        ' . $strIndexes . ':' . "\n";
        echo '        ' . PMA_showMySQLDocu('optimization', 'optimizing-database-structure') . "\n";
        ?>
</td></tr><?php 
        $edit_link_text = '';
        $drop_link_text = '';
        // We need to copy the value or else the == 'both' check will always return true
        $propicon = (string) $cfg['PropertiesIconic'];
        if ($cfg['PropertiesIconic'] === true || $propicon == 'both') {
            $edit_link_text = '<img src="' . $pmaThemeImage . 'b_edit.png" width="16" height="16" hspace="2" border="0" title="' . $strEdit . '" alt="' . $strEdit . '" />';
            $drop_link_text = '<img src="' . $pmaThemeImage . 'b_drop.png" width="16" height="16" hspace="2" border="0" title="' . $strDrop . '" alt="' . $strDrop . '" />';
        }
        if ($cfg['PropertiesIconic'] === false || $propicon == 'both') {
            $edit_link_text .= $strEdit;
            $drop_link_text .= $strDrop;
        }
        if ($propicon == 'both') {
Пример #10
0
        $this_sql_query = 'DROP DATABASE ' . PMA_backquote($GLOBALS['db']);
        $this_url_params = array('sql_query' => $this_sql_query, 'back' => 'db_operations.php', 'goto' => 'main.php', 'reload' => '1', 'purge' => '1', 'message_to_show' => sprintf(__('Database %s has been dropped.'), htmlspecialchars(PMA_backquote($db))), 'db' => null);
        ?>
        <li><a href="sql.php<?php 
        echo PMA_generate_common_url($this_url_params);
        ?>
" <?php 
        echo $GLOBALS['cfg']['AjaxEnable'] ? 'id="drop_db_anchor"' : '';
        ?>
>
            <?php 
        echo __('Drop the database (DROP)');
        ?>
</a>
        <?php 
        echo PMA_showMySQLDocu('SQL-Syntax', 'DROP_DATABASE');
        ?>
    </li>
</ul>
</fieldset>
</div>
<?php 
    }
    /**
     * Copy database
     */
    ?>
        <div class="operations_half_width clearfloat">
        <form id="copy_db_form" <?php 
    echo $GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax" ' : '';
    ?>
Пример #11
0
    echo ' enctype="multipart/form-data"';
}
?>
 onsubmit="return checkSqlQuery(this)" name="sqlform">
<?php 
echo $strHiddenFields;
?>
<a name="querybox"></a>
<table border="0" cellpadding="2" cellspacing="0">
<tr><td class="tblHeaders" colspan="2">
    <?php 
// if you want navigation:
$strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url() . '&amp;db=' . urlencode($db) . '">' . htmlspecialchars($db) . '</a>';
// else use
// $strDBLink = htmlspecialchars($db);
echo '&nbsp;' . sprintf($strRunSQLQuery, $strDBLink) . ':&nbsp;' . PMA_showMySQLDocu('Reference', 'SELECT');
?>
</td></tr>
<tr align="center" bgcolor="<?php 
echo $cfg['BgcolorOne'];
?>
"><td colspan="2">
<textarea name="sql_query" cols="<?php 
echo $cfg['TextareaCols'] * 2;
?>
" rows="<?php 
echo $cfg['TextareaRows'];
?>
" dir="<?php 
echo $text_dir;
?>
 /**
  * Show index data
  *
  * @param   string      $table          The tablename
  * @param   array       $indexes_info   Referenced info array
  * @param   array       $indexes_data   Referenced data array
  * @param   boolean     $print_mode
  * @access  public
  * @return  array       Index collection array
  */
 public static function getView($table, $schema, $print_mode = false)
 {
     $indexes = PMA_Index::getFromTable($table, $schema);
     if (count($indexes) < 1) {
         return PMA_Message::error(__('No index defined!'))->getDisplay();
     }
     $r = '';
     $r .= '<h2>' . __('Indexes') . ': ';
     $r .= PMA_showMySQLDocu('optimization', 'optimizing-database-structure');
     $r .= '</h2>';
     $r .= '<table>';
     $r .= '<thead>';
     $r .= '<tr>';
     if (!$print_mode) {
         $r .= '<th colspan="2">' . __('Action') . '</th>';
     }
     $r .= '<th>' . __('Keyname') . '</th>';
     $r .= '<th>' . __('Type') . '</th>';
     $r .= '<th>' . __('Unique') . '</th>';
     $r .= '<th>' . __('Packed') . '</th>';
     $r .= '<th>' . __('Column') . '</th>';
     $r .= '<th>' . __('Cardinality') . '</th>';
     $r .= '<th>' . __('Collation') . '</th>';
     $r .= '<th>' . __('Null') . '</th>';
     $r .= '<th>' . __('Comment') . '</th>';
     $r .= '</tr>';
     $r .= '</thead>';
     $r .= '<tbody>';
     $odd_row = true;
     foreach ($indexes as $index) {
         $row_span = ' rowspan="' . $index->getColumnCount() . '" ';
         $r .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
         if (!$print_mode) {
             $this_params = $GLOBALS['url_params'];
             $this_params['index'] = $index->getName();
             $r .= '<td ' . $row_span . '>' . '    <a href="tbl_indexes.php' . PMA_generate_common_url($this_params) . '">' . PMA_getIcon('b_edit.png', __('Edit')) . '</a>' . '</td>' . "\n";
             $this_params = $GLOBALS['url_params'];
             if ($index->getName() == 'PRIMARY') {
                 $this_params['sql_query'] = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP PRIMARY KEY';
                 $this_params['message_to_show'] = __('The primary key has been dropped');
                 $js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP PRIMARY KEY');
             } else {
                 $this_params['sql_query'] = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP INDEX ' . PMA_backquote($index->getName());
                 $this_params['message_to_show'] = sprintf(__('Index %s has been dropped'), $index->getName());
                 $js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP INDEX ' . $index->getName());
             }
             $r .= '<td ' . $row_span . '>';
             $r .= '<input type="hidden" class="drop_primary_key_index_msg" value="' . $js_msg . '" />';
             $r .= '    <a ';
             if ($GLOBALS['cfg']['AjaxEnable']) {
                 $r .= 'class="drop_primary_key_index_anchor" ';
             }
             $r .= ' href="sql.php' . PMA_generate_common_url($this_params) . '" >' . PMA_getIcon('b_drop.png', __('Drop')) . '</a>' . '</td>' . "\n";
         }
         $r .= '<th ' . $row_span . '>' . htmlspecialchars($index->getName()) . '</th>';
         $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getType()) . '</td>';
         $r .= '<td ' . $row_span . '>' . $index->isUnique(true) . '</td>';
         $r .= '<td ' . $row_span . '>' . $index->isPacked(true) . '</td>';
         foreach ($index->getColumns() as $column) {
             if ($column->getSeqInIndex() > 1) {
                 $r .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
             }
             $r .= '<td>' . htmlspecialchars($column->getName());
             if ($column->getSubPart()) {
                 $r .= ' (' . $column->getSubPart() . ')';
             }
             $r .= '</td>';
             $r .= '<td>' . htmlspecialchars($column->getCardinality()) . '</td>';
             $r .= '<td>' . htmlspecialchars($column->getCollation()) . '</td>';
             $r .= '<td>' . htmlspecialchars($column->getNull()) . '</td>';
             if ($column->getSeqInIndex() == 1) {
                 $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getComments()) . '</td>';
             }
             $r .= '</tr>';
         }
         // end foreach $index['Sequences']
         $odd_row = !$odd_row;
     }
     // end while
     $r .= '</tbody>';
     $r .= '</table>';
     if (!$print_mode) {
         $r .= PMA_Index::findDuplicates($table, $schema);
     }
     return $r;
 }
Пример #13
0
</tr>
</thead>
<tbody>
<?php
$odd_row = true;
foreach ($serverVars as $name => $value) {
    $has_session_value = isset($serverVarsSession[$name]) && $serverVarsSession[$name] != $value;
    $row_class = ($odd_row ? 'odd' : 'even') . ' ' . ($has_session_value ? 'diffSession' : '');
    ?>
<tr class="<?php echo $row_class; ?>">
    <th class="nowrap"><?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?></th>
    <td class="value"><?php echo formatVariable($name, $value); ?></td>
    <td class="value"><?php
    // To display variable documentation link
    if (isset($VARIABLE_DOC_LINKS[$name])) {
        echo PMA_showMySQLDocu($VARIABLE_DOC_LINKS[$name][1], $VARIABLE_DOC_LINKS[$name][1], false, $VARIABLE_DOC_LINKS[$name][2] . '_' . $VARIABLE_DOC_LINKS[$name][0]);
    }
    ?></td>
    <?php
    if ($has_session_value) {
        ?>
</tr>
<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?> ">
    <td>(<?php echo __('Session value'); ?>)</td>
    <td class="value"><?php echo formatVariable($name, $serverVarsSession[$name]); ?></td>
    <td class="value"></td>
    <?php } ?>
</tr>
    <?php
    $odd_row = ! $odd_row;
}
    echo PMA_generate_common_hidden_inputs('', '', 5);
    ?>
            <input type="hidden" name="reload" value="1" />
            <input type="text" name="new_db" value="<?php 
    echo $db_to_create;
    ?>
" maxlength="64" class="textfield" id="text_create_db"/>
    <?php 
    include_once './libraries/mysql_charsets.lib.php';
    echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', null, null, true, 5);
    if (!empty($dbstats)) {
        echo '<input type="hidden" name="dbstats" value="1" />';
    }
    ?>
            <input type="submit" value="<?php 
    echo __('Create');
    ?>
" id="buttonGo" />
        </form>
    <?php 
} else {
    ?>
    <!-- db creation no privileges message -->
        <strong><?php 
    echo __('Create database') . ':&nbsp;' . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_DATABASE');
    ?>
</strong><br />
        <?php 
    echo '<span class="noPrivileges">' . ($cfg['ErrorIconic'] ? PMA_getImage('s_error2.png', '', array('hspace' => 2, 'border' => 0, 'align' => 'middle')) : '') . '' . __('No Privileges') . '</span>';
}
// end create db form or message
Пример #15
0
echo $GLOBALS['strSearchNeedle'];
?>
</td>
        <td><input type="text" name="search_str" size="60"
                value="<?php 
echo $searched;
?>
" /></td>
    </tr>
    <tr><td align="right" valign="top">
            <?php 
echo $GLOBALS['strSearchType'];
?>
</td>
            <td><?php 
$choices = array('1' => $GLOBALS['strSearchOption1'] . PMA_showHint($GLOBALS['strSplitWordsWithSpace']), '2' => $GLOBALS['strSearchOption2'] . PMA_showHint($GLOBALS['strSplitWordsWithSpace']), '3' => $GLOBALS['strSearchOption3'], '4' => $GLOBALS['strSearchOption4'] . ' ' . PMA_showMySQLDocu('Regexp', 'Regexp'));
// 4th parameter set to true to add line breaks
// 5th parameter set to false to avoid htmlspecialchars() escaping in the label
//  since we have some HTML in some labels
PMA_display_html_radio('search_option', $choices, $search_option, true, false);
unset($choices);
?>
            </td>
    </tr>
    <tr><td align="right" valign="top">
            <?php 
echo $GLOBALS['strSearchInTables'];
?>
</td>
        <td rowspan="2">
<?php 
Пример #16
0
/**
 * prints list item for main page
 *
 * @param   string  $name   displayed text
 * @param   string  $id     id, used for css styles
 * @param   string  $url    make item as link with $url as target
 * @param   string  $mysql_help_page  display a link to MySQL's manual
 * @param   string  $target special target for $url
 * @param   string  $a_id   id for the anchor, used for jQuery to hook in functions
 * @param   string  $class  class for the li element
 * @param   string  $a_class  class for the anchor element
 */
function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null, $target = null, $a_id = null, $class = null, $a_class = null)
{
    echo '<li id="' . $id . '"';
    if (null !== $class) {
        echo ' class="' . $class . '"';
    }
    echo '>';
    if (null !== $url) {
        echo '<a href="' . $url . '"';
        if (null !== $target) {
            echo ' target="' . $target . '"';
        }
        if (null != $a_id) {
            echo ' id="' . $a_id . '"';
        }
        if (null != $a_class) {
            echo ' class="' . $a_class . '"';
        }
        echo '>';
    }
    echo $name;
    if (null !== $url) {
        echo '</a>' . "\n";
    }
    if (null !== $mysql_help_page) {
        echo PMA_showMySQLDocu('', $mysql_help_page);
    }
    echo '</li>';
}
    : $strModifyIndexTopic);
?>
    </legend>

<div class="formelement">
<label for="input_index_name"><?php echo $strIndexName; ?></label>
<input type="text" name="index[Key_name]" id="input_index_name" size="25"
    value="<?php echo htmlspecialchars($index->getName()); ?>" onfocus="this.select()" />
</div>

<div class="formelement">
<label for="select_index_type"><?php echo $strIndexType; ?></label>
<select name="index[Index_type]" id="select_index_type" onchange="return checkIndexName()">
    <?php echo $index->generateIndexSelector(); ?>
</select>
<?php echo PMA_showMySQLDocu('SQL-Syntax', 'ALTER_TABLE'); ?>
</div>


<br class="clearfloat" />
<?php
PMA_Message::warning('strPrimaryKeyWarning')->display();
?>

<table>
<thead>
<tr><th><?php echo $strField; ?></th>
    <th><?php echo $strSize; ?></th>
</tr>
</thead>
<tbody>
            <?php 
    echo PMA_generate_common_hidden_inputs('', '', 5);
    ?>
            <input type="hidden" name="reload" value="1" />
            <input type="text" name="new_db" value="<?php 
    echo $db_to_create;
    ?>
" maxlength="64" class="textfield" id="text_create_db"/>
            <?php 
    if (PMA_MYSQL_INT_VERSION >= 40101) {
        require_once './libraries/mysql_charsets.lib.php';
        echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', null, null, TRUE, 5);
    }
    ?>
            <input type="submit" value="<?php 
    echo $strCreate;
    ?>
" id="buttonGo" />
        </form>
    <?php 
} else {
    ?>
    <!-- db creation no privileges message -->
        <b><?php 
    echo $strCreateNewDatabase . ':&nbsp;' . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_DATABASE');
    ?>
</b><br />
        <?php 
    echo '<span class="noPrivileges">' . ($cfg['ErrorIconic'] ? '<img src="' . $pmaThemeImage . 's_error2.png" width="11" height="11" hspace="2" border="0" align="middle" />' : '') . '' . $strNoPrivileges . '</span>';
}
// end create db form or message
    echo '</tbody>' . "\n"
       . '</table>' . "\n";

} else {

    /**
     * Displays details about a given Storage Engine
     */

    $engine_plugin = PMA_StorageEngine::getEngine($_REQUEST['engine']);
    echo '<h2>' . "\n"
       . ($GLOBALS['cfg']['MainPageIconic']
            ? '<img class="icon" src="' . $pmaThemeImage . 'b_engine.png"'
                .' width="16" height="16" alt="" />' : '')
       . '    ' . htmlspecialchars($engine_plugin->getTitle()) . "\n"
       . '    ' . PMA_showMySQLDocu('', $engine_plugin->getMysqlHelpPage()) . "\n"
       . '</h2>' . "\n\n";
    echo '<p>' . "\n"
       . '    <em>' . "\n"
       . '        ' . htmlspecialchars($engine_plugin->getComment()) . "\n"
       . '    </em>' . "\n"
       . '</p>' . "\n\n";
    $infoPages = $engine_plugin->getInfoPages();
    if (!empty($infoPages) && is_array($infoPages)) {
        echo '<p>' . "\n"
           . '    <strong>[</strong>' . "\n";
        if (empty($_REQUEST['page'])) {
            echo '    <strong>' . $strServerTabVariables . '</strong>' . "\n";
        } else {
            echo '    <a href="./server_engines.php'
                . PMA_generate_common_url(array('engine' => $_REQUEST['engine'])) . '">'
Пример #20
0
        echo $strPartitionMaintenance;
        ?>
</legend>
<?php 
        $html_select = '<select name="partition_name">' . "\n";
        foreach ($partition_names as $one_partition) {
            $one_partition = htmlspecialchars($one_partition);
            $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
        }
        $html_select .= '</select>' . "\n";
        printf($GLOBALS['strPartition'], $html_select);
        unset($partition_names, $one_partition, $html_select);
        $choices = array('ANALYZE' => $strAnalyze, 'CHECK' => $strCheck, 'OPTIMIZE' => $strOptimize, 'REBUILD' => $strRebuild, 'REPAIR' => $strRepair);
        PMA_display_html_radio('partition_operation', $choices, '', false);
        unset($choices);
        echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
        // I'm not sure of the best way to display that; this link does
        // not depend on the Go button
        $this_url_params = array_merge($url_params, array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'));
        ?>
    <br /><a href="sql.php<?php 
        echo PMA_generate_common_url($this_url_params);
        ?>
">
            <?php 
        echo $strRemovePartitioning;
        ?>
</a>
</fieldset>
<fieldset class="tblFooters">
    <input type="submit" name="submit_partition" value="<?php 
Пример #21
0
    }
    ?>
<a href="sql.php?<?php 
    echo $url_query;
    ?>
&amp;session_max_rows=all&amp;sql_query=<?php 
    echo urlencode('SELECT * FROM ' . PMA_backquote($table) . ' PROCEDURE ANALYSE()');
    ?>
"><?php 
    if ($cfg['PropertiesIconic']) {
        echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . $strStructPropose . '" />';
    }
    echo $strStructPropose;
    ?>
</a><?php 
    echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
    if (PMA_Tracker::isActive()) {
        echo '<a href="tbl_tracking.php?' . $url_query . '">';
        if ($cfg['PropertiesIconic']) {
            echo '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . $strTrackingTrackTable . '" /> ';
        }
        echo $strTrackingTrackTable . '</a>';
    }
    ?>
    
    <br />
<form method="post" action="tbl_addfield.php"
    onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php 
    echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']);
    ?>
', 1)">
Пример #22
0
/**
 * string PMA_pluginGetOneOption(string $section, string $plugin_name, string $id, array &$opt)
 *
 * returns single option in a table row
 *
 * @uses    PMA_getString()
 * @uses    PMA_pluginCheckboxCheck()
 * @uses    PMA_pluginGetDefault()
 * @param   string  $section        name of config section in
 *                                  $GLOBALS['cfg'][$section] for plugin
 * @param   string  $plugin_name    unique plugin name
 * @param   string  $id             option id
 * @param   array   &$opt           plugin option details
 * @return  string                  table row with option
 */
function PMA_pluginGetOneOption($section, $plugin_name, $id, &$opt)
{
    $ret = "\n";
    if ($opt['type'] == 'bool') {
        $ret .= '<div class="formelementrow">' . "\n";
        $ret .= '<input type="checkbox" name="' . $plugin_name . '_' . $opt['name'] . '"' . ' value="something" id="checkbox_' . $plugin_name . '_' . $opt['name'] . '"' . ' ' . PMA_pluginCheckboxCheck($section, $plugin_name . '_' . $opt['name']);
        if (isset($opt['force'])) {
            /* Same code is also few lines lower, update both if needed */
            $ret .= ' onclick="if (!this.checked &amp;&amp; ' . '(!document.getElementById(\'checkbox_' . $plugin_name . '_' . $opt['force'] . '\') ' . '|| !document.getElementById(\'checkbox_' . $plugin_name . '_' . $opt['force'] . '\').checked)) ' . 'return false; else return true;"';
        }
        $ret .= ' />';
        $ret .= '<label for="checkbox_' . $plugin_name . '_' . $opt['name'] . '">' . PMA_getString($opt['text']) . '</label>';
        $ret .= '</div>' . "\n";
    } elseif ($opt['type'] == 'text') {
        $ret .= '<div class="formelementrow">' . "\n";
        $ret .= '<label for="text_' . $plugin_name . '_' . $opt['name'] . '" class="desc">' . PMA_getString($opt['text']) . '</label>';
        $ret .= '<input type="text" name="' . $plugin_name . '_' . $opt['name'] . '"' . ' value="' . PMA_pluginGetDefault($section, $plugin_name . '_' . $opt['name']) . '"' . ' id="text_' . $plugin_name . '_' . $opt['name'] . '"' . (isset($opt['size']) ? ' size="' . $opt['size'] . '"' : '') . (isset($opt['len']) ? ' maxlength="' . $opt['len'] . '"' : '') . ' />';
        $ret .= '</div>' . "\n";
    } elseif ($opt['type'] == 'message_only') {
        $ret .= '<div class="formelementrow">' . "\n";
        $ret .= '<label for="text_' . $plugin_name . '_' . $opt['name'] . '" class="desc">' . PMA_getString($opt['text']) . '</label>';
        $ret .= '</div>' . "\n";
    } elseif ($opt['type'] == 'select') {
        $ret .= '<div class="formelementrow">' . "\n";
        $ret .= '<label for="select_' . $plugin_name . '_' . $opt['name'] . '" class="desc">' . PMA_getString($opt['text']) . '</label>';
        $ret .= '<select name="' . $plugin_name . '_' . $opt['name'] . '"' . ' id="select_' . $plugin_name . '_' . $opt['name'] . '">';
        $default = PMA_pluginGetDefault($section, $plugin_name . '_' . $opt['name']);
        foreach ($opt['values'] as $key => $val) {
            $ret .= '<option name="' . $key . '"';
            if ($key == $default) {
                $ret .= ' selected="selected"';
            }
            $ret .= '>' . PMA_getString($val) . '</option>';
        }
        $ret .= '</select>';
        $ret .= '</div>' . "\n";
    } elseif ($opt['type'] == 'hidden') {
        $ret .= '<input type="hidden" name="' . $plugin_name . '_' . $opt['name'] . '"' . ' value="' . PMA_pluginGetDefault($section, $plugin_name . '_' . $opt['name']) . '"' . ' />';
    } elseif ($opt['type'] == 'bgroup') {
        $ret .= '<fieldset><legend>';
        /* No checkbox without name */
        if (!empty($opt['name'])) {
            $ret .= '<input type="checkbox" name="' . $plugin_name . '_' . $opt['name'] . '"' . ' value="something" id="checkbox_' . $plugin_name . '_' . $opt['name'] . '"' . ' ' . PMA_pluginCheckboxCheck($section, $plugin_name . '_' . $opt['name']);
            if (isset($opt['force'])) {
                /* Same code is also few lines higher, update both if needed */
                $ret .= ' onclick="if (!this.checked &amp;&amp; ' . '(!document.getElementById(\'checkbox_' . $plugin_name . '_' . $opt['force'] . '\') ' . '|| !document.getElementById(\'checkbox_' . $plugin_name . '_' . $opt['force'] . '\').checked)) ' . 'return false; else return true;"';
            }
            $ret .= ' />';
            $ret .= '<label for="checkbox_' . $plugin_name . '_' . $opt['name'] . '">' . PMA_getString($opt['text']) . '</label>';
        } else {
            $ret .= PMA_getString($opt['text']);
        }
        $ret .= '</legend>';
    } elseif ($opt['type'] == 'egroup') {
        $ret .= '</fieldset>';
    } else {
        /* This should be seen only by plugin writers, so I do not thing this
         * needs translation. */
        $ret .= 'UNKNOWN OPTION ' . $opt['type'] . ' IN IMPORT PLUGIN ' . $plugin_name . '!';
    }
    if (isset($opt['doc'])) {
        $ret .= PMA_showMySQLDocu($opt['doc'][0], $opt['doc'][1]);
    }
    $ret .= "\n";
    return $ret;
}
Пример #23
0
/**
 * Creates a list of items containing the relevant
 * information and some action links.
 *
 * @param    string   $type    One of ['routine'|'trigger'|'event']
 * @param    array    $items   An array of items
 *
 * @return   string   HTML code of the list of items
 */
function PMA_RTE_getList($type, $items)
{
    global $table;
    /**
     * Conditional classes switch the list on or off
     */
    $class1 = 'hide';
    $class2 = '';
    if (!$items) {
        $class1 = '';
        $class2 = ' hide';
    }
    /**
     * Generate output
     */
    $retval = "<!-- LIST OF " . PMA_RTE_getWord('docu') . " START -->\n";
    $retval .= "<fieldset>\n";
    $retval .= "    <legend>\n";
    $retval .= "        " . PMA_RTE_getWord('title') . "\n";
    $retval .= "        " . PMA_showMySQLDocu('SQL-Syntax', PMA_RTE_getWord('docu')) . "\n";
    $retval .= "    </legend>\n";
    $retval .= "    <div class='{$class1}' id='nothing2display'>\n";
    $retval .= "      " . PMA_RTE_getWord('nothing') . "\n";
    $retval .= "    </div>\n";
    $retval .= "    <table class='data{$class2}'>\n";
    $retval .= "        <!-- TABLE HEADERS -->\n";
    $retval .= "        <tr>\n";
    switch ($type) {
        case 'routine':
            $retval .= "            <th>" . __('Name') . "</th>\n";
            $retval .= "            <th colspan='4'>" . __('Action') . "</th>\n";
            $retval .= "            <th>" . __('Type') . "</th>\n";
            $retval .= "            <th>" . __('Returns') . "</th>\n";
            break;
        case 'trigger':
            $retval .= "            <th>" . __('Name') . "</th>\n";
            if (empty($table)) {
                $retval .= "            <th>" . __('Table') . "</th>\n";
            }
            $retval .= "            <th colspan='3'>" . __('Action') . "</th>\n";
            $retval .= "            <th>" . __('Time') . "</th>\n";
            $retval .= "            <th>" . __('Event') . "</th>\n";
            break;
        case 'event':
            $retval .= "            <th>" . __('Name') . "</th>\n";
            $retval .= "            <th>" . __('Status') . "</th>\n";
            $retval .= "            <th colspan='3'>" . __('Action') . "</th>\n";
            $retval .= "            <th>" . __('Type') . "</th>\n";
            break;
        default:
            break;
    }
    $retval .= "        </tr>\n";
    $retval .= "        <!-- TABLE DATA -->\n";
    $ct = 0;
    foreach ($items as $item) {
        $rowclass = $ct % 2 == 0 ? 'odd' : 'even';
        if ($GLOBALS['is_ajax_request']) {
            $rowclass .= ' ajaxInsert hide';
        }
        // Get each row from the correct function
        switch ($type) {
            case 'routine':
                $retval .= PMA_RTN_getRowForList($item, $rowclass);
                break;
            case 'trigger':
                $retval .= PMA_TRI_getRowForList($item, $rowclass);
                break;
            case 'event':
                $retval .= PMA_EVN_getRowForList($item, $rowclass);
                break;
            default:
                break;
        }
        $ct++;
    }
    $retval .= "    </table>\n";
    $retval .= "</fieldset>\n";
    $retval .= "<!-- LIST OF " . PMA_RTE_getWord('docu') . " END -->\n";
    return $retval;
}
Пример #24
0
            // end if... else....
        } elseif (isset($existrel_innodb[$master_field])) {
            if (PMA_MYSQL_INT_VERSION >= 40013) {
                $upd_query = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP FOREIGN KEY ' . PMA_backquote($existrel_innodb[$master_field]['constraint']);
            }
        }
        // end if... else....
        if (isset($upd_query)) {
            $upd_rs = PMA_DBI_try_query($upd_query);
            $tmp_error = PMA_DBI_getError();
            if (substr($tmp_error, 1, 4) == '1216') {
                PMA_mysqlDie($tmp_error, $upd_query, FALSE, '', FALSE);
                echo PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
            }
            if (substr($tmp_error, 1, 4) == '1005') {
                echo '<p class="warning">' . $strNoIndex . ' (' . $master_field . ')</p>' . PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
            }
            unset($upd_query, $tmp_error);
        }
    }
    // end while
}
// end if isset($destination_innodb)
// U p d a t e s   f o r   d i s p l a y   f i e l d
if ($cfgRelation['displaywork'] && isset($display_field)) {
    if ($disp) {
        if ($display_field != '') {
            $upd_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . ' SET display_field = \'' . PMA_sqlAddslashes($display_field) . '\'' . ' WHERE db_name  = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
        } else {
            $upd_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . ' WHERE db_name  = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
        }
Пример #25
0
    <?php 
    echo $GLOBALS['strOr'];
    ?>
    <?php 
    echo sprintf($strAddFields, '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />');
    ?>
    <input type="submit" name="submit_num_fields"
        value="<?php 
    echo $GLOBALS['strGo'];
    ?>
"
<?php 
    /*        onclick="if (addField()) return false;" */
    ?>
        onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php 
    echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']);
    ?>
', 1)"
        />
<?php 
}
?>
</fieldset>

</form>

<center><?php 
echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE');
?>
</center>
Пример #26
0
/**
 * prints querybox fieldset
 *
 * @param string  $query          query to display in the textarea
 * @param boolean $is_querywindow if inside querywindow or not
 * @param string  $delimiter      default delimiter to use
 *
 * @usedby  PMA_sqlQueryForm()
 */
function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, $delimiter = ';')
{
    // enable auto select text in textarea
    if ($GLOBALS['cfg']['TextareaAutoSelect']) {
        $auto_sel = ' onclick="selectContent(this, sql_box_locked, true)"';
    } else {
        $auto_sel = '';
    }
    // enable locking if inside query window
    if ($is_querywindow) {
        $locking = ' onkeypress="document.sqlform.elements[\'LockFromUpdate\'].' . 'checked = true;"';
        $height = $GLOBALS['cfg']['TextareaRows'] * 1.25;
    } else {
        $locking = '';
        $height = $GLOBALS['cfg']['TextareaRows'] * 2;
    }
    $table = '';
    $db = '';
    $fields_list = array();
    if (!strlen($GLOBALS['db'])) {
        // prepare for server related
        $legend = sprintf(__('Run SQL query/queries on server %s'), '&quot;' . htmlspecialchars(!empty($GLOBALS['cfg']['Servers'][$GLOBALS['server']]['verbose']) ? $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['verbose'] : $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host']) . '&quot;');
    } elseif (!strlen($GLOBALS['table'])) {
        // prepare for db related
        $db = $GLOBALS['db'];
        // if you want navigation:
        $tmp_db_link = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db) . '"';
        if ($is_querywindow) {
            $tmp_db_link .= ' target="_self"' . ' onclick="this.target=window.opener.frame_content.name"';
        }
        $tmp_db_link .= '>' . htmlspecialchars($db) . '</a>';
        // else use
        // $tmp_db_link = htmlspecialchars($db);
        $legend = sprintf(__('Run SQL query/queries on database %s'), $tmp_db_link);
        if (empty($query)) {
            $query = PMA_expandUserString($GLOBALS['cfg']['DefaultQueryDatabase'], 'PMA_backquote');
        }
    } else {
        $table = $GLOBALS['table'];
        $db = $GLOBALS['db'];
        // Get the list and number of fields
        // we do a try_query here, because we could be in the query window,
        // trying to synchonize and the table has not yet been created
        $fields_list = PMA_DBI_get_columns($db, $GLOBALS['table'], null, true);
        $tmp_db_link = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db) . '"';
        if ($is_querywindow) {
            $tmp_db_link .= ' target="_self"' . ' onclick="this.target=window.opener.frame_content.name"';
        }
        $tmp_db_link .= '>' . htmlspecialchars($db) . '</a>';
        // else use
        // $tmp_db_link = htmlspecialchars($db);
        $legend = sprintf(__('Run SQL query/queries on database %s'), $tmp_db_link);
        if (empty($query)) {
            $query = PMA_expandUserString($GLOBALS['cfg']['DefaultQueryTable'], 'PMA_backquote');
        }
    }
    $legend .= ': ' . PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
    if (count($fields_list)) {
        $sqlquerycontainer_id = 'sqlquerycontainer';
    } else {
        $sqlquerycontainer_id = 'sqlquerycontainerfull';
    }
    echo '<a id="querybox"></a>' . "\n" . '<div id="queryboxcontainer">' . "\n" . '<fieldset id="queryboxf">' . "\n";
    echo '<legend>' . $legend . '</legend>' . "\n";
    echo '<div id="queryfieldscontainer">' . "\n";
    echo '<div id="' . $sqlquerycontainer_id . '">' . "\n" . '<textarea tabindex="100" name="sql_query" id="sqlquery"' . '  cols="' . $GLOBALS['cfg']['TextareaCols'] . '"' . '  rows="' . $height . '"' . '  dir="' . $GLOBALS['text_dir'] . '"' . $auto_sel . $locking . '>' . htmlspecialchars($query) . '</textarea>' . "\n";
    // Add buttons to generate query easily for select all,single select,insert,update and delete
    if (count($fields_list)) {
        echo '<input type="button" value="SELECT *" id="selectall" class="button sqlbutton" />';
        echo '<input type="button" value="SELECT" id="select" class="button sqlbutton" />';
        echo '<input type="button" value="INSERT" id="insert" class="button sqlbutton" />';
        echo '<input type="button" value="UPDATE" id="update" class="button sqlbutton" />';
        echo '<input type="button" value="DELETE" id="delete" class="button sqlbutton" />';
    }
    echo '<input type="button" value="' . __('Clear') . '" id="clear" class="button sqlbutton" />';
    echo '</div>' . "\n";
    if (count($fields_list)) {
        echo '<div id="tablefieldscontainer">' . "\n" . '<label>' . __('Columns') . '</label>' . "\n" . '<select id="tablefields" name="dummy" ' . 'size="' . ($GLOBALS['cfg']['TextareaRows'] - 2) . '" ' . 'multiple="multiple" ondblclick="insertValueQuery()">' . "\n";
        foreach ($fields_list as $field) {
            echo '<option value="' . PMA_backquote(htmlspecialchars($field['Field'])) . '"';
            if (isset($field['Field']) && strlen($field['Field']) && isset($field['Comment'])) {
                echo ' title="' . htmlspecialchars($field['Comment']) . '"';
            }
            echo '>' . htmlspecialchars($field['Field']) . '</option>' . "\n";
        }
        echo '</select>' . "\n" . '<div id="tablefieldinsertbuttoncontainer">' . "\n";
        if ($GLOBALS['cfg']['PropertiesIconic']) {
            echo '<input type="button" class="button" name="insert" value="&lt;&lt;"' . ' onclick="insertValueQuery()"' . ' title="' . __('Insert') . '" />' . "\n";
        } else {
            echo '<input type="button" class="button" name="insert"' . ' value="' . __('Insert') . '"' . ' onclick="insertValueQuery()" />' . "\n";
        }
        echo '</div>' . "\n" . '</div>' . "\n";
    }
    echo '<div class="clearfloat"></div>' . "\n";
    echo '</div>' . "\n";
    if (!empty($GLOBALS['cfg']['Bookmark'])) {
        ?>
        <div id="bookmarkoptions">
        <div class="formelement">
        <label for="bkm_label">
            <?php 
        echo __('Bookmark this SQL query');
        ?>
:</label>
        <input type="text" name="bkm_label" id="bkm_label" tabindex="110" value="" />
        </div>
        <div class="formelement">
        <input type="checkbox" name="bkm_all_users" tabindex="111" id="id_bkm_all_users" value="true" />
        <label for="id_bkm_all_users">
            <?php 
        echo __('Let every user access this bookmark');
        ?>
</label>
        </div>
        <div class="formelement">
        <input type="checkbox" name="bkm_replace" tabindex="112" id="id_bkm_replace"
            value="true" />
        <label for="id_bkm_replace">
            <?php 
        echo __('Replace existing bookmark of same name');
        ?>
</label>
        </div>
        </div>
        <?php 
    }
    echo '<div class="clearfloat"></div>' . "\n";
    echo '</fieldset>' . "\n" . '</div>' . "\n";
    echo '<fieldset id="queryboxfooter" class="tblFooters">' . "\n";
    echo '<div class="formelement">' . "\n";
    if ($is_querywindow) {
        ?>
        <script type="text/javascript">
        //<![CDATA[
            document.writeln(' <input type="checkbox" name="LockFromUpdate" checked="checked" tabindex="120" id="checkbox_lock" /> <label for="checkbox_lock"><?php 
        echo __('Do not overwrite this query from outside the window');
        ?>
</label> ');
        //]]>
        </script>
        <?php 
    }
    echo '</div>' . "\n";
    echo '<div class="formelement">' . "\n";
    echo '<label for="id_sql_delimiter">[ ' . __('Delimiter') . '</label>' . "\n";
    echo '<input type="text" name="sql_delimiter" tabindex="131" size="3" ' . 'value="' . $delimiter . '" ' . 'id="id_sql_delimiter" /> ]' . "\n";
    echo '<input type="checkbox" name="show_query" value="1" ' . 'id="checkbox_show_query" tabindex="132" checked="checked" />' . "\n" . '<label for="checkbox_show_query">' . __('Show this query here again') . '</label>' . "\n";
    if (!$is_querywindow) {
        echo '<input type="checkbox" name="retain_query_box" value="1" ' . 'id="retain_query_box" tabindex="133" ' . ($GLOBALS['cfg']['RetainQueryBox'] === false ? '' : ' checked="checked"') . ' />' . '<label for="retain_query_box">' . __('Retain query box') . '</label>';
    }
    echo '</div>' . "\n";
    echo '<input type="submit" id="button_submit_query" name="SQL" tabindex="200" value="' . __('Go') . '" />' . "\n";
    echo '<div class="clearfloat"></div>' . "\n";
    echo '</fieldset>' . "\n";
}
Пример #27
0
echo __('Words or values to search for (wildcard: "%"):');
?>
</td>
        <td><input type="text" name="search_str" size="60"
                value="<?php 
echo $searched;
?>
" /></td>
    </tr>
    <tr><td class="right vtop">
            <?php 
echo __('Find:');
?>
</td>
            <td><?php 
$choices = array('1' => __('at least one of the words') . PMA_showHint(__('Words are separated by a space character (" ").')), '2' => __('all words') . PMA_showHint(__('Words are separated by a space character (" ").')), '3' => __('the exact phrase'), '4' => __('as regular expression') . ' ' . PMA_showMySQLDocu('Regexp', 'Regexp'));
// 4th parameter set to true to add line breaks
// 5th parameter set to false to avoid htmlspecialchars() escaping in the label
//  since we have some HTML in some labels
PMA_display_html_radio('search_option', $choices, $search_option, true, false);
unset($choices);
?>
            </td>
    </tr>
    <tr><td class="right vtop">
            <?php 
echo __('Inside tables:');
?>
</td>
        <td rowspan="2">
<?php 
        // end if... else....
        if (!empty($sql_query)) {
            PMA_DBI_try_query($sql_query);
            $tmp_error = PMA_DBI_getError();
            if (!empty($tmp_error)) {
                $seen_error = true;
            }
            if (substr($tmp_error, 1, 4) == '1216' || substr($tmp_error, 1, 4) == '1452') {
                PMA_mysqlDie($tmp_error, $sql_query, FALSE, '', FALSE);
                echo PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
            }
            if (substr($tmp_error, 1, 4) == '1005') {
                $message = PMA_Message::warning('strForeignKeyError');
                $message->addParam($master_field);
                $message->display();
                echo PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
            }
            unset($tmp_error);
            $sql_query = '';
        }
    }
    // end foreach
    if (!empty($display_query)) {
        if ($seen_error) {
            PMA_showMessage($strError, null, 'error');
        } else {
            PMA_showMessage($strSuccess, null, 'success');
        }
    }
}
// end if isset($destination_foreign)
if ($cfg['ShowTooltip']) {
    echo '&amp;reload=1';
}
?>
">
                    <?php 
echo $strFlushTable;
?>
</a>&nbsp;
        </td>
        <td bgcolor="<?php 
echo $cfg['BgcolorOne'];
?>
">
                    <?php 
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH') . "\n";
?>
        </td>
    </tr>

<?php 
// Referential integrity check
// The Referential integrity check was intended for the non-InnoDB
// tables for which the relations are defined in pmadb
// so I assume that if the current table is InnoDB, I don't display
// this choice (InnoDB maintains integrity by itself)
if ($cfgRelation['relwork'] && $tbl_type != "INNODB") {
    // we need this PMA_DBI_select_db if the user has access to more than one db
    // and $db is not the last of the list, because PMA_availableDatabases()
    // has made a PMA_DBI_select_db() on the last one
    PMA_DBI_select_db($db);
Пример #30
0
    foreach ($mysql_storage_engines as $engine => $details) {
        echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ($details['Support'] == 'NO' || $details['Support'] == 'DISABLED' ? ' disabled' : '') . '">' . "\n" . '    <td><a href="./server_engines.php' . PMA_generate_common_url(array('engine' => $engine)) . '">' . "\n" . '            ' . htmlspecialchars($details['Engine']) . "\n" . '        </a>' . "\n" . '    </td>' . "\n";
        if (PMA_MYSQL_INT_VERSION >= 40102) {
            echo '    <td>' . htmlspecialchars($details['Comment']) . "\n" . '    </td>' . "\n";
        }
        echo '</tr>' . "\n";
        $odd_row = !$odd_row;
    }
    unset($odd_row, $engine, $details);
    echo '</tbody>' . "\n" . '</table>' . "\n";
} else {
    /**
     * Displays details about a given Storage Engine
     */
    $engine_plugin = PMA_StorageEngine::getEngine($_REQUEST['engine']);
    echo '<h2>' . "\n" . ($GLOBALS['cfg']['MainPageIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_engine.png"' . ' width="16" height="16" alt="" />' : '') . '    ' . htmlspecialchars($engine_plugin->getTitle()) . "\n" . '    ' . PMA_showMySQLDocu('', $engine_plugin->getMysqlHelpPage()) . "\n" . '</h2>' . "\n\n";
    if (PMA_MYSQL_INT_VERSION >= 40102) {
        echo '<p>' . "\n" . '    <em>' . "\n" . '        ' . htmlspecialchars($engine_plugin->getComment()) . "\n" . '    </em>' . "\n" . '</p>' . "\n\n";
    }
    $infoPages = $engine_plugin->getInfoPages();
    if (!empty($infoPages) && is_array($infoPages)) {
        echo '<p>' . "\n" . '    <strong>[</strong>' . "\n";
        if (empty($_REQUEST['page'])) {
            echo '    <strong>' . $strServerTabVariables . '</strong>' . "\n";
        } else {
            echo '    <a href="./server_engines.php' . PMA_generate_common_url(array('engine' => $_REQUEST['engine'])) . '">' . $strServerTabVariables . '</a>' . "\n";
        }
        foreach ($infoPages as $current => $label) {
            echo '    <strong>|</strong>' . "\n";
            if (isset($_REQUEST['page']) && $_REQUEST['page'] == $current) {
                echo '    <strong>' . $label . '</strong>' . "\n";