1
0
Fork 0
mirror of https://github.com/Alamantus/Lexiconga.git synced 2026-09-24 13:07:11 +02:00

Fixes to get user creation working with docker setup

This commit is contained in:
Robbie Antenesse 2026-08-24 21:49:59 -06:00
parent f1e6d97d35
commit 2fa8a6a91c
5 changed files with 14 additions and 12 deletions

View file

@ -5,7 +5,7 @@ class Db {
private $dbh;
public $last_error_info;
function __construct() {
$this->dbh = new PDO('mysql:host=localhost;dbname=' . DB_NAME . ';charset=utf8', DB_USER, DB_PASSWORD);
$this->dbh = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8', DB_USER, DB_PASSWORD);
$this->dbh->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$this->last_error_info = null;
}
@ -20,7 +20,7 @@ class Db {
$this->last_error_info = $stmt->errorInfo();
return false;
}
public function query ($query, $params = array()) {
// Run a query that returns results
$stmt = $this->dbh->prepare($query);

View file

@ -61,7 +61,7 @@ VALUES ($new_id, ?, ?, ?, ?, ?, ?)";
public function changeCurrent ($user, $dictionary) {
$update_query = 'UPDATE users SET current_dictionary=? WHERE id=?';
$update = $this->db->query($update_query, array($dictionary, $user));
if (trim($this->db->last_error_info[2]) == '') {
if (trim($this->db->last_error_info[2] ?? '') == '') {
return $dictionary;
}
return false;
@ -312,7 +312,7 @@ created_on=VALUES(created_on)';
etymology=VALUES(etymology),
related=VALUES(related),
principal_parts=VALUES(principal_parts)';
$results1 = $this->db->execute($query1, $params1);
// if ($results1) {
@ -353,7 +353,7 @@ principal_parts=VALUES(principal_parts)';
$insert_query = trim($insert_query, ', ') . ' ON DUPLICATE KEY UPDATE deleted_on=VALUES(deleted_on)';
$delete_query = trim($delete_query, ', ') . ')';
$insert_results = $this->db->execute($insert_query, $insert_params);
if ($insert_results) {
$delete_results = $this->db->execute($delete_query, $delete_params);

View file

@ -4,8 +4,10 @@ require_once(realpath(dirname(__FILE__) . '/./Token.php'));
require_once(realpath(dirname(__FILE__) . '/./Dictionary.php'));
class User {
private $db;
private $token;
private Db $db;
private Token $token;
private Dictionary $dictionary;
function __construct () {
$this->db = new Db();
$this->token = new Token();
@ -276,7 +278,7 @@ VALUES (?, ?, ?, ?, current_timestamp())';
$date,
$email,
));
if ($reset) {
$user_data = $this->getUserDataByEmailForPasswordReset($email);
if ($user_data) {
@ -317,7 +319,7 @@ VALUES (?, ?, ?, ?, current_timestamp())';
$unhashed_code,
));
$results = $stmt->fetchAll();
if ($stmt && $results) {
return count($results) === 1;
} else {

View file

@ -156,9 +156,9 @@ switch ($view) {
}
})(window.onload);
</script>";
$html = str_replace('{{upup_insert}}', $upup_insert, $html);
$imported_from_http = '';
if (isset($_POST['oldDictionaryFromHTTP'])) {
$imported_from_http = '<script>window.dictionaryImportedFromHTTP = "' . addslashes($_POST['oldDictionaryFromHTTP']) . '";</script>';

View file

@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS `dictionaries` (
`case_sensitive` tinyint(1) NOT NULL DEFAULT 0,
`sort_by_definition` tinyint(1) NOT NULL DEFAULT 0,
`theme` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'default',
`custom_css` text COLLATE utf8_unicode_ci NOT NULL COMMENT 'CSS',
`custom_css` text COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'CSS',
`is_public` tinyint(1) NOT NULL DEFAULT 0,
`last_updated` int(11) DEFAULT NULL,
`created_on` int(11) NOT NULL,