*** empty log message ***
[phpmyadmin/crack.git] / ldi_check.php3
blobecae5ac2f3b37c6e651351bbc78e4e917e7a13ec
1 <?php
2 /* $Id$ */
5 /**
6 * This file checks and builds the sql-string for
7 * LOAD DATA INFILE 'file_name.txt' [REPLACE | IGNORE] INTO TABLE table_name
8 * [FIELDS
9 * [TERMINATED BY '\t']
10 * [OPTIONALLY] ENCLOSED BY "]
11 * [ESCAPED BY '\\' ]]
12 * [LINES TERMINATED BY '\n']
13 * [(column_name,...)]
17 /**
18 * Gets some core scripts
20 require('./grab_globals.inc.php3');
21 require('./lib.inc.php3');
24 /**
25 * The form used to define the query has been submitted -> do the work
27 if (isset($btnLDI) && ($textfile != 'none')) {
28 if (!isset($replace)) {
29 $replace = '';
32 // Formats the data posted to this script
33 $textfile = sql_addslashes($textfile);
34 if (get_magic_quotes_gpc()) {
35 $field_terminater = stripslashes($field_terminater);
36 $enclosed = sql_addslashes(stripslashes(str_replace('&quot;', '"', $enclosed)));
37 $escaped = sql_addslashes(stripslashes($escaped));
38 $line_terminator = stripslashes($line_terminator);
39 $column_name = sql_addslashes(stripslashes($column_name));
40 } else {
41 $enclosed = sql_addslashes(str_replace('&quot;', '"', $enclosed));
42 $escaped = sql_addslashes($escaped);
43 $column_name = sql_addslashes($column_name);
46 // Builds the query
47 $query = 'LOAD DATA LOCAL INFILE \'' . $textfile . '\'';
48 if (!empty($replace)) {
49 $query .= ' ' . $replace;
51 $query .= ' INTO TABLE ' . backquote($into_table);
52 if (isset($field_terminater)) {
53 $query .= ' FIELDS TERMINATED BY \'' . $field_terminater . '\'';
55 if (isset($enclose_option) && strlen($enclose_option) > 0) {
56 $query .= ' OPTIONALLY';
58 if (strlen($enclosed) > 0) {
59 $query .= ' ENCLOSED BY \'' . $enclosed . '\'';
61 if (strlen($escaped) > 0) {
62 $query .= ' ESCAPED BY \'' . $escaped . '\'';
64 if (strlen($line_terminator) > 0){
65 $query .= ' LINES TERMINATED BY \'' . $line_terminator . '\'';
67 if (strlen($column_name) > 0) {
68 if (MYSQL_INT_VERSION >= 32306) {
69 $query .= ' (';
70 $tmp = split(',( ?)', $column_name);
71 for ($i = 0; $i < count($tmp); $i++) {
72 if ($i > 0) {
73 $query .= ', ';
75 $query .= backquote(trim($tmp[$i]));
76 } // end for
77 $query .= ')';
78 } else {
79 $query .= ' (' . $column_name . ')';
83 // Executes the query
84 // sql.php3 will stripslash the query if 'magic_quotes_gpc' is set to on
85 if (get_magic_quotes_gpc()) {
86 $sql_query = addslashes($query);
87 } else {
88 $sql_query = $query;
90 include('./sql.php3');
94 /**
95 * The form used to define the query hasn't been yet submitted -> loads it
97 else {
98 include('./ldi_table.php3');