예제 #1
0
파일: ban.c 프로젝트: michaelmwu/bota
void auto_ban_ip(int site)
{

    char name [ MAX_STRING_LENGTH ];
    BAN_DATA *pban;

    int decA = ( site >> 24 ) & 0xFF;
    int decB = ( site >> 16 ) & 0xFF;
    int decC = ( site >>  8 ) & 0xFF;
    int decD = ( site       ) & 0xFF;

    if(decA == 127 && decB == 0 && decB == 0 && decD == 1)
    {
        return; /* Localhost is OK for right now */
    }

    sprintf(name,"%d.%d.%d.", decA, decB, decC);

    pban = new_ban();
    pban->name = str_dup(name);
    pban->level = 105;

    SET_BIT(pban->ban_flags,BAN_SUFFIX);
    SET_BIT(pban->ban_flags,BAN_PERMANENT);

    pban->next  = ban_list;
    ban_list    = pban;
    save_bans();
    log_f("%s has been automatically banned.\n\r",pban->name);

    return;
}
예제 #2
0
/*
 * Unbans a site.
 */
void do_allow(CHAR_DATA * ch, char *argument)
{
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    BAN_DATA *prev;
    BAN_DATA *curr;

    one_argument(argument, arg);

    if (arg[0] == '\0')
    {
        send_to_char("Remove which site from the ban list?\r\n", ch);
        return;
    }

    prev = NULL;
    for (curr = ban_list; curr != NULL; prev = curr, curr = curr->next)
    {
        if (!str_cmp(arg, curr->name))
        {
            if (curr->level > get_trust(ch))
            {
                send_to_char("You are not powerful enough to lift that ban.\r\n", ch);
                return;
            }

            if (prev == NULL)
            {
                ban_list = ban_list->next;
            }
            else
            {
                prev->next = curr->next;
            }

            free_ban(curr);
            sprintf(buf, "Ban on %s lifted.\r\n", arg);
            send_to_char(buf, ch);
            save_bans();
            return;
        }
    }

    send_to_char("Site is not banned.\r\n", ch);
    return;

} // end do_allow
예제 #3
0
파일: ban.c 프로젝트: KillerMud/Source
void update_bans()
{
    BAN_DATA *prev;
    BAN_DATA *curr;

    prev = NULL;
    for ( curr = ban_list; curr != NULL; prev = curr, curr = curr->next )
    {
        if ( curr->period > 0 && curr->date_stamp + ( curr->period * 24 * 3600 ) <= current_time )
        {
            if ( prev == NULL )
                ban_list = ban_list->next;
            else
                prev->next = curr->next;

            free_ban( curr );
            save_bans();
            return ;
        }
    }

    return ;
}
예제 #4
0
파일: ban.c 프로젝트: KillerMud/Source
void do_allow( CHAR_DATA *ch, char *argument )
{
    char arg[ MAX_INPUT_LENGTH ];
    char buf[ MAX_STRING_LENGTH ];
    BAN_DATA *prev;
    BAN_DATA *curr;

    one_argument( argument, arg );

    if ( arg[ 0 ] == '\0' )
    {
        send_to_char( "Który ban usun±æ z listy?\n\r", ch );
        return ;
    }

    prev = NULL;
    for ( curr = ban_list; curr != NULL; prev = curr, curr = curr->next )
    {
        if ( !str_cmp( arg, curr->site ) )
        {
            if ( prev == NULL )
                ban_list = ban_list->next;
            else
                prev->next = curr->next;

            free_ban( curr );
            sprintf( buf, "Ban na adres %s zdjêty.\n\r", arg );
            send_to_char( buf, ch );
            save_bans();
            return ;
        }
    }

    send_to_char( "Tego adresu nie ma na li¶cie banów.\n\r", ch );
    return ;
}
예제 #5
0
파일: ban.c 프로젝트: Lundex/wileymud
void do_unban(struct char_data *ch, const char *argument, int cmd)
{
    char                                    ban_type[MAX_STRING_LENGTH] = "\0\0\0";
    char                                    buf[MAX_STRING_LENGTH] = "\0\0\0\0\0\0\0";
    int                                     i = 0;

    if (DEBUG)
	log_info("called %s with %s, %s, %d", __PRETTY_FUNCTION__, SAFE_NAME(ch),
		 VNULL(argument), cmd);

    if (IS_NPC(ch)) {
	cprintf(ch, "You're a mob, you can't unban anyone.\r\n");
	return;
    }
    if (argument && *argument) {
	argument = one_argument(argument, ban_type);
	only_argument(argument, buf);
	if (*ban_type) {
	    if (!str_cmp(ban_type, "name")) {
		if (*buf) {
		    /*
		     * First, we need to make sure it isn't already a mob or player. then we can try adding it to the
		     * ban table. 
		     */
		    if (!banned_name(buf)) {
			cprintf(ch, "%s is not banned.\r\n", buf);
			return;
		    }
                    for (i = 0; i < banned_names_count; i++) {
                        if (!str_cmp(banned_names[i], buf)) {
                            char **tmp_foo = calloc(banned_names_count - 1, sizeof(char *));
                            int j = 0;
                            for( j = 0; j < i; j++ ) {
                                tmp_foo[j] = banned_names[j];
                            }
                            for( j = i + 1; j < banned_names_count; j++ ) {
                                tmp_foo[j-1] = banned_names[j];
                            }
                            free(banned_names[i]);
                            banned_names_count--;
                            free(banned_names);
                            banned_names = tmp_foo;
                            cprintf(ch, "%s is no longer banned!\r\n", buf);
                            log_auth(ch, "BAN %s has been unbanned by %s!", buf, GET_NAME(ch));
                            save_bans();
                            return;
                        }
                    }
		    return;
		} else {
		    cprintf(ch, "Banned names:\r\n");
		    for (i = 0; i < banned_names_count; i++) {
			cprintf(ch, "%-20s\r\n", banned_names[i]);
		    }
		    return;
		}
	    } else if (!str_cmp(ban_type, "ip") || !str_cmp(ban_type, "address")
		       || !str_cmp(ban_type, "site")) {
		if (*buf) {
		    /*
		     * No banning localhost! 
		     */
		    if (!banned_ip(buf)) {
			cprintf(ch, "%s is not banned.\r\n", buf);
			return;
		    }
                    for (i = 0; i < banned_names_count; i++) {
                        if (!str_cmp(banned_ips[i], buf)) {
                            char **tmp_foo = calloc(banned_ips_count - 1, sizeof(char *));
                            int j = 0;
                            for( j = 0; j < i; j++ ) {
                                tmp_foo[j] = banned_ips[j];
                            }
                            for( j = i + 1; j < banned_ips_count; j++ ) {
                                tmp_foo[j-1] = banned_ips[j];
                            }
                            free(banned_ips[i]);
                            banned_ips_count--;
                            free(banned_ips);
                            banned_ips = tmp_foo;
                            cprintf(ch, "%s is no longer banned!\r\n", buf);
                            log_auth(ch, "BAN %s has been unbanned by %s!", buf, GET_NAME(ch));
                            save_bans();
                            return;
                        }
                    }
		    return;
		} else {
		    cprintf(ch, "Banned IP addresses:\r\n");
		    for (i = 0; i < banned_ips_count; i++) {
			cprintf(ch, "%-20s\r\n", banned_ips[i]);
		    }
		    return;
		}
	    }
	}
    }
    cprintf(ch, "Usage: unban < name|ip > [ name|address ]\r\n");
}
예제 #6
0
파일: ban.c 프로젝트: Lundex/wileymud
void do_ban(struct char_data *ch, const char *argument, int cmd)
{
    char                                    ban_type[MAX_STRING_LENGTH] = "\0\0\0\0\0\0\0";
    char                                    buf[MAX_STRING_LENGTH] = "\0\0\0\0\0\0\0";
    int                                     i = 0;

    if (DEBUG)
	log_info("called %s with %s, %s, %d", __PRETTY_FUNCTION__, SAFE_NAME(ch),
		 VNULL(argument), cmd);

    if (IS_NPC(ch)) {
	cprintf(ch, "You're a mob, you can't ban anyone.\r\n");
	return;
    }
    if (argument && *argument) {
	argument = one_argument(argument, ban_type);
	only_argument(argument, buf);
	if (*ban_type) {
	    if (!str_cmp(ban_type, "name")) {
		if (*buf) {
		    /*
		     * First, we need to make sure it isn't already a mob or player. then we can try adding it to the
		     * ban table. 
		     */
		    if (!acceptable_name(buf)) {
			cprintf(ch, "%s is already an invalid choice.\r\n", buf);
			return;
		    }

		    banned_names_count++;
		    banned_names = realloc(banned_names, banned_names_count * sizeof(char *));
		    banned_names[banned_names_count - 1] = strdup(buf);
		    cprintf(ch, "%s is now banned!\r\n", buf);
		    log_auth(ch, "BAN %s has been banned by %s!", buf, GET_NAME(ch));
		    save_bans();
		    return;
		} else {
		    cprintf(ch, "Banned names:\r\n");
		    for (i = 0; i < banned_names_count; i++) {
			cprintf(ch, "%-20s\r\n", banned_names[i]);
		    }
		    return;
		}
	    } else if (!str_cmp(ban_type, "ip") || !str_cmp(ban_type, "address")
		       || !str_cmp(ban_type, "site")) {
		if (*buf) {
		    /*
		     * No banning localhost! 
		     */
		    if (str_cmp("127.0.0.1", buf)) {
			cprintf(ch, "You cannot ban localhost!\r\n");
			return;
		    }
		    banned_ips_count++;
		    banned_ips = realloc(banned_ips, banned_ips_count * sizeof(char *));
		    banned_ips[banned_ips_count - 1] = strdup(buf);
		    cprintf(ch, "%s is now banned!\r\n", buf);
		    log_auth(ch, "BAN %s has been banned by %s!", buf, GET_NAME(ch));
		    save_bans();
		    return;
		} else {
		    cprintf(ch, "Banned IP addresses:\r\n");
		    for (i = 0; i < banned_ips_count; i++) {
			cprintf(ch, "%-20s\r\n", banned_ips[i]);
		    }
		    return;
		}
	    }
	}
    }
    cprintf(ch, "Usage: ban < name|ip > [ name|address ]\r\n");
}
예제 #7
0
파일: ban.c 프로젝트: KillerMud/Source
void ban_site( CHAR_DATA *ch, char *argument )
{
	char date[ 50 ];
	struct tm *btime;
    char buf[ MAX_STRING_LENGTH ], buf2[ MAX_STRING_LENGTH ], buf3[ MAX_STRING_LENGTH ];
    char arg1[ MAX_INPUT_LENGTH ], arg2[ MAX_INPUT_LENGTH ], arg3[ MAX_INPUT_LENGTH ];
    char *name;
    BUFFER *buffer;
    BAN_DATA *pban, *prev;
    bool prefix = FALSE, suffix = FALSE;
    int type;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    argument = one_argument( argument, arg3 );

    if ( arg1[ 0 ] == '\0' )
    {
        if ( ban_list == NULL )
        {
            send_to_char( "Nie ma ¿adnych banów.\n\r", ch );
            return ;
        }
        buffer = new_buf();

        add_buf( buffer, "{CAdres                                       Kto        Typ{x\n\r" );
        for ( pban = ban_list;pban != NULL;pban = pban->next )
        {
            sprintf( buf2, "%s%s%s",
                     IS_SET( pban->ban_flags, BAN_PREFIX ) ? "*" : "",
                     pban->site,
                     IS_SET( pban->ban_flags, BAN_SUFFIX ) ? "*" : "" );

            btime = localtime( &pban->date_stamp );
            strftime( date, 20, "%d-%m-%Y %H:%M:%S", btime );

            if ( pban->period <= 0 )
                sprintf( buf3, "od %s na sta³e", date );
            else if ( pban->period == 1 )
                sprintf( buf3, "od %s na 1 dzieñ", date );
            else
                sprintf( buf3, "od %s na %d dni", date, pban->period );

            sprintf( buf, "{Y%-40s{x    %-10s %-7s\n\r{CCzas{x: %s\n\r{CPowód{x: %s\n\r",
                     buf2, pban->person,
                     IS_SET( pban->ban_flags, BAN_NEWBIES ) ? "newbies" :
                     IS_SET( pban->ban_flags, BAN_PERMIT ) ? "permit" :
                     IS_SET( pban->ban_flags, BAN_ALL ) ? "all"	: "",
                     buf3,
                     IS_NULLSTR(pban->reason) ? "nie podano" : pban->reason );
            add_buf( buffer, buf );
            if ( pban->next )
            add_buf( buffer, "\n\r" );
        }

        add_buf( buffer, "\n\rDodanie nowego bana:\n\r" );
        add_buf( buffer, "permban [*]<adres>[*] all|newbies|permit <ile dni> [<powod>]\n\r" );
        add_buf( buffer, "- podanie 0 przy liczbie dni oznacza ban na sta³e\n\r" );
        page_to_char( buf_string( buffer ), ch );
        free_buf( buffer );
        return ;
    }

    /* find out what type of ban */
    if ( !str_prefix( arg2, "permit" ) )
        type = BAN_PERMIT;
    else if ( !str_prefix( arg2, "newbies" ) )
        type = BAN_NEWBIES;
    else if ( !str_prefix( arg2, "all" ) )
        type = BAN_ALL;
    else
    {
        send_to_char( "Dopuszczalne typy bana to: all, newbies, permit.\n\r", ch );
        return ;
    }

    name = arg1;

    if ( name[ 0 ] == '*' )
    {
        prefix = TRUE;
        name++;
    }

    if ( name[ strlen( name ) - 1 ] == '*' )
    {
        suffix = TRUE;
        name[ strlen( name ) - 1 ] = '\0';
    }

    if ( strlen( name ) == 0 )
    {
        send_to_char( "Nie poda³e¶ adresu do zbanowania.\n\r", ch );
        return ;
    }

    if ( arg3[0] == '\0' || !is_number( arg3 ) )
    {
        send_to_char( "Podaj liczbê dni przez jak± ma trwaæ ban (0 - ca³y czas).\n\r", ch );
        return;
    }

    prev = NULL;
    for ( pban = ban_list; pban != NULL; prev = pban, pban = pban->next )
    {
        if ( !str_cmp( name, pban->site ) )
        {
            if ( prev == NULL )
                ban_list = pban->next;
            else
                prev->next = pban->next;
            free_ban( pban );
        }
    }

    pban = new_ban();
    pban->site   = str_dup( name );
    pban->person = str_dup( ch->name );
    pban->date_stamp = current_time;
    pban->period = UMAX( 0, atoi( arg3 ) );
    pban->reason = str_dup( argument );

    /* set ban type */
    pban->ban_flags = type;

    if ( prefix )
        SET_BIT( pban->ban_flags, BAN_PREFIX );
    if ( suffix )
        SET_BIT( pban->ban_flags, BAN_SUFFIX );

    pban->next = ban_list;
    ban_list = pban;
    save_bans();
    sprintf( buf, "Adres %s zosta³ dodany do listy banów.\n\r", pban->site );
    send_to_char( buf, ch );
    return ;
}
예제 #8
0
파일: ban.c 프로젝트: michaelmwu/bota
void ban_site(CHAR_DATA *ch, char *argument, bool fPerm)
{
    char buf[MAX_STRING_LENGTH],buf2[MAX_STRING_LENGTH];
    char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
    char *name;
    BUFFER *buffer;
    BAN_DATA *pban, *prev;
    bool prefix = FALSE,suffix = FALSE;
    int type;

    argument = one_argument(argument,arg1);
    argument = one_argument(argument,arg2);

    if ( arg1[0] == '\0' )
    {
	if (ban_list == NULL)
	{
	    send_to_char("No sites banned at this time.\n\r",ch);
	    return;
  	}
	buffer = new_buf();

        add_buf(buffer,"Banned sites  level  type     status\n\r");
        for (pban = ban_list;pban != NULL;pban = pban->next)
        {
	    sprintf(buf2,"%s%s%s",
		IS_SET(pban->ban_flags,BAN_PREFIX) ? "*" : "",
		pban->name,
		IS_SET(pban->ban_flags,BAN_SUFFIX) ? "*" : "");
	    sprintf(buf,"%-12s    %-3d  %-7s  %s\n\r",
		buf2, pban->level,
		IS_SET(pban->ban_flags,BAN_NEWBIES) ? "newbies" :
		IS_SET(pban->ban_flags,BAN_MULTI)   ? "multi" :
		IS_SET(pban->ban_flags,BAN_PERMIT)  ? "permit"  :
		IS_SET(pban->ban_flags,BAN_ALL)     ? "all"	: "",
	    	IS_SET(pban->ban_flags,BAN_PERMANENT) ? "perm" : "temp");
	    add_buf(buffer,buf);
        }

        page_to_char( buf_string(buffer), ch );
	free_buf(buffer);
        return;
    }

    /* find out what type of ban */
    if (arg2[0] == '\0' || !str_prefix(arg2,"all"))
	type = BAN_ALL;
    else if (!str_prefix(arg2,"newbies"))
	type = BAN_NEWBIES;
    else if (!str_prefix(arg2,"multi"))
	type = BAN_MULTI;
    else if (!str_prefix(arg2,"permit"))
	type = BAN_PERMIT;
    else
    {
	send_to_char("Acceptable ban types are all, newbies, and permit, and multi.\n\r",
	    ch); 
	return;
    }

    name = arg1;

    if (name[0] == '*')
    {
	prefix = TRUE;
	name++;
    }

    if (name[strlen(name) - 1] == '*')
    {
	suffix = TRUE;
	name[strlen(name) - 1] = '\0';
    }

    if (strlen(name) == 0)
    {
	send_to_char("You have to ban SOMETHING.\n\r",ch);
	return;
    }

    prev = NULL;
    for ( pban = ban_list; pban != NULL; prev = pban, pban = pban->next )
    {
        if (!str_cmp(name,pban->name))
        {
	    if (pban->level > get_trust(ch))
	    {
            	send_to_char( "That ban was set by a higher power.\n\r", ch );
            	return;
	    }
	    else
	    {
		if (prev == NULL)
		    ban_list = pban->next;
		else
		    prev->next = pban->next;
		free_ban(pban);
	    }
        }
    }

    pban = new_ban();
    pban->name = str_dup(name);
    pban->level = get_trust(ch);

    /* set ban type */
    pban->ban_flags = type;

    if (prefix)
	SET_BIT(pban->ban_flags,BAN_PREFIX);
    if (suffix)
	SET_BIT(pban->ban_flags,BAN_SUFFIX);
    if (fPerm)
	SET_BIT(pban->ban_flags,BAN_PERMANENT);

    pban->next  = ban_list;
    ban_list    = pban;
    save_bans();
    sprintf(buf,"%s has been banned.\n\r",pban->name);
    send_to_char( buf, ch );
    return;
}
예제 #9
0
void do_allow( CHAR_DATA *ch, char *argument )                        
{
    char arg[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    BAN_DATA *prev;
    BAN_DATA *curr;
    char *name, *user, *host;

    one_argument( argument, arg );

    if ( arg[0] == '\0' )
    {
        send_to_char( "Remove which site from the ban list?\n\r", ch );
        return;
    }

    name = arg;

    user = &str_empty[0];
    for ( host = name; *name != '\0'; )
    {
	if ( *name == '@' )
	{
	    user	= host;
	    *name	= '\0';
	    host	= name+1;
	    break;
	}
	name++;
    }

    prev = NULL;
    for ( curr = ban_list; curr != NULL; prev = curr, curr = curr->next )
    {
	if ( IS_SET(curr->ban_flags, BAN_USER)
	&&   str_cmp(curr->user, user) )
	    continue;

        if ( !str_cmp( host, curr->host ) )
        {
	    if (curr->level > get_trust(ch))
	    {
		send_to_char(
		   "You are not powerful enough to lift that ban.\n\r",ch);
		return;
	    }
            if ( prev == NULL )
                ban_list   = ban_list->next;
            else
                prev->next = curr->next;

	    if ( IS_SET(curr->ban_flags, BAN_USER) )
		sprintf( buf, "Ban on %s@%s lifted.\r\n",
		    curr->user, curr->host );
	    else
		sprintf( buf, "Ban on %s lifted.\r\n",
		    curr->host );
            free_ban(curr);
            send_to_char( buf, ch );
	    save_bans();
            return;
        }
    }

    send_to_char( "Site is not banned.\n\r", ch );
    return;
}