From e4ea548ea034235308c9f7082662721985cb2aa5 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 22 Nov 2017 13:44:09 +0100 Subject: [PATCH] Update call for Users class --- misc/testing/DB/setUserPasswordHash.php | 35 ++++++++++--------- .../DB/setUserPasswordHashesToEmail.php | 2 +- public/pages/BasePage.php | 2 +- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/misc/testing/DB/setUserPasswordHash.php b/misc/testing/DB/setUserPasswordHash.php index dd8cc8e0f..5f9110021 100644 --- a/misc/testing/DB/setUserPasswordHash.php +++ b/misc/testing/DB/setUserPasswordHash.php @@ -15,12 +15,12 @@ $pdo = new DB(); if ($argc < 3) { exit( - $pdo->log->error( - 'Not enough parameters!'.PHP_EOL. - 'Argument 1: New password.'.PHP_EOL. - 'Argument 2: ID or username of the user.'.PHP_EOL - ) - ); + $pdo->log->error( + 'Not enough parameters!'.PHP_EOL. + 'Argument 1: New password.'.PHP_EOL. + 'Argument 2: ID or username of the user.'.PHP_EOL + ) + ); } $password = $argv[1]; @@ -31,24 +31,25 @@ if (is_numeric($password)) { $field = (is_numeric($identifier) ? 'id' : 'username'); $user = $pdo->queryOneRow( - sprintf( - 'SELECT id, username FROM users WHERE %s = %s', - $field, - (is_numeric($identifier) ? $identifier : $pdo->escapeString($identifier)) - ) + sprintf( + 'SELECT id, username FROM users WHERE %s = %s', + $field, + (is_numeric($identifier) ? $identifier : $pdo->escapeString($identifier)) + ) ); if ($user !== false) { - $users = new Users(['Settings' => $pdo]); + $users = new Users(); $hash = $users->hashPassword($password); $result = false; if ($hash !== false) { $hash = $pdo->queryExec( - sprintf( - 'UPDATE users SET password = %s WHERE id = %d', - $hash, $user['id'] - ) - ); + sprintf( + 'UPDATE users SET password = %s WHERE id = %d', + $hash, + $user['id'] + ) + ); } if ($result === false || $hash === false) { diff --git a/misc/testing/DB/setUserPasswordHashesToEmail.php b/misc/testing/DB/setUserPasswordHashesToEmail.php index 38369d049..fbe56327a 100644 --- a/misc/testing/DB/setUserPasswordHashesToEmail.php +++ b/misc/testing/DB/setUserPasswordHashesToEmail.php @@ -45,7 +45,7 @@ $pdo = new DB(); $users = $pdo->query('SELECT id, username, email, password FROM users'); $update = $pdo->Prepare('UPDATE users SET password = :password WHERE id = :id'); -$Users = new Users(['Settings' => $pdo]); +$Users = new Users(); foreach ($users as $user) { if (needUpdate($user)) { diff --git a/public/pages/BasePage.php b/public/pages/BasePage.php index ba263b81c..26cbf303e 100644 --- a/public/pages/BasePage.php +++ b/public/pages/BasePage.php @@ -144,7 +144,7 @@ class BasePage $this->page = $_GET['page'] ?? 'content'; - $this->users = new Users(['Settings' => $this->pdo]); + $this->users = new Users(); if ($this->users->isLoggedIn()) { $this->setUserPreferences(); } else {