bool Commands::getInfo(Creature* creature, const std::string& cmd, const std::string& param) { Player* player = creature->getPlayer(); if(!player) return true; Player* paramPlayer = g_game.getPlayerByName(param); if(paramPlayer) { std::stringstream info; if(paramPlayer->getAccessLevel() >= player->getAccessLevel() && player != paramPlayer){ player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "You can not get info about this player."); return true; } uint8_t ip[4]; *(uint32_t*)&ip = paramPlayer->lastip; info << "name: " << paramPlayer->getName() << std::endl << "access: " << paramPlayer->getAccessLevel() << std::endl << "level: " << paramPlayer->getPlayerInfo(PLAYERINFO_LEVEL) << std::endl << "maglvl: " << paramPlayer->getPlayerInfo(PLAYERINFO_MAGICLEVEL) << std::endl << "speed: " << paramPlayer->getSpeed() <<std::endl << "position " << paramPlayer->getPosition() << std::endl << "ip: " << ipText(ip); player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, info.str().c_str()); } else{ player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Player not found."); } return true; }
void ForwardRules::buildDefaultRules(const char* domain, const char* hostname, const char* ipAddress, const char* fqhn, int localPort, TiXmlDocument& xmlDoc) { // Note: fqhn == fully qualified host name UtlString hostnamePort(hostname ? hostname : "localhost"); UtlString domainPort(domain ? domain : ""); UtlString ipAddressPort(ipAddress ? ipAddress : "127.0.0.1"); UtlString fqhnPort(fqhn ? fqhn : "localhost"); if(localPort == 5060) localPort = PORT_NONE; if(portIsValid(localPort)) { char portString[40]; sprintf(portString,":%d", localPort); hostnamePort.append(portString); domainPort.append(portString); ipAddressPort.append(portString); fqhnPort.append(portString); } UtlString sdsAddress(fqhn); sdsAddress.append(":5090"); UtlString statusAddress(fqhn); statusAddress.append(":5110"); UtlString regAddress(fqhn); regAddress.append(":5070"); UtlString configAddress("sipuaconfig"); UtlString configFqhnAddress(configAddress); configFqhnAddress.append("."); configFqhnAddress.append(domain); TiXmlElement routes("routes"); TiXmlElement route("route"); route.SetAttribute("mappingType", "local"); TiXmlElement routeFromDomain("routeFrom"); TiXmlText domainText(domainPort.data()); TiXmlElement routeFromFqhn("routeFrom"); TiXmlText fqhnText(fqhnPort.data()); TiXmlElement routeFromHost("routeFrom"); TiXmlText hostText(hostnamePort.data()); TiXmlElement routeFromIp("routeFrom"); TiXmlText ipText(ipAddressPort.data()); TiXmlElement methodMatch("methodMatch"); TiXmlElement methodPattern("methodPattern"); TiXmlText subscribe("SUBSCRIBE"); TiXmlElement fieldMatchConfig("fieldMatch"); fieldMatchConfig.SetAttribute("fieldName", "Event"); TiXmlElement fieldPatternConfig("fieldPattern"); TiXmlText configEvent("sip-config"); TiXmlElement routeToSds("routeTo"); TiXmlText sdsText(sdsAddress.data()); TiXmlElement fieldMatchStatus("fieldMatch"); fieldMatchStatus.SetAttribute("fieldName", "Event"); TiXmlElement fieldPatternStatus("fieldPattern"); TiXmlText mwiEvent("message-summary*"); TiXmlElement routeToStatus("routeTo"); TiXmlText statusText(statusAddress.data()); TiXmlElement routeToReg("routeTo"); TiXmlText regText(regAddress.data()); TiXmlElement routeConfig("route"); TiXmlElement routeFromFqhnConfig("routeFrom"); TiXmlText fqhnConfigText(configFqhnAddress.data()); TiXmlElement routeFromConfig("routeFrom"); TiXmlText configText(configAddress.data()); // Link everything up in reverse order as it TinyXml // makes copies routeFromDomain.InsertEndChild(domainText); route.InsertEndChild(routeFromDomain); routeFromHost.InsertEndChild(hostText); route.InsertEndChild(routeFromHost); routeFromFqhn.InsertEndChild(fqhnText); route.InsertEndChild(routeFromFqhn); routeFromIp.InsertEndChild(ipText); route.InsertEndChild(routeFromIp); methodPattern.InsertEndChild(subscribe); methodMatch.InsertEndChild(methodPattern); fieldPatternStatus.InsertEndChild(mwiEvent); fieldMatchStatus.InsertEndChild(fieldPatternStatus); routeToStatus.InsertEndChild(statusText); fieldMatchStatus.InsertEndChild(routeToStatus); methodMatch.InsertEndChild(fieldMatchStatus); fieldPatternConfig.InsertEndChild(configEvent); fieldMatchConfig.InsertEndChild(fieldPatternConfig); routeToSds.InsertEndChild(sdsText); fieldMatchConfig.InsertEndChild(routeToSds); methodMatch.InsertEndChild(fieldMatchConfig); routeToReg.InsertEndChild(regText); methodMatch.InsertEndChild(routeToReg); route.InsertEndChild(methodMatch); route.InsertEndChild(routeToReg); routeFromFqhnConfig.InsertEndChild(fqhnConfigText); routeConfig.InsertEndChild(routeFromFqhnConfig); routeFromConfig.InsertEndChild(configText); routeConfig.InsertEndChild(routeFromConfig); routeConfig.InsertEndChild(routeToReg); routes.InsertEndChild(route); routes.InsertEndChild(routeConfig); xmlDoc.InsertEndChild(routes); }