don't try to pass string literal NOW() to ORM as a timestamp

This commit is contained in:
Andrew Dolgov 2021-03-01 23:07:20 +03:00
parent b150e46a52
commit 031ee47a3e
6 changed files with 10 additions and 6 deletions

View File

@ -29,7 +29,7 @@ abstract class Auth_Base extends Plugin implements IAuthModule {
$user->login = mb_strtolower($login);
$user->pwd_hash = UserHelper::hash_password($password, $user->salt);
$user->access_level = 0;
$user->created = 'NOW()';
$user->created = Db::NOW();
$user->save();
return UserHelper::find_user_by_login($login);

View File

@ -16,6 +16,10 @@ class Db
ORM::configure('return_result_sets', true);
}
static function NOW() {
return date("Y-m-d H:i:s", time());
}
private function __clone() {
//
}

View File

@ -475,7 +475,7 @@ class Feeds extends Handler_Protected {
/* bump login timestamp if needed */
if (time() - $_SESSION["last_login_update"] > 3600) {
$user = ORM::for_table('ttrss_users')->find_one($_SESSION["uid"]);
$user->last_login = 'NOW()';
$user->last_login = Db::NOW();
$user->save();
$_SESSION["last_login_update"] = time();

View File

@ -157,7 +157,7 @@ class Pref_Users extends Handler_Administrative {
$user->login = mb_strtolower($login);
$user->pwd_hash = UserHelper::hash_password($new_password, $user->salt);
$user->access_level = 0;
$user->created = 'NOW()';
$user->created = Db::NOW();
$user->save();
if ($new_uid = UserHelper::find_user_by_login($login)) {

View File

@ -51,7 +51,7 @@ class UserHelper {
$_SESSION["user_agent"] = sha1($_SERVER['HTTP_USER_AGENT']);
$_SESSION["pwd_hash"] = $user->pwd_hash;
$user->last_login = 'NOW()';
$user->last_login = Db::NOW();
$user->save();
return true;
@ -132,7 +132,7 @@ class UserHelper {
} else {
/* bump login timestamp */
$user = ORM::for_table('ttrss_users')->find_one($_SESSION["uid"]);
$user->last_login = 'NOW()';
$user->last_login = Db::NOW();
$user->save();
$_SESSION["last_login_update"] = time();

View File

@ -237,7 +237,7 @@ class Auth_Internal extends Auth_Base {
if (hash_equals("$pwd_algo:$raw_hash", $test_hash)) {
$pass = ORM::for_table('ttrss_app_passwords')->find_one($row["id"]);
$pass->last_used = 'NOW()';
$pass->last_used = Db::NOW();
if ($pwd_algo != UserHelper::HASH_ALGOS[0]) {
// upgrade password to current algo