* @return string cryptic string which gets combined with password
*/
function permanentLogin() {
- return "";
+ return password_file();
}
/** Identifier of selected database
</script>
<?php
echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
- if ($this->permanentLogin()) {
- echo checkbox("permanent", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
- }
+ echo checkbox("permanent", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
}
/** Authorize the user
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
<?php
-/** PHP implementation of XXTEA encryption algorithm.
+/** PHP implementation of XXTEA encryption algorithm
* @author Ma Bingyao <andot@ujn.edu.cn>
* @link http://www.coolcode.cn/?action=show&id=128
*/
Adminer 3.0.0-dev:
Drivers for MS SQL, SQLite, PostgreSQL
Allow concurrent logins on the same server
+Allow permanent login without customization
In-place editation in select
Show number of tables in server overview
Operator LIKE %%
return lang('Editor');
}
- //! driver
+ //! driver, ns
function credentials() {
return array(); // default INI settings
}
function permanentLogin() {
- return "";
+ return password_file();
}
function database() {
</script>
<?php
echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
- if ($this->permanentLogin()) {
- echo checkbox("permanent", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
- }
+ echo checkbox("permanent", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
}
function login($login, $password) {