Kod: Kodu kopyalamak için üzerine çift tıklayın!
#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 _WIN32
#include "version.h"
#endif
extern void sendto_one(aClient *to, char *pattern, ...);
#define CFLAG_GIRIS 'X'
#define UFLAG_GIRIS 'X'
#define DelCmode(x) if (x) CmodeDel(x); x = NULL
#define DelUmode(x) if (x) UmodeDel(x); x = NULL
#define DelHook(x) if (x) HookDel(x); x = NULL
DLLFUNC int MOD_UNLOAD(agiris)(int module_unload);
DLLFUNC int cb_join(aClient *sptr, aChannel *chptr, char *parv[]);
static Cmode *AddCmode(Module *module, CmodeInfo *req, Cmode_t *mode);
static Umode *AddUmode(Module *module, char ch, long *mode);
static int cmode_check(aClient *, aChannel *, char *, int, int);
Hook *HookJoin = NULL;
static ModuleInfo *thismodinfo = NULL;
#ifdef HOOKTYPE_REHASH_COMPLETE
static int cb_rehash_complete();
Hook *HookRehashDone;
#endif
Cmode_t MODE_GIRIS = 0L;
long UMODE_GIRIS = 0;
Cmode *ModeGiris = NULL;
Umode *UmodeGiris = NULL;
ModuleHeader MOD_HEADER(giris) = { "m_giris", "$Id: m_giris.c,v 1.11 2008/05/31 16:58 $", "Guvenli Baglanti.. ", "3.2-b8-1", NULL };
DLLFUNC int MOD_TEST(giris)(ModuleInfo *modinfo)
{
CmodeInfo req;
memset(&req, 0, sizeof req);
req.paracount = 0;
req.is_ok = cmode_check;
req.flag = CFLAG_GIRIS;
ModeGiris = AddCmode(modinfo->handle, &req, &MODE_GIRIS);
UmodeGiris = AddUmode(modinfo->handle, UFLAG_GIRIS, &UMODE_GIRIS);
if (!ModeGiris || !UmodeGiris)
{
MOD_UNLOAD(giris)(0);
return MOD_FAILED;
}
return MOD_SUCCESS;
}
DLLFUNC int MOD_INIT(giris)(ModuleInfo *modinfo)
{
thismodinfo = modinfo;
#ifndef STATIC_LINKING
ModuleSetOptions(modinfo->handle, MOD_OPT_PERM);
#endif
return MOD_SUCCESS;
}
DLLFUNC int MOD_LOAD(giris)(int module_load)
{
HookJoin = HookAddEx(thismodinfo->handle, HOOKTYPE_PRE_LOCAL_JOIN, cb_join);
if (!HookJoin)
{
sendto_realops("m_giris: Couldn't load properly: %s", ModuleGetErrorStr(thismodinfo->handle));
return MOD_FAILED;
}
#ifdef HOOKTYPE_REHASH_COMPLETE
HookRehashDone = HookAddEx(thismodinfo->handle, HOOKTYPE_REHASH_COMPLETE, cb_rehash_complete);
if (!HookRehashDone)
{
sendto_realops("m_giris: Couldn't load properly: %s", ModuleGetErrorStr(thismodinfo->handle));
return MOD_FAILED;
}
#endif
return MOD_SUCCESS;
}
DLLFUNC int MOD_UNLOAD(giris)(int module_unload)
{
DelCmode(ModeGiris);
DelUmode(UmodeGiris);
DelHook(HookJoin);
#ifdef HOOKTYPE_REHASH_COMPLETE
DelHook(HookRehashDone);
#endif
return MOD_SUCCESS;
}
static Cmode *AddCmode(Module *module, CmodeInfo *req, Cmode_t *mode)
{
Cmode *cmode;
*mode = 0;
cmode = CmodeAdd(module, *req, mode);
#ifndef STATIC_LINKING
if (ModuleGetError(module) != MODERR_NOERROR || !cmode)
{
config_error("HATA! +%c Modul yüklenemedi.. %s: %s", req->flag, MOD_HEADER(giris).name, ModuleGetErrorStr(module));
return NULL;
}
#else
if (!cmode)
{
config_error("HATA! +%c Modul yüklenemedi.. %s", req->flag, MOD_HEADER(giris).name);
return NULL;
}
#endif
return cmode;
}
static Umode *AddUmode(Module *module, char ch, long *mode)
{
Umode *umode;
*mode = 0;
umode = UmodeAdd(module, ch, UMODE_GLOBAL, NULL, mode);
#ifndef STATIC_LINKING
if (ModuleGetError(module) != MODERR_NOERROR || !umode)
{
config_error("Hata.. +%c Modul yüklenemedi.. %s: %s", ch, MOD_HEADER(giris).name, ModuleGetErrorStr(module));
return NULL;
}
#else
if (!umode)
{
config_error("Hata! +%c Modul yüklenemedi.. %s", ch, MOD_HEADER(giris).name);
return NULL;
}
#endif
return umode;
}
static int cmode_check(aClient *sptr, aChannel *chptr, char *para, int type, int what)
{
if ((type == EXCHK_ACCESS) || (type == EXCHK_ACCESS_ERR))
{
if (IsPerson(sptr) && !IsULine(sptr) && !is_chan_op(sptr, chptr))
{
if (type == EXCHK_ACCESS_ERR)
sendto_one(sptr, err_str(ERR_CHANOPRIVSNEEDED), me.name, sptr->name, chptr->chname);
return EX_DENY;
}
return EX_ALLOW;
}
return 0;
}
int cb_join(aClient *sptr, aChannel *chptr, char *parv[])
{
if (chptr && !IsMember(sptr, chptr))
{
if ((chptr->mode.extmode & CFLAG_GIRIS) && !(sptr->umodes & UMODE_GIRIS))
{
sendto_one(sptr, ":%s %s %s :Kanal Guvenlidir, Bu Kanala giremezsiniz.", me.name, IsWebTV(sptr) ? "PRIVMSG" : "NOTICE", sptr->name, chptr->chname, sptr->name);
return HOOK_DENY;
}
}
return HOOK_CONTINUE;
}
#ifdef HOOKTYPE_REHASH_COMPLETE
static int cb_rehash_complete()
{
HookJoin = HookAddEx(thismodinfo->handle, HOOKTYPE_PRE_LOCAL_JOIN, cb_join);
if (!HookJoin)
{
sendto_realops("m_giris: Modul acilamiyor.. %s", ModuleGetErrorStr(thismodinfo->handle));
return MOD_FAILED;
}
}
#endif
verirsin bu sekil olabilir bence dediğin..