]> jfr.im git - irc/quakenet/newserv.git/commitdiff
2.09
authorstrutsi <redacted>
Wed, 13 Jul 2005 19:05:00 +0000 (20:05 +0100)
committerstrutsi <redacted>
Wed, 13 Jul 2005 19:05:00 +0000 (20:05 +0100)
52 files changed:
helpmod2/changelist
helpmod2/commands/acconf
helpmod2/commands/addchan
helpmod2/commands/aliases
helpmod2/commands/autoqueue
helpmod2/commands/ban
helpmod2/commands/censor
helpmod2/commands/chanban
helpmod2/commands/chanconf
helpmod2/commands/delchan
helpmod2/commands/dequeue
helpmod2/commands/dnmo
helpmod2/commands/done
helpmod2/commands/enqueue
helpmod2/commands/everyoneout
helpmod2/commands/idlekick
helpmod2/commands/kick
helpmod2/commands/klingon
helpmod2/commands/lamercontrol
helpmod2/commands/listuser
helpmod2/commands/load
helpmod2/commands/message
helpmod2/commands/next
helpmod2/commands/out
helpmod2/commands/queue
helpmod2/commands/report
helpmod2/commands/showcommands
helpmod2/commands/stats
helpmod2/commands/status
helpmod2/commands/term
helpmod2/commands/welcome
helpmod2/commands/whois
helpmod2/haccount.c
helpmod2/hban.c
helpmod2/hban.h
helpmod2/hchanban.c
helpmod2/hchanban.h
helpmod2/hchannel.c
helpmod2/hcommands.c
helpmod2/hconf.c
helpmod2/hdef.h
helpmod2/helpmod.c
helpmod2/helpmod.db
helpmod2/helpmod.h
helpmod2/hgen.c
helpmod2/hgen.h
helpmod2/hhooks.c
helpmod2/hlamer.c
helpmod2/hlamer.h
helpmod2/hqueue.c
helpmod2/hstat.c
helpmod2/hstat.h

index e8cc8cff61133175dcc26d2f31a5b1d9b6579cb7..6b01535e713b33fa1b107e88018573edc3c57830 100644 (file)
@@ -222,3 +222,62 @@ Added a new acconf option to suppress the unknown command error
 Checkchannel command changed according to requests
 Showcommands now lists the commands in a bit more ordered fashion
 Top10 now prints the time spent fields in a different order
+
+2.05
+Termstats now really really work (sort order fixed)
+Checkchannel now shows +o/+v and sorts the output based on those
+Checkchannel now tells the % of users authed on the channel
+Fixed the admin command description
+Checkchannel no longer shows +k channels
+Banning lamers (userlevel H_LAMER) on join now works properly
+Users no longer receive the "your userlevel has been changed" when changed to lamer
+Some code cleanup
++h users are now excluded from idle user removal
+Queue on/off when queue is in the desired state no longer produces a channel message
+Censor del can now remove patterns other than the first
+Fixed a minor typo in invite messaging
+Non-opered staff can now invite themselves to oper-only channels they have tickets to
+A month is now 30 days instead of 30 weeks
+Queue message wording changed a bit
+Fixed a bug in the command help
+
+2.06
+The voiced count in checkchannel is now correct
+Time printing was changed a bit
+Account name is now shown correctly in checkchannel
+Added a sanity check to stats calculation
+Fixed a bug when reading/writing stats from disk
+Statistics printing fields widened a bit
+Changed ban expiration printing
+statsdebug command is now statsdump
+Added a statsrepair command
+All normal users are now devoiced when the queue is turned off
+Fixed a typo in the kick command
+Out command now accepts an optional reason
+Normal users no longer receive errors for commands issued on channels
+Incorrect term find reply is now fixed
+Added sanity checking to account adding
+Fixed some command help files
+
+2.07
+top10 number parameter now works
+top10 should now work
+top10 listing order changed a bit
+Statistics should now work better
+
+2.08
+Kick and out command replies changed a bit
+Some code cleanup, mostly void* stuff removed
+Added a statsreset command
+Fixed a bug with weekly calculation of stats
+
+2.09
+Fixed a minor bug in channel daily report
+Changed report interval from 5 minutes to one hour
+Passive state support improved
+Fixed the time print bug
+The +k restriction in checkchannel was removed
+Tickets command wording changed a bit
+Fixed a typo in showticket command
+Checkchannel does not show channel topic for +i/+k channels
+Some command descriptions changed
index a31eb3382781c57ff3e723deba465b51290c98d1..a2bfd607b85c03275168edfd5ad5031df83dd7ef 100644 (file)
@@ -2,4 +2,4 @@ Syntax:  acconf [[+/-]value1] ... [[+/-]valuen]
 Example: acconf +1 -3
 Acconf configures the account specific H features.
 Up to 6 values can be changed with one command.
-When called without parameters, acconf will print your account configuration.
\ No newline at end of file
+When called without parameters, acconf will print your account configuration.
index 116ccd9200198f0939c6a64c60759a5b821aecac..dc008d5b6ef71a921bd09b8dd582df9e3c350dd0 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  addchan [channel]
 Example: addchan #help
 Adds H to the given channel.
-Don't forget to configure the channel using chanconf as the default configuration is most likely not what you want.
\ No newline at end of file
+Don't forget to configure the channel using chanconf as the default configuration is most likely not what you want.
index 82772fd8852f4e4e69259788e386504c597108ef..f863da5db3f549372ebd7062f9a20caf0fe66d47 100644 (file)
@@ -1,3 +1,3 @@
 Syntax:  aliases
 Example: aliases
-Lists all aliases to the help system
\ No newline at end of file
+Lists all aliases to the help system
index db4be29b7eaec151f30a362f3d32e897ef136c69..77a4a8663824b605a2430619960beef1f6e2c66e 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  autoqueue [channel] [amount]
 Example: autoqueue #feds 2
 Same as 'queue maintain'.
-Sets the autoqueue for the channel, autoqueue can be disabled with value of 0.
\ No newline at end of file
+Sets the autoqueue for the channel, autoqueue can be disabled with value of 0.
index 7dddaca14b07a1e553148e4fcd05681f4f00f4d5..212c448ea007bee55332826149fd343aa51cf798 100644 (file)
@@ -4,4 +4,4 @@ Handles global bans.
 Following operations are supported:
 list    [pattern]                       Lists global bans based on pattern, if pattern is omitted all bans are listed
 add     [mask] [duration] [reason]      Adds a global ban, duration and reason are optional
-del     [mask1] ... [maskn]             Removes global banmasks, up to 6 masks can be defined at once
\ No newline at end of file
+del     [mask1] ... [maskn]             Removes global banmasks, up to 6 masks can be defined at once
index 69f1cca24ed1950c2bb74a55c515729ce78bf235..5f971935a0c5df664c6f9a935766411d5ee0ba99 100644 (file)
@@ -4,4 +4,4 @@ Handles the censor for a channel. Censor allows certain patterns to result in an
 Following operations are supported:
 add [pattern] [reason]   Adds the pattern to censor with the given reason
 del [#pattern]           Removes the pattern for the index
-If no operation or parameters are specified, all censor entries are listed.
\ No newline at end of file
+If no operation or parameters are specified, all censor entries are listed.
index 00fce3fa88ba59d44144cbd79166b145dc510557..72d83da89faa3340099669e13545db4bf58a950c 100644 (file)
@@ -4,4 +4,4 @@ Handles channel bans. Following operations are supported:
 add [mask1] .. [maskn]  Adds bans to channel
 del [mask1] .. [maskn]  Removes bans from channel 
 list [pattern]          Lists bans matching pattern
-Up to 6 masks can be given for add and del.
\ No newline at end of file
+Up to 6 masks can be given for add and del.
index 9b6924920da49a50095f5c0c4cc745801d0082dd..53ca00b3da057c2f9a89b4c6f739a14e2a5ba885 100644 (file)
@@ -4,4 +4,4 @@ Handles channel configuration. Chanconf is used to enable and disable H features
 Most features are configured by their own command but are enabled from chanconf.
 Chanconf without parameters lists channel configuration.
 Up to 6 values can be disabled or enabled at once.
-NOTE: chanconf value 0 (passive mode) completely disables any H activity for a channel, it is provided as a way to disable H without delchan.
\ No newline at end of file
+NOTE: chanconf value 0 (passive mode) completely disables any H activity for a channel, it is provided as a way to disable H without delchan.
index 55e55e6daba864808218eb44d2229bcc30e4eac7..65d396a24a923f9a9db331ca28b10ee113f59856 100644 (file)
@@ -2,4 +2,4 @@ Syntax:  delchan [channel] YesImSure
 Example: delchan #feds.fi YesImSure
 Deletes H from the channel.
 All data related to the channel is removed.
-The YesImSure is an additional parameter to protect against accidents.
\ No newline at end of file
+The YesImSure is an additional parameter to protect against accidents.
index 1dbd542f156e92f633f4c532d4f496f3ab339e05..472704a0dc922525107b646a219c84fe2e937dc0 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  dequeue [channel]
 Example: dequeue #feds
 Same as 'queue off'.
-Turns the queue off for the given channel.
\ No newline at end of file
+Turns the queue off for the given channel.
index f8a2ca7d6e3ba08186473a60e1b2db16e7b31fd0..b06564c58226e25d000d1074d35dc9715cec2e5d 100644 (file)
@@ -2,4 +2,4 @@ Syntax:  dnmo [nick1] ... [nickn]
 Example: dnmo CS^kiddie
 dnmo (DoNotMessageOpers) is meant to be used with the H queue system.
 When used, the target is set to the last position on any channels where he/she is on queue.
-Target is also sent a message explaining the error of his/her lame behaviour.
\ No newline at end of file
+Target is also sent a message explaining the error of his/her lame behaviour.
index 9cf665ea2ed7e214921a2d5145b67f32782ff99f..46477e759df4c16372fd2d5abdaf5665a96023ca 100644 (file)
@@ -2,4 +2,4 @@ Syntax:  done [channel] [nick1 .. nickn]
 Example: done #feds user
 Same as 'queue done'.
 Tells that the user is finished with and devoices him.
-Up to 6 nicks can be specified.
\ No newline at end of file
+Up to 6 nicks can be specified.
index 10a018a5f277e58f63128a6f3a4b4e6df729a2d9..d69947a57ba0bd0746a40db0e26f3fae0b861ba1 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  enqueue [channel]
 Example: enqueue #feds
 Same as 'queue on'.
-Turns the queue on for the given channel.
\ No newline at end of file
+Turns the queue on for the given channel.
index dab8cb2d8bcac0bea4cd8dd164954c885792a637..920e3fe364d69c7ed794219b3535ef8d904b9403 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  everyoneout [channel] [reason]
 Example: everyoneout #feds enough laming
 Removes all normal users from the channel and sets H to enforce +i on the channel.
-If reason is omitted the default reason is 'clearing channel'.
\ No newline at end of file
+If reason is omitted the default reason is 'clearing channel'.
index 5c4f388a1c375fd17a7b41f43cfc26b6f95b98e3..d60fda0537092792d3da179b7af0e25af62edc08 100644 (file)
@@ -2,4 +2,4 @@ Syntax:  idlekick [channel] [timeout]
 Example: idlekick #feds 60s
 Views or sets the idle kick timeout for the channel.
 Minimum value is 60 seconds, the actual timeout is "close enough" to the timeout value.
-Non-peons and Users currently in queue are not considered idle.
\ No newline at end of file
+Non-peons and Users currently in queue are not considered idle.
index 39d8298293ce3f7ddc73dc0464f8e9f7d02c94db..7943c9f2e3fa63d22e79363d74b6e81cd46932c1 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  kick [channel] [nick1] ... [nickn] :[reason]
 Example: kick #feds luser
 Kicks the target nick from the channel. Reason is optional.
-Up to 6 targets can be specified.
\ No newline at end of file
+Up to 6 targets can be specified.
index 6acd524aed2ec1ea13a55c960a8fc778ec693b32..6d6cc7a5e89e847f55e6fc886f519f57910a6f87 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  klingon [channel] [user]
 Example: klingon #feds
 Makes H say something in klingon on the channel.
-If a user is specified the message is targeted to that user.
\ No newline at end of file
+If a user is specified the message is targeted to that user.
index 18757b31f99fd6785b5b136beae6fd32c12e587f..82146c00640df10978c8193bbb257463829d9e0d 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  lamercontrol [channel]
 Example: lamercontrol #feds strict
 Views or sets the lamercontrol profile for a channel.
-To list all available lamercontrol profiles, use the keyword list.
\ No newline at end of file
+To list all available lamercontrol profiles, use the keyword list.
index c969fed7d829440d288bc2f06f19e937d98b94a4..20346af0486e6b6d68dd5078339bae639defbf62 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  listuser [pattern]
 Example: listuser *
 Lists H accounts based on the pattern.
-If no pattern is specified, all accounts are listed.
\ No newline at end of file
+If no pattern is specified, all accounts are listed.
index 9893717663685a441b698d9b9f44436857524d72..5350e856471834836823e92d3def51c413e569bf 100644 (file)
@@ -1,3 +1,3 @@
 Syntax:  load [filename]
 Example: load database1
-Loads a new help database (help command). Users currently using the help system are reset.
\ No newline at end of file
+Loads a new help database (help command). Users currently using the help system are reset.
index cf7d097beea5091b97d09e740834d3ac54664276..95e706740fa39cda54d14c579f1495bf7d8c6a73 100644 (file)
@@ -1,3 +1,3 @@
 Syntax:  message <channel> <message>
 Sends a message to the channel. The message sent is prefixed with your nick. 
-G must be on the channel the message is sent to.
\ No newline at end of file
+G must be on the channel the message is sent to.
index 795f19fbf218833950bbc9a92b1bd36bd548b0cb..c0416e19201a13ffd6b960f7ddb2714bac55d211 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  next [channel] [amount]
 Example: next #feds 2
 Same as 'queue next'.
-Moves the queue forward by the given amount.
\ No newline at end of file
+Moves the queue forward by the given amount.
index 4fe29a8aa5b9ee343f748660e09af600a624abd9..cadd54cdf4609664f25d97454317bae1bb9f7401 100644 (file)
@@ -1,5 +1,5 @@
-Syntax:  out [nick1 ... nickn]
-Example: out luser
+Syntax:  out [nick1 ... nickn] :[reason]
+Example: out luser :Enough complaining
 Removes an unwanted user from H visibility.
-Sets a short duration ban to keep the user away.
+Sets a short duration ban to keep the user away. Reason is optional.
 Up to 6 users can be specified.
index c608d2f268a3dab515415ff32c661ba04f3fabfc..e96ada0dc828f99cf6d9ed5e2cbb5982cd4ed0d7 100644 (file)
@@ -9,4 +9,4 @@ maintain [amount]       Automatic queue, keeps a constant amount of users voiced
 list                    Lists all users in queue
 summary                 Gives a short summary of the queues status
 reset                   Resets the queue
-Some common commands like done or next have a shortcut, see showcommands for a list.
\ No newline at end of file
+Some common commands like done or next have a shortcut, see showcommands for a list.
index b88cfe1d9808840a71f299af980ca78466f7ff9b..874d3f2df8d0e3b79587f8657fa7d141c7cd7a46 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  report [channel of] [channel to]
 Example: report #feds #qnet.feds
 Sets the channel where some channel statistics are reported every 5 minutes.
-H must be active on both the source and the target channel.
\ No newline at end of file
+H must be active on both the source and the target channel.
index 1eb016f428670bbf7487b0fa71bf56b5f4593c90..3cc266445c3699e3a756b66948e2e58102e68eca 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  showcommands [level]
 Example: showcommands
 Lists all commands available to the given level.
-If the level is invalid or higher than yours, commands available to your userlevel are printed.
\ No newline at end of file
+If the level is invalid or higher than yours, commands available to your userlevel are printed.
index c032719434706ae985beda13a35a0534dad7ed41..0b67c90edfb0725fca874cc07f9634062e298448 100644 (file)
@@ -3,4 +3,4 @@ Example: stats #feds short 7 1
 Gives your statistics for a channel. Type must be either short or long.
 Parameters ndays and nweeks tell how many lines of statistics to print. Statistics are kept for a duration of 10 weeks.
 Default is to print the short statistics for the last day.
-Statistics of other users are only available to administrators.
\ No newline at end of file
+Statistics of other users are only available to administrators.
index b1cb02eba801972533e03922280aca2d43bd9c79..749a8f7dc6dfb146c9fa1523301d959aae5af3e8 100644 (file)
@@ -1,3 +1,3 @@
 Syntax:  status
 Example: status
-Gives some service status information
\ No newline at end of file
+Gives some service status information.
index f7c9e7e0d407574509185694147b91caf5ef98a5..0c2bdbb8e731bc16826c7450d2cadf6119bc2fdb 100644 (file)
@@ -8,4 +8,4 @@ get             [term]                   Gets a specific term
 find            [pattern]                Returns the first term matching the pattern
 list                                     Lists all term names
 listfull                                 Lists all terms with their descriptions
-Command '?' is available to all users and is the same as term [channel] find.
\ No newline at end of file
+Command '?' is available to all users and is the same as term [channel] find.
index 20d2ff1350c05c9f8d167d6b1026647e1a7b8f9b..51f13008744423b4f55e8a608f916aeed3d24caa 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  welcome [channel] [new message]
 Example: welcome #feds welcome to #feds, may we recommend a good book while you're in queue ?
 Views or sets the channel welcome message.
-When called with just the channel name, the welcome message for the channel is printed.
\ No newline at end of file
+When called with just the channel name, the welcome message for the channel is printed.
index 3e3a97e53434b22c38f5732eb9d4187f80f6779d..95ca40414dc1c4fb4591883c4e523b3ba9bc175d 100644 (file)
@@ -1,4 +1,4 @@
 Syntax:  whois [nick1] ... [nickn]
 Example: whois user
 Gives the information H has on a user.
-Up to 6 nicks can be specified.
\ No newline at end of file
+Up to 6 nicks can be specified.
index 3bb649e3ffb83f2f88782bf1659c61705acbf455..47c93152ed881584f1bc213a4d2c48680b176e4d 100644 (file)
@@ -33,6 +33,12 @@ haccount *haccount_add(const char *name, hlevel lvl)
 {
     haccount *tmp = (haccount*)malloc(sizeof (haccount));
 
+    if (haccount_get_by_name(name))
+    {
+       Error("helpmod", ERR_ERROR, "Attempt to add a duplicate account: %s", name);
+       return haccount_get_by_name(name);
+    }
+
     if (*name == '#')
         name++;
 
index 51424bd594a9488c39a2051097eb6848925a29a6..81ded2057fe724a08d5beb84ccfeaa82a5814431 100644 (file)
@@ -60,12 +60,9 @@ hban *hban_add(const char* pat, const char* rsn, time_t exp, int now)
     return ptr;
 }
 
-hban *hban_huser(void *target, const char* rsn, time_t exp, int now)
+hban *hban_huser(huser *husr, const char* rsn, time_t exp, int now)
 {
-    const char *banmask;
-    huser *husr = (huser*)target;
-
-    banmask = hban_ban_string(husr->real_user, HBAN_HOST);
+    const char *banmask = hban_ban_string(husr->real_user, HBAN_HOST);
 
     return hban_add(banmask, rsn, exp, now);
 }
index 0822d05394bcf725306467ae87b749aa5b596238..ea16437728442e91e2dc46c7852b639a65f6e58d 100644 (file)
@@ -4,11 +4,12 @@
 #include <time.h>
 
 #include "../channel/channel.h"
-
 #include "../nick/nick.h"
-
 #include "../lib/sstring.h"
 
+/* Forward declarations */
+struct huser_struct;
+
 typedef struct hban_struct
 {
     chanban *real_ban;
@@ -34,7 +35,7 @@ hban *hban_get(const char*);
 
 int hban_count(void);
 /* the first parameter is huser* */
-hban *hban_huser(void*, const char*, time_t, int);
+hban *hban_huser(struct huser_struct*, const char*, time_t, int);
 
 hban *hban_check(nick*);
 
index aedffe0da3ca93620c705244fc691d0584afbf45..180f2076935cebc2ab1bb59ef22a3f8a5fb93aef 100644 (file)
@@ -54,12 +54,10 @@ hchanban *hchanban_get(hchannel* hchan, const char* banmask)
     return NULL;
 }
 
-void hchanban_schedule_entry(void* ptr)
+void hchanban_schedule_entry(hchanban* item)
 {
-    hchanban *item = (hchanban*)ptr;
-
     if (hchannel_is_valid(item->hchan))
         helpmod_setban(item->hchan, item->banmask->content, 0, MCB_DEL, HNOW);
 
-    hchanban_del(ptr);
+    hchanban_del(item);
 }
index 2f4ad0726e89f69845a884fd78a75d1c220dc7ff..31c327ddd971773e06c5eb659ef8f62e3dd6d437 100644 (file)
@@ -22,6 +22,6 @@ hchanban *hchanban_del_all(void);
 
 hchanban *hchanban_get(hchannel*, const char*);
 
-void hchanban_schedule_entry(void*);
+void hchanban_schedule_entry(hchanban*);
 
 #endif
index 266157873bf1660d07dfa19c0424b7d18682c92b..1503c0a42c794e4c6c504552859b6fbe5225bd4e 100644 (file)
@@ -449,6 +449,7 @@ void hchannel_activate_join_flood(hchannel *hchan)
 
     scheduleoneshot(time(NULL) + 60, &hchannel_deactivate_join_flood, NULL);
 }
+
 /* goes to schedule */
 void hchannel_deactivate_join_flood()
 {
@@ -459,14 +460,6 @@ void hchannel_deactivate_join_flood()
             helpmod_simple_modes(hchan, 0, CHANMODE_REGONLY, 1);
             hchan->flags &= ~H_JOIN_FLOOD;
         }
-        /*if (IsRegOnly(hchan->real_channel) && hchan->jf_control < time(NULL))
-        {
-            helpmod_simple_modes(hchan, 0, CHANMODE_REGONLY, 1);
-            return;
-        }
-
-     scheduleoneshot(time(NULL) + 60, &hchannel_deactivate_join_flood, NULL);
-     */
 }
 
 const char *hchannel_get_sname(int flag)
@@ -517,6 +510,6 @@ const char *hchannel_get_sname(int flag)
     case 19:
         return "Require a ticket to join";
     default:
-        return "error, please contact strutsi";
+        return "Error, please contact strutsi";
     }
 }
index fedc9bf6efd4ab42cdeb37eed788284251e6a0e1..d2cf9247e0c307d16db8f73ae090dcde9dac9ef5 100644 (file)
@@ -299,7 +299,7 @@ static void helpmod_cmd_change_userlevel(huser *sender, hlevel target_level, cha
 
     if (argc == 0)
     {
-        helpmod_reply(sender, returntype, "Incorrect syntax, nick or account required");
+       helpmod_reply(sender, returntype, "Incorrect syntax: Nick or account required");
         return ;
     }
 
@@ -1066,7 +1066,7 @@ static void helpmod_cmd_term (huser *sender, channel* returntype, char* ostr, in
 
         if (htrm == NULL)
         {
-            helpmod_reply(sender, returntype, "No term found matching '%s'", argv[0]);
+            helpmod_reply(sender, returntype, "No term found matching '%s'", argv[1]);
             return;
         }
         if (returntype != NULL && huser_get_level(sender) > H_PEON)
@@ -1510,6 +1510,10 @@ static void helpmod_cmd_out (huser *sender, channel* returntype, char* ostr, int
 {
     huser *husr;
     int i;
+    char *reason = "Banned";
+    huser *targets[H_CMD_MAX_ARGS];
+    int ntargets = 0;
+
     if (argc == 0)
     {
         helpmod_reply(sender, returntype, "Can not get rid of the user: User not specified");
@@ -1520,7 +1524,22 @@ static void helpmod_cmd_out (huser *sender, channel* returntype, char* ostr, int
         argc = H_CMD_MAX_ARGS;
     for (i=0;i<argc;i++)
     {
-        husr = huser_get(getnickbynick(argv[i]));
+       if (argv[i][0] == ':')
+       {
+           if (i == 0)
+           {
+               helpmod_reply(sender, returntype, "Can not get rid of users: No users specified");
+               return;
+           }
+           while (i--)
+           {
+               SKIP_WORD;
+           }
+           reason = ostr + 1;
+           break;
+       }
+
+       husr = huser_get(getnickbynick(argv[i]));
         if (husr == NULL)
         {
             helpmod_reply(sender, returntype, "Can not get rid of the user: User %s not found", argv[i]);
@@ -1530,13 +1549,17 @@ static void helpmod_cmd_out (huser *sender, channel* returntype, char* ostr, int
         {
             helpmod_reply(sender, returntype, "Can not get rid of the user: User %s is not a peon", husr->real_user->nick);
             continue;
-        }
-        {
-            const char *banmask = hban_ban_string(husr->real_user, HBAN_HOST);
+       }
+        targets[ntargets++] = husr;
+    }
 
-            hban_add(banmask, "Banned", time(NULL) + HCMD_OUT_DEFAULT, 0);
-        }
-        helpmod_reply(sender, returntype, "User %s is now gone", husr->real_user->nick);
+    for (i=0;i<ntargets;i++)
+    {
+       const char *banmask = hban_ban_string(targets[i]->real_user, HBAN_HOST);
+
+       hban_add(banmask, reason, time(NULL) + HCMD_OUT_DEFAULT, 0);
+
+       helpmod_reply(sender, returntype, "User %s is now gone", targets[i]->real_user->nick);
     }
 }
 
@@ -1589,7 +1612,7 @@ static void helpmod_cmd_kick (huser *sender, channel* returntype, char* ostr, in
 {
     hchannel *hchan;
     int i;
-    huser *husr, *targets[6];
+    huser *husr, *targets[H_CMD_MAX_ARGS];
     int ntargets = 0;
     char *reason = "out";
     DEFINE_HCHANNEL;
@@ -1599,15 +1622,27 @@ static void helpmod_cmd_kick (huser *sender, channel* returntype, char* ostr, in
     if (hchan == NULL)
     {
         helpmod_reply(sender, returntype, "Can not kick the user: Channel not defined or not found");
-        return;
+       return;
+    }
+
+    if (argc == 0)
+    {
+       helpmod_reply(sender, returntype, "Can not kick users: No users specified");
+       return;
     }
+
     if (argc > H_CMD_MAX_ARGS)
         argc = H_CMD_MAX_ARGS;
     for (i=0;i<argc;i++)
     {
         if (*argv[i] == ':')
         {
-            while (i--)
+           if (i == 0)
+           {
+               helpmod_reply(sender, returntype, "Can not kick the user: No users defined");
+               return;
+           }
+           while (i--)
             {
                 SKIP_WORD;
             }
@@ -1622,7 +1657,7 @@ static void helpmod_cmd_kick (huser *sender, channel* returntype, char* ostr, in
         }
         if (huser_on_channel(husr, hchan) == NULL)
         {
-            helpmod_reply(sender, returntype, "Can not kick the user: User %s is on channel", husr->real_user->nick, hchannel_get_name(hchan));
+            helpmod_reply(sender, returntype, "Can not kick the user: User %s is not on channel %s", husr->real_user->nick, hchannel_get_name(hchan));
             continue;
         }
         if (huser_get_level(husr) > H_PEON)
@@ -1632,11 +1667,7 @@ static void helpmod_cmd_kick (huser *sender, channel* returntype, char* ostr, in
         }
         targets[ntargets++] = husr;
     }
-    if (!ntargets)
-    {
-        helpmod_reply(sender, returntype, "Can not kick the user: No users defined");
-        return;
-    }
+
     for (i=0;i<ntargets;i++)
         helpmod_kick(hchan, targets[i], reason);
 }
@@ -1858,7 +1889,7 @@ static void helpmod_cmd_chanstats (huser *sender, channel* returntype, char* ost
         for (i=0;i<weeks;i++) /* latest weeks */
         {
             stat_entry = &hchan->stats->longterm[(hstat_week() - i + 10)  % 10];
-            helpmod_reply(sender, returntype, "%s", hstat_channel_print(stat_entry, type));
+           helpmod_reply(sender, returntype, "%s", hstat_channel_print(stat_entry, type));
         }
     }
 }
@@ -1949,7 +1980,7 @@ static void helpmod_cmd_top10 (huser *sender, channel* returntype, char* ostr, i
         else if (!ci_strcmp(argv[0], "staff") || !ci_strcmp(argv[0], "s"))
             lvl = H_STAFF;
     }
-    if (argc == 2)
+    if (argc == 3)
     {
         int tmp;
         if (sscanf(argv[1], "%d", &tmp) && (tmp >= 10) && (tmp <= 50))
@@ -1960,7 +1991,7 @@ static void helpmod_cmd_top10 (huser *sender, channel* returntype, char* ostr, i
 
     helpmod_reply(sender, returntype, "Top%d most active %ss of channel %s", top_n, hlevel_name(lvl), hchannel_get_name(hchan));
     for (i=0;i < arr.arrlen && i < top_n;i++)
-        helpmod_reply(sender, returntype, "#%-2d %-20s %-20s %-20s",i+1,((haccount*)(arr.array[i].owner))->name->content, helpmod_strtime(arr.array[i].time_spent), helpmod_strtime(arr.array[i].prime_time_spent));
+       helpmod_reply(sender, returntype, "#%-2d %-20s %-20s %-20s",i+1,((haccount*)(arr.array[i].owner))->name->content, helpmod_strtime(arr.array[i].prime_time_spent), helpmod_strtime(arr.array[i].time_spent));
 
     free(arr.array);
 }
@@ -2367,7 +2398,7 @@ static void helpmod_cmd_tickets (huser *sender, channel* returntype, char* ostr,
     for (i = 0;htick;htick = htick->next, i++)
         helpmod_reply(sender, returntype, "%4d %16s %48s", i, htick->authname, helpmod_strtime(time(NULL) - htick->time_expiration));
 
-    helpmod_reply(sender, returntype, "Done listing tickets. Channel %s had %d valid tickets", hchannel_get_name(hchan), i);
+    helpmod_reply(sender, returntype, "Done listing tickets. Channel %s had %d valid ticket%s", hchannel_get_name(hchan), i, (i==1)?"":"s");
 }
 
 static void helpmod_cmd_showticket (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
@@ -2408,7 +2439,7 @@ static void helpmod_cmd_showticket (huser *sender, channel* returntype, char* os
             helpmod_reply(sender, returntype, "Can not show the ticket: User %s does not have a valid ticket for channel %s", argv[i], hchannel_get_name(hchan));
             continue;
         }
-        helpmod_reply(sender, returntype, "User %s has a ticket for chanenl %s expiring in %s", argv[i], hchannel_get_name(hchan), helpmod_strtime(htick->time_expiration - time(NULL)));
+        helpmod_reply(sender, returntype, "User %s has a ticket for channel %s expiring in %s", argv[i], hchannel_get_name(hchan), helpmod_strtime(htick->time_expiration - time(NULL)));
     }
 }
 
@@ -2501,12 +2532,6 @@ static void helpmod_cmd_checkchannel(huser *sender, channel* returntype, char* o
     if (argc > 1 && !ci_strcmp(argv[1], "summary"))
         summary_only = 1;
 
-    if (IsKey(chan))
-    {
-       helpmod_reply(sender, returntype, "Can not check channel: Permission denied. Channel %s is +k", argv[0]);
-        return;
-    }
-
     /* first pass - verify validity and count nicks */
     for (i=0;i < chan->users->hashsize;i++)
     {
@@ -2548,7 +2573,8 @@ static void helpmod_cmd_checkchannel(huser *sender, channel* returntype, char* o
 
     helpmod_reply(sender, returntype, "Information on channel %s", argv[0]);
     helpmod_reply(sender, returntype, "Channel created %s ago", helpmod_strtime(time(NULL) - chan->timestamp));
-    helpmod_reply(sender, returntype, "Channel topic: %s", chan->topic?chan->topic->content:"Not set");
+    if (!IsKey(chan) && !IsInviteOnly(chan))
+       helpmod_reply(sender, returntype, "Channel topic: %s", chan->topic?chan->topic->content:"Not set");
     helpmod_reply(sender, returntype, "Channel modes: %s", printflags(chan->flags, cmodeflags));
 
 
@@ -2576,17 +2602,17 @@ static void helpmod_cmd_checkchannel(huser *sender, channel* returntype, char* o
 
            visiblehostmask(getnickbynumeric(numeric_array[i]), buf);
            if (IsAccount(getnickbynumeric(numeric_array[i])))
-               helpmod_reply(sender, returntype, "%c%s (%s)", status, buf, getnickbynumeric(numeric_array[i]));//nick_array[i]->authname);
+               helpmod_reply(sender, returntype, "%c%s (%s)", status, buf, getnickbynumeric(numeric_array[i])->authname);//nick_array[i]->authname);
            else
                helpmod_reply(sender, returntype, "%c%s", status, buf);
        }
 
-    helpmod_reply(sender, returntype, "Users: %d  Clones: %d  Opped: %d  Voiced: %d  Authed: %3.0f%%", nick_count, nick_count - countuniquehosts(chan), o_limit, o_limit - v_limit, ((float)authed_count / (float)nick_count) * 100.0);
+    helpmod_reply(sender, returntype, "Users: %d  Clones: %d  Opped: %d  Voiced: %d  Authed: %3.0f%%", nick_count, nick_count - countuniquehosts(chan), o_limit, v_limit - o_limit, ((float)authed_count / (float)nick_count) * 100.0);
 
     free(numeric_array);
 }
 
-static void helpmod_cmd_statsdebug (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
+static void helpmod_cmd_statsdump (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
 {
     haccount *hacc = haccounts;
     hstat_account *ptr;
@@ -2605,6 +2631,158 @@ static void helpmod_cmd_statsdebug (huser *sender, channel* returntype, char* os
         }
 }
 
+static void helpmod_cmd_statsrepair (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
+{
+    haccount *hacc = haccounts;
+    hstat_account *ptr;
+    int i;
+
+    helpmod_reply(sender, returntype, "Repairing account statistics");
+    for (;hacc;hacc = hacc->next)
+        for (ptr = hacc->stats;ptr;ptr = ptr->next)
+       {
+           for (i = 0;i < 7;i++)
+           {
+               if (ptr->week[i].time_spent > HDEF_d)
+               {
+                   ptr->week[i].time_spent = 0;
+                   helpmod_reply(sender, returntype, "repaired short term TimeSpent %s @ %s : Greater than one day",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+               if (ptr->week[i].time_spent < 0)
+               {
+                   ptr->week[i].time_spent = 0;
+                   helpmod_reply(sender, returntype, "repaired short term TimeSpent %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+
+               if (ptr->week[i].prime_time_spent > HDEF_d)
+               {
+                   ptr->week[i].prime_time_spent = 0;
+                   helpmod_reply(sender, returntype, "repaired short term PrimeTimeSpent %s @ %s : Greater than one day",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }                    
+               if (ptr->week[i].prime_time_spent < 0)
+               {
+                   ptr->week[i].prime_time_spent = 0;
+                   helpmod_reply(sender, returntype, "repaired short term PrimeTimeSpent %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+
+               if (ptr->week[i].lines > 10000)
+               {
+                   ptr->week[i].lines = 0;
+                   helpmod_reply(sender, returntype, "repaired short term Lines %s @ %s : Greater than 10000",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+               if (ptr->week[i].lines < 0)
+               {
+                   ptr->week[i].lines = 0;
+                   helpmod_reply(sender, returntype, "repaired short term Lines %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+
+               if (ptr->week[i].words > 50000)
+               {
+                   ptr->week[i].words = 0;
+                   helpmod_reply(sender, returntype, "repaired short term Words %s @ %s : Greater than 50000",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+               if (ptr->week[i].words < 0)
+               {
+                   ptr->week[i].words = 0;
+                   helpmod_reply(sender, returntype, "repaired short term Words %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+           }
+           for (i = 0;i < 10;i++)
+           {
+               if (ptr->longterm[i].time_spent > HDEF_w)
+               {
+                   ptr->longterm[i].time_spent = 0;
+                   helpmod_reply(sender, returntype, "repaired long term TimeSpent %s @ %s : Greater than one week",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+               if (ptr->longterm[i].time_spent < 0)
+               {
+                   ptr->longterm[i].time_spent = 0;
+                   helpmod_reply(sender, returntype, "repaired long term TimeSpent %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+
+               if (ptr->longterm[i].prime_time_spent > HDEF_w)
+               {
+                   ptr->longterm[i].prime_time_spent = 0;
+                   helpmod_reply(sender, returntype, "repaired long term PrimeTimeSpent %s @ %s : Greater than one week",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }                    
+               if (ptr->longterm[i].prime_time_spent < 0)
+               {
+                   ptr->longterm[i].prime_time_spent = 0;
+                   helpmod_reply(sender, returntype, "repaired long term PrimeTimeSpent %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+
+               if (ptr->longterm[i].lines > 50000)
+               {
+                   ptr->longterm[i].lines = 0;
+                   helpmod_reply(sender, returntype, "repaired long term Lines %s @ %s : Greater than 50000",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+               if (ptr->longterm[i].lines < 0)
+               {
+                   ptr->longterm[i].lines = 0;
+                   helpmod_reply(sender, returntype, "repaired long term Lines %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+
+               if (ptr->longterm[i].words > 50000)
+               {
+                   ptr->longterm[i].words = 0;
+                   helpmod_reply(sender, returntype, "repaired long term Words %s @ %s : Greater than 50000",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+               if (ptr->longterm[i].words < 0)
+               {
+                   ptr->longterm[i].words = 0;
+                   helpmod_reply(sender, returntype, "repaired long term Words %s @ %s : Less than zero",hacc->name->content, hchannel_get_name(ptr->hchan));
+               }
+           }
+       }
+    helpmod_reply(sender, returntype, "Account statistics repaired");
+
+}
+
+static void helpmod_cmd_statsreset (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
+{
+    haccount *hacc = haccounts;
+    hstat_account *ptr;
+    hchannel *hchan;
+    int i, short_del, long_del;
+
+    if (argc < 2)
+    {
+       helpmod_reply(sender, returntype, "Insufficient parameters");
+       return;
+    }
+
+    if (sscanf(argv[0], "%d", &short_del) == 0)
+    {
+       helpmod_reply(sender, returntype, "Invalid parameter");
+       return;
+    }
+    if (sscanf(argv[1], "%d", &long_del) == 0)
+    {
+       helpmod_reply(sender, returntype, "Invalid parameter");
+       return;
+    }
+
+    for (;hacc;hacc = hacc->next)
+        for (ptr = hacc->stats;ptr;ptr = ptr->next)
+       {
+            for (i = 1;i < short_del + 1;i++)
+               HSTAT_ACCOUNT_ZERO(ptr->week[(hstat_day() + i) % 7]);
+           for (i = 1;i < long_del + 1;i++)
+                HSTAT_ACCOUNT_ZERO(ptr->longterm[(hstat_week() + i) % 10]);
+       }
+
+    for (hchan = hchannels;hchan;hchan = hchan->next)
+    {
+       for (i = 1;i < short_del + 1;i++)
+           HSTAT_CHANNEL_ZERO(hchan->stats->week[(hstat_day() + i) % 7]);
+       for (i = 1;i < long_del + 1;i++)
+           HSTAT_CHANNEL_ZERO(hchan->stats->longterm[(hstat_week() + i) % 10]);
+
+    }
+
+    helpmod_reply(sender, returntype, "Statistics reset complete");
+}
+
 static void helpmod_cmd_message (huser *sender, channel* returntype, char* ostr, int argc, char *argv[])
 {
     hchannel *hchan;
@@ -2796,11 +2974,11 @@ void hcommands_add(void)
     hcommand_add("staff", H_OPER, helpmod_cmd_staff, "Sets the userlevel of the target to staff (lvl 3)");
     hcommand_add("oper", H_OPER, helpmod_cmd_oper, "Sets the userlevel of the target to oper (lvl 4)");
     hcommand_add("admin", H_ADMIN, helpmod_cmd_admin, "Sets the userlevel of the target to admin (lvl 5)");
-    hcommand_add("deluser", H_OPER, helpmod_cmd_deluser, "Removes an account from H");
-    hcommand_add("listuser", H_STAFF, helpmod_cmd_listuser, "Lists user accounts of H");
+    hcommand_add("deluser", H_OPER, helpmod_cmd_deluser, "Removes an account from " HELPMOD_NICK);
+    hcommand_add("listuser", H_STAFF, helpmod_cmd_listuser, "Lists user accounts of " HELPMOD_NICK);
 
     hcommand_add("chanconf", H_STAFF, helpmod_cmd_chanconf, "Channel configuration");
-    hcommand_add("acconf", H_TRIAL, helpmod_cmd_acconf, "Personalise H behaviour");
+    hcommand_add("acconf", H_TRIAL, helpmod_cmd_acconf, "Personalise " HELPMOD_NICK " behaviour");
     hcommand_add("welcome", H_STAFF, helpmod_cmd_welcome, "Views or changes the channel welcome message");
     hcommand_add("censor", H_STAFF, helpmod_cmd_censor, "Handles the censored patterns for a channel");
 
@@ -2833,11 +3011,11 @@ void hcommands_add(void)
     hcommand_add("top10", H_STAFF, helpmod_cmd_top10, "Shows the top 10 most active staff");
     hcommand_add("report", H_OPER, helpmod_cmd_report, "Sets the channel where to report this channels statistics every 5 minutes");
 
-    hcommand_add("whoami", H_LAMER, helpmod_cmd_whoami, "Tells who you are to H");
+    hcommand_add("whoami", H_LAMER, helpmod_cmd_whoami, "Tells who you are to " HELPMOD_NICK);
     hcommand_add("whois", H_STAFF, helpmod_cmd_whois, "Tells you who someone is");
     hcommand_add("command", H_LAMER, helpmod_cmd_command, "Gives detailed information on a command");
-    hcommand_add("addchan", H_ADMIN, helpmod_cmd_addchan, "Joins H to a new channel");
-    hcommand_add("delchan", H_ADMIN, helpmod_cmd_delchan, "Removes H permanently from a channel");
+    hcommand_add("addchan", H_ADMIN, helpmod_cmd_addchan, "Joins " HELPMOD_NICK " to a new channel");
+    hcommand_add("delchan", H_ADMIN, helpmod_cmd_delchan, "Removes " HELPMOD_NICK " permanently from a channel");
     hcommand_add("seen", H_STAFF, helpmod_cmd_seen, "Tells when a specific user/account has had activity");
 
     hcommand_add("op", H_STAFF, helpmod_cmd_op, "Sets mode +o on channels");
@@ -2853,7 +3031,10 @@ void hcommands_add(void)
 
     hcommand_add("termstats", H_OPER, helpmod_cmd_termstats, "Lists usage statistics for terms");
     hcommand_add("checkchannel", H_STAFF, helpmod_cmd_checkchannel, "Shows channel information for any channel");
-    hcommand_add("statsdebug", H_ADMIN, helpmod_cmd_statsdebug, "Statistics debug command");
+    hcommand_add("statsdump", H_ADMIN, helpmod_cmd_statsdump, "Statistics dump command");
+    hcommand_add("statsrepair", H_ADMIN, helpmod_cmd_statsrepair, "Statistics repair command");
+    hcommand_add("statsreset", H_ADMIN, helpmod_cmd_statsreset, "Statistics reset command");
+
     hcommand_add("message", H_TRIAL, helpmod_cmd_message, "Sends a message to a channel");
     /*hcommand_add("megod", H_PEON, helpmod_cmd_megod, "Gives you userlevel 4, if you see this in the final version, please kill strutsi");*/
     /*hcommand_add("test", H_PEON, helpmod_cmd_test, "Gives you userlevel 4, if you see this in the final version, please kill strutsi");*/
@@ -2924,7 +3105,7 @@ void helpmod_command(huser *sender, channel* returntype, char *args)
     if (sscanf(parsed_args[0], "%d", &useless_var) && returntype == NULL)
     {
         helpmod_cmd_help(sender, NULL, parsed_args[0], 1, NULL);
-        return;
+       return;
     }
 
     {
@@ -2933,7 +3114,7 @@ void helpmod_command(huser *sender, channel* returntype, char *args)
 
        if (hcom == NULL)
        {
-            if (sender->account == NULL || !(sender->account->flags & H_NO_CMD_ERROR))
+           if ((sender->account == NULL && returntype == NULL) || (sender->account != NULL && !(sender->account->flags & H_NO_CMD_ERROR)))
                helpmod_reply(sender, returntype, "Unknown command '%s', please see showcommands for a list of all commands available to you", parsed_args[0]);
        }
         else
index fc33e08bf66dcc6dd1bc960efbd68cb54a7c7a2c..c62140586e29a8f1d809e12f13cc8460e12f4b63 100644 (file)
@@ -447,7 +447,7 @@ int helpmod_config_write_ban(FILE *out, hban *hb)
 {
     fprintf(out, "\t%s\n", bantostring(hb->real_ban));
     fprintf(out, "\t%s\n", hb->reason?hb->reason->content:NULL);
-    fprintf(out, "\t%d\n", hb->expiration);
+    fprintf(out, "\t%u\n", hb->expiration);
     return 0;
 }
 
@@ -590,7 +590,7 @@ int helpmod_config_read_chanstats(FILE *in, hstat_channel *hs_chan)
         if (i < 7) /* days */
             entry = &hs_chan->week[(hstat_day() + i) % 7];
         else /* weeks */
-            entry = &hs_chan->longterm[(hstat_week() + (i-7)) % 7];
+            entry = &hs_chan->longterm[(hstat_week() + (i-7)) % 10];
 
         if (sscanf(buf, "%d %d %d %d %d %d", &entry->time_spent, &entry->prime_time_spent, &entry->joins, &entry->queue_use, &entry->lines, &entry->words) != 6)
             return -1;
@@ -608,7 +608,7 @@ int helpmod_config_write_chanstats(FILE *out, hstat_channel *hs_chan)
         if (i < 7) /* days */
             entry = &hs_chan->week[(hstat_day() + i) % 7];
         else /* weeks */
-            entry = &hs_chan->longterm[(hstat_week() + (i-7)) % 7];
+            entry = &hs_chan->longterm[(hstat_week() + (i-7)) % 10];
 
         fprintf(out, "\t%d %d %d %d %d %d\n", entry->time_spent, entry->prime_time_spent, entry->joins, entry->queue_use, entry->lines, entry->words);
     }
@@ -641,7 +641,7 @@ int helpmod_config_read_stats(FILE *in, hstat_account *hs_acc)
         if (i < 7) /* days */
             entry = &hs_acc->week[(hstat_day() + i) % 7];
         else /* weeks */
-            entry = &hs_acc->longterm[(hstat_week() + (i-7)) % 7];
+            entry = &hs_acc->longterm[(hstat_week() + (i-7)) % 10];
 
         if (sscanf(buf, "%d %d %d %d", &entry->time_spent, &entry->prime_time_spent, &entry->lines, &entry->words) != 4)
             return -1;
@@ -661,7 +661,7 @@ int helpmod_config_write_stats(FILE *out, hstat_account *hs_acc)
         if (i < 7) /* days */
             entry = &hs_acc->week[(hstat_day() + i) % 7];
         else /* weeks */
-            entry = &hs_acc->longterm[(hstat_week() + (i-7)) % 7];
+            entry = &hs_acc->longterm[(hstat_week() + (i-7)) % 10];
 
         fprintf(out, "\t%d %d %d %d\n", entry->time_spent, entry->prime_time_spent, entry->lines, entry->words);
     }
index 9827b32ed048b30faf6ac55546b02ecf4171057a..caeb50f3469a09ca3bbcd30a31a785f37ed15122 100644 (file)
@@ -9,7 +9,7 @@
 enum
 {
     HDEF_s = 1,
-    HDEF_m = 60,
+    HDEF_m = 60  * HDEF_s,
     HDEF_h = 60  * HDEF_m,
     HDEF_d = 24  * HDEF_h,
     HDEF_w = 7   * HDEF_d,
index bd03f23ea8d2adaf10c0777812b76990fdda8af7..b54c5b2b3f5d9350c119e3dc67fc08557ce56933 100644 (file)
 int HELPMOD_ACCOUNT_EXPIRATION[] =
 {
     14 * HDEF_d, /* H_LAMER */
-    7 * HDEF_d, /* H_PEON */
-    2 * HDEF_M, /* H_TRIAL */
-    6 * HDEF_M, /* H_STAFF */
-    1 * HDEF_y, /* H_OPER */
-    2 * HDEF_y /* H_ADMIN */
+    7  * HDEF_d, /* H_PEON */
+    2  * HDEF_M, /* H_TRIAL */
+    6  * HDEF_M, /* H_STAFF */
+    1  * HDEF_y, /* H_OPER */
+    2  * HDEF_y  /* H_ADMIN */
 };
 
 /* new H stuff */
@@ -128,6 +128,9 @@ void helpmod_message_channel(hchannel *hchan, const char *message, ...)
     vsnprintf(buf,512,message,va);
     va_end(va);
 
+    if (hchan->flags & H_PASSIVE)
+        return;
+
     sendmessagetochannel(helpmodnick, hchan->real_channel, "%s", buf);
 }
 
@@ -145,6 +148,9 @@ void helpmod_message_channel_long(hchannel *hchan, const char *message, ...)
     vsnprintf(buf,2048,message,va);
     va_end(va);
 
+    if (hchan->flags & H_PASSIVE)
+        return;
+
     while (strlen(bp) > 450)
     {
         for (i=0;i<50;i++)
@@ -179,6 +185,9 @@ void helpmod_kick(hchannel *hchan, huser *target, const char *reason, ...)
 
 void helpmod_invite(hchannel *hchan, huser *husr)
 {
+    if (hchan->flags & H_PASSIVE)
+        return;
+
     localinvite(helpmodnick, hchan->real_channel, husr->real_user);
 }
 
@@ -201,6 +210,9 @@ void helpmod_channick_modes(huser *target, hchannel *hchan, short mode, int now)
         return;
     }
 
+    if (hchan->flags & H_PASSIVE)
+        return;
+
     switch (mode)
     {
     case MC_OP:
@@ -224,6 +236,10 @@ void helpmod_channick_modes(huser *target, hchannel *hchan, short mode, int now)
 void helpmod_setban(hchannel *hchan, const char *banstr, time_t expiration, int type, int now)
 {
     hmode_set_channel(hchan);
+
+    if (hchan->flags & H_PASSIVE)
+        return;
+
     localdosetmode_ban(&hmodechanges, banstr, type);
 
     if ((type == MCB_ADD) && (expiration > time(NULL)))
@@ -237,6 +253,9 @@ void helpmod_simple_modes(hchannel *hchan, int add, int remove, int now)
 {
     hmode_set_channel(hchan);
 
+    if (hchan->flags & H_PASSIVE)
+        return;
+
     localdosetmode_simple(&hmodechanges, add, remove);
 
     if (now)
@@ -245,6 +264,9 @@ void helpmod_simple_modes(hchannel *hchan, int add, int remove, int now)
 
 void helpmod_set_topic(hchannel *hchan, const char* topic)
 {
+    if (hchan->flags & H_PASSIVE)
+        return;
+
     localsettopic(helpmodnick, hchan->real_channel, (char*)topic);
 }
 
@@ -397,7 +419,7 @@ void _init()
     schedulerecurring(time(NULL)+1,0,HDEF_d,(ScheduleCallback)&haccount_clear_inactives,NULL);
     schedulerecurring(time(NULL)+1,0,HDEF_m,(ScheduleCallback)&hban_remove_expired,NULL);
     schedulerecurring(time(NULL)+1,0,30 * HDEF_s, (ScheduleCallback)&hchannel_remove_inactive_users, NULL);
-    schedulerecurring(time(NULL)+1,0,5 * HDEF_m,(ScheduleCallback)&hchannel_report, NULL);
+    schedulerecurring(time(NULL)+1,0,60 * HDEF_m,(ScheduleCallback)&hchannel_report, NULL);
     schedulerecurring(time(NULL) + HDEF_h, 0, 6 * HDEF_h, (ScheduleCallback)&helpmod_config_scheduled_events, NULL);
     schedulerecurring(time(NULL)+1,0,10 * HDEF_m, (ScheduleCallback)&hticket_remove_expired, NULL);
     schedulerecurring(hstat_get_schedule_time() - 5 * HDEF_m, 0, HDEF_d, (ScheduleCallback)&hstat_scheduler, NULL);
index 35946e473193dd9c5e54816440bb77b0d8873bf1..f9319ae21b8ae404a004d3aba99ec29984e96659 100644 (file)
@@ -95,7 +95,7 @@ channel
 
 % Initial account (mine)
 account
-       strutsi
+       sdjfkl
        5       0
         0
 
index 03a0e8451bd75e20aa7a3da4aa3cf3863b7fc2d1..28956183d942a10da330af735e012c699e8afd14 100644 (file)
@@ -10,7 +10,7 @@
 
 /* configuration */
 
-#define HELPMOD_VERSION "2.05"
+#define HELPMOD_VERSION "2.09"
 
 #define HELPMOD_USER_TIMEOUT 1200
 
index d2c9e3718ce6c97d352e32aef9972cb30a597e49..d7b52f11cb77b5a7b5ca95cf19c23b4f72621cc8 100644 (file)
@@ -78,22 +78,27 @@ if (elem)\
     buf+=tmp;\
 }\
 
-
+/* This implementation might look a little evil but it does work */
 const char *helpmod_strtime(int total_seconds)
 {
-    static char buffer[64];
-    char *buf = buffer;
+    static int buffer_index = 0;
+    static char buffers[3][64];
+
+    char *buf = buffers[buffer_index];
+    char *buffer = buf;
 
     int years, months, days, hours, minutes, seconds, tmp;
 
+    buffer_index = (buffer_index+1) % 3;
+
     /* trivial case */
     if (!total_seconds)
         return "0s";
 
     if (total_seconds < 0)
     {
-        *buf = '-';
-        buf++;
+       *buf = '-';
+       buf++;
         total_seconds = -total_seconds;
     }
 
@@ -110,7 +115,7 @@ const char *helpmod_strtime(int total_seconds)
     total_seconds %= HDEF_h;
 
     minutes = total_seconds / HDEF_m;
-    total_seconds %= 60;
+    total_seconds %= HDEF_m;
 
     seconds = total_seconds;
 
@@ -121,7 +126,10 @@ const char *helpmod_strtime(int total_seconds)
     TIME_PRINT(minutes, "m");
     TIME_PRINT(seconds, "s");
 
-    return buffer+1;
+    if (*buffer != '-')
+       return buffer+1;
+    else
+        return buffer;
 }
 
 int helpmod_read_strtime(const char *str)
index c901593e9c4601bc94b204be0a8bb02daeaaaef3..efdbd825294e4c362e3c108df83a13902ddf572e 100644 (file)
@@ -9,7 +9,7 @@ int ci_strcmp(const char*, const char*);
 /* matches string (const char*) to the regular expression (? and *) (const char*) */
 int strregexp(const char *, const char *);
 
-/* prints the time in the common 1h 2m 3s format, hour is the maximum unit printed currently */
+/* prints the time in the common 1h 2m 3s format, has three internal buffers */
 const char *helpmod_strtime(int);
 /* reads a time string */
 int helpmod_read_strtime(const char *);
index 2d77c190ecb9b72185c1418a328ded6203e3d2ad..0e9eeab823ef3eafea78e29f27c832029d6197d8 100644 (file)
@@ -40,28 +40,31 @@ void helpmod_hook_join(int unused, void *args)
     huser *husr;
 
     /* if we're not on this channel, the event is of no interest */
-    if (hchan == NULL || hchan->flags & H_PASSIVE)
+    if (hchan == NULL)
         return;
 
     husr = huser_get(nck);
 
     assert(husr != NULL); /* hook_channel_newnick should fix this */
 
-    if (hchan->flags & H_JOINFLOOD_PROTECTION)
+    if (hchan->flags & H_JOINFLOOD_PROTECTION & !(hchan->flags & H_PASSIVE))
     {
-        if (hchan->jf_control < time(NULL))
-            hchan->jf_control = time(NULL);
-        else
-            hchan->jf_control++;
+       if (hchan->jf_control < time(NULL))
+           hchan->jf_control = time(NULL);
+       else
+           hchan->jf_control++;
 
-        if (hchan->jf_control - time(NULL) > 25 && !IsRegOnly(hchan))
-        {
-            if (hchan->flags & H_REPORT && hchannel_is_valid(hchan->report_to))
+       if (hchan->jf_control - time(NULL) > 25 && !IsRegOnly(hchan))
+       {
+           if (hchan->flags & H_REPORT && hchannel_is_valid(hchan->report_to))
                 helpmod_message_channel(hchan->report_to, "Warning: Possible join flood on %s, setting +r", hchannel_get_name(hchan));
             hchannel_activate_join_flood(hchan);
         }
     }
 
+    if (hchan->flags & H_PASSIVE)
+        return;
+
     if (hchan->flags & H_DO_STATS)
         hstat_add_join(hchan);
 
@@ -116,6 +119,9 @@ void helpmod_hook_channel_newnick(int unused, void *args)
     hchannel_add_user(hchan, husr);
     huser_add_channel(husr, hchan);
 
+    if (hchan->flags & H_PASSIVE)
+        return;
+
     if (huser_get_level(husr) == H_LAMER || (huser_get_level(husr) == H_PEON && hban_check(nck)))
     {
         hban *hb = hban_check(nck);
@@ -162,8 +168,8 @@ void helpmod_hook_channel_lostnick(int unused, void *args)
     assert(hchannel_on_channel(hchan, husr) != NULL);
     assert(huserchan != NULL);
 
-    if ((hchan->flags & H_QUEUE) && (hchan->flags & H_QUEUE_MAINTAIN)) /* && (huser_get_level(husr) == H_PEON) && (huserchan->flags & HCUMODE_VOICE) && (hchannel_count_queue(hchan)))*/
-        if (serverlist[homeserver(husr->real_user->numeric)].linkstate != LS_SQUIT)
+    if ((hchan->flags & H_QUEUE) && (hchan->flags & H_QUEUE_MAINTAIN) && !(hchan->flags & H_PASSIVE)) /* && (huser_get_level(husr) == H_PEON) && (huserchan->flags & HCUMODE_VOICE) && (hchannel_count_queue(hchan)))*/
+       if (serverlist[homeserver(husr->real_user->numeric)].linkstate != LS_SQUIT)
             /* if it was a netsplit, we do not trigger autoqueue */
         {
             oper = huserchan->responsible_oper;
@@ -197,7 +203,7 @@ void helpmod_hook_nick_lostnick(int unused, void *args)
 
     /* it was someone we didn't even know */
     if (husr == NULL)
-            return;
+       return;
 
     huser_del(husr);
 }
@@ -222,6 +228,9 @@ void helpmod_hook_channel_opped(int unused, void *args)
 
     huserchan->flags |= HCUMODE_OP;
 
+    if (hchan->flags & H_PASSIVE)
+        return;
+
     /* if the +o was given by a network service, G will not interfere */
     if (husr2 == NULL || strlen(husr2->real_user->nick) == 1)
         return;
@@ -295,6 +304,9 @@ void helpmod_hook_channel_devoiced(int unused, void *args)
 
     huserchan->flags &= ~HCUMODE_VOICE;
 
+    if (hchan->flags & H_PASSIVE)
+        return;
+
     if ((hchan->flags & H_QUEUE) && (hchan->flags & H_QUEUE_MAINTAIN) && (huser_get_level(husr) == H_PEON) && (huserchan->flags & HCUMODE_VOICE) && (hchannel_count_queue(hchan)))
     {
         if (serverlist[homeserver(husr->real_user->numeric)].linkstate != LS_SQUIT)
@@ -314,7 +326,7 @@ void helpmod_hook_channel_topic(int unused, void *args)
     hchannel *hchan = hchannel_get_by_channel(((channel**)args)[0]);
     huser *husr;
 
-    if (hchan == NULL)
+    if (hchan == NULL || hchan->flags & H_PASSIVE)
         return;
 
     husr = huser_get(((nick**)args)[2]);
index 0e0b6ff09891b4d72e330c7d13783bd75d96b26f..ecc9fa2e26e15925a4215965b1cd156815076090 100644 (file)
@@ -249,10 +249,10 @@ static int hlc_check_spam(hlc_profile *hlc_prof, huser *husr, const char *line)
 }
 
 /* checks a string for lameness, returns non-zero if lameness is present */
-int hlc_check(void *hchan_ptr, void *husr_ptr, const char *line)
+int hlc_check(hchannel *hchan, huser* husr, const char *line)
 {
-    hchannel *hchan = (hchannel*)hchan_ptr;
-    huser *husr = (huser*)husr_ptr;
+//    hchannel *hchan = (hchannel*)hchan_ptr;
+//    huser *husr = (huser*)husr_ptr;
 
     if (hchan == NULL || hchan->lc_profile == NULL)
         return 0;
index 1381d69490bb396e704431290cd0cd731114d3bc..7d830f82216d41c32a96493d4d69fc53f63eae55 100644 (file)
@@ -6,6 +6,10 @@
 
 #define HLC_DEFAULT_BANTIME (60 * 60 * 24)
 
+/* Forward declarations */
+struct hchannel_struct;
+struct huser_struct;
+
 typedef enum
 {
     HLC_CAPS,
@@ -48,8 +52,7 @@ hlc_profile *hlc_del(hlc_profile *);
 void hlc_del_all(void);
 hlc_profile *hlc_get(const char *);
 
-/* checks a string for lameness, returns non-zero if lameness is present and user is kicked */
-/* the first parameter is hchannel* and second is huser*, but since hchannel.h includes hlamer.h, this is needed */
-int hlc_check(void *, void*, const char *);
+/* checks a string for lameness, returns non-zero if lameness is present and the user is kicked */
+int hlc_check(struct hchannel_struct*, struct huser_struct*, const char *);
 
 #endif
index 347f76a81b31069f999a8d7306a2f5d8170c3ead..fd32c50744860cf0488e4a38356ccd143d32ca43 100644 (file)
@@ -4,6 +4,7 @@
 #include "hqueue.h"
 #include "hgen.h"
 #include "hstat.h"
+#include "huser.h"
 
 #include "hcommands.h"
 
@@ -199,6 +200,19 @@ void helpmod_queue_handler (huser *sender, channel* returntype, hchannel *hchan,
             helpmod_reply(sender, returntype, "Queue deactivated for channel %s", hchannel_get_name(hchan));
            hchannel_conf_change(hchan, hchan->flags | H_QUEUE);
            hchan->autoqueue = 0;
+
+           {   /* devoice all users of level H_PEON */
+               hchannel_user *hchanuser;
+                huser_channel *huserchan;
+               for (hchanuser = hchan->channel_users;hchanuser != NULL;hchanuser = hchanuser->next)
+               {
+                   huserchan = huser_on_channel(hchanuser->husr, hchan);
+                   if (huser_get_level(hchanuser->husr) == H_PEON && huserchan->flags & HCUMODE_VOICE)
+                       helpmod_channick_modes(hchanuser->husr, hchan, MC_DEVOICE, HLAZY);
+               }
+
+           }
+
        }
         return;
     }
index 97a21085adc62088dda342c175e620e70d021ad2..9c990412b3fea0c5436c6e7fd42397aa4b8393fd 100644 (file)
@@ -24,55 +24,66 @@ void hstat_scheduler(void)
     struct tm *tstruct = localtime(&timer);
     int is_sunday = (tstruct->tm_wday == 0); /* is it sunday ? */
     int i;
-    hstat_cycle++;
+
+    /* Fix the hstat_cycle in case it's broken */
+    if (is_sunday)
+        hstat_cycle = hstat_cycle - (hstat_cycle % 7) + 6;
 
     {   /* accounts */
         haccount *ptr = haccounts;
-        if (is_sunday)
-            for (;ptr;ptr = ptr->next)
-                if (ptr->level > H_PEON)
-                {
-                    hstat_account *ptr2 = ptr->stats;
-                    for (;ptr2;ptr2 = ptr2->next)
-                    {
-                        HSTAT_ACCOUNT_ZERO(ptr2->longterm[(hstat_week() - 1) % 10]);
-                        for (i=0;i<7;i++)
-                        {
-                            HSTAT_ACCOUNT_SUM(ptr2->longterm[(hstat_week() - 1) % 10], ptr2->longterm[(hstat_week() - 1) % 10], ptr2->week[i]);
-                        }
-                        /*ptr2->longterm[(hstat_week() - 1) % 10] = ptr2->longterm[hstat_week()];*/
-                        /*for (i=0;i<7;i++)
-                        {
-                            HSTAT_ACCOUNT_ZERO(ptr2->week[i]);
-                        }*/
-                    }
-                }
+       for (;ptr;ptr = ptr->next)
+           if (ptr->level > H_PEON)
+           {
+               hstat_account *ptr2 = ptr->stats;
+               for (;ptr2;ptr2 = ptr2->next)
+               {
+                   if (is_sunday)
+                   {
+                       HSTAT_ACCOUNT_ZERO(ptr2->longterm[(hstat_week() + 1) % 10]);
+                       for (i=0;i<7;i++)
+                       {
+                           HSTAT_ACCOUNT_SUM(ptr2->longterm[(hstat_week() + 1) % 10], ptr2->longterm[(hstat_week() + 1) % 10], ptr2->week[i]);
+                       }
+                   }
+                   HSTAT_ACCOUNT_ZERO(ptr2->week[(hstat_day() + 1) % 7]);
+                   /*                        ptr2->longterm[(hstat_week() - 1) % 10] = ptr2->longterm[hstat_week()];
+                    for (i=0;i<7;i++)
+                    {
+                    HSTAT_ACCOUNT_ZERO(ptr2->day[i]);
+                    }*/
+               }
+           }
     }
     {   /* hchannels */
         hchannel *ptr = hchannels;
         for (;ptr;ptr = ptr->next)
         {
-            if ((ptr->flags & H_REPORT) && hchannel_is_valid(ptr))
+           hstat_channel *ptr2;
+           if (ptr->flags & H_REPORT && hchannel_is_valid(ptr->report_to))
             {
                 hstat_channel_entry *entry = &ptr->stats->week[hstat_day()];
                 helpmod_message_channel(ptr->report_to, "Daily summary for channel %s: Time spent %s, joins %d and queue usage %d", hchannel_get_name(ptr),helpmod_strtime(entry->time_spent), entry->joins, entry->queue_use);
             }
-            if (is_sunday)
-            {
-                hstat_channel *ptr2 = ptr->stats;
-                HSTAT_CHANNEL_ZERO(ptr2->longterm[(hstat_week() - 1) % 10]);
+
+           ptr2 = ptr->stats;
+           if (is_sunday)
+           {
+                HSTAT_CHANNEL_ZERO(ptr2->longterm[(hstat_week() + 1) % 10]);
                 for (i=0;i<7;i++)
                 {
-                    HSTAT_CHANNEL_SUM(ptr2->longterm[(hstat_week() - 1) % 10], ptr2->longterm[(hstat_week() - 1) % 10], ptr2->week[i]);
+                    HSTAT_CHANNEL_SUM(ptr2->longterm[(hstat_week() + 1) % 10], ptr2->longterm[(hstat_week() + 1) % 10], ptr2->week[i]);
                 }
-                /*ptr2->longterm[(hstat_week() - 1) % 10] = ptr2->longterm[hstat_week()];*/
-                /*for (i=0;i<7;i++)
-                {
-                    HSTAT_CHANNEL_ZERO(ptr2->week[i]);
+/*                ptr2->longterm[(hstat_week() - 1) % 10] = ptr2->longterm[hstat_week()];
+                for (i=0;i<7;i++)
+               {
+                    HSTAT_CHANNEL_ZERO(ptr2->day[i]);
                 }*/
-            }
+           }
+           HSTAT_CHANNEL_ZERO(ptr2->week[(hstat_day() + 1) % 7]);
         }
     }
+
+    hstat_cycle++;
 }
 
 int hstat_get_schedule_time(void)
@@ -94,9 +105,8 @@ hstat_channel *get_hstat_channel(void)
     return tmp;
 }
 
-void hstat_del_channel(void* ptr)
+void hstat_del_channel(hchannel *hchan)
 {
-    hchannel *hchan = (hchannel*)ptr;
     haccount *hacc = haccounts;
     hstat_account **hs_acc;
     for (;hacc;hacc = hacc->next)
@@ -123,10 +133,8 @@ hstat_account *get_hstat_account(void)
     return tmp;
 }
 
-void hstat_calculate_general(void* param1, void* param2, const char *message)
+void hstat_calculate_general(hchannel *hchan, huser* husr, const char *message)
 {
-    hchannel *hchan = (hchannel*)param1;
-    huser *husr = (huser*)param2;
     hstat_account **acc_stat;
     hstat_account_entry *acc_entry;
     hstat_channel_entry *chan_entry;
@@ -142,8 +150,7 @@ void hstat_calculate_general(void* param1, void* param2, const char *message)
             break;
 
     if (*acc_stat == NULL)
-    /* this user has no stats for the channel -> create them */
-    {
+    { /* this user has no stats for the channel -> create them */
         *acc_stat = get_hstat_account();
         (*acc_stat)->hchan = hchan;
     }
@@ -153,7 +160,7 @@ void hstat_calculate_general(void* param1, void* param2, const char *message)
 
     time_spent = time(NULL) - huserchan->last_activity;
 
-    if (time_spent < HSTAT_ACTIVITY_TRESHOLD)
+    if (time_spent > 0 && time_spent < HSTAT_ACTIVITY_TRESHOLD)
     {
         acc_entry->time_spent+=time_spent;
         chan_entry->time_spent+=time_spent;
@@ -174,19 +181,16 @@ void hstat_calculate_general(void* param1, void* param2, const char *message)
     chan_entry->words+=wordc;
 }
 
-void hstat_add_join(void *param)
+void hstat_add_join(hchannel *hchan)
 {
-    hchannel *hchan = (hchannel*)param;
     hchan->stats->week[hstat_day()].joins++;
 }
 
-void hstat_add_queue(void *param, int amount)
+void hstat_add_queue(hchannel *hchan, int amount)
 {
-    hchannel *hchan = (hchannel*)param;
     hchan->stats->week[hstat_day()].queue_use+=amount;
 }
 
-
 const char *hstat_channel_print(hstat_channel_entry *entry, int type)
 {
     static char buffer[256];
@@ -194,10 +198,10 @@ const char *hstat_channel_print(hstat_channel_entry *entry, int type)
     switch (type)
     {
     case HSTAT_CHANNEL_LONG:
-        sprintf(buffer, "%-15s %-15s %-10d %-10d %-10d %-10d", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent), entry->joins, entry->queue_use, entry->lines, entry->words);
+        sprintf(buffer, "%-18s %-18s %-10d %-10d %-10d %-10d", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent), entry->joins, entry->queue_use, entry->lines, entry->words);
         break;
     case HSTAT_CHANNEL_SHORT:
-        sprintf(buffer, "%-15s %-15s", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent));
+        sprintf(buffer, "%-18s %-18s", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent));
         break;
     }
     return buffer;
@@ -210,10 +214,10 @@ const char *hstat_account_print(hstat_account_entry *entry, int type)
     switch (type)
     {
     case HSTAT_ACCOUNT_LONG:
-        sprintf(buffer, "%-15s %-15s %-10d %-10d", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent), entry->lines, entry->words);
+        sprintf(buffer, "%-18s %-18s %-10d %-10d", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent), entry->lines, entry->words);
         break;
     case HSTAT_ACCOUNT_SHORT:
-        sprintf(buffer, "%-15s %-15s", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent));
+        sprintf(buffer, "%-18s %-18s", helpmod_strtime(entry->time_spent), helpmod_strtime(entry->prime_time_spent));
         break;
     }
     return buffer;
@@ -224,15 +228,15 @@ const char *hstat_header(hstat_type type)
     switch (type)
     {
     case HSTAT_ACCOUNT_SHORT:
-        return "TimeSpent       PrimeTimeSpent";
+        return "TimeSpent          PrimeTimeSpent";
     case HSTAT_ACCOUNT_LONG:
-        return "TimeSpent       PrimeTimeSpent  Lines      Words";
+        return "TimeSpent          PrimeTimeSpent     Lines      Words";
     case HSTAT_CHANNEL_SHORT:
-        return "TimeSpent       PrimeTimeSpent";
+        return "TimeSpent          PrimeTimeSpent";
     case HSTAT_CHANNEL_LONG:
-        return "TimeSpent       PrimeTimeSpent  Joins      QueueUse   Lines      Words";
+        return "TimeSpent          PrimeTimeSpent     Joins      QueueUse   Lines      Words";
     default:
-        return "error: please contact strutsi";
+        return "Error: please contact strutsi";
     }
 }
 
@@ -310,9 +314,8 @@ static int hstat_account_compare(hstat_account_entry_sum *e1, hstat_account_entr
     return e2->prime_time_spent - e1->prime_time_spent;
 }
 
-hstat_accounts_array create_hstat_account_array(void* tptr, hlevel lvl)
+hstat_accounts_array create_hstat_account_array(hchannel *hchan, hlevel lvl)
 {
-    hchannel *hchan = (hchannel*)tptr;
     hstat_accounts_array arr = {NULL, 0};
     hstat_account *ptr;
     hstat_account_entry_sum tmp1, tmp2;
@@ -329,21 +332,20 @@ hstat_accounts_array create_hstat_account_array(void* tptr, hlevel lvl)
     if (!initial_arrlen)
         return arr;
 
-    arr.array = malloc(sizeof(hstat_account_entry_sum) * initial_arrlen);
+    arr.array = (hstat_account_entry_sum*)malloc(sizeof(hstat_account_entry_sum) * initial_arrlen);
     for (;hacc;hacc = hacc->next)
         if ((lvl == H_OPER && (hacc->level == H_OPER || hacc->level == H_ADMIN)) ||
             (lvl == H_STAFF && (hacc->level == H_TRIAL || hacc->level == H_STAFF)))
-        //if ((lvl == H_OPER)?(hacc->level >= H_OPER && hacc->level < H_SERVICE):(hacc->level > H_PEON || hacc->level < H_OPER))
-            for (ptr = hacc->stats;ptr;ptr = ptr->next)
-                if (ptr->hchan == hchan)
-                {
-                    assert(arr.arrlen < initial_arrlen);
-                    tmp1 = hstat_account_last_month(ptr);
-                    tmp2 = hstat_account_last_week(ptr);
-                    HSTAT_ACCOUNT_SUM(arr.array[arr.arrlen], tmp1, tmp2);
-                    arr.array[arr.arrlen].owner = (void*)hacc;
-                    arr.arrlen++;
-                }
+           for (ptr = hacc->stats;ptr;ptr = ptr->next)
+               if (ptr->hchan == hchan)
+               {
+                   assert(arr.arrlen < initial_arrlen);
+                   tmp1 = hstat_account_last_month(ptr);
+                   tmp2 = hstat_account_last_week(ptr);
+                   HSTAT_ACCOUNT_SUM(arr.array[arr.arrlen], tmp1, tmp2);
+                   arr.array[arr.arrlen].owner = hacc;
+                   arr.arrlen++;
+               }
 
     qsort(arr.array, arr.arrlen, sizeof(hstat_account_entry_sum), (int(*)(const void*, const void*))hstat_account_compare);
     return arr;
index 27e26196d3794d3ba7d76e54b96b7a272b716de3..1a0c3f521c20d76fe9271391dcf0ecaca7017db5 100644 (file)
@@ -6,7 +6,12 @@
 extern int hstat_cycle;
 extern time_t hstat_last_cycle;
 
-#define HSTAT_ACTIVITY_TRESHOLD (3 * 60)
+/* forward declarations */
+struct haccount_struct;
+struct hchannel_struct;
+struct huser_struct;
+
+#define HSTAT_ACTIVITY_TRESHOLD (3 * HDEF_m)
 
 #define HSTAT_ACCOUNT_SUM(sum, op1, op2)\
 {\
@@ -66,7 +71,7 @@ typedef struct hstat_account_entry_sum_struct
     int prime_time_spent;
     int lines;
     int words;
-    void *owner; /* haccount* */
+    struct haccount_struct *owner; /* haccount* */
 } hstat_account_entry_sum;
 
 typedef struct hstat_channel_entry_struct
@@ -105,7 +110,7 @@ typedef struct hstat_accounts_array_struct
 } hstat_accounts_array;
 
 /* free() this.entries, arguments: channel, level to list */
-hstat_accounts_array create_hstat_account_array(void*, hlevel);
+hstat_accounts_array create_hstat_account_array(struct hchannel_struct*, hlevel);
 
 hstat_channel *get_hstat_channel(void);
 hstat_account *get_hstat_account(void);
@@ -116,15 +121,12 @@ const char *hstat_channel_print(hstat_channel_entry*, int);
 
 const char *hstat_account_print(hstat_account_entry*, int);
 
-/* void* = hchannel*, huser* */
-void hstat_calculate_general(void*, void*, const char *);
+void hstat_calculate_general(struct hchannel_struct*, struct huser_struct*, const char *);
 
-/* void* = hchannel* */
-void hstat_add_join(void*);
-void hstat_del_channel(void*);
+void hstat_add_join(struct hchannel_struct*);
+void hstat_del_channel(struct hchannel_struct*);
 
-/* void* = hchannel* */
-void hstat_add_queue(void*, int);
+void hstat_add_queue(struct hchannel_struct*, int);
 
 int is_prime_time(void); /* tells if now is the "main" time in #feds */