]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_operlog.cpp
Windows support. Tested and working to compile on freebsd and linux. Next step is...
[user/henk/code/inspircd.git] / src / modules / m_operlog.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13  
14 #include "users.h"
15 #include "channels.h"
16 #include "modules.h"
17 #include "inspircd.h"
18 #include <vector>
19
20 /* $ModDesc: A module which logs all oper commands to the ircd log at default loglevel. */
21
22 class ModuleOperLog : public Module
23 {
24  private:
25          
26  public:
27         ModuleOperLog(InspIRCd* Me) : Module(Me)
28         {
29                 
30         }
31  
32         virtual ~ModuleOperLog()
33         {
34         }
35  
36         virtual Version GetVersion()
37         {
38                 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
39         }
40  
41         void Implements(char* List)
42         {
43                 List[I_OnPreCommand] = List[I_On005Numeric] = 1;
44         }
45
46         virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
47         {
48                 /* If the command doesnt appear to be valid, we dont want to mess with it. */
49                 if (!validated)
50                         return 0;
51  
52                 if ((IS_OPER(user)) && (IS_LOCAL(user)) && (user->HasPermission(command)))
53                 {
54                         command_t* thiscommand = ServerInstance->Parser->GetHandler(command);
55                         if ((thiscommand) && (thiscommand->flags_needed = 'o'))
56                         {
57                                 std::string plist = "";
58                                 for (int j = 0; j < pcnt; j++)
59                                         plist.append(std::string(" ")+std::string(parameters[j]));
60
61                                 ServerInstance->Log(DEFAULT,"OPERLOG: [%s!%s@%s] %s%s",user->nick,user->ident,user->host,command.c_str(),plist.c_str());
62                         }
63                 }
64
65                 return 0;
66         }
67
68         virtual void On005Numeric(std::string &output)
69         {
70                 output.append(" OPERLOG");
71         }
72
73 };
74  
75  
76  
77 /******************************************************************************************************/
78  
79 class ModuleOperLogFactory : public ModuleFactory
80 {
81  public:
82         ModuleOperLogFactory()
83         {
84         }
85  
86         ~ModuleOperLogFactory()
87         {
88         }
89  
90         virtual Module * CreateModule(InspIRCd* Me)
91         {
92                 return new ModuleOperLog(Me);
93         }
94  
95 };
96  
97 extern "C" DllExport void * init_module( void )
98 {
99         return new ModuleOperLogFactory;
100 }
101