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 window
.addEvent('domready', function() {
36 // add event when user click on "Go" button
37 $
('buttonGo').addEvent('click', function() {
38 $
('upload_form_form').setStyle("display", "none"); // hide form
39 $
('upload_form_status').setStyle("display", "inline"); // show progress bar
40 $
('upload_form_status_info').setStyle("display", "inline"); // - || -
42 if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") {
44 $
('upload_form_status').set('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
= new Request({
55 url
: 'import_status.php?id=<?php echo $upload_id ; ?>&<?php echo PMA_generate_common_url(); ?>', // the "&" is causing problems for webkit browsers
57 update
: 'upload_form_status',
58 onComplete
: function(response
) {
59 objectsReturned
= JSON
.decode(response
);
61 $each(objectsReturned
, function(item
, index
) {
63 if (index
=="finished") {
66 $clear(periodical_upload
);
67 $
('importmain').setStyle('display', 'none');
68 $
('import_form_status').setStyle('display', 'inline');
69 $
('import_form_status').set('html', '<img src="<?php echo $GLOBALS['pmaThemeImage
'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo PMA_jsFormat($strImportProceedingFile); ?> ');
70 $
('import_form_status').load('import_status.php?message=true&<?php echo PMA_generate_common_url(); ?>'); // loads the message, either success or mysql error
72 // reload the left sidebar when the import is finished
73 $GLOBALS['reload']=true;
74 PMA_reloadNavigation(true);
76 } // if finished==item
77 } // if index==finished
82 if (index
=="complete")
85 if (total
==0 && complete
==0 && percent
==0) {
86 $
('upload_form_status_info').set('html', '<img src="<?php echo $GLOBALS['pmaThemeImage
'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo PMA_jsFormat($strImportLargeFileUploading); ?>');
87 $
('upload_form_status').setStyle("display", "none");
89 $
('upload_form_status_info').set('html', ' '+Math
.round(percent
)+
'%, '+complete+
'/'+total
);
90 $
('status').tween('width', Math
.round(percent
)*2+
'px');
94 perform_upload
= function () {
95 request_upload
.send('r=' +
$time() +
$random(0, 100)); // hack for IE7,8 & webkit (Safari, Chrome, Arora...)
97 periodical_upload
= perform_upload
.periodical(1000);
101 $
('upload_form_status_info').set('html', '<img src="<?php echo $GLOBALS['pmaThemeImage
'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo $strImportUploadInfoNotAvailable . PMA_showDocu('faq2_9
'); ?>');
102 $
('upload_form_status').setStyle("display", "none");
109 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"'; ?>>');
113 <form action
="import.php" method
="post" enctype
="multipart/form-data" name
="import">
115 <input type
="hidden" name
="<?php echo $ID_KEY; ?>" value
="<?php echo $upload_id ; ?>" />
117 if ($import_type == 'server') {
118 echo PMA_generate_common_hidden_inputs('', '', 1);
119 } elseif ($import_type == 'database') {
120 echo PMA_generate_common_hidden_inputs($db, '', 1);
122 echo PMA_generate_common_hidden_inputs($db, $table, 1);
124 echo ' <input type="hidden" name="import_type" value="' . $import_type . '" />'."\n";
125 echo PMA_pluginGetJavascript($import_list);
127 <fieldset
class="options">
128 <legend
><?php
echo $strFileToImport; ?
></legend
>
132 if ($GLOBALS['is_upload']) {
135 <div
class="formelementrow" id
="upload_form">
136 <div id
="upload_form_status" style
="display: none;"></div
>
137 <div id
="upload_form_status_info" style
="display: none;"></div
>
138 <div id
="upload_form_form">
139 <label
for="input_import_file"><?php
echo $strLocationTextfile; ?
></label
>
140 <input style
="margin: 5px" type
="file" name
="import_file" id
="input_import_file" onchange
="match_file(this.value);" />
142 echo PMA_displayMaximumUploadSize($max_upload_size) . "\n";
143 // some browsers should respect this :)
144 echo PMA_generateHiddenMaxFileSize($max_upload_size) . "\n";
150 PMA_Message
::warning('strUploadsNotAllowed')->display();
152 if (!empty($cfg['UploadDir'])) {
154 foreach ($import_list as $key => $val) {
155 if (!empty($extensions)) {
158 $extensions .= $val['extension'];
160 $matcher = '@\.(' . $extensions . ')(\.(' . PMA_supportedDecompressions() . '))?$@';
162 $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ?
$local_import_file : '');
163 echo '<div class="formelementrow">' . "\n";
164 if ($files === FALSE) {
165 PMA_Message
::error('strWebServerUploadDirectoryError')->display();
166 } elseif (!empty($files)) {
168 echo ' <i>' . $strOr . '</i><br/><label for="select_local_import_file">' . $strWebServerUploadDirectory . '</label> : ' . "\n";
169 echo ' <select style="margin: 5px" size="1" name="local_import_file" onchange="match_file(this.value)" id="select_local_import_file">' . "\n";
170 echo ' <option value=""> </option>' . "\n";
172 echo ' </select>' . "\n";
174 echo '</div>' . "\n";
175 } // end if (web-server upload directory)
178 echo '<div class="formelementrow">' . "\n";
179 if ($cfg['AllowAnywhereRecoding']) {
180 echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>';
181 reset($cfg['AvailableCharsets']);
182 echo '<select id="charset_of_file" name="charset_of_file" size="1">';
183 foreach ($cfg['AvailableCharsets'] as $temp_charset) {
184 echo '<option value="' . htmlentities($temp_charset) . '"';
185 if ((empty($cfg['Import']['charset']) && $temp_charset == $charset)
186 ||
$temp_charset == $cfg['Import']['charset']) {
187 echo ' selected="selected"';
189 echo '>' . htmlentities($temp_charset) . '</option>';
191 echo ' </select><br />';
193 echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>' . "\n";
194 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET
, 'charset_of_file', 'charset_of_file', 'utf8', FALSE);
195 } // end if (recoding)
196 echo '</div>' . "\n";
198 // zip, gzip and bzip2 encode features
199 $compressions = $strNone;
201 if ($cfg['GZipDump'] && @function_exists
('gzopen')) {
202 $compressions .= ', gzip';
204 if ($cfg['BZipDump'] && @function_exists
('bzopen')) {
205 $compressions .= ', bzip2';
207 if ($cfg['ZipDump'] && @function_exists
('zip_open')) {
208 $compressions .= ', zip';
211 // We don't have show anything about compression, when no supported
212 if ($compressions != $strNone) {
213 echo '<div class="formelementrow">' . "\n";
214 printf($strCompressionWillBeDetected, $compressions);
215 echo '</div>' . "\n";
220 <fieldset
class="options">
221 <legend
><?php
echo $strPartialImport; ?
></legend
>
224 if (isset($timeout_passed) && $timeout_passed) {
225 echo '<div class="formelementrow">' . "\n";
226 echo '<input type="hidden" name="skip" value="' . $offset . '" />';
227 echo sprintf($strTimeoutInfo, $offset) . '';
228 echo '</div>' . "\n";
231 <div
class="formelementrow">
232 <input type
="checkbox" name
="allow_interrupt" value
="yes"
233 id
="checkbox_allow_interrupt" <?php
echo PMA_pluginCheckboxCheck('Import', 'allow_interrupt'); ?
>/>
234 <label
for="checkbox_allow_interrupt"><?php
echo $strAllowInterrupt; ?
></label
><br
/>
238 if (! (isset($timeout_passed) && $timeout_passed)) {
240 <div
class="formelementrow">
241 <label
for="text_skip_queries"><?php
echo $strSkipQueries; ?
></label
>
242 <input type
="text" name
="skip_queries" value
="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id
="text_skip_queries" />
246 // If timeout has passed,
247 // do not show the Skip dialog to avoid the risk of someone
248 // entering a value here that would interfere with "skip"
250 <input type
="hidden" name
="skip_queries" value
="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id
="text_skip_queries" />
256 <fieldset
class="options">
257 <legend
><?php
echo $strImportFormat; ?
></legend
>
259 // Let's show format options now
260 echo '<div style="float: left;">';
261 echo PMA_pluginGetChoice('Import', 'format', $import_list);
264 echo '<div style="float: left;">';
265 echo PMA_pluginGetOptions('Import', $import_list);
268 <div
class="clearfloat"></div
>
271 // Encoding setting form appended by Y.Kawada
272 if (function_exists('PMA_set_enc_form')) {
273 echo PMA_set_enc_form(' ');
277 <fieldset
class="tblFooters">
278 <input type
="submit" value
="<?php echo $strGo; ?>" id
="buttonGo" />
282 <script type
="text/javascript">