1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-12 01:24:17 +02:00

Respect original memory_limit

This commit is contained in:
Jakub Vrana
2011-08-24 14:16:11 +02:00
parent 2348c4cd4c
commit 9d944c8fc1
3 changed files with 17 additions and 3 deletions

View File

@@ -25,12 +25,12 @@ if (!$error && $_POST) {
: "compress.bzip2://adminer.sql.bz2"
)), "rb");
$query = ($fp ? fread($fp, 1e6) : false);
} elseif ($_FILES && $_FILES["sql_file"]["error"] != 4) { // 4 - UPLOAD_ERR_NO_FILE
} elseif ($_FILES && $_FILES["sql_file"]["error"] != UPLOAD_ERR_NO_FILE) {
$query = get_file("sql_file", true);
}
if (is_string($query)) { // get_file() returns error as number, fread() as false
if (function_exists('memory_get_usage')) {
@ini_set("memory_limit", max(ini_get("memory_limit"), 2 * strlen($query) + memory_get_usage() + 8e6)); // @ - may be disabled, 2 - substr and trim, 8e6 - other variables
@ini_set("memory_limit", max(ini_bytes("memory_limit"), 2 * strlen($query) + memory_get_usage() + 8e6)); // @ - may be disabled, 2 - substr and trim, 8e6 - other variables
}
if ($query != "" && strlen($query) < 1e6) { // don't add big queries
$q = $query . (ereg(';$', $query) ? "" : ";"); //! doesn't work with DELIMITER |