updates
[phpmyadmin/crack.git] / tbl_query_box.php3
blob7d1b31ff6592abf2a003a32cfc76276a2e5b362d
1 <?php
2 /* $Id$ */
5 /**
6 * Defines the query to be displayed in the query textarea
7 */
8 if (isset($show_query) && $show_query == '1') {
9 // This script has been called by read_dump.php3
10 if (isset($sql_query_cpy)) {
11 $query_to_display = $sql_query_cpy;
13 // Other cases
14 else if (get_magic_quotes_gpc()) {
15 $query_to_display = stripslashes($sql_query);
17 else {
18 $query_to_display = $sql_query;
20 } else {
21 $query_to_display = '';
23 unset($sql_query);
26 /**
27 * Get the list and number of fields
29 $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
30 $result = @PMA_mysql_query($local_query);
31 if (!$result) {
32 PMA_mysqlDie('', $local_query, '', $err_url);
34 else {
35 $fields_cnt = mysql_num_rows($result);
36 while ($row = PMA_mysql_fetch_array($result)) {
37 $fields_list[] = $row['Field'];
38 } // end while
39 mysql_free_result($result);
43 /**
44 * Work on the table
46 // loic1: defines wether file upload is available or not
47 // lem9: we should check if PHP 4.0.0 really implements the "file_uploads"
48 // variable, because I got a support request and his 4.0.0 did not have it
50 $is_upload = (PMA_PHP_INT_VERSION >= 40000 && function_exists('ini_get'))
51 ? ((strtolower(ini_get('file_uploads')) == 'on' || ini_get('file_uploads') == 1) && intval(ini_get('upload_max_filesize')))
52 // loic1: php 3.0.15 and lower bug -> always enabled
53 : (PMA_PHP_INT_VERSION < 30016 || intval(@get_cfg_var('upload_max_filesize')));
55 $auto_sel = ($cfg['TextareaAutoSelect'])
56 ? "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; this.form.elements[\'sql_query\'].select();}"'
57 : '';
59 <!-- Query box and bookmark support -->
60 <li>
61 <a name="querybox"></a>
62 <form method="post" action="read_dump.php3"<?php if ($is_upload) echo ' enctype="multipart/form-data"'; echo "\n"; ?>
63 onsubmit="return checkSqlQuery(this)" name="sqlform">
64 <input type="hidden" name="is_js_confirmed" value="0" />
65 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
66 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
67 <input type="hidden" name="server" value="<?php echo $server; ?>" />
68 <input type="hidden" name="db" value="<?php echo $db; ?>" />
69 <input type="hidden" name="table" value="<?php echo $table; ?>" />
70 <input type="hidden" name="pos" value="0" />
71 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
72 <input type="hidden" name="zero_rows" value="<?php echo $strSuccess; ?>" />
73 <input type="hidden" name="prev_sql_query" value="<?php echo ((!empty($query_to_display)) ? urlencode($query_to_display) : ''); ?>" />
74 <?php echo sprintf($strRunSQLQuery, htmlspecialchars($db)) . ' ' . PMA_showMySQLDocu('Reference', 'SELECT') . '&nbsp;&nbsp;&nbsp;' . $strFields . ':' . "\n"; ?>
75 <select name="dummy" size="1">
76 <?php
77 echo "\n";
78 for ($i = 0 ; $i < $fields_cnt; $i++) {
79 echo ' '
80 . '<option value="' . urlencode($fields_list[$i]) . '">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
83 </select>
84 <input type="button" name="insert" value="<?php echo($strInsert); ?>" onclick="sqlform.sql_query.value = sqlform.sql_query.value + sqlform.dummy.value" />
85 <br />
86 <div style="margin-bottom: 5px">
87 <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; ?>>
88 <?php echo ((!empty($query_to_display)) ? htmlspecialchars($query_to_display) : 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE 1'); ?>
89 </textarea><br />
90 <input type="checkbox" name="show_query" value="1" id="checkbox_show_query" checked="checked" />&nbsp;
91 <label for="checkbox_show_query"><?php echo $strShowThisQuery; ?></label><br />
92 </div>
93 <?php
94 // loic1: displays import dump feature only if file upload available
95 if ($is_upload) {
96 echo ' <i>' . $strOr . '</i> ' . $strLocationTextfile . '&nbsp;:<br />' . "\n";
98 <div style="margin-bottom: 5px">
99 <input type="file" name="sql_file" class="textfield" /><br />
100 <?php
101 if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
102 $temp_charset = reset($cfg['AvailableCharsets']);
103 echo $strCharsetOfFile . "\n"
104 . ' <select name="charset_of_file" size="1">' . "\n"
105 . ' <option value="' . $temp_charset . '"';
106 if ($temp_charset == $charset) {
107 echo ' selected="selected"';
109 echo '>' . $temp_charset . '</option>' . "\n";
110 while ($temp_charset = next($cfg['AvailableCharsets'])) {
111 echo ' <option value="' . $temp_charset . '"';
112 if ($temp_charset == $charset) {
113 echo ' selected="selected"';
115 echo '>' . $temp_charset . '</option>' . "\n";
116 } // end while
117 echo ' </select>';
118 } // end if
119 echo "\n";
121 </div>
122 <?php
123 } // end if
124 echo "\n";
126 // Encoding setting form appended by Y.Kawada
127 if (function_exists('PMA_set_enc_form')) {
128 echo PMA_set_enc_form(' ');
131 // Bookmark Support
132 if ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table']) {
133 if (($bookmark_list = PMA_listBookmarks($db, $cfg['Bookmark'])) && count($bookmark_list) > 0) {
134 echo " <i>$strOr</i> $strBookmarkQuery&nbsp;:<br />\n";
135 echo ' <div style="margin-bottom: 5px">' . "\n";
136 echo ' <select name="id_bookmark" style="vertical-align: middle">' . "\n";
137 echo ' <option value=""></option>' . "\n";
138 while (list($key, $value) = each($bookmark_list)) {
139 echo ' <option value="' . $value . '">' . htmlentities($key) . '</option>' . "\n";
141 echo ' </select>' . "\n";
142 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";
143 echo ' &nbsp;<input type="radio" name="action_bookmark" value="1" id="radio_bookmark1" style="vertical-align: middle" /><label for="radio_bookmark1">' . $strBookmarkView . '</label>' . "\n";
144 echo ' &nbsp;<input type="radio" name="action_bookmark" value="2" id="radio_bookmark2" style="vertical-align: middle" /><label for="radio_bookmark2">' . $strDelete . '</label>' . "\n";
145 echo ' <br />' . "\n";
146 echo ' </div>' . "\n";
150 <input type="submit" name="SQL" value="<?php echo $strGo; ?>" />
151 </form>
152 </li>
154 <?php
155 // loic1: displays import dump feature only if file upload available
156 if ($is_upload) {
158 <!-- Insert a text file -->
159 <li>
160 <div style="margin-bottom: 10px"><a href="ldi_table.php3?<?php echo $url_query; ?>"><?php echo $strInsertTextfiles; ?></a></div>
161 </li>
162 <?php
164 echo "\n";