summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2014-03-26 09:42:50 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2014-03-26 09:42:50 +0800
commit193ea6ae116c2a9e56682705c92fcffd51963d8f (patch)
tree344491c612fd2c65299863329c7bfd29c0d02ba8
parenta54cbdd9300f97b3f7ac98fa0b3b04a02f9a6aa0 (diff)
downloadpttbbs-193ea6ae116c2a9e56682705c92fcffd51963d8f.tar
pttbbs-193ea6ae116c2a9e56682705c92fcffd51963d8f.tar.gz
pttbbs-193ea6ae116c2a9e56682705c92fcffd51963d8f.tar.bz2
pttbbs-193ea6ae116c2a9e56682705c92fcffd51963d8f.tar.lz
pttbbs-193ea6ae116c2a9e56682705c92fcffd51963d8f.tar.xz
pttbbs-193ea6ae116c2a9e56682705c92fcffd51963d8f.tar.zst
pttbbs-193ea6ae116c2a9e56682705c92fcffd51963d8f.zip
Change update_online to do same way as pwcu does.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5970 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/util/update_online.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/pttbbs/util/update_online.c b/pttbbs/util/update_online.c
index 4e17dd72..26853e28 100644
--- a/pttbbs/util/update_online.c
+++ b/pttbbs/util/update_online.c
@@ -7,10 +7,18 @@ static int verbose = 0;
void fastcheck()
{
- int i, total = SHM->UTMPnumber - 1;
+ int i, total = SHM->UTMPnumber;
int sorted[USHM_SIZE], last_uid = -1;
userec_t urec;
userinfo_t u;
+ struct tm base_tm = {0};
+ time4_t base;
+
+ base = time4(0);
+ localtime4_r(&base, &base_tm);
+ base_tm.tm_sec = base_tm.tm_min = base_tm.tm_hour = 0;
+ base_tm.tm_min = 40; base_tm.tm_hour = 9;
+ base = mktime(&base_tm);
assert(sizeof(sorted) == sizeof(**SHM->sorted));
memcpy(sorted, SHM->sorted[SHM->currsorted][7],
@@ -19,8 +27,11 @@ void fastcheck()
if (sorted[i] < 0 || sorted[i] >= USHM_SIZE)
continue;
memcpy(&u, SHM->uinfo + sorted[i], sizeof(u));
+ if (!u.userid[0])
+ continue;
+ if (verbose > 2)
+ fprintf(stderr, "scanning: %s (UID:%d, PID:%d)\n", u.userid, u.uid, u.pid);
if (u.mode == DEBUGSLEEPING ||
- !u.userid[0] ||
(u.userlevel & PERM_VIOLATELAW) ||
!(u.userlevel & PERM_LOGINOK) ||
u.pid <= 0 ||
@@ -41,13 +52,13 @@ void fastcheck()
if (verbose > 1)
fprintf(stderr, "checking: %s (%s)\n", urec.userid, Cdatelite(&urec.lastlogin));
- /* user still online, let's mock it. */
- if (now < urec.lastlogin + DAY_SECONDS - 60 * 60)
+ if (urec.lastlogin >= base)
continue;
if (verbose)
fprintf(stderr, "update: %s (%s, %d) ->", urec.userid,
Cdatelite(&urec.lastlogin), urec.numlogindays);
+ /* user still online, let's mock it. */
urec.lastlogin = now;
urec.numlogindays++;
if (verbose)