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'] && !$db ||
($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 = '';
80 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
83 document
.writeln('<form method="post" target="phpmain' +
<?php
echo ((isset($is_inside_querywindow) && $is_inside_querywindow == TRUE) ?
'opener.' : ''); ?
>top
.frames
.nav
.document
.hashform
.hash
.value +
'" action="read_dump.php3"<?php if ($is_upload) echo ' enctype
="multipart/form-data"'; ?>');
88 <form method
="post" target
="phpmain<?php echo md5($cfg['PmaAbsoluteUri']); ?>" action
="read_dump.php3"<?php
if ($is_upload) echo ' enctype="multipart/form-data"'; echo "\n"; ?
>
92 onsubmit
="return checkSqlQuery(this)" name
="sqlform">
93 <input type
="hidden" name
="is_js_confirmed" value
="0" />
94 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
95 <input type
="hidden" name
="pos" value
="0" />
96 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
97 <input type
="hidden" name
="zero_rows" value
="<?php echo $strSuccess; ?>" />
98 <input type
="hidden" name
="prev_sql_query" value
="<?php echo ((!empty($query_to_display)) ? urlencode($query_to_display) : ''); ?>" />
100 if (!isset($is_inside_querywindow) ||
101 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'sql' ||
$querydisplay_tab == 'full'))) {
103 <!-- Query box
and bookmark support
-->
104 <a name
="querybox"></a
>
105 <table cellpadding
="1" cellspacing
="1">
108 <?php
echo sprintf($strRunSQLQuery, htmlspecialchars($db)) . $queryframe_db_list . (isset($is_inside_querywindow) ?
'<br />' : ' ') . PMA_showMySQLDocu('Reference', 'SELECT'); ?
>
110 <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; ?
>>
111 <?php
echo ((!empty($query_to_display)) ?
htmlspecialchars($query_to_display) : 'SELECT * FROM ' . htmlspecialchars(PMA_backquote($table)) . ' WHERE 1'); ?
></textarea
>
113 <?php
if (isset($table) && $fields_cnt > 0) { ?
>
114 <td align
="center" valign
="top"><?php
echo (isset($is_inside_querywindow) ?
'<br />' : '') . $strFields; ?
>:<br
/>
115 <select name
="dummy" size
="4" multiple
>
118 for ($i = 0 ; $i < $fields_cnt; $i++
) {
120 . '<option value="' . PMA_backquote(htmlspecialchars($fields_list[$i])) . '">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
123 </select
><br
/><br
/>
124 <input type
="button" name
="insert" value
="<?php echo($strInsert); ?>" onclick
="insertValueQuery()" />
131 <input type
="checkbox" name
="show_query" value
="1" id
="checkbox_show_query" checked
="checked" /> 
;
132 <label
for="checkbox_show_query"><?php
echo $strShowThisQuery; ?
></label
><br
/>
137 <input type
="hidden" name
="sql_query" value
="" />
138 <input type
="hidden" name
="show_query" value
="1" />
142 // loic1: displays import dump feature only if file upload available
143 if ($is_upload && (!isset($is_inside_querywindow) ||
144 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' ||
$querydisplay_tab == 'full'))) && isset($db) && $db != '') {
145 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";
147 <div style
="margin-bottom: 5px">
148 <input type
="file" name
="sql_file" class="textfield" /><br
/>
150 $is_gzip = ($cfg['GZipDump'] && @function_exists
('gzopen'));
151 $is_bzip = ($cfg['BZipDump'] && @function_exists
('bzdecompress'));
152 if ($is_bzip ||
$is_gzip) {
153 echo ' ' . $strCompression . ':' . "\n"
154 . ' <input type="radio" id="radio_sql_file_compression_auto" name="sql_file_compression" value="" checked="checked" />' . "\n"
155 . ' <label for="radio_sql_file_compression_auto">' . $strAutodetect . '</label> ' . "\n"
156 . ' <input type="radio" id="radio_sql_file_compression_plain" name="sql_file_compression" value="text/plain" />' . "\n"
157 . ' <label for="radio_sql_file_compression_plain">' . $strNone . '</label> ' . "\n";
159 echo ' <input type="radio" id="radio_sql_file_compression_gzip" name="sql_file_compression" value="application/x-gzip" />' . "\n"
160 . ' <label for="radio_sql_file_compression_gzip">' . $strGzip . '</label> ' . "\n";
163 echo ' <input type="radio" id="radio_sql_file_compression_bzip" name="sql_file_compression" value="application/x-bzip" />' . "\n"
164 . ' <label for="radio_sql_file_compression_bzip">' . $strBzip . '</label> ' . "\n";
167 echo ' <input type="hidden" name="sql_file_compression" value="text/plain" />' . "\n";
175 if (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && $querydisplay_tab == 'files' && (!isset($db) ||
$db == '')) {
177 <b
><?php
echo $strNoDatabasesSelected; ?
></b
>
181 // web-server upload directory
182 $is_upload_dir = false;
183 if ($cfg['UploadDir'] != '' && !isset($is_inside_querywindow) ||
184 ($cfg['UploadDir'] != '' && isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' ||
$querydisplay_tab == 'full')) && isset($db) && $db != '') {
186 if ($handle = @opendir
($cfg['UploadDir'])) {
188 while ($file = @readdir
($handle)) {
189 if (is_file($cfg['UploadDir'] . $file) && substr($file, -4) == '.sql') {
190 if ($is_first == 0) {
191 $is_upload_dir = true;
193 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";
194 echo ' <div style="margin-bottom: 5px">' . "\n";
195 echo ' <select size="1" name="sql_localfile">' . "\n";
196 echo ' <option value="" selected="selected"></option>' . "\n";
197 } // end if (is_first)
198 echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
200 } // end if (is_file)
203 echo ' </select>' . "\n"
204 . ' </div>' . "\n\n";
205 } // end if (isfirst > 0)
208 echo ' <div style="margin-bottom: 5px">' . "\n";
209 echo ' <font color="red">' . $strError . '</font><br />' . "\n";
210 echo ' ' . $strWebServerUploadDirectoryError . "\n";
211 echo ' </div>' . "\n";
213 } // end if (web-server upload directory)
216 // Encoding setting form appended by Y.Kawada
217 if (function_exists('PMA_set_enc_form')) {
218 echo PMA_set_enc_form(' ');
221 // Charset conversion options
222 if (($is_upload ||
$is_upload_dir) &&
223 (!isset($is_inside_querywindow) ||
224 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' ||
$querydisplay_tab == 'full')))
225 && isset($db) && $db != ''){
226 if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
227 echo ' <div style="margin-bottom: 5px">' . "\n";
228 $temp_charset = reset($cfg['AvailableCharsets']);
229 echo $strCharsetOfFile . "\n"
230 . ' <select name="charset_of_file" size="1">' . "\n"
231 . ' <option value="' . $temp_charset . '"';
232 if ($temp_charset == $charset) {
233 echo ' selected="selected"';
235 echo '>' . $temp_charset . '</option>' . "\n";
236 while ($temp_charset = next($cfg['AvailableCharsets'])) {
237 echo ' <option value="' . $temp_charset . '"';
238 if ($temp_charset == $charset) {
239 echo ' selected="selected"';
241 echo '>' . $temp_charset . '</option>' . "\n";
243 echo ' </select><br />' . "\n" . ' ';
244 echo ' </div>' . "\n";
245 } // end if (recoding)
249 $bookmark_go = FALSE;
250 if (!isset($is_inside_querywindow) ||
251 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'history' ||
$querydisplay_tab == 'full'))) {
252 if ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table']) {
253 if (($bookmark_list = PMA_listBookmarks($db, $cfg['Bookmark'])) && count($bookmark_list) > 0) {
254 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";
256 echo ' <div style="margin-bottom: 5px">' . "\n";
257 echo ' <select name="id_bookmark" style="vertical-align: middle">' . "\n";
258 echo ' <option value=""></option>' . "\n";
259 while (list($key, $value) = each($bookmark_list)) {
260 echo ' <option value="' . $value . '">' . htmlspecialchars($key) . '</option>' . "\n";
262 echo ' </select>' . "<br />\n";
263 echo ' ' . $strVar . ' (<a href="./Documentation.html#faqbookmark" target="documentation">' . $strDocu . '</a>): <input type="text" name="bookmark_variable" class="textfield" size="10" />' . "\n";
264 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";
265 echo ' <input type="radio" name="action_bookmark" value="1" id="radio_bookmark1" style="vertical-align: middle" /><label for="radio_bookmark1">' . $strBookmarkView . '</label>' . "\n";
266 echo ' <input type="radio" name="action_bookmark" value="2" id="radio_bookmark2" style="vertical-align: middle" /><label for="radio_bookmark2">' . $strDelete . '</label>' . "\n";
267 echo ' <br />' . "\n";
268 echo ' </div>' . "\n";
274 if (!isset($is_inside_querywindow) ||
(isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && (($querydisplay_tab == 'files' && isset($db) && $db != '') ||
$querydisplay_tab == 'sql' ||
$querydisplay_tab == 'full' ||
($querydisplay_tab == 'history' && $bookmark_go)))) {
276 <input type
="submit" name
="SQL" value
="<?php echo $strGo; ?>" />
280 if (!isset($is_inside_querywindow) ||
281 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' ||
$querydisplay_tab == 'full')) && isset($db) && $db != '') {
283 // loic1: displays import dump feature only if file upload available
284 $ldi_target = 'ldi_table.php3?' . $url_query;
286 if ($is_upload && isset($db) && isset($table)) {
288 <!-- Insert a text file
-->
292 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
296 document
.writeln('<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\' + opener.top.frames.nav.document.hashform.hash.value + \'.location.href = \'' . $ldi_target . '\'; return false;"' : ''); ?>><?php echo $strInsertTextfiles; ?></a></div>');
303 <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' . md5($cfg['PmaAbsoluteUri']) . '.location.href = \'' . $ldi_target . '\'; return false;"' : ''); ?
>><?php
echo $strInsertTextfiles; ?
></a
></div
>