3 // vim: expandtab sw=4 ts=4 sts=4:
7 if (!defined('PMA_COMMON_LIB_INCLUDED')) {
8 include('./libraries/common.lib.php3');
10 if (!defined('PMA_BOOKMARK_LIB_INCLUDED')) {
11 include('./libraries/bookmark.lib.php3');
14 if (!($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'sql' ||
$querydisplay_tab == 'full'))) {
15 PMA_checkParameters(array('db','table','url_query'));
19 * Defines the query to be displayed in the query textarea
21 if (isset($show_query) && $show_query == '1') {
22 // This script has been called by read_dump.php3
23 if (isset($sql_query_cpy)) {
24 $query_to_display = $sql_query_cpy;
28 $query_to_display = $sql_query;
31 $query_to_display = '';
36 * Get the list and number of fields
39 if (isset($db) && isset($table) && $table != '' && $db != '') {
40 $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
41 $result = @PMA_mysql_query
($local_query);
43 PMA_mysqlDie('', $local_query, '', $err_url);
46 $fields_cnt = mysql_num_rows($result);
47 while ($row = PMA_mysql_fetch_array($result)) {
48 $fields_list[] = $row['Field'];
50 mysql_free_result($result);
57 // loic1: defines wether file upload is available or not
58 // ($is_upload now defined in common.lib.php3)
60 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'sql' ||
$querydisplay_tab == 'full')) {
61 $locking = 'onKeyPress="document.sqlform.elements[\'LockFromUpdate\'].checked = true;"';
66 $auto_sel = ($cfg['TextareaAutoSelect']
67 // 2003-02-05 rabus: This causes big trouble with Opera 7 for
68 // Windows, so let's disable it there...
69 && !(PMA_USR_OS
== 'Win' && PMA_USR_BROWSER_AGENT
== 'OPERA' && PMA_USR_BROWSER_VER
>= 7))
70 ?
"\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; document.sqlform.elements[\'sql_query\'].select();}"'
72 $auto_sel .= ' ' . $locking;
74 // garvin: If non-JS query window is embedded, display a list of databases to choose from.
75 // Apart from that, a non-js query window sucks badly.
77 if ($cfg['QueryFrame'] && (!$cfg['QueryFrameJS'] && !$db ||
($cfg['QueryFrameJS'] && !$db))) {
79 * Get the list and number of available databases.
82 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
88 $queryframe_db_list = '<select size=1 name="db">';
89 for ($i = 0; $i < $num_dbs; $i++
) {
91 $queryframe_db_list .= '<option value="' . htmlspecialchars($t_db) . '">' . htmlspecialchars($t_db) . '</option>';
93 $queryframe_db_list .= '</select>';
95 $queryframe_db_list = '';
98 $queryframe_db_list = '';
103 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && isset($is_inside_querywindow) && $is_inside_querywindow) {
105 <script type
="text/javascript">
107 document
.writeln('<form method="post" target="phpmain' +
<?php
echo ((isset($is_inside_querywindow) && $is_inside_querywindow == TRUE) ?
'opener.' : '');?
>parent
.frames
.queryframe
.document
.hashform
.hash
.value +
'" action="read_dump.php3"<?php if ($is_upload) echo ' enctype
="multipart/form-data"'; ?> onsubmit="return checkSqlQuery(this)" name="sqlform">');
111 <form method
="post" target
="phpmain<?php echo md5($cfg['PmaAbsoluteUri']); ?>" action
="read_dump.php3"<?php
if ($is_upload) echo ' enctype="multipart/form-data"'; ?
> name
="sqlform">
116 <form method
="post" action
="read_dump.php3"<?php
if ($is_upload) echo ' enctype="multipart/form-data"'; ?
> onsubmit
="return checkSqlQuery(this)" name
="sqlform">
120 <input type
="hidden" name
="is_js_confirmed" value
="0" />
121 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
122 <input type
="hidden" name
="pos" value
="0" />
123 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
124 <input type
="hidden" name
="zero_rows" value
="<?php echo $strSuccess; ?>" />
125 <input type
="hidden" name
="prev_sql_query" value
="<?php echo ((!empty($query_to_display)) ? urlencode($query_to_display) : ''); ?>" />
127 if (!isset($is_inside_querywindow) ||
128 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'sql' ||
$querydisplay_tab == 'full'))) {
130 <!-- Query box
and bookmark support
-->
132 if (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE) {
134 <input type
="hidden" name
="focus_querywindow" value
="true" />
138 <a name
="querybox"></a
>
139 <table cellpadding
="1" cellspacing
="1">
142 <?php
echo sprintf($strRunSQLQuery, htmlspecialchars($db)) . $queryframe_db_list . (isset($is_inside_querywindow) ?
'<br />' : ' ') . PMA_showMySQLDocu('Reference', 'SELECT'); ?
>
144 <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; ?
>>
145 <?php
echo ((!empty($query_to_display)) ?
htmlspecialchars($query_to_display) : 'SELECT * FROM ' . htmlspecialchars(PMA_backquote($table)) . ' WHERE 1'); ?
></textarea
>
147 <?php
if (isset($table) && $fields_cnt > 0) { ?
>
148 <td align
="center" valign
="top"><?php
echo (isset($is_inside_querywindow) ?
'<br />' : '') . $strFields; ?
>:<br
/>
149 <select name
="dummy" size
="4" multiple
>
152 for ($i = 0 ; $i < $fields_cnt; $i++
) {
154 . '<option value="' . PMA_backquote(htmlspecialchars($fields_list[$i])) . '">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
157 </select
><br
/><br
/>
158 <input type
="button" name
="insert" value
="<?php echo($strInsert); ?>" onclick
="insertValueQuery()" />
165 <input type
="checkbox" name
="show_query" value
="1" id
="checkbox_show_query" checked
="checked" /> 
;
166 <label
for="checkbox_show_query"><?php
echo $strShowThisQuery; ?
></label
><br
/>
168 if (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE) {
170 <script type
="text/javascript">
171 document
.writeln('<input type="checkbox" name="LockFromUpdate" value="1" id="checkbox_lock" /> ');
172 document
.writeln(' <label for="checkbox_lock"><?php echo $strQueryWindowLock; ?></label><br />');
183 <input type
="hidden" name
="sql_query" value
="" />
184 <input type
="hidden" name
="show_query" value
="1" />
188 // loic1: displays import dump feature only if file upload available
189 if ($is_upload && (!isset($is_inside_querywindow) ||
190 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' ||
$querydisplay_tab == 'full')))) {
192 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";
194 <div style
="margin-bottom: 5px">
195 <input type
="file" name
="sql_file" class="textfield" /><br
/>
197 if (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE) {
199 <input type
="hidden" name
="focus_querywindow" value
="true" />
203 $is_gzip = ($cfg['GZipDump'] && @function_exists
('gzopen'));
204 $is_bzip = ($cfg['BZipDump'] && @function_exists
('bzdecompress'));
205 if ($is_bzip ||
$is_gzip) {
206 echo ' ' . $strCompression . ':' . "\n"
207 . ' <input type="radio" id="radio_sql_file_compression_auto" name="sql_file_compression" value="" checked="checked" />' . "\n"
208 . ' <label for="radio_sql_file_compression_auto">' . $strAutodetect . '</label> ' . "\n"
209 . ' <input type="radio" id="radio_sql_file_compression_plain" name="sql_file_compression" value="text/plain" />' . "\n"
210 . ' <label for="radio_sql_file_compression_plain">' . $strNone . '</label> ' . "\n";
212 echo ' <input type="radio" id="radio_sql_file_compression_gzip" name="sql_file_compression" value="application/x-gzip" />' . "\n"
213 . ' <label for="radio_sql_file_compression_gzip">' . $strGzip . '</label> ' . "\n";
216 echo ' <input type="radio" id="radio_sql_file_compression_bzip" name="sql_file_compression" value="application/x-bzip" />' . "\n"
217 . ' <label for="radio_sql_file_compression_bzip">' . $strBzip . '</label> ' . "\n";
220 echo ' <input type="hidden" name="sql_file_compression" value="text/plain" />' . "\n";
228 // web-server upload directory
229 $is_upload_dir = false;
230 if (!empty($cfg['UploadDir']) && !isset($is_inside_querywindow) ||
231 (!empty($cfg['UploadDir']) && isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' ||
$querydisplay_tab == 'full'))) {
233 if (substr($cfg['UploadDir'], -1) != '/') {
234 $cfg['UploadDir'] .= '/';
236 if ($handle = @opendir
($cfg['UploadDir'])) {
237 if (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE) {
239 <input type
="hidden" name
="focus_querywindow" value
="true" />
244 while ($file = @readdir
($handle)) {
245 if (is_file($cfg['UploadDir'] . $file) && PMA_checkFileExtensions($file, '.sql')) {
246 if ($is_first == 0) {
247 $is_upload_dir = true;
249 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";
250 echo ' <div style="margin-bottom: 5px">' . "\n";
251 echo ' <select size="1" name="sql_localfile">' . "\n";
252 echo ' <option value="" selected="selected"></option>' . "\n";
254 } // end if (is_first)
255 echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
257 } // end if (is_file)
260 echo ' </select>' . "\n"
261 . ' </div>' . "\n\n";
262 } // end if (isfirst > 0)
265 echo ' <div style="margin-bottom: 5px">' . "\n";
266 echo ' <font color="red">' . $strError . '</font><br />' . "\n";
267 echo ' ' . $strWebServerUploadDirectoryError . "\n";
268 echo ' </div>' . "\n";
270 } // end if (web-server upload directory)
273 // Encoding setting form appended by Y.Kawada
274 if (function_exists('PMA_set_enc_form')) {
275 echo PMA_set_enc_form(' ');
279 // Charset conversion options
280 if (($is_upload ||
$is_upload_dir) &&
281 (!isset($is_inside_querywindow) ||
282 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' ||
$querydisplay_tab == 'full')))
283 && isset($db) && $db != ''){
284 if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
286 echo ' <div style="margin-bottom: 5px">' . "\n";
287 $temp_charset = reset($cfg['AvailableCharsets']);
288 echo $strCharsetOfFile . "\n"
289 . ' <select name="charset_of_file" size="1">' . "\n"
290 . ' <option value="' . $temp_charset . '"';
291 if ($temp_charset == $charset) {
292 echo ' selected="selected"';
294 echo '>' . $temp_charset . '</option>' . "\n";
295 while ($temp_charset = next($cfg['AvailableCharsets'])) {
296 echo ' <option value="' . $temp_charset . '"';
297 if ($temp_charset == $charset) {
298 echo ' selected="selected"';
300 echo '>' . $temp_charset . '</option>' . "\n";
302 echo ' </select><br />' . "\n" . ' ';
303 echo ' </div>' . "\n";
304 } // end if (recoding)
308 $bookmark_go = FALSE;
309 if (!isset($is_inside_querywindow) ||
310 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'history' ||
$querydisplay_tab == 'full'))) {
311 if ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table']) {
312 if (($bookmark_list = PMA_listBookmarks($db, $cfg['Bookmark'])) && count($bookmark_list) > 0) {
314 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";
316 if (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE) {
318 <input type
="hidden" name
="focus_querywindow" value
="true" />
322 echo ' <div style="margin-bottom: 5px">' . "\n";
323 echo ' <select name="id_bookmark" style="vertical-align: middle">' . "\n";
324 echo ' <option value=""></option>' . "\n";
325 while (list($key, $value) = each($bookmark_list)) {
326 echo ' <option value="' . $value . '">' . htmlspecialchars($key) . '</option>' . "\n";
328 echo ' </select>' . "<br />\n";
329 echo ' ' . $strVar . ' (<a href="./Documentation.html#faqbookmark" target="documentation">' . $strDocu . '</a>): <input type="text" name="bookmark_variable" class="textfield" size="10" />' . "\n";
330 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";
331 echo ' <input type="radio" name="action_bookmark" value="1" id="radio_bookmark1" style="vertical-align: middle" /><label for="radio_bookmark1">' . $strBookmarkView . '</label>' . "\n";
332 echo ' <input type="radio" name="action_bookmark" value="2" id="radio_bookmark2" style="vertical-align: middle" /><label for="radio_bookmark2">' . $strDelete . '</label>' . "\n";
333 echo ' <br />' . "\n";
334 echo ' </div>' . "\n";
340 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)))) {
341 if ($form_items > 0) {
346 <input type
="submit" name
="SQL" value
="<?php echo $strGo; ?>" />
349 if (!isset($is_inside_querywindow) ||
isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && $querydisplay_tab != 'history') {
352 <input type
="submit" name
="SQLbookmark" value
="<?php echo $strGo . ' & ' . $strBookmarkThis; ?>" />
357 <legend
><?php
echo $strBookmarkOptions; ?
></legend
>
358 <?php
echo $strBookmarkLabel; ?
>: <input type
="text" name
="bkm_label" value
="" /><br
/>
359 <input type
="checkbox" name
="bkm_all_users" id
="id_bkm_all_users" value
="true" /><label
for="id_bkm_all_users"><?php
echo $strBookmarkAllUsers; ?
></label
>
369 // TODO: Add a more complete warning that no items (like for file import) where found.
370 // (After 2.5.2 release!)
371 echo $strWebServerUploadDirectoryError;
377 if (!isset($is_inside_querywindow) ||
378 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' ||
$querydisplay_tab == 'full')) && isset($db) && $db != '') {
380 // loic1: displays import dump feature only if file upload available
381 $ldi_target = 'ldi_table.php3?' . $url_query . (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE ?
'&focus_querywindow=true' : '');
383 if ($is_upload && isset($db) && isset($table)) {
385 <!-- Insert a text file
-->
389 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
392 <script type
="text/javascript">
393 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.parent.frames.phpmain\' + opener.parent.frames.queryframe.document.hashform.hash.value + \'.location.href = \\\'' . $ldi_target . '\\\'; return false;"' : ''); ?>><?php echo addslashes($strInsertTextfiles); ?></a></div>');
400 <script type
="text/javascript">
401 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.parent.frames.phpmain' . md5($cfg['PmaAbsoluteUri']) . '.location.href = \\\'' . $ldi_target . '\\\'; return false;"' : ''); ?>><?php echo addslashes($strInsertTextfiles); ?></a></div>');
409 <div style
="margin-bottom: 10px"><a href
="<?php echo $ldi_target; ?>"><?php
echo $strInsertTextfiles; ?
></a
></div
>