From bdb450084704da1f33e28c9edd3d2d16b720a946 Mon Sep 17 00:00:00 2001 From: HarpyWar Date: Tue, 25 Mar 2014 23:32:25 +0400 Subject: [PATCH] Various modifications to /finger: - Displaying account creation time - Renamed is_admin/operator to Admin/Operator respectively - Displaying whether account is muted or not - Displaying last login owner http://developer.berlios.de/patch/?func=detailpatch&patch_id=2859&group_id=2291 --- src/bnetd/account_wrap.cpp | 5 +++++ src/bnetd/account_wrap.h | 1 + src/bnetd/command.cpp | 27 +++++++++++++++++++-------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/bnetd/account_wrap.cpp b/src/bnetd/account_wrap.cpp index 874ade2b2..74c7098ba 100644 --- a/src/bnetd/account_wrap.cpp +++ b/src/bnetd/account_wrap.cpp @@ -453,6 +453,11 @@ namespace pvpgn /****************************************************************/ + /* Account creation time */ + extern unsigned int account_get_ll_ctime(t_account * account) + { + return account_get_numattr(account, "BNET\\acct\\ctime"); + } extern unsigned int account_get_ll_time(t_account * account) { diff --git a/src/bnetd/account_wrap.h b/src/bnetd/account_wrap.h index 63f050bc7..32c8a47a3 100644 --- a/src/bnetd/account_wrap.h +++ b/src/bnetd/account_wrap.h @@ -89,6 +89,7 @@ namespace pvpgn extern char const * account_get_desc(t_account * account); /* last login */ + extern unsigned int account_get_ll_ctime(t_account * account); extern unsigned int account_get_ll_time(t_account * account); extern int account_set_ll_time(t_account * account, unsigned int t); extern char const * account_get_ll_user(t_account * account); diff --git a/src/bnetd/command.cpp b/src/bnetd/command.cpp index db47f31e9..ef54b105d 100644 --- a/src/bnetd/command.cpp +++ b/src/bnetd/command.cpp @@ -3441,6 +3441,8 @@ namespace pvpgn char const * ip; char * tok; t_clanmember * clanmemb; + std::time_t then; + struct std::tm * tmthen; for (i = 0; text[i] != ' ' && text[i] != '\0'; i++); /* skip command */ for (; text[i] == ' '; i++); @@ -3460,12 +3462,19 @@ namespace pvpgn message_send_text(c, message_type_error, c, "Invalid user."); return 0; } + + then = account_get_ll_ctime(account); + tmthen = std::localtime(&then); /* FIXME: determine user's timezone */ + snprintf(msgtemp, sizeof(msgtemp), "Login: %-16.16s "UID_FORMAT" Sex: %.14s", account_get_name(account), account_get_uid(account), account_get_sex(account)); message_send_text(c, message_type_info, c, msgtemp); + std::strftime(msgtemp, sizeof(msgtemp), "Created: %a %b %d %H:%M %Y ", tmthen); + message_send_text(c, message_type_info, c, msgtemp); + if ((clanmemb = account_get_clanmember(account))) { t_clan * clan; @@ -3517,8 +3526,6 @@ namespace pvpgn ip = "unknown"; { - std::time_t then; - struct std::tm * tmthen; then = account_get_ll_time(account); tmthen = std::localtime(&then); /* FIXME: determine user's timezone */ @@ -3540,13 +3547,17 @@ namespace pvpgn if ((account_get_command_groups(conn_get_account(c)) & command_get_group("/admin-addr"))) { /* the player who requested /finger has admin privileges - give him more info about the one he querys; - is_admin, is_operator, is_locked, email */ - snprintf(msgtemp, sizeof(msgtemp), "email:%.128s , is_operator: %d , is_admin: %d , is_acc_locked: %d", + give him more info about the one he querys; + is_admin, is_operator, is_locked, email */ + snprintf(msgtemp, sizeof(msgtemp), "Email: %.128s, Operator: %s, Admin: %s, Locked: %s, Muted: %s", account_get_email(account), - account_get_auth_operator(account, NULL), - account_get_auth_admin(account, NULL), - account_get_auth_lock(account)); + account_get_auth_operator(account, NULL) == 1 ? "Yes" : "No", + account_get_auth_admin(account, NULL) == 1 ? "Yes" : "No", + account_get_auth_lock(account) == 1 ? "Yes" : "No", + account_get_auth_mute(account) == 1 ? "Yes" : "No"); + message_send_text(c, message_type_info, c, msgtemp); + snprintf(msgtemp, sizeof(msgtemp), "Last login Owner: %.128s", + account_get_ll_owner(account)); message_send_text(c, message_type_info, c, msgtemp); }