Tekil Mesaj gösterimi
Alt 28 Aralık 2017, 17:29   #3
Çevrimdışı
Turk06
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (0)
IF Ticaret Yüzdesi:(%)
Cevap: RuLzzServices-0.6 sorunu




Emrehan Nickli Üyeden Alıntı
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
Merhaba, RuLzz*/modules/operserv/news.c dosyasını paylaşın bir inceleyelim.

PHP Kod:   Kodu kopyalamak için üzerine çift tıklayın!
/* News module.
 * Based on code by Andrew Kempe (TheShadow) <
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
>
 *
 * IRC Services is copyright (c) 1996-2007 Andrew Church.
 *     E-mail: <
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
>
 * Parts written by Andrew Kempe and others.
 * This program is free but copyrighted software; see the file COPYING for
 * details.
 */

#include "services.h"
#include "modules.h"
#include "conffile.h"
#include "commands.h"
#include "language.h"

#include "operserv.h"
#include "news.h"
#include "modules/nickserv/nickserv.h"

/*************************************************************************/

static Module *module;
static 
Module *module_operserv;

static 
char *NewsDBName;

static 
int db_opened 0;

static 
void do_logonnews(User *u);
static 
void do_opernews(User *u);

static 
Command cmds[] = {
    
/* Anyone can use *NEWS LIST, but *NEWS {ADD,DEL} are reserved for
     * Services operators.  (The command routines check permissions.) */
    
{"LOGONNEWS"do_logonnewsNULL,             NEWS_HELP_LOGON,     -1,-1},
    {
"OPERNEWS",  do_opernews,  NULL,             NEWS_HELP_OPER,      -1,-1},
    {
NULL}
};







/*************************************************************************/

/* List of messages for each news type.  This simplifies message sending. */

#define MSG_SYNTAX    0
#define MSG_LIST_HEADER    1
#define MSG_LIST_ENTRY    2
#define MSG_LIST_NONE    3
#define MSG_ADD_SYNTAX    4
#define MSG_ADD_FULL    5
#define MSG_ADDED    6
#define MSG_DEL_SYNTAX    7
#define MSG_DEL_NOT_FOUND 8
#define MSG_DELETED    9
#define MSG_DEL_NONE    10
#define MSG_DELETED_ALL    11
#define MSG_MAX        11

struct newsmsgs {
    
int16 type;
    const 
char *name;
    
int msgs[MSG_MAX+1];
};
static 
struct newsmsgs msgarray[] = {
    { 
NEWS_LOGON"LOGON",
    { 
NEWS_LOGON_SYNTAX,
      
NEWS_LOGON_LIST_HEADER,
      
NEWS_LOGON_LIST_ENTRY,
      
NEWS_LOGON_LIST_NONE,
      
NEWS_LOGON_ADD_SYNTAX,
      
NEWS_LOGON_ADD_FULL,
      
NEWS_LOGON_ADDED,
      
NEWS_LOGON_DEL_SYNTAX,
      
NEWS_LOGON_DEL_NOT_FOUND,
      
NEWS_LOGON_DELETED,
      
NEWS_LOGON_DEL_NONE,
      
NEWS_LOGON_DELETED_ALL
    
}
    },
    { 
NEWS_OPER"OPER",
    { 
NEWS_OPER_SYNTAX,
      
NEWS_OPER_LIST_HEADER,
      
NEWS_OPER_LIST_ENTRY,
      
NEWS_OPER_LIST_NONE,
      
NEWS_OPER_ADD_SYNTAX,
      
NEWS_OPER_ADD_FULL,
      
NEWS_OPER_ADDED,
      
NEWS_OPER_DEL_SYNTAX,
      
NEWS_OPER_DEL_NOT_FOUND,
      
NEWS_OPER_DELETED,
      
NEWS_OPER_DEL_NONE,
      
NEWS_OPER_DELETED_ALL
    
}
    }
};

static 
int *findmsgs(int16 typechar **typename) {
    
int i;
    for (
0lenof(msgarray); i++) {
    if (
msgarray[i].type == type) {
        if (
typename)
        *
typename = (char *)msgarray[i].name;
        return 
msgarray[i].msgs;
    }
    }
    return 
NULL;
}

/*************************************************************************/

/* Main handler for NEWS commands. */
static void do_news(User *uint16 type);

/* Lists all a certain type of news. */
static void do_news_list(User *uint16 typeint *msgs);

/* Add news items. */
static void do_news_add(User *uint16 typeint *msgs, const char *typename);
static 
int add_newsitem(User *u, const char *textint16 type);

/* Delete news items. */
static void do_news_del(User *uint16 typeint *msgs, const char *typename);
static 
int del_newsitem(int numint16 type);

/*************************************************************************/
/***************************** News display ******************************/
/*************************************************************************/

static void display_news(User *uint16 type)
{
    
NewsItem *news, *disp[NEWS_DISPCOUNT];
    
int count 0;    /* Number we're going to show--not more than 3 */
    
int msg;

    if (
type == NEWS_LOGON) {
    
msg NEWS_LOGON_TEXT;
    } else if (
type == NEWS_OPER) {
    
msg NEWS_OPER_TEXT;
    } else {
    
module_log("Invalid type (%d) to display_news()"type);
    return;
    }

    for (
news first_news(); newsnews next_news()) {
    if (
count >= NEWS_DISPCOUNT)
        break;
    if (
news->type == type) {
        
disp[count] = news;
        
count++;
        
news->locked++;
    }
    }
    while (--
count >= 0) {
    
char timebuf[BUFSIZE];

    
strftime_lang(timebufsizeof(timebuf), u->ngi,
              
STRFTIME_SHORT_DATE_FORMATdisp[count]->time);
    
notice_lang(s_GlobalNoticerumsgtimebufdisp[count]->text);
    }
}

/*************************************************************************/
/***************************** News editing ******************************/
/*************************************************************************/

static void do_logonnews(User *u)
{
    
do_news(uNEWS_LOGON);

send_cmd(s_GlobalNoticer"NOTICE %s ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s \2"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s Merhaba, \2 %s\2"u->nicku->nick);
send_cmd(s_GlobalNoticer"NOTICE %s Kullanilan Services VERSION -> RuLzzServices-0.5"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s Bu Services Surumu, Orjinalliginin disinda"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s Sadece \2 toXic \2 Tarafindan Kodlanmis ve gelistirilmistir."u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s Servisler uzerindeki eklentileri, \2 /Services BILGI \2 Komutu ile listeleyebilirsiniz."u->nick);
//send_cmd(s_GlobalNoticer, "NOTICE %s Services Hakkindaki bilgiler icin, \2/Services toXic\2 Komutunu kullaniniz.", u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s \2RuLzz\2 Cagin Modern ustu IRC Servicesi"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s \2"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"u->nick);

}

static 
void do_opernews(User *u)
{
    
do_news(uNEWS_OPER);
}

/*************************************************************************/

/* Main news command handling routine. */
static void do_news(User *uint16 type)
{
    const 
char *cmd strtok(NULL" ");
    
char *typename;
    
int *msgs;

    
msgs findmsgs(type, &typename);
    if (!
msgs) {
    
module_log("Invalid type to do_news()");
    return;
    }

    if (!
cmd)
    
cmd "";

    if (
stricmp(cmd"LIST") == 0) {
    
do_news_list(utypemsgs);

    } else if (
stricmp(cmd"ADD") == 0) {
    if (
is_services_oper(u))
        
do_news_add(utypemsgstypename);
    else
        
notice_lang(s_OperServuPERMISSION_DENIED);

    } else if (
stricmp(cmd"DEL") == 0) {
    if (
is_services_oper(u))
        
do_news_del(utypemsgstypename);
    else
        
notice_lang(s_OperServuPERMISSION_DENIED);

    } else {
    
char buf[32];
    
snprintf(bufsizeof(buf), "%sNEWS"typename);
    
syntax_error(s_OperServubufmsgs[MSG_SYNTAX]);
    }
}

/*************************************************************************/

/* Handle a {LOGON,OPER}NEWS LIST command. */

static void do_news_list(User *uint16 typeint *msgs)
{
    
NewsItem *news;
    
int count 0;
    
char timebuf[64];

    for (
news first_news(); newsnews next_news()) {
    if (
news->type == type) {
        if (
count == 0)
        
notice_lang(s_OperServumsgs[MSG_LIST_HEADER]);
        
strftime_lang(timebufsizeof(timebuf), u->ngi,
              
STRFTIME_DATE_TIME_FORMATnews->time);
        
notice_lang(s_OperServumsgs[MSG_LIST_ENTRY],
            
news->numtimebuf,
            *
news->who news->who "<unknown>",
            
news->text);
        
count++;
    }
    }
    if (
count == 0)
    
notice_lang(s_OperServumsgs[MSG_LIST_NONE]);
}

/*************************************************************************/

/* Handle a {LOGON,OPER}NEWS ADD command. */

static void do_news_add(User *uint16 typeint *msgs, const char *typename)
{
    
char *text strtok_remaining();

    if (!
text) {
    
char buf[32];
    
snprintf(bufsizeof(buf), "%sNEWS"typename);
    
syntax_error(s_OperServubufmsgs[MSG_ADD_SYNTAX]);
    } else {
    
int n add_newsitem(utexttype);
    if (
0)
        
notice_lang(s_OperServumsgs[MSG_ADD_FULL]);
    else
        
notice_lang(s_OperServumsgs[MSG_ADDED], n);
    if (
readonly)
        
notice_lang(s_OperServuREAD_ONLY_MODE);
    }
}


/* Actually add a news item.  Return the number assigned to the item, or -1
 * if the news list is full (MAX_NEWS items).
 */

static int add_newsitem(User *u, const char *textint16 type)
{
    
NewsItem *news;
    
int num;

    if (
news_count() >= MAX_NEWS)
    return -
1;

    
num 0;
    for (
news first_news(); newsnews next_news()) {
    if (
news->type == type && num news->num)
        
num news->num;
    }
    if (
num+num) {
    
module_log("BUG: add_newsitem(): news number overflow (MAX_NEWS"
           " too small?)"
);
    return -
1;
    }
    
news scalloc(1sizeof(*news));
    
news->type type;
    
news->num num+1;
    
news->text sstrdup(text);
    
news->time time(NULL);
    
strscpy(news->whou->nickNICKMAX);
    
add_news(news);
    return 
num+1;
}

/*************************************************************************/

/* Handle a {LOGON,OPER}NEWS DEL command. */

static void do_news_del(User *uint16 typeint *msgs, const char *typename)
{
    
char *text strtok(NULL" ");

    if (!
text) {
    
char buf[32];
    
snprintf(bufsizeof(buf), "%sNEWS"typename);
    
syntax_error(s_OperServubufmsgs[MSG_DEL_SYNTAX]);
    } else {
    if (
stricmp(text"ALL") != 0) {
        
int num atoi(text);
        if (
num && del_newsitem(numtype))
        
notice_lang(s_OperServumsgs[MSG_DELETED], num);
        else
        
notice_lang(s_OperServumsgs[MSG_DEL_NOT_FOUND], num);
    } else {
        if (
del_newsitem(0type))
        
notice_lang(s_OperServumsgs[MSG_DELETED_ALL]);
        else
        
notice_lang(s_OperServumsgs[MSG_DEL_NONE]);
    }
    if (
readonly)
        
notice_lang(s_OperServuREAD_ONLY_MODE);
    }
}


/* Actually delete a news item.  If `num' is 0, delete all news items of
 * the given type.  Returns the number of items deleted.
 */

static int del_newsitem(int numint16 type)
{
    
NewsItem *news;
    
int count 0;

    for (
news first_news(); newsnews next_news()) {
    if (
news->type == type && (num == || news->num == num)) {
        
del_news(news);
        
count++;
    }
    }
    return 
count;
}

/*************************************************************************/
/*************************** Callback routines ***************************/
/*************************************************************************/

/* Callback for users logging on. */

static int new_user_callback(User *u)
{




    
display_news(uNEWS_LOGON);
 
send_cmd(s_GlobalNoticer"NOTICE %s :\2坍之才~之才~之才~之才~之才~之才~之才~之\2"u->nick);
    
send_cmd(s_GlobalNoticer"NOTICE %s :En Son kaydedilen nick: \2%s\2"u->nicklast_register_nick);
    
send_cmd(s_GlobalNoticer"NOTICE %s :En Son kaydedilen kanal: \2%s\2"u->nicklast_register_chan);
    
send_cmd(s_GlobalNoticer"NOTICE %s :\2坍之才~之才~之才~之才~之才~之才~之才~之\2"u->nick);
  
NickInfo *ni;
NickInfo *SkyMax first_nickinfo(), *TempNI=NULL;
if (
SkyMax) {
  for (
TempNI first_nickinfo(); TempNITempNI next_nickinfo()) {
    if (
SkyMax->toplamzaman TempNI->toplamzaman)
      
SkyMax TempNI;
  }

  
send_cmd(s_GlobalNoticer"NOTICE %s :En Fazla online olan nick : \2%s"u->nickSkyMax->nick);
 
send_cmd(s_GlobalNoticer"NOTICE %s Online Suresi  \2 \2%d\2 Gun, \2%d\2 Saat, \2%d\2 Dakika, \2%d\2 Saniye.",
u->nick,  (ni->toplamzaman 86400), ((ni->toplamzaman 86400) / 3600),
  (((
ni->toplamzaman 86400) % 3600) / 60),
  ((((
ni->toplamzaman 86400) % 3600) % 60) % 60));
}
send_cmd(s_GlobalNoticer"NOTICE %s :壯壯壯壯壯壯壯壯壯壯壯壯壯壯壯壯壯壯壯?"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :Sunucu Yoneticilerini /Motd Komutu ile gorebilirsiniz."u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :Vhost Hakkinda Yardim icin, /NS VhostHelp"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :Profil Hakkinda Yardim icin, /NS Profil Komutunu Kullaniniz."u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :Sansinizi denemek icin, /NS Sans Komutunu Kullaniniz."u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :Random bir kanala girmek icin, /NS Kanal Komutunu Kullaniniz."u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :Kendi Puaninini gormek icin /NS Points komutunu, "u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :Baskasininkini gormek icin /NS Points NICK komutunu uygulayin"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :Ne kadar cok online olursaniz, o kadar cok aktiflik puani kazanirsiniz."u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :/NS SET DURUM MESAJ komutu ile icinizden gecenleri yazabilirsiniz."u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :Arkadaslarinizin, Sevdiklerinizin durumuna /NS DURUM NICK komutu ile bakabilir, takip edebilirsiniz."u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :Kullanilan Services IRCServices EXT RuLzzSpecial "u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :RuLzzSpecial eklentileri (toXic Tarafindan kurgulanip, sistemlenip, kodlanip gelistirilmistir.)"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :Ayrintili bilgiler icin, /services bilgi Komutunu kullaniniz."u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :NOT: Network uzerinde kayitli bulunan tum nick ve kanallar, yonetime aittir."u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EzgiSohbet~~~~~~~~~~~~~~~~~~~~~~~~~~~~"u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :SUNUCU Bilgileri Gosteriliyor.."u->nick);

    
long countmem;
time_t uptime time(NULL) - start_time;
  
    
int days uptime/86400hours = (uptime/3600)%24,
        
mins = (uptime/60)%60secs uptime%60;
    
char timebuf[BUFSIZE];

        
get_user_stats(&count, &mem);
        
notice_lang(s_OperServuOPER_STATS_ALL_USER_MEM,
                        
count, (mem+512) / 1024);
        
get_channel_stats(&count, &mem);
        
notice_lang(s_OperServuOPER_STATS_ALL_CHANNEL_MEM,
                        
count, (mem+512) / 1024);
        
get_server_stats(&count, &mem);
        
notice_lang(s_OperServuOPER_STATS_ALL_SERVER_MEM,
                        
count, (mem+512) / 1024);
  
notice_lang(s_OperServuOPER_STATS_CURRENT_USERSusercntopcnt);
    
strftime_lang(timebufsizeof(timebuf), u->ngi,
                  
STRFTIME_DATE_TIME_FORMATmaxusertime);
    
notice_lang(s_OperServuOPER_STATS_MAX_USERSmaxusercnttimebuf);
    if (
days >= 1) {
        const 
char *str getstring(u->ngidays!=STR_DAYS STR_DAY);
        
notice_lang(s_OperServuOPER_STATS_UPTIME_DHMS,
                
daysstrhoursminssecs);
    } else {
        
notice_lang(s_OperServuOPER_STATS_UPTIME_HM_MS,
                    
maketime(u->ngiuptimeMT_DUALUNIT|MT_SECONDS));
    }


 
uint32 readwrittensocksizetotalsize;
            
int ratio1ratio2;
            
sock_rwstat(servsock, &read, &written);
            
sock_bufstat(servsock, &socksize, &totalsize, &ratio1, &ratio2);
            
socksize /= 1024;
            
totalsize /= 1024;
            
notice_lang(s_OperServuOPER_STATS_KBYTES_READread);
            
notice_lang(s_OperServuOPER_STATS_KBYTES_WRITTENwritten);
send_cmd(s_GlobalNoticer"NOTICE %s :Sunucu bilgileri sonu."u->nick);
send_cmd(s_GlobalNoticer"NOTICE %s :壯壯壯壯壯壯壯壯壯壯壯壯壯壯壯壯壯壯壯?"u->nick);

    return 
0;
}

/*************************************************************************/

/* Callback to watch for mode +o to send oper news. */

static int user_mode_callback(User *uint modecharint add)
{
    if (
modechar == 'o' && add)
    
display_news(uNEWS_OPER);
    return 
0;
}

/*************************************************************************/

/* Callback for saving data. */

static int do_save_data(void)
{
    
sync_news_db(NewsDBName);
    return 
0;
}

/*************************************************************************/
/***************************** Module stuff ******************************/
/*************************************************************************/

const int32 module_version MODULE_VERSION_CODE;

ConfigDirective module_config[] = {
    { 
"NewsDB",           { { CD_STRINGCF_DIRREQ, &NewsDBName } } },
    { 
NULL }
};

/*************************************************************************/

int init_module(Module *module_)
{
    
module module_;

    
module_operserv find_module("operserv/main");
    if (!
module_operserv) {
    
module_log("Main OperServ module not loaded");
    return 
0;
    }
    
use_module(module_operserv);

    if (!
register_commands(module_operservcmds)) {
    
module_log("Unable to register commands");
    
exit_module(0);
    return 
0;
    }

    if (!
add_callback(NULL"save data"do_save_data)
     || !
add_callback(NULL"user create"new_user_callback)
     || !
add_callback(NULL"user MODE"user_mode_callback)
    ) {
    
module_log("Unable to add callbacks");
    
exit_module(0);
    return 
0;
    }

    
open_news_db(NewsDBName);
    
db_opened 1;

    return 
1;
}

/*************************************************************************/

int exit_module(int shutdown_unused)
{
#ifdef CLEAN_COMPILE
    
shutdown_unused shutdown_unused;
#endif

    
if (db_opened)
    
close_news_db(NewsDBName);

    
remove_callback(NULL"user create"new_user_callback);
    
remove_callback(NULL"user MODE"user_mode_callback);
    
remove_callback(NULL"save data"do_save_data);

    if (
module_operserv) {
    
unregister_commands(module_operservcmds);
    
unuse_module(module_operserv);
    
module_operserv NULL;
    }

    return 
1;
}

/*************************************************************************/ 


 
Alıntı ile Cevapla

IRCForumlari.NET Reklamlar
sohbet odaları eglen sohbet reklamver