/** Get file contents from $_FILES
* @param string
* @param bool
+* @param string
* @return mixed int for error, string otherwise
*/
-function get_file($key, $decompress = false) {
+function get_file($key, $decompress = false, $delimiter = "") {
$file = $_FILES[$key];
if (!$file) {
return null;
); //! may not be reachable because of open_basedir
if ($decompress) {
$start = substr($content, 0, 3);
- if (function_exists("iconv") && preg_match("~^\xFE\xFF|^\xFF\xFE~", $start, $regs)) { // not ternary operator to save memory
+ if (function_exists("iconv") && preg_match("~^\xFE\xFF|^\xFF\xFE~", $start)) { // not ternary operator to save memory
$content = iconv("utf-16", "utf-8", $content);
} elseif ($start == "\xEF\xBB\xBF") { // UTF-8 BOM
$content = substr($content, 3);
}
- $return .= $content . "\n\n";
- } else {
- $return .= $content;
+ }
+ $return .= $content;
+ if ($delimiter) {
+ $return .= (preg_match("($delimiter\\s*\$)", $content) ? "" : $delimiter) . "\n\n";
}
}
- //! support SQL files not ending with semicolon
return $return;
}
), "rb");
$query = ($fp ? fread($fp, 1e6) : false);
} else {
- $query = get_file("sql_file", true);
+ $query = get_file("sql_file", true, ";");
}
if (is_string($query)) { // get_file() returns error as number, fread() as false
Adminer dev:
+Fix importing multiple SQL files not terminated by semicolon
Adminer 5.0.2 (released 2025-03-10):
PostgreSQL: Fix setting NULL and original value on enum (bug #884)