Exemple #1
0
VOIDSIG signal_rehash(int signum)
{
#ifdef	POSIX_SIGNALS
    struct sigaction act;
#endif
#ifdef SIGHUP
    if (signum == SIGHUP) {
#endif
        Dadmin *a;
        int i;

        alog(LOG_NORMAL,
             "Received SIGHUP: Saving Databases & Rehash Configuration");
        if (initconf(denora->config, 1, mainconf) == -1) {
            denora->qmsg = calloc(50, 1);
            if (!denora->qmsg) {
                denora->qmsg = sstrdup(langstr(ALOG_ERR_REHASH_NO_MEM));
            } else {
                ircsnprintf(denora->qmsg, sizeof(denora->qmsg), "%s",
                            langstr(ALOG_ERR_REHASH));
            }
            denora->quitting = 1;
            send_event(EVENT_SIGNAL, 2, "SIGHUP", denora->qmsg);
        } else {
            /* Remove all config file admins from admin struct before re-reading config file */
            for (i = 0; i < 1024; i++) {
                for (a = adminlists[i]; a; a = a->next) {
                    if (a->configfile) {
                        free_admin(a);
                    }
                    break;
                }
            }
            merge_confs();
        }
        /* Reload GeoIP db files */
        if (gi) {
			GeoIP_delete(gi);
		}
		if (gi_v6) {
			GeoIP_delete(gi_v6);
		}
	    gi = GeoIP_new(GEOIP_STANDARD);
	    gi_v6 = GeoIP_open_type(GEOIP_COUNTRY_EDITION_V6, GEOIP_STANDARD);
#ifdef	POSIX_SIGNALS
        act.sa_handler = signal_rehash;
        act.sa_flags = 0;

        (void) sigemptyset(&act.sa_mask);
        (void) sigaddset(&act.sa_mask, SIGHUP);
        (void) sigaction(SIGHUP, &act, NULL);
#else
# ifndef _WIN32
        (void) signal(SIGHUP, signal_rehash);   /* sysV -argv */
# endif
#endif
#ifdef SIGHUP
    }
#endif
}
Exemple #2
0
int chanstats_weekly(const char *name)
{
    if (!denora->do_sql) {
        return MOD_CONT;
    }
    if (!name) {
        return MOD_CONT;
    }
    SET_SEGV_LOCATION();
    alog(LOG_NORMAL, langstr(ALOG_RESETTING_WEEKLY));
    rdb_query
        (QUERY_LOW,
         "UPDATE %s SET letters=0, words=0, line=0, actions=0, smileys=0, "
         "kicks=0, modes=0, topics=0, wasted=0, "
         "time0=0, time1=0, time2=0, time3=0, time4=0, time5=0, time6=0, time7=0, "
         "time8=0, time9=0, time10=0, time11=0, time12=0, time13=0, time14=0, "
         "time15=0, time16=0, time17=0, time18=0, time19=0, time20=0, time21=0, "
         "time22=0, time23=0  WHERE type=2;", UStatsTable);
    rdb_query(QUERY_LOW,
              "UPDATE %s SET letters=0, words=0, line=0, actions=0, smileys=0, "
              "kicks=0, modes=0, topics=0, "
              "time0=0, time1=0, time2=0, time3=0, time4=0, time5=0, time6=0, time7=0, "
              "time8=0, time9=0, time10=0, time11=0, time12=0, time13=0, time14=0, "
              "time15=0, time16=0, time17=0, time18=0, time19=0, time20=0, time21=0, "
              "time22=0, time23=0  WHERE type=2;", CStatsTable);
    rdb_query(QUERY_LOW,
              "DELETE %s.*,%s.* FROM %s,%s WHERE %s.uname = %s.uname AND %s.lastspoke < %i AND %s.ignore = 'N';",
              UStatsTable, AliasesTable, UStatsTable, AliasesTable,
              UStatsTable, AliasesTable, UStatsTable,
              (time(NULL) - ClearInActive), AliasesTable);
    return MOD_CONT;
}
Exemple #3
0
int DenoraInit(int argc, char **argv)
{
    if (denora->protocoldebug) {
        protocol_debug(NULL, argc, argv);
    }
    /* Only 1 protocol module may be loaded */
    if (protocolModuleLoaded()) {
        alog(LOG_NORMAL, langstr(ALOG_MOD_BE_ONLY_ONE));
        return MOD_STOP;
    }

    moduleAddAuthor("Denora");
    moduleAddVersion("$Id: scarynet.c 64 2007-05-08 16:48:13Z outsider $");
    moduleSetType(PROTOCOL);

    pmodule_ircd_version("ScaryNet IRCu 2.10.11");
    pmodule_ircd_cap(myIrcdcap);
    pmodule_ircd_var(myIrcd);
    pmodule_ircd_useTSMode(0);
    pmodule_irc_var(IRC_SCARYNET);
    IRCDModeInit();
    pmodule_oper_umode(UMODE_o);

    moduleAddIRCDCmds();
    moduleAddIRCDMsgs();

    return MOD_CONT;
}
Exemple #4
0
int DenoraInit(int argc, char **argv)
{
    if (denora->protocoldebug) {
        protocol_debug(NULL, argc, argv);
    }
    /* Only 1 protocol module may be loaded */
    if (protocolModuleLoaded()) {
        alog(LOG_NORMAL, langstr(ALOG_MOD_BE_ONLY_ONE));
        return MOD_STOP;
    }

    moduleAddAuthor("Denora");
    moduleAddVersion("$Id: bahamut.c 388 2011-01-04 21:12:18Z hal9000 $");
    moduleSetType(PROTOCOL);

    pmodule_ircd_version("BahamutIRCd 1.4.*/1.8.*");
    pmodule_ircd_cap(myIrcdcap);
    pmodule_ircd_var(myIrcd);
    pmodule_ircd_useTSMode(0);

    IRCDModeInit();
    pmodule_oper_umode(UMODE_o);
    pmodule_irc_var(IRC_BAHAMUT);
    moduleAddIRCDCmds();
    moduleAddIRCDMsgs();
    return MOD_CONT;
}
Exemple #5
0
void
house::send_message() {
    QString t = _msg_field->text();

    if (t.isEmpty()) return;

    if (!_flood_control.allow_send()) {
        _chat_view->status_message(langstr("chat/flood_control"));
        return;
    }
    if (t.length() > (int)app_opts.limit_chat_msg())
        t.truncate(app_opts.limit_chat_msg());

    // IMPROVE Qt check if this needed
    // t.substitute("\r", "");


    // Check for a command
    if (!_chat_command(t)) {
        // Sending a public message
        message_send *msg =
          new message_send(::message::send,
                           t.toLatin1().constData(),
                           self_model()->user().id(),
                           self_model()->sequence(),
                           0);
        net_messenger()->send_msg(msg);
    }

    _msg_field->setText("");

    emit send_message();
}
Exemple #6
0
void
house::_check_if_self_blocked() {
    if (self_model()->user().ip_as_string().empty() ||
        _global_ip_block.size() == 0)
    {
        return;
    }

    struct in_addr a;
    if (!ACE_OS::inet_aton(self_model()->user().ip_as_string().c_str(), &a)) {
        ACE_ERROR((LM_ERROR, "house::_check_if_self_blocked: "
                   "could not make IP of %s\n",
                   self_model()->user().ip_as_string().c_str()));
        return;
    }

    a.s_addr = ntohl(a.s_addr);

    if (_global_ip_block.is_blocked(a.s_addr)) {
        // Let user know he is in global block list, how unfortunate for him
        // IMPROVE Qt test this
        // IMPROVE Qt there used to be url to RV Pub Forum in here, see below. Not sure if it's really necessary anymore.
        QMessageBox::information(::house_win(), langstr("app/self_on_global_ignore_topic"), langstr("app/self_on_global_ignore"));

//        house_message_box::information(
//            ::app(), FX::MBOX_OK,
//            conf()->get("www", "pub_forum").c_str(),
//            langstr("app/self_on_global_ignore_topic"),
//            langstr("app/self_on_global_ignore")
//        );
    }
}
Exemple #7
0
int DenoraInit(int argc, char **argv)
{
    if (denora->protocoldebug) {
        protocol_debug(NULL, argc, argv);
    }
    /* Only 1 protocol module may be loaded */
    if (protocolModuleLoaded()) {
        alog(LOG_NORMAL, langstr(ALOG_MOD_BE_ONLY_ONE));
        return MOD_STOP;
    }
    /* Actual module code stuff */
    moduleAddAuthor("Denora");
    moduleAddVersion("$Id: asuka.c 388 2011-01-04 21:12:18Z hal9000 $");
    moduleSetType(PROTOCOL);
    /* protocol version and name that we support */
    pmodule_ircd_version("Asuka 1.2.1");
    /* set the flag of what ircd */
    pmodule_irc_var(IRC_ASUKA);

    pmodule_ircd_cap(myIrcdcap);
    pmodule_ircd_var(myIrcd);
    pmodule_ircd_useTSMode(0);

    IRCDModeInit();
    pmodule_oper_umode(UMODE_o);

    moduleAddIRCDCmds();
    moduleAddIRCDMsgs();

    return MOD_CONT;
}
Exemple #8
0
int DenoraInit(int argc, char **argv)
{
    if (denora->protocoldebug) {
        protocol_debug(NULL, argc, argv);
    }
    /* Only 1 protocol module may be loaded */
    if (protocolModuleLoaded()) {
        alog(LOG_NORMAL, langstr(ALOG_MOD_BE_ONLY_ONE));
        return MOD_STOP;
    }

    moduleAddAuthor("Denora");
    moduleAddVersion
        ("$Id$");
    moduleSetType(PROTOCOL);

    pmodule_ircd_version("InspIRCd 1.1.x");
    pmodule_ircd_cap(myIrcdcap);
    pmodule_ircd_var(myIrcd);
    pmodule_ircd_useTSMode(0);
    pmodule_irc_var(IRC_INSPIRCD11);
    IRCDModeInit();
    pmodule_oper_umode(UMODE_o);

    moduleAddIRCDCmds();
    moduleAddIRCDMsgs();

    return MOD_CONT;
}
Exemple #9
0
int chanstats_daily(const char *name)
{
    if (!denora->do_sql) {
        return MOD_CONT;
    }
    if (!name) {
        return MOD_CONT;
    }
    SET_SEGV_LOCATION();
    alog(LOG_NORMAL, langstr(ALOG_RESET_DAILY));
    rdb_query
        (QUERY_LOW,
         "UPDATE %s SET letters=0, words=0, line=0, actions=0, smileys=0, "
         "kicks=0, modes=0, topics=0, wasted=0, "
         "time0=0, time1=0, time2=0, time3=0, time4=0, time5=0, time6=0, time7=0, "
         "time8=0, time9=0, time10=0, time11=0, time12=0, time13=0, time14=0, "
         "time15=0, time16=0, time17=0, time18=0, time19=0, time20=0, time21=0, "
         "time22=0, time23=0  WHERE type=1;", UStatsTable);
    rdb_query(QUERY_LOW,
              "UPDATE %s SET letters=0, words=0, line=0, actions=0, smileys=0, "
              "kicks=0, modes=0, topics=0, "
              "time0=0, time1=0, time2=0, time3=0, time4=0, time5=0, time6=0, time7=0, "
              "time8=0, time9=0, time10=0, time11=0, time12=0, time13=0, time14=0, "
              "time15=0, time16=0, time17=0, time18=0, time19=0, time20=0, time21=0, "
              "time22=0, time23=0  WHERE type=1;", CStatsTable);
    return MOD_CONT;
}
Exemple #10
0
void
chat::_handle_global_ignore(::message *msg) {
    ACE_DEBUG((LM_DEBUG, "chat::_handle_global_ignore"));
    message_global_ignore *m = dynamic_ptr_cast<message_global_ignore>(msg);
    message_global_ignore::ip_list_type::const_iterator i = m->ip_begin();

    bool first = true;
    for (; i != m->ip_end(); i++) {
        if (first) {
            status_message(langstr("chat/global_ignore"));
            first = false;
        }
        status_message(
            langstr("chat/user_global_ignore",
                    i->userid.c_str(), i->reason.c_str())
        );
    }
}
Exemple #11
0
void Win32LoadCoreDir(char *dirname)
{
#ifdef USE_MODULES
    BOOL fFinished;
    HANDLE hList;
    TCHAR szDir[MAX_PATH + 1];
    TCHAR szSubDir[MAX_PATH + 1];
    WIN32_FIND_DATA FileData;
    char *mname = NULL;
    Module *m;
    int status;
    char buffer[_MAX_PATH];

    /* Get the current working directory: */
    if (_getcwd(buffer, _MAX_PATH) == NULL) {
        alog(LOG_DEBUG, "debug: Unable to set Current working directory");
    }
    ircsnprintf(szDir, sizeof(szDir), "%s\\%s\\*", buffer, dirname);

    hList = FindFirstFile(szDir, &FileData);
    if (hList != INVALID_HANDLE_VALUE) {
        fFinished = FALSE;
        while (!fFinished) {
            if (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
                mname = sstrdup(FileData.cFileName);
                mname[strlen(FileData.cFileName) - 4] = '\0';
                m = findModule(mname);
                if (!m) {
                    m = createCoreModule(mname);
                    mod_current_module = m;
                    mod_current_user = NULL;
                    alog(LOG_DEBUG, "trying to load [%s]",
                         mod_current_module->name);
                    status = loadCoreModule(mod_current_module, NULL);
                    alog(LOG_DEBUG, langstr(ALOG_MOD_STATUS), status,
                         ModuleGetErrStr(status));
                    if (status != MOD_ERR_OK) {
                        destroyModule(m);
                    }
                    mod_current_module = NULL;
                    mod_current_user = NULL;
                }
                dfree(mname);
            }
            if (!FindNextFile(hList, &FileData)) {
                if (GetLastError() == ERROR_NO_MORE_FILES) {
                    fFinished = TRUE;
                }
            }
        }
    } else {
        printf("Invalid File Handle. GetLastError reports %d\n",
               GetLastError());
    }
    FindClose(hList);
#endif
}
Exemple #12
0
// rooms_view::observer interface
void
house::room_added(const chat_gaming::room &r) {
    _chat_view->status_message(langstr("chat/room_created", r.topic().c_str()));
    // Don't flash the window, however, if playing or in some room
    // already
    if (app_opts.flash_new_room() &&
        self_model()->user().status() != chat_gaming::user::status_playing &&
        self_model()->user().room_id().empty())
    {
        os::flash_window(this);
    }
}
Exemple #13
0
router_fw_help::router_fw_help(QWidget *parent) : modal_dialog_guard(parent) {
    this->setWindowTitle(langstr("app/dht_connect_err_title"));

    QVBoxLayout *l = new QVBoxLayout;
    l->setSpacing(0);

    l->addWidget(new QLabel(langstr_range("app/dht_connect_err",1,9,"\n").c_str()));

    /* Button part and layout */
    l->addStretch(1);
    QDialogButtonBox *button_box = new QDialogButtonBox;
    QPushButton *ok_button = new QPushButton(langstr("common/ok_button"), this);
    button_box->addButton(ok_button, QDialogButtonBox::AcceptRole);
    l->addWidget(button_box);

    connect(ok_button, SIGNAL(clicked()), this, SLOT(accept()));

    this->setLayout(l);

    ACE_DEBUG((LM_DEBUG, "router_fw_help::ctor() exit\n"));
}
Exemple #14
0
bool
house::handle_external_ip_message(::message *msg) {
    message_string *ms = dynamic_cast<message_string *>(msg);
    if (!ms) return false;

    switch (ms->id()) {
    case message::external_ip_fetching:
        _status_tmp = langstr("main_win/ip_detecting", ms->str().c_str()); break;
    case message::external_ip_fetch_done:
        _status_tmp = langstr("main_win/ip_detected",  ms->str().c_str());
        self_model()->user().ip_as_string(ms->str());
        _check_if_self_blocked();
        break;
    case message::external_ip_fetch_fail:
        _status_tmp = langstr("main_win/ip_failed",    ms->str().c_str()); break;
    default:
        return false;
    }

    _update_status();
    return true;
}
Exemple #15
0
bool
house::handle_ctz_message(::message *msg) {
    switch (msg->id()) {
    case message::ctz_group_joining:   _status_ctz = langstr("main_win/ctz_connecting"); break;
    case message::ctz_group_joined:
        _status_ctz   = langstr("main_win/ctz_connected");
        _conn_tries = 0;
        break;
    case message::ctz_group_leaving:   _status_ctz = langstr("main_win/ctz_disconnecting"); break;
    case message::ctz_group_not_joined:
    {
        _ctz_disconnected = true;
        _status_ctz = langstr("main_win/ctz_disconnected");
        // Install a timer hook that causes a connection retry.
        // The more times reconnect has been tried without getting
        // a connection, the longer time to wait. Give up
        // altogether if more than 5 times tried.
        if (_conn_tries < 5) {
            int conn_in_secs = 30 * _conn_tries;
            ACE_DEBUG((LM_DEBUG, "house::installing reconnect timer %d secs\n",
                       conn_in_secs));
            QTimer::singleShot(conn_in_secs*1000, this, SLOT(reconnect()));
        }
    }
        break;
    case message::ctz_group_server_unreachable:
    {
    }
        break;
    default:
        return false;
    }

    _ctz_disconnected = (msg->id() == message::ctz_group_not_joined
                        ? true : false);

    return true;
}
Exemple #16
0
// users_view::observer interface
void
house::user_added(const chat_gaming::user &u) {
    if (app_opts.flash_new_user() &&
        self_model()->user().status() != chat_gaming::user::status_playing)
    {
        os::flash_window(this);
    }
    _chat_view->status_message(langstr("chat/user_entered", u.display_id().c_str()));

    std::string login_lowercase = u.login_id();
    std::transform(login_lowercase.begin(), login_lowercase.end(), login_lowercase.begin(), tolower);
    if (user_conf()->get("users", login_lowercase.c_str(), std::string()) == "block")
    {
        // TODO users.cpp uses the exact same functionality to create addr from string,
        // put into some utility function
        struct in_addr a;
        std::string ipstr = u.ip_as_string();
        if (!ACE_OS::inet_aton(ipstr.c_str(), &a)) {
            ACE_ERROR((LM_ERROR, "house::user_added: IP '%s' not "
                       "recognized\n", ipstr.c_str()));
            return;
        }

        a.s_addr = ntohl(a.s_addr);
        if (a.s_addr == INADDR_ANY      ||
            a.s_addr == INADDR_LOOPBACK ||
            a.s_addr == INADDR_NONE)
        {
            ACE_ERROR((LM_ERROR, "house::user_added: IP '%s' invalid as IP\n",
                       ipstr.c_str()));
            return;
        }

        message_block_users *m = new message_block_users(
            ::message::block_users,
            self_model()->user(),
            self_model()->sequence(),
            0
        );
        m->ip_push_back(a.s_addr);
        net_messenger()->send_msg(m);
    }
}
Exemple #17
0
VOIDSIG signal_pipe(int signum)
{
    int32 sum;

#ifdef SIGPIPE
    if (signum == SIGPIPE) {
        send_event(EVENT_SIGNAL, 2, "SIGPIPE",
                   "Received SIGPIPE: Broken pipe");
        alog(LOG_NORMAL, "Received SIGPIPE: Broken pipe");
        if (sigpipecount >= 2) {
            sum = time(NULL) - sigpipetime;
            if (sum < 3600) {
                alog(LOG_NORMAL,
                     "This error has happened serval times in less then an hour.");
                alog(LOG_NORMAL,
                     "This generally means there is a serious problem that you need to address.");
                alog(LOG_NORMAL, "Denora will now exit");
                denora_shutdown();
                exit(-1);
            } else if (sum < 86400) {
                alog(LOG_NORMAL,
                     "This error has happened serval times in less then 24 period");
                alog(LOG_NORMAL,
                     "You should consider restarting or resolveing the issue before continue on");
                sigpipecount++;
                sigpipetime = time(NULL);
            } else {
                alog(LOG_NORMAL,
                     "This error has happened serval times in greater then 24 period");
                alog(LOG_NORMAL,
                     "Operation is still iffy but lowering the sigpipe count");
                sigpipecount--;
                sigpipetime = time(NULL);
            }
        } else {
            alog(LOG_NORMAL, langstr(ALOG_SIGPIPE_WARNING));
            do_backtrace(0);
            sigpipecount++;
            sigpipetime = time(NULL);
        }
    }
#endif
}
Exemple #18
0
VOIDSIG signal_restart(int signum)
{
#ifdef SIGUSR2
    if (signum == SIGUSR2) {
#endif
        alog(LOG_NORMAL, "Received SIGUSR2, restarting.");
        if (!denora->qmsg) {
            denora->qmsg = sstrdup("Restarting on SIGUSR2");
        }
        send_event(EVENT_SIGNAL, 2, "SIGUSR2", denora->qmsg);
#ifdef STATS_BIN
        denora_restart();
#else
        denora->qmsg = sstrdup(langstr(ALOG_NO_STATS_BIN));
#endif
        exit(-1);
#ifdef SIGUSR2
    }
#endif
}
Exemple #19
0
void
chat::handle_message(::message *msg) {
    switch (msg->id()) {
    case ::message::send:
    case ::message::send_private:
    {
        message_channel *m = dynamic_ptr_cast<message_channel>(msg);
        ACE_DEBUG((LM_DEBUG, "chat::handle message _channel/channel %s/%s\n",
                  _channel.c_str(), m->channel().c_str()));

        if (_channel == m->channel()) {
            // Public message
            public_message(m->sender_id(), m->str(), m->group_base());
        }
    }
        break;
    case ::message::private_refused:
    {
        message_channel *m = dynamic_ptr_cast<message_channel>(msg);
        ACE_DEBUG((LM_DEBUG, "chat::handle message _channel/channel %s/%s\n",
                  _channel.c_str(), m->channel().c_str()));

        if (_channel == m->channel()) {
            // Status message of refused
            status_message(
                langstr("chat/private_msg_refused", m->str().c_str())
            );
        }
    }
        break;
    case ::message::send_notification:
    {
        message_channel *m = dynamic_ptr_cast<message_channel>(msg);
        ACE_DEBUG((LM_DEBUG, "chat::handle message _channel/channel %s/%s\n",
                  _channel.c_str(), m->channel().c_str()));

        if (_channel == m->channel()) {
            notification_message(
                m->sender_id(), m->str(), m->group_base()
            );
        }
    }
        break;
    case ::message::block_users:
    {
        message_block_users *m = dynamic_ptr_cast<message_block_users>(msg);
        if (m->global_ignore() == false) {
            ACE_DEBUG((LM_DEBUG, "chat::handle message block_users\n"));
            status_message(
                langstr("chat/user_ignores", m->user().display_id().c_str())
            );
        }
    }
        break;
    case ::message::global_ignore_list:
        _handle_global_ignore(msg);
        break;
    case ::message::room:
    {
        message_room *m = dynamic_ptr_cast<message_room>(msg);
        const chat_gaming::room &r = m->room();

    if (app_opts.debug()) {
        std::string msgstr =
            "Room update id " + (const std::string)r.id() +
            " topic "         + r.topic() +
            " owner id "      + (const std::string)(r.owner_id());
        status_message(msgstr);
    }

    }
        break;
    case ::message::user:
    {
        message_user *m = dynamic_ptr_cast<message_user>(msg);
        const chat_gaming::user &u = m->user();

    if (app_opts.debug()) {
        std::string msgstr =
            "User update id " + (std::string)u.id() +
            " in room id "    + (std::string)u.room_id();
        status_message(msgstr);
    }


    }
        break;

    }
}
Exemple #20
0
void
house::user_blocked(const std::string &display_id) {
    _chat_view->status_message(langstr("chat/user_ignored",display_id.c_str()));
}
Exemple #21
0
int chanstats_month(const char *name)
{
#ifdef USE_MYSQL
    MYSQL_RES *mysql_res;
    ChannelStats *cs;
    char *chan_;
#endif
    time_t tbuf;

    if (!denora->do_sql) {
        return MOD_CONT;
    }
    if (!name) {
        return MOD_CONT;
    }
    SET_SEGV_LOCATION();
    alog(LOG_NORMAL, langstr(ALOG_RESETTING_MONTHLY));
    rdb_query
        (QUERY_LOW,
         "UPDATE %s SET letters=0, words=0, line=0, actions=0, smileys=0, "
         "kicks=0, modes=0, topics=0, wasted=0, "
         "time0=0, time1=0, time2=0, time3=0, time4=0, time5=0, time6=0, time7=0, "
         "time8=0, time9=0, time10=0, time11=0, time12=0, time13=0, time14=0, "
         "time15=0, time16=0, time17=0, time18=0, time19=0, time20=0, time21=0, "
         "time22=0, time23=0 WHERE type=3;", UStatsTable);
    rdb_query(QUERY_LOW,
              "UPDATE %s SET letters=0, words=0, line=0, actions=0, smileys=0, "
              "kicks=0, modes=0, topics=0, "
              "time0=0, time1=0, time2=0, time3=0, time4=0, time5=0, time6=0, time7=0, "
              "time8=0, time9=0, time10=0, time11=0, time12=0, time13=0, time14=0, "
              "time15=0, time16=0, time17=0, time18=0, time19=0, time20=0, time21=0, "
              "time22=0, time23=0 WHERE type=3;", CStatsTable);

    /* request 109 -  auto-delete channel after not used for 1 month */

    tbuf = (time(NULL) - ClearChanInActive);
    rdb_query
        (QUERY_HIGH,
         "SELECT chan FROM %s WHERE (lastspoke > 0) AND (lastspoke < %i);",
         CStatsTable, tbuf);
#ifdef USE_MYSQL
    mysql_res = mysql_store_result(mysql);
    if (mysql_num_rows(mysql_res) > 0) {
        SET_SEGV_LOCATION();
        while ((mysql_row = mysql_fetch_row(mysql_res)) != NULL) {
            if ((cs = find_cs(mysql_row[0]))) {
                alog(LOG_DEBUG,
                     "chanstats monthly: channel %s is expired, statserv will leave this chan, all stats are deleted");
                del_cs(cs);     /* make statserv part the chan */
                chan_ = rdb_escape(mysql_row[0]);
                rdb_query(QUERY_LOW, "DELETE FROM %s WHERE chan=\'%s\'",
                          CStatsTable, chan_);
                rdb_query(QUERY_LOW, "DELETE FROM %s WHERE chan=\'%s\'",
                          UStatsTable, chan_);
                free(chan_);
                if (LogChannel) {
                    if (stricmp(LogChannel, mysql_row[0])) {
                        denora_cmd_part(s_StatServ, mysql_row[0],
                                        getstring(NULL,
                                                  STATS_CHANSTATS_PART),
                                        mysql_row[0]);

                    }
                }
            }
        }
        save_cs_db();
    }
#endif
    return MOD_CONT;
}
Exemple #22
0
about::about(QWidget *parent)
    : QDialog(parent)
{
    this->setWindowTitle(langstr("about_win/title"));
    this->setWindowIcon(app_icons()->get("about"));

    QVBoxLayout *l = new QVBoxLayout;
    l->setSpacing(0);
    l->addWidget(new QLabel(APP_NAME " " APP_VERSION));
    l->addWidget(new QLabel);
    l->addWidget(new QLabel("Copyright (C) 2006-2013 Arto Jalkanen"));
    l->addWidget(new QLabel);
    l->addWidget(new QLabel(langstr("about_win/license", "GPL").c_str()));
    l->addWidget(new QLabel);
    l->addWidget(new QLabel(langstr("about_win/icons_by", "ADX").c_str()));
    // l->addWidget(new QLabel("<br>"));
    l->addWidget(new QLabel(langstr("about_win/house_icon_by", "Pigasque").c_str()));
    l->addWidget(new QLabel);
    l->addWidget(new QLabel(langstr("about_win/other_sites")));
    l->addWidget(new QLabel);

    std::list<const char *> urls;
    urls.push_back("http://rvhouse.revoltzone.net");
    urls.push_back("http://revoltzone.net");
    urls.push_back("http://www.revoltrace.com");
    urls.push_back("http://rv12.revoltzone.net");
    for (std::list<const char *>::iterator i = urls.begin(); i != urls.end(); ++i) {
        std::string ahref = "<a href=\"";
        ahref.append(*i);
        ahref.append("\">");
        ahref.append(*i);
        ahref.append("</a>");
        QLabel *label = new QLabel(ahref.c_str());
        label->setOpenExternalLinks(true);
        l->addWidget(label);
    }

    l->addWidget(new QLabel);

    l->addWidget(new QLabel(langstr("about_win/using")));
    l->addWidget(new QLabel(langstr("about_win/using_lib", "Qt 4.7 GUI Library", "Nokia").c_str()));
    l->addWidget(new QLabel(langstr("about_win/using_lib", "ACE network library", "Douglas C. Schmidth").c_str()));
    l->addWidget(new QLabel(langstr("about_win/using_lib", "KadC P2P library", "Enzo Michelangeli").c_str()));
    l->addWidget(new QLabel(langstr("about_win/using_lib", "libdht, libreudp, libnetcomgrp", "ajalkane").c_str()));
    l->addWidget(new QLabel(langstr("about_win/using_lib", "Boost serialization", "Robert Ramey").c_str()));

    l->addWidget(new QLabel);

    std::list<lang::info> lang_infos = lang_mngr()->lang_infos();
    // Remove english, as its the original language and not a translation,
    // from the list before listing translations
    std::list<lang::info>::iterator new_end
      = std::remove_if(lang_infos.begin(), lang_infos.end(),
                       lang::info_match_lang_fobj("English"));
    lang_infos.erase(new_end, lang_infos.end());
    if (lang_infos.size() > 0) {
        l->addWidget(new QLabel(langstr("about_win/translations")));
        std::list<lang::info>::const_iterator i = lang_infos.begin();
        for (; i != lang_infos.end(); i++) {
            l->addWidget(new QLabel(langstr("about_win/translation",
                                            i->lang().c_str(),
                                            i->author().c_str(),
                                            i->email().c_str(),
                                            i->version().c_str()).c_str()));
        }
    }

    /**
     * Bottom part
     */
    l->addStretch(1);
    QFrame      *separator = new QFrame;
    separator->setFrameStyle(QFrame::HLine | QFrame::Sunken);
    l->addWidget(separator);
    QDialogButtonBox *button_box = new QDialogButtonBox;
    QPushButton *ok_button = new QPushButton(langstr("common/ok_button"), this);
    button_box->addButton(ok_button, QDialogButtonBox::AcceptRole);
    l->addWidget(button_box);

    connect(ok_button, SIGNAL(clicked()), this, SLOT(accept()));

    this->setLayout(l);
}
Exemple #23
0
void
house::room_removed(const chat_gaming::room &r) {
    _chat_view->status_message(langstr("chat/room_closed", r.topic().c_str()));
}
Exemple #24
0
/**
 * Load the Stats database from disk
 *
 * @return void - no returend value
 *
 */
void load_stats_db(void)
{
    DenoraDBFile *dbptr = calloc(1, sizeof(DenoraDBFile));
    char *key, *value;
    int retval = 0;

    alog(LOG_NORMAL, "Loading %s", statsDB);

    fill_db_ptr(dbptr, 0, STATSDB_VERSION, s_StatServ, statsDB);
    SET_SEGV_LOCATION();

    /* let's remove existing temp files here, because we only load dbs on startup */
    remove(dbptr->temp_name);

    /* Open the db, fill the rest of dbptr and allocate memory for key and value */
    if (new_open_db_read(dbptr, &key, &value)) {
        SET_SEGV_LOCATION();
        free(dbptr);
        return;                 /* Bang, an error occurred */
    }

    while (1) {
        /* read a new entry and fill key and value with it -Certus */
        retval = new_read_db_entry(&key, &value, dbptr->fptr);

        if (retval == DB_READ_ERROR) {
            alog(LOG_NORMAL, langstr(ALOG_DB_ERROR), dbptr->filename);
            new_close_db(dbptr->fptr, &key, &value);
            SET_SEGV_LOCATION();
            free(dbptr);
            return;
        } else if (retval == DB_EOF_ERROR) {
            alog(LOG_EXTRADEBUG, langstr(ALOG_DEBUG_DB_OK),
                 dbptr->filename);
            new_close_db(dbptr->fptr, &key, &value);
            SET_SEGV_LOCATION();
            free(dbptr);
            return;
        } else if (retval == DB_READ_BLOCKEND) {        /* DB_READ_BLOCKEND */
            /* a channel has completely been read. put any checks in here! */
        } else {
            /* DB_READ_SUCCESS */

            if (!*value || !*key) {
                continue;
            }
            SET_SEGV_LOCATION();

            if (!stricmp(key, "usermax")) {
                stats->users_max = atoi(value);
            } else if (!stricmp(key, "usermaxtime")) {
                stats->users_max_time = atoi(value);
            } else if (!stricmp(key, "channelmax")) {
                stats->chans_max = atoi(value);
            } else if (!stricmp(key, "channelmaxtime")) {
                stats->chans_max_time = atoi(value);
            } else if (!stricmp(key, "servermax")) {
                stats->servers_max = atoi(value);
            } else if (!stricmp(key, "servermaxtime")) {
                stats->servers_max_time = atoi(value);
            } else if (!stricmp(key, "opermax")) {
                stats->opers_max = atoi(value);
                if ((int) stats->opers_max < 0) {
                    stats->opers_max = 0;
                }
            } else if (!stricmp(key, "opermaxtime")) {
                stats->opers_max_time = atoi(value);
            }
        }                       /* else */
    }                           /* while */
}
Exemple #25
0
void
house::room_join_selected(QTreeWidgetItem *item, int column) {
    ACE_DEBUG((LM_DEBUG, "house: joining room\n"));

    if (item == NULL) {
        ACE_DEBUG((LM_DEBUG, "house: no room selected\n"));
        return;
    }

    if (item->isDisabled()) {
        ACE_DEBUG((LM_DEBUG, "house: room is disabled\n"));
        return;
    }

    if (!self_model()->user().room_id().empty()) {
        ACE_DEBUG((LM_DEBUG, "house: already in room id %s, ignored\n",
                   self_model()->user().id().c_str()));
        return;
    }
    if (!self_model()->joining_room().empty()) {
        ACE_DEBUG((LM_DEBUG, "house: already joining room id %s, ignored\n",
                   self_model()->joining_room().c_str()));
        return;
    }

    view::rooms::item_type *selected_item = static_cast<view::rooms::item_type *>(item);
    ACE_DEBUG((LM_DEBUG, "house::selected_item is %d\n", selected_item));

    if (selected_item == NULL) {
        return;
    }

    // room_item *item = _rooms_view->item_at(i);
    chat_gaming::room::id_type rid = selected_item->room_id();

    if (rid.empty()) {
        ACE_DEBUG((LM_ERROR, "house::on_room_join no matching room "
                  "found for room pointer %d\n", selected_item));
        return;
    }

    model::house::house_type::room_iterator ri = house_model()->room_find(rid);
    if (ri == house_model()->room_end()) {
        ACE_DEBUG((LM_ERROR, "house::on_room_join no matching room "
                  "found from model for room id %s\n", rid.c_str()));
        return;
    }

    chat_gaming::room r(*ri);
    // Check if the room requires a password and ask for it if so
    if (r.has_password()) {
        bool ok = false;
        QString pass = QInputDialog::getText(this,
                                             langstr("main_win/ask_room_pass_title"),
                                             langstr("main_win/ask_room_pass"),
                                             QLineEdit::Normal, QString(),
                                             &ok);
        if (!ok) {
            return;
        }
        r.password(pass.toLatin1().constData());
    }
    // TODO message_room_join would be more appropriate, change when time
    // permits, this one will do for now
    message_room *m = new message_room(
        message::room_join,
        r,
        self_model()->user().id(),
        self_model()->sequence(),
        0
    );
    net_messenger()->send_msg(m);
    self_model()->joining_room(r.id());
    ::app()->interruptable_action_update(langstr("main_win/joining_room"));
    // return 0;
}
Exemple #26
0
void do_backtrace(int header)
{
#ifndef _WIN32
#ifdef HAVE_BACKTRACE
    void *array[50];
    size_t size;
    char **strings;
    int idx;
    int i;
    ModuleHash *current = NULL;

    if (header) {
        alog(LOG_NORMAL, "Backtrace: Segmentation fault detected");
        alog(LOG_NORMAL, langstr(BACKTRACE_LINES));
        alog(LOG_NORMAL,
             "The following lines should not be seen as a definitive backtrace");
        alog(LOG_NORMAL,
             "If reproducable please use gdb to get proper backtraces");
        alog(LOG_NORMAL, "Example:");
        alog(LOG_NORMAL, "gdb stats");
        alog(LOG_NORMAL, "run -nofork -debug -protocoldebug");
        alog(LOG_NORMAL, "crash the program");
        alog(LOG_NORMAL, "bt full");
        alog(LOG_NORMAL,
             "paste results and following line into the bugtracker");
        alog(LOG_NORMAL,
             "[================ COPY THE FOLLOWING =================]");
        alog(LOG_NORMAL, "Backtrace: %s", segv_location);
        alog(LOG_NORMAL, "[inbuf][%s]", inbuf);
        alog(LOG_NORMAL,
             "Backtrace: Denora version %s build #%s, compiled %s %s",
             denora->version, denora->build, denora->date, denora->time);
        alog(LOG_NORMAL,
             "[modules]: Listing all currently loaded modules");
        for (idx = 0; idx != MAX_CMD_HASH; idx++) {
            for (current = MODULE_HASH[idx]; current;
                 current = current->next) {
                alog(LOG_DEBUG, "[name=%s][type=%d][version %s]",
                     current->name, current->m->type, current->m->version);
            }
        }
    } else {
        alog(LOG_NORMAL, "Execution trace: %s", segv_location);
        alog(LOG_NORMAL, "Execution trace: in progress");
    }
    size = backtrace(array, 10);
    strings = backtrace_symbols(array, size);
    for (i = 0; i < (int) size; i++) {
        alog(LOG_NORMAL, "%s(%d): %s",
             (header ? "Backtrace" : "Execution Trace"), i, strings[i]);
    }
    free(strings);
    alog(LOG_NORMAL, "%s: complete",
         (header ? "Backtrace" : "Execution Trace"));
    if (header) {
        alog(LOG_NORMAL,
             "[=================================================]");
    }
#else
    if (segv_location) {
        alog(LOG_NORMAL, "Backtrace: %s", segv_location);
    }
    if (header) {
        alog(LOG_NORMAL, langstr(BACKTRACE_NOT_HERE));
    }
#endif
#else
    char *winver;
    if (segv_location) {
        alog(LOG_NORMAL, "Backtrace: %s", segv_location);
    }
    alog(LOG_NORMAL, "Backtrace not supported on win32");
    winver = GetWindowsVersion();
    alog(LOG_NORMAL, "Running %s", winver);
    free(winver);
#endif
}
Exemple #27
0
bool
house::handle_dht_message(::message *msg) {
    switch (msg->id()) {
    case message::dht_connecting:      _status_dht = langstr("main_win/dht_connecting");    break;
    case message::dht_connected:       _status_dht = langstr("main_win/dht_connected");     break;
    case message::dht_disconnecting:   _status_dht = langstr("main_win/dht_disconnecting"); break;
    case message::dht_disconnected:    _status_dht = langstr("main_win/dht_disconnected");     break;
    case message::dht_upd_nodes:       _status_dht = langstr("main_win/dht_upding_contacts"); break;
    case message::dht_upd_nodes_done:  _status_dht = langstr("main_win/dht_upd_contacts"); break;
    case message::dht_upd_nodes_fail:  _status_dht = langstr("main_win/dht_upd_contacts_fail"); break;
    case message::dht_group_joining:   _status_dht = langstr("main_win/dht_joining"); break;
    case message::dht_group_joined:    _status_dht = langstr("main_win/dht_joined"); break;
    case message::dht_group_leaving:   _status_dht = langstr("main_win/dht_leaving"); break;
    case message::dht_group_not_joined:_status_dht = langstr("main_win/dht_left"); break;
    case message::dht_peers_find_start:_status_dht_extra[0] = langstr("main_win/dht_searching"); break;
    case message::dht_peers_find_stop: _status_dht_extra[0] = ""; break;
    case message::dht_announce_start:  _status_dht_extra[1] = langstr("main_win/dht_announcing"); break;
    case message::dht_announce_stop:   _status_dht_extra[1] = ""; break;
    default:
        return false;
    }

    switch (msg->id()) {
    case message::dht_connecting:
    case message::dht_connected:
    case message::dht_disconnecting:
    case message::dht_disconnected:
        _last_dht_status_message_id = msg->id();
    }

    if (msg->id() == message::dht_disconnected) {
        ACE_DEBUG((LM_DEBUG, "house: adding a DHT disconnect timer\n"));
        // Install a timer that checks if still in dht_disconnected
        // mode, and if so it displays a help. A timer is needed
        // because even if we receive dht_disconnected, the networking
        // thread might decide to retry right after. By starting a timer
        // and checking if the state is still dht_disconnected we
        // get a reliable result.
        QTimer::singleShot(5000, this, SLOT(dht_disconnected()));
    }

    return true;
}
Exemple #28
0
void
house::user_removed(const chat_gaming::user &u) {
    _chat_view->status_message(langstr("chat/user_exited", u.display_id().c_str()));
}