Bug: Live query chart always zero
[phpmyadmin/tyronm.git] / libraries / display_import.lib.php
blobd709631790c9a26ed7f1da528d3de01193272799
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
7 if (! defined('PHPMYADMIN')) {
8 exit;
11 /**
14 require_once './libraries/file_listing.php';
15 require_once './libraries/plugin_interface.lib.php';
16 require_once './libraries/display_import_ajax.lib.php';
18 /* Scan for plugins */
19 $import_list = PMA_getPlugins('./libraries/import/', $import_type);
21 /* Fail if we didn't find any plugin */
22 if (empty($import_list)) {
23 PMA_Message::error(__('Could not load import plugins, please check your installation!'))->display();
24 require './libraries/footer.inc.php';
28 <iframe id="import_upload_iframe" name="import_upload_iframe" width="1" height="1" style="display: none;"></iframe>
29 <div id="import_form_status" style="display: none;"></div>
30 <div id="importmain">
31 <img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" style="display: none;" />
32 <script type="text/javascript">
33 //<![CDATA[
34 $(document).ready( function() {
35 // add event when user click on "Go" button
36 $('#buttonGo').bind('click', function() {
37 $('#upload_form_form').css("display", "none"); // hide form
38 $('#upload_form_status').css("display", "inline"); // show progress bar
39 $('#upload_form_status_info').css("display", "inline"); // - || -
40 <?php
41 if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") {
43 $('#upload_form_status').html('<div class="upload_progress_bar_outer"><div id="status" class="upload_progress_bar_inner"></div></div>'); // add the progress bar
45 var finished = false;
46 var percent = 0.0;
47 var total = 0;
48 var complete = 0;
50 var perform_upload;
51 var periodical_upload;
53 var request_upload = [];
55 perform_upload = function () {
56 new $.getJSON(
57 'import_status.php?id=<?php echo $upload_id ; ?>&<?php echo PMA_generate_common_url(); ?>',
58 {},
59 function(response) {
60 finished = response.finished;
61 percent = response.percent;
62 total = response.total;
63 complete = response.complete;
65 if (total==0 && complete==0 && percent==0) {
66 $('#upload_form_status_info').html('<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo PMA_jsFormat(__('The file being uploaded is probably larger than the maximum allowed size or this is a known bug in webkit based (Safari, Google Chrome, Arora etc.) browsers.'), false); ?>');
67 $('#upload_form_status').css("display", "none");
68 } else {
69 $('#upload_form_status_info').html(' '+Math.round(percent)+'%, '+complete+'/'+total);
70 $('#status').animate({width: Math.round(percent)*2+'px'},150);
71 } // else
73 if (finished==true) {
74 $('#importmain').css('display', 'none');
75 $('#import_form_status').css('display', 'inline');
76 $('#import_form_status').html('<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo PMA_jsFormat(__('The file is being processed, please be patient.'), false); ?> ');
77 $('#import_form_status').load('import_status.php?message=true&<?php echo PMA_generate_common_url(); ?>'); // loads the message, either success or mysql error
78 <?php
79 // reload the left sidebar when the import is finished
80 $GLOBALS['reload']=true;
81 PMA_reloadNavigation(true);
84 } // if finished
85 else {
86 window.setTimeout(perform_upload, 1000);
93 window.setTimeout(perform_upload, 1000);
95 <?php
96 } else { // no plugin available
98 $('#upload_form_status_info').html('<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo PMA_jsFormat(__('Please be patient, the file is being uploaded. Details about the upload are not available.'), false) . PMA_showDocu('faq2_9'); ?>');
99 $('#upload_form_status').css("display", "none");
100 <?php
101 } // else
103 }); // onclick
104 }); // domready
106 document.write('<form action="import.php" method="post" enctype="multipart/form-data" name="import"<?php if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") echo ' target="import_upload_iframe"'; ?>>');
107 //]]>
108 </script>
109 <noscript>
110 <form action="import.php" method="post" enctype="multipart/form-data" name="import">
111 </noscript>
112 <input type="hidden" name="<?php echo $ID_KEY; ?>" value="<?php echo $upload_id ; ?>" />
113 <?php
114 if ($import_type == 'server') {
115 echo PMA_generate_common_hidden_inputs('', '', 1);
116 } elseif ($import_type == 'database') {
117 echo PMA_generate_common_hidden_inputs($db, '', 1);
118 } else {
119 echo PMA_generate_common_hidden_inputs($db, $table, 1);
121 echo ' <input type="hidden" name="import_type" value="' . $import_type . '" />'."\n";
124 <div class="exportoptions" id="header">
125 <h2>
126 <img class="icon ic_b_import" src="themes/dot.gif" alt="import" />
127 <?php
128 if ($import_type == 'server') {
129 echo __('Importing into the current server');
130 } elseif ($import_type == 'database') {
131 printf(__('Importing into the database "%s"'), htmlspecialchars($db));
132 } else {
133 printf(__('Importing into the table "%s"'), htmlspecialchars($table));
135 </h2>
136 </div>
138 <div class="importoptions">
139 <h3><?php echo __('File to Import:'); ?></h3>
140 <?php
141 // zip, gzip and bzip2 encode features
142 $compressions = array();
144 if ($cfg['GZipDump'] && @function_exists('gzopen')) {
145 $compressions[] = 'gzip';
147 if ($cfg['BZipDump'] && @function_exists('bzopen')) {
148 $compressions[] = 'bzip2';
150 if ($cfg['ZipDump'] && @function_exists('zip_open')) {
151 $compressions[] = 'zip';
153 // We don't have show anything about compression, when no supported
154 if ($compressions != array()) {
155 echo '<div class="formelementrow" id="compression_info">';
156 printf(__('File may be compressed (%s) or uncompressed.'), implode(", ", $compressions));
157 echo '<br />';
158 echo __('A compressed file\'s name must end in <b>.[format].[compression]</b>. Example: <b>.sql.zip</b>');
159 echo '</div>';
162 <div class="formelementrow" id="upload_form">
163 <?php if ($GLOBALS['is_upload'] && !empty($cfg['UploadDir'])) { ?>
164 <ul>
165 <li>
166 <input type="radio" name="file_location" id="radio_import_file" />
167 <?php PMA_browseUploadFile($max_upload_size); ?>
168 </li>
169 <li>
170 <input type="radio" name="file_location" id="radio_local_import_file" />
171 <?php PMA_selectUploadFile($import_list, $cfg['UploadDir']); ?>
172 </li>
173 </ul>
174 <?php } else if ($GLOBALS['is_upload']) {
175 $uid = uniqid("");
176 PMA_browseUploadFile($max_upload_size);
177 } else if (!$GLOBALS['is_upload']) {
178 PMA_Message::notice(__('File uploads are not allowed on this server.'))->display();
179 } else if (!empty($cfg['UploadDir'])) {
180 PMA_selectUploadFile($import_list, $cfg['UploadDir']);
181 } // end if (web-server upload directory)
183 </div>
185 <div class="formelementrow" id="charaset_of_file">
186 <?php // charset of file
187 if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE) {
188 echo '<label for="charset_of_file">' . __('Character set of the file:') . '</label>';
189 reset($cfg['AvailableCharsets']);
190 echo '<select id="charset_of_file" name="charset_of_file" size="1">';
191 foreach ($cfg['AvailableCharsets'] as $temp_charset) {
192 echo '<option value="' . htmlentities($temp_charset) . '"';
193 if ((empty($cfg['Import']['charset']) && $temp_charset == 'utf-8')
194 || $temp_charset == $cfg['Import']['charset']) {
195 echo ' selected="selected"';
197 echo '>' . htmlentities($temp_charset) . '</option>';
199 echo ' </select><br />';
200 } else {
201 echo '<label for="charset_of_file">' . __('Character set of the file:') . '</label>' . "\n";
202 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', 'charset_of_file', 'utf8', false);
203 } // end if (recoding)
205 </div>
206 </div>
207 <div class="importoptions">
208 <h3><?php echo __('Partial Import:'); ?></h3>
210 <?php
211 if (isset($timeout_passed) && $timeout_passed) {
212 echo '<div class="formelementrow">' . "\n";
213 echo '<input type="hidden" name="skip" value="' . $offset . '" />';
214 echo sprintf(__('Previous import timed out, after resubmitting will continue from position %d.'), $offset) . '';
215 echo '</div>' . "\n";
218 <div class="formelementrow">
219 <input type="checkbox" name="allow_interrupt" value="yes"
220 id="checkbox_allow_interrupt" <?php echo PMA_pluginCheckboxCheck('Import', 'allow_interrupt'); ?>/>
221 <label for="checkbox_allow_interrupt"><?php echo __('Allow the interruption of an import in case the script detects it is close to the PHP timeout limit. <i>(This might be good way to import large files, however it can break transactions.)</i>'); ?></label><br />
222 </div>
224 <?php
225 if (! (isset($timeout_passed) && $timeout_passed)) {
227 <div class="formelementrow">
228 <label for="text_skip_queries"><?php echo __('Number of rows to skip, starting from the first row:'); ?></label>
229 <input type="text" name="skip_queries" value="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id="text_skip_queries" />
230 </div>
231 <?php
232 } else {
233 // If timeout has passed,
234 // do not show the Skip dialog to avoid the risk of someone
235 // entering a value here that would interfere with "skip"
237 <input type="hidden" name="skip_queries" value="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id="text_skip_queries" />
238 <?php
241 </div>
243 <div class="importoptions">
244 <h3><?php echo __('Format:'); ?></h3>
245 <?php echo PMA_pluginGetChoice('Import', 'format', $import_list); ?>
246 <div id="import_notification"></div>
247 </div>
249 <div class="importoptions" id="format_specific_opts">
250 <h3><?php echo __('Format-Specific Options:'); ?></h3>
251 <p class="no_js_msg" id="scroll_to_options_msg">Scroll down to fill in the options for the selected format and ignore the options for other formats.</p>
252 <?php echo PMA_pluginGetOptions('Import', $import_list); ?>
253 </div>
254 <div class="clearfloat"></div>
255 </div>
256 <?php
257 // Encoding setting form appended by Y.Kawada
258 if (function_exists('PMA_set_enc_form')) { ?>
259 <div class="importoptions" id="kanji_encoding">
260 <h3><?php echo __('Encoding Conversion:'); ?></h3>
261 <?php echo PMA_set_enc_form(' '); ?>
262 </div>
263 <?php }
264 echo "\n";
266 <div class="importoptions" id="submit">
267 <input type="submit" value="<?php echo __('Go'); ?>" id="buttonGo" />
268 </div>
269 </form>