Назад

@unbanip (by Griniy)

Автор: ZzAQ: Дата: 06.12.2008

Вот, как следствие, UnBan по IP. Снимает бан по имени игрока(char_name).

atcommand.h


AtCommand_unbanip, //By [Griniy]


atcommand.c


ACMD_FUNC(unbanip); //By [Griniy]


{ AtCommand_unbanip,      "@unbanip",      20, atcommand_unbanip }, //By [Griniy]


// UnBanIP by [Griniy]
int atcommand_unbanip(const int fd, struct map_session_data* sd,    const char* command, const char* message)
{
    char ip[16];
    nullpo_retr(-1, sd);

    memset(atcmd_player_name, '', sizeof(atcmd_player_name));

    if (!message || !*message || (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)) {
clif_displaymessage(fd, "Please, enter a player name to unban (usage: @unbanip ).");
return -1;
    }
    sprintf(tmpsql,"SELECT `last_ip` From `login`, `char` WHERE login.account_id = char.account_id AND char.name = '%s'",atcmd_player_name);
    if(mysql_query(&mmysql_handle, tmpsql)) {
       ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle));
       ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
return -1;
    }
sql_res = mysql_store_result(&mmysql_handle);
if (sql_res) {
sql_row = mysql_fetch_row(sql_res);
if (!sql_row) {
   clif_displaymessage(fd, "The character name is unknown. Check and repit");
   mysql_free_result(sql_res);
   return -1;
}
strcpy(ip, sql_row[0]);
mysql_free_result(sql_res);
}
sprintf(tmpsql,"SELECT `rtime` From `ipbanlist` Where `list` = '%s'",ip);
    if(mysql_query(&mmysql_handle, tmpsql)) {
       ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle));
       ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
return -1;
    }
sql_res = mysql_store_result(&mmysql_handle);
if (sql_res) {
sql_row = mysql_fetch_row(sql_res);
     if (!sql_row) {
     clif_displaymessage(fd, "This Character dosn`t found in IPban list.");
     mysql_free_result(sql_res);
     return -1;
     } else {
mysql_free_result(sql_res);
     }
}
    sprintf(tmpsql,"DELETE FROM `ipbanlist` WHERE `list` = '%s'",ip);
    if(mysql_query(&mmysql_handle, tmpsql)) {
       ShowSQL("DB error - %s\n",mysql_error(&mmysql_handle));
       ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql);
return -1;
    }
    clif_displaymessage(fd, "Unbanip succes.");
return 0;
}

Автор: : Дата: 01.01.1970