tbl_move_copy
[phpmyadmin/crack.git] / tbl_query_box.php3
blobe772f98ca8ab496e8c0d322087d938a8b7cd604c
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Defines the query to be displayed in the query textarea
8 */
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;
14 // Other cases
15 else if (get_magic_quotes_gpc()) {
16 $query_to_display = stripslashes($sql_query);
18 else {
19 $query_to_display = $sql_query;
21 } else {
22 $query_to_display = '';
24 unset($sql_query);
27 /**
28 * Get the list and number of fields
30 $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
31 $result = @PMA_mysql_query($local_query);
32 if (!$result) {
33 PMA_mysqlDie('', $local_query, '', $err_url);
35 else {
36 $fields_cnt = mysql_num_rows($result);
37 while ($row = PMA_mysql_fetch_array($result)) {
38 $fields_list[] = $row['Field'];
39 } // end while
40 mysql_free_result($result);
44 /**
45 * Work on the table
47 // loic1: defines wether file upload is available or not
48 // lem9: we should check if PHP 4.0.0 really implements the "file_uploads"
49 // variable, because I got a support request and his 4.0.0 did not have it
51 $is_upload = (PMA_PHP_INT_VERSION >= 40000 && function_exists('ini_get'))
52 ? ((strtolower(ini_get('file_uploads')) == 'on' || ini_get('file_uploads') == 1) && intval(ini_get('upload_max_filesize')))
53 // loic1: php 3.0.15 and lower bug -> always enabled
54 : (PMA_PHP_INT_VERSION < 30016 || intval(@get_cfg_var('upload_max_filesize')));
56 $auto_sel = ($cfg['TextareaAutoSelect'])
57 ? "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; this.form.elements[\'sql_query\'].select();}"'
58 : '';
60 <!-- Query box and bookmark support -->
61 <li>
62 <a name="querybox"></a>
63 <form method="post" action="read_dump.php3"<?php if ($is_upload) echo ' enctype="multipart/form-data"'; echo "\n"; ?>
64 onsubmit="return checkSqlQuery(this)" name="sqlform">
65 <input type="hidden" name="is_js_confirmed" value="0" />
66 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
67 <input type="hidden" name="pos" value="0" />
68 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
69 <input type="hidden" name="zero_rows" value="<?php echo $strSuccess; ?>" />
70 <input type="hidden" name="prev_sql_query" value="<?php echo ((!empty($query_to_display)) ? urlencode($query_to_display) : ''); ?>" />
71 <?php echo sprintf($strRunSQLQuery, htmlspecialchars($db)) . ' ' . PMA_showMySQLDocu('Reference', 'SELECT') . '&nbsp;&nbsp;&nbsp;' . $strFields . ':' . "\n"; ?>
72 <select name="dummy" size="1">
73 <?php
74 echo "\n";
75 for ($i = 0 ; $i < $fields_cnt; $i++) {
76 echo ' '
77 . '<option value="' . urlencode($fields_list[$i]) . '">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
80 </select>
81 <input type="button" name="insert" value="<?php echo($strInsert); ?>" onclick="sqlform.sql_query.value = sqlform.sql_query.value + sqlform.dummy.value" />
82 <br />
83 <div style="margin-bottom: 5px">
84 <textarea name="sql_query" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols'] * 2; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>"<?php echo $auto_sel; ?>>
85 <?php echo ((!empty($query_to_display)) ? htmlspecialchars($query_to_display) : 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE 1'); ?>
86 </textarea><br />
87 <input type="checkbox" name="show_query" value="1" id="checkbox_show_query" checked="checked" />&nbsp;
88 <label for="checkbox_show_query"><?php echo $strShowThisQuery; ?></label><br />
89 </div>
90 <?php
91 // loic1: displays import dump feature only if file upload available
92 if ($is_upload) {
93 echo ' <i>' . $strOr . '</i> ' . $strLocationTextfile . '&nbsp;:<br />' . "\n";
95 <div style="margin-bottom: 5px">
96 <input type="file" name="sql_file" class="textfield" /><br />
97 <?php
98 if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
99 $temp_charset = reset($cfg['AvailableCharsets']);
100 echo $strCharsetOfFile . "\n"
101 . ' <select name="charset_of_file" size="1">' . "\n"
102 . ' <option value="' . $temp_charset . '"';
103 if ($temp_charset == $charset) {
104 echo ' selected="selected"';
106 echo '>' . $temp_charset . '</option>' . "\n";
107 while ($temp_charset = next($cfg['AvailableCharsets'])) {
108 echo ' <option value="' . $temp_charset . '"';
109 if ($temp_charset == $charset) {
110 echo ' selected="selected"';
112 echo '>' . $temp_charset . '</option>' . "\n";
113 } // end while
114 echo ' </select><br />' . "\n" . ' ';
115 } // end if
116 $is_gzip = ($cfg['GZipDump'] && @function_exists('gzopen'));
117 $is_bzip = ($cfg['BZipDump'] && @function_exists('bzdecompress'));
118 if ($is_bzip || $is_gzip) {
119 echo ' ' . $strCompression . ':' . "\n"
120 . ' <input type="radio" id="radio_sql_file_compression_plain" name="sql_file_compression" value="text/plain" checked="checked" />' . "\n"
121 . ' <label for="radio_sql_file_compression_plain">' . $strNone . '</label>&nbsp;&nbsp;&nbsp;' . "\n";
122 if ($is_gzip) {
123 echo ' <input type="radio" id="radio_sql_file_compression_gzip" name="sql_file_compression" value="application/x-gzip" />' . "\n"
124 . ' <label for="radio_sql_file_compression_gzip">' . $strGzip . '</label>&nbsp;&nbsp;&nbsp;' . "\n";
126 if ($is_bzip) {
127 echo ' <input type="radio" id="radio_sql_file_compression_bzip" name="sql_file_compression" value="application/x-bzip" />' . "\n"
128 . ' <label for="radio_sql_file_compression_bzip">' . $strBzip . '</label>&nbsp;&nbsp;&nbsp;' . "\n";
130 } else {
131 echo ' <input type="hidden" name="sql_file_compression" value="text/plain" />' . "\n";
134 </div>
135 <?php
136 } // end if
137 echo "\n";
139 // Encoding setting form appended by Y.Kawada
140 if (function_exists('PMA_set_enc_form')) {
141 echo PMA_set_enc_form(' ');
144 // Bookmark Support
145 if ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table']) {
146 if (($bookmark_list = PMA_listBookmarks($db, $cfg['Bookmark'])) && count($bookmark_list) > 0) {
147 echo " <i>$strOr</i> $strBookmarkQuery&nbsp;:<br />\n";
148 echo ' <div style="margin-bottom: 5px">' . "\n";
149 echo ' <select name="id_bookmark" style="vertical-align: middle">' . "\n";
150 echo ' <option value=""></option>' . "\n";
151 while (list($key, $value) = each($bookmark_list)) {
152 echo ' <option value="' . $value . '">' . htmlentities($key) . '</option>' . "\n";
154 echo ' </select>' . "\n";
155 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";
156 echo ' &nbsp;<input type="radio" name="action_bookmark" value="1" id="radio_bookmark1" style="vertical-align: middle" /><label for="radio_bookmark1">' . $strBookmarkView . '</label>' . "\n";
157 echo ' &nbsp;<input type="radio" name="action_bookmark" value="2" id="radio_bookmark2" style="vertical-align: middle" /><label for="radio_bookmark2">' . $strDelete . '</label>' . "\n";
158 echo ' <br />' . "\n";
159 echo ' </div>' . "\n";
163 <input type="submit" name="SQL" value="<?php echo $strGo; ?>" />
164 </form>
165 </li>
167 <?php
168 // loic1: displays import dump feature only if file upload available
169 if ($is_upload) {
171 <!-- Insert a text file -->
172 <li>
173 <div style="margin-bottom: 10px"><a href="ldi_table.php3?<?php echo $url_query; ?>"><?php echo $strInsertTextfiles; ?></a></div>
174 </li>
175 <?php
177 echo "\n";