sohbet

Kanal ve Özel Loglama Modülü m_loggit.c



Kod:
#include "config.h"
#include "struct.h"
#include "common.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "channel.h"
#include <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include "h.h"

#define MyMod            LoggitModInfo->handle
#define DelHook(x)        if (x) HookDel(x); x = NULL

DLLFUNC char        *loggit_cikis(aClient *sptr, int parc, char *parv[]);
DLLFUNC char        *loggit_giris(aClient *sptr, int parc, char *parv[]);
DLLFUNC char        *loggit_nick(aClient *, char *);
DLLFUNC char        *loggit_privmsg(aClient *, aClient *, aClient *, char *, int);
DLLFUNC char        *loggit_chanmsg(aClient *, aClient *, aChannel *, char *, int);


// ==================================================================
// Module header
// ==================================================================

ModuleHeader MOD_HEADER(m_loggit)
  = {
    "Loggit",
    "$Id: m_loggit.c,v 3.6 2007 MartinCo Exp $",
    "Loggit",
    "3.2-b8-1",
    NULL
    };

ModuleInfo        *LoggitModInfo;

static Hook        *HookPrivMsg, *HookChanMsg, *HookNick;
static Hook        *HookGiris, *HookCikis;
static FILE *fp;


DLLFUNC int MOD_INIT(m_loggit)(ModuleInfo *modinfo)
{
    int ret = MOD_SUCCESS;
      
        LoggitModInfo    = modinfo;

    HookPrivMsg    = HookAddPCharEx(MyMod, HOOKTYPE_USERMSG, loggit_privmsg);
    HookChanMsg    = HookAddPCharEx(MyMod, HOOKTYPE_CHANMSG, loggit_chanmsg);
    HookNick             = HookAddPCharEx(MyMod, HOOKTYPE_LOCAL_NICKCHANGE, loggit_nick);
    HookGiris             = HookAddPCharEx(MyMod, HOOKTYPE_LOCAL_CONNECT, loggit_giris);
    HookCikis             = HookAddPCharEx(MyMod, HOOKTYPE_LOCAL_QUIT, loggit_cikis);


    return ret;
}

DLLFUNC int MOD_LOAD(m_loggit)(int module_load)
{
    return MOD_SUCCESS;
}

DLLFUNC int MOD_UNLOAD(m_loggit)(int module_unload)
{

    DelHook(HookChanMsg);
    DelHook(HookPrivMsg);
    return MOD_SUCCESS;
}

DLLFUNC char *loggit_privmsg(aClient *cptr, aClient *sptr, aClient *acptr, char *text, int notice)
{

    time_t calender_time;
    struct tm tdate;
    calender_time = time(NULL);
    tdate = *localtime(&calender_time);

    FILE * pFile;
    pFile = fopen ("ozel.log", "a");
    fprintf (pFile, "%02d-%02d-%02d %02d:%02d [%s > %s] %s\n", tdate.tm_mday, tdate.tm_mon + 1, tdate.tm_year - 100, tdate.tm_hour, tdate.tm_min, cptr->name, acptr->name, text);
    
fclose (pFile);
   
return text;
}

DLLFUNC char *loggit_chanmsg(aClient *cptr, aClient *sptr, aChannel *chptr, char *text, int notice)
{

    time_t calender_time;
    struct tm tdate;
    calender_time = time(NULL);
    tdate = *localtime(&calender_time);

    FILE * pFile;
    pFile = fopen ("kanal.log", "a");
    fprintf (pFile, "%02d-%02d-%02d %02d:%02d [%s] [%s] %s\n", tdate.tm_mday, tdate.tm_mon + 1, tdate.tm_year - 100, tdate.tm_hour, tdate.tm_min, chptr->chname, cptr->name, text);

    fclose (pFile);

    return text;
}

DLLFUNC char *loggit_nick(aClient *sptr, char *n)
{
  time_t calender_time;
    struct tm tdate;
    calender_time = time(NULL);
    tdate = *localtime(&calender_time);

    FILE * pFile;
    pFile = fopen ("nick.log", "a");
    fprintf (pFile, "Tarih: -> %02d-%02d-%02d Saat: -> %02d:%02d Nick: -> (%s) Yeninick: -> (%s) \n", tdate.tm_mday, tdate.tm_mon + 1, tdate.tm_year - 100, tdate.tm_hour, tdate.tm_min, sptr->name, n);
    
fclose (pFile);

return 0;
}

DLLFUNC char *loggit_giris(aClient *sptr, int parc, char *parv[])
{
 time_t calender_time;
    struct tm tdate;
    calender_time = time(NULL);
    tdate = *localtime(&calender_time);

    FILE * pFile;
    pFile = fopen ("giris.log", "a");
    fprintf (pFile, "Tarih: -> %02d-%02d-%02d Saat: -> %02d:%02d Nick: -> (%s) Identd: -> (%s) IP: -> (%s) Fullname: -> (%s) \n", tdate.tm_mday, tdate.tm_mon + 1, tdate.tm_year - 100, tdate.tm_hour, tdate.tm_min, sptr->name, sptr->user->username, sptr->user->realhost, sptr->info);
   
 fclose (pFile);
 
 return 0;
}

DLLFUNC char *loggit_cikis(aClient *sptr, int parc, char *parv[])
{
 time_t calender_time;
    struct tm tdate;
    calender_time = time(NULL);
    tdate = *localtime(&calender_time);

    FILE * pFile;
    pFile = fopen ("cikis.log", "a");
    fprintf (pFile, "Tarih: -> %02d-%02d-%02d Saat: -> %02d:%02d Nick: -> (%s) Identd: -> (%s) IP: -> (%s) Fullname: -> (%s) \n", tdate.tm_mday, tdate.tm_mon + 1, tdate.tm_year - 100, tdate.tm_hour, tdate.tm_min, sptr->name, sptr->user->username, sptr->user->realhost, sptr->info);
    
fclose (pFile);
   
return 0;
}

Yorum Gönder

Daha yeni Daha eski