void SRA_FUSER_Init(void) { rc_t rc = 0; /* reopen log file and start watch thread(s) */ if( (rc = LogFile_Init(NULL, 0, true, NULL)) != 0 ) { LOGERR(klogErr, rc, "log file"); } XML_Init(); LOGMSG(klogInfo, "Started"); }
void Webadmin_BuildMessage(msg_t* msg, const char* username, qboolean invalidloginattempt, const char* banmsg, const char* url, httpPostVals_t* values) { xml_t xmlbase; xml_t* xmlobj = &xmlbase; char actionval[64]; char colorbuf[2048]; const char *postval; char netadrstr[128]; uint64_t steamid; int power, oldpower, oldinvokerclnum; uint64_t oldinvokersteamid; char oldinvokername[64]; const char* name; XML_Init(xmlobj, (char*)msg->data, msg->maxsize, "ISO-8859-1"); XO("html"); XO("head"); XO("title"); XA("CoD4X Web Server"); XC; XO2("link","href","/files/webadmin.css","rel","stylesheet");XC; XC; XO("body"); XO1("div","class","container"); XO1("div","class","page-header"); XO("h1"); XA("CoD4 X v1.8"); XO("small"); XA(" Web Server"); XC; XC; XO("h3"); XA(Webadmin_ConvertToHTMLColor(sv_hostname->string, colorbuf, sizeof(colorbuf))); XA(" "); XA(sv_mapname->string); XC; XC; if(!Q_strncmp(url, "/webadmin", 9)) { if(username == NULL || username[0] == '\0') { Webadmin_BuildLoginForm(xmlobj, invalidloginattempt, banmsg); }else { steamid = Auth_GetSteamID(username); if(!Q_strncmp(url +9, "/listadmins", 11)) { Webadmin_BuildAdminList(xmlobj, steamid); }else { XO1("div","class","loginusername"); XO1("span","class","label label-primary"); XA("Logged in as: ");XA(username);XA(". "); XO2("a","href","/webadmin/?action=logout","style","color: #fff"); XA("Log Out"); XC; XC; XC; XO1("div", "class", "col-lg-6 right_line"); XO("h3");XA("Server Status");XC; XO("hr");XC; Webadmin_BuildServerStatus(xmlobj, qtrue); XC; XO1("div", "class", "col-lg-6 left_line"); XO("h3");XA("Command Console");XC; XO("hr");XC; if(Webadmin_GetUrlVal( url, "action", actionval, sizeof(actionval)))//nnjpls { if (strcmp(actionval, "logout") == 0) { Auth_WipeSessionId(username); }else{ oldpower = Cmd_GetInvokerPower(); oldinvokerclnum = Cmd_GetInvokerClnum(); oldinvokersteamid = Cmd_GetInvokerSteamID(); Cmd_GetInvokerName(oldinvokername, sizeof(oldinvokername)); power = Auth_GetClPowerBySteamID(steamid); name = Auth_GetNameBySteamID(steamid); Cmd_SetCurrentInvokerInfo(power, -1, steamid, name); if(strcmp(actionval, "sendcmd") == 0){ postval = HTTP_GetFormDataItem(values, "consolecommand"); if(postval[0]){ XO1("div","class","well"); Webadmin_ConsoleCommand(xmlobj, postval, steamid); XC; } }else if(strcmp(actionval, "banclient") == 0){ Webadmin_BanClient(xmlobj, values, steamid); }else if(strcmp(actionval, "kickclient") == 0){ Webadmin_KickClient(xmlobj, values, steamid); } Cmd_SetCurrentInvokerInfo(oldpower, oldinvokerclnum, oldinvokersteamid, oldinvokername); } } XO5("form", "name", "input", "action", "webadmin?action=sendcmd", "method", "post", "class","form-control","id","con_form"); XA("<label for=\"consolecommand\">Send Command</label> <input type=\"text\" name=\"consolecommand\" id=\"consolecommand\">"); XA("<button class=\"givesomespace btn btn-primary btn-xs\" type=\"submit\">Send Command</button>"); XC; XC; } } }else if(!Q_strncmp(url, "/status", 7)){ XO("h3");XA("Server Status");XC; XO("hr");XC; Webadmin_BuildServerStatus(xmlobj,qfalse); }else { XO1("h3","align","center"); XA("Where do you want to go?"); XC; XO1("div","align","center"); XA("<a href=\"/webadmin\" class=\"btn btn-primary givesomespace\">Web Admin</a>"); XA("<a href=\"/status\" class=\"btn btn-primary givesomespace\">Server Status</a>"); XC; } XO("p"); XA("Net: "); XA(NET_GetHostAddress(netadrstr, sizeof(netadrstr))); XC; XC; XC; XC; msg->cursize = xmlobj->bufposition; }