3 // vim: expandtab sw=4 ts=4 sts=4:
7 * Defines the query to be displayed in the query textarea
9 if (isset($show_query) && $show_query == '1') {
10 // This script has been called by read_dump.php3
11 if (isset($sql_query_cpy)) {
12 $query_to_display = $sql_query_cpy;
16 $query_to_display = $sql_query;
19 $query_to_display = '';
24 * Get the list and number of fields
27 if (isset($db) && isset($table) && $table != '' && $db != '') {
28 $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
29 $result = @PMA_mysql_query
($local_query);
31 PMA_mysqlDie('', $local_query, '', $err_url);
34 $fields_cnt = mysql_num_rows($result);
35 while ($row = PMA_mysql_fetch_array($result)) {
36 $fields_list[] = $row['Field'];
38 mysql_free_result($result);
45 // loic1: defines wether file upload is available or not
46 // ($is_upload now defined in common.lib.php3)
48 $auto_sel = ($cfg['TextareaAutoSelect']
49 // 2003-02-05 rabus: This causes big trouble with Opera 7 for
50 // Windows, so let's disable it there...
51 && !(PMA_USR_OS
== 'Win' && PMA_USR_BROWSER_AGENT
== 'OPERA' && PMA_USR_BROWSER_VER
>= 7))
52 ?
"\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; this.form.elements[\'sql_query\'].select();}"'
55 // garvin: If non-JS query window is embedded, display a list of databases to choose from.
56 // Apart from that, a non-js query window sucks badly.
58 if ($cfg['QueryFrame'] && (!$cfg['QueryFrameJS'] ||
($cfg['QueryFrameJS'] && !$db))) {
60 * Get the list and number of available databases.
63 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
69 $queryframe_db_list = '<select size=1 name="db">';
70 for ($i = 0; $i < $num_dbs; $i++
) {
72 $queryframe_db_list .= '<option value="' . htmlspecialchars($t_db) . '">' . htmlspecialchars($t_db) . '</option>';
74 $queryframe_db_list .= '</select>';
77 $queryframe_db_list = '';
81 <form method
="post" target
="phpmain" action
="read_dump.php3"<?php
if ($is_upload) echo ' enctype="multipart/form-data"'; echo "\n"; ?
>
82 onsubmit
="return checkSqlQuery(this)" name
="sqlform">
83 <input type
="hidden" name
="is_js_confirmed" value
="0" />
84 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
85 <input type
="hidden" name
="pos" value
="0" />
86 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
87 <input type
="hidden" name
="zero_rows" value
="<?php echo $strSuccess; ?>" />
88 <input type
="hidden" name
="prev_sql_query" value
="<?php echo ((!empty($query_to_display)) ? urlencode($query_to_display) : ''); ?>" />
90 if (!isset($is_inside_querywindow) ||
91 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'sql' ||
$querydisplay_tab == 'full'))) {
93 <!-- Query box
and bookmark support
-->
94 <a name
="querybox"></a
>
95 <table cellpadding
="1" cellspacing
="1">
98 <?php
echo sprintf($strRunSQLQuery, htmlspecialchars($db)) . $queryframe_db_list . (isset($is_inside_querywindow) ?
'<br />' : ' ') . PMA_showMySQLDocu('Reference', 'SELECT'); ?
>
100 <textarea name
="sql_query" rows
="<?php echo $cfg['TextareaRows']; ?>" cols
="<?php echo (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE ? ceil($cfg['TextareaCols'] * 1.25) : $cfg['TextareaCols'] * 2); ?>" wrap
="virtual" dir
="<?php echo $text_dir; ?>"<?php
echo $auto_sel; ?
>>
101 <?php
echo ((!empty($query_to_display)) ?
htmlspecialchars($query_to_display) : 'SELECT * FROM ' . htmlspecialchars(PMA_backquote($table)) . ' WHERE 1'); ?
></textarea
>
103 <?php
if (isset($table) && $fields_cnt > 0) { ?
>
104 <td align
="center" valign
="top"><?php
echo (isset($is_inside_querywindow) ?
'<br />' : '') . $strFields; ?
>:<br
/>
105 <select name
="dummy" size
="4" multiple
>
108 for ($i = 0 ; $i < $fields_cnt; $i++
) {
110 . '<option value="' . PMA_backquote(htmlspecialchars($fields_list[$i])) . '">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
113 </select
><br
/><br
/>
114 <input type
="button" name
="insert" value
="<?php echo($strInsert); ?>" onclick
="insertValueQuery()" />
121 <input type
="checkbox" name
="show_query" value
="1" id
="checkbox_show_query" checked
="checked" /> 
;
122 <label
for="checkbox_show_query"><?php
echo $strShowThisQuery; ?
></label
><br
/>
127 <input type
="hidden" name
="sql_query" value
="" />
128 <input type
="hidden" name
="show_query" value
="1" />
132 // loic1: displays import dump feature only if file upload available
133 if ($is_upload && (!isset($is_inside_querywindow) ||
134 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' ||
$querydisplay_tab == 'full')))) {
135 echo ' ' . ((isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && $querydisplay_tab == 'full') ||
!isset($is_inside_querywindow) ?
'<i>' . $strOr . '</i>' : '') . ' ' . $strLocationTextfile . ' :<br />' . "\n";
137 <div style
="margin-bottom: 5px">
138 <input type
="file" name
="sql_file" class="textfield" /><br
/>
140 if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
141 $temp_charset = reset($cfg['AvailableCharsets']);
142 echo $strCharsetOfFile . "\n"
143 . ' <select name="charset_of_file" size="1">' . "\n"
144 . ' <option value="' . $temp_charset . '"';
145 if ($temp_charset == $charset) {
146 echo ' selected="selected"';
148 echo '>' . $temp_charset . '</option>' . "\n";
149 while ($temp_charset = next($cfg['AvailableCharsets'])) {
150 echo ' <option value="' . $temp_charset . '"';
151 if ($temp_charset == $charset) {
152 echo ' selected="selected"';
154 echo '>' . $temp_charset . '</option>' . "\n";
156 echo ' </select><br />' . "\n" . ' ';
158 $is_gzip = ($cfg['GZipDump'] && @function_exists
('gzopen'));
159 $is_bzip = ($cfg['BZipDump'] && @function_exists
('bzdecompress'));
160 if ($is_bzip ||
$is_gzip) {
161 echo ' ' . $strCompression . ':' . "\n"
162 . ' <input type="radio" id="radio_sql_file_compression_auto" name="sql_file_compression" value="" checked="checked" />' . "\n"
163 . ' <label for="radio_sql_file_compression_auto">' . $strAutodetect . '</label> ' . "\n"
164 . ' <input type="radio" id="radio_sql_file_compression_plain" name="sql_file_compression" value="text/plain" />' . "\n"
165 . ' <label for="radio_sql_file_compression_plain">' . $strNone . '</label> ' . "\n";
167 echo ' <input type="radio" id="radio_sql_file_compression_gzip" name="sql_file_compression" value="application/x-gzip" />' . "\n"
168 . ' <label for="radio_sql_file_compression_gzip">' . $strGzip . '</label> ' . "\n";
171 echo ' <input type="radio" id="radio_sql_file_compression_bzip" name="sql_file_compression" value="application/x-bzip" />' . "\n"
172 . ' <label for="radio_sql_file_compression_bzip">' . $strBzip . '</label> ' . "\n";
175 echo ' <input type="hidden" name="sql_file_compression" value="text/plain" />' . "\n";
183 // web-server upload directory
184 // (TODO: display the charset selection, even if is_upload == FALSE)
185 if ($cfg['UploadDir'] != '' && !isset($is_inside_querywindow) ||
186 ($cfg['UploadDir'] != '' && isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' ||
$querydisplay_tab == 'full'))) {
188 if ($handle = @opendir
($cfg['UploadDir'])) {
190 while ($file = @readdir
($handle)) {
191 if (is_file($cfg['UploadDir'] . $file) && substr($file, -4) == '.sql') {
192 if ($is_first == 0) {
194 echo ' ' . ((isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && $querydisplay_tab == 'full') ||
!isset($is_inside_querywindow) ?
'<i>' . $strOr . '</i>' : '') . ' ' . $strWebServerUploadDirectory . ' :<br />' . "\n";
195 echo ' <div style="margin-bottom: 5px">' . "\n";
196 echo ' <select size="1" name="sql_localfile">' . "\n";
197 echo ' <option value="" selected="selected"></option>' . "\n";
198 } // end if (is_first)
199 echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
201 } // end if (is_file)
204 echo ' </select>' . "\n"
205 . ' </div>' . "\n\n";
206 } // end if (isfirst > 0)
209 echo ' <div style="margin-bottom: 5px">' . "\n";
210 echo ' <font color="red">' . $strError . '</font><br />' . "\n";
211 echo ' ' . $strWebServerUploadDirectoryError . "\n";
212 echo ' </div>' . "\n";
214 } // end if (web-server upload directory)
217 // Encoding setting form appended by Y.Kawada
218 if (function_exists('PMA_set_enc_form')) {
219 echo PMA_set_enc_form(' ');
223 $bookmark_go = FALSE;
224 if (!isset($is_inside_querywindow) ||
225 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'history' ||
$querydisplay_tab == 'full'))) {
226 if ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table']) {
227 if (($bookmark_list = PMA_listBookmarks($db, $cfg['Bookmark'])) && count($bookmark_list) > 0) {
228 echo " " . ((isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && $querydisplay_tab == 'full') ||
!isset($is_inside_querywindow) ?
"<i>$strOr</i>" : '') . " $strBookmarkQuery :<br />\n";
230 echo ' <div style="margin-bottom: 5px">' . "\n";
231 echo ' <select name="id_bookmark" style="vertical-align: middle">' . "\n";
232 echo ' <option value=""></option>' . "\n";
233 while (list($key, $value) = each($bookmark_list)) {
234 echo ' <option value="' . $value . '">' . htmlspecialchars($key) . '</option>' . "\n";
236 echo ' </select>' . "<br />\n";
237 echo ' ' . $strVar . ' (<a href="./Documentation.html#faqbookmark" target="documentation">' . $strDocu . '</a>): <input type="text" name="bookmark_variable" class="textfield" size="10" />' . "\n";
238 echo ' <input type="radio" name="action_bookmark" value="0" id="radio_bookmark0" checked="checked" style="vertical-align: middle" /><label for="radio_bookmark0">' . $strSubmit . '</label>' . "\n";
239 echo ' <input type="radio" name="action_bookmark" value="1" id="radio_bookmark1" style="vertical-align: middle" /><label for="radio_bookmark1">' . $strBookmarkView . '</label>' . "\n";
240 echo ' <input type="radio" name="action_bookmark" value="2" id="radio_bookmark2" style="vertical-align: middle" /><label for="radio_bookmark2">' . $strDelete . '</label>' . "\n";
241 echo ' <br />' . "\n";
242 echo ' </div>' . "\n";
248 if (!isset($is_inside_querywindow) ||
(isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' ||
$querydisplay_tab == 'sql' ||
$querydisplay_tab == 'full' ||
($querydisplay_tab == 'history' && $bookmark_go)))) {
250 <input type
="submit" name
="SQL" value
="<?php echo $strGo; ?>" />
254 if (!isset($is_inside_querywindow) ||
255 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' ||
$querydisplay_tab == 'full'))) {
257 // loic1: displays import dump feature only if file upload available
258 $ldi_target = 'ldi_table.php3?' . $url_query;
260 if ($is_upload && isset($db) && isset($table)) {
262 <!-- Insert a text file
-->
265 <div style
="margin-bottom: 10px"><a href
="<?php echo (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE ? '#' : $ldi_target); ?>" <?php
echo (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE ?
'onclick="opener.top.frames.phpmain.location.href = \'' . $ldi_target . '\'; return false;"' : ''); ?
>><?php
echo $strInsertTextfiles; ?
></a
></div
>