Skip to content
Newer
Older
100644 736 lines (662 sloc) 22.6 KB
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
1 <?php
817e790 synced/fixed vim line
Sebastian Mendel authored Mar 19, 2007
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
374abd5 fixed/added page level docblock
Sebastian Mendel authored Mar 20, 2007
3 /**
4 * Core script for import, this is just the glue around all other stuff
5 *
e56949f @nijel Use package name PhpMyAdmin
nijel authored Oct 25, 2011
6 * @package PhpMyAdmin
374abd5 fixed/added page level docblock
Sebastian Mendel authored Mar 20, 2007
7 */
28d15eb @nijel Add method for checking if encoding conversion is supported
nijel authored Mar 8, 2016
8 use PMA\libraries\Encoding;
178a6ed @Tithugues Add namespace on part of plugins classes.
Tithugues authored Sep 5, 2015
9 use PMA\libraries\plugins\ImportPlugin;
b54e5b0 @nijel Use File class for file imports
nijel authored Apr 11, 2016
10 use PMA\libraries\File;
0b64827 @007durgesh219 Refactored url parmeters generating, Issue #11990
007durgesh219 authored Feb 19, 2016
11 use PMA\libraries\URL;
43cfba9 @madhuracj Refactor bookmarking
madhuracj authored Mar 9, 2016
12 use PMA\libraries\Bookmark;
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
13
14 /**
15 * Get the variables sent or posted to this script and a core script
16 */
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored Mar 16, 2012
17 require_once 'libraries/common.inc.php';
3dd3587 @scnakandala removed include sql.php from import.php
scnakandala authored Jul 24, 2013
18 require_once 'libraries/sql.lib.php';
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored Mar 16, 2012
19 //require_once 'libraries/display_import_functions.lib.php';
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
20
1fa9416 @lem9 No longer depend on grab_globals.lib.php for $_GET variables
lem9 authored Mar 4, 2012
21 if (isset($_REQUEST['show_as_php'])) {
22 $GLOBALS['show_as_php'] = $_REQUEST['show_as_php'];
23 }
24
8a46508 @ashutoshdhundhara RFE#861: Simulate UPDATE queries.
ashutoshdhundhara authored Jun 18, 2014
25 // Import functions.
26 require_once 'libraries/import.lib.php';
27
28 // If there is a request to 'Simulate DML'.
29 if (isset($_REQUEST['simulate_dml'])) {
30 PMA_handleSimulateDMLRequest();
31 exit;
32 }
33
fb14e92 @WhaleWatching PMA console, history and bookmarks.
WhaleWatching authored Jun 16, 2014
34 // If it's a refresh console bookmarks request
54000aa @WhaleWatching [Console]Second commit
WhaleWatching authored Jul 2, 2014
35 if (isset($_REQUEST['console_bookmark_refresh'])) {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
36 $response = PMA\libraries\Response::getInstance();
30e0dc7 @Tithugues Coding style modifications.
Tithugues authored Aug 9, 2014
37 $response->addJSON(
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
38 'console_message_bookmark', PMA\libraries\Console::getBookmarkContent()
30e0dc7 @Tithugues Coding style modifications.
Tithugues authored Aug 9, 2014
39 );
fb14e92 @WhaleWatching PMA console, history and bookmarks.
WhaleWatching authored Jun 16, 2014
40 exit;
41 }
54000aa @WhaleWatching [Console]Second commit
WhaleWatching authored Jul 2, 2014
42 // If it's a console bookmark add request
43 if (isset($_REQUEST['console_bookmark_add'])) {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
44 $response = PMA\libraries\Response::getInstance();
30e0dc7 @Tithugues Coding style modifications.
Tithugues authored Aug 9, 2014
45 if (isset($_REQUEST['label']) && isset($_REQUEST['db'])
46 && isset($_REQUEST['bookmark_query']) && isset($_REQUEST['shared'])
47 ) {
43cfba9 @madhuracj Refactor bookmarking
madhuracj authored Mar 9, 2016
48 $cfgBookmark = Bookmark::getParams();
54000aa @WhaleWatching [Console]Second commit
WhaleWatching authored Jul 2, 2014
49 $bookmarkFields = array(
50 'bkm_database' => $_REQUEST['db'],
51 'bkm_user' => $cfgBookmark['user'],
52 'bkm_sql_query' => urlencode($_REQUEST['bookmark_query']),
53 'bkm_label' => $_REQUEST['label']
54 );
55 $isShared = ($_REQUEST['shared'] == 'true' ? true : false);
43cfba9 @madhuracj Refactor bookmarking
madhuracj authored Mar 9, 2016
56 $bookmark = Bookmark::createBookmark($bookmarkFields, $isShared);
b47256c @madhuracj Check whether valid bookmark was returned
madhuracj authored Mar 9, 2016
57 if ($bookmark !== false && $bookmark->save()) {
65ab32f @lem9 Fix typo
lem9 authored Aug 2, 2014
58 $response->addJSON('message', __('Succeeded'));
54000aa @WhaleWatching [Console]Second commit
WhaleWatching authored Jul 2, 2014
59 $response->addJSON('data', $bookmarkFields);
60 $response->addJSON('isShared', $isShared);
61 } else {
62 $response->addJSON('message', __('Failed'));
63 }
64 die();
65 } else {
66 $response->addJSON('message', __('Incomplete params'));
67 die();
68 }
69 }
fb14e92 @WhaleWatching PMA console, history and bookmarks.
WhaleWatching authored Jun 16, 2014
70
3bacb68 @nijel Make sure format is always defined
nijel authored Feb 12, 2016
71 $format = '';
72
ed8a498 @lem9 $_POST and bookmark actions
lem9 authored Mar 11, 2012
73 /**
74 * Sets globals from $_POST
75 */
76 $post_params = array(
0326405 Don't rely on grab_globals for import.php
Jo Michael authored Mar 16, 2012
77 'charset_of_file',
78 'format',
79 'import_type',
ed8a498 @lem9 $_POST and bookmark actions
lem9 authored Mar 11, 2012
80 'is_js_confirmed',
0326405 Don't rely on grab_globals for import.php
Jo Michael authored Mar 16, 2012
81 'MAX_FILE_SIZE',
82 'message_to_show',
83 'noplugin',
1f7336f Fix bug #3890 [import] Web server upload directory import fails
J.M authored Apr 26, 2013
84 'skip_queries',
85 'local_import_file'
ed8a498 @lem9 $_POST and bookmark actions
lem9 authored Mar 11, 2012
86 );
0326405 Don't rely on grab_globals for import.php
Jo Michael authored Mar 16, 2012
87
ed8a498 @lem9 $_POST and bookmark actions
lem9 authored Mar 11, 2012
88 foreach ($post_params as $one_post_param) {
89 if (isset($_POST[$one_post_param])) {
90 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
91 }
92 }
93
60536d7 @lem9 patch #2798592 [import] Progress bar
lem9 authored Jul 2, 2009
94 // reset import messages for ajax request
95 $_SESSION['Import_message']['message'] = null;
96 $_SESSION['Import_message']['go_back_url'] = null;
395741c refresh left frame also on multiqueries and bookmarks
Sebastian Mendel authored Feb 5, 2006
97 // default values
98 $GLOBALS['reload'] = false;
99
9b77d74 @Tithugues Mass modifications to use PMA_String.
Tithugues authored Aug 15, 2014
100 // Use to identify current cycle is executing
4465c28 @Chanaka Fixed an issue related to multiquery statements and routines modifica…
Chanaka authored Jul 26, 2012
101 // a multiquery statement or stored routine
102 if (!isset($_SESSION['is_multi_query'])) {
103 $_SESSION['is_multi_query'] = false;
104 }
105
6439a10 @madhuracj bug #4872 Drop table doesn't remove the table name from navigation bar
madhuracj authored May 29, 2015
106 $ajax_reload = array();
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
107 // Are we just executing plain query or sql file?
108 // (eg. non import, but query box/window run)
621280e @alexukf remove spaces around the not operator
alexukf authored Apr 20, 2012
109 if (! empty($sql_query)) {
8cb8281 @madhuracj rfe #1380 Support for Paramaters with raw SQL
madhuracj authored Apr 29, 2015
110
111 // apply values for parameters
9a40c11 @lem9 Fixes #11792 Undefined index: parameters
lem9 authored Dec 28, 2015
112 if (! empty($_REQUEST['parameterized'])
113 && ! empty($_REQUEST['parameters'])
3b22720 @devenbansod Make phpcs happy
devenbansod authored Mar 22, 2016
114 && is_array($_REQUEST['parameters'])
115 ) {
8cb8281 @madhuracj rfe #1380 Support for Paramaters with raw SQL
madhuracj authored Apr 29, 2015
116 $parameters = $_REQUEST['parameters'];
117 foreach ($parameters as $parameter => $replacement) {
118 $quoted = preg_quote($parameter);
cca0e02 @madhuracj Improve parameter applying
madhuracj authored Apr 29, 2015
119 // making sure that :param does not apply values to :param1
8cb8281 @madhuracj rfe #1380 Support for Paramaters with raw SQL
madhuracj authored Apr 29, 2015
120 $sql_query = preg_replace(
121 '/' . $quoted . '([^a-zA-Z0-9_])/',
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
122 PMA\libraries\Util::sqlAddSlashes($replacement) . '${1}',
8cb8281 @madhuracj rfe #1380 Support for Paramaters with raw SQL
madhuracj authored Apr 29, 2015
123 $sql_query
124 );
cca0e02 @madhuracj Improve parameter applying
madhuracj authored Apr 29, 2015
125 // for parameters the appear at the end of the string
126 $sql_query = preg_replace(
127 '/' . $quoted . '$/',
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
128 PMA\libraries\Util::sqlAddSlashes($replacement),
cca0e02 @madhuracj Improve parameter applying
madhuracj authored Apr 29, 2015
129 $sql_query
130 );
8cb8281 @madhuracj rfe #1380 Support for Paramaters with raw SQL
madhuracj authored Apr 29, 2015
131 }
132 }
133
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
134 // run SQL query
135 $import_text = $sql_query;
136 $import_type = 'query';
3e79c53 @nijel Generic plugin infrastructure and use it in import (needed for RFE#13…
nijel authored Dec 8, 2005
137 $format = 'sql';
915f209 @rakeshkaundilya BugFix#4714
rakeshkaundilya authored Jan 20, 2015
138 $_SESSION['sql_from_query_box'] = true;
bfec931 @nijel Improve functionality of limiting DROP DATABASE (bug #1456082).
nijel authored Apr 27, 2006
139
04d7be1 @ashutoshdhundhara RFE#869: Run SQL query: Allow rollback for InnoDB tables.
ashutoshdhundhara authored Jun 20, 2014
140 // If there is a request to ROLLBACK when finished.
141 if (isset($_REQUEST['rollback_query'])) {
142 PMA_handleRollbackRequest($import_text);
143 }
144
f3aa2a3 @zixtor Fix bug 3842: create, alter, drop queries were not shown after execution
zixtor authored Mar 21, 2013
145 // refresh navigation and main panels
146 if (preg_match('/^(DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
395741c refresh left frame also on multiqueries and bookmarks
Sebastian Mendel authored Feb 5, 2006
147 $GLOBALS['reload'] = true;
6439a10 @madhuracj bug #4872 Drop table doesn't remove the table name from navigation bar
madhuracj authored May 29, 2015
148 $ajax_reload['reload'] = true;
395741c refresh left frame also on multiqueries and bookmarks
Sebastian Mendel authored Feb 5, 2006
149 }
bfec931 @nijel Improve functionality of limiting DROP DATABASE (bug #1456082).
nijel authored Apr 27, 2006
150
f3aa2a3 @zixtor Fix bug 3842: create, alter, drop queries were not shown after execution
zixtor authored Mar 21, 2013
151 // refresh navigation panel only
9b78827 @lem9 Fix coding style
lem9 authored Oct 28, 2013
152 if (preg_match(
153 '/^(CREATE|ALTER)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
154 $sql_query
155 )) {
6439a10 @madhuracj bug #4872 Drop table doesn't remove the table name from navigation bar
madhuracj authored May 29, 2015
156 $ajax_reload['reload'] = true;
f3aa2a3 @zixtor Fix bug 3842: create, alter, drop queries were not shown after execution
zixtor authored Mar 21, 2013
157 }
158
7112e7f @ayushchd Cosmetic changes
ayushchd authored Feb 26, 2013
159 // do a dynamic reload if table is RENAMED
160 // (by sending the instruction to the AJAX response handler)
9b78827 @lem9 Fix coding style
lem9 authored Oct 28, 2013
161 if (preg_match(
162 '/^RENAME\s+TABLE\s+(.*?)\s+TO\s+(.*?)($|;|\s)/i',
163 $sql_query,
164 $rename_table_names
165 )) {
6439a10 @madhuracj bug #4872 Drop table doesn't remove the table name from navigation bar
madhuracj authored May 29, 2015
166 $ajax_reload['reload'] = true;
ffc4422 @Tithugues Make PHPCS happy.
Tithugues authored Oct 19, 2015
167 $ajax_reload['table_name'] = PMA\libraries\Util::unQuote(
168 $rename_table_names[2]
169 );
69b73a4 @ayushchd Bug fix #3818 After "Rename table ... to ..." left menu doesn't refle…
ayushchd authored Feb 25, 2013
170 }
466a764 @madhuracj PHP keywords must be lowercase
madhuracj authored Apr 12, 2013
171
b2f3ae5 make $sql_query persistent (init it, never unset it, always assume it…
Sebastian Mendel authored Apr 1, 2007
172 $sql_query = '';
621280e @alexukf remove spaces around the not operator
alexukf authored Apr 20, 2012
173 } elseif (! empty($sql_file)) {
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
174 // run uploaded SQL file
175 $import_file = $sql_file;
176 $import_type = 'queryfile';
3e79c53 @nijel Generic plugin infrastructure and use it in import (needed for RFE#13…
nijel authored Dec 8, 2005
177 $format = 'sql';
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
178 unset($sql_file);
f9248d3 @madhuracj Use request params directly, 'id_bookmark'
madhuracj authored Nov 14, 2014
179 } elseif (! empty($_REQUEST['id_bookmark'])) {
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
180 // run bookmark
181 $import_type = 'query';
3e79c53 @nijel Generic plugin infrastructure and use it in import (needed for RFE#13…
nijel authored Dec 8, 2005
182 $format = 'sql';
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
183 }
184
bfec931 @nijel Improve functionality of limiting DROP DATABASE (bug #1456082).
nijel authored Apr 27, 2006
185 // If we didn't get any parameters, either user called this directly, or
f4a8faf @nijel Try to detect that upload failed because of limits (RFE #1240480).
nijel authored Oct 8, 2005
186 // upload limit has been reached, let's assume the second possibility.
187 if ($_POST == array() && $_GET == array()) {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
188 $message = PMA\libraries\Message::error(
bf61709 @Tithugues Make PHPCS happy.
Tithugues authored Jul 23, 2015
189 __(
190 'You probably tried to upload a file that is too large. Please refer ' .
191 'to %sdocumentation%s for a workaround for this limit.'
192 )
9727ee2 @ruleant improve message, wrap long line
ruleant authored Sep 3, 2012
193 );
61a601f @nijel Implement linking to new documentation
nijel authored Nov 12, 2012
194 $message->addParam('[doc@faq1-16]');
371d420 @nijel Simplify linking to documentation
nijel authored Sep 5, 2012
195 $message->addParam('[/doc]');
60536d7 @lem9 patch #2798592 [import] Progress bar
lem9 authored Jul 2, 2009
196
197 // so we can obtain the message
198 $_SESSION['Import_message']['message'] = $message->getDisplay();
6053814 @lem9 Clarify variable's origin
lem9 authored Jul 25, 2014
199 $_SESSION['Import_message']['go_back_url'] = $GLOBALS['goto'];
60536d7 @lem9 patch #2798592 [import] Progress bar
lem9 authored Jul 2, 2009
200
0f18e49 make use of PMA_Message
Sebastian Mendel authored Oct 17, 2007
201 $message->display();
eb98110 @roccivic Dropped footer.inc.php
roccivic authored Jun 2, 2012
202 exit; // the footer is displayed automatically
f4a8faf @nijel Try to detect that upload failed because of limits (RFE #1240480).
nijel authored Oct 8, 2005
203 }
204
fb14e92 @WhaleWatching PMA console, history and bookmarks.
WhaleWatching authored Jun 16, 2014
205 // Add console message id to response output
a995e28 @ZweiSteinSoft Fix coding style in import.php
ZweiSteinSoft authored Jul 2, 2014
206 if (isset($_POST['console_message_id'])) {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
207 $response = PMA\libraries\Response::getInstance();
fb14e92 @WhaleWatching PMA console, history and bookmarks.
WhaleWatching authored Jun 16, 2014
208 $response->addJSON('console_message_id', $_POST['console_message_id']);
209 }
210
0326405 Don't rely on grab_globals for import.php
Jo Michael authored Mar 16, 2012
211 /**
212 * Sets globals from $_POST patterns, for import plugins
213 * We only need to load the selected plugin
214 */
215
0124642 @lem9 [security] Global variables scope injection vulnerability (see PMASA-…
lem9 authored Jun 28, 2013
216 if (! in_array(
80e6ecc @nijel Merge commit '5d590ef3d67b4f87b58dbda50e86519bf9b64d34'
nijel authored Jul 29, 2013
217 $format,
0124642 @lem9 [security] Global variables scope injection vulnerability (see PMASA-…
lem9 authored Jun 28, 2013
218 array(
219 'csv',
220 'ldi',
221 'mediawiki',
222 'ods',
223 'shp',
224 'sql',
225 'xml'
226 )
227 )
228 ) {
229 // this should not happen for a normal user
230 // but only during an attack
231 PMA_fatalError('Incorrect format parameter');
232 }
233
0326405 Don't rely on grab_globals for import.php
Jo Michael authored Mar 16, 2012
234 $post_patterns = array(
235 '/^force_file_/',
6335b10 @madhuracj Fix coding style
madhuracj authored Jan 8, 2014
236 '/^' . $format . '_/'
0326405 Don't rely on grab_globals for import.php
Jo Michael authored Mar 16, 2012
237 );
8a3bf5a @lem9 Refactor code duplication
lem9 authored Oct 20, 2014
238
239 PMA_setPostAsGlobal($post_patterns);
0326405 Don't rely on grab_globals for import.php
Jo Michael authored Mar 16, 2012
240
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
241 // Check needed parameters
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
242 PMA\libraries\Util::checkParameters(array('import_type', 'format'));
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
243
3e79c53 @nijel Generic plugin infrastructure and use it in import (needed for RFE#13…
nijel authored Dec 8, 2005
244 // We don't want anything special in format
245 $format = PMA_securePath($format);
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
246
247 // Create error and goto url
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
248 if ($import_type == 'table') {
0b64827 @007durgesh219 Refactored url parmeters generating, Issue #11990
007durgesh219 authored Feb 19, 2016
249 $err_url = 'tbl_import.php' . URL::getCommon(
037a034 @Tithugues Minor coding style modifications.
Tithugues authored Nov 2, 2014
250 array(
251 'db' => $db, 'table' => $table
252 )
253 );
60536d7 @lem9 patch #2798592 [import] Progress bar
lem9 authored Jul 2, 2009
254 $_SESSION['Import_message']['go_back_url'] = $err_url;
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
255 $goto = 'tbl_import.php';
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
256 } elseif ($import_type == 'database') {
0b64827 @007durgesh219 Refactored url parmeters generating, Issue #11990
007durgesh219 authored Feb 19, 2016
257 $err_url = 'db_import.php' . URL::getCommon(array('db' => $db));
60536d7 @lem9 patch #2798592 [import] Progress bar
lem9 authored Jul 2, 2009
258 $_SESSION['Import_message']['go_back_url'] = $err_url;
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
259 $goto = 'db_import.php';
260 } elseif ($import_type == 'server') {
0b64827 @007durgesh219 Refactored url parmeters generating, Issue #11990
007durgesh219 authored Feb 19, 2016
261 $err_url = 'server_import.php' . URL::getCommon();
60536d7 @lem9 patch #2798592 [import] Progress bar
lem9 authored Jul 2, 2009
262 $_SESSION['Import_message']['go_back_url'] = $err_url;
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
263 $goto = 'server_import.php';
264 } else {
265 if (empty($goto) || !preg_match('@^(server|db|tbl)(_[a-z]*)*\.php$@i', $goto)) {
55b317c @nijel Remove /*overload*/ prefix from mb_* calls
nijel authored Dec 21, 2015
266 if (mb_strlen($table) && mb_strlen($db)) {
ad06b4a @nijel Rename tbl_* files to drop useless _properties part.
nijel authored Oct 25, 2006
267 $goto = 'tbl_structure.php';
55b317c @nijel Remove /*overload*/ prefix from mb_* calls
nijel authored Dec 21, 2015
268 } elseif (mb_strlen($db)) {
cac4247 @nijel Rename db_* files to drop useless _details part.
nijel authored Oct 25, 2006
269 $goto = 'db_structure.php';
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
270 } else {
271 $goto = 'server_sql.php';
272 }
273 }
55b317c @nijel Remove /*overload*/ prefix from mb_* calls
nijel authored Dec 21, 2015
274 if (mb_strlen($table) && mb_strlen($db)) {
0b64827 @007durgesh219 Refactored url parmeters generating, Issue #11990
007durgesh219 authored Feb 19, 2016
275 $common = URL::getCommon(array('db' => $db, 'table' => $table));
55b317c @nijel Remove /*overload*/ prefix from mb_* calls
nijel authored Dec 21, 2015
276 } elseif (mb_strlen($db)) {
0b64827 @007durgesh219 Refactored url parmeters generating, Issue #11990
007durgesh219 authored Feb 19, 2016
277 $common = URL::getCommon(array('db' => $db));
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
278 } else {
0b64827 @007durgesh219 Refactored url parmeters generating, Issue #11990
007durgesh219 authored Feb 19, 2016
279 $common = URL::getCommon();
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
280 }
b1a7039 @ZweiSteinSoft Convert PMA_URL_getCommon calls to new style
ZweiSteinSoft authored Oct 17, 2014
281 $err_url = $goto . $common
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
282 . (preg_match('@^tbl_[a-z]*\.php$@', $goto)
283 ? '&amp;table=' . htmlspecialchars($table)
284 : '');
60536d7 @lem9 patch #2798592 [import] Progress bar
lem9 authored Jul 2, 2009
285 $_SESSION['Import_message']['go_back_url'] = $err_url;
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
286 }
2e76e83 @zixtor Fix bug 4483/4440: selflink was disappearing in certain cases
zixtor authored Jul 8, 2014
287 // Avoid setting selflink to 'import.php'
288 // problem similar to bug 4276
289 if (basename($_SERVER['SCRIPT_NAME']) === 'import.php') {
290 $_SERVER['SCRIPT_NAME'] = $goto;
291 }
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
292
293
55b317c @nijel Remove /*overload*/ prefix from mb_* calls
nijel authored Dec 21, 2015
294 if (mb_strlen($db)) {
650a8cd @madhuracj Convert database interface to a class
madhuracj authored May 24, 2013
295 $GLOBALS['dbi']->selectDb($db);
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
296 }
297
298 @set_time_limit($cfg['ExecTimeLimit']);
621280e @alexukf remove spaces around the not operator
alexukf authored Apr 20, 2012
299 if (! empty($cfg['MemoryLimit'])) {
8c6b399 @nijel Configurable memory limit (RFE #1373904).
nijel authored Dec 16, 2005
300 @ini_set('memory_limit', $cfg['MemoryLimit']);
301 }
302
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
303 $timestamp = time();
89158e9 @madhuracj Use request data directly for 'allow_interrupt'
madhuracj authored Nov 14, 2014
304 if (isset($_REQUEST['allow_interrupt'])) {
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
305 $maximum_time = ini_get('max_execution_time');
306 } else {
307 $maximum_time = 0;
308 }
309
310 // set default values
3cf4830 @nijel Replace TRUE/FALSE with true/false.
nijel authored Jun 6, 2011
311 $timeout_passed = false;
312 $error = false;
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
313 $read_multiply = 1;
3cf4830 @nijel Replace TRUE/FALSE with true/false.
nijel authored Jun 6, 2011
314 $finished = false;
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
315 $offset = 0;
316 $max_sql_len = 0;
317 $file_to_unlink = '';
318 $sql_query = '';
3cf4830 @nijel Replace TRUE/FALSE with true/false.
nijel authored Jun 6, 2011
319 $sql_query_disabled = false;
320 $go_sql = false;
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
321 $executed_queries = 0;
3cf4830 @nijel Replace TRUE/FALSE with true/false.
nijel authored Jun 6, 2011
322 $run_query = true;
323 $charset_conversion = false;
324 $reset_charset = false;
325 $bookmark_created = false;
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
326
327 // Bookmark Support: get a query back from bookmark if required
f9248d3 @madhuracj Use request params directly, 'id_bookmark'
madhuracj authored Nov 14, 2014
328 if (! empty($_REQUEST['id_bookmark'])) {
329 $id_bookmark = (int)$_REQUEST['id_bookmark'];
303dfd7 @madhuracj User request params directly, 'action_bookimark'
madhuracj authored Nov 14, 2014
330 switch ($_REQUEST['action_bookmark']) {
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
331 case 0: // bookmarked query that have to be run
43cfba9 @madhuracj Refactor bookmarking
madhuracj authored Mar 9, 2016
332 $bookmark = Bookmark::get(
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
333 $db,
334 $id_bookmark,
335 'id',
83a4a2d @madhuracj action_bookmark_all was never added to GLOBALS, use from REQUEST dire…
madhuracj authored Nov 14, 2014
336 isset($_REQUEST['action_bookmark_all'])
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
337 );
b55ddd0 @madhuracj Use as non-static methods
madhuracj authored Mar 10, 2016
338
fc340c3 @madhuracj Use variable 'bookmark_variable' directly from REQUEST
madhuracj authored Nov 14, 2014
339 if (! empty($_REQUEST['bookmark_variable'])) {
5c4c0c2 @madhuracj Pass bookmark variables as method parameters
madhuracj authored Mar 10, 2016
340 $import_text = $bookmark->applyVariables(
341 $_REQUEST['bookmark_variable']
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
342 );
b55ddd0 @madhuracj Use as non-static methods
madhuracj authored Mar 9, 2016
343 } else {
344 $import_text = $bookmark->getQuery();
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
345 }
bfec931 @nijel Improve functionality of limiting DROP DATABASE (bug #1456082).
nijel authored Apr 27, 2006
346
f3aa2a3 @zixtor Fix bug 3842: create, alter, drop queries were not shown after execution
zixtor authored Mar 21, 2013
347 // refresh navigation and main panels
9b78827 @lem9 Fix coding style
lem9 authored Oct 28, 2013
348 if (preg_match(
349 '/^(DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
350 $import_text
351 )) {
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
352 $GLOBALS['reload'] = true;
6439a10 @madhuracj bug #4872 Drop table doesn't remove the table name from navigation bar
madhuracj authored May 29, 2015
353 $ajax_reload['reload'] = true;
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
354 }
bfec931 @nijel Improve functionality of limiting DROP DATABASE (bug #1456082).
nijel authored Apr 27, 2006
355
f3aa2a3 @zixtor Fix bug 3842: create, alter, drop queries were not shown after execution
zixtor authored Mar 21, 2013
356 // refresh navigation panel only
9b78827 @lem9 Fix coding style
lem9 authored Oct 28, 2013
357 if (preg_match(
358 '/^(CREATE|ALTER)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i',
359 $import_text
360 )
361 ) {
f3aa2a3 @zixtor Fix bug 3842: create, alter, drop queries were not shown after execution
zixtor authored Mar 21, 2013
362 $ajax_reload['reload'] = true;
363 }
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
364 break;
365 case 1: // bookmarked query that have to be displayed
43cfba9 @madhuracj Refactor bookmarking
madhuracj authored Mar 9, 2016
366 $bookmark = Bookmark::get($db, $id_bookmark);
367 $import_text = $bookmark->getQuery();
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
368 if ($GLOBALS['is_ajax_request'] == true) {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
369 $message = PMA\libraries\Message::success(__('Showing bookmark'));
370 $response = PMA\libraries\Response::getInstance();
fd7c852 @lem9 Clarify method name
lem9 authored Oct 3, 2015
371 $response->setRequestStatus($message->isSuccess());
a16e723 @roccivic Dropped PMA_ajaxResponse()
roccivic authored Jun 11, 2012
372 $response->addJSON('message', $message);
373 $response->addJSON('sql_query', $import_text);
303dfd7 @madhuracj User request params directly, 'action_bookimark'
madhuracj authored Nov 14, 2014
374 $response->addJSON('action_bookmark', $_REQUEST['action_bookmark']);
a16e723 @roccivic Dropped PMA_ajaxResponse()
roccivic authored Jun 11, 2012
375 exit;
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
376 } else {
377 $run_query = false;
378 }
379 break;
380 case 2: // bookmarked query that have to be deleted
43cfba9 @madhuracj Refactor bookmarking
madhuracj authored Mar 9, 2016
381 $bookmark = Bookmark::get($db, $id_bookmark);
382 if (! empty($bookmark)) {
383 $bookmark->delete();
384 if ($GLOBALS['is_ajax_request'] == true) {
385 $message = PMA\libraries\Message::success(
386 __('The bookmark has been deleted.')
387 );
388 $response = PMA\libraries\Response::getInstance();
389 $response->setRequestStatus($message->isSuccess());
390 $response->addJSON('message', $message);
391 $response->addJSON('action_bookmark', $_REQUEST['action_bookmark']);
392 $response->addJSON('id_bookmark', $id_bookmark);
393 exit;
394 } else {
395 $run_query = false;
396 $error = true; // this is kind of hack to skip processing the query
397 }
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
398 }
43cfba9 @madhuracj Refactor bookmarking
madhuracj authored Mar 9, 2016
399
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
400 break;
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
401 }
402 } // end bookmarks reading
403
fb9a3a5 @nijel Check before commit!
nijel authored Nov 17, 2006
404 // Do no run query if we show PHP code
405 if (isset($GLOBALS['show_as_php'])) {
3cf4830 @nijel Replace TRUE/FALSE with true/false.
nijel authored Jun 6, 2011
406 $run_query = false;
407 $go_sql = true;
fb9a3a5 @nijel Check before commit!
nijel authored Nov 17, 2006
408 }
409
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
410 // We can not read all at once, otherwise we can run out of memory
411 $memory_limit = trim(@ini_get('memory_limit'));
412 // 2 MB as default
3bac98e @nijel Work on 10MB chunks if no memory limit is set (bug #1399477).
nijel authored Jan 9, 2006
413 if (empty($memory_limit)) {
414 $memory_limit = 2 * 1024 * 1024;
415 }
416 // In case no memory limit we work on 10MB chunks
966549e @lem9 bug #2222230 [import] Assigning a value in import.php
lem9 authored Nov 4, 2008
417 if ($memory_limit == -1) {
3bac98e @nijel Work on 10MB chunks if no memory limit is set (bug #1399477).
nijel authored Jan 9, 2006
418 $memory_limit = 10 * 1024 * 1024;
419 }
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
420
421 // Calculate value of the limit
55b317c @nijel Remove /*overload*/ prefix from mb_* calls
nijel authored Dec 21, 2015
422 $memoryUnit = mb_strtolower(substr($memory_limit, -1));
49ababa @Tithugues Replace mb functions by standard string functions.
Tithugues authored Oct 4, 2014
423 if ('m' == $memoryUnit) {
424 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024;
425 } elseif ('k' == $memoryUnit) {
426 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024;
427 } elseif ('g' == $memoryUnit) {
428 $memory_limit = (int)substr($memory_limit, 0, -1) * 1024 * 1024 * 1024;
0ae8842 (not complete) PEAR coding standard
Sebastian Mendel authored Jan 17, 2006
429 } else {
430 $memory_limit = (int)$memory_limit;
431 }
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
432
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
433 // Just to be sure, there might be lot of memory needed for uncompression
434 $read_limit = $memory_limit / 8;
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
435
436 // handle filenames
69e1b68 @lem9 No longer globalize $_FILES
lem9 authored Feb 26, 2012
437 if (isset($_FILES['import_file'])) {
438 $import_file = $_FILES['import_file']['tmp_name'];
439 }
621280e @alexukf remove spaces around the not operator
alexukf authored Apr 20, 2012
440 if (! empty($local_import_file) && ! empty($cfg['UploadDir'])) {
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
441
442 // sanitize $local_import_file as it comes from a POST
443 $local_import_file = PMA_securePath($local_import_file);
444
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
445 $import_file = PMA\libraries\Util::userDir($cfg['UploadDir'])
7664661 @Chanaka Implement class behavior of common.lib.php file
Chanaka authored Jun 22, 2012
446 . $local_import_file;
7e169fc @madhuracj Coding style improvements
madhuracj authored Aug 31, 2012
447
621280e @alexukf remove spaces around the not operator
alexukf authored Apr 20, 2012
448 } elseif (empty($import_file) || ! is_uploaded_file($import_file)) {
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
449 $import_file = 'none';
450 }
451
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
452 // Do we have file to import?
60536d7 @lem9 patch #2798592 [import] Progress bar
lem9 authored Jul 2, 2009
453
621280e @alexukf remove spaces around the not operator
alexukf authored Apr 20, 2012
454 if ($import_file != 'none' && ! $error) {
9e83516 @lem9 bug #2033962 [import] Cannot import zip file
lem9 authored Aug 9, 2008
455 /**
456 * Handle file compression
457 */
b54e5b0 @nijel Use File class for file imports
nijel authored Apr 11, 2016
458 $import_handle = new File($import_file);
459 $import_handle->checkUploadedFile();
f90ca55 @nijel Add missing error check
nijel authored Apr 11, 2016
460 if ($import_handle->isError()) {
461 PMA_stopImport($import_handle->getError());
462 }
b54e5b0 @nijel Use File class for file imports
nijel authored Apr 11, 2016
463 $import_handle->setDecompressContent(true);
464 $import_handle->open();
465 if ($import_handle->isError()) {
466 PMA_stopImport($import_handle->getError());
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
467 }
621280e @alexukf remove spaces around the not operator
alexukf authored Apr 20, 2012
468 } elseif (! $error) {
13b3195 @lem9 For easier reading, replace "!isset" with "! isset"
lem9 authored May 9, 2011
469 if (! isset($import_text) || empty($import_text)) {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
470 $message = PMA\libraries\Message::error(
bf61709 @Tithugues Make PHPCS happy.
Tithugues authored Jul 23, 2015
471 __(
472 'No data was received to import. Either no file name was ' .
473 'submitted, or the file size exceeded the maximum size permitted ' .
474 'by your PHP configuration. See [doc@faq1-16]FAQ 1.16[/doc].'
475 )
2095bc3 @madhuracj Wrap some long lines
madhuracj authored Sep 5, 2012
476 );
f78e1a2 @lem9 Move function to library and rename it
lem9 authored Feb 22, 2014
477 PMA_stopImport($message);
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
478 }
479 }
480
60536d7 @lem9 patch #2798592 [import] Progress bar
lem9 authored Jul 2, 2009
481 // so we can obtain the message
482 //$_SESSION['Import_message'] = $message->getDisplay();
483
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
484 // Convert the file's charset if necessary
28d15eb @nijel Add method for checking if encoding conversion is supported
nijel authored Mar 8, 2016
485 if (Encoding::isSupported() && isset($charset_of_file)) {
8f54092 @nijel Remove forgotten references to $charset
nijel authored Jun 3, 2011
486 if ($charset_of_file != 'utf-8') {
3cf4830 @nijel Replace TRUE/FALSE with true/false.
nijel authored Jun 6, 2011
487 $charset_conversion = true;
3e79c53 @nijel Generic plugin infrastructure and use it in import (needed for RFE#13…
nijel authored Dec 8, 2005
488 }
fbe587c @madhuracj bug #4661 Drag and drop file import always fails
madhuracj authored Dec 22, 2014
489 } elseif (isset($charset_of_file) && $charset_of_file != 'utf-8') {
7fadb9e @madhuracj Remove Drizzle support from import and export
madhuracj authored Sep 4, 2015
490 $GLOBALS['dbi']->query('SET NAMES \'' . $charset_of_file . '\'');
491 // We can not show query in this case, it is in different charset
492 $sql_query_disabled = true;
493 $reset_charset = true;
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
494 }
495
da4bcee @lem9 Directly use the POST parameter
lem9 authored Jul 29, 2015
496 // Something to skip? (because timeout has passed)
497 if (! $error && isset($_POST['skip'])) {
498 $original_skip = $skip = $_POST['skip'];
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
499 while ($skip > 0) {
500 PMA_importGetNextChunk($skip < $read_limit ? $skip : $read_limit);
3b89a46 @lem9 Fix typos
lem9 authored Jan 11, 2014
501 // Disable read progressivity, otherwise we eat all memory!
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
502 $read_multiply = 1;
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
503 $skip -= $read_limit;
504 }
505 unset($skip);
506 }
507
d5acfed @Chanaka Multiple results support for SQL executions
Chanaka authored Jul 20, 2012
508 // This array contain the data like numberof valid sql queries in the statement
509 // and complete valid sql statement (which affected for rows)
510 $sql_data = array('valid_sql' => array(), 'valid_queries' => 0);
511
621280e @alexukf remove spaces around the not operator
alexukf authored Apr 20, 2012
512 if (! $error) {
9b77d74 @Tithugues Mass modifications to use PMA_String.
Tithugues authored Aug 15, 2014
513 // Check for file existence
623de27 @ruleant use include(_once) in case of conditional including
ruleant authored Aug 30, 2012
514 include_once "libraries/plugin_interface.lib.php";
a3c3c57 @madhuracj Use type hinting
madhuracj authored Jun 18, 2015
515 /* @var $import_plugin ImportPlugin */
a87f283 @alexukf plugins and OOP: create general class structure and ExportXML
alexukf authored May 10, 2012
516 $import_plugin = PMA_getPlugin(
517 "import",
518 $format,
06655bf @kasunchathuranga Fix bug #3879 Import broken for CSV using LOAD DATA
kasunchathuranga authored Apr 17, 2013
519 'libraries/plugins/import/',
520 $import_type
a87f283 @alexukf plugins and OOP: create general class structure and ExportXML
alexukf authored May 10, 2012
521 );
522 if ($import_plugin == null) {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
523 $message = PMA\libraries\Message::error(
a87f283 @alexukf plugins and OOP: create general class structure and ExportXML
alexukf authored May 10, 2012
524 __('Could not load import plugins, please check your installation!')
525 );
f78e1a2 @lem9 Move function to library and rename it
lem9 authored Feb 22, 2014
526 PMA_stopImport($message);
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
527 } else {
528 // Do the real import
34720c2 @nisargjhaveri Disable foreign key checks in SQL query box and config option
nisargjhaveri authored May 30, 2015
529 try {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
530 $default_fk_check = PMA\libraries\Util::handleDisableFKCheckInit();
6e1b2aa @udan11 Fix #11340.
udan11 authored Aug 2, 2015
531 $import_plugin->doImport($sql_data);
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
532 PMA\libraries\Util::handleDisableFKCheckCleanup($default_fk_check);
34720c2 @nisargjhaveri Disable foreign key checks in SQL query box and config option
nisargjhaveri authored May 30, 2015
533 } catch (Exception $e) {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
534 PMA\libraries\Util::handleDisableFKCheckCleanup($default_fk_check);
34720c2 @nisargjhaveri Disable foreign key checks in SQL query box and config option
nisargjhaveri authored May 30, 2015
535 throw $e;
df38a76 @madhuracj rfe #1306 Add lock tables, disable keys options
madhuracj authored Mar 11, 2015
536 }
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
537 }
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
538 }
539
b54e5b0 @nijel Use File class for file imports
nijel authored Apr 11, 2016
540 if (isset($import_handle)) {
541 $import_handle->close();
415071a @lem9 correct fix for bug 2143882
lem9 authored Oct 9, 2008
542 }
543
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
544 // Cleanup temporary file
545 if ($file_to_unlink != '') {
546 unlink($file_to_unlink);
547 }
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
548
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
549 // Reset charset back, if we did some changes
550 if ($reset_charset) {
650a8cd @madhuracj Convert database interface to a class
madhuracj authored May 24, 2013
551 $GLOBALS['dbi']->query('SET CHARACTER SET utf8');
552 $GLOBALS['dbi']->query(
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
553 'SET SESSION collation_connection =\'' . $collation_connection . '\''
554 );
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
555 }
556
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
557 // Show correct message
303dfd7 @madhuracj User request params directly, 'action_bookimark'
madhuracj authored Nov 14, 2014
558 if (! empty($id_bookmark) && $_REQUEST['action_bookmark'] == 2) {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
559 $message = PMA\libraries\Message::success(__('The bookmark has been deleted.'));
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
560 $display_query = $import_text;
3cf4830 @nijel Replace TRUE/FALSE with true/false.
nijel authored Jun 6, 2011
561 $error = false; // unset error marker, it was used just to skip processing
303dfd7 @madhuracj User request params directly, 'action_bookimark'
madhuracj authored Nov 14, 2014
562 } elseif (! empty($id_bookmark) && $_REQUEST['action_bookmark'] == 1) {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
563 $message = PMA\libraries\Message::notice(__('Showing bookmark'));
3249698 @nijel Show message when bookmark has been created (RFE #477472), show delet…
nijel authored Oct 9, 2005
564 } elseif ($bookmark_created) {
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
565 $special_message = '[br]' . sprintf(
9d17a60 @nijel Better messasge after creating a bookmark
nijel authored Feb 2, 2014
566 __('Bookmark %s has been created.'),
1c416c1 @lem9 Directly use the POST parameter
lem9 authored Jul 31, 2015
567 htmlspecialchars($_POST['bkm_label'])
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
568 );
621280e @alexukf remove spaces around the not operator
alexukf authored Apr 20, 2012
569 } elseif ($finished && ! $error) {
c60f973 @nijel Avoiud displaying query without message
nijel authored Feb 17, 2016
570 // Do not display the query with message, we do it separately
571 $display_query = ';';
8bf212f @nijel Avoid displaying import query twice
nijel authored Feb 17, 2016
572 if ($import_type != 'query') {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
573 $message = PMA\libraries\Message::success(
addebbe @nijel Avoid code duplication
nijel authored Feb 5, 2014
574 '<em>'
0a2facd @nijel Properly use plural for message with number of queries
nijel authored Feb 17, 2016
575 . _ngettext(
576 'Import has been successfully finished, %d query executed.',
577 'Import has been successfully finished, %d queries executed.',
578 $executed_queries
579 )
addebbe @nijel Avoid code duplication
nijel authored Feb 5, 2014
580 . '</em>'
581 );
582 $message->addParam($executed_queries);
78b0082 @nijel [core] Updated mootools to fix some glitches with Safari.
nijel authored Jan 4, 2010
583
addebbe @nijel Avoid code duplication
nijel authored Feb 5, 2014
584 if ($import_notice) {
15441de @lem9 do not try to display a tab that was not built
lem9 authored Aug 22, 2009
585 $message->addString($import_notice);
addebbe @nijel Avoid code duplication
nijel authored Feb 5, 2014
586 }
c080382 @lem9 Fixes #11380 Incomplete message after import
lem9 authored Aug 10, 2015
587 if (! empty($local_import_file)) {
968d5d5 @nijel Sanitize filename in import message
nijel authored Feb 5, 2014
588 $message->addString('(' . htmlspecialchars($local_import_file) . ')');
15441de @lem9 do not try to display a tab that was not built
lem9 authored Aug 22, 2009
589 } else {
bbeacf8 @lem9 Fix coding style
lem9 authored Feb 22, 2014
590 $message->addString(
591 '(' . htmlspecialchars($_FILES['import_file']['name']) . ')'
592 );
15441de @lem9 do not try to display a tab that was not built
lem9 authored Aug 22, 2009
593 }
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
594 }
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
595 }
596
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
597 // Did we hit timeout? Tell it user.
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
598 if ($timeout_passed) {
bf61709 @Tithugues Make PHPCS happy.
Tithugues authored Jul 23, 2015
599 $importUrl = $err_url .= '&timeout_passed=1&offset=' . urlencode(
9cbfa30 @Tithugues Make PHPCS happy.
Tithugues authored Jul 23, 2015
600 $GLOBALS['offset']
601 );
f6dd7c2 @madhuracj Pass local_import_file
madhuracj authored Mar 30, 2015
602 if (isset($local_import_file)) {
603 $importUrl .= '&local_import_file=' . urlencode($local_import_file);
604 }
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
605 $message = PMA\libraries\Message::error(
52e0087 @madhuracj Long messages wrapped
madhuracj authored Nov 11, 2014
606 __(
607 'Script timeout passed, if you want to finish import,'
0d94439 @lem9 Improve a message
lem9 authored Mar 30, 2015
608 . ' please %sresubmit the same file%s and import will resume.'
52e0087 @madhuracj Long messages wrapped
madhuracj authored Nov 11, 2014
609 )
2095bc3 @madhuracj Wrap some long lines
madhuracj authored Sep 5, 2012
610 );
4c0b0f9 @madhuracj bug #4821 Timed-out import fails to restart when file represented
madhuracj authored Mar 30, 2015
611 $message->addParam('<a href="' . $importUrl . '">', false);
612 $message->addParam('</a>', false);
613
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
614 if ($offset == 0 || (isset($original_skip) && $original_skip == $offset)) {
2095bc3 @madhuracj Wrap some long lines
madhuracj authored Sep 5, 2012
615 $message->addString(
52e0087 @madhuracj Long messages wrapped
madhuracj authored Nov 11, 2014
616 __(
617 'However on last run no data has been parsed,'
618 . ' this usually means phpMyAdmin won\'t be able to'
619 . ' finish this import unless you increase php time limits.'
620 )
2095bc3 @madhuracj Wrap some long lines
madhuracj authored Sep 5, 2012
621 );
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
622 }
623 }
624
6f9253b @madhuracj Various coding style improvements
madhuracj authored Jun 3, 2012
625 // if there is any message, copy it into $_SESSION as well,
626 // so we can obtain it by AJAX call
60536d7 @lem9 patch #2798592 [import] Progress bar
lem9 authored Jul 2, 2009
627 if (isset($message)) {
15441de @lem9 do not try to display a tab that was not built
lem9 authored Aug 22, 2009
628 $_SESSION['Import_message']['message'] = $message->getDisplay();
60536d7 @lem9 patch #2798592 [import] Progress bar
lem9 authored Jul 2, 2009
629 }
817e790 synced/fixed vim line
Sebastian Mendel authored Mar 19, 2007
630 // Parse and analyze the query, for correct db and table name
5e0722a @lem9 bug #1533945, wrong table name in header (SELECT from query window)
lem9 authored Aug 11, 2006
631 // in case of a query typed in the query window
bc77225 @lem9 bug #2941101 import timeout when table already created and several da…
lem9 authored Jan 31, 2010
632 // (but if the query is too large, in case of an imported file, the parser
633 // can choke on it so avoid parsing)
55b317c @nijel Remove /*overload*/ prefix from mb_* calls
nijel authored Dec 21, 2015
634 $sqlLength = mb_strlen($sql_query);
80ced5f @Tithugues Fix PHPCS issues.
Tithugues authored Oct 30, 2014
635 if ($sqlLength <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
faaec8e @lem9 Refactor high-level parser calling into a function
lem9 authored Oct 22, 2015
636 include_once 'libraries/parse_analyze.lib.php';
637
638 list(
639 $analyzed_sql_results,
640 $db,
641 $table
642 ) = PMA_parseAnalyze($sql_query, $db);
643 // @todo: possibly refactor
644 extract($analyzed_sql_results);
bc77225 @lem9 bug #2941101 import timeout when table already created and several da…
lem9 authored Jan 31, 2010
645 }
5e0722a @lem9 bug #1533945, wrong table name in header (SELECT from query window)
lem9 authored Aug 11, 2006
646
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
647 // There was an error?
648 if (isset($my_die)) {
466a764 @madhuracj PHP keywords must be lowercase
madhuracj authored Apr 12, 2013
649 foreach ($my_die as $key => $die) {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
650 PMA\libraries\Util::mysqlDie(
2dfdf47 @Chanaka Fixed documentation issue related to argument type mismatching, raise…
Chanaka authored May 17, 2014
651 $die['error'], $die['sql'], false, $err_url, $error
7e169fc @madhuracj Coding style improvements
madhuracj authored Aug 30, 2012
652 );
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
653 }
654 }
655
656 if ($go_sql) {
80e6ecc @nijel Merge commit '5d590ef3d67b4f87b58dbda50e86519bf9b64d34'
nijel authored Jul 29, 2013
657
2352809 @madhuracj Use query execution and results display mechanism multiple time for m…
madhuracj authored Nov 12, 2014
658 if (! empty($sql_data) && ($sql_data['valid_queries'] > 1)) {
659 $_SESSION['is_multi_query'] = true;
660 $sql_queries = $sql_data['valid_sql'];
661 } else {
662 $sql_queries = array($sql_query);
663 }
664
665 $html_output = '';
666 foreach ($sql_queries as $sql_query) {
faaec8e @lem9 Refactor high-level parser calling into a function
lem9 authored Oct 22, 2015
667
2352809 @madhuracj Use query execution and results display mechanism multiple time for m…
madhuracj authored Nov 12, 2014
668 // parse sql query
faaec8e @lem9 Refactor high-level parser calling into a function
lem9 authored Oct 22, 2015
669 include_once 'libraries/parse_analyze.lib.php';
670 list(
671 $analyzed_sql_results,
672 $db,
673 $table
674 ) = PMA_parseAnalyze($sql_query, $db);
675 // @todo: possibly refactor
676 extract($analyzed_sql_results);
2352809 @madhuracj Use query execution and results display mechanism multiple time for m…
madhuracj authored Nov 12, 2014
677
678 $html_output .= PMA_executeQueryAndGetQueryResponse(
f7689d5 @udan11 Replaced more of the old parser.
udan11 authored Jun 27, 2015
679 $analyzed_sql_results, // analyzed_sql_results
680 false, // is_gotofile
681 $db, // db
682 $table, // table
683 null, // find_real_end
ff967d9 @madhuracj Fix #11814 SQL comment and variable stripped from bookmark on save
madhuracj authored Jan 15, 2016
684 $_REQUEST['sql_query'], // sql_query_for_bookmark
f7689d5 @udan11 Replaced more of the old parser.
udan11 authored Jun 27, 2015
685 null, // extra_data
686 null, // message_to_show
687 null, // message
688 null, // sql_data
689 $goto, // goto
690 $pmaThemeImage, // pmaThemeImage
691 null, // disp_query
692 null, // disp_message
693 null, // query_type
694 $sql_query, // sql_query
695 null, // selectedTables
696 null // complete_query
2352809 @madhuracj Use query execution and results display mechanism multiple time for m…
madhuracj authored Nov 12, 2014
697 );
698 }
699
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
700 $response = PMA\libraries\Response::getInstance();
eda24da @Tithugues Fix #4593 Manual SELECT doesn't change active table
Tithugues authored Dec 6, 2014
701 $response->addJSON('ajax_reload', $ajax_reload);
2352809 @madhuracj Use query execution and results display mechanism multiple time for m…
madhuracj authored Nov 12, 2014
702 $response->addHTML($html_output);
703 exit();
704
5d590ef @zixtor Fix bug#4006
zixtor authored Jul 29, 2013
705 } else if ($result) {
29fb3c8 @ashutoshdhundhara Bug Fix: #4365 Creating bookmark with multiple queries not working.
ashutoshdhundhara authored Apr 15, 2014
706 // Save a Bookmark with more than one queries (if Bookmark label given).
707 if (! empty($_POST['bkm_label']) && ! empty($import_text)) {
43cfba9 @madhuracj Refactor bookmarking
madhuracj authored Mar 9, 2016
708 $cfgBookmark = Bookmark::getParams();
29fb3c8 @ashutoshdhundhara Bug Fix: #4365 Creating bookmark with multiple queries not working.
ashutoshdhundhara authored Apr 15, 2014
709 PMA_storeTheQueryAsBookmark(
98034ba @nijel Remove $GLOBALS['cfg']['Bookmark'] variable
nijel authored Jun 12, 2014
710 $db, $cfgBookmark['user'],
446d35f @udan11 Bug #4784 Incomplete bookmark saving
udan11 authored Mar 11, 2015
711 $_REQUEST['sql_query'], $_POST['bkm_label'],
29fb3c8 @ashutoshdhundhara Bug Fix: #4365 Creating bookmark with multiple queries not working.
ashutoshdhundhara authored Apr 15, 2014
712 isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null
713 );
714 }
715
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
716 $response = PMA\libraries\Response::getInstance();
fd7c852 @lem9 Clarify method name
lem9 authored Oct 3, 2015
717 $response->setRequestStatus(true);
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
718 $response->addJSON('message', PMA\libraries\Message::success($msg));
cb5e1cb @nijel Various coding style fixes
nijel authored Aug 7, 2013
719 $response->addJSON(
720 'sql_query',
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
721 PMA\libraries\Util::getMessage($msg, $sql_query, 'success')
cb5e1cb @nijel Various coding style fixes
nijel authored Aug 7, 2013
722 );
5d590ef @zixtor Fix bug#4006
zixtor authored Jul 29, 2013
723 } else if ($result == false) {
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
724 $response = PMA\libraries\Response::getInstance();
fd7c852 @lem9 Clarify method name
lem9 authored Oct 3, 2015
725 $response->setRequestStatus(false);
f0ba28f @Tithugues Set namespace on Advisor, Config, Console and Util classes.
Tithugues authored Aug 25, 2015
726 $response->addJSON('message', PMA\libraries\Message::error($msg));
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
727 } else {
6a093d4 @nijel Switch all SQL from read_dump.php to import.php.
nijel authored Oct 8, 2005
728 $active_page = $goto;
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored Mar 16, 2012
729 include '' . $goto;
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
730 }
04d7be1 @ashutoshdhundhara RFE#869: Run SQL query: Allow rollback for InnoDB tables.
ashutoshdhundhara authored Jun 20, 2014
731
732 // If there is request for ROLLBACK in the end.
733 if (isset($_REQUEST['rollback_query'])) {
734 $GLOBALS['dbi']->query('ROLLBACK');
735 }
Something went wrong with that request. Please try again.