home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / ldi_table.php < prev    next >
Encoding:
PHP Script  |  2003-12-12  |  7.4 KB  |  201 lines

  1. <?php
  2. /* $Id: ldi_table.php,v 2.3 2003/12/13 13:20:06 lem9 Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5.  
  6. /**
  7.  * This file defines the forms used to insert a textfile into a table
  8.  */
  9.  
  10. require_once('./libraries/grab_globals.lib.php');
  11.  
  12. // Check parameters
  13. require_once('./libraries/common.lib.php');
  14. PMA_checkParameters(array('db', 'table'));
  15.  
  16.  
  17. /**
  18.  * Gets some core libraries and displays links
  19.  */
  20. require('./tbl_properties_common.php');
  21. $err_url   = 'ldi_table.php' . $err_url;
  22. $url_query .= '&goto=ldi_table.php&back=ldi_table.php';
  23. require('./tbl_properties_table_info.php');
  24.  
  25. /**
  26.  * Displays the form
  27.  */
  28. ?>
  29. <form action="ldi_check.php" method="post" enctype="multipart/form-data">
  30.     <table cellpadding="5" border="2">
  31.     <tr>
  32.         <td><?php echo $strLocationTextfile; ?></td>
  33.         <td colspan="2"><input type="file" name="textfile" /> 
  34.         <?php
  35. echo PMA_displayMaximumUploadSize($max_upload_size);
  36. // some browsers should respect this :)
  37. echo '    ' . PMA_generateHiddenMaxFileSize($max_upload_size) . "\n";
  38.  
  39. if (!empty($cfg['UploadDir'])) {
  40.     if (substr($cfg['UploadDir'], -1) != '/') {
  41.         $cfg['UploadDir'] .= '/';
  42.     }
  43.     if ($handle = @opendir($cfg['UploadDir'])) {
  44.         $is_first = 0;
  45.         while ($file = @readdir($handle)) {
  46.             if (is_file($cfg['UploadDir'] . $file) && substr($file, -4) == '.csv') {
  47.                 if ($is_first == 0) {
  48.                     $is_upload_dir = true;
  49.                     echo "<br />\n";
  50.                     echo '    <i>' . $strOr . '</i> ' . $strWebServerUploadDirectory . ' : ' . "\n";
  51.                     echo '    <div style="margin-bottom: 5px">' . "\n";
  52.                     echo '        <select size="1" name="local_textfile">' . "\n";
  53.                     echo '            <option value="" selected="selected"></option>' . "\n";
  54.                 } // end if (is_first)
  55.                 echo '            <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
  56.                 $is_first++;
  57.             } // end if (is_file)
  58.         } // end while
  59.         if ($is_first > 0) {
  60.             echo '        </select>' . "\n"
  61.                     . '    </div>' . "\n\n";
  62.         } // end if (isfirst > 0)
  63.         @closedir($handle);
  64.     } else {
  65.         echo '    <div style="margin-bottom: 5px">' . "\n";
  66.         echo '        <font color="red">' . $strError . '</font><br />' . "\n";
  67.         echo '        ' . $strWebServerUploadDirectoryError . "\n";
  68.         echo '    </div>' . "\n";
  69.     }
  70. } // end if (web-server upload directory)
  71. echo "\n";
  72.         ?>
  73.         </td>
  74.     </tr>
  75.  
  76. <?php
  77. if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
  78.     $temp_charset = reset($cfg['AvailableCharsets']);
  79.     echo '    <tr>' . "\n"
  80.          . '        <td>' . $strCharsetOfFile . '</td>' . "\n"
  81.          . '        <td colspan="2">' . "\n"
  82.          . '            <select name="charset_of_file" size="1">' . "\n"
  83.          . '                <option value="' . $temp_charset . '"';
  84.     if ($temp_charset == $charset) {
  85.         echo ' selected="selected"';
  86.     }
  87.     echo '>' . $temp_charset . '</option>' . "\n";
  88.     while ($temp_charset = next($cfg['AvailableCharsets'])) {
  89.         echo '                <option value="' . $temp_charset . '"';
  90.         if ($temp_charset == $charset) {
  91.             echo ' selected="selected"';
  92.         }
  93.         echo '>' . $temp_charset . '</option>' . "\n";
  94.     } // end while
  95.     echo '            </select>' . "\n";
  96.     echo '        </td>' . "\n";
  97.     echo '    </tr>';
  98. } // end if
  99. echo "\n";
  100. ?>
  101.     <tr>
  102.         <td><?php echo $strReplaceTable; ?></td>
  103.         <td><input type="checkbox" name="replace" value="REPLACE" id="checkbox_replace" /><?php echo $strReplace; ?></td>
  104.         <td><label for="checkbox_replace"><?php echo $strTheContents; ?></label></td>
  105.     </tr>
  106.     <tr>
  107.         <td><?php echo $strFieldsTerminatedBy; ?></td>
  108.         <td><input type="text" name="field_terminater" size="2" maxlength="2" value=";" /></td>
  109.         <td><?php echo $strTheTerminator; ?></td>
  110.     </tr>
  111.     <tr>
  112.         <td><?php echo $strFieldsEnclosedBy; ?></td>
  113.         <td>
  114.             <input type="text" name="enclosed" size="1" maxlength="1" value=""" />
  115.             <input type="checkbox" name="enclose_option" value="OPTIONALLY" id="checkbox_enclose_option" />
  116.             <label for="checkbox_enclose_option"><?php echo $strOptionally; ?></label>
  117.         </td>
  118.         <td><?php echo $strOftenQuotation; ?></td>
  119.     </tr>
  120.     <tr>
  121.         <td><?php echo $strFieldsEscapedBy; ?></td>
  122.         <td><input type="text" name="escaped" size="2" maxlength="2" value="\" /></td>
  123.         <td><?php echo $strOptionalControls; ?></td>
  124.     </tr>
  125.     <tr>
  126.         <td><?php echo $strLinesTerminatedBy; ?></td>
  127.         <td><input type="text" name="line_terminator" size="8" maxlength="8" value="<?php echo ((PMA_whichCrlf() == "\n") ? '\n' : '\r\n'); ?>" /></td>
  128.         <td><?php echo $strCarriage; ?><br /><?php echo $strLineFeed; ?></td>
  129.     </tr>
  130.     <tr>
  131.         <td><?php echo $strColumnNames; ?></td>
  132.         <td><input type="text" name="column_name" /></td>
  133.         <td><?php echo $strIfYouWish; ?></td>
  134.     </tr>
  135. <?php
  136. // 2002/2/22 appended by Y.Kawada: Kanji encoding convert controls
  137. if (function_exists('PMA_set_enc_form')) {
  138.     echo '    <tr>' . "\n"
  139.          . '        <td>' . $strKanjiEncodConvert . '</td>' . "\n"
  140.          . '        <td colspan=2>' . "\n"
  141.          . PMA_set_enc_form('            ')
  142.          . '        </td>' . "\n"
  143.          . '    </tr>' . "\n";
  144. } // end if
  145.  
  146.  
  147. // Check if we should check the LOCAL radio button by default
  148. $local_option_selected = FALSE;
  149.  
  150. if (PMA_MYSQL_INT_VERSION < 32349) {
  151.         $local_option_selected = TRUE;
  152. }
  153.  
  154. if (PMA_MYSQL_INT_VERSION > 40003) {
  155.     $tmp_query  = "SHOW VARIABLES LIKE 'local\\_infile'";
  156.     $result = PMA_mysql_query($tmp_query);
  157.     if ($result != FALSE && mysql_num_rows($result) > 0) {
  158.         $tmp = PMA_mysql_fetch_row($result);
  159.         if ($tmp[1] == 'ON') {
  160.             $local_option_selected = TRUE;
  161.         }
  162.     }
  163.     mysql_free_result($result);
  164. }
  165.  
  166. ?>
  167.     <tr>
  168.         <td><?php echo $strLoadMethod; ?>
  169.         </td>
  170.         <td>
  171.             <input type="radio" id="radio_local_option_0" name="local_option" value="0" <?php echo (!$local_option_selected ? ' checked="checked" ' : ''); ?>/><label for="radio_local_option_0">...DATA</label><br />
  172.             <input type="radio" id="radio_local_option_1" name="local_option" value="1" <?php echo ($local_option_selected ? ' checked="checked" ' : ''); ?>/><label for="radio_local_option_1">...DATA LOCAL</label>
  173.         </td>
  174.         <td><?php echo $strLoadExplanation; ?>
  175.         </td>
  176.     </tr>
  177.     <tr>
  178.         <td colspan="3" align="center"><?php print PMA_showMySQLDocu('Reference', 'LOAD_DATA'); ?></td>
  179.     </tr>
  180.     <tr>
  181.         <td colspan="3" align="center">
  182.             <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
  183.             <input type="hidden" name="zero_rows" value="<?php echo $strTheContent; ?>" />
  184.             <input type="hidden" name="goto" value="tbl_properties.php" />
  185.             <input type="hidden" name="back" value="ldi_table.php" />
  186.             <input type="hidden" name="into_table" value="<?php echo htmlspecialchars($table); ?>" />
  187.             <input type="submit" name="btnLDI" value="<?php echo $strSubmit; ?>" />  
  188.             <input type="reset" value="<?php echo $strReset; ?>" />
  189.         </td>
  190.     </tr>
  191. </table>
  192. </form>
  193.  
  194.  
  195. <?php
  196. /**
  197.  * Displays the footer
  198.  */
  199. require_once('./footer.inc.php');
  200. ?>
  201.