void GScr_BanClient() { client_t *cl; if(Scr_GetNumParam() != 1) Scr_Error("Usage: ban(<clientid>)\n"); int clnum = Scr_GetInt(0); if(clnum < 0 || clnum >= g_maxclients->integer) Scr_Error("ban(): Out of range client id\n"); cl = &svs.clients[clnum]; if(!SV_UseUids()){ SV_AddBan(0, 0, &cl->pbguid[24], cl->name, (time_t)-1, "Banned by scriptadmin"); SV_DropClient(cl, "Banned by scriptadmin\n"); }else{ if(cl->uid > 0) { SV_AddBan(cl->uid, 0, cl->pbguid, cl->name, (time_t)-1, "Banned by scriptadmin"); SV_DropClient(cl, "Banned by scriptadmin\n"); }else{ SV_DropClient(cl, "Player kicked by scriptadmin\n"); } } }
void Webadmin_BanClient( xml_t* xmlobj, httpPostVals_t* values, int uid) { const char* arg1; const char* reason; int cid, cluid; mvabuf; if(Auth_GetClPowerByUID(uid) < Cmd_GetPower("permban")) { XA("Insufficient permissions"); return; } if( (reason = Webadmin_GetPostVal(values, "reason")) ) { if( (arg1 = Webadmin_GetPostVal(values, "cid")) ) { cid = atoi(arg1); if (cid >= 0 && cid < sv_maxclients->integer) { if(uid > 0 || strlen(svs.clients[cid].pbguid) == 32) { SV_AddBan(svs.clients[cid].uid, uid, svs.clients[cid].pbguid, svs.clients[cid].name, (time_t)-1, (char*)reason); } SV_PlayerAddBanByip(&svs.clients[cid].netchan.remoteAddress, (char*)reason, svs.clients[cid].uid, svs.clients[cid].pbguid, uid, -1); XA("Banned player"); XA(svs.clients[cid].name); } }else if( (arg1 = Webadmin_GetPostVal(values, "uid")) ){ cluid = atoi(arg1); if (cluid > 0) { SV_AddBan(cluid, uid, NULL, "N/A", (time_t)-1, (char*)reason); XA(va("Banned player with uid %d", cluid)); } }else if ( (arg1 = Webadmin_GetPostVal(values, "guid"))) { if (strlen(arg1) == 32) { SV_AddBan(0, uid, (char*)arg1, "N/A", (time_t)-1, (char*)reason); XA("Banned player with guid "); XA(arg1); } } } }
P_P_F void Plugin_BanClient( unsigned int clientnum, int duration, int invokerid, char *banreason ) { client_t *cl; char* guid; time_t expire; char* temp; time_t aclock; char endtime[32]; char dropmsg[MAX_STRING_CHARS]; if(clientnum > sv_maxclients->integer) return; cl = &svs.clients[clientnum]; time(&aclock); if(duration == -1) { expire = duration; Q_strncpyz(endtime, "never", sizeof(endtime)); } else { expire = (aclock+(time_t)(duration*60)); temp = ctime(&expire); temp[strlen(temp)-1] = 0; Q_strncpyz(endtime, temp, sizeof(endtime)); } if(strlen(cl->pbguid) == 32) { guid = &cl->pbguid[24]; } else if(cl->uid < 1) { Com_Printf("Error: This player has no valid ID and got banned by IP only\n"); SV_DropClient(cl, "Invalid ID\n"); SV_PlayerAddBanByip(&cl->netchan.remoteAddress, "INVALID USER", 0, "INVALID", 0, expire); return; } if(banreason == NULL) { banreason = "N/A"; } SV_AddBan(cl->uid, invokerid, guid, cl->name, expire, banreason); if( cl->uid > 0 ) { Com_Printf( "Banrecord added for player: %s uid: %i\n", cl->name, cl->uid); SV_PrintAdministrativeLog( "Banned player: %s uid: %i until %s with the following reason: %s", cl->name, cl->uid, endtime, banreason); Com_sprintf(dropmsg, sizeof(dropmsg), "You have been banned from this server\nYour ban will expire on: %s\nYour UID is: %i Banning admin UID is: %i\nReason for this ban:\n%s", endtime, cl->uid, invokerid, banreason); }else{ Com_Printf( "Banrecord added for player: %s guid: %s\n", cl->name, cl->pbguid); SV_PrintAdministrativeLog( "Banned player: %s guid: %s until %s with the following reason: %s", cl->name, cl->pbguid, endtime, banreason); Com_sprintf(dropmsg, sizeof(dropmsg), "You have been banned from this server\nYour ban will expire on: %s\nYour GUID is: %s Banning admin UID is: %i\nReason for this ban:\n%s", endtime, cl->pbguid, invokerid, banreason); if(cl->authentication < 1) { SV_PlayerAddBanByip(&cl->netchan.remoteAddress, banreason, 0, cl->pbguid, 0, expire); } } SV_DropClient(cl, dropmsg); }