Files
adminer/plugins/login-table.php

34 lines
1016 B
PHP
Raw Normal View History

2011-02-09 21:15:34 +01:00
<?php
/* Requires this table:
CREATE TABLE login (
id int NOT NULL AUTO_INCREMENT, -- optional
login varchar(30) NOT NULL, -- any length
password_sha1 char(40) NOT NULL,
UNIQUE (login),
PRIMARY KEY (id)
);
*/
/** Authenticate a user from the login table
2015-09-08 09:23:25 -07:00
* @link https://www.adminer.org/plugins/#use
2017-02-27 13:43:33 +01:00
* @author Jakub Vrana, https://www.vrana.cz/
2018-01-14 11:03:54 +01:00
* @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)
2011-02-09 21:15:34 +01:00
*/
class AdminerLoginTable {
2011-08-11 17:06:42 +02:00
/** @access protected */
2011-02-09 21:15:34 +01:00
var $database;
2025-02-21 13:53:18 +01:00
2011-03-21 10:14:22 +01:00
/** Set database of login table
* @param string
*/
2015-08-15 17:04:21 +02:00
function __construct($database) {
2011-02-09 21:15:34 +01:00
$this->database = $database;
}
2025-02-21 13:53:18 +01:00
2011-02-09 21:15:34 +01:00
function login($login, $password) {
2025-03-05 11:40:56 +01:00
$connection = Adminer\connection();
2025-03-05 14:51:55 +01:00
return (bool) $connection->result("SELECT COUNT(*) FROM " . Adminer\idf_escape($this->database) . ".login WHERE login = " . Adminer\q($login) . " AND password_sha1 = " . Adminer\q(sha1($password)));
2011-02-09 21:15:34 +01:00
}
}