Skip to content

Commit

Permalink
Show upload_max_filesize
Browse files Browse the repository at this point in the history
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@841 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information
jakubvrana committed Jul 16, 2009
1 parent 04a3f5b commit e2a03c0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions adminer/include/functions.inc.php
Expand Up @@ -151,6 +151,11 @@ function get_file($key) {
return (!$_FILES[$key] || $_FILES[$key]["error"] ? $_FILES[$key]["error"] : file_get_contents($_FILES[$key]["tmp_name"]));
}

function upload_error($error) {
$max_size = ($error == UPLOAD_ERR_INI_SIZE ? ini_get("upload_max_filesize") : null); // post_max_size is checked in index.php
return lang('Unable to upload a file.') . ($max_size ? " " . lang('Maximum allowed file size is %sB.', $max_size) : "");
}

function odd($s = ' class="odd"') {
static $i = 0;
if (!$s) { // reset counter
Expand Down
1 change: 1 addition & 0 deletions adminer/lang/cs.inc.php
Expand Up @@ -228,4 +228,5 @@
'Binary' => 'Binární',
'Lists' => 'Seznamy',
'Relations' => 'Vztahy',
'Maximum allowed file size is %sB.' => 'Maximální povolená velikost souboru je %sB.',
);
2 changes: 1 addition & 1 deletion adminer/select.inc.php
Expand Up @@ -166,7 +166,7 @@
$result = queries("INSERT INTO " . idf_escape($_GET["select"]) . "$cols VALUES" . implode(",", $rows));
query_redirect(queries(), remove_from_uri("page"), lang('%d row(s) has been imported.', $dbh->affected_rows), $result, false, !$result);
} else {
$error = lang('Unable to upload a file.');
$error = upload_error($file);
}
}

Expand Down
5 changes: 3 additions & 2 deletions adminer/sql.inc.php
Expand Up @@ -3,7 +3,8 @@
$history = &$_SESSION["history"][$_GET["server"]][$_GET["db"]];

if (!$error && $_POST) {
if (is_string($query = (isset($_POST["file"]) ? get_file("sql_file") : $_POST["query"]))) { // get_file() returns error as number
$query = (isset($_POST["file"]) ? get_file("sql_file") : $_POST["query"]);
if (is_string($query)) { // get_file() returns error as number
@set_time_limit(0); // set_time_limit() can be disabled
$query = str_replace("\r", "", $query); // parser looks for \n
$query = rtrim($query);
Expand Down Expand Up @@ -64,7 +65,7 @@
echo "<p class='message'>" . lang('No commands to execute.') . "\n";
}
} else {
echo "<p class='error'>" . lang('Unable to upload a file.') . "\n";
echo "<p class='error'>" . upload_error($query) . "\n";
}
}
?>
Expand Down

0 comments on commit e2a03c0

Please sign in to comment.