qboolean SV_ParseBanlist(char* line, time_t aclock, int linenumber){ banList_t *this; int playeruid = 0; int adminuid = 0; time_t expire = 0; char reason[128]; char guid[9]; guid[8] = 0; char playername[MAX_NAME_LENGTH]; int i; playeruid = atoi(Info_ValueForKey(line, "uid")); adminuid = atoi(Info_ValueForKey(line, "auid")); expire = atoi(Info_ValueForKey(line, "exp")); Q_strncpyz(reason, Info_ValueForKey(line, "rsn"), sizeof(reason)); Q_strncpyz(guid, Info_ValueForKey(line, "guid"), sizeof(guid)); Q_strncpyz(playername, Info_ValueForKey(line, "nick"), sizeof(guid)); if(expire < aclock && expire != (time_t)-1){ return qtrue; } this = banlist; if(!this) return qfalse; if(playeruid){ for(i = 0; i < current_banindex; this++, i++){ if(this->playeruid == playeruid){ Com_Printf("Error: This player with UID: %i is already banned onto this server (line: %d)\n",playeruid, linenumber); return qfalse; } } }else if(guid[7]){ for(i = 0; i < current_banindex; this++, i++){ if(!Q_stricmp(this->pbguid, guid)){ Com_Printf("Error: This player with GUID: %s is already banned onto this server (line: %d)\n",guid, linenumber); return qfalse; } } }else{ Com_Printf("Error: This player has no uid/guid (line: %d)\n",linenumber); return qfalse; //Bad entry: No Id } if(!SV_OversizeBanlistAlign()) return qfalse; this = &banlist[current_banindex]; this->playeruid = playeruid; this->adminuid = adminuid; this->expire = expire; Q_strncpyz(this->reason, reason, sizeof(this->reason)); Q_strncpyz(this->pbguid, guid, sizeof(this->pbguid)); Q_strncpyz(this->playername, playername, sizeof(this->playername)); current_banindex++; //Rise the array index return qtrue; }
qboolean SV_AddBan(int uid, int auid, char* guid, char* name, time_t expire, char* banreason){ if(!SV_OversizeBanlistAlign()) return qfalse; banList_t *this; int i; this = banlist; if(!this) return qfalse; int type; if(uid > 0){ type = 0; }else if(guid && strlen(guid) == 8){ type = 1; }else{ return qfalse; } if(!SV_ReloadBanlist()) return qfalse; for(i = 0 ; i < current_banindex; this++, i++){ switch(type) { case 0: if(uid != this->playeruid) continue; break; case 1: if(Q_stricmp(guid, this->pbguid)) continue; } break; } if(i == current_banindex){ current_banindex++; //Rise the array index }else{ if(type == 0){ Com_Printf( "Modifying banrecord for player uid: %i\n", uid); SV_PrintAdministrativeLog( "modified banrecord of player uid: %i:", uid); }else{ Com_Printf( "Modifying banrecord for player guid: %s\n", guid); SV_PrintAdministrativeLog( "modified banrecord of player guid: %s:", guid); } } this->playeruid = uid; this->adminuid = auid; this->expire = expire; if(banreason) Q_strncpyz(this->reason, banreason, sizeof(this->reason)); else *this->reason = 0; if(guid && type) Q_strncpyz(this->pbguid, guid, sizeof(this->pbguid)); else *this->pbguid = 0; if(name) Q_strncpyz(this->playername, name, sizeof(this->playername)); else *this->playername = 0; SV_WriteBanlist(); return qtrue; }
qboolean SV_ParseBanlist(char* line, time_t aclock, int linenumber){ banList_t *this; uint64_t playerid = 0; uint64_t adminsteamid = 0; time_t expire = 0; time_t create = 0; char reason[128]; char playername[MAX_NAME_LENGTH]; int i; char *tmp; netadr_t adr; playerid = Plugin_StringToSteamID(Info_ValueForKey(line, "playerid")); adminsteamid = Plugin_StringToSteamID(Info_ValueForKey(line, "asteamid")); expire = atoi(Info_ValueForKey(line, "exp")); create = atoi(Info_ValueForKey(line, "create")); tmp = Info_ValueForKey(line, "netadr"); if(tmp && tmp[0]) { Plugin_NET_StringToAdr(tmp, &adr, NA_UNSPEC); }else{ memset(&adr, 0, NA_BAD); } Q_strncpyz(reason, Info_ValueForKey(line, "rsn"), sizeof(reason)); Q_strncpyz(playername, Info_ValueForKey(line, "nick"), sizeof(playername)); if(expire < aclock && expire != (time_t)-1) { return qtrue; } this = banlist; if(!this) return qfalse; if(playerid){ for(i = 0; i < current_banindex; this++, i++){ if(this->playerid == playerid){ Plugin_SteamIDToString(playerid, tmp, sizeof(tmp)); Plugin_Printf("Error: This player with playerid: %s is already banned on this server (line: %d)\n", tmp, linenumber); return qfalse; } } }else{ Plugin_Printf("Error: This player has no id (line: %d)\n",linenumber); return qfalse; //Bad entry: No Id } if(!SV_OversizeBanlistAlign()) return qfalse; this = &banlist[current_banindex]; this->playerid = playerid; this->adminsteamid = adminsteamid; this->expire = expire; this->created = create; Q_strncpyz(this->reason, reason, sizeof(this->reason)); Q_strncpyz(this->playername, playername, sizeof(this->playername)); this->remote = adr; current_banindex++; //Rise the array index return qtrue; }
qboolean SV_ParseBanlistLegacy(char* line, time_t aclock, int linenumber){ banList_t *this; time_t expire = 0; time_t create = 0; char reason[128]; char guid[9]; guid[8] = 0; char playername[MAX_NAME_LENGTH]; int i; char *tmp; netadr_t adr; expire = atoi(Info_ValueForKey(line, "exp")); tmp = Info_ValueForKey(line, "create"); if(tmp && tmp[0]) { create = atoi(tmp); } tmp = Info_ValueForKey(line, "netadr"); if(tmp && tmp[0]) { Plugin_NET_StringToAdr(tmp, &adr, NA_UNSPEC); }else{ memset(&adr, 0, NA_BAD); } Q_strncpyz(reason, Info_ValueForKey(line, "rsn"), sizeof(reason)); Q_strncpyz(guid, Info_ValueForKey(line, "guid"), sizeof(guid)); Q_strncpyz(playername, Info_ValueForKey(line, "nick"), sizeof(playername)); if(expire < aclock && expire != (time_t)-1) { return qtrue; } this = banlist; if(!this) return qfalse; if(guid[7]){ for(i = 0; i < current_banindex; this++, i++){ if(Q_stricmpn(this->guid, guid, 8) == 0){ Plugin_Printf("Error: This player with GUID: %s is already banned on this server (line: %d)\n",guid, linenumber); return qfalse; } } }else{ Plugin_Printf("Error: This player has no guid (line: %d)\n",linenumber); return qfalse; //Bad entry: No Id } if(!SV_OversizeBanlistAlign()) return qfalse; this = &banlist[current_banindex]; Q_strncpyz(this->guid, guid, sizeof(this->guid)); this->expire = expire; this->created = create; Q_strncpyz(this->reason, reason, sizeof(this->reason)); Q_strncpyz(this->playername, playername, sizeof(this->playername)); this->remote = adr; current_banindex++; //Rise the array index return qtrue; }
qboolean SV_AddBanToInternalList(uint64_t playerid, uint64_t adminsteamid, char* name, netadr_t* adr, time_t expire, char* banreason) { char pid[128]; time_t aclock; if(!SV_OversizeBanlistAlign()) return qfalse; time(&aclock); banList_t *this; int i; this = banlist; if(!this) return qfalse; if(playerid == 0) { return qfalse; } if(!SV_ReloadBanlist()) return qfalse; for(i = 0 ; i < current_banindex; this++, i++){ if(playerid == this->playerid) break; } if(i == current_banindex) { current_banindex++; //Rise the array index }else{ Plugin_SteamIDToString(playerid, pid, sizeof(pid)); Plugin_Printf( "Modifying banrecord for player id: %s\n", pid); Plugin_PrintAdministrativeLog( "modified banrecord of player id: %s:", pid); } this->playerid = playerid; this->adminsteamid = adminsteamid; this->expire = expire; this->created = aclock; if(adr && adr->type != NA_BAD) { this->remote = *adr; }else{ memset(&this->remote, 0, sizeof(netadr_t)); } if(banreason) Q_strncpyz(this->reason, banreason, sizeof(this->reason)); else *this->reason = 0; if(name) Q_strncpyz(this->playername, name, sizeof(this->playername)); else *this->playername = 0; SV_WriteBanlist(); return qtrue; }