Menu

### How to configure adminer editor 4-6-3 with Sqlite (Aug 2018) ?

DUV
2018-08-28
2018-10-27
  • DUV

    DUV - 2018-08-28

    Adminer 4-6-3 + Sqlite work well with this adminer.php file :

    <?php
    function adminer_object()
    {
        include_once "./plugins/plugin.php";
        include_once "./plugins/login-password-less.php";
        return new AdminerPlugin(array(
            // TODO: inline the result of password_hash() so that the password is not visible in source codes
            new AdminerLoginPasswordLess(password_hash("toto", PASSWORD_DEFAULT)),
        ));
    }
    
    // include original Adminer or Adminer Editor
    include "./adminer-4.6.3.php";
    

    it's work well

    But, I can't do work adminer editor 4-6-3 + Sqlite

    I tried this file editor.php (similar with adminer.php )

    <?php
    function adminer_object()
    {
        include_once "./plugins/plugin.php";
        include_once "./plugins/login-password-less.php";
        return new AdminerPlugin(array(
            // TODO: inline the result of password_hash() so that the password is not visible in source codes
            new AdminerLoginPasswordLess(password_hash("toto", PASSWORD_DEFAULT)),
        ));
    }
    // include original Adminer or Adminer Editor
    include "./editor-4.6.3.php";
    

    I obtain a green error message : "The action will be performed after successfull login with the same credentials."

    I tried a version with login et loginForm functions :

    <?php
    function adminer_object()
    {
    include_once "./plugins/plugin.php";
    include_once "./plugins/login-password-less.php";
    
        class AdminerSoftware extends Adminer
        {
    
            function database()
            {
                // database name, will be escaped by Adminer
                return 'db.sqlite';
            }
    
            function login($login, $password)
            {
                // validate user submitted credentials
                return ($login == 'toto' && $password == 'toto');
            }
    
            function loginForm()
    {
        ?>
    <table cellspacing="0">
    <tr><th><?php echo lang('Username'); ?>
    <td>
    <input type="text" name="auth[driver]" value="sqlite">
    <input type="text" name="auth[server]" value="">
    <input id="username" name="auth[username]" value="<?php echo h($_GET["username"]); ?>">
    <tr><th><?php echo lang('Password'); ?><td>
    <input type="password" name="auth[password]"">
    </table>
    <?php
    echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
    echo checkbox("permanent", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
    }
        }
        return new AdminerSoftware;
    }
    include "./editor-4.6.3.php";
    

    I obtain a red error message : Database does not support password.

    Is there a default configuration to use Sqlite and editor-4.6.3.php ?

    Many thanks

    edit 20:40 for typo

     

    Last edit: DUV 2018-08-28
  • Jakub Vrána

    Jakub Vrána - 2018-09-18

    This is one option:

    <?php
    function adminer_object() {
        include_once "../plugins/plugin.php";
        include_once "../plugins/login-password-less.php";
        class AdminerSqlite extends AdminerPlugin {
            function loginFormField($name, $heading, $value) {
                return $heading . ($name == 'username' ? preg_replace('~"server"~', '"sqlite"', $value) : $value);
            }
            function database() {
                return 'db.sqlite';
            }
        }
        return new AdminerSqlite(array(
            // TODO: inline the result of password_hash() so that the password is not visible in source codes
            new AdminerLoginPasswordLess(password_hash("YOUR_PASSWORD_HERE", PASSWORD_DEFAULT)),
        ));
    }
    
    include "./index.php";
    
     
  • DUV

    DUV - 2018-09-26

    Hello,

    Thanks to your example.

    I have done the same, with terminating by :

    include "./editor-4.6.3.php";
    

    /var/log/apache2/errors.log give a :
    PHP Warning: Declaration of AdminerPlugin::dumpTable($table, $style, $is_view = 0) should be compatible with Adminer::dumpTable() in /mnt/nas/plugins/plugin.php on line 0

    but it works !

    many thanks

     
  • DUV

    DUV - 2018-09-26

    Sorry, I don't see how to check as [SOLVED]

     
  • Jakub Vrána

    Jakub Vrána - 2018-10-27

    The warning is probably caused by using an old plugin.php, please update it.

     

Log in to post a comment.