Php 基于登录无密码插件如何使用无密码管理员

Php 基于登录无密码插件如何使用无密码管理员,php,adminer,Php,Adminer,我想使用没有密码的管理员 我上传了adminer-4.7.7-en.php文件并找到了登录密码较少的插件 我使用以下内容创建文件plugins/login-password-less.php: <?php /** Enable login for password-less database * @link https://www.adminer.org/plugins/#use * @author Jakub Vrana, https://www.vrana.cz/ * @licens

我想使用没有密码的管理员

我上传了adminer-4.7.7-en.php文件并找到了登录密码较少的插件 我使用以下内容创建文件plugins/login-password-less.php:

<?php

/** Enable login for password-less database
* @link https://www.adminer.org/plugins/#use
* @author Jakub Vrana, https://www.vrana.cz/
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class AdminerLoginPasswordLess {
    /** @access protected */
    var $password_hash;
    
    /** Set allowed password
    * @param string result of password_hash
    */
    function __construct($password_hash) {
        $this->password_hash = $password_hash;
    }

    function credentials() {
        $password = get_password();
        return array(SERVER, $_GET["username"], (password_verify($password, $this->password_hash) ? "" : $password));
    }
    
    function login($login, $password) {
        if ($password != "") {
            return true;
        }
    }

}
<pre>::-2 AdminerLoginPasswordLess->__construct:$this->password_hash::c61d49aaab35ca428e60d764ff05159d</pre>
<pre>::-1After:AdminerLoginPasswordLess</pre>
哪一种是使用无密码adminer的有效方法

已修改: 我提出:

所选的“md5”方法有效吗

但我有一个错误:

Fatal error: Uncaught Error: Class 'AdminerPlugin' not found in /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer.php:32 Stack trace: #0 /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer-4.7.7-en.php(1654): adminer_object() #1 /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer.php(36): include('/mnt/_work_sdb8...') #2 {main} thrown in /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer.php on line 32
已修改: 在站点的源代码版本中,使用AdminerPlugin类实现I foun file plugin.php。 我把这个文件移到了插件目录下。 在plugins/login-password-less.php中,我添加了对plugins/plugin.php文件的引用,并添加了调试信息:

<?php

/** Enable login for password-less database
* @link https://www.adminer.org/plugins/#use
* @author Jakub Vrana, https://www.vrana.cz/
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/

include_once "./plugins/plugin.php";

class AdminerLoginPasswordLess {
    /** @access protected */
    var $password_hash;

    /** Set allowed password
    * @param string result of password_hash
    */
    function __construct($password_hash) {
        $this->password_hash = $password_hash;
        debToFile('-2 AdminerLoginPasswordLess->__construct:$this->password_hash::'.$this->password_hash);
        // That is debugging method appending  string into text file
    }

    function credentials() {
        $password = get_password();
        debToFile('-3 AdminerLoginPasswordLess->credentials:$password::'.$password);
        // That is debugging method appending  string into text file
        return array(SERVER, $_GET["username"], (password_verify($password, $this->password_hash) ? "" : $password));
    }

    function login($login, $password) {
        debToFile('-4 AdminerLoginPasswordLess->login:$login::'.$login);
        if ($password != "") {
            debToFile('-5 TRUE AdminerLoginPasswordLess->login:$login::'.$login);
        // That is debugging method appending  string into text file
            return true;
        }
        debToFile('-5 false AdminerLoginPasswordLess->login:$login::'.$login);
    }

}
我在日志文件中看到:

::-2管理员登录无密码->构造:$this->password\u散列::c61d49aaab35ca428e60d764ff05159d
:-1之后:管理员登录无密码
这意味着不会触发AdminerLoginPasswordLess类的方法凭据和登录。 我在浏览器中运行的身份为:

或 //apache配置中的主机

我没有错误,但我仍然需要输入mysql\u登录用户的密码

我是否错过了一些选项/插件

谢谢

第一件事

mkdir-p插件;
wget-O plugins/plugin.phphttps://raw.githubusercontent.com/vrana/adminer/master/plugins/plugin.php;
nano插件/passwordless_login.php
然后写


如果您可以绕过耗时的小任务,通常可以节省时间。我尝试了上述方法,但对我无效,因此我在2021年为Adminer4.7.9做了以下工作。
警告:请注意,它仅适用于本地计算机,不建议用于在线数据库。
步骤1:从Github下载管理员源代码,点击此处。
步骤2:打开
adminer master\adminer\include\auth.inc.php

步骤3:在第55到57行编辑以下内容,并用MySQL凭据替换my_用户名和my_密码:

步骤4:通过将浏览器指向“Adminer master\Adminer”保存并立即打开Adminer
第五步:只需单击“登录”按钮,即可登录,无需输入任何内容。

希望它对您有用。

请查看修改后的block。如果您可以将文件上载到存储库,它将有所帮助。正如您在这里看到的,在任何插件之前都包含了
/plugins/plugin.php
,您可以通过包含插件文件来改变这一点,您不必这样做,因为您的插件将在下面加载到autoloader
foreach
循环中。谢谢!,看来这有帮助。我有登录页面,我可以提交它没有凭据。是否有管理员会话时间参数/工具?我希望尽可能保持当前会话(包括当前数据库和表打开),即使在第二天关闭/打开浏览之后…@mstdmstd我认为Adminer有类似的功能,但PHP也有,web服务器(nginx、apache、lighthttpd等)有,甚至web浏览器也有。。无论如何,这属于另一个线程^^太好了!谢谢你的帮助!
Fatal error: Uncaught Error: Class 'AdminerPlugin' not found in /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer.php:32 Stack trace: #0 /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer-4.7.7-en.php(1654): adminer_object() #1 /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer.php(36): include('/mnt/_work_sdb8...') #2 {main} thrown in /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer.php on line 32
<?php

/** Enable login for password-less database
* @link https://www.adminer.org/plugins/#use
* @author Jakub Vrana, https://www.vrana.cz/
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/

include_once "./plugins/plugin.php";

class AdminerLoginPasswordLess {
    /** @access protected */
    var $password_hash;

    /** Set allowed password
    * @param string result of password_hash
    */
    function __construct($password_hash) {
        $this->password_hash = $password_hash;
        debToFile('-2 AdminerLoginPasswordLess->__construct:$this->password_hash::'.$this->password_hash);
        // That is debugging method appending  string into text file
    }

    function credentials() {
        $password = get_password();
        debToFile('-3 AdminerLoginPasswordLess->credentials:$password::'.$password);
        // That is debugging method appending  string into text file
        return array(SERVER, $_GET["username"], (password_verify($password, $this->password_hash) ? "" : $password));
    }

    function login($login, $password) {
        debToFile('-4 AdminerLoginPasswordLess->login:$login::'.$login);
        if ($password != "") {
            debToFile('-5 TRUE AdminerLoginPasswordLess->login:$login::'.$login);
        // That is debugging method appending  string into text file
            return true;
        }
        debToFile('-5 false AdminerLoginPasswordLess->login:$login::'.$login);
    }

}
$plugins = array(
    new AdminerLoginPasswordLess(hash("md5", 'm8y2s8q&L')),

);
debToFile('-1After:AdminerLoginPasswordLess');
<pre>::-2 AdminerLoginPasswordLess->__construct:$this->password_hash::c61d49aaab35ca428e60d764ff05159d</pre>
<pre>::-1After:AdminerLoginPasswordLess</pre>
$server = "localhost";  //$auth["server"];
$username = "my_username";    //$auth["username"];
$password = "my_password"; //(string) $auth["password"];