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" src
="import.php"></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">
36 // Mootools code for handling Ajax requests
37 window
.addEvent('load', function() {
38 // webkit fix from 3rd source, but it does not work sometimes (??) --
40 ////////////////////////////// {{{{{
41 Request
.HTML
.implement({
43 processHTML
: function(text
) {
44 var match
= text
.match(/<body
[^
>]*>([\s\S
]*?
)<\
/body
>/i
);
45 text
= (match
) ? match
[1] : text
;
47 var container
= new Element('div');
49 return $try(function(){
50 var root
= '<root>' + text +
'</root>', doc
;
51 doc
= new DOMParser().parseFromString(root
, 'text/html');
52 root
= doc
.getElementsByTagName('root')[0];
53 for (var i
= 0, k
= root
.childNodes
.length
; i
< k
; i++
){
54 var child
= Element
.clone(root
.childNodes
[i
], true, true);
55 if (child
) container
.grab(child
);
58 }) || container
.set('html', text
);
63 ////////////////////////// }}}}}
64 // add event when user click on "Go" button
65 $
('buttonGo').addEvent('click', function() {
66 $
('upload_form_form').setStyle("display", "none"); // hide form
67 $
('upload_form_status').setStyle("display", "inline"); // show progress bar
68 $
('upload_form_status_info').setStyle("display", "inline"); // - || -
70 if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") {
72 $
('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
80 var periodical_upload
;
82 var request_upload
= new Request({
83 url
: 'import_status.php?id=<?php echo $upload_id ; ?>&<?php echo PMA_generate_common_url(); ?>', // the "&" is causing problems for webkit browsers
85 update
: 'upload_form_status',
86 onComplete
: function(response
) {
87 objectsReturned
= JSON
.decode(response
);
89 $each(objectsReturned
, function(item
, index
) {
91 if (index
=="finished") {
94 $clear(periodical_upload
);
95 $
('importmain').setStyle('display', 'none');
96 $
('import_form_status').setStyle('display', 'inline');
97 $
('import_form_status').set('html', '<img src="<?php echo $GLOBALS['pmaThemeImage
'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo $strImportProceedingFile; ?> ');
98 $
('import_form_status').load('import_status.php?message=true&<?php echo PMA_generate_common_url(); ?>'); // loads the message, either success or mysql error
101 // reload the left sidebar when the import is finished
102 $GLOBALS['reload']=true;
103 PMA_reloadNavigation(true);
106 } // if [finished==item]
107 } // if [index==finished]
108 if (index
=="percent")
113 if (index
=="complete")
116 if (total
==0 && complete
==0 && percent
==0) {
117 $
('upload_form_status_info').set('html', '<img src="<?php echo $GLOBALS['pmaThemeImage
'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo PMA_jsFormat($strImportLargeFileUploading); ?>');
118 $
('upload_form_status').setStyle("display", "none");
120 $
('upload_form_status_info').set('html', ' '+Math
.round(percent
)+
'%, '+complete+
'/'+total
);
121 $
('status').tween('width', Math
.round(percent
)*2+
'px');
125 perform_upload
= function () {
126 request_upload
.send('r=' +
$time() +
$random(0, 100)); // hack for IE7,8 & webkit (Safari, Chrome, Arora...)
128 periodical_upload
= perform_upload
.periodical(1000);
132 $
('upload_form_status_info').set('html', '<img src="<?php echo $GLOBALS['pmaThemeImage
'];?>ajax_clock_small.gif" alt="ajax clock" /> <?php echo $strImportUploadInfoNotAvailable; ?>');
133 $
('upload_form_status').setStyle("display", "none");
139 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"'; ?>>');
144 <form action
="import.php" method
="post" enctype
="multipart/form-data" name
="import">
146 <input type
="hidden" name
="<?php echo $ID_KEY; ?>" value
="<?php echo $upload_id ; ?>" />
148 if ($import_type == 'server') {
149 echo PMA_generate_common_hidden_inputs('', '', 1);
150 } elseif ($import_type == 'database') {
151 echo PMA_generate_common_hidden_inputs($db, '', 1);
153 echo PMA_generate_common_hidden_inputs($db, $table, 1);
155 echo ' <input type="hidden" name="import_type" value="' . $import_type . '" />'."\n";
156 echo PMA_pluginGetJavascript($import_list);
158 <fieldset
class="options">
159 <legend
><?php
echo $strFileToImport; ?
></legend
>
163 if ($GLOBALS['is_upload']) {
166 <div
class="formelementrow" id
="upload_form">
167 <div id
="upload_form_status" style
="display: none;"></div
>
168 <div id
="upload_form_status_info" style
="display: none;"></div
>
169 <div id
="upload_form_form">
170 <label
for="input_import_file"><?php
echo $strLocationTextfile; ?
></label
>
171 <input style
="margin: 5px" type
="file" name
="import_file" id
="input_import_file" onchange
="match_file(this.value);" />
173 echo PMA_displayMaximumUploadSize($max_upload_size) . "\n";
174 // some browsers should respect this :)
175 echo PMA_generateHiddenMaxFileSize($max_upload_size) . "\n";
181 PMA_Message
::warning('strUploadsNotAllowed')->display();
183 if (!empty($cfg['UploadDir'])) {
185 foreach ($import_list as $key => $val) {
186 if (!empty($extensions)) {
189 $extensions .= $val['extension'];
191 $matcher = '@\.(' . $extensions . ')(\.(' . PMA_supportedDecompressions() . '))?$@';
193 $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ?
$local_import_file : '');
194 echo '<div class="formelementrow">' . "\n";
195 if ($files === FALSE) {
196 PMA_Message
::error('strWebServerUploadDirectoryError')->display();
197 } elseif (!empty($files)) {
199 echo ' <i>' . $strOr . '</i><br/><label for="select_local_import_file">' . $strWebServerUploadDirectory . '</label> : ' . "\n";
200 echo ' <select style="margin: 5px" size="1" name="local_import_file" onchange="match_file(this.value)" id="select_local_import_file">' . "\n";
201 echo ' <option value=""> </option>' . "\n";
203 echo ' </select>' . "\n";
205 echo '</div>' . "\n";
206 } // end if (web-server upload directory)
209 echo '<div class="formelementrow">' . "\n";
210 if ($cfg['AllowAnywhereRecoding']) {
211 echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>';
212 reset($cfg['AvailableCharsets']);
213 echo '<select id="charset_of_file" name="charset_of_file" size="1">';
214 foreach ($cfg['AvailableCharsets'] as $temp_charset) {
215 echo '<option value="' . htmlentities($temp_charset) . '"';
216 if ((empty($cfg['Import']['charset']) && $temp_charset == $charset)
217 ||
$temp_charset == $cfg['Import']['charset']) {
218 echo ' selected="selected"';
220 echo '>' . htmlentities($temp_charset) . '</option>';
222 echo ' </select><br />';
224 echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>' . "\n";
225 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET
, 'charset_of_file', 'charset_of_file', 'utf8', FALSE);
226 } // end if (recoding)
227 echo '</div>' . "\n";
229 // zip, gzip and bzip2 encode features
230 $compressions = $strNone;
232 if ($cfg['GZipDump'] && @function_exists
('gzopen')) {
233 $compressions .= ', gzip';
235 if ($cfg['BZipDump'] && @function_exists
('bzopen')) {
236 $compressions .= ', bzip2';
238 if ($cfg['ZipDump'] && @function_exists
('zip_open')) {
239 $compressions .= ', zip';
242 // We don't have show anything about compression, when no supported
243 if ($compressions != $strNone) {
244 echo '<div class="formelementrow">' . "\n";
245 printf($strCompressionWillBeDetected, $compressions);
246 echo '</div>' . "\n";
251 <fieldset
class="options">
252 <legend
><?php
echo $strPartialImport; ?
></legend
>
255 if (isset($timeout_passed) && $timeout_passed) {
256 echo '<div class="formelementrow">' . "\n";
257 echo '<input type="hidden" name="skip" value="' . $offset . '" />';
258 echo sprintf($strTimeoutInfo, $offset) . '';
259 echo '</div>' . "\n";
262 <div
class="formelementrow">
263 <input type
="checkbox" name
="allow_interrupt" value
="yes"
264 id
="checkbox_allow_interrupt" <?php
echo PMA_pluginCheckboxCheck('Import', 'allow_interrupt'); ?
>/>
265 <label
for="checkbox_allow_interrupt"><?php
echo $strAllowInterrupt; ?
></label
><br
/>
269 if (! (isset($timeout_passed) && $timeout_passed)) {
271 <div
class="formelementrow">
272 <label
for="text_skip_queries"><?php
echo $strSkipQueries; ?
></label
>
273 <input type
="text" name
="skip_queries" value
="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id
="text_skip_queries" />
277 // If timeout has passed,
278 // do not show the Skip dialog to avoid the risk of someone
279 // entering a value here that would interfere with "skip"
281 <input type
="hidden" name
="skip_queries" value
="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id
="text_skip_queries" />
287 <fieldset
class="options">
288 <legend
><?php
echo $strImportFormat; ?
></legend
>
290 // Let's show format options now
291 echo '<div style="float: left;">';
292 echo PMA_pluginGetChoice('Import', 'format', $import_list);
295 echo '<div style="float: left;">';
296 echo PMA_pluginGetOptions('Import', $import_list);
299 <div
class="clearfloat"></div
>
302 // Encoding setting form appended by Y.Kawada
303 if (function_exists('PMA_set_enc_form')) {
304 echo PMA_set_enc_form(' ');
308 <fieldset
class="tblFooters">
309 <input type
="submit" value
="<?php echo $strGo; ?>" id
="buttonGo" />
313 <script type
="text/javascript">