Explorar el Código

* Added modified for .whois on chattr/+host/-host

svn: 304
Bryan Drewery hace 22 años
padre
commit
c5822282bb
Se han modificado 4 ficheros con 68 adiciones y 12 borrados
  1. 20 12
      src/cmds.c
  2. 1 0
      src/proto.h
  3. 46 0
      src/userent.c
  4. 1 0
      src/users.h

+ 20 - 12
src/cmds.c

@@ -365,8 +365,7 @@ static void cmd_config(struct userrec *u, int idx, char *par)
   }
 #ifdef HUB
   write_userfile(idx);
-#endif
-
+#endif /* HUB */
 }
 
 static void cmd_botconfig(struct userrec *u, int idx, char *par)
@@ -407,9 +406,9 @@ static void cmd_botconfig(struct userrec *u, int idx, char *par)
     return;
   }
   if (!par[0]) {
-    for (i=0;i<cfg_count;i++) {
+    for (i = 0; i < cfg_count; i++) {
       if ((cfg[i]->flags & CFGF_LOCAL) && (cfg[i]->describe)) {
-	k=get_user(&USERENTRY_CONFIG, u2);
+	k = get_user(&USERENTRY_CONFIG, u2);
 	while (k && strcmp(k->key, cfg[i]->name))
 	  k=k->next;
 	if (k)
@@ -420,7 +419,7 @@ static void cmd_botconfig(struct userrec *u, int idx, char *par)
     }
     return;
   }
-  p=newsplit(&par);
+  p = newsplit(&par);
   cfgent=NULL;
   for (i=0;!cfgent && (i<cfg_count);i++)
     if (!strcmp(cfg[i]->name, p) && (cfg[i]->flags & CFGF_LOCAL) && (cfg[i]->describe))
@@ -430,14 +429,17 @@ static void cmd_botconfig(struct userrec *u, int idx, char *par)
     return;
   }
   if (par[0]) {
+    char tmp[100];    
     set_cfg_str(u2->handle, cfgent->name, (strcmp(par, "-")) ? par : NULL);
+    snprintf(tmp, sizeof tmp, "%s %s", cfgent->name, par);
+    update_mod(u2->handle, dcc[idx].nick, "botconfig", tmp);
     dprintf(idx, STR("Now: "));
     write_userfile(idx);
   } else {
     if (cfgent->describe)
       cfgent->describe(cfgent, idx);
   }
-  k=get_user(&USERENTRY_CONFIG, u2);
+  k = get_user(&USERENTRY_CONFIG, u2);
   while (k && strcmp(k->key, cfgent->name))
     k=k->next;
   if (k)
@@ -1689,6 +1691,7 @@ static void cmd_comment(struct userrec *u, int idx, char *par)
     return;
   }
   dprintf(idx, STR("Changed comment.\n"));
+  update_mod(handle, dcc[idx].nick, "comment", NULL);
   set_user(&USERENTRY_COMMENT, u1, par);
 }
 
@@ -2241,12 +2244,15 @@ static void cmd_chattr(struct userrec *u, int idx, char *par)
     }
     set_user_flagrec(u2, &user, par);
   }
-  if (chan)
-    putlog(LOG_CMDS, "*", STR("#%s# (%s) chattr %s %s"),
-	   dcc[idx].nick, chan ? chan->dname : "*", hand, chg ? chg : "");
-  else
-    putlog(LOG_CMDS, "*", STR("#%s# chattr %s %s"), dcc[idx].nick, hand,
-	   chg ? chg : "");
+  if (chan) {
+    char tmp[100];
+    putlog(LOG_CMDS, "*", STR("#%s# (%s) chattr %s %s"), dcc[idx].nick, chan ? chan->dname : "*", hand, chg ? chg : "");
+    snprintf(tmp, sizeof tmp, "chattr %s", chg);
+    update_mod(hand, dcc[idx].nick, tmp, chan->dname);
+  } else {
+    putlog(LOG_CMDS, "*", STR("#%s# chattr %s %s"), dcc[idx].nick, hand, chg ? chg : "");
+    update_mod(hand, dcc[idx].nick, "chattr", chg);
+  }
   /* Get current flags and display them */
   if (user.match & FR_GLOBAL) {
     user.match = FR_GLOBAL;
@@ -3258,6 +3264,7 @@ static void cmd_pls_host(struct userrec *u, int idx, char *par)
       return;
     }
   addhost_by_handle(handle, host);
+  update_mod(handle, dcc[idx].nick, "+host", host);
   dprintf(idx, STR("Added '%s' to %s.\n"), host, handle);
   if ((me = module_find("irc", 0, 0))) {
     Function *func = me->funcs;
@@ -3330,6 +3337,7 @@ static void cmd_mns_host(struct userrec *u, int idx, char *par)
   }
   if (delhost_by_handle(handle, host)) {
     dprintf(idx, STR("Removed '%s' from %s.\n"), host, handle);
+    update_mod(handle, dcc[idx].nick, "-host", host);
     if ((me = module_find("irc", 0, 0))) {
       Function *func = me->funcs;
 

+ 1 - 0
src/proto.h

@@ -342,6 +342,7 @@ int findidx(int);
 int findanyidx(int);
 
 /* userent.c */
+void update_mod(char *, char *, char *, char *);
 void add_cfg(struct cfg_entry *);
 void list_type_kill(struct list_type *);
 int list_type_expmem(struct list_type *);

+ 46 - 0
src/userent.c

@@ -33,6 +33,7 @@ void init_userent()
   add_entry_type(&USERENTRY_BOTFL);
   add_entry_type(&USERENTRY_STATS);
   add_entry_type(&USERENTRY_ADDED);
+  add_entry_type(&USERENTRY_MODIFIED);
   add_entry_type(&USERENTRY_CONFIG);
 }
 
@@ -676,6 +677,51 @@ struct user_entry_type USERENTRY_STATS = {
   "STATS"
 };
 
+void update_mod(char *handle, char *nick, char *cmd, char *par)
+{
+  char tmp[100];
+  snprintf(tmp, sizeof tmp, "%lu, %s (%s %s)", now, nick, cmd, par);
+  set_user(&USERENTRY_MODIFIED, get_user_by_handle(userlist, handle), tmp);
+}
+
+void modified_display(int idx, struct user_entry *e, struct userrec *u)
+{
+  if (e && dcc[idx].user && (dcc[idx].user->flags & USER_MASTER)) {
+    char tmp[1024],
+      tmp2[1024],
+     *hnd;
+    time_t tm;
+    strncpyz(tmp, e->u.string, sizeof(tmp));
+    hnd = strchr(tmp, ' ');
+    if (hnd)
+      *hnd++ = 0;
+    tm = atoi(tmp);
+    strftime(tmp2, sizeof(tmp2), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&tm));
+    if (hnd)
+      dprintf(idx, " -- Modified %s by %s\n", tmp2, hnd);
+    else
+      dprintf(idx, " -- Modified %s\n", tmp2);
+  }
+}
+
+struct user_entry_type USERENTRY_MODIFIED =
+{
+  0,
+  def_gotshare,
+  def_dupuser,
+  def_unpack,
+  def_pack,
+  def_write_userfile,
+  def_kill,
+  def_get,
+  def_set,
+  0,
+  0,
+  def_expmem,
+  modified_display,
+  "MODIFIED"
+};
+
 int pass_set(struct userrec *u, struct user_entry *e, void *buf)
 {
   char new[32];

+ 1 - 0
src/users.h

@@ -53,6 +53,7 @@ extern struct user_entry_type USERENTRY_COMMENT, USERENTRY_LASTON,
  USERENTRY_PASS, USERENTRY_BOTFL,
   USERENTRY_STATS,
   USERENTRY_ADDED,
+  USERENTRY_MODIFIED,
   USERENTRY_CONFIG,
   USERENTRY_SECPASS,
   USERENTRY_XTRA;