From 2bc063ccd25092e1b4251136573adaeed8e55937 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Thu, 11 Dec 2008 14:35:53 +0100 Subject: Corrected a lot of small errors, setting wrong flag and SQL mistakes --- database/sqlite/administration.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'database/sqlite') diff --git a/database/sqlite/administration.c b/database/sqlite/administration.c index 6eb1205..3927192 100644 --- a/database/sqlite/administration.c +++ b/database/sqlite/administration.c @@ -423,10 +423,15 @@ int eDBadminGetUserInfo(eurephiaCTX *ctx, int getInfo, eurephiaUSERINFO *user) { " (bl.username IS NOT NULL), opensess, logincount" " FROM openvpn_users u" " LEFT JOIN openvpn_blacklist bl USING(username)" - " LEFT JOIN (SELECT uid, count(*) AS logincount FROM openvpn_lastlog) lc" + " LEFT JOIN (SELECT uid, count(*) AS logincount " + " FROM openvpn_lastlog" + " GROUP BY uid) lc" " ON (lc.uid = u.uid)" - " LEFT JOIN (SELECT uid, count(*)>0 AS opensess FROM openvpn_lastlog) os" - " ON (os.uid = u.uid) ", + " LEFT JOIN (SELECT uid, count(*) > 0 AS opensess" + " FROM openvpn_lastlog" + " WHERE sessionstatus = 2" + " GROUP BY uid) os" + " ON (os.uid = u.uid)", NULL, uinfo_map); if( uinf == NULL ) { @@ -447,7 +452,7 @@ int eDBadminGetUserInfo(eurephiaCTX *ctx, int getInfo, eurephiaUSERINFO *user) { user->account_flags = ((sqlite_get_value(uinf, 0, 3) == NULL) ? ACCFLAG_NEVERUSED : 0); user->account_flags|= ((sqlite_get_value(uinf, 0, 2) != NULL) ? ACCFLAG_DEACTIVATED : 0); user->account_flags|= ((atoi(sqlite_get_value(uinf, 0, 5)) == 1) ? ACCFLAG_BLACKLISTED : 0); - user->account_flags|= ((atoi_nullsafe(sqlite_get_value(uinf, 0, 6))==1) ? ACCFLAG_BLACKLISTED : 0); + user->account_flags|= ((atoi_nullsafe(sqlite_get_value(uinf, 0, 6))==1) ? ACCFLAG_OPENSESSION : 0); if( (getInfo & USERINFO_user) == USERINFO_user ) { free_nullsafe(user->password); -- cgit