2 /* vim: set expandtab sw=4 ts=4 sts=4: */
7 if (! defined('PHPMYADMIN')) {
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
>
31 <img src
="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" alt
="ajax clock" style
="display: none;" />
32 <script type
="text/javascript">
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"); // - || -
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
51 var periodical_upload
;
53 var request_upload
= [];
55 perform_upload
= function () {
57 'import_status.php?id=<?php echo $upload_id ; ?>&<?php echo PMA_generate_common_url(); ?>',
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
.')); ?>');
67 $
('#upload_form_status').css("display", "none");
69 $
('#upload_form_status_info').html(' '+Math
.round(percent
)+
'%, '+complete+
'/'+total
);
70 $
('#status').animate({width
: Math
.round(percent
)*2+
'px'},150);
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
.')); ?> ');
77 $
('#import_form_status').load('import_status.php?message=true&<?php echo PMA_generate_common_url(); ?>'); // loads the message, either success or mysql error
79 // reload the left sidebar when the import is finished
80 $GLOBALS['reload']=true;
81 PMA_reloadNavigation(true);
86 window
.setTimeout(perform_upload
, 1000);
93 window
.setTimeout(perform_upload
, 1000);
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
.')) . PMA_showDocu('faq2_9
'); ?>');
99 $
('#upload_form_status').css("display", "none");
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"'; ?>>');
110 <form action
="import.php" method
="post" enctype
="multipart/form-data" name
="import">
112 <input type
="hidden" name
="<?php echo $ID_KEY; ?>" value
="<?php echo $upload_id ; ?>" />
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);
119 echo PMA_generate_common_hidden_inputs($db, $table, 1);
121 echo ' <input type="hidden" name="import_type" value="' . $import_type . '" />'."\n";
122 echo PMA_pluginGetJavascript($import_list);
124 <fieldset
class="options">
125 <legend
><?php
echo __('File to import'); ?
></legend
>
129 if ($GLOBALS['is_upload']) {
132 <div
class="formelementrow" id
="upload_form">
133 <div id
="upload_form_status" style
="display: none;"></div
>
134 <div id
="upload_form_status_info" style
="display: none;"></div
>
135 <div id
="upload_form_form">
136 <label
for="input_import_file"><?php
echo __('Location of the text file'); ?
></label
>
137 <input style
="margin: 5px" type
="file" name
="import_file" id
="input_import_file" onchange
="match_file(this.value);" />
139 echo PMA_displayMaximumUploadSize($max_upload_size) . "\n";
140 // some browsers should respect this :)
141 echo PMA_generateHiddenMaxFileSize($max_upload_size) . "\n";
147 PMA_Message
::warning(__('File uploads are not allowed on this server.'))->display();
149 if (!empty($cfg['UploadDir'])) {
151 foreach ($import_list as $key => $val) {
152 if (!empty($extensions)) {
155 $extensions .= $val['extension'];
157 $matcher = '@\.(' . $extensions . ')(\.(' . PMA_supportedDecompressions() . '))?$@';
159 $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ?
$local_import_file : '');
160 echo '<div class="formelementrow">' . "\n";
161 if ($files === FALSE) {
162 PMA_Message
::error(__('The directory you set for upload work cannot be reached'))->display();
163 } elseif (!empty($files)) {
165 echo ' <i>' . __('Or') . '</i><br/><label for="select_local_import_file">' . __('web server upload directory') . '</label> : ' . "\n";
166 echo ' <select style="margin: 5px" size="1" name="local_import_file" onchange="match_file(this.value)" id="select_local_import_file">' . "\n";
167 echo ' <option value=""> </option>' . "\n";
169 echo ' </select>' . "\n";
171 echo '</div>' . "\n";
172 } // end if (web-server upload directory)
175 echo '<div class="formelementrow">' . "\n";
176 if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE
) {
177 echo '<label for="charset_of_file">' . __('Character set of the file:') . '</label>';
178 reset($cfg['AvailableCharsets']);
179 echo '<select id="charset_of_file" name="charset_of_file" size="1">';
180 foreach ($cfg['AvailableCharsets'] as $temp_charset) {
181 echo '<option value="' . htmlentities($temp_charset) . '"';
182 if ((empty($cfg['Import']['charset']) && $temp_charset == $charset)
183 ||
$temp_charset == $cfg['Import']['charset']) {
184 echo ' selected="selected"';
186 echo '>' . htmlentities($temp_charset) . '</option>';
188 echo ' </select><br />';
190 echo '<label for="charset_of_file">' . __('Character set of the file:') . '</label>' . "\n";
191 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET
, 'charset_of_file', 'charset_of_file', 'utf8', FALSE);
192 } // end if (recoding)
193 echo '</div>' . "\n";
195 // zip, gzip and bzip2 encode features
196 $compressions = __('None');
198 if ($cfg['GZipDump'] && @function_exists
('gzopen')) {
199 $compressions .= ', gzip';
201 if ($cfg['BZipDump'] && @function_exists
('bzopen')) {
202 $compressions .= ', bzip2';
204 if ($cfg['ZipDump'] && @function_exists
('zip_open')) {
205 $compressions .= ', zip';
208 // We don't have show anything about compression, when no supported
209 if ($compressions != __('None')) {
210 echo '<div class="formelementrow">' . "\n";
211 printf(__('Imported file compression will be automatically detected from: %s'), $compressions);
212 echo '</div>' . "\n";
217 <fieldset
class="options">
218 <legend
><?php
echo __('Partial import'); ?
></legend
>
221 if (isset($timeout_passed) && $timeout_passed) {
222 echo '<div class="formelementrow">' . "\n";
223 echo '<input type="hidden" name="skip" value="' . $offset . '" />';
224 echo sprintf(__('Previous import timed out, after resubmitting will continue from position %d.'), $offset) . '';
225 echo '</div>' . "\n";
228 <div
class="formelementrow">
229 <input type
="checkbox" name
="allow_interrupt" value
="yes"
230 id
="checkbox_allow_interrupt" <?php
echo PMA_pluginCheckboxCheck('Import', 'allow_interrupt'); ?
>/>
231 <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
/>
235 if (! (isset($timeout_passed) && $timeout_passed)) {
237 <div
class="formelementrow">
238 <label
for="text_skip_queries"><?php
echo __('Number of queries to skip from start'); ?
></label
>
239 <input type
="text" name
="skip_queries" value
="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id
="text_skip_queries" />
243 // If timeout has passed,
244 // do not show the Skip dialog to avoid the risk of someone
245 // entering a value here that would interfere with "skip"
247 <input type
="hidden" name
="skip_queries" value
="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id
="text_skip_queries" />
253 <fieldset
class="options">
254 <legend
><?php
echo __('Format of imported file'); ?
></legend
>
256 // Let's show format options now
257 echo '<div style="float: left;">';
258 echo PMA_pluginGetChoice('Import', 'format', $import_list);
261 echo '<div style="float: left;">';
262 echo PMA_pluginGetOptions('Import', $import_list);
265 <div
class="clearfloat"></div
>
268 // Encoding setting form appended by Y.Kawada
269 if (function_exists('PMA_set_enc_form')) {
270 echo PMA_set_enc_form(' ');
274 <fieldset
class="tblFooters">
275 <input type
="submit" value
="<?php echo __('Go'); ?>" id
="buttonGo" />