Rev Author Line No. Line
250 kaklik 1 <?php
2 /* $Id: display_import.lib.php,v 1.17 2006/01/17 17:02:30 cybot_tm Exp $ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4  
5 require_once('./libraries/file_listing.php');
6 require_once('./libraries/plugin_interface.lib.php');
7  
8 /* Scan for plugins */
9 $import_list = PMA_getPlugins('./libraries/import/', $import_type);
10  
11 /* Fail if we didn't find any plugin */
12 if (empty($import_list)) {
13 $GLOBALS['show_error_header'] = TRUE;
14 PMA_showMessage($strCanNotLoadImportPlugins);
15 unset($GLOBALS['show_error_header']);
16 require('./libraries/footer.inc.php');
17 }
18 ?>
19  
20 <form action="import.php" method="post" enctype="multipart/form-data" name="import">
21 <?php
22 if ($import_type == 'server') {
23 echo PMA_generate_common_hidden_inputs('', '', 1);
24 } elseif ($import_type == 'database') {
25 echo PMA_generate_common_hidden_inputs($db, '', 1);
26 } else {
27 echo PMA_generate_common_hidden_inputs($db, $table, 1);
28 }
29 echo ' <input type="hidden" name="import_type" value="' . $import_type . '" />';
30 echo PMA_pluginGetJavascript($import_list);
31 ?>
32  
33 <h2><?php echo $strImport; ?></h2>
34  
35 <!-- File name, and some other common options -->
36 <fieldset class="options">
37 <legend><?php echo $strFileToImport; ?></legend>
38  
39 <div class="formelementrow">
40 <label for="input_import_file"><?php echo $strLocationTextfile; ?></label>
41 <input style="margin: 5px" type="file" name="import_file" id="input_import_file" onchange="match_file(this.value);" />
42 <?php
43 echo PMA_displayMaximumUploadSize($max_upload_size) . "\n";
44 // some browsers should respect this :)
45 echo PMA_generateHiddenMaxFileSize($max_upload_size) . "\n";
46 ?>
47 </div>
48 <?php
49 if (!empty($cfg['UploadDir'])) {
50 $extensions = '';
51 foreach ($import_list as $key => $val) {
52 if (!empty($extensions)) {
53 $extensions .= '|';
54 }
55 $extensions .= $val['extension'];
56 }
57 $matcher = '@\.(' . $extensions . ')(\.(' . PMA_supportedDecompressions() . '))?$@';
58  
59 $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : '');
60 echo '<div class="formelementrow">' . "\n";
61 if ($files === FALSE) {
62 echo ' <div class="warning">' . "\n";
63 echo ' <strong>' . $strError . '</strong>: ' . "\n";
64 echo ' ' . $strWebServerUploadDirectoryError . "\n";
65 echo ' </div>' . "\n";
66 } elseif (!empty($files)) {
67 echo "\n";
68 echo ' <i>' . $strOr . '</i><br/><label for="select_local_import_file">' . $strWebServerUploadDirectory . '</label>&nbsp;: ' . "\n";
69 echo ' <select style="margin: 5px" size="1" name="local_import_file" onchange="match_file(this.value)" id="select_local_import_file">' . "\n";
70 echo ' <option value=""></option>' . "\n";
71 echo $files;
72 echo ' </select>' . "\n";
73 }
74 echo '</div>' . "\n";
75 } // end if (web-server upload directory)
76  
77 // charset of file
78 echo '<div class="formelementrow">' . "\n";
79 if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
80 echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>' . "\n";
81 $temp_charset = reset($cfg['AvailableCharsets']);
82 echo $strCharsetOfFile . "\n"
83 . ' <select id="charset_of_file" name="charset_of_file" size="1">' . "\n"
84 . ' <option value="' . htmlentities( $temp_charset ) . '"';
85 if ($temp_charset == $charset) {
86 echo ' selected="selected"';
87 }
88 echo '>' . htmlentities( $temp_charset ) . '</option>' . "\n";
89 while ($temp_charset = next($cfg['AvailableCharsets'])) {
90 echo ' <option value="' . htmlentities( $temp_charset ) . '"';
91 if ($temp_charset == $charset) {
92 echo ' selected="selected"';
93 }
94 echo '>' . htmlentities( $temp_charset ) . '</option>' . "\n";
95 }
96 echo ' </select><br />' . "\n" . ' ';
97 } elseif (PMA_MYSQL_INT_VERSION >= 40100) {
98 echo '<label for="charset_of_file">' . $strCharsetOfFile . '</label>' . "\n";
99 echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', 'charset_of_file', 'utf8', FALSE);
100 } // end if (recoding)
101 echo '</div>' . "\n";
102  
103 // zip, gzip and bzip2 encode features
104 $compressions = $strNone;
105  
106 if ($cfg['GZipDump'] && @function_exists('gzopen')) {
107 $compressions .= ', gzip';
108 }
109 if ($cfg['BZipDump'] && @function_exists('bzopen')) {
110 $compressions .= ', bzip2';
111 }
112 if ($cfg['ZipDump'] && @function_exists('gzinflate')) {
113 $compressions .= ', zip';
114 }
115  
116 // We don't have show anything about compression, when no supported
117 if ($compressions != $strNone) {
118 echo '<div class="formelementrow">' . "\n";
119 printf( $strCompressionWillBeDetected, $compressions);
120 echo '</div>' . "\n";
121 }
122 echo "\n";
123 ?>
124 </fieldset>
125 <fieldset class="options">
126 <legend><?php echo $strPartialImport; ?></legend>
127  
128 <?php
129 if (isset($timeout_passed) && $timeout_passed) {
130 echo '<div class="formelementrow">' . "\n";
131 echo '<input type="hidden" name="skip" value="' . $offset . '" />';
132 echo sprintf($strTimeoutInfo, $offset) . '';
133 echo '</div>' . "\n";
134 }
135 ?>
136 <div class="formelementrow">
137 <input type="checkbox" name="allow_interrupt" value="yes"
138 id="checkbox_allow_interrupt" <?php echo PMA_pluginCheckboxCheck('Import', 'allow_interrupt'); ?>/>
139 <label for="checkbox_allow_interrupt"><?php echo $strAllowInterrupt; ?></label><br />
140 </div>
141  
142 <div class="formelementrow">
143 <label for="text_skip_queries"><?php echo $strSkipQueries; ?></label>
144 <input type="text" name="skip_queries" value="<?php echo PMA_pluginGetDefault('Import', 'skip_queries');?>" id="text_skip_queries" />
145 </div>
146 </fieldset>
147  
148 <fieldset class="options">
149 <legend><?php echo $strImportFormat; ?></legend>
150 <?php
151 // Let's show format options now
152 echo '<div style="float: left;">';
153 echo PMA_pluginGetChoice('Import', 'format', $import_list);
154 echo '</div>';
155  
156 echo '<div style="float: left;">';
157 echo PMA_pluginGetOptions('Import', $import_list);
158 echo '</div>';
159 ?>
160 <div class="clearfloat"></div>
161 </fieldset>
162 <?php
163 // Encoding setting form appended by Y.Kawada
164 if (function_exists('PMA_set_enc_form')) {
165 echo PMA_set_enc_form(' ');
166 }
167 echo "\n";
168 ?>
169 <fieldset class="tblFooters">
170 <input type="submit" value="<?php echo $strGo; ?>" id="buttonGo" />
171 </fieldset>
172 </form>
173 <script type="text/javascript" language="javascript">
174 //<![CDATA[
175 init_options();
176 //]]>
177 </script>