1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-09 16:17:48 +02:00

Allow permanent login without customization

This commit is contained in:
Jakub Vrana
2010-05-06 15:45:34 +02:00
parent 605b09301b
commit 4ba2d85623
5 changed files with 38 additions and 10 deletions

View File

@@ -644,6 +644,37 @@ 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
* @return string or false if the file can not be created
*/
function password_file() {
$dir = ini_get("upload_tmp_dir"); // session_save_path() may contain other storage path
if (!$dir) {
if (function_exists('sys_get_temp_dir')) {
$dir = sys_get_temp_dir();
} else {
$filename = @tempnam("", ""); // @ - temp directory can be disabled by open_basedir
if (!$filename) {
return false;
}
$dir = dirname($filename);
unlink($filename);
}
}
$filename = "$dir/adminer.key";
$return = @file_get_contents($filename); // @ - can not exist
if ($return) {
return $return;
}
$fp = @fopen($filename, "w"); // @ - can have insufficient rights //! is not atomic
if ($fp) {
$return = md5(uniqid(mt_rand(), true));
fwrite($fp, $return);
fclose($fp);
}
return $return;
}
/** Check whether the string is e-mail address
* @param string
* @return bool