From 250d5c21e0761f27c74553a3c679789c8e4db7f2 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Mon, 14 Mar 2016 21:34:50 -0400 Subject: [PATCH] Record last login timestamp in the database --- controllers/config.php | 2 +- locales/ar_AR/translations.php | 1 + locales/cs_CZ/translations.php | 1 + locales/de_DE/translations.php | 1 + locales/es_ES/translations.php | 1 + locales/fr_FR/translations.php | 3 ++- locales/it_IT/translations.php | 1 + locales/ja_JP/translations.php | 3 ++- locales/pt_BR/translations.php | 1 + locales/ru_RU/translations.php | 3 ++- locales/sr_RS/translations.php | 1 + locales/sr_RS@latin/translations.php | 1 + locales/tr_TR/translations.php | 1 + locales/zh_CN/translations.php | 1 + models/user.php | 14 +++++++++++--- templates/about.php | 3 +++ 16 files changed, 31 insertions(+), 7 deletions(-) diff --git a/controllers/config.php b/controllers/config.php index f976cfe..35848b2 100644 --- a/controllers/config.php +++ b/controllers/config.php @@ -54,7 +54,7 @@ Router\post_action('new-db', function() { Response\redirect('?action=database'); }); -// Comfirmation box before auto-update +// Confirmation box before auto-update Router\get_action('confirm-auto-update', function() { Response\html(Template\layout('confirm_auto_update', array( diff --git a/locales/ar_AR/translations.php b/locales/ar_AR/translations.php index 08b6d8f..b52f145 100644 --- a/locales/ar_AR/translations.php +++ b/locales/ar_AR/translations.php @@ -244,4 +244,5 @@ return array( // 'view' => '', // 'Item title links to' => '', // 'Original' => '', + // 'Last login:' => '', ); diff --git a/locales/cs_CZ/translations.php b/locales/cs_CZ/translations.php index f03dd47..a8530ca 100644 --- a/locales/cs_CZ/translations.php +++ b/locales/cs_CZ/translations.php @@ -244,4 +244,5 @@ return array( 'view' => 'zobrazit', 'Item title links to' => 'Titulek článku odkazuje na', 'Original' => 'Originál', + // 'Last login:' => '', ); diff --git a/locales/de_DE/translations.php b/locales/de_DE/translations.php index 120dd63..be17992 100644 --- a/locales/de_DE/translations.php +++ b/locales/de_DE/translations.php @@ -244,4 +244,5 @@ return array( // 'view' => '', // 'Item title links to' => '', // 'Original' => '', + // 'Last login:' => '', ); diff --git a/locales/es_ES/translations.php b/locales/es_ES/translations.php index 73673b6..1dec4b2 100644 --- a/locales/es_ES/translations.php +++ b/locales/es_ES/translations.php @@ -244,4 +244,5 @@ return array( // 'view' => '', // 'Item title links to' => '', // 'Original' => '', + // 'Last login:' => '', ); diff --git a/locales/fr_FR/translations.php b/locales/fr_FR/translations.php index 3a91818..564409f 100644 --- a/locales/fr_FR/translations.php +++ b/locales/fr_FR/translations.php @@ -243,5 +243,6 @@ return array( 'Back to the group' => 'Revenir sur le groupe', 'view' => 'voir', 'Item title links to' => 'Le titre des articles redirige vers', - 'Original' => 'Original' + 'Original' => 'Original', + 'Last login:' => 'Dernière connexion :', ); diff --git a/locales/it_IT/translations.php b/locales/it_IT/translations.php index 373e372..72a3bf5 100644 --- a/locales/it_IT/translations.php +++ b/locales/it_IT/translations.php @@ -244,4 +244,5 @@ return array( // 'view' => '', // 'Item title links to' => '', // 'Original' => '', + // 'Last login:' => '', ); diff --git a/locales/ja_JP/translations.php b/locales/ja_JP/translations.php index 493a13b..221ff68 100644 --- a/locales/ja_JP/translations.php +++ b/locales/ja_JP/translations.php @@ -245,5 +245,6 @@ return array( 'Back to the group' => 'グループへ戻る', 'view' => '表示', 'Item title links to' => 'アイテムのタイトルのリンク先', - 'Original' => '元のページ' + 'Original' => '元のページ', + // 'Last login:' => '', ); diff --git a/locales/pt_BR/translations.php b/locales/pt_BR/translations.php index c73a63f..ee7840b 100644 --- a/locales/pt_BR/translations.php +++ b/locales/pt_BR/translations.php @@ -244,4 +244,5 @@ return array( // 'view' => '', // 'Item title links to' => '', // 'Original' => '', + // 'Last login:' => '', ); diff --git a/locales/ru_RU/translations.php b/locales/ru_RU/translations.php index 284e85b..c94e053 100644 --- a/locales/ru_RU/translations.php +++ b/locales/ru_RU/translations.php @@ -243,5 +243,6 @@ return array( 'Back to the group' => 'Назад в группу', 'view' => 'смотреть', 'Item title links to' => 'Заголовок статьи ведет на', - 'Original' => 'Оригинал' + 'Original' => 'Оригинал', + // 'Last login:' => '', ); diff --git a/locales/sr_RS/translations.php b/locales/sr_RS/translations.php index 245199f..5d1c38a 100644 --- a/locales/sr_RS/translations.php +++ b/locales/sr_RS/translations.php @@ -244,4 +244,5 @@ return array( // 'view' => '', // 'Item title links to' => '', // 'Original' => '', + // 'Last login:' => '', ); diff --git a/locales/sr_RS@latin/translations.php b/locales/sr_RS@latin/translations.php index 504d9ed..172ab78 100644 --- a/locales/sr_RS@latin/translations.php +++ b/locales/sr_RS@latin/translations.php @@ -244,4 +244,5 @@ return array( // 'view' => '', // 'Item title links to' => '', // 'Original' => '', + // 'Last login:' => '', ); diff --git a/locales/tr_TR/translations.php b/locales/tr_TR/translations.php index 48465f1..5c5b263 100644 --- a/locales/tr_TR/translations.php +++ b/locales/tr_TR/translations.php @@ -244,4 +244,5 @@ return array( 'view' => 'görüntüle', // 'Item title links to' => '', // 'Original' => '', + // 'Last login:' => '', ); diff --git a/locales/zh_CN/translations.php b/locales/zh_CN/translations.php index 248b26e..5ff2989 100644 --- a/locales/zh_CN/translations.php +++ b/locales/zh_CN/translations.php @@ -244,4 +244,5 @@ return array( 'view' => '查看', // 'Item title links to' => '', // 'Original' => '', + // 'Last login:' => '', ); diff --git a/models/user.php b/models/user.php index aa1abba..afc1c6c 100644 --- a/models/user.php +++ b/models/user.php @@ -24,13 +24,21 @@ function logout() } // Get the credentials from the current selected database -function getCredentials() +function get_credentials() { return Database::getInstance('db') ->hashtable('settings') ->get('username', 'password'); } +// Set last login date +function set_last_login() +{ + return Database::getInstance('db') + ->hashtable('settings') + ->put(array('last_login' => time())); +} + // Validate authentication function validate_login(array $values) { @@ -45,10 +53,10 @@ function validate_login(array $values) if ($result) { - $credentials = getCredentials(); + $credentials = get_credentials(); if ($credentials && $credentials['username'] === $values['username'] && password_verify($values['password'], $credentials['password'])) { - + set_last_login(); $_SESSION['loggedin'] = true; $_SESSION['config'] = Config\get_all(); diff --git a/templates/about.php b/templates/about.php index 4b0b8aa..5ce74da 100644 --- a/templates/about.php +++ b/templates/about.php @@ -28,6 +28,9 @@