xhtml typo
[phpmyadmin/crack.git] / tbl_query_box.php3
blob6ff4c201349613f8f51c2bfe86927d25a817c7b2
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 {
16 $query_to_display = $sql_query;
18 } else {
19 $query_to_display = '';
21 unset($sql_query);
23 /**
24 * Get the list and number of fields
26 $fields_cnt = 0;
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);
30 if (!$result) {
31 PMA_mysqlDie('', $local_query, '', $err_url);
33 else {
34 $fields_cnt = mysql_num_rows($result);
35 while ($row = PMA_mysql_fetch_array($result)) {
36 $fields_list[] = $row['Field'];
37 } // end while
38 mysql_free_result($result);
42 /**
43 * Work on the table
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();}"'
53 : '';
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))) {
59 /**
60 * Get the list and number of available databases.
62 if ($server > 0) {
63 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
64 } else {
65 $num_dbs = 0;
68 if ($num_dbs > 0) {
69 $queryframe_db_list = '<select size=1 name="db">';
70 for ($i = 0; $i < $num_dbs; $i++) {
71 $t_db = $dblist[$i];
72 $queryframe_db_list .= '<option value="' . htmlspecialchars($t_db) . '">' . htmlspecialchars($t_db) . '</option>';
74 $queryframe_db_list .= '</select>';
76 } else {
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 <?php
91 if (!isset($is_inside_querywindow) ||
92 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full'))) {
94 <!-- Query box and bookmark support -->
95 <li>
96 <a name="querybox"></a>
97 <?php echo sprintf($strRunSQLQuery, htmlspecialchars($db)) . $queryframe_db_list . ' ' . PMA_showMySQLDocu('Reference', 'SELECT'); ?>
98 <?php if (isset($table) && $fields_cnt > 0) { ?>
99 &nbsp;&nbsp;&nbsp;<?php echo $strFields; ?>:
100 <select name="dummy" size="1">
101 <?php
102 echo "\n";
103 for ($i = 0 ; $i < $fields_cnt; $i++) {
104 echo ' '
105 . '<option value="' . urlencode($fields_list[$i]) . '">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
108 </select>
109 <input type="button" name="insert" value="<?php echo($strInsert); ?>" onclick="sqlform.sql_query.value = sqlform.sql_query.value + sqlform.dummy.value" />
110 <?php
113 <br />
114 <div style="margin-bottom: 5px">
115 <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; ?>>
116 <?php echo ((!empty($query_to_display)) ? htmlspecialchars($query_to_display) : 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE 1'); ?>
117 </textarea><br />
118 <input type="checkbox" name="show_query" value="1" id="checkbox_show_query" checked="checked" />&nbsp;
119 <label for="checkbox_show_query"><?php echo $strShowThisQuery; ?></label><br />
120 </div>
121 <?php
122 } else {
124 <input type="hidden" name="sql_query" value="" />
125 <input type="hidden" name="show_query" value="1" />
126 <?php
129 // loic1: displays import dump feature only if file upload available
130 if ($is_upload && (!isset($is_inside_querywindow) ||
131 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' || $querydisplay_tab == 'full')))) {
132 echo ' ' . ((isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && $querydisplay_tab == 'full') || !isset($is_inside_querywindow) ? '<i>' . $strOr . '</i>' : '') . ' ' . $strLocationTextfile . '&nbsp;:<br />' . "\n";
134 <div style="margin-bottom: 5px">
135 <input type="file" name="sql_file" class="textfield" /><br />
136 <?php
137 if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
138 $temp_charset = reset($cfg['AvailableCharsets']);
139 echo $strCharsetOfFile . "\n"
140 . ' <select name="charset_of_file" size="1">' . "\n"
141 . ' <option value="' . $temp_charset . '"';
142 if ($temp_charset == $charset) {
143 echo ' selected="selected"';
145 echo '>' . $temp_charset . '</option>' . "\n";
146 while ($temp_charset = next($cfg['AvailableCharsets'])) {
147 echo ' <option value="' . $temp_charset . '"';
148 if ($temp_charset == $charset) {
149 echo ' selected="selected"';
151 echo '>' . $temp_charset . '</option>' . "\n";
152 } // end while
153 echo ' </select><br />' . "\n" . ' ';
154 } // end if
155 $is_gzip = ($cfg['GZipDump'] && @function_exists('gzopen'));
156 $is_bzip = ($cfg['BZipDump'] && @function_exists('bzdecompress'));
157 if ($is_bzip || $is_gzip) {
158 echo ' ' . $strCompression . ':' . "\n"
159 . ' <input type="radio" id="radio_sql_file_compression_plain" name="sql_file_compression" value="text/plain" checked="checked" />' . "\n"
160 . ' <label for="radio_sql_file_compression_plain">' . $strNone . '</label>&nbsp;&nbsp;&nbsp;' . "\n";
161 if ($is_gzip) {
162 echo ' <input type="radio" id="radio_sql_file_compression_gzip" name="sql_file_compression" value="application/x-gzip" />' . "\n"
163 . ' <label for="radio_sql_file_compression_gzip">' . $strGzip . '</label>&nbsp;&nbsp;&nbsp;' . "\n";
165 if ($is_bzip) {
166 echo ' <input type="radio" id="radio_sql_file_compression_bzip" name="sql_file_compression" value="application/x-bzip" />' . "\n"
167 . ' <label for="radio_sql_file_compression_bzip">' . $strBzip . '</label>&nbsp;&nbsp;&nbsp;' . "\n";
169 } else {
170 echo ' <input type="hidden" name="sql_file_compression" value="text/plain" />' . "\n";
173 </div>
174 <?php
175 } // end if
176 echo "\n";
178 // Encoding setting form appended by Y.Kawada
179 if (function_exists('PMA_set_enc_form')) {
180 echo PMA_set_enc_form(' ');
183 // Bookmark Support
184 $bookmark_go = FALSE;
185 if (!isset($is_inside_querywindow) ||
186 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full'))) {
187 if ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table']) {
188 if (($bookmark_list = PMA_listBookmarks($db, $cfg['Bookmark'])) && count($bookmark_list) > 0) {
189 echo " " . ((isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && $querydisplay_tab == 'full') || !isset($is_inside_querywindow) ? "<i>$strOr</i>" : '') . " $strBookmarkQuery&nbsp;:<br />\n";
191 echo ' <div style="margin-bottom: 5px">' . "\n";
192 echo ' <select name="id_bookmark" style="vertical-align: middle">' . "\n";
193 echo ' <option value=""></option>' . "\n";
194 while (list($key, $value) = each($bookmark_list)) {
195 echo ' <option value="' . $value . '">' . htmlentities($key) . '</option>' . "\n";
197 echo ' </select>' . "<br />\n";
198 echo ' ' . $strVar . ' (<a href="./Documentation.html#faqbookmark" target="documentation">' . $strDocu . '</a>): <input type="text" name="bookmark_variable" class="textfield" size="10" />' . "\n";
199 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";
200 echo ' &nbsp;<input type="radio" name="action_bookmark" value="1" id="radio_bookmark1" style="vertical-align: middle" /><label for="radio_bookmark1">' . $strBookmarkView . '</label>' . "\n";
201 echo ' &nbsp;<input type="radio" name="action_bookmark" value="2" id="radio_bookmark2" style="vertical-align: middle" /><label for="radio_bookmark2">' . $strDelete . '</label>' . "\n";
202 echo ' <br />' . "\n";
203 echo ' </div>' . "\n";
204 $bookmark_go = TRUE;
209 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)))) {
211 <input type="submit" name="SQL" value="<?php echo $strGo; ?>" />
212 </li>
213 <?php
216 if (!isset($is_inside_querywindow) ||
217 (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' || $querydisplay_tab == 'full'))) {
219 // loic1: displays import dump feature only if file upload available
220 $ldi_target = 'ldi_table.php3?' . $url_query;
222 if ($is_upload && isset($db) && isset($table)) {
224 <!-- Insert a text file -->
225 <br /><br />
226 <li>
227 <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>
228 </li>
229 <?php
232 echo "\n";
234 </form>