Unreal3.2/logs klasoru içersine kendi Yıl,Ay,Gün Olarak Kyt Edecektir.
PHP Kod: Kodu kopyalamak için üzerine çift tıklayın!
/*
* ==================================================================
* Filename: m_loggit.c
* Description: Real-time Logging
* Written by: MartinCo
* ==================================================================
*/
#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>
#ifdef _WIN32
#include <io.h>
#endif
#include <fcntl.h>
#include "h.h"
#ifdef STRIPBADWORDS
#include "badwords.h"
#endif
#ifdef _WIN32
#include "version.h"
#endif
#define MyMod LoggitModInfo->handle
#define DelHook(x) if (x) HookDel(x); x = NULL
DLLFUNC char *loggit_privmsg(aClient *, aClient *, aClient *, char *, int);
DLLFUNC char *loggit_chanmsg(aClient *, aClient *, aChannel *, char *, int);
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 *HookChanMsg;
static Hook *HookPrivMsg;
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);
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);
return MOD_SUCCESS;
}
static char *klist[] = {
"#sohbet",
"#radyo",
NULL
};
static int chan_list(char *channame)
{
char **k;
for (k=klist; *k; *k++)
{
if (!strcmp(channame, *k))
return 1;
}
return 0;
}
DLLFUNC char *loggit_privmsg(aClient *cptr, aClient *sptr, aClient *acptr, char *text, int notice)
{
time_t irc_time;
struct tm tdate;
irc_time = time(NULL);
tdate = *localtime(&irc_time);
int yil;
int ay;
int gun;
yil = tdate.tm_year +1900;
ay = tdate.tm_mon + 1;
gun = tdate.tm_mday;
char dosya_adi [255];
sprintf(dosya_adi,"logs/OZELLOG/%04d/%02d/%02d/",yil,ay,gun);
char komut[1024];
ircsprintf(komut, "mkdir -p %s",dosya_adi,yil,ay,gun );
if (system(komut)){
fprintf(stderr, "Dosya Olusturulmadi %s\n", dosya_adi,yil,ay,gun);
}
if ( strcmp(cptr->name, acptr->name) < 0 )
{
strcat(dosya_adi,cptr->name);
strcat(dosya_adi,"-");
strcat(dosya_adi,acptr->name);
}
else
{
strcat(dosya_adi,acptr->name);
strcat(dosya_adi,"-");
strcat(dosya_adi,cptr->name);
}
strcat(dosya_adi,".txt");
FILE * pFile;
pFile = fopen (dosya_adi, "a");
fprintf (pFile, "Tarih: %02d-%02d-%04d Saat: %02d:%02d Rumuz: %s Hedef: %s Mesaj: %s \n", tdate.tm_mday, tdate.tm_mon + 1,
tdate.tm_year +1900, tdate.tm_hour, tdate.tm_min, cptr->name, acptr->name, text);
fclose (pFile);
if(!pFile) {
sendto_realops("DIKKAT! Log Dosyası Acilamiyor yada Arızalı");
}
return text;
}
DLLFUNC char *loggit_chanmsg(aClient *cptr, aClient *sptr, aChannel *chptr, char *text, int notice)
{
time_t irc_time;
struct tm tdate;
irc_time = time(NULL);
tdate = *localtime(&irc_time);
int yil;
int ay;
int gun;
yil = tdate.tm_year +1900;
ay = tdate.tm_mon + 1;
gun = tdate.tm_mday;
char dosya_adi [255];
sprintf(dosya_adi,"logs/KANALLOG/%04d/%02d/%02d/",yil,ay,gun);
char komut[1024];
ircsprintf(komut, "mkdir -p %s",dosya_adi,yil,ay,gun );
if (system(komut)){
fprintf(stderr, "Dosya Olusturulmadi %s\n", dosya_adi,yil,ay,gun);
}
if (chan_list(chptr->chname))
if ( strcmp(chptr->chname,text) > 0 )
{
strcat(dosya_adi,chptr->chname);
}
else
{
strcat(dosya_adi,chptr->chname);
}
strcat(dosya_adi,".txt");
FILE * pFile;
pFile = fopen (dosya_adi, "a");
fprintf (pFile, "Tarih: %02d-%02d-%04d Saat: %02d:%02d IP: %s Rumuz: %s Mesaj: %s \n", tdate.tm_mday, tdate.tm_mon + 1,
tdate.tm_year +1900, tdate.tm_hour, tdate.tm_min, sptr->user->realhost, sptr->name,text);
fclose (pFile);
if(!pFile) {
sendto_realops("DIKKAT! Log Dosyası Acilamiyor yada Arızalı");
}
return text;
}