1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

Prevent against brute force login attempts from the same IP address

This commit is contained in:
Jakub Vrana
2014-03-21 22:47:34 -07:00
parent 619b49c3d4
commit 06f4346cfe
9 changed files with 77 additions and 18 deletions

View File

@@ -1034,26 +1034,33 @@ function apply_sql_function($function, $column) {
return ($function ? ($function == "unixepoch" ? "DATETIME($column, '$function')" : ($function == "count distinct" ? "COUNT(DISTINCT " : strtoupper("$function(")) . "$column)") : $column);
}
/** Read password from file adminer.key in temporary directory or create one
* @param bool
* @return string or false if the file can not be created
/** Get path of the temporary directory
* @return string
*/
function password_file($create) {
$dir = ini_get("upload_tmp_dir"); // session_save_path() may contain other storage path
if (!$dir) {
function get_temp_dir() {
$return = ini_get("upload_tmp_dir"); // session_save_path() may contain other storage path
if (!$return) {
if (function_exists('sys_get_temp_dir')) {
$dir = sys_get_temp_dir();
$return = sys_get_temp_dir();
} else {
$filename = @tempnam("", ""); // @ - temp directory can be disabled by open_basedir
if (!$filename) {
return false;
}
$dir = dirname($filename);
$return = dirname($filename);
unlink($filename);
}
}
$filename = "$dir/adminer.key";
$return = @file_get_contents($filename); // @ - can not exist
return $return;
}
/** Read password from file adminer.key in temporary directory or create one
* @param bool
* @return string or false if the file can not be created
*/
function password_file($create) {
$filename = get_temp_dir() . "/adminer.key";
$return = @file_get_contents($filename); // @ - may not exist
if ($return || !$create) {
return $return;
}