update_last_login.php 656 B

123456789101112131415161718
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once '../inc/global.inc.php';
  4. api_protect_admin_script();
  5. $tableUser = Database::get_main_table(TABLE_MAIN_USER);
  6. $userInfo = api_get_user_info(api_get_user_id());
  7. if (isset($userInfo['last_login'])) {
  8. $sql = "SELECT login_user_id, MAX(login_date) login_date from track_e_login group by login_user_id";
  9. $result = Database::query($sql);
  10. while ($row = Database::fetch_array($result)) {
  11. $date = $row['login_date'];
  12. $userId = $row['login_user_id'];
  13. $sql = "UPDATE $tableUser SET last_login ='$date' WHERE user_id = $userId";
  14. Database::query($sql);
  15. }
  16. }