Browse Source

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

master
Andrew Dolgov 1 year ago
parent
commit
031ee47a3e
  1. 2
      classes/auth/base.php
  2. 4
      classes/db.php
  3. 2
      classes/feeds.php
  4. 2
      classes/pref/users.php
  5. 4
      classes/userhelper.php
  6. 2
      plugins/auth_internal/init.php

2
classes/auth/base.php

@ -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);

4
classes/db.php

@ -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() {
//
}

2
classes/feeds.php

@ -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();

2
classes/pref/users.php

@ -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)) {

4
classes/userhelper.php

@ -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();

2
plugins/auth_internal/init.php

@ -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

Loading…
Cancel
Save