do the work */ if (isset($btnLDI) && ($textfile != 'none')) { if (!isset($replace)) { $replace = ''; } error_reporting(E_ALL); chmod($textfile, 0644); // Kanji encoding convert appended by Y.Kawada if (function_exists('PMA_kanji_file_conv')) { $textfile = PMA_kanji_file_conv($textfile, $knjenc, isset($xkana) ? $xkana : ''); } // Convert the file's charset if necessary if ($cfg['AllowAnywhereRecoding'] && $allow_recoding && isset($charset_of_file) && $charset_of_file != $charset) { $textfile = PMA_convert_file($charset_of_file, $convcharset, $textfile); } // Formats the data posted to this script $textfile = PMA_sqlAddslashes($textfile); if (get_magic_quotes_gpc()) { $field_terminater = stripslashes($field_terminater); $enclosed = PMA_sqlAddslashes(stripslashes($enclosed)); $escaped = PMA_sqlAddslashes(stripslashes($escaped)); $line_terminator = stripslashes($line_terminator); $column_name = PMA_sqlAddslashes(stripslashes($column_name)); } else { $enclosed = PMA_sqlAddslashes($enclosed); $escaped = PMA_sqlAddslashes($escaped); $column_name = PMA_sqlAddslashes($column_name); } // (try to) make sure the file is readable: chmod($textfile, 0777); // Builds the query $query = 'LOAD DATA'; // for versions before 3.23.49, we use the LOCAL keyword, because // there was a version (cannot find which one, and it does not work // with 3.23.38) where the user can LOAD, even if the user does not // have FILE priv, and even if the file is on the server // (which is the present case) // // we could also code our own loader, but LOAD DATA INFILE is optimized // for speed if (PMA_MYSQL_INT_VERSION < 32349) { $query .= ' LOCAL'; } if (PMA_MYSQL_INT_VERSION > 40003) { $tmp_query = "SHOW VARIABLES LIKE 'local\\_infile'"; $result = PMA_mysql_query($tmp_query); if ($result != FALSE && mysql_num_rows($result) > 0) { $tmp = PMA_mysql_fetch_row($result); if ($tmp[1] == 'ON') { $query .= ' LOCAL'; } } mysql_free_result($result); } $query .= ' INFILE \'' . $textfile . '\''; if (!empty($replace)) { $query .= ' ' . $replace; } $query .= ' INTO TABLE ' . PMA_backquote($into_table); if (isset($field_terminater)) { $query .= ' FIELDS TERMINATED BY \'' . $field_terminater . '\''; } if (isset($enclose_option) && strlen($enclose_option) > 0) { $query .= ' OPTIONALLY'; } if (strlen($enclosed) > 0) { $query .= ' ENCLOSED BY \'' . $enclosed . '\''; } if (strlen($escaped) > 0) { $query .= ' ESCAPED BY \'' . $escaped . '\''; } if (strlen($line_terminator) > 0){ $query .= ' LINES TERMINATED BY \'' . $line_terminator . '\''; } if (strlen($column_name) > 0) { if (PMA_MYSQL_INT_VERSION >= 32306) { $query .= ' ('; $tmp = split(',( ?)', $column_name); for ($i = 0; $i < count($tmp); $i++) { if ($i > 0) { $query .= ', '; } $query .= PMA_backquote(trim($tmp[$i])); } // end for $query .= ')'; } else { $query .= ' (' . $column_name . ')'; } } // Executes the query // sql.php3 will stripslash the query if 'magic_quotes_gpc' is set to on if (get_magic_quotes_gpc()) { $sql_query = addslashes($query); } else { $sql_query = $query; } // We could rename the ldi* scripts to tbl_properties_ldi* to improve // consistency with the other sub-pages. // // The $goto in ldi_table.php3 is set to tbl_properties.php3 but maybe // if would be better to Browse the latest inserted data. include('./sql.php3'); } /** * The form used to define the query hasn't been yet submitted -> loads it */ else { include('./ldi_table.php3'); } ?>