/home/mjc1/public_html/db_admin/ldi_table.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php
/* $Id: ldi_table.php,v 2.8 2004/09/06 00:28:21 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:


/**
 * This file defines the forms used to insert a textfile into a table
 */

require_once('./libraries/grab_globals.lib.php');

// Check parameters
require_once('./libraries/common.lib.php');
PMA_checkParameters(array('db''table'));


/**
 * Gets some core libraries and displays links
 */
require('./tbl_properties_common.php');
$err_url   'ldi_table.php' $err_url;
$url_query .= '&amp;goto=ldi_table.php&amp;back=ldi_table.php';
require(
'./tbl_properties_table_info.php');

/**
 * Displays the form
 */
?>
<form action="ldi_check.php" method="post" enctype="multipart/form-data">
    <table cellpadding="5" border="2">
    <tr>
        <td><?php echo $strLocationTextfile?></td>
        <td colspan="2"><input type="file" name="textfile" />&nbsp;
        <?php
echo PMA_displayMaximumUploadSize($max_upload_size);
// some browsers should respect this :)
echo '    ' PMA_generateHiddenMaxFileSize($max_upload_size) . "\n";

if (!empty(
$cfg['UploadDir'])) {
    if (
substr($cfg['UploadDir'], -1) != '/') {
        
$cfg['UploadDir'] .= '/';
    }
    if (
$handle = @opendir($cfg['UploadDir'])) {
        
$is_first 0;
        while (
$file = @readdir($handle)) {
            if (
is_file($cfg['UploadDir'] . $file) && substr($file, -4) == '.csv') {
                if (
$is_first == 0) {
                    
$is_upload_dir true;
                    echo 
"<br />\n";
                    echo 
'    <i>' $strOr '</i> ' $strWebServerUploadDirectory '&nbsp;: ' "\n";
                    echo 
'    <div style="margin-bottom: 5px">' "\n";
                    echo 
'        <select size="1" name="local_textfile">' "\n";
                    echo 
'            <option value="" selected="selected"></option>' "\n";
                } 
// end if (is_first)
                
echo '            <option value="' htmlspecialchars($file) . '">' htmlspecialchars($file) . '</option>' "\n";
                
$is_first++;
            } 
// end if (is_file)
        
// end while
        
if ($is_first 0) {
            echo 
'        </select>' "\n"
                    
'    </div>' "\n\n";
        } 
// end if (isfirst > 0)
        
@closedir($handle);
    } else {
        echo 
'    <div style="margin-bottom: 5px">' "\n";
        echo 
'        <font color="red">' $strError '</font><br />' "\n";
        echo 
'        ' $strWebServerUploadDirectoryError "\n";
        echo 
'    </div>' "\n";
    }
// end if (web-server upload directory)
echo "\n";
        
?>
        </td>
    </tr>

<?php
if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
    
$temp_charset reset($cfg['AvailableCharsets']);
    echo 
'    <tr>' "\n"
         
'        <td>' $strCharsetOfFile '</td>' "\n"
         
'        <td colspan="2">' "\n"
         
'            <select name="charset_of_file" size="1">' "\n"
         
'                <option value="' $temp_charset '"';
    if (
$temp_charset == $charset) {
        echo 
' selected="selected"';
    }
    echo 
'>' $temp_charset '</option>' "\n";
    while (
$temp_charset next($cfg['AvailableCharsets'])) {
        echo 
'                <option value="' $temp_charset '"';
        if (
$temp_charset == $charset) {
            echo 
' selected="selected"';
        }
        echo 
'>' $temp_charset '</option>' "\n";
    } 
// end while
    
echo '            </select>' "\n";
    echo 
'        </td>' "\n";
    echo 
'    </tr>';
// end if
echo "\n";
?>
    <tr>
        <td><?php echo $strReplaceTable?></td>
        <td><input type="checkbox" name="replace" value="REPLACE" id="checkbox_replace" /><label for="checkbox_replace"><?php echo $strReplace?></label></td>
        <td><?php echo $strTheContents?></td>
    </tr>
    <tr>
        <td><?php echo $strFieldsTerminatedBy?></td>
        <td><input type="text" name="field_terminater" size="4" maxlength="4" value=";" /></td>
        <td><?php echo $strTheTerminator?></td>
    </tr>
    <tr>
        <td><?php echo $strFieldsEnclosedBy?></td>
        <td>
            <input type="text" name="enclosed" size="1" maxlength="1" value="&quot;" />
            <input type="checkbox" name="enclose_option" value="OPTIONALLY" id="checkbox_enclose_option" />
            <label for="checkbox_enclose_option"><?php echo $strOptionally?></label>
        </td>
        <td><?php echo $strOftenQuotation?></td>
    </tr>
    <tr>
        <td><?php echo $strFieldsEscapedBy?></td>
        <td><input type="text" name="escaped" size="2" maxlength="2" value="\" /></td>
        <td><?php echo $strOptionalControls?></td>
    </tr>
    <tr>
        <td><?php echo $strLinesTerminatedBy?></td>
        <td><input type="text" name="line_terminator" size="8" maxlength="8" value="<?php echo ((PMA_whichCrlf() == "\n") ? '\n' '\r\n'); ?>" /></td>
        <td><?php echo $strCarriage?><br /><?php echo $strLineFeed?></td>
    </tr>
    <tr>
        <td><?php echo $strColumnNames?></td>
        <td><input type="text" name="column_name" /></td>
        <td><?php echo $strIfYouWish?></td>
    </tr>
<?php
// 2002/2/22 appended by Y.Kawada: Kanji encoding convert controls
if (function_exists('PMA_set_enc_form')) {
    echo 
'    <tr>' "\n"
         
'        <td>' $strKanjiEncodConvert '</td>' "\n"
         
'        <td colspan=2>' "\n"
         
PMA_set_enc_form('            ')
         . 
'        </td>' "\n"
         
'    </tr>' "\n";
// end if


// Check if we should check the LOCAL radio button by default
$local_option_selected FALSE;

if (
PMA_MYSQL_INT_VERSION 32349) {
        
$local_option_selected TRUE;
}

if (
PMA_MYSQL_INT_VERSION 40003) {
    
$result PMA_DBI_try_query('SHOW VARIABLES LIKE \'local\\_infile\';');
    if (
$result != FALSE && PMA_DBI_num_rows($result) > 0) {
        
$tmp PMA_DBI_fetch_row($result);
        if (
$tmp[1] == 'ON') {
            
$local_option_selected TRUE;
        }
    }
    
PMA_DBI_free_result($result);
    unset(
$result);
}

?>
    <tr>
        <td><?php echo $strLoadMethod?>
        </td>
        <td>
            <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 />
            <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>
        </td>
        <td><?php echo $strLoadExplanation?>
        </td>
    </tr>
    <tr>
        <td colspan="3" align="center"><?php print PMA_showMySQLDocu('Reference''LOAD_DATA'); ?></td>
    </tr>
    <tr>
        <td colspan="3" align="center">
            <?php echo PMA_generate_common_hidden_inputs($db$table); ?>
            <input type="hidden" name="zero_rows" value="<?php echo $strTheContent?>" />
            <input type="hidden" name="goto" value="tbl_properties.php" />
            <input type="hidden" name="back" value="ldi_table.php" />
            <input type="hidden" name="into_table" value="<?php echo htmlspecialchars($table); ?>" />
            <input type="submit" name="btnLDI" value="<?php echo $strSubmit?>" />&nbsp;&nbsp;
            <input type="reset" value="<?php echo $strReset?>" />
        </td>
    </tr>
</table>
</form>


<?php
/**
 * Displays the footer
 */
require_once('./footer.inc.php');
?>