]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanserv/usercmds/whois.c
A4STATS: remove E style escapes and switch to createtable for indices
[irc/quakenet/newserv.git] / chanserv / usercmds / whois.c
index 280f91823cc5813627f9c21534e045df9a431f80..ffc81d66ccf17b628aa559289609f1408ae88440 100644 (file)
 #include "../chanserv.h"
 #include "../../lib/irc_string.h"
 #include "../../lib/strlfunc.h"
+#include "../../lib/ccassert.h"
 #include <stdio.h>
 #include <string.h>
 
 int csu_dowhois(void *source, int cargc, char **cargv) {
   nick *sender=source;
-  reguser *rup=getreguserfromnick(sender), *target;
+  reguser *rup, *target;
   char buf[200];
   char nbpos=0;
-  struct tm *tmp;
   regchanuser *rcup, *rcup2;
   flag_t flagmask, flags;
   int doneheader=0;
   authname *anp;
   nick *tnp;
 
+  CCASSERT(sizeof(buf) > TIMELEN);
+
   if (!(rup=getreguserfromnick(sender)))
     return CMD_ERROR;
   
@@ -69,6 +71,8 @@ int csu_dowhois(void *source, int cargc, char **cargv) {
       char expiresbuf[100];
       char *reason, *suspendtype, *whom;
 
+      CCASSERT(sizeof(expiresbuf) > TIMELEN);
+
       if(UIsDelayedGline(target)) {
         suspendtype = "delayed gline";
       } else if(UIsGline(target)) {
@@ -83,7 +87,7 @@ int csu_dowhois(void *source, int cargc, char **cargv) {
         if(time(NULL) >= target->suspendexp) {
           strlcpy(expiresbuf, "(next auth)", sizeof(expiresbuf));
         } else {
-          strftime(expiresbuf, sizeof(expiresbuf), Q9_FORMAT_TIME, gmtime(&(target->suspendexp)));
+          q9strftime(expiresbuf, sizeof(expiresbuf), target->suspendexp);
         }
       } else {
         strlcpy(expiresbuf, "(never)", sizeof(expiresbuf));
@@ -100,7 +104,7 @@ int csu_dowhois(void *source, int cargc, char **cargv) {
         whom = "(hidden)";
       }
 
-      if(target->suspendreason && target->suspendreason->content) {
+      if(target->suspendreason) {
         reason = target->suspendreason->content;
       } else {
         reason = "(none)";
@@ -130,8 +134,8 @@ int csu_dowhois(void *source, int cargc, char **cargv) {
   }
 
   if (rup==target)
-    flagmask|=(QUFLAG_OPER | QUFLAG_DEV | QUFLAG_HELPER | 
-              QUFLAG_ADMIN | QUFLAG_INFO | QUFLAG_NOTICE | QUFLAG_STAFF);
+    flagmask|=(QUFLAG_OPER | QUFLAG_DEV | QUFLAG_HELPER | QUFLAG_ADMIN |
+              QUFLAG_INFO | QUFLAG_NOTICE | QUFLAG_STAFF | QUFLAG_ACHIEVEMENTS);
 
   if (flagmask & target->flags)
     chanservstdmessage(sender, QM_WHOIS_FLAGS, printflagsornone(flagmask & target->flags, ruflags));
@@ -158,21 +162,28 @@ int csu_dowhois(void *source, int cargc, char **cargv) {
   if (target->lastauth == 0) {
     snprintf(buf,sizeof(buf),"(never)");
   } else {
-    tmp=gmtime(&(target->lastauth));
-    strftime(buf,sizeof(buf),Q9_FORMAT_TIME,tmp);
+    q9strftime(buf,sizeof(buf),target->lastauth);
   }
   chanservstdmessage(sender, QM_WHOIS_LASTAUTH, buf);
   
-  if (target->lastuserhost && (rup==target || cs_privcheck(QPRIV_VIEWFULLWHOIS, sender))) {
+  /* The third clause of this hides user@host of opers from non-opered staff. */
+  if (target->lastuserhost && (rup==target || cs_privcheck(QPRIV_VIEWFULLWHOIS, sender)) &&
+      (!UHasOperPriv(target) || UHasOperPriv(rup)) ) {
 /* Commenting out language until we implement some - splidge 
     chanservstdmessage(sender, QM_WHOIS_USERLANG, cslanguages[target->languageid] ?
                       cslanguages[target->languageid]->name->content : "(unknown)");  */
-    chanservstdmessage(sender, QM_WHOIS_LASTUSERHOST, target->lastuserhost->content);
+    if(rup==target || cs_privcheck(QPRIV_VIEWREALHOST, sender)) {
+      chanservstdmessage(sender, QM_WHOIS_LASTUSERHOST, target->lastuserhost->content);
+    }
   }
 
   if (target->email && (rup==target || cs_privcheck(QPRIV_VIEWEMAIL, sender))) {
     chanservstdmessage(sender, QM_WHOIS_EMAIL, target->email->content);
-    chanservstdmessage(sender, QM_WHOIS_EMAILSET, target->lastemailchange);
+
+    if (target->lastemailchange)
+      chanservstdmessage(sender, QM_WHOIS_EMAILSET, target->lastemailchange);
+    if (target->lastpasschange)
+      chanservstdmessage(sender, QM_WHOIS_PASSSET, target->lastpasschange);
   }
 
   if (target->info && *target->info->content) {
@@ -216,5 +227,11 @@ int csu_dowhois(void *source, int cargc, char **cargv) {
 
   chanservstdmessage(sender, QM_ENDOFLIST);
 
+  if (rup==target) {
+    triggerhook(HOOK_CHANSERV_WHOAMI, sender);
+  } else {
+    triggerhook(HOOK_CHANSERV_WHOIS, sender);
+  }
+
   return CMD_OK;
 }