public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator) { var vars = new Dictionary<string, object>(); IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IGenericsConnector>(); GridNewsItem news; if (requestParameters.ContainsKey("Submit")) { string title = requestParameters["NewsTitle"].ToString(); string text = requestParameters["NewsText"].ToString(); string id = requestParameters["NewsID"].ToString(); news = connector.GetGeneric<GridNewsItem>(UUID.Zero, "WebGridNews", id); connector.RemoveGeneric(UUID.Zero, "WebGridNews", id); GridNewsItem item = new GridNewsItem { Text = text, Time = news.Time, Title = title, ID = int.Parse(id) }; connector.AddGeneric(UUID.Zero, "WebGridNews", id, item.ToOSD()); vars["ErrorMessage"] = "News item edit successfully"; webInterface.Redirect(httpResponse, "index.html?page=news_manager", filename); return vars; } else vars["ErrorMessage"] = ""; news = connector.GetGeneric<GridNewsItem>(UUID.Zero, "WebGridNews", httpRequest.Query["newsid"].ToString()); vars.Add("NewsTitle", news.Title); vars.Add("NewsText", news.Text); vars.Add("NewsID", news.ID.ToString()); vars.Add("NewsItemTitle", translator.GetTranslatedString("NewsItemTitle")); vars.Add("NewsItemText", translator.GetTranslatedString("NewsItemText")); vars.Add("EditNewsText", translator.GetTranslatedString("EditNewsText")); vars.Add("Submit", translator.GetTranslatedString("Submit")); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator) { var vars = new Dictionary<string, object>(); IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IGenericsConnector>(); GridNewsItem news = connector.GetGeneric<GridNewsItem>(UUID.Zero, "WebGridNews", httpRequest.Query["newsid"].ToString()); if (news != null) { vars.Add("NewsTitle", news.Title); vars.Add("NewsText", news.Text); vars.Add("NewsID", news.ID.ToString()); } else { if (httpRequest.Query["newsid"].ToString() == "-1") { vars.Add("NewsTitle", "No news to report"); vars.Add("NewsText", ""); } else { vars.Add("NewsTitle", "Invalid News Item"); vars.Add("NewsText", ""); } vars.Add("NewsID", "-1"); } vars.Add("News", translator.GetTranslatedString("News")); vars.Add("NewsItemTitle", translator.GetTranslatedString("NewsItemTitle")); vars.Add("NewsItemText", translator.GetTranslatedString("NewsItemText")); vars.Add("EditNewsText", translator.GetTranslatedString("EditNewsText")); return vars; }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { httpResponse.ContentType = "image/jpeg"; // StreamReader sr = new StreamReader(requestData); // string body = sr.ReadToEnd(); // sr.Close(); // body = body.Trim(); try { lock (m_RequestLock) { Dictionary<string, object> request = new Dictionary<string, object>(); foreach (string name in httpRequest.QueryString) request[name] = httpRequest.QueryString[name]; return SendWorldView(request); } } catch (Exception e) { m_log.Debug("[WORLDVIEW]: Exception: " + e.ToString()); } return new Byte[0]; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); // Style Switcher vars.Add("styles1", translator.GetTranslatedString("styles1")); vars.Add("styles2", translator.GetTranslatedString("styles2")); vars.Add("styles3", translator.GetTranslatedString("styles3")); vars.Add("styles4", translator.GetTranslatedString("styles4")); vars.Add("styles5", translator.GetTranslatedString("styles5")); vars.Add("StyleSwitcherStylesText", translator.GetTranslatedString("StyleSwitcherStylesText")); vars.Add("StyleSwitcherLanguagesText", translator.GetTranslatedString("StyleSwitcherLanguagesText")); vars.Add("StyleSwitcherChoiceText", translator.GetTranslatedString("StyleSwitcherChoiceText")); // Language Switcher vars.Add("en", translator.GetTranslatedString("en")); vars.Add("fr", translator.GetTranslatedString("fr")); vars.Add("de", translator.GetTranslatedString("de")); vars.Add("it", translator.GetTranslatedString("it")); vars.Add("es", translator.GetTranslatedString("es")); return vars; }
private byte[] SimulatorFeaturesCAP(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { OSDMap data = new OSDMap(); data["MeshRezEnabled"] = true; data["MeshUploadEnabled"] = true; data["MeshXferEnabled"] = true; data["PhysicsMaterialsEnabled"] = true; OSDMap typesMap = new OSDMap(); typesMap["convex"] = true; typesMap["none"] = true; typesMap["prim"] = true; data["PhysicsShapeTypes"] = typesMap; //Data URLS need sent as well //Not yet... //data["DataUrls"] = m_service.Registry.RequestModuleInterface<IGridRegistrationService> ().GetUrlForRegisteringClient (m_service.AgentID + "|" + m_service.RegionHandle); //Send back data return OSDParser.SerializeLLSDXmlBytes(data); }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator) { var vars = new Dictionary<string, object>(); IAgentInfoConnector users = DataManager.DataManager.RequestPlugin<IAgentInfoConnector>(); IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IGenericsConnector>(); GridWelcomeScreen welcomeInfo = connector.GetGeneric<GridWelcomeScreen>(UUID.Zero, "GridWelcomeScreen", "GridWelcomeScreen"); if (welcomeInfo == null) welcomeInfo = GridWelcomeScreen.Default; IConfigSource config = webInterface.Registry.RequestModuleInterface<ISimulationBase>().ConfigSource; vars.Add("GridStatus", translator.GetTranslatedString("GridStatus")); vars.Add("GridOnline", welcomeInfo.GridStatus ? translator.GetTranslatedString("Online") : translator.GetTranslatedString("Offline")); vars.Add("TotalUserCount", translator.GetTranslatedString("TotalUserCount")); vars.Add("UserCount", webInterface.Registry.RequestModuleInterface<IUserAccountService>(). NumberOfUserAccounts(null, "").ToString()); vars.Add("TotalRegionCount", translator.GetTranslatedString("TotalRegionCount")); vars.Add("RegionCount", DataManager.DataManager.RequestPlugin<IRegionData>(). Count((Framework.RegionFlags)0, (Framework.RegionFlags)0).ToString()); vars.Add("UniqueVisitors", translator.GetTranslatedString("UniqueVisitors")); vars.Add("UniqueVisitorCount", users.RecentlyOnline((uint)TimeSpan.FromDays(30).TotalSeconds, false).ToString()); vars.Add("OnlineNow", translator.GetTranslatedString("OnlineNow")); vars.Add("OnlineNowCount", users.RecentlyOnline(5 * 60, true).ToString()); vars.Add("HGActiveText", translator.GetTranslatedString("HyperGrid")); string disabled = translator.GetTranslatedString("Disabled"), enabled = translator.GetTranslatedString("Enabled"); vars.Add("HGActive", disabled + "(TODO: FIX)"); vars.Add("VoiceActiveLabel", translator.GetTranslatedString("Voice")); vars.Add("VoiceActive", config.Configs["Voice"] != null && config.Configs["Voice"].GetString("Module", "GenericVoice") != "GenericVoice" ? enabled : disabled); vars.Add("CurrencyActiveLabel", translator.GetTranslatedString("Currency")); vars.Add("CurrencyActive", webInterface.Registry.RequestModuleInterface<IMoneyModule>() != null ? enabled : disabled); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator) { var vars = new Dictionary<string, object>(); if (requestParameters.ContainsKey("Submit")) { string title = requestParameters["NewsTitle"].ToString(); string text = requestParameters["NewsText"].ToString(); IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IGenericsConnector>(); GridNewsItem item = new GridNewsItem { Text = text, Time = DateTime.Now, Title = title }; item.ID = connector.GetGenericCount(UUID.Zero, "WebGridNews") + 1; connector.AddGeneric(UUID.Zero, "WebGridNews", item.ID.ToString(), item.ToOSD()); vars["ErrorMessage"] = "News item added successfully"; webInterface.Redirect(httpResponse, "index.html?page=news_manager", filename); return vars; } else vars["ErrorMessage"] = ""; vars.Add("NewsItemTitle", translator.GetTranslatedString("NewsItemTitle")); vars.Add("NewsItemText", translator.GetTranslatedString("NewsItemText")); vars.Add("AddNewsText", translator.GetTranslatedString("AddNewsText")); vars.Add("Submit", translator.GetTranslatedString("Submit")); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IGenericsConnector>(); GridNewsItem news; if (requestParameters.ContainsKey("Submit")) { string title = requestParameters["NewsTitle"].ToString(); string text = requestParameters["NewsText"].ToString(); string id = requestParameters["NewsID"].ToString(); news = connector.GetGeneric<GridNewsItem>(UUID.Zero, "WebGridNews", id); connector.RemoveGeneric(UUID.Zero, "WebGridNews", id); GridNewsItem item = new GridNewsItem { Text = text, Time = news.Time, Title = title, ID = int.Parse(id) }; connector.AddGeneric(UUID.Zero, "WebGridNews", id, item.ToOSD()); response = "<h3>News item editted successfully, redirecting to main page</h3>" + "<script language=\"javascript\">" + "setTimeout(function() {window.location.href = \"index.html?page=news_manager\";}, 0);" + "</script>"; return null; } news = connector.GetGeneric<GridNewsItem>(UUID.Zero, "WebGridNews", httpRequest.Query["newsid"].ToString()); vars.Add("NewsTitle", news.Title); vars.Add("NewsText", news.Text); vars.Add("NewsID", news.ID.ToString()); vars.Add("NewsItemTitle", translator.GetTranslatedString("NewsItemTitle")); vars.Add("NewsItemText", translator.GetTranslatedString("NewsItemText")); vars.Add("EditNewsText", translator.GetTranslatedString("EditNewsText")); vars.Add("Submit", translator.GetTranslatedString("Submit")); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); // Tooltips Urls vars.Add("TooltipsWelcomeScreen", translator.GetTranslatedString("TooltipsWelcomeScreen")); vars.Add("TooltipsWorldMap", translator.GetTranslatedString("TooltipsWorldMap")); // Index Page vars.Add("HomeText", translator.GetTranslatedString("HomeText")); vars.Add("HomeTextWelcome", translator.GetTranslatedString("HomeTextWelcome")); vars.Add("HomeTextTips", translator.GetTranslatedString("HomeTextTips")); vars.Add("WelcomeScreen", translator.GetTranslatedString("WelcomeScreen")); vars.Add("WelcomeToText", translator.GetTranslatedString("WelcomeToText")); IGenericsConnector generics = Aurora.DataManager.DataManager.RequestPlugin<IGenericsConnector>(); var settings = generics.GetGeneric<GridSettings>(UUID.Zero, "WebSettings", "Settings"); if (PagesMigrator.RequiresUpdate() && PagesMigrator.CheckWhetherIgnoredVersionUpdate(settings.LastPagesVersionUpdateIgnored)) vars.Add("PagesUpdateRequired", translator.GetTranslatedString("Pages") + " " + translator.GetTranslatedString("DefaultsUpdated")); else vars.Add("PagesUpdateRequired", ""); if (SettingsMigrator.RequiresUpdate() && SettingsMigrator.CheckWhetherIgnoredVersionUpdate(settings.LastSettingsVersionUpdateIgnored)) vars.Add("SettingsUpdateRequired", translator.GetTranslatedString("Settings") + " " + translator.GetTranslatedString("DefaultsUpdated")); else vars.Add("SettingsUpdateRequired", ""); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); if (requestParameters.ContainsKey("ResetMenu")) { PagesMigrator.ResetToDefaults(); response = translator.GetTranslatedString("ChangesSavedSuccessfully"); return null; } if (requestParameters.ContainsKey("ResetSettings")) { SettingsMigrator.ResetToDefaults(); response = translator.GetTranslatedString("ChangesSavedSuccessfully"); return null; } vars.Add("FactoryReset", translator.GetTranslatedString("FactoryReset")); vars.Add("ResetMenuText", translator.GetTranslatedString("ResetMenuText")); vars.Add("ResetSettingsText", translator.GetTranslatedString("ResetSettingsText")); vars.Add("ResetMenuInfoText", translator.GetTranslatedString("ResetMenuText")); vars.Add("ResetSettingsInfoText", translator.GetTranslatedString("ResetSettingsInfoText")); vars.Add("Reset", translator.GetTranslatedString("Reset")); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); if (requestParameters.ContainsKey("Submit")) { string title = requestParameters["NewsTitle"].ToString(); string text = requestParameters["NewsText"].ToString(); IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IGenericsConnector>(); GridNewsItem item = new GridNewsItem { Text = text, Time = DateTime.Now, Title = title }; item.ID = connector.GetGenericCount(UUID.Zero, "WebGridNews") + 1; connector.AddGeneric(UUID.Zero, "WebGridNews", item.ID.ToString(), item.ToOSD()); response = "<h3>News item added successfully, redirecting to main page</h3>" + "<script language=\"javascript\">" + "setTimeout(function() {window.location.href = \"index.html?page=news_manager\";}, 0);" + "</script>"; return null; } vars.Add("NewsItemTitle", translator.GetTranslatedString("NewsItemTitle")); vars.Add("NewsItemText", translator.GetTranslatedString("NewsItemText")); vars.Add("AddNewsText", translator.GetTranslatedString("AddNewsText")); vars.Add("Submit", translator.GetTranslatedString("Submit")); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IGenericsConnector>(); if (httpRequest.Query.Contains("delete")) { string newsID = httpRequest.Query["delete"].ToString(); connector.RemoveGeneric(UUID.Zero, "WebGridNews", newsID); vars["Success"] = "Successfully deleted the news item"; } else vars["Success"] = ""; var newsItems = connector.GetGenerics<GridNewsItem>(UUID.Zero, "WebGridNews"); vars.Add("News", newsItems.ConvertAll<Dictionary<string, object>>(item => item.ToDictionary())); vars.Add("NewsManager", translator.GetTranslatedString("NewsManager")); vars.Add("EditNewsItem", translator.GetTranslatedString("EditNewsItem")); vars.Add("AddNewsItem", translator.GetTranslatedString("AddNewsItem")); vars.Add("DeleteNewsItem", translator.GetTranslatedString("DeleteNewsItem")); vars.Add("NewsTitleText", translator.GetTranslatedString("NewsTitleText")); vars.Add("NewsDateText", translator.GetTranslatedString("NewsDateText")); vars.Add("EditNewsText", translator.GetTranslatedString("EditNewsText")); vars.Add("DeleteNewsText", translator.GetTranslatedString("DeleteNewsText")); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); var regionslist = new List<Dictionary<string, object>>(); uint amountPerQuery = 10; if (requestParameters.ContainsKey("Submit")) { IGridService gridService = webInterface.Registry.RequestModuleInterface<IGridService>(); string regionname = requestParameters["regionname"].ToString(); int start = httpRequest.Query.ContainsKey("Start") ? int.Parse(httpRequest.Query["Start"].ToString()) : 0; uint count = gridService.GetRegionsByNameCount(null, regionname); int maxPages = (int)(count / amountPerQuery) - 1; if (start == -1) start = (int)(maxPages < 0 ? 0 : maxPages); vars.Add("CurrentPage", start); vars.Add("NextOne", start + 1 > maxPages ? start : start + 1); vars.Add("BackOne", start - 1 < 0 ? 0 : start - 1); var regions = gridService.GetRegionsByName(null, regionname, (uint)start, amountPerQuery); if (regions != null) { foreach (var region in regions) { regionslist.Add(new Dictionary<string, object> { { "RegionName", region.RegionName }, { "RegionID", region.RegionID } }); } } } else { vars.Add("CurrentPage", 0); vars.Add("NextOne", 0); vars.Add("BackOne", 0); } vars.Add("RegionsList", regionslist); vars.Add("RegionSearchText", translator.GetTranslatedString("RegionSearchText")); vars.Add("SearchForRegionText", translator.GetTranslatedString("SearchForRegionText")); vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText")); vars.Add("Search", translator.GetTranslatedString("Search")); vars.Add("FirstText", translator.GetTranslatedString("FirstText")); vars.Add("BackText", translator.GetTranslatedString("BackText")); vars.Add("NextText", translator.GetTranslatedString("NextText")); vars.Add("LastText", translator.GetTranslatedString("LastText")); vars.Add("CurrentPageText", translator.GetTranslatedString("CurrentPageText")); vars.Add("SearchResultForRegionText", translator.GetTranslatedString("SearchResultForRegionText")); vars.Add("RegionMoreInfo", translator.GetTranslatedString("RegionMoreInfo")); vars.Add("MoreInfoText", translator.GetTranslatedString("MoreInfoText")); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); vars.Add("ChatText", translator.GetTranslatedString("ChatText")); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator) { var vars = new Dictionary<string, object>(); vars.Add("WebsiteDownInfoText", translator.GetTranslatedString("WebsiteDownInfoText")); vars.Add("WebsiteDownText", translator.GetTranslatedString("WebsiteDownText")); return vars; }
public void Run() { while (m_running) { PollServiceHttpRequest req = m_request.Dequeue(); try { if (req.PollServiceArgs.Valid()) { if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) { StreamReader str; try { str = new StreamReader(req.Request.Body); } catch (ArgumentException) { // Stream was not readable means a child agent // was closed due to logout, leaving the // Event Queue request orphaned. continue; } Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); var request = new OSHttpRequest(req.HttpContext, req.Request); m_server.MessageHandler.SendGenericHTTPResponse( responsedata, request.MakeResponse(System.Net.HttpStatusCode.OK, "OK"), request ); } else { if ((Environment.TickCount - req.RequestTime) > m_timeout) { var request = new OSHttpRequest(req.HttpContext, req.Request); m_server.MessageHandler.SendGenericHTTPResponse( req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), request.MakeResponse(System.Net.HttpStatusCode.OK, "OK"), request); } else { ReQueuePollServiceItem reQueueItem = ReQueue; if (reQueueItem != null) reQueueItem(req); } } } } catch (Exception e) { MainConsole.Instance.ErrorFormat("Exception in poll service thread: " + e); } } }
public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { byte[] data = ReadFully(request); string param = GetParam(path); string responseString = m_method(data, path, param); return Encoding.UTF8.GetBytes(responseString); }
public static bool CheckAdminAuthentication(OSHttpRequest request) { if (request.Cookies["SessionID"] != null) { if (_authenticatedAdminUsers.ContainsKey(UUID.Parse(request.Cookies["SessionID"].Value))) return true; } return false; }
public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { MainConsole.Instance.DebugFormat ("[SIMULATION]: Stream handler called"); Hashtable keysvals = new Hashtable (); Hashtable headervals = new Hashtable (); string[] querystringkeys = httpRequest.QueryString.AllKeys; string[] rHeaders = httpRequest.Headers.AllKeys; keysvals.Add ("uri", httpRequest.RawUrl); keysvals.Add ("content-type", httpRequest.ContentType); keysvals.Add ("http-method", httpRequest.HttpMethod); foreach (string queryname in querystringkeys) keysvals.Add (queryname, httpRequest.QueryString[queryname]); foreach (string headername in rHeaders) headervals[headername] = httpRequest.Headers[headername]; keysvals.Add ("headers", headervals); keysvals.Add ("querystringkeys", querystringkeys); Stream inputStream = httpRequest.ContentType == "application/x-gzip" ? new GZipStream (request, CompressionMode.Decompress) : request; Encoding encoding = Encoding.UTF8; StreamReader reader = new StreamReader (inputStream, encoding); string requestBody = reader.ReadToEnd (); reader.Close (); keysvals.Add ("body", requestBody); httpResponse.StatusCode = 200; httpResponse.ContentType = "text/html"; httpResponse.KeepAlive = false; Hashtable responsedata = new Hashtable (); UUID agentID; UUID regionID; string action; if (!WebUtils.GetParams ((string)keysvals["uri"], out agentID, out regionID, out action)) { MainConsole.Instance.InfoFormat ("[AGENT HANDLER]: Invalid parameters for agent message {0}", keysvals["uri"]); httpResponse.StatusCode = 404; return encoding.GetBytes ("false"); } DoAgentPost (keysvals, responsedata, agentID); httpResponse.StatusCode = (int)responsedata["int_response_code"]; return encoding.GetBytes ((string)responsedata["str_response_string"]); }
public static UserAccount GetAuthentication(OSHttpRequest request) { if (request.Cookies["SessionID"] != null) { UUID sessionID = UUID.Parse(request.Cookies["SessionID"].Value); if (_authenticatedUsers.ContainsKey(sessionID)) return _authenticatedUsers[sessionID]; } return null; }
public static bool CheckAdminAuthentication(OSHttpRequest request, int adminLevelRequired) { if (request.Cookies["SessionID"] != null) { var session = _authenticatedAdminUsers.FirstOrDefault((acc) => acc.Key == UUID.Parse(request.Cookies["SessionID"].Value)); if (session.Value != null && session.Value.UserLevel >= adminLevelRequired) return true; } return false; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); List<Dictionary<string, object>> RegionListVars = new List<Dictionary<string, object>>(); var sortBy = new Dictionary<string, bool>(); if (httpRequest.Query.ContainsKey("region")) sortBy.Add(httpRequest.Query["region"].ToString(), true); else if (httpRequest.Query.ContainsKey("Order")) sortBy.Add(httpRequest.Query["Order"].ToString(), true); uint amountPerQuery = 50; int start = httpRequest.Query.ContainsKey("Start") ? int.Parse(httpRequest.Query["Start"].ToString()) : 0; uint count = DataManager.DataManager.RequestPlugin<IRegionData>().Count((Framework.RegionFlags)0, Framework.RegionFlags.Hyperlink | Framework.RegionFlags.Foreign | Framework.RegionFlags.Hidden); int maxPages = (int)(count / amountPerQuery) - 1; if (start == -1) start = (int)(maxPages < 0 ? 0 : maxPages); vars.Add("CurrentPage", start); vars.Add("NextOne", start + 1 > maxPages ? start : start + 1); vars.Add("BackOne", start - 1 < 0 ? 0 : start - 1); var regions = DataManager.DataManager.RequestPlugin<IRegionData>().Get((Framework.RegionFlags)0, Framework.RegionFlags.Hyperlink | Framework.RegionFlags.Foreign | Framework.RegionFlags.Hidden, (uint)(start * amountPerQuery), amountPerQuery, sortBy); foreach (var region in regions) RegionListVars.Add(new Dictionary<string, object> { { "RegionLocX", region.RegionLocX / Constants.RegionSize }, { "RegionLocY", region.RegionLocY / Constants.RegionSize }, { "RegionName", region.RegionName }, { "RegionID", region.RegionID } }); vars.Add("RegionList", RegionListVars); vars.Add("RegionText", translator.GetTranslatedString("Region")); vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText")); vars.Add("RegionLocXText", translator.GetTranslatedString("RegionLocXText")); vars.Add("RegionLocYText", translator.GetTranslatedString("RegionLocYText")); vars.Add("SortByLocX", translator.GetTranslatedString("SortByLocX")); vars.Add("SortByLocY", translator.GetTranslatedString("SortByLocY")); vars.Add("SortByName", translator.GetTranslatedString("SortByName")); vars.Add("RegionListText", translator.GetTranslatedString("RegionListText")); vars.Add("FirstText", translator.GetTranslatedString("FirstText")); vars.Add("BackText", translator.GetTranslatedString("BackText")); vars.Add("NextText", translator.GetTranslatedString("NextText")); vars.Add("LastText", translator.GetTranslatedString("LastText")); vars.Add("CurrentPageText", translator.GetTranslatedString("CurrentPageText")); vars.Add("MoreInfoText", translator.GetTranslatedString("MoreInfoText")); vars.Add("RegionMoreInfo", translator.GetTranslatedString("RegionMoreInfo")); return vars; }
public static void ChangeAuthentication(OSHttpRequest request, UserAccount account) { if (request.Cookies["SessionID"] != null) { UUID sessionID = UUID.Parse(request.Cookies["SessionID"].Value); if (_authenticatedUsers.ContainsKey(sessionID)) _authenticatedUsers[sessionID] = account; if (_authenticatedAdminUsers.ContainsKey(sessionID)) _authenticatedAdminUsers[sessionID] = account; } }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); //MainConsole.Instance.DebugFormat("[XXX]: query String: {0}", body); try { Dictionary<string, object> request = WebUtils.ParseQueryString(body); if (!request.ContainsKey("METHOD")) return FailureResult(); string method = request["METHOD"].ToString(); IGridRegistrationService urlModule = m_registry.RequestModuleInterface<IGridRegistrationService>(); switch (method) { case "getavatar": if (urlModule != null) if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) return FailureResult(); return GetAvatar(request); case "setavatar": if (urlModule != null) if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) return FailureResult(); return SetAvatar(request); case "resetavatar": if (urlModule != null) if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) return FailureResult(); return ResetAvatar(request); case "cachewearabledata": if (urlModule != null) if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) return FailureResult(); return CacheWearableData(request); } MainConsole.Instance.DebugFormat("[AVATAR HANDLER]: unknown method request: {0}", method); } catch (Exception e) { MainConsole.Instance.Debug("[AVATAR HANDLER]: Exception {0}" + e); } return FailureResult(); }
/// <summary> /// Callback for a viewerstats cap /// </summary> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public byte[] ViewerStatsReport(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { IUserStatsDataConnector dataConnector = Aurora.DataManager.DataManager.RequestPlugin<IUserStatsDataConnector>(); OpenMetaverse.Messages.Linden.ViewerStatsMessage vsm = new OpenMetaverse.Messages.Linden.ViewerStatsMessage(); vsm.Deserialize((OSDMap)OSDParser.DeserializeLLSDXml(request)); dataConnector.UpdateUserStats(vsm, m_service.AgentID, m_service.Region.RegionID); return MainServer.BlankResponse; }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); //MainConsole.Instance.DebugFormat("[XXX]: query String: {0}", body); try { Dictionary<string, object> request = WebUtils.ParseQueryString(body); if (!request.ContainsKey("METHOD")) return FailureResult(); IGridRegistrationService urlModule = m_registry.RequestModuleInterface<IGridRegistrationService>(); string method = request["METHOD"].ToString(); switch (method) { case "AddAbuseReport": if (urlModule != null) if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) return FailureResult(); return AddAbuseReport(request); case "GetAbuseReport": if (urlModule != null) if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) return FailureResult(); return GetAbuseReport(request); case "UpdateAbuseReport": if (urlModule != null) if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) return FailureResult(); return UpdateAbuseReport(request); case "UpdateAbuseReports": if (urlModule != null) if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) return FailureResult(); return GetAbuseReports(request); } MainConsole.Instance.DebugFormat("[ABUSEREPORT HANDLER]: unknown method {0} request {1}", method.Length, method); } catch (Exception e) { MainConsole.Instance.DebugFormat("[ABUSEREPORT HANDLER]: Exception {0}", e); } return FailureResult(); }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); var usersList = new List<Dictionary<string, object>>(); uint amountPerQuery = 10; int start = httpRequest.Query.ContainsKey("Start") ? int.Parse(httpRequest.Query["Start"].ToString()) : 0; uint count = DataManager.DataManager.RequestPlugin<IAgentInfoConnector>().RecentlyOnline(5 * 60, true); int maxPages = (int)(count / amountPerQuery) - 1; if (start == -1) start = (int)(maxPages < 0 ? 0 : maxPages); vars.Add("CurrentPage", start); vars.Add("NextOne", start + 1 > maxPages ? start : start + 1); vars.Add("BackOne", start - 1 < 0 ? 0 : start - 1); var users = DataManager.DataManager.RequestPlugin<IAgentInfoConnector>().RecentlyOnline(5 * 60, true, new Dictionary<string, bool>(), (uint)start, amountPerQuery); IUserAccountService accountService = webInterface.Registry.RequestModuleInterface<IUserAccountService>(); IGridService gridService = webInterface.Registry.RequestModuleInterface<IGridService>(); foreach (var user in users) { var region = gridService.GetRegionByUUID(null, user.CurrentRegionID); var account = accountService.GetUserAccount(region.AllScopeIDs, UUID.Parse(user.UserID)); if (account != null && region != null) usersList.Add(new Dictionary<string, object> { { "UserName", account.Name }, { "UserRegion", region.RegionName }, { "UserID", user.UserID }, { "UserRegionID", region.RegionID } }); } if (requestParameters.ContainsKey("Order")) { if (requestParameters["Order"].ToString() == "RegionName") usersList.Sort((a, b) => a["UserRegion"].ToString().CompareTo(b["UserRegion"].ToString())); if (requestParameters["Order"].ToString() == "UserName") usersList.Sort((a, b) => a["UserName"].ToString().CompareTo(b["UserName"].ToString())); } vars.Add("UsersOnlineList", usersList); vars.Add("OnlineUsersText", translator.GetTranslatedString("OnlineUsersText")); vars.Add("UserNameText", translator.GetTranslatedString("UserNameText")); vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText")); vars.Add("MoreInfoText", translator.GetTranslatedString("MoreInfoText")); vars.Add("FirstText", translator.GetTranslatedString("FirstText")); vars.Add("BackText", translator.GetTranslatedString("BackText")); vars.Add("NextText", translator.GetTranslatedString("NextText")); vars.Add("LastText", translator.GetTranslatedString("LastText")); vars.Add("CurrentPageText", translator.GetTranslatedString("CurrentPageText")); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IGenericsConnector>(); var settings = connector.GetGeneric<GridSettings>(UUID.Zero, "WebSettings", "Settings"); if (requestParameters.ContainsKey("Submit")) { settings.MapCenter.X = int.Parse(requestParameters["GridCenterX"].ToString()); settings.MapCenter.Y = int.Parse(requestParameters["GridCenterY"].ToString()); settings.HideLanguageTranslatorBar = requestParameters["HideLanguageBar"].ToString() == "1"; settings.HideStyleBar = requestParameters["HideStyleBar"].ToString() == "1"; connector.AddGeneric(UUID.Zero, "WebSettings", "Settings", settings.ToOSD()); response = "Successfully updated settings."; return null; } else if (requestParameters.ContainsKey("IgnorePagesUpdates")) { settings.LastPagesVersionUpdateIgnored = PagesMigrator.CurrentVersion; connector.AddGeneric(UUID.Zero, "WebSettings", "Settings", settings.ToOSD()); } else if (requestParameters.ContainsKey("IgnoreSettingsUpdates")) { settings.LastSettingsVersionUpdateIgnored = PagesMigrator.CurrentVersion; connector.AddGeneric(UUID.Zero, "WebSettings", "Settings", settings.ToOSD()); } vars.Add("GridCenterX", settings.MapCenter.X); vars.Add("GridCenterY", settings.MapCenter.Y); vars.Add("HideLanguageBarNo", !settings.HideLanguageTranslatorBar ? "selected=\"selected\"" : ""); vars.Add("HideLanguageBarYes", settings.HideLanguageTranslatorBar ? "selected=\"selected\"" : ""); vars.Add("HideStyleBarNo", !settings.HideStyleBar ? "selected=\"selected\"" : ""); vars.Add("HideStyleBarYes", settings.HideStyleBar ? "selected=\"selected\"" : ""); vars.Add("IgnorePagesUpdates", PagesMigrator.CheckWhetherIgnoredVersionUpdate(settings.LastPagesVersionUpdateIgnored) ? "" : "checked"); vars.Add("IgnoreSettingsUpdates", settings.LastSettingsVersionUpdateIgnored != SettingsMigrator.CurrentVersion ? "" : "checked"); vars.Add("SettingsManager", translator.GetTranslatedString("SettingsManager")); vars.Add("IgnorePagesUpdatesText", translator.GetTranslatedString("IgnorePagesUpdatesText")); vars.Add("IgnoreSettingsUpdatesText", translator.GetTranslatedString("IgnoreSettingsUpdatesText")); vars.Add("GridCenterXText", translator.GetTranslatedString("GridCenterXText")); vars.Add("GridCenterYText", translator.GetTranslatedString("GridCenterYText")); vars.Add("HideLanguageBarText", translator.GetTranslatedString("HideLanguageBarText")); vars.Add("HideStyleBarText", translator.GetTranslatedString("HideStyleBarText")); vars.Add("Save", translator.GetTranslatedString("Save")); vars.Add("No", translator.GetTranslatedString("No")); vars.Add("Yes", translator.GetTranslatedString("Yes")); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); vars.Add("Logout", translator.GetTranslatedString("Logout")); vars.Add("LoggedOutSuccessfullyText", translator.GetTranslatedString("LoggedOutSuccessfullyText")); Authenticator.RemoveAuthentication(httpRequest); return vars; }
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary<string, object>(); IMapService mapService = webInterface.Registry.RequestModuleInterface<IMapService>(); vars.Add("WorldMapServiceURL", mapService.MapServiceURL.Remove(mapService.MapServiceURL.Length - 1)); vars.Add("WorldMapAPIServiceURL", mapService.MapServiceAPIURL.Remove(mapService.MapServiceAPIURL.Length - 1)); return vars; }
/// <summary> /// This methods is the start of incoming HTTP request handling. /// </summary> /// <param name="context"></param> public virtual void HandleRequest(HttpListenerContext context) { HttpListenerRequest request = context.Request; using (HttpListenerResponse response = context.Response) { OSHttpRequest req = new OSHttpRequest(context); OSHttpResponse resp = new OSHttpResponse(context); if (request.HttpMethod == String.Empty) // Can't handle empty requests, not wasting a thread { byte[] buffer = GetHTML500(response); response.ContentLength64 = buffer.LongLength; response.Close(buffer, true); return; } response.KeepAlive = false; string requestMethod = request.HttpMethod; string uriString = request.RawUrl; int requestStartTick = Environment.TickCount; // Will be adjusted later on. int requestEndTick = requestStartTick; IStreamedRequestHandler requestHandler = null; try { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US", true); string path = request.RawUrl; string handlerKey = GetHandlerKey(request.HttpMethod, path); byte[] buffer = null; if ((request.ContentType == "application/xml" || request.ContentType == "text/xml") && GetXmlRPCHandler(request.RawUrl) != null) { buffer = HandleXmlRpcRequests(req, resp); } else if (TryGetStreamHandler(handlerKey, out requestHandler)) { response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. buffer = requestHandler.Handle(path, request.InputStream, req, resp); } request.InputStream.Close(); try { if (buffer != null) { if (request.ProtocolVersion.Minor == 0) { //HTTP 1.0... no chunking response.ContentLength64 = buffer.Length; using (Stream stream = response.OutputStream) { HttpServerHandlerHelpers.WriteNonChunked(stream, buffer); } } else { response.SendChunked = true; using (Stream stream = response.OutputStream) { HttpServerHandlerHelpers.WriteChunked(stream, buffer); } } //response.ContentLength64 = buffer.LongLength; response.Close(); } else { response.Close(new byte[0], true); } } catch (Exception ex) { if (!(ex is HttpListenerException) || !HttpListenerManager.IGNORE_ERROR_CODES.Contains(((HttpListenerException)ex).ErrorCode)) { MainConsole.Instance.WarnFormat( "[BASE HTTP SERVER]: HandleRequest failed to write all data to the stream: {0}", ex.ToString()); } response.Abort(); } requestEndTick = Environment.TickCount; } catch (Exception e) { MainConsole.Instance.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.ToString()); response.Abort(); } finally { // Every month or so this will wrap and give bad numbers, not really a problem // since its just for reporting int tickdiff = requestEndTick - requestStartTick; if (tickdiff > 3000 && requestHandler != null) { MainConsole.Instance.InfoFormat( "[BASE HTTP SERVER]: Slow handling of {0} {1} took {2}ms", requestMethod, uriString, tickdiff); } else if (MainConsole.Instance.IsTraceEnabled) { MainConsole.Instance.TraceFormat( "[BASE HTTP SERVER]: Handling {0} {1} took {2}ms", requestMethod, uriString, tickdiff); } } } }
/// <summary> /// Try all the registered xmlrpc handlers when an xmlrpc request is received. /// Sends back an XMLRPC unknown request response if no handler is registered for the requested method. /// </summary> /// <param name="request"></param> /// <param name="response"></param> private byte[] HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response) { string requestBody = HttpServerHandlerHelpers.ReadString(request.InputStream); requestBody = requestBody.Replace("<base64></base64>", ""); string responseString = String.Empty; XmlRpcRequest xmlRprcRequest = null; try { xmlRprcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); } catch (XmlException e) { MainConsole.Instance.WarnFormat( "[BASE HTTP SERVER]: Got XMLRPC request with invalid XML from {0}. XML was '{1}'. Sending blank response. Exception: {2}", request.RemoteIPEndPoint, requestBody, e.ToString()); } if (xmlRprcRequest != null) { string methodName = xmlRprcRequest.MethodName; if (methodName != null) { xmlRprcRequest.Params.Add(request.RemoteIPEndPoint); // Param[1] XmlRpcResponse xmlRpcResponse; XmlRpcMethod method; bool methodWasFound; lock (m_rpcHandlers) methodWasFound = m_rpcHandlers.TryGetValue(methodName, out method); if (methodWasFound) { xmlRprcRequest.Params.Add(request.Url); // Param[2] string xff = "X-Forwarded-For"; string xfflower = xff.ToLower(); foreach (string s in request.Headers.AllKeys) { if (s != null && s.Equals(xfflower)) { xff = xfflower; break; } } xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3] try { xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint); } catch (Exception e) { string errorMessage = String.Format( "Requested method [{0}] from {1} threw exception: {2} {3}", methodName, request.RemoteIPEndPoint.Address, e.Message, e.StackTrace); MainConsole.Instance.ErrorFormat("[BASE HTTP SERVER]: {0}", errorMessage); // if the registered XmlRpc method threw an exception, we pass a fault-code along xmlRpcResponse = new XmlRpcResponse(); // Code probably set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php xmlRpcResponse.SetFault(-32603, errorMessage); } } else { xmlRpcResponse = new XmlRpcResponse(); // Code set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php xmlRpcResponse.SetFault( XmlRpcErrorCodes.SERVER_ERROR_METHOD, String.Format("Requested method [{0}] not found", methodName)); } response.ContentType = "text/xml"; responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse); } else { //HandleLLSDRequests(request, response); response.ContentType = "text/plain"; response.StatusCode = 404; response.StatusDescription = "Not Found"; responseString = "Not found"; MainConsole.Instance.ErrorFormat( "[BASE HTTP SERVER]: Handler not found for http request {0} {1}", request.HttpMethod, request.Url.PathAndQuery); } } byte[] buffer = Encoding.UTF8.GetBytes(responseString); response.SendChunked = false; response.ContentEncoding = Encoding.UTF8; return(buffer); }