Exemplo n.º 1
0
int __stdcall dlgRouterRestrictions(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{	if(uMsg==WM_INITDIALOG)
	{	hDlgRouterRestrictions=hDlg;
		dlgRouterRestrictions_langUpdate();
		if(tmpOptions->_AllowInvalid&ALLOW_INVALID_ENTRY)	CheckDlgButton(hDlg,15400,BST_CHECKED);
		if(tmpOptions->_AllowInvalid&ALLOW_INVALID_EXIT)	CheckDlgButton(hDlg,15401,BST_CHECKED);
		if(tmpOptions->_AllowInvalid&ALLOW_INVALID_MIDDLE)	CheckDlgButton(hDlg,15402,BST_CHECKED);
		if(tmpOptions->_AllowInvalid&ALLOW_INVALID_INTRODUCTION)	CheckDlgButton(hDlg,15404,BST_CHECKED);
		if(tmpOptions->_AllowInvalid&ALLOW_INVALID_RENDEZVOUS)	CheckDlgButton(hDlg,15403,BST_CHECKED);
		if(tmpOptions->EnforceDistinctSubnets)
		{	CheckDlgButton(hDlg,15405,BST_CHECKED);
			if(tmpOptions->EnforceDistinctSubnets==1)	CheckDlgButton(hDlg,15501,BST_CHECKED);
			else	CheckDlgButton(hDlg,15502,BST_CHECKED);
		}
		else
		{	EnableWindow(GetDlgItem(hDlg,15501),0);EnableWindow(GetDlgItem(hDlg,15502),0);
			CheckDlgButton(hDlg,15501,BST_CHECKED);
		}
		if(tmpOptions->FastFirstHopPK)	CheckDlgButton(hDlg,15406,BST_CHECKED);
		if(tmpOptions->FetchUselessDescriptors)	CheckDlgButton(hDlg,15407,BST_CHECKED);
		if(tmpOptions->StrictEntryNodes)	CheckDlgButton(hDlg,15408,BST_CHECKED);
		if(tmpOptions->StrictExitNodes){	CheckDlgButton(hDlg,15409,BST_CHECKED);EnableWindow(GetDlgItem(hDlg,15010),0);EnableWindow(GetDlgItem(hDlg,15503),0);}
		SendDlgItemMessage(hDlg,15100,EM_LIMITTEXT,65535,0);
		SendDlgItemMessage(hDlg,15101,EM_LIMITTEXT,65535,0);
		SendDlgItemMessage(hDlg,15500,TBM_SETRANGE,1,MAKELONG(1,10));
		SendDlgItemMessage(hDlg,15500,TBM_SETPOS,1,tmpOptions->CircuitPathLength);
		show_bans();
		show_favorites();
		SendDlgItemMessage(hDlg,15503,TBM_SETRANGE,1,MAKELONG(0,100));
		SendDlgItemMessage(hDlg,15503,TBM_SETPOS,1,tmpOptions->FavoriteExitNodesPriority);
	}
	else if(uMsg==WM_COMMAND)
	{
		if((LOWORD(wParam)>=15400)&&(LOWORD(wParam)<=15404))
		{	tmpOptions->_AllowInvalid=0;
			char *tmp1=tor_malloc(32768),*tmp2;
			if(tmpOptions->AllowInvalidNodes)
			{	SMARTLIST_FOREACH(tmpOptions->AllowInvalidNodes, char *, cp, tor_free(cp));
				smartlist_clear(tmpOptions->AllowInvalidNodes);
			}
			else	tmpOptions->AllowInvalidNodes=smartlist_create();
Exemplo n.º 2
0
void do_ban( CHAR_DATA* ch, const char* argument)
{
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    char arg3[MAX_INPUT_LENGTH];
    char arg4[MAX_INPUT_LENGTH];
    char *temp;
    BAN_DATA *pban;
    int value = 0, btime;

    if( IS_NPC( ch ) )   /* Don't want mobs banning sites ;) */
    {
        send_to_char( "Monsters are too dumb to do that!\r\n", ch );
        return;
    }

    if( !ch->desc )   /* No desc means no go :) */
    {
        bug( "%s", "do_ban: no descriptor" );
        return;
    }

    set_char_color( AT_IMMORT, ch );
    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    argument = one_argument( argument, arg3 );
    argument = one_argument( argument, arg4 );

    /*
     * Do we have a time duration for the ban?
     */

    if( arg4[0] != '\0' && is_number( arg4 ) )
        btime = atoi( arg4 );
    else
        btime = -1;


    /*
     * -1 is default, but no reason the time should be greater than 1000
     * * or less than 1, after all if it is greater than 1000 you are talking
     * * around 3 years.
     */

    if( btime != -1 && ( btime < 1 || btime > 1000 ) )
    {
        send_to_char( "Time value is -1 (forever) or from 1 to 1000.\r\n", ch );
        return;
    }

    /*
     * Need to be carefull with sub-states or everything will get messed up.
     */

    switch ( ch->substate )
    {
    default:
        bug( "%s", "do_ban: illegal substate" );
        return;
    case SUB_RESTRICTED:
        send_to_char( "You cannot use this command from within another command.\r\n", ch );
        return;
    case SUB_NONE:
        ch->tempnum = SUB_NONE;
        break;

    /*
     * Returning to end the editing of the note
     */

    case SUB_BAN_DESC:
        add_ban( ch, "", "", 0, 0 );
        return;
    }
    if( arg1[0] == '\0' )
        goto syntax_message;

    /*
     * If no args are sent after the class/site/race, show the current banned
     * * items.  Shaddai
     */

    if( !str_cmp( arg1, "site" ) )
    {
        if( arg2[0] == '\0' )
        {
            show_bans( ch, BAN_SITE );
            return;
        }

        /*
         * Are they high enough to ban sites?
         */

        if( get_trust( ch ) < sysdata.ban_site_level )
        {
            ch_printf( ch, "You must be %d level to add bans.\r\n", sysdata.ban_site_level );
            return;
        }
        if( arg3[0] == '\0' )
            goto syntax_message;
        if( !add_ban( ch, arg2, arg3, btime, BAN_SITE ) )
            return;
    }
    else if( !str_cmp( arg1, "race" ) )
    {
        if( arg2[0] == '\0' )
        {
            show_bans( ch, BAN_RACE );
            return;
        }

        /*
         * Are they high enough level to ban races?
         */

        if( get_trust( ch ) < sysdata.ban_race_level )
        {
            ch_printf( ch, "You must be %d level to add bans.\r\n", sysdata.ban_race_level );
            return;
        }
        if( arg3[0] == '\0' )
            goto syntax_message;
        if( !add_ban( ch, arg2, arg3, btime, BAN_RACE ) )
            return;
    }
    else if( !str_cmp( arg1, "class" ) )
    {
        if( arg2[0] == '\0' )
        {
            show_bans( ch, BAN_CLASS );
            return;
        }

        /*
         * Are they high enough to ban classes?
         */

        if( get_trust( ch ) < sysdata.ban_class_level )
        {
            ch_printf( ch, "You must be %d level to add bans.\r\n", sysdata.ban_class_level );
            return;
        }
        if( arg3[0] == '\0' )
            goto syntax_message;
        if( !add_ban( ch, arg2, arg3, btime, BAN_CLASS ) )
            return;
    }
    else if( !str_cmp( arg1, "show" ) )
    {

        /*
         * This will show the note attached to a ban
         */

        if( arg2[0] == '\0' || arg3[0] == '\0' )
            goto syntax_message;
        temp = arg3;
        if( arg3[0] == '#' ) /* Use #1 to show the first ban */
        {
            temp = arg3;
            temp++;
            if( !is_number( temp ) )
            {
                send_to_char( "Which ban # to show?\r\n", ch );
                return;
            }
            value = atoi( temp );
            if( value < 1 )
            {
                send_to_char( "You must specify a number greater than 0.\r\n", ch );
                return;
            }
        }
        if( !str_cmp( arg2, "site" ) )
        {
            pban = first_ban;
            if( temp[0] == '*' )
                temp++;
            if( temp[strlen( temp ) - 1] == '*' )
                temp[strlen( temp ) - 1] = '\0';
        }
        else if( !str_cmp( arg2, "class" ) )
            pban = first_ban_class;
        else if( !str_cmp( arg2, "race" ) )
            pban = first_ban_race;
        else
            goto syntax_message;
        for( ; pban; pban = pban->next )
            if( value == 1 || !str_cmp( pban->name, temp ) )
                break;
            else if( value > 1 )
                value--;

        if( !pban )
        {
            send_to_char( "No such ban.\r\n", ch );
            return;
        }
        ch_printf( ch, "Banned by: %s\r\n", pban->ban_by );
        send_to_char( pban->note, ch );
        return;
    }
    else
        goto syntax_message;
    return;

    /* Catch all syntax message, make sure that return stays above this or you
     * will get the syntax message everytime you issue the command even if it
     * is a valid one.  Shaddai
     */

syntax_message:
    send_to_char( "Syntax: ban site  <address> <type> <duration>\r\n", ch );
    send_to_char( "Syntax: ban race  <race>    <type> <duration>\r\n", ch );
    send_to_char( "Syntax: ban class <class>   <type> <duration>\r\n", ch );
    send_to_char( "Syntax: ban show  <field>   <number>\r\n", ch );
    send_to_char( "Ban site lists current bans.\r\n", ch );
    send_to_char( "Duration is the length of the ban in days.\r\n", ch );
    send_to_char( "Type can be:  newbie, mortal, all, warn or level.\r\n", ch );
    send_to_char( "In ban show, the <field> is site, race or class,", ch );
    send_to_char( "  and the <number> is the ban number.\r\n", ch );
    return;
}