Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 217 lines (201 sloc) 9.481 kb
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4
5
6 /**
7 * Does the common work
8 */
9 require('./server_common.inc.php');
10
11
12 /**
13 * Displays the links
14 */
15 require('./server_links.inc.php');
16
17
18
19 /**
20 * Database work
21 */
22 if (isset($show_query) && $show_query == '1') {
23 // This script has been called by read_dump.php
24 if (isset($sql_query_cpy)) {
25 $query_to_display = $sql_query_cpy;
26 }
27 // Other cases
28 else {
29 $query_to_display = $sql_query;
30 }
31 } else {
32 $query_to_display = '';
33 }
34
35
36 // loic1: defines wether file upload is available or not
37 // (now defined in common.lib.php)
38
39 $auto_sel = ($cfg['TextareaAutoSelect']
40 // 2003-02-05 rabus: This causes big trouble with Opera 7 for
41 // Windows, so let's disable it there...
42 && !(PMA_USR_OS == 'Win' && PMA_USR_BROWSER_AGENT == 'OPERA' && PMA_USR_BROWSER_VER >= 7))
43 ? "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; this.form.elements[\'sql_query\'].select();}"'
44 : '';
45
46
47 // for better administration
48 $strHiddenFields = ' <input type="hidden" name="is_js_confirmed" value="0" />' ."\n"
49 . ' ' .PMA_generate_common_hidden_inputs() . "\n"
50 . ' <input type="hidden" name="pos" value="0" />' . "\n"
51 . ' <input type="hidden" name="goto" value="server_sql.php" />' . "\n"
52 . ' <input type="hidden" name="zero_rows" value="' . htmlspecialchars($strSuccess) . '" />' . "\n"
53 . ' <input type="hidden" name="prev_sql_query" value="' . ((!empty($query_to_display)) ? htmlspecialchars($query_to_display) : '') . '" />' . "\n";
54 ?>
55 <!-- Query box, sql file loader and bookmark support -->
56 <form method="post" action="read_dump.php"<?php if ($is_upload) echo ' enctype="multipart/form-data"'; ?> onsubmit="return checkSqlQuery(this)" name="sqlform">
57 <?php
58 echo $strHiddenFields;
59 ?>
60 <a name="querybox"></a>
61 <table border="0" cellpadding="2" cellspacing="0">
62 <tr><td class="tblHeaders" colspan="2">
63 <?php
64 echo '&nbsp;' . sprintf($strRunSQLQueryOnServer, htmlspecialchars($GLOBALS['cfg']['Servers'][$server]['host'])) . ':&nbsp;' . PMA_showMySQLDocu('Reference', 'SELECT');
65
66 ?>
67 </td></tr>
68 <tr align="center" bgcolor="<?php echo $cfg['BgcolorOne']; ?>"><td colspan="2">
69 <textarea name="sql_query" cols="<?php echo $cfg['TextareaCols'] * 2; ?>" rows="<?php echo $cfg['TextareaRows']; ?>" dir="<?php echo $text_dir; ?>"<?php echo $auto_sel; ?>>
70 <?php
71 if (!empty($query_to_display)) {
72 echo htmlspecialchars($query_to_display);
73 }
74 ?></textarea>
75 </td></tr>
76 <tr class="tblFooters">
77 <td>
78 <input type="checkbox" name="show_query" value="1" id="checkbox_show_query" checked="checked" /><label for="checkbox_show_query"><?php echo $strShowThisQuery; ?></label>
79 </td>
80 <td align="right"><input type="submit" name="SQL" value="<?php echo $strGo; ?>" /></td>
81 </tr>
82 <?php
83 // loic1: displays import dump feature only if file upload available
84 if ($is_upload) {
85 ?>
86 <tr><td colspan="2"><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width="1" height="1" border="0" alt="" /></td></tr>
87 <tr>
88 <td colspan="2" class="tblHeaders">
89 <i><?php echo $strOr; ?></i>
90 <b><?php echo $strLocationTextfile; ?>:</b>
91 </td>
92 </tr>
93 <tr bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
94 <td colspan="2" align="center">
95 <input type="file" name="sql_file" class="textfield" />&nbsp;
96 <?php
97 echo PMA_displayMaximumUploadSize($max_upload_size) . '<br />';
98 // some browsers should respect this :)
99 echo ' ' . PMA_generateHiddenMaxFileSize($max_upload_size) . "\n";
100 $is_gzip = ($cfg['GZipDump'] && @function_exists('gzopen'));
101 $is_bzip = ($cfg['BZipDump'] && @function_exists('bzdecompress'));
102 if ($is_bzip || $is_gzip) {
103 echo ' </td>' . "\n"
104 . '</tr>' . "\n"
105 . '<tr bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
106 . ' <td colspan="2">' . "\n";
107 echo ' &nbsp;&nbsp;' . $strCompression . ':<br />&nbsp;&nbsp;&nbsp;' . "\n"
108 . ' <input type="radio" id="radio_sql_file_compression_auto" name="sql_file_compression" value="" checked="checked" /><label for="radio_sql_file_compression_auto">' . $strAutodetect . '</label>&nbsp;&nbsp;' . "\n"
109 . ' <input type="radio" id="radio_sql_file_compression_plain" name="sql_file_compression" value="text/plain" /><label for="radio_sql_file_compression_plain">' . $strNone . '</label>&nbsp;&nbsp' . "\n";
110 if ($is_gzip) {
111 echo ' <input type="radio" id="radio_sql_file_compression_gzip" name="sql_file_compression" value="application/x-gzip" /><label for="radio_sql_file_compression_gzip">' . $strGzip . '</label>&nbsp;&nbsp;' . "\n";
112 }
113 if ($is_bzip) {
114 echo ' <input type="radio" id="radio_sql_file_compression_bzip" name="sql_file_compression" value="application/x-bzip" /><label for="radio_sql_file_compression_bzip">' . $strBzip . '</label>&nbsp;&nbsp;' . "\n";
115 }
116 } else {
117 ?>
118 <input type="hidden" name="sql_file_compression" value="text/plain" />
119 </td>
120 </tr>
121 <?php
122 }
123 } // end if (is upload)
124 // web-server upload directory
125 $is_upload_dir = false;
126 if (!empty($cfg['UploadDir'])) {
127 if (substr($cfg['UploadDir'], -1) != '/') {
128 $cfg['UploadDir'] .= '/';
129 }
130 if ($handle = @opendir($cfg['UploadDir'])) {
131 $is_first = 0;
132 while ($file = @readdir($handle)) {
133 if (is_file($cfg['UploadDir'] . $file) && PMA_checkFileExtensions($file, '.sql')) {
134 if ($is_first == 0) {
135 $is_upload_dir = true;
136 echo "\n";
137 echo ' <tr><td colspan=2" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n";
138 echo ' &nbsp;<b>' . $strWebServerUploadDirectory . ':</b>&nbsp;' . "\n";
139 echo ' </td></tr>' . "\n";
140 echo ' <tr bgcolor="' . $cfg['BgcolorOne'] . '"><td colspan="2">' . "\n";
141 // add 2004-05-08 by mkkeck
142 // todo: building a php script for indexing files in UploadDir
143 //if ($cfg['UploadDirIndex']) {
144 // echo '&nbsp;<a href="' . $cfg['UploadDir'] . '" target="_blank">' . $cfg['UploadDir'] . '</a>&nbsp;';
145 //}
146 // end indexing
147 echo ' <select size="1" name="sql_localfile">' . "\n";
148 echo ' <option value="" selected="selected"></option>' . "\n";
149 } // end if (is_first)
150 echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
151 $is_first++;
152 } // end if (is_file)
153 } // end while
154 if ($is_first > 0) {
155 echo ' </select>' . "\n"
156 . ' </td>'
157 . ' </tr>' . "\n\n";
158 } // end if (isfirst > 0)
159 @closedir($handle);
160 }
161 else {
162 $upload_dir_error = '<tr><td colspan="2"><img src="' .$GLOBALS['pmaThemeImage'] . 'spacer.png' . '" width="1" height="1" border="0" alt="" /></td></tr>' . "\n"
163 . '<tr><th colspan="2" class="tblHeadError"><div class="errorhead">' . $strError . '</div></th></tr>' . "\n"
164 . '<tr><td colspan="2" class="tblError">' . $strWebServerUploadDirectoryError
165 . '</td></tr>' . "\n";
166 }
167 } // end if (web-server upload directory)
168 // Charset conversion options
169 if ($is_upload || $is_upload_dir) {
170 echo ' <tr class="tblFooters"><td>' . "\n";
171 if (PMA_MYSQL_INT_VERSION < 40100 && $cfg['AllowAnywhereRecoding'] && $allow_recoding) {
172 $temp_charset = reset($cfg['AvailableCharsets']);
173 echo '&nbsp;' . $strCharsetOfFile . "\n"
174 . ' <select name="charset_of_file" size="1">' . "\n"
175 . ' <option value="' . $temp_charset . '"';
176 if ($temp_charset == $charset) {
177 echo ' selected="selected"';
178 }
179 echo '>' . $temp_charset . '</option>' . "\n";
180 while ($temp_charset = next($cfg['AvailableCharsets'])) {
181 echo ' <option value="' . $temp_charset . '"';
182 if ($temp_charset == $charset) {
183 echo ' selected="selected"';
184 }
185 echo '>' . $temp_charset . '</option>' . "\n";
186 }
187 echo ' </select><br />' . "\n" . ' ';
188 } elseif (PMA_MYSQL_INT_VERSION >= 40100) {
189 echo $strCharsetOfFile . "\n";
190 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', NULL, 'utf8', FALSE);
191 } // end if (recoding)
192 echo ' </td>' . "\n";
193 echo ' <td align="right"><input type="submit" name="SQL" value="' . $strGo . '" /></td>' . "\n";
194 echo ' </tr>' . "\n";
195 }
196
197
198 // Encoding setting form appended by Y.Kawada
199 if (function_exists('PMA_set_enc_form')) {
200 echo PMA_set_enc_form(' ');
201 }
202 // modified by mkkeck 2004-05-08
203 // showing UploadDir Error at the end of all option for SQL-Queries
204 if (isset($upload_dir_error)) {
205 echo $upload_dir_error;
206 }
207 ?>
208 </table>
209 </form>
210 <?php
211 /**
212 * Displays the footer
213 */
214 echo "\n";
215 require_once('./footer.inc.php');
216 ?>
Something went wrong with that request. Please try again.