2 /* vim: set expandtab sw=4 ts=4 sts=4: */
8 if (! defined('PHPMYADMIN')) {
15 require_once './libraries/file_listing.php';
16 require_once './libraries/plugin_interface.lib.php';
17 require_once './libraries/display_import_ajax.lib.php';
19 /* Scan for plugins */
20 $import_list = PMA_getPlugins('./libraries/import/', $import_type);
22 /* Fail if we didn't find any plugin */
23 if (empty($import_list)) {
24 PMA_Message
::error('strCanNotLoadImportPlugins')->display();
25 require './libraries/footer.inc.php';
29 <iframe id
="import_upload_iframe" name
="import_upload_iframe" width
="1" height
="1" style
="display: none"></iframe
>
30 <div id
="import_form_status" style
="display: none;"></div
>
32 <img src
="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt
="ajax clock" style
="display: none;" />
33 <script type
="text/javascript">
35 $
(document
).ready( function() {
36 // add event when user click on "Go" button
37 $
('#buttonGo').bind('click', function() {
38 $
('#upload_form_form').css("display", "none"); // hide form
39 $
('#upload_form_status').css("display", "inline"); // show progress bar
40 $
('#upload_form_status_info').css("display", "inline"); // - || -
42 if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") {
44 $
('#upload_form_status').html('<div class="upload_progress_bar_outer"><div id="status" class="upload_progress_bar_inner"></div></div>'); // add the progress bar
52 var periodical_upload
;
54 var request_upload
= [];
56 perform_upload
= function () {
58 'import_status.php?id=<?php echo $upload_id ; ?>&<?php echo PMA_generate_common_url(); ?>',
61 finished
= response
.finished
;
62 percent
= response
.percent
;
63 total
= response
.total
;
64 complete
= response
.complete
;
66 if (total
==0 && complete
==0 && percent
==0) {
67 $
('#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
.')); ?>');
68 $
('#upload_form_status').css("display", "none");
70 $
('#upload_form_status_info').html(' '+Math
.round(percent
)+
'%, '+complete+
'/'+total
);
71 $
('#status').animate({width
: Math
.round(percent
)*2+
'px'},150);
75 $
('#importmain').css('display', 'none');
76 $
('#import_form_status').css('display', 'inline');
77 $
('#import_form_status').html('<img src="<?php echo $GLOBALS['pmaThemeImage
'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo __('The file is being processed
, please be patient
.'); ?> ');
78 $
('#import_form_status').load('import_status.php?message=true&<?php echo PMA_generate_common_url(); ?>'); // loads the message, either success or mysql error
80 // reload the left sidebar when the import is finished
81 $GLOBALS['reload']=true;
82 PMA_reloadNavigation(true);
87 window
.setTimeout(perform_upload
, 1000);
94 window
.setTimeout(perform_upload
, 1000);
97 } else { // no plugin avaliable
99 $
('#upload_form_status_info').html('<img src="<?php echo $GLOBALS['pmaThemeImage
'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo __('Please be patient
, the file is being uploaded
. Details about the upload are not available
.') . PMA_showDocu('faq2_9
'); ?>');
100 $
('#upload_form_status').css("display", "none");
107 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"'; ?>>');
111 <form action
="import.php" method
="post" enctype
="multipart/form-data" name
="import">
113 <input type
="hidden" name
="<?php echo $ID_KEY; ?>" value
="<?php echo $upload_id ; ?>" />
115 if ($import_type == 'server') {
116 echo PMA_generate_common_hidden_inputs('', '', 1);
117 } elseif ($import_type == 'database') {
118 echo PMA_generate_common_hidden_inputs($db, '', 1);
120 echo PMA_generate_common_hidden_inputs($db, $table, 1);
122 echo ' <input type="hidden" name="import_type" value="' . $import_type . '" />'."\n";
123 echo PMA_pluginGetJavascript($import_list);
125 <fieldset
class="options">
126 <legend
><?php
echo __('File to import'); ?
></legend
>
130 if ($GLOBALS['is_upload']) {
133 <div
class="formelementrow" id
="upload_form">
134 <div id
="upload_form_status" style
="display: none;"></div
>
135 <div id
="upload_form_status_info" style
="display: none;"></div
>
136 <div id
="upload_form_form">
137 <label
for="input_import_file"><?php
echo __('Location of the text file'); ?
></label
>
138 <input style
="margin: 5px" type
="file" name
="import_file" id
="input_import_file" onchange
="match_file(this.value);" />
140 echo PMA_displayMaximumUploadSize($max_upload_size) . "\n";
141 // some browsers should respect this :)
142 echo PMA_generateHiddenMaxFileSize($max_upload_size) . "\n";
148 PMA_Message
::warning('strUploadsNotAllowed')->display();
150 if (!empty($cfg['UploadDir'])) {
152 foreach ($import_list as $key => $val) {
153 if (!empty($extensions)) {
156 $extensions .= $val['extension'];
158 $matcher = '@\.(' . $extensions . ')(\.(' . PMA_supportedDecompressions() . '))?$@';
160 $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ?
$local_import_file : '');
161 echo '<div class="formelementrow">' . "\n";
162 if ($files === FALSE) {
163 PMA_Message
::error('strWebServerUploadDirectoryError')->display();
164 } elseif (!empty($files)) {
166 echo ' <i>' . __('Or') . '</i><br/><label for="select_local_import_file">' . __('web server upload directory') . '</label> : ' . "\n";
167 echo ' <select style="margin: 5px" size="1" name="local_import_file" onchange="match_file(this.value)" id="select_local_import_file">' . "\n";
168 echo ' <option value=""> </option>' . "\n";
170 echo ' </select>' . "\n";
172 echo '</div>' . "\n";
173 } // end if (web-server upload directory)
176 echo '<div class="formelementrow">' . "\n";
177 if ($cfg['AllowAnywhereRecoding']) {
178 echo '<label for="charset_of_file">' . __('Character set of the file:') . '</label>';
179 reset($cfg['AvailableCharsets']);
180 echo '<select id="charset_of_file" name="charset_of_file" size="1">';
181 foreach ($cfg['AvailableCharsets'] as $temp_charset) {
182 echo '<option value="' . htmlentities($temp_charset) . '"';
183 if ((empty($cfg['Import']['charset']) && $temp_charset == $charset)
184 ||
$temp_charset == $cfg['Import']['charset']) {
185 echo ' selected="selected"';
187 echo '>' . htmlentities($temp_charset) . '</option>';
189 echo ' </select><br />';
191 echo '<label for="charset_of_file">' . __('Character set of the file:') . '</label>' . "\n";
192 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET
, 'charset_of_file', 'charset_of_file', 'utf8', FALSE);
193 } // end if (recoding)
194 echo '</div>' . "\n";
196 // zip, gzip and bzip2 encode features
197 $compressions = __('None');
199 if ($cfg['GZipDump'] && @function_exists
('gzopen')) {
200 $compressions .= ', gzip';
202 if ($cfg['BZipDump'] && @function_exists
('bzopen')) {
203 $compressions .= ', bzip2';
205 if ($cfg['ZipDump'] && @function_exists
('zip_open')) {
206 $compressions .= ', zip';
209 // We don't have show anything about compression, when no supported
210 if ($compressions != __('None')) {
211 echo '<div class="formelementrow">' . "\n";
212 printf(__('Imported file compression will be automatically detected from: %s'), $compressions);
213 echo '</div>' . "\n";
218 <fieldset
class="options">
219 <legend
><?php
echo __('Partial import'); ?
></legend
>
222 if (isset($timeout_passed) && $timeout_passed) {
223 echo '<div class="formelementrow">' . "\n";
224 echo '<input type="hidden" name="skip" value="' . $offset . '" />';
225 echo sprintf(__('Previous import timed out, after resubmitting will continue from position %d.'), $offset) . '';
226 echo '</div>' . "\n";
229 <div
class="formelementrow">
230 <input type
="checkbox" name
="allow_interrupt" value
="yes"
231 id
="checkbox_allow_interrupt" <?php
echo PMA_pluginCheckboxCheck('Import', 'allow_interrupt'); ?
>/>
232 <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. This might be good way to import large files, however it can break transactions.'); ?
></label
><br
/>
236 if (! (isset($timeout_passed) && $timeout_passed)) {
238 <div
class="formelementrow">
239 <label
for="text_skip_queries"><?php
echo __('Number of records (queries) to skip from start'); ?
></label
>
240 <input type
="text" name
="skip_queries" value
="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id
="text_skip_queries" />
244 // If timeout has passed,
245 // do not show the Skip dialog to avoid the risk of someone
246 // entering a value here that would interfere with "skip"
248 <input type
="hidden" name
="skip_queries" value
="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id
="text_skip_queries" />
254 <fieldset
class="options">
255 <legend
><?php
echo __('Format of imported file'); ?
></legend
>
257 // Let's show format options now
258 echo '<div style="float: left;">';
259 echo PMA_pluginGetChoice('Import', 'format', $import_list);
262 echo '<div style="float: left;">';
263 echo PMA_pluginGetOptions('Import', $import_list);
266 <div
class="clearfloat"></div
>
269 // Encoding setting form appended by Y.Kawada
270 if (function_exists('PMA_set_enc_form')) {
271 echo PMA_set_enc_form(' ');
275 <fieldset
class="tblFooters">
276 <input type
="submit" value
="<?php echo __('Go'); ?>" id
="buttonGo" />