예제 #1
0
void Webadmin_ConsoleCommand(xml_t* xmlobj, const char* command, int uid)
{
	char sv_outputbuf[SV_OUTPUTBUF_LENGTH];
	char buffer[960];
	char cmd[48];
	int power, powercmd, oldpower, oldinvokeruid, oldinvokerclnum, i;
	
	
	if((power = Auth_GetClPowerByUID(uid)) < 100)
	{
		i = 0;
		/* Get the current user's power 1st */
		while ( command[i] != ' ' && command[i] != '\0' && command[i] != '\n' && i < 32 ){
			i++;
		}
		if(i > 29 || i < 3) return;
		
		Q_strncpyz(cmd,command,i+1);
		
		//Prevent buffer overflow as well as prevent the execution of priveleged commands by using seperator characters
		Q_strncpyz(buffer, command, sizeof(buffer));
		Q_strchrrepl(buffer,';','\0');
		Q_strchrrepl(buffer,'\n','\0');
		Q_strchrrepl(buffer,'\r','\0');
		// start redirecting all print outputs to the packet
		
		powercmd = Cmd_GetPower(cmd);
		if(powercmd > power)
		{
			XA(" Insufficient permissions! ");
				return;
		}
		
		xmlobjFlush = xmlobj;
		
		oldpower = Cmd_GetInvokerPower();
		oldinvokeruid = Cmd_GetInvokerUID();
		oldinvokerclnum = Cmd_GetInvokerClnum();
		Cmd_SetCurrentInvokerInfo(uid, power, -1);
		
		Com_BeginRedirect (sv_outputbuf, SV_OUTPUTBUF_LENGTH, Webadmin_FlushRedirect);
		Cmd_ExecuteSingleCommand(0,0, buffer);
		
		Cmd_SetCurrentInvokerInfo(oldinvokeruid, oldpower, oldinvokerclnum);
		
	}else{
		xmlobjFlush = xmlobj;
		Com_BeginRedirect (sv_outputbuf, SV_OUTPUTBUF_LENGTH, Webadmin_FlushRedirect);
		Cmd_ExecuteSingleCommand(0,0, command);
#ifdef PUNKBUSTER
		if(!Q_stricmpn(command, "pb_sv_", 6)) PbServerForceProcess();
#endif
	}

	Com_EndRedirect();

	xmlobjFlush = NULL;
}
예제 #2
0
void HL2Rcon_SourceRconStreaming_enable( int type, int uid ){

	rconUser_t* user;
	char* c;
	char* cg;
	char* ch;
	char* ev;

	if(sourceRcon.redirectUser < 1 || sourceRcon.redirectUser > MAX_RCONUSERS){
		Com_Printf("This command can only be used from SourceRcon\n");
		return;
	}

	user = &sourceRcon.activeRconUsers[sourceRcon.redirectUser -1];

	if(Auth_GetClPowerByUID(uid) > 98 || !(type & 1))
	{
		user->streamlog = type & 1;

	}else if(type & 1){
		Com_Printf("Insufficient permissions to open console logfile!\n");

	}
	user->streamgamelog = type & 2;
	user->streamchat = type & 4;
	user->streamevents = type & 8;

	if(user->streamlog)
		c = "logfile";
	else
		c = "";

	if(user->streamgamelog)
		cg = "gamelog";
	else
		cg = "";

	if(user->streamchat)
		ch = "chat";
	else
		ch = "";

	if(user->streamevents)
		ev = "events";
	else
		ev = "";

	Com_Printf("Streaming turned on for: %s %s %s %s\n", c, cg, ch, ev);
}
예제 #3
0
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);
			}
		}
	}

}
예제 #4
0
void Webadmin_BuildAdminList(xml_t* xmlobj, int uid)
{
	int i, cnt;
	char colorbuf[2048];
	authData_admin_t* badmin;
	mvabuf;

	if(Auth_GetClPowerByUID(uid) < Cmd_GetPower("adminlistadmins"))
	{
		XA("Insufficient permissions");
		return;
	}

	XO1("table","class","table table-striped table-bordered cod4xtable");
	XA("<th>Name</th><th>UID</th><th>Power</th>");
	
	for (i = 0, cnt = 0, badmin = Auth_GetAdminFromIndex( i ); badmin != NULL; i++, badmin = Auth_GetAdminFromIndex( i ))
	{
		if(badmin->username[0] == '\0')
		{
			continue;
		}
		
		XO("tr");

			XO("td");//Name
			XA(Webadmin_ConvertToHTMLColor(badmin->username, colorbuf, sizeof(colorbuf)));
			XC;
			
			XO("td");//GUID
			XA(va("%d", badmin->uid));
			XC;

			XO("td");//Power points
			XA(va("%d", badmin->power));
			XC;

		XC;
		++cnt;
	}
	XC;
	XA(va("%d admins", cnt));
	
}