Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 private byte[] OKResponse(OSHttpResponse httpResponse)
 {
     httpResponse.AddHeader("X-Handlers-Provided", m_HandlersType);
     httpResponse.StatusCode = (int) HttpStatusCode.OK;
     httpResponse.StatusDescription = "OK";
     return MainServer.BlankResponse;
 }
Exemplo n.º 3
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>();

            // 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;
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
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>();
            
            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;
        }
Exemplo n.º 6
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>();
            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;
        }
Exemplo n.º 7
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>();
     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;
 }
Exemplo n.º 8
0
        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 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];
        }
Exemplo n.º 10
0
        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;
        }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
0
        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;
        }
Exemplo n.º 13
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>();
            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;
        }
Exemplo n.º 14
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>();
            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;
        }
Exemplo n.º 15
0
        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;
        }
Exemplo n.º 16
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>();
			vars.Add("ChatText", translator.GetTranslatedString("ChatText"));
			return vars;
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        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"]);
        }
Exemplo n.º 19
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>();

            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 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();
        }
Exemplo n.º 21
0
        /// <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;
        }
Exemplo n.º 22
0
        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();
        }
Exemplo n.º 23
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>();
            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;
        }
Exemplo n.º 24
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>();
            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;
        }
Exemplo n.º 25
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>();

            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;
        }
Exemplo n.º 26
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>();
			
			vars.Add("Logout", translator.GetTranslatedString("Logout"));
            vars.Add("LoggedOutSuccessfullyText", translator.GetTranslatedString("LoggedOutSuccessfullyText"));
			
            Authenticator.RemoveAuthentication(httpRequest);
			
            return vars;
        }
        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();

            // We need to check the authorization header
            //httpRequest.Headers["authorization"] ...

            //MainConsole.Instance.DebugFormat("[XXX]: query String: {0}", body);
            string method = string.Empty;
            try
            {
                Dictionary<string, object> request =
                    WebUtils.ParseQueryString(body);

                if (!request.ContainsKey("METHOD"))
                    return FailureResult();

                method = request["METHOD"].ToString();
                IGridRegistrationService urlModule =
                    m_registry.RequestModuleInterface<IGridRegistrationService>();
                switch (method)
                {
                    case "getaccount":
                        if (urlModule != null)
                            if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.None))
                                return new byte[0];
                        return GetAccount(request);
                    case "getaccounts":
                        if (urlModule != null)
                            if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.None))
                                return new byte[0];
                        return GetAccounts(request);
                    case "setaccount":
                        if (urlModule != null)
                            if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Full))
                                return new byte[0];
                        return StoreAccount(request);
                }
                MainConsole.Instance.DebugFormat("[USER SERVICE HANDLER]: unknown method request: {0}", method);
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat("[USER SERVICE HANDLER]: Exception in method {0}: {1}", method, e);
            }

            return FailureResult();
        }
Exemplo n.º 28
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>();
            IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin<IGenericsConnector>();

            if (requestParameters.ContainsKey("Submit"))
            {
                GridWelcomeScreen submittedInfo = new GridWelcomeScreen();
                submittedInfo.SpecialWindowMessageTitle = requestParameters["SpecialWindowTitle"].ToString();
                submittedInfo.SpecialWindowMessageText = requestParameters["SpecialWindowText"].ToString();
                submittedInfo.SpecialWindowMessageColor = requestParameters["SpecialWindowColor"].ToString();
                submittedInfo.SpecialWindowActive = requestParameters["SpecialWindowStatus"].ToString() == "1";
                submittedInfo.GridStatus = requestParameters["GridStatus"].ToString() == "1";

                connector.AddGeneric(UUID.Zero, "GridWelcomeScreen", "GridWelcomeScreen", submittedInfo.ToOSD());

                response = "Successfully saved data";
                return null;
            }

            GridWelcomeScreen welcomeInfo = connector.GetGeneric<GridWelcomeScreen>(UUID.Zero, "GridWelcomeScreen", "GridWelcomeScreen");
            if (welcomeInfo == null)
                welcomeInfo = GridWelcomeScreen.Default;
            vars.Add("OpenNewsManager", translator.GetTranslatedString("OpenNewsManager"));
            vars.Add("SpecialWindowTitleText", translator.GetTranslatedString("SpecialWindowTitleText"));
            vars.Add("SpecialWindowTextText", translator.GetTranslatedString("SpecialWindowTextText"));
            vars.Add("SpecialWindowColorText", translator.GetTranslatedString("SpecialWindowColorText"));
            vars.Add("SpecialWindowStatusText", translator.GetTranslatedString("SpecialWindowStatusText"));
            vars.Add("WelcomeScreenManagerFor", translator.GetTranslatedString("WelcomeScreenManagerFor"));
            vars.Add("GridStatus", translator.GetTranslatedString("GridStatus"));
            vars.Add("Online", translator.GetTranslatedString("Online"));
            vars.Add("Offline", translator.GetTranslatedString("Offline"));
            vars.Add("Enabled", translator.GetTranslatedString("Enabled"));
            vars.Add("Disabled", translator.GetTranslatedString("Disabled"));

            vars.Add("SpecialWindowTitle", welcomeInfo.SpecialWindowMessageTitle);
            vars.Add("SpecialWindowMessage", welcomeInfo.SpecialWindowMessageText);
            vars.Add("SpecialWindowActive", welcomeInfo.SpecialWindowActive ? "selected" : "");
            vars.Add("SpecialWindowInactive", welcomeInfo.SpecialWindowActive ? "" : "selected");
            vars.Add("GridActive", welcomeInfo.GridStatus ? "selected" : "");
            vars.Add("GridInactive", welcomeInfo.GridStatus ? "" : "selected");
            vars.Add("SpecialWindowColorRed", welcomeInfo.SpecialWindowMessageColor == "red" ? "selected" : "");
            vars.Add("SpecialWindowColorYellow", welcomeInfo.SpecialWindowMessageColor == "yellow" ? "selected" : "");
            vars.Add("SpecialWindowColorGreen", welcomeInfo.SpecialWindowMessageColor == "green" ? "selected" : "");
            vars.Add("SpecialWindowColorWhite", welcomeInfo.SpecialWindowMessageColor == "white" ? "selected" : "");
            vars.Add("Submit", translator.GetTranslatedString("Submit"));

            return vars;
        }
Exemplo n.º 29
0
        public byte[] GroupMemberData(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            try
            {
                //MainConsole.Instance.Debug("[CAPS]: UploadBakedTexture Request in region: " +
                //        m_regionName);

                OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml(request);
                UUID groupID = rm["group_id"].AsUUID();

                OSDMap defaults = new OSDMap();
                ulong EveryonePowers = (ulong)(GroupPowers.AllowSetHome |
                                                           GroupPowers.Accountable |
                                                           GroupPowers.JoinChat |
                                                           GroupPowers.AllowVoiceChat |
                                                           GroupPowers.ReceiveNotices |
                                                           GroupPowers.StartProposal |
                                                           GroupPowers.VoteOnProposal);
                defaults["default_powers"] = EveryonePowers;

                List<string> titles = new List<string>();
                OSDMap members = new OSDMap();
                int count = 0;
                foreach (GroupMembersData gmd in m_groupService.GetGroupMembers(m_service.AgentID, groupID))
                {
                    OSDMap member = new OSDMap();
                    member["donated_square_meters"] = gmd.Contribution;
                    member["owner"] = (gmd.IsOwner ? "Y" : "N");
                    member["last_login"] = gmd.OnlineStatus;
                    member["title"] = count;
                    member["powers"] = gmd.AgentPowers;
                    titles.Add(gmd.Title);
                    count++;
                }
                
                OSDMap map = new OSDMap();
                map["member_count"] = count;
                map["group_id"] = groupID;
                map["defaults"] = defaults;
                map["titles"] = titles.ToOSDArray();
                map["members"] = members;
                return OSDParser.SerializeLLSDXmlBytes(map);
            }
            catch (Exception e)
            {
                MainConsole.Instance.Error("[CAPS]: " + e);
            }

            return null;
        }
Exemplo n.º 30
0
        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("ColorBoxImageText", translator.GetTranslatedString("ColorBoxImageText"));
			vars.Add("ColorBoxOfText", translator.GetTranslatedString("ColorBoxOfText"));
			vars.Add("ColorBoxPreviousText", translator.GetTranslatedString("ColorBoxPreviousText"));
			vars.Add("ColorBoxNextText", translator.GetTranslatedString("ColorBoxNextText"));
			vars.Add("ColorBoxCloseText", translator.GetTranslatedString("ColorBoxCloseText"));
			vars.Add("ColorBoxStartSlideshowText", translator.GetTranslatedString("ColorBoxStartSlideshowText"));
			vars.Add("ColorBoxStopSlideshowText", translator.GetTranslatedString("ColorBoxStopSlideshowText"));

            return vars;
        }
Exemplo n.º 31
0
        /// <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);
                    }
                }
            }
        }
Exemplo n.º 32
0
        /// <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);
        }