Esempio n. 1
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("DisplayLG1", "display: none;");
            vars.Add("DisplayLG2", "display: none;");
            vars.Add("DisplayLG3", "display: none;");
            vars.Add("DisplayLG4", "display: none;");
            vars.Add("DisplayLG5", "display: none;");
            if (translator.LanguageName == "en")
                vars["DisplayLG1"] = "";
            if (translator.LanguageName == "fr")
                vars["DisplayLG2"] = "";
            if (translator.LanguageName == "de")
                vars["DisplayLG3"] = "";
            if (translator.LanguageName == "it")
                vars["DisplayLG4"] = "";
            if (translator.LanguageName == "es")
                vars["DisplayLG5"] = "";

            return vars;
        }
Esempio n. 2
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 = Framework.Utilities.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;
        }
Esempio 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>();
     IGenericsConnector connector = Framework.Utilities.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;
 }
Esempio n. 4
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;
        }
        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 = Framework.Utilities.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 = Framework.Utilities.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;
        }
Esempio 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>();

            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;
        }
Esempio n. 7
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;
                    if (titles.Contains(gmd.Title))
                    {
                        member["title"] = titles.FindIndex((s) => s == gmd.Title);
                    }
                    else
                    {
                        titles.Add(gmd.Title);
                        member["title"] = titles.Count-1;
                    }
                    member["powers"] = gmd.AgentPowers;
                    count++;
                    members[gmd.AgentID.ToString()] = member;
                }

                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;
        }
Esempio n. 8
0
 public static bool CheckAuthentication(OSHttpRequest request)
 {
     if (request.Cookies["SessionID"] != null)
     {
         if (_authenticatedUsers.ContainsKey(UUID.Parse(request.Cookies["SessionID"].Value)))
             return true;
     }
     return false;
 }
Esempio n. 9
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 = Framework.Utilities.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;
        }
Esempio n. 10
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("ForgotPassword", translator.GetTranslatedString("ForgotPassword"));
     return vars;
 }
Esempio n. 11
0
 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;
 }
Esempio n. 12
0
 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;
     }
 }
Esempio 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>();
     vars.Add("Error505Text", translator.GetTranslatedString("Error505Text"));
     vars.Add("Error505InfoText", translator.GetTranslatedString("Error505InfoText"));
     vars.Add("HomePage505Text", translator.GetTranslatedString("HomePage505Text"));
     return vars;
 }
Esempio n. 14
0
 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;
 }
Esempio n. 15
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 = Framework.Utilities.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;
        }
Esempio n. 16
0
        /// <summary>
        ///     Callback for a viewerstats cap
        /// </summary>
        /// <param name="request"></param>
        /// <param name="path"></param>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <returns></returns>
        public byte[] ViewerStatsReport(string path, Stream request, OSHttpRequest httpRequest,
                                        OSHttpResponse httpResponse)
        {
            IUserStatsDataConnector dataConnector =
                Framework.Utilities.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;
        }
Esempio n. 17
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;
        }
Esempio n. 18
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>();

            string error = "";
            if (requestParameters.ContainsKey("username") && requestParameters.ContainsKey("password"))
            {
                string username = requestParameters["username"].ToString();
                string password = requestParameters["password"].ToString();

                ILoginService loginService = webInterface.Registry.RequestModuleInterface<ILoginService>();
                if (loginService.VerifyClient(UUID.Zero, username, "UserAccount", password))
                {
                    UUID sessionID = UUID.Random();
                    UserAccount account =
                        webInterface.Registry.RequestModuleInterface<IUserAccountService>()
                                    .GetUserAccount(null, username);
                    Authenticator.AddAuthentication(sessionID, account);
                    if (account.UserLevel > 0)
                        Authenticator.AddAdminAuthentication(sessionID, account);
                    httpResponse.AddCookie(new System.Web.HttpCookie("SessionID", sessionID.ToString())
                                               {
                                                   Expires =
                                                       DateTime
                                                       .MinValue,
                                                   Path = ""
                                               });

                    response = "<h3>Successfully logged in, redirecting to main page</h3>" +
                               "<script language=\"javascript\">" +
                               "setTimeout(function() {window.location.href = \"index.html\";}, 0);" +
                               "</script>";
                }
                else
                    response = "<h3>Failed to verify user name and password</h3>";
                return null;
            }

            vars.Add("ErrorMessage", error);
            vars.Add("Login", translator.GetTranslatedString("Login"));
            vars.Add("UserNameText", translator.GetTranslatedString("UserName"));
            vars.Add("PasswordText", translator.GetTranslatedString("Password"));
            vars.Add("ForgotPassword", translator.GetTranslatedString("ForgotPassword"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));

            return vars;
        }
        public byte[] ChatSessionRequest(string path, Stream request, OSHttpRequest httpRequest,
                                         OSHttpResponse httpResponse)
        {
            try
            {
                OSDMap rm = (OSDMap) OSDParser.DeserializeLLSDXml(request);

                return Encoding.UTF8.GetBytes(m_imService.ChatSessionRequest(m_service, rm));
            }
            catch (Exception e)
            {
                MainConsole.Instance.Error("[IMCAPS]: " + e.ToString());
            }

            return null;
        }
Esempio n. 20
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>();

            IAgentInfoConnector users = Framework.Utilities.DataManager.RequestPlugin<IAgentInfoConnector>();
            IGenericsConnector connector = Framework.Utilities.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", Framework.Utilities.DataManager.RequestPlugin<IRegionData>().
                                                Count((RegionFlags) 0, (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;
        }
Esempio n. 21
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("WorldMap", translator.GetTranslatedString("WorldMap"));

            IGenericsConnector connector = Framework.Utilities.DataManager.RequestPlugin<IGenericsConnector>();
            var settings = connector.GetGeneric<GridSettings>(UUID.Zero, "WebSettings", "Settings");

            vars.Add("GridCenterX", settings.MapCenter.X);
            vars.Add("GridCenterY", settings.MapCenter.Y);

            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("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;
        }
Esempio 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>();

            IGridServerInfoService infoService = webInterface.Registry.RequestModuleInterface<IGridServerInfoService>();

            string mapService = infoService.GetGridURI("MapService");
            string mapAPIService = infoService.GetGridURI("MapAPIService");

            vars.Add("WorldMapServiceURL", mapService.Remove(mapService.Length - 1));
            vars.Add("WorldMapAPIServiceURL", mapAPIService.Remove(mapAPIService.Length - 1));

            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("Sun", translator.GetTranslatedString("Sun"));
     vars.Add("Mon", translator.GetTranslatedString("Mon"));
     vars.Add("Tue", translator.GetTranslatedString("Tue"));
     vars.Add("Wed", translator.GetTranslatedString("Wed"));
     vars.Add("Thu", translator.GetTranslatedString("Thu"));
     vars.Add("Fri", translator.GetTranslatedString("Fri"));
     vars.Add("Sat", translator.GetTranslatedString("Sat"));
     vars.Add("Sunday", translator.GetTranslatedString("Sunday"));
     vars.Add("Monday", translator.GetTranslatedString("Monday"));
     vars.Add("Tuesday", translator.GetTranslatedString("Tuesday"));
     vars.Add("Wednesday", translator.GetTranslatedString("Wednesday"));
     vars.Add("Thursday", translator.GetTranslatedString("Thursday"));
     vars.Add("Friday", translator.GetTranslatedString("Friday"));
     vars.Add("Saturday", translator.GetTranslatedString("Saturday"));
     vars.Add("Jan", translator.GetTranslatedString("Jan"));
     vars.Add("Feb", translator.GetTranslatedString("Feb"));
     vars.Add("Mar", translator.GetTranslatedString("Mar"));
     vars.Add("Apr", translator.GetTranslatedString("Apr"));
     vars.Add("May", translator.GetTranslatedString("May"));
     vars.Add("Jun", translator.GetTranslatedString("Jun"));
     vars.Add("Jul", translator.GetTranslatedString("Jul"));
     vars.Add("Aug", translator.GetTranslatedString("Aug"));
     vars.Add("Sep", translator.GetTranslatedString("Sep"));
     vars.Add("Oct", translator.GetTranslatedString("Oct"));
     vars.Add("Nov", translator.GetTranslatedString("Nov"));
     vars.Add("Dec", translator.GetTranslatedString("Dec"));
     vars.Add("January", translator.GetTranslatedString("January"));
     vars.Add("February", translator.GetTranslatedString("February"));
     vars.Add("March", translator.GetTranslatedString("March"));
     vars.Add("April", translator.GetTranslatedString("April"));
     vars.Add("June", translator.GetTranslatedString("June"));
     vars.Add("July", translator.GetTranslatedString("July"));
     vars.Add("August", translator.GetTranslatedString("August"));
     vars.Add("September", translator.GetTranslatedString("September"));
     vars.Add("October", translator.GetTranslatedString("October"));
     vars.Add("November", translator.GetTranslatedString("November"));
     vars.Add("December", translator.GetTranslatedString("December"));
     return vars;
 }
Esempio 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>();
            vars.Add("HelpText", translator.GetTranslatedString("HelpText"));
            vars.Add("HelpViewersConfigText", translator.GetTranslatedString("HelpViewersConfigText"));
            vars.Add("AngstormViewer", translator.GetTranslatedString("AngstormViewer"));
            vars.Add("VoodooViewer", translator.GetTranslatedString("VoodooViewer"));
            vars.Add("AstraViewer", translator.GetTranslatedString("AstraViewer"));
            vars.Add("ImprudenceViewer", translator.GetTranslatedString("ImprudenceViewer"));
            vars.Add("PhoenixViewer", translator.GetTranslatedString("PhoenixViewer"));
            vars.Add("SingularityViewer", translator.GetTranslatedString("SingularityViewer"));
            vars.Add("ZenViewer", translator.GetTranslatedString("ZenViewer"));

            return vars;
        }
Esempio 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>();

            IGenericsConnector connector = Framework.Utilities.DataManager.RequestPlugin<IGenericsConnector>();
            GridWelcomeScreen welcomeInfo = connector.GetGeneric<GridWelcomeScreen>(UUID.Zero, "GridWelcomeScreen",
                                                                                    "GridWelcomeScreen");
            if (welcomeInfo == null)
                welcomeInfo = GridWelcomeScreen.Default;

            vars.Add("Title", welcomeInfo.SpecialWindowMessageTitle);
            vars.Add("Text", welcomeInfo.SpecialWindowMessageText);
            vars.Add("Color", welcomeInfo.SpecialWindowMessageColor);
            vars.Add("Active", welcomeInfo.SpecialWindowActive);
            return vars;
        }
Esempio n. 27
0
        public byte[] OnHTTPGetTextureImage(string path, Stream request, OSHttpRequest httpRequest,
            OSHttpResponse httpResponse)
        {
            byte[] jpeg = new byte[0];
            IAssetService m_AssetService = _registry.RequestModuleInterface<IAssetService>();

            using (MemoryStream imgstream = new MemoryStream())
            {
                // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular jpeg data

                // non-async because we know we have the asset immediately.
                byte[] mapasset = m_AssetService.GetData(httpRequest.QueryString["uuid"]);

                if (mapasset != null)
                {
                    // Decode image to System.Drawing.Image
                    Image image = null;
                    ManagedImage managedImage;
                    if (OpenJPEG.DecodeToImage(mapasset, out managedImage, out image))
                    {
                        // Save to bitmap
                        using (Bitmap texture = ResizeBitmap(image, 256, 256))
                        {
                            EncoderParameters myEncoderParameters = new EncoderParameters();
                            myEncoderParameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality,
                                                                                75L);

                            // Save bitmap to stream
                            texture.Save(imgstream, GetEncoderInfo("image/jpeg"), myEncoderParameters);

                            // Write the stream to a byte array for output
                            jpeg = imgstream.ToArray();
                        }
                        image.Dispose();
                    }
                }
            }

            httpResponse.ContentType = "image/jpeg";

            return jpeg;
        }
        public byte[] GetBakedTexture(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            string[] req = path.Split('/');
            UUID avID = UUID.Parse(req[2]);
            string type = req[3];
            UUID textureID = UUID.Parse(req[4]);

            //IAvatarService avService = m_registry.RequestModuleInterface<IAvatarService>();
            //Aurora.Framework.ClientInterfaces.AvatarAppearance appearance = avService.GetAppearance(avID);
            //AvatarTextureIndex textureIndex = AppearanceManager.BakeTypeToAgentTextureIndex((BakeType)Enum.Parse(typeof(BakeType), type, true));
            //AssetBase texture = m_assetService.Get(appearance.Texture.FaceTextures[(int)textureIndex].TextureID.ToString());
            AssetBase texture = m_assetService.Get(textureID.ToString());
            if (texture == null)
            {
                return new byte[0];
            }
            // Full content request
            httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
            httpResponse.ContentType = texture.TypeString;
            return texture.Data;
        }
Esempio n. 29
0
        private byte[] MeshUploadFlagCAP(string path, Stream request,
            OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            OSDMap data = new OSDMap();
            IUserProfileInfo info = m_profileConnector.GetUserProfile(m_service.AgentID);

            data["id"] = m_service.AgentID;
            data["username"] = m_service.ClientCaps.AccountInfo.Name;
            data["display_name"] = info.DisplayName;
            data["display_name_next_update"] = Utils.UnixTimeToDateTime(0);
            data["legacy_first_name"] = m_service.ClientCaps.AccountInfo.FirstName;
            data["legacy_last_name"] = m_service.ClientCaps.AccountInfo.LastName;
            data["mesh_upload_status"] = "valid"; // add if account has ability to upload mesh?
            bool isDisplayNameNDefault = (info.DisplayName == m_service.ClientCaps.AccountInfo.Name) ||
                                         (info.DisplayName ==
                                          m_service.ClientCaps.AccountInfo.FirstName + "." +
                                          m_service.ClientCaps.AccountInfo.LastName);
            data["is_display_name_default"] = isDisplayNameNDefault;

            //Send back data
            return OSDParser.SerializeLLSDXmlBytes(data);
        }
Esempio n. 30
0
        public byte[] ParcelVoiceInfoRequest(string path, Stream request, OSHttpRequest httpRequest,
            OSHttpResponse httpResponse)
        {
            // - check whether we have a region channel in our cache
            // - if not:
            //       create it and cache it
            // - send it to the client
            // - send channel_uri: as "sip:regionID@m_sipDomain"
            try
            {
                string channel_uri;
                int localID;

                m_voiceModule.ParcelVoiceRequest(m_service, out channel_uri, out localID);

                // fill in our response to the client
                OSDMap map = new OSDMap();
                map["region_name"] = m_service.Region.RegionName;
                map["parcel_local_id"] = localID;
                map["voice_credentials"] = new OSDMap();
                ((OSDMap) map["voice_credentials"])["channel_uri"] = channel_uri;

                MainConsole.Instance.DebugFormat(
                    "[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel ({1}): avatar \"{2}\"",
                    m_service.Region.RegionName, localID, m_service.ClientCaps.AccountInfo.Name);
                return OSDParser.SerializeLLSDXmlBytes(map);
            }
            catch (Exception e)
            {
                MainConsole.Instance.ErrorFormat(
                    "[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later",
                    m_service.Region.RegionName, m_service.ClientCaps.AccountInfo.Name, e.Message);
                MainConsole.Instance.DebugFormat(
                    "[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed",
                    m_service.Region.RegionName, m_service.ClientCaps.AccountInfo.Name, e.ToString());

                return Encoding.UTF8.GetBytes("<llsd><undef /></llsd>");
            }
        }
Esempio n. 31
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 = Framework.Utilities.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);
        }
Esempio n. 32
0
        /// <summary>
        ///     Get the user's display name, currently not used?
        /// </summary>
        /// <param name="path"></param>
        /// <param name="request"></param>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <returns></returns>
        private byte[] ProcessGetDisplayName(string path, Stream request, OSHttpRequest httpRequest,
                                             OSHttpResponse httpResponse)
        {
            //I've never seen this come in, so for now... do nothing
            NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);

            string[] ids      = query.GetValues("ids");
            string   username = query.GetOne("username");

            OSDMap   map           = new OSDMap();
            OSDArray agents        = new OSDArray();
            OSDArray bad_ids       = new OSDArray();
            OSDArray bad_usernames = new OSDArray();

            if (ids != null)
            {
                foreach (string id in ids)
                {
                    UserAccount account = m_userService.GetUserAccount(m_service.ClientCaps.AccountInfo.AllScopeIDs,
                                                                       UUID.Parse(id));
                    if (account != null)
                    {
                        IUserProfileInfo info =
                            Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>()
                            .GetUserProfile(account.PrincipalID);
                        if (info != null)
                        {
                            PackUserInfo(info, account, ref agents);
                        }
                        else
                        {
                            PackUserInfo(info, account, ref agents);
                        }
                        //else //Technically is right, but needs to be packed no matter what for OS based grids
                        //    bad_ids.Add (id);
                    }
                }
            }
            else if (username != null)
            {
                UserAccount account = m_userService.GetUserAccount(m_service.ClientCaps.AccountInfo.AllScopeIDs,
                                                                   username.Replace('.', ' '));
                if (account != null)
                {
                    IUserProfileInfo info =
                        Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>()
                        .GetUserProfile(account.PrincipalID);
                    if (info != null)
                    {
                        PackUserInfo(info, account, ref agents);
                    }
                    else
                    {
                        bad_usernames.Add(username);
                    }
                }
            }

            map["agents"]        = agents;
            map["bad_ids"]       = bad_ids;
            map["bad_usernames"] = bad_usernames;

            return(OSDParser.SerializeLLSDXmlBytes(map));
        }
Esempio n. 33
0
        /// <summary>
        /// </summary>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <param name="textureID"></param>
        /// <param name="format"></param>
        /// <param name="response"></param>
        /// <returns>False for "caller try another codec"; true otherwise</returns>
        private bool FetchTexture(OSHttpRequest httpRequest, OSHttpResponse httpResponse, UUID textureID, string format,
                                  out byte[] response)
        {
            //MainConsole.Instance.DebugFormat("[GET TEXTURE]: {0} with requested format {1}", textureID, format);
            AssetBase texture;

            string fullID = textureID.ToString();

            if (format != DefaultFormat)
            {
                fullID = fullID + "-" + format;
            }

            if (!String.IsNullOrEmpty(REDIRECT_URL))
            {
                // Only try to fetch locally cached textures. Misses are redirected
                texture = m_assetService.GetCached(fullID);

                if (texture != null)
                {
                    if (texture.Type != (sbyte)AssetType.Texture &&         // not actually a texture, but appears to be valid
                        texture.Type != (sbyte)AssetType.Unknown &&
                        texture.Type != (sbyte)AssetType.Simstate)
                    {
                        httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
                        response = MainServer.BlankResponse;
                        return(true);
                    }

                    response = WriteTextureData(httpRequest, httpResponse, texture, format);
                    return(true);
                }
                else
                {
                    string textureUrl = REDIRECT_URL + textureID;
                    MainConsole.Instance.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl);
                    httpResponse.RedirectLocation = textureUrl;
                    response = MainServer.BlankResponse;
                    return(true);
                }
            }

            // no redirect
            // try the cache
            texture = m_assetService.GetCached(fullID);

            if (texture == null)
            {
                //MainConsole.Instance.DebugFormat("[GET TEXTURE]: texture was not in the cache");

                // Fetch locally or remotely. Misses return a 404
                texture = m_assetService.Get(textureID.ToString());

                if (texture != null)
                {
                    if (texture.Type != (sbyte)AssetType.Texture &&
                        texture.Type != (sbyte)AssetType.Unknown &&
                        texture.Type != (sbyte)AssetType.Simstate)
                    {
                        httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
                        response = MainServer.BlankResponse;
                        return(true);
                    }

                    if (format == DefaultFormat)
                    {
                        response = WriteTextureData(httpRequest, httpResponse, texture, format);
                        return(true);
                    }

                    AssetBase newTexture = new AssetBase(texture.ID + "-" + format, texture.Name, AssetType.Texture,
                                                         texture.CreatorID)
                    {
                        Data = ConvertTextureData(texture, format)
                    };

                    if (newTexture.Data.Length == 0)            // Unable to convert
                    {
                        response = MainServer.BlankResponse;
                        return(false);                        // Caller try another codec, please!
                    }

                    newTexture.Flags = AssetFlags.Collectable | AssetFlags.Temporary;
                    newTexture.ID    = m_assetService.Store(newTexture);
                    response         = WriteTextureData(httpRequest, httpResponse, newTexture, format);
                    return(true);
                }

                // Nothing found so replace with the 'missing_texture" texture
                // Try the cache first
                texture = m_assetService.GetCached(MISSING_TEXTURE_ID);

                if (texture == null)
                {
                    texture = m_assetService.Get(MISSING_TEXTURE_ID);                                   // Not in local cache...
                }
                if (texture != null)
                {
                    if (format == DefaultFormat)
                    {
                        MainConsole.Instance.Debug("[GET TEXTURE]: Texture " + textureID + " replaced with default 'missing' texture");
                        response = WriteTextureData(httpRequest, httpResponse, texture, format);
                        return(true);
                    }
                }

                // Texture not found and we have no 'missing texture', or if all else fails...
                MainConsole.Instance.Warn("[GETTEXTURE]: Texture " + textureID + " not found (no default)");
                httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
                response = MainServer.BlankResponse;
                return(true);
            }

            // Found the texture in th cache
            if (texture.Type != (sbyte)AssetType.Texture &&
                texture.Type != (sbyte)AssetType.Unknown &&
                texture.Type != (sbyte)AssetType.Simstate)
            {
                httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
                response = MainServer.BlankResponse;
                return(true);
            }

            //MainConsole.Instance.DebugFormat("[GET TEXTURE]: texture was in the cache");
            response = WriteTextureData(httpRequest, httpResponse, texture, format);
            return(true);
        }
Esempio n. 34
0
        public byte[] ProcessGetMesh(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            httpResponse.ContentType = "text/plain";

            string meshStr = string.Empty;


            if (httpRequest.QueryString["mesh_id"] != null)
            {
                meshStr = httpRequest.QueryString["mesh_id"];
            }


            UUID meshID = UUID.Zero;

            if (!String.IsNullOrEmpty(meshStr) && UUID.TryParse(meshStr, out meshID))
            {
                if (m_assetService == null)
                {
                    return(Encoding.UTF8.GetBytes("The asset service is unavailable.  So is your mesh."));
                }

                // Only try to fetch locally cached textures. Misses are redirected
                AssetBase mesh = m_assetService.GetCached(meshID.ToString());
                if (mesh != null)
                {
                    if (mesh.Type == (SByte)AssetType.Mesh)
                    {
                        httpResponse.StatusCode  = 200;
                        httpResponse.ContentType = "application/vnd.ll.mesh";
                        return(mesh.Data);
                    }

                    // Optionally add additional mesh types here
                    httpResponse.StatusCode  = 404; //501; //410; //404;
                    httpResponse.ContentType = "text/plain";
                    return(Encoding.UTF8.GetBytes("Unfortunately, this asset isn't a mesh."));
                }

                // not in the cache
                mesh = m_assetService.GetMesh(meshID.ToString());
                if (mesh != null)
                {
                    if (mesh.Type == (SByte)AssetType.Mesh)
                    {
                        httpResponse.StatusCode  = 200;
                        httpResponse.ContentType = "application/vnd.ll.mesh";
                        return(mesh.Data);
                    }

                    // Optionally add additional mesh types here
                    httpResponse.StatusCode  = 404; //501; //410; //404;
                    httpResponse.ContentType = "text/plain";
                    return(Encoding.UTF8.GetBytes("Unfortunately, this asset isn't a mesh."));
                }

                // not found
                httpResponse.StatusCode  = 404; //501; //410; //404;
                httpResponse.ContentType = "text/plain";
                return(Encoding.UTF8.GetBytes("Your Mesh wasn't found.  Sorry!"));
            }

            // null or not a UUID
            httpResponse.StatusCode = 404;
            return(Encoding.UTF8.GetBytes("Invalid mesh"));
        }
Esempio n. 35
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);
        }
Esempio n. 36
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);
        }
Esempio n. 37
0
        private void WriteTextureData(OSHttpRequest request, OSHttpResponse response, AssetBase texture, string format)
        {
            m_service.Registry.RequestModuleInterface <ISimulationBase>().EventManager.FireGenericEventHandler(
                "AssetRequested", new object[] { m_service.Registry, texture, m_service.AgentID });

            string range = request.Headers.GetOne("Range");

            //MainConsole.Instance.DebugFormat("[GETTEXTURE]: Range {0}", range);
            if (!String.IsNullOrEmpty(range)) // JP2's only
            {
                // Range request
                int start, end;
                if (TryParseRange(range, out start, out end))
                {
                    // Before clamping start make sure we can satisfy it in order to avoid
                    // sending back the last byte instead of an error status
                    if (start >= texture.Data.Length)
                    {
                        response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable;
                    }
                    else
                    {
                        end   = Utils.Clamp(end, 0, texture.Data.Length - 1);
                        start = Utils.Clamp(start, 0, end);
                        int len = end - start + 1;

                        //MainConsole.Instance.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);

                        if (len < texture.Data.Length)
                        {
                            response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent;
                        }
                        else
                        {
                            response.StatusCode = (int)System.Net.HttpStatusCode.OK;
                        }

                        response.ContentLength = len;
                        response.ContentType   = texture.TypeString;
                        response.AddHeader("Content-Range", String.Format("bytes {0}-{1}/{2}", start, end, texture.Data.Length));

                        response.Body.Write(texture.Data, start, len);
                    }
                }
                else
                {
                    MainConsole.Instance.Warn("[GETTEXTURE]: Malformed Range header: " + range);
                    response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                }
            }
            else // JP2's or other formats
            {
                // Full content request
                response.StatusCode    = (int)System.Net.HttpStatusCode.OK;
                response.ContentLength = texture.Data.Length;
                response.ContentType   = texture.TypeString;
                if (format == DefaultFormat)
                {
                    response.ContentType = texture.TypeString;
                }
                else
                {
                    response.ContentType = "image/" + format;
                }
                response.Body.Write(texture.Data, 0, texture.Data.Length);
            }
        }
Esempio n. 38
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>();

            string      username = filename.Split('/').LastOrDefault();
            UserAccount account  = null;

            if (httpRequest.Query.ContainsKey("userid"))
            {
                string userid = httpRequest.Query["userid"].ToString();

                account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().
                          GetUserAccount(null, UUID.Parse(userid));
            }
            else if (httpRequest.Query.ContainsKey("name"))
            {
                string name = httpRequest.Query.ContainsKey("name") ? httpRequest.Query["name"].ToString() : username;
                name    = name.Replace('.', ' ');
                name    = name.Replace("%20", " ");
                account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().
                          GetUserAccount(null, name);
            }
            else
            {
                username = username.Replace("%20", " ");
                webInterface.Redirect(httpResponse, "/webprofile/?name=" + username);
                return(vars);
            }

            if (account == null)
            {
                return(vars);
            }

            vars.Add("UserName", account.Name);
            vars.Add("UserBorn", Util.ToDateTime(account.Created).ToShortDateString());

            IUserProfileInfo profile = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>().
                                       GetUserProfile(account.PrincipalID);

            vars.Add("UserType", profile.MembershipGroup == "" ? "Resident" : profile.MembershipGroup);
            if (profile != null)
            {
                if (profile.Partner != UUID.Zero)
                {
                    account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().
                              GetUserAccount(null, profile.Partner);
                    vars.Add("UserPartner", account.Name);
                }
                else
                {
                    vars.Add("UserPartner", "No partner");
                }
                vars.Add("UserAboutMe", profile.AboutText == "" ? "Nothing here" : profile.AboutText);
                string url = "../images/icons/no_picture.jpg";
                IWebHttpTextureService webhttpService =
                    webInterface.Registry.RequestModuleInterface <IWebHttpTextureService>();
                if (webhttpService != null && profile.Image != UUID.Zero)
                {
                    url = webhttpService.GetTextureURL(profile.Image);
                }
                vars.Add("UserPictureURL", url);
            }
            UserAccount ourAccount = Authenticator.GetAuthentication(httpRequest);

            if (ourAccount != null)
            {
                IFriendsService friendsService = webInterface.Registry.RequestModuleInterface <IFriendsService>();
                var             friends        = friendsService.GetFriends(account.PrincipalID);
                UUID            friendID       = UUID.Zero;
                if (friends.Any(f => UUID.TryParse(f.Friend, out friendID) && friendID == ourAccount.PrincipalID))
                {
                    IAgentInfoService agentInfoService =
                        webInterface.Registry.RequestModuleInterface <IAgentInfoService>();
                    IGridService gridService = webInterface.Registry.RequestModuleInterface <IGridService>();
                    UserInfo     ourInfo     = agentInfoService.GetUserInfo(account.PrincipalID.ToString());
                    if (ourInfo != null && ourInfo.IsOnline)
                    {
                        vars.Add("OnlineLocation", gridService.GetRegionByUUID(null, ourInfo.CurrentRegionID).RegionName);
                    }
                    vars.Add("UserIsOnline", ourInfo != null && ourInfo.IsOnline);
                    vars.Add("IsOnline",
                             ourInfo != null && ourInfo.IsOnline
                                 ? translator.GetTranslatedString("Online")
                                 : translator.GetTranslatedString("Offline"));
                }
                else
                {
                    vars.Add("OnlineLocation", "");
                    vars.Add("UserIsOnline", false);
                    vars.Add("IsOnline", translator.GetTranslatedString("Offline"));
                }
            }
            else
            {
                vars.Add("OnlineLocation", "");
                vars.Add("UserIsOnline", false);
                vars.Add("IsOnline", translator.GetTranslatedString("Offline"));
            }

            // Menu Profile
            vars.Add("MenuProfileTitle", translator.GetTranslatedString("MenuProfileTitle"));
            vars.Add("MenuGroupTitle", translator.GetTranslatedString("MenuGroupTitle"));
            vars.Add("MenuPicksTitle", translator.GetTranslatedString("MenuPicksTitle"));

            vars.Add("UserProfileFor", translator.GetTranslatedString("UserProfileFor"));
            vars.Add("ResidentSince", translator.GetTranslatedString("ResidentSince"));
            vars.Add("AccountType", translator.GetTranslatedString("AccountType"));
            vars.Add("PartnersName", translator.GetTranslatedString("PartnersName"));
            vars.Add("AboutMe", translator.GetTranslatedString("AboutMe"));
            vars.Add("IsOnlineText", translator.GetTranslatedString("IsOnlineText"));
            vars.Add("OnlineLocationText", translator.GetTranslatedString("OnlineLocationText"));

            // 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"));

            IGenericsConnector generics = Framework.Utilities.DataManager.RequestPlugin <IGenericsConnector>();
            var settings = generics.GetGeneric <GridSettings>(UUID.Zero, "WebSettings", "Settings");

            vars.Add("ShowLanguageTranslatorBar", !settings.HideLanguageTranslatorBar);
            vars.Add("ShowStyleBar", !settings.HideStyleBar);

            return(vars);
        }
 public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest,
                               OSHttpResponse httpResponse)
 {
     return(_method(path, request, httpRequest, httpResponse));
 }
Esempio n. 40
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("WorldMap", translator.GetTranslatedString("WorldMap"));

            IGenericsConnector connector = Aurora.DataManager.DataManager.RequestPlugin <IGenericsConnector>();
            var settings = connector.GetGeneric <GridSettings>(UUID.Zero, "WebSettings", "Settings");

            vars.Add("GridCenterX", settings.MapCenter.X);
            vars.Add("GridCenterY", settings.MapCenter.Y);

            return(vars);
        }
Esempio n. 41
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 = "Menu: " + translator.GetTranslatedString("ChangesSavedSuccessfully");
                return(null);
            }
            if (requestParameters.ContainsKey("ResetSettings"))
            {
                SettingsMigrator.ResetToDefaults(webInterface);
                response = "WebUI: " + 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);
        }
Esempio n. 42
0
        protected virtual byte[] processGridInstantMessage(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            GridInstantMessage gim = ProtoBuf.Serializer.Deserialize <GridInstantMessage>(request);

            // Trigger the Instant message in the scene.
            IScenePresence user;
            bool           successful = false;

            foreach (IScene scene in m_scenes)
            {
                if (scene.TryGetScenePresence(gim.ToAgentID, out user))
                {
                    if (!user.IsChildAgent)
                    {
                        scene.EventManager.TriggerIncomingInstantMessage(gim);
                        successful = true;
                        break;
                    }
                }
            }

            //Send response back to region calling if it was successful
            // calling region uses this to know when to look up a user's location again.
            return(new byte[1] {
                successful ? (byte)1 : (byte)0
            });
        }
Esempio n. 43
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;
            IConfig gridInfo        = webInterface.Registry.RequestModuleInterface <ISimulationBase>().ConfigSource.Configs ["GridInfoService"];
            var     InWorldCurrency = gridInfo.GetString("CurrencySymbol", String.Empty) + " ";
            var     RealCurrency    = gridInfo.GetString("RealCurrencySymbol", String.Empty) + " ";

            var vars          = new Dictionary <string, object>();
            var purchasesList = new List <Dictionary <string, object> >();

            uint   amountPerQuery = 25;
            var    today          = DateTime.Now;
            var    thirtyDays     = today.AddDays(-7);
            string DateStart      = thirtyDays.ToShortDateString();
            string DateEnd        = today.ToShortDateString();
            UUID   UserID         = UUID.Zero;
            int    start          = 0;


            IMoneyModule moneyModule = webInterface.Registry.RequestModuleInterface <IMoneyModule>();
            string       noDetails   = translator.GetTranslatedString("NoPurchasesText");

            // Check if we're looking at the standard page or the submitted one
            if (requestParameters.ContainsKey("Submit"))
            {
                if (requestParameters.ContainsKey("date_start"))
                {
                    DateStart = requestParameters ["date_start"].ToString();
                }
                if (requestParameters.ContainsKey("date_end"))
                {
                    DateEnd = requestParameters ["date_end"].ToString();
                }

                // pagination
                start = httpRequest.Query.ContainsKey("Start")
                    ? int.Parse(httpRequest.Query ["Start"].ToString())
                    : 0;
                int count    = (int)moneyModule.NumberOfPurchases(UserID);
                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);
            }
            else
            {
                vars.Add("CurrentPage", 0);
                vars.Add("NextOne", 0);
                vars.Add("BackOne", 0);
            }

            UserAccount user = Authenticator.GetAuthentication(httpRequest);

            // Purchases Logs
            var      timeNow  = DateTime.Now.ToString("HH:mm:ss");
            var      dateFrom = DateTime.Parse(DateStart + " " + timeNow);
            var      dateTo   = DateTime.Parse(DateEnd + " " + timeNow);
            TimeSpan period   = dateTo.Subtract(dateFrom);

            List <AgentPurchase> purchases;

            purchases = moneyModule.GetPurchaseHistory(user.PrincipalID, dateFrom, dateTo, (uint)start, amountPerQuery);

            // data
            if (purchases.Count > 0)
            {
                noDetails = "";

                foreach (var purchase in purchases)
                {
                    purchasesList.Add(new Dictionary <string, object> {
                        { "ID", purchase.ID },
                        { "AgentID", purchase.AgentID },
                        { "AgentName", user.Name },
                        { "LoggedIP", purchase.IP },
                        { "Description", "Purchase" },
                        { "Amount", purchase.Amount },
                        { "RealAmount", ((float)purchase.RealAmount / 100).ToString("0.00") },
                        { "PurchaseDate", Culture.LocaleDate(purchase.PurchaseDate.ToLocalTime(), "MMM dd, hh:mm:ss tt") },
                        { "UpdateDate", Culture.LocaleDate(purchase.UpdateDate.ToLocalTime(), "MMM dd, hh:mm:ss tt") }
                    });
                }
            }

            if (purchasesList.Count == 0)
            {
                purchasesList.Add(new Dictionary <string, object> {
                    { "ID", "" },
                    { "AgentID", "" },
                    { "AgentName", "" },
                    { "LoggedIP", "" },
                    { "Description", translator.GetTranslatedString("NoPurchasesText") },
                    { "Amount", "" },
                    { "RealAmount", "" },
                    { "PurchaseDate", "" },
                    { "UpdateDate", "" },
                });
            }

            // always required data
            vars.Add("DateStart", DateStart);
            vars.Add("DateEnd", DateEnd);
            vars.Add("Period", period.TotalDays + " " + translator.GetTranslatedString("DaysText"));
            vars.Add("PurchasesList", purchasesList);
            vars.Add("NoPurchasesText", noDetails);

            // labels
            vars.Add("PurchasesText", translator.GetTranslatedString("PurchasesText"));
            vars.Add("DateInfoText", translator.GetTranslatedString("DateInfoText"));
            vars.Add("DateStartText", translator.GetTranslatedString("DateStartText"));
            vars.Add("DateEndText", translator.GetTranslatedString("DateEndText"));
            vars.Add("SearchUserText", translator.GetTranslatedString("AvatarNameText"));

            vars.Add("PurchaseAgentText", translator.GetTranslatedString("TransactionToAgentText"));
            vars.Add("PurchaseDateText", translator.GetTranslatedString("TransactionDateText"));
            vars.Add("PurchaseUpdateDateText", translator.GetTranslatedString("TransactionDateText"));
            //vars.Add("PurchaseTimeText", translator.GetTranslatedString("Time"));
            vars.Add("PurchaseDetailText", translator.GetTranslatedString("TransactionDetailText"));
            vars.Add("LoggedIPText", translator.GetTranslatedString("LoggedIPText"));
            vars.Add("PurchaseAmountText", InWorldCurrency + translator.GetTranslatedString("TransactionAmountText"));
            vars.Add("PurchaseRealAmountText", RealCurrency + translator.GetTranslatedString("PurchaseCostText"));

            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);
        }
Esempio n. 44
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();

            // 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());
        }
Esempio n. 45
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            UserAccount  ourAccount     = Authenticator.GetAuthentication(httpRequest);
            IMoneyModule moneyModule    = webInterface.Registry.RequestModuleInterface <IMoneyModule> ();
            var          currencySymbol = "$";

            if (moneyModule != null)
            {
                currencySymbol = moneyModule.InWorldCurrencySymbol;
            }

            response = null;
            var vars     = new Dictionary <string, object> ();
            var duration = 10;

            if (requestParameters.ContainsKey("Submit"))
            {
                string eventName        = requestParameters ["eventName"].ToString();
                string eventDate        = requestParameters ["eventDate"].ToString();
                string eventTime        = requestParameters ["eventTime"].ToString();
                string eventDuration    = requestParameters ["eventDuration"].ToString();
                string eventLocation    = requestParameters ["eventLocation"].ToString();
                string eventCategory    = requestParameters ["eventCategory"].ToString();
                string eventCoverCharge = requestParameters ["eventCoverCharge"].ToString();
                string eventDescription = requestParameters ["eventDescription"].ToString();

                var directoryService = Framework.Utilities.DataManager.RequestPlugin <IDirectoryServiceConnector> ();
                var regionData       = Framework.Utilities.DataManager.RequestPlugin <IRegionData> ();

                var selParcel = eventLocation.Split(',');
                // Format: parcelLocationX, parcelLocationY, parcelLandingX, parcelLandingY, parcelLandingZ, parcelUUID
                // "1020,995,128,28,25,d436261b-7186-42a6-dcd3-b80c1bcafaa4"

                Framework.Services.GridRegion region = null;
                var parcel = directoryService.GetParcelInfo((UUID)selParcel [5]);
                if (parcel != null)
                {
                    region = regionData.Get(parcel.RegionID, null);
                }
                if (region == null)
                {
                    var error = "Parcel details not found!";
                    vars.Add("ErrorMessage", "<h3>" + error + "</h3>");
                    response = "<h3>" + error + "</h3>";
                    return(null);
                }

                // we have details...
                var eventDT  = DateTime.Parse(eventDate + " " + eventTime);
                var localPos = new Vector3(int.Parse(selParcel [0]), int.Parse(selParcel [0]), 0);

                var nEvent = directoryService.CreateEvent(
                    ourAccount.PrincipalID,
                    region.RegionID,
                    (UUID)selParcel [5],
                    eventDT,
                    uint.Parse(eventCoverCharge),
                    (DirectoryManager.EventFlags)Util.ConvertAccessLevelToMaturity(region.Access),
                    region.Access,
                    uint.Parse(eventDuration),
                    localPos,
                    eventName,
                    eventDescription,
                    eventCategory
                    );

                if (nEvent != null)
                {
                    response = "<h3>Event added successfully, redirecting to main page</h3>" +
                               "<script language=\"javascript\">" +
                               "setTimeout(function() {window.location.href = \"/?page=events\";}, 0);" +
                               "</script>";
                }

                return(null);
            }

            // Time selections
            var nearestHalf = Utilities.RoundUp(DateTime.Now, TimeSpan.FromMinutes(30)).ToString("HH\\:mm\\:ss");

            vars.Add("EventDate", DateTime.Now.AddDays(1).ToShortDateString());
            vars.Add("EventTimes", WebHelpers.EventTimeSelections(nearestHalf));

            // event durations
            vars.Add("EventDurations", WebHelpers.EventDurationSelections(duration));

            // event locations
            vars.Add("EventLocations", WebHelpers.EventLocations(ourAccount, webInterface.Registry, ""));

            vars.Add("EventCategories", WebHelpers.EventCategorySelections(-1, translator));
            vars.Add("EventCoverCharge", "0");

            // labels
            vars.Add("AddEventText", translator.GetTranslatedString("AddEventText"));
            vars.Add("EventNameText", translator.GetTranslatedString("EventNameText"));
            vars.Add("EventDateText", translator.GetTranslatedString("EventDateText"));
            vars.Add("EventTimeText", translator.GetTranslatedString("TimeText"));
            vars.Add("EventTimeInfoText", translator.GetTranslatedString("EventTimeInfoText"));
            vars.Add("EventDurationText", translator.GetTranslatedString("DurationText"));
            vars.Add("EventLocationText", translator.GetTranslatedString("EventLocationText"));
            vars.Add("EventCategoryText", translator.GetTranslatedString("CategoryText"));
            vars.Add("EventCoverChargeText", translator.GetTranslatedString("CoverChargeText") + " " + currencySymbol);
            vars.Add("EventDescriptionText", translator.GetTranslatedString("DescriptionText"));


            vars.Add("ErrorMessage", "");
            vars.Add("Submit", translator.GetTranslatedString("AddEventText"));

            return(vars);
        }
Esempio n. 46
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 (httpRequest.Query.ContainsKey("regionid"))
            {
                GridRegion region = webInterface.Registry.RequestModuleInterface<IGridService>().GetRegionByUUID(null,
                                                                                                                 UUID
                                                                                                                     .Parse
                                                                                                                     (httpRequest
                                                                                                                          .Query
                                                                                                                          [
                                                                                                                              "regionid"
                                                                                                                          ]
                                                                                                                          .ToString
                                                                                                                          ()));

                IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin<IEstateConnector>();
                EstateSettings estate = estateConnector.GetEstateSettings(region.RegionID);

                vars.Add("RegionName", region.RegionName);
                vars.Add("OwnerUUID", estate.EstateOwner);
                var estateOwnerAccount = webInterface.Registry.RequestModuleInterface<IUserAccountService>().
                                                      GetUserAccount(null, estate.EstateOwner);
                vars.Add("OwnerName", estateOwnerAccount == null ? "No account found" : estateOwnerAccount.Name);
                vars.Add("RegionLocX", region.RegionLocX/Constants.RegionSize);
                vars.Add("RegionLocY", region.RegionLocY/Constants.RegionSize);
                vars.Add("RegionSizeX", region.RegionSizeX);
                vars.Add("RegionSizeY", region.RegionSizeY);
                vars.Add("RegionType", region.RegionType);
                vars.Add("RegionOnline",
                         (region.Flags & (int) RegionFlags.RegionOnline) ==
                         (int) RegionFlags.RegionOnline
                             ? translator.GetTranslatedString("Online")
                             : translator.GetTranslatedString("Offline"));

                IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface<IAgentInfoService>();
                IUserAccountService userService = webInterface.Registry.RequestModuleInterface<IUserAccountService>();
                if (agentInfoService != null)
                {
                    List<UserInfo> usersInRegion = agentInfoService.GetUserInfos(region.RegionID);
                    vars.Add("NumberOfUsersInRegion", usersInRegion.Count);
                    List<Dictionary<string, object>> users = new List<Dictionary<string, object>>();
                    foreach (var client in usersInRegion)
                    {
                        UserAccount account = userService.GetUserAccount(null, client.UserID);
                        if (account == null)
                            continue;
                        Dictionary<string, object> user = new Dictionary<string, object>();
                        user.Add("UserNameText", translator.GetTranslatedString("UserNameText"));
                        user.Add("UserUUID", client.UserID);
                        user.Add("UserName", account.Name);
                        users.Add(user);
                    }
                    vars.Add("UsersInRegion", users);
                }
                else
                {
                    vars.Add("NumberOfUsersInRegion", 0);
                    vars.Add("UsersInRegion", new List<Dictionary<string, object>>());
                }
                IDirectoryServiceConnector directoryConnector =
                    Framework.Utilities.DataManager.RequestPlugin<IDirectoryServiceConnector>();
                if (directoryConnector != null)
                {
                    List<LandData> data = directoryConnector.GetParcelsByRegion(0, 10, region.RegionID, UUID.Zero,
                                                                                ParcelFlags.None, ParcelCategory.Any);
                    List<Dictionary<string, object>> parcels = new List<Dictionary<string, object>>();
                    foreach (var p in data)
                    {
                        Dictionary<string, object> parcel = new Dictionary<string, object>();
                        parcel.Add("ParcelNameText", translator.GetTranslatedString("ParcelNameText"));
                        parcel.Add("ParcelOwnerText", translator.GetTranslatedString("ParcelOwnerText"));
                        parcel.Add("ParcelUUID", p.GlobalID);
                        parcel.Add("ParcelName", p.Name);
                        parcel.Add("ParcelOwnerUUID", p.OwnerID);
                        IUserAccountService accountService =
                            webInterface.Registry.RequestModuleInterface<IUserAccountService>();
                        if (accountService != null)
                        {
                            var account = accountService.GetUserAccount(null, p.OwnerID);
                            if (account == null)
                                parcel.Add("ParcelOwnerName", translator.GetTranslatedString("NoAccountFound"));
                            else
                                parcel.Add("ParcelOwnerName", account.Name);
                        }
                        parcels.Add(parcel);
                    }
                    vars.Add("ParcelInRegion", parcels);
                    vars.Add("NumberOfParcelsInRegion", parcels.Count);
                }
                IWebHttpTextureService webTextureService = webInterface.Registry.
                                                                        RequestModuleInterface<IWebHttpTextureService>();
                if (webTextureService != null && region.TerrainMapImage != UUID.Zero)
                    vars.Add("RegionImageURL", webTextureService.GetTextureURL(region.TerrainMapImage));
                else
                    vars.Add("RegionImageURL", "images/icons/no_picture.jpg");

                // Menu Region
                vars.Add("MenuRegionTitle", translator.GetTranslatedString("MenuRegionTitle"));
                vars.Add("MenuParcelTitle", translator.GetTranslatedString("MenuParcelTitle"));
                vars.Add("MenuOwnerTitle", translator.GetTranslatedString("MenuOwnerTitle"));

                vars.Add("RegionInformationText", translator.GetTranslatedString("RegionInformationText"));
                vars.Add("OwnerNameText", translator.GetTranslatedString("OwnerNameText"));
                vars.Add("RegionLocationText", translator.GetTranslatedString("RegionLocationText"));
                vars.Add("RegionSizeText", translator.GetTranslatedString("RegionSizeText"));
                vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText"));
                vars.Add("RegionTypeText", translator.GetTranslatedString("RegionTypeText"));
                vars.Add("RegionInfoText", translator.GetTranslatedString("RegionInfoText"));
                vars.Add("RegionOnlineText", translator.GetTranslatedString("RegionOnlineText"));
                vars.Add("NumberOfUsersInRegionText", translator.GetTranslatedString("NumberOfUsersInRegionText"));
                vars.Add("ParcelsInRegionText", translator.GetTranslatedString("ParcelsInRegionText"));

                // 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;
        }
        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("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);
        }
Esempio n. 48
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> ();

            string error = "";

            if (requestParameters.ContainsKey("Submit"))
            {
                string username  = requestParameters ["username"].ToString();
                string UserEmail = requestParameters ["UserEmail"].ToString();

                UserAccount userAcct =
                    webInterface.Registry.RequestModuleInterface <IUserAccountService> ()
                    .GetUserAccount(null, username);

                if (!userAcct.Valid)
                {
                    response = "<h3>Please enter a valid username</h3>";
                    return(null);
                }

                // email user etc here...
                if (userAcct.Email == "")
                {
                    response = "<h3>Sorry! Your account has no email details. Please contact the administrator to correct</h3>" +
                               "<script language=\"javascript\">" +
                               "setTimeout(function() {window.location.href = \"index.html\";}, 5000);" +
                               "</script>";

                    return(null);
                }

                var emailAddress = userAcct.Email;
                if (UserEmail != emailAddress)
                {
                    response = "<h3>Sorry! Unable to authenticate your account. Please contact the administrator to correct</h3>" +
                               "<script language=\"javascript\">" +
                               "setTimeout(function() {window.location.href = \"index.html\";}, 5000);" +
                               "</script>";

                    return(null);
                }

                IEmailModule Email = webInterface.Registry.RequestModuleInterface <IEmailModule> ();
                if ((Email != null) && (!Email.LocalOnly()))
                {
                    var  newPassword = Utilities.RandomPassword.Generate(2, 1, 0);
                    var  authService = webInterface.Registry.RequestModuleInterface <IAuthenticationService> ();
                    var  gridName    = webInterface.Registry.RequestModuleInterface <IGridInfo> ().GridName;
                    bool success     = false;

                    if (authService != null)
                    {
                        success = authService.SetPassword(userAcct.PrincipalID, "UserAccount", newPassword);
                    }

                    if (success)
                    {
                        Email.SendEmail(
                            UUID.Zero,
                            emailAddress,
                            "Password reset request",
                            string.Format("This request was made via the {0} WebUi at {1}\n\nYour new passsword is : {2}",
                                          gridName, Culture.LocaleTimeDate(), newPassword),
                            null);

                        response = "<h3>An email has been sent with your new password</h3>Redirecting to main page";
                    }
                    else
                    {
                        response = "<h3>Sorry! Your password was not able to be reset.<h3>Please contact the administrator directly<br>Redirecting to main page</h3>";
                    }
                }
                else
                {
                    response = "<h3>The email functions are local to the grid or have not yet been set up<h3>Please contact the administrator directly<br>Redirecting to main page</h3>";
                }


                response = response +
                           "<script language=\"javascript\">" +
                           "setTimeout(function() {window.location.href = \"index.html\";}, 5000);" +
                           "</script>";

                return(null);
            }


            vars.Add("ErrorMessage", error);
            vars.Add("ForgotPassword", translator.GetTranslatedString("ForgotPassword"));
            vars.Add("UserNameText", translator.GetTranslatedString("UserName"));
            vars.Add("UserEmailText", translator.GetTranslatedString("UserEmailText"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));

            return(vars);
        }
Esempio n. 49
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          = Framework.Utilities.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 = Framework.Utilities.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);
        }
Esempio n. 50
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="httpRequest"></param>
        /// <param name="httpResponse"></param>
        /// <param name="textureID"></param>
        /// <param name="format"></param>
        /// <returns>False for "caller try another codec"; true otherwise</returns>
        private bool FetchTexture(OSHttpRequest httpRequest, OSHttpResponse httpResponse, UUID textureID, string format)
        {
            MainConsole.Instance.DebugFormat("[GETTEXTURE]: {0} with requested format {1}", textureID, format);
            AssetBase texture;

            string fullID = textureID.ToString();

            if (format != DefaultFormat)
            {
                fullID = fullID + "-" + format;
            }

            if (!String.IsNullOrEmpty(REDIRECT_URL))
            {
                // Only try to fetch locally cached textures. Misses are redirected
                texture = m_assetService.GetCached(fullID);

                if (texture != null)
                {
                    if (texture.Type != (sbyte)AssetType.Texture && texture.Type != (sbyte)AssetType.Unknown && texture.Type != (sbyte)AssetType.Simstate)
                    {
                        httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
                        return(true);
                    }
                    WriteTextureData(httpRequest, httpResponse, texture, format);
                }
                else
                {
                    string textureUrl = REDIRECT_URL + textureID.ToString();
                    MainConsole.Instance.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl);
                    httpResponse.RedirectLocation = textureUrl;
                    return(true);
                }
            }
            else // no redirect
            {
                // try the cache
                texture = m_assetService.GetCached(fullID);

                if (texture == null)
                {
                    //MainConsole.Instance.DebugFormat("[GETTEXTURE]: texture was not in the cache");

                    // Fetch locally or remotely. Misses return a 404
                    texture = m_assetService.Get(textureID.ToString());

                    if (texture != null)
                    {
                        if (texture.Type != (sbyte)AssetType.Texture && texture.Type != (sbyte)AssetType.Unknown && texture.Type != (sbyte)AssetType.Simstate)
                        {
                            httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
                            return(true);
                        }
                        if (format == DefaultFormat)
                        {
                            WriteTextureData(httpRequest, httpResponse, texture, format);
                            texture = null;
                            return(true);
                        }
                        AssetBase newTexture = new AssetBase(texture.ID + "-" + format, texture.Name, AssetType.Texture,
                                                             texture.CreatorID)
                        {
                            Data = ConvertTextureData(texture, format)
                        };
                        if (newTexture.Data.Length == 0)
                        {
                            return(false); // !!! Caller try another codec, please!
                        }
                        newTexture.Flags = AssetFlags.Collectable | AssetFlags.Temporary;
                        newTexture.ID    = m_assetService.Store(newTexture);
                        WriteTextureData(httpRequest, httpResponse, newTexture, format);
                        newTexture = null;
                        return(true);
                    }
                }
                else // it was on the cache
                {
                    if (texture.Type != (sbyte)AssetType.Texture && texture.Type != (sbyte)AssetType.Unknown && texture.Type != (sbyte)AssetType.Simstate)
                    {
                        httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
                        return(true);
                    }
                    //MainConsole.Instance.DebugFormat("[GETTEXTURE]: texture was in the cache");
                    WriteTextureData(httpRequest, httpResponse, texture, format);
                    texture = null;
                    return(true);
                }
            }

            // not found
            MainConsole.Instance.Warn("[GETTEXTURE]: Texture " + textureID + " not found");
            httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
            return(true);
        }
Esempio n. 51
0
        public override byte[] Handle(string path, Stream request,
                                      OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            byte[] result = new byte[0];

            string[] p = SplitParams(path);

            if (p.Length == 0)
            {
                return(result);
            }

            IGridRegistrationService urlModule =
                m_registry.RequestModuleInterface <IGridRegistrationService>();

            if (urlModule != null)
            {
                if (!urlModule.CheckThreatLevel("", m_regionHandle, "Asset_Get", ThreatLevel.Low))
                {
                    return(new byte[0]);
                }
            }
            if (p.Length > 1 && p[1] == "data")
            {
                result = m_AssetService.GetData(p[0]);
                if (result == null)
                {
                    httpResponse.StatusCode  = (int)HttpStatusCode.NotFound;
                    httpResponse.ContentType = "text/plain";
                    result = new byte[0];
                }
                else
                {
                    httpResponse.StatusCode  = (int)HttpStatusCode.OK;
                    httpResponse.ContentType = "application/octet-stream";
                }
            }
            else if (p.Length > 1 && p[1] == "exists")
            {
                try
                {
                    bool          RetVal = m_AssetService.GetExists(p[0]);
                    XmlSerializer xs     =
                        new XmlSerializer(typeof(AssetMetadata));
                    result = WebUtils.SerializeResult(xs, RetVal);

                    if (result == null)
                    {
                        httpResponse.StatusCode  = (int)HttpStatusCode.NotFound;
                        httpResponse.ContentType = "text/plain";
                        result = new byte[0];
                    }
                    else
                    {
                        httpResponse.StatusCode  = (int)HttpStatusCode.OK;
                        httpResponse.ContentType = "application/octet-stream";
                    }
                }
                catch (Exception ex)
                {
                    result = new byte[0];
                    m_log.Warn("[AssetServerGetHandler]: Error serializing the result for /exists for asset " + p[0] + ", " + ex.ToString());
                }
            }
            else if (p.Length > 1 && p[1] == "metadata")
            {
                AssetMetadata metadata = m_AssetService.GetMetadata(p[0]);

                if (metadata != null)
                {
                    XmlSerializer xs =
                        new XmlSerializer(typeof(AssetMetadata));
                    result = WebUtils.SerializeResult(xs, metadata);

                    httpResponse.StatusCode  = (int)HttpStatusCode.OK;
                    httpResponse.ContentType =
                        SLUtil.SLAssetTypeToContentType(metadata.Type);
                }
                else
                {
                    httpResponse.StatusCode  = (int)HttpStatusCode.NotFound;
                    httpResponse.ContentType = "text/plain";
                    result = new byte[0];
                }
            }
            else
            {
                AssetBase asset = m_AssetService.Get(p[0]);

                if (asset != null)
                {
                    XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
                    result = WebUtils.SerializeResult(xs, asset);

                    httpResponse.StatusCode  = (int)HttpStatusCode.OK;
                    httpResponse.ContentType =
                        SLUtil.SLAssetTypeToContentType(asset.Type);
                }
                else
                {
                    httpResponse.StatusCode  = (int)HttpStatusCode.NotFound;
                    httpResponse.ContentType = "text/plain";
                    result = new byte[0];
                }
            }
            return(result);
        }
Esempio n. 52
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>();

            string      username = filename.Split('/').LastOrDefault();
            UserAccount account  = null;

            if (httpRequest.Query.ContainsKey("userid"))
            {
                string userid = httpRequest.Query["userid"].ToString();

                account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, UUID.Parse(userid));
            }
            else if (httpRequest.Query.ContainsKey("name") || username.Contains('.'))
            {
                string name = httpRequest.Query.ContainsKey("name") ? httpRequest.Query["name"].ToString() : username;
                name    = name.Replace('.', ' ');
                account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, name);
            }
            else
            {
                username = username.Replace("%20", " ");
                account  = webInterface.Registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, username);
            }

            if (account == null)
            {
                return(vars);
            }

            // User found...
            vars.Add("UserName", account.Name);

            IUserProfileInfo       profile        = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>().GetUserProfile(account.PrincipalID);
            IWebHttpTextureService webhttpService = webInterface.Registry.RequestModuleInterface <IWebHttpTextureService>();

            if (profile != null)
            {
                vars.Add("UserType", profile.MembershipGroup == "" ? "Citizen" : profile.MembershipGroup);

                if (profile.Partner != UUID.Zero)
                {
                    account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, profile.Partner);
                    vars.Add("UserPartner", account.Name);
                }
                else
                {
                    vars.Add("UserPartner", "No partner");
                }

                vars.Add("UserAboutMe", profile.AboutText == "" ? "Nothing here" : profile.AboutText);
                string url = "../images/icons/no_avatar.jpg";

                if (webhttpService != null && profile.Image != UUID.Zero)
                {
                    url = webhttpService.GetTextureURL(profile.Image);
                }

                vars.Add("UserPictureURL", url);
            }
            else
            {
                // no profile yet
                vars.Add("UserType", "Citizen");
                vars.Add("UserPartner", "Not specified yet");
                vars.Add("UserAboutMe", "Nothing here yet");
                vars.Add("UserPictureURL", "../images/icons/no_avatar.jpg");
            }

            vars.Add("UsersGroupsText", translator.GetTranslatedString("UsersGroupsText"));

            IGroupsServiceConnector             groupsConnector = Framework.Utilities.DataManager.RequestPlugin <IGroupsServiceConnector>();
            List <Dictionary <string, object> > groups          = new List <Dictionary <string, object> >();

            if (groupsConnector != null)
            {
                foreach (var grp in groupsConnector.GetAgentGroupMemberships(account.PrincipalID, account.PrincipalID))
                {
                    var    grpData = groupsConnector.GetGroupProfile(account.PrincipalID, grp.GroupID);
                    string url     = "../images/icons/no_groups.jpg";

                    if (webhttpService != null && grpData.InsigniaID != UUID.Zero)
                    {
                        url = webhttpService.GetTextureURL(grpData.InsigniaID);
                    }

                    groups.Add(new Dictionary <string, object> {
                        { "GroupPictureURL", url },
                        { "GroupName", grp.GroupName }
                    });
                }

                if (groups.Count == 0)
                {
                    groups.Add(new Dictionary <string, object> {
                        { "GroupPictureURL", "../images/icons/no_groups.jpg" },
                        { "GroupName", "None yet" }
                    });
                }
            }

            vars.Add("GroupNameText", translator.GetTranslatedString("GroupNameText"));
            vars.Add("Groups", groups);
            vars.Add("GroupsJoined", groups.Count);

            return(vars);
        }
Esempio n. 53
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);
            }

            var regionData = Framework.Utilities.DataManager.RequestPlugin <IRegionData> ();
            var regions    = regionData.Get((RegionFlags)0, RegionFlags.Hyperlink | RegionFlags.Foreign | RegionFlags.Hidden, null, null, sortBy);

            foreach (var region in regions)
            {
                string info;
                info = (region.RegionArea < 1000000) ? region.RegionArea + " m2" : (region.RegionArea / 1000000) + " km2";
                info = info + ", " + region.RegionTerrain;

                RegionListVars.Add(new Dictionary <string, object> {
                    { "RegionLocX", region.RegionLocX / Constants.RegionSize },
                    { "RegionLocY", region.RegionLocY / Constants.RegionSize },
                    { "RegionName", region.RegionName },
                    { "RegionInfo", info },
                    { "RegionStatus", region.IsOnline ? "yes" : "no" },
                    { "RegionID", region.RegionID },
                    { "RegionURI", region.RegionURI }
                });
            }

            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("RegionOnlineText", translator.GetTranslatedString("Online"));
            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"));
            vars.Add("MainServerURL", webInterface.GridURL);

            return(vars);
        }
Esempio n. 54
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("Error505Text", translator.GetTranslatedString("Error505Text"));
            vars.Add("Error505InfoText", translator.GetTranslatedString("Error505InfoText"));
            vars.Add("HomePage505Text", translator.GetTranslatedString("HomePage505Text"));
            return(vars);
        }
Esempio n. 55
0
        byte[] WriteTextureData(OSHttpRequest request, OSHttpResponse response, AssetBase texture, string format)
        {
            string range = request.Headers.GetOne("Range");

            //MainConsole.Instance.DebugFormat("[GET TEXTURE]: Range {0}", range);
            if (!String.IsNullOrEmpty(range)) // JP2's only
            {
                // Range request
                int start, end;
                if (TryParseRange(range, out start, out end))
                {
                    // Before clamping start make sure we can satisfy it in order to avoid
                    // sending back the last byte instead of an error status
                    if (start >= texture.Data.Length)
                    {
                        response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable;
                        return(MainServer.BlankResponse);
                    }
                    else
                    {
                        // Handle the case where portions of the range are missing.
                        if (start == -1)
                        {
                            start = 0;
                        }
                        if (end == -1)
                        {
                            end = int.MaxValue;
                        }

                        end   = Utils.Clamp(end, 0, texture.Data.Length - 1);
                        start = Utils.Clamp(start, 0, end);
                        int len = end - start + 1;

                        //MainConsole.Instance.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID);

                        if (len < texture.Data.Length)
                        {
                            response.StatusCode = (int)System.Net.HttpStatusCode.PartialContent;
                        }
                        else
                        {
                            response.StatusCode = (int)System.Net.HttpStatusCode.OK;
                        }

                        response.ContentType = texture.TypeString;
                        response.AddHeader("Content-Range",
                                           String.Format("bytes {0}-{1}/{2}", start, end, texture.Data.Length));
                        byte[] array = new byte[len];
                        Array.Copy(texture.Data, start, array, 0, len);
                        return(array);
                    }
                }

                MainConsole.Instance.Warn("[GET TEXTURE]: Malformed Range header: " + range);
                response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                return(MainServer.BlankResponse);
            }

            // Full content request
            response.StatusCode  = (int)System.Net.HttpStatusCode.OK;
            response.ContentType = texture.TypeString;
            if (format == DefaultFormat)
            {
                response.ContentType = texture.TypeString;
            }
            else
            {
                response.ContentType = "image/" + format;
            }
            return(texture.Data);
        }
Esempio n. 56
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>();

            string      error = "";
            UserAccount user  = Authenticator.GetAuthentication(httpRequest);

            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitPasswordChange")
            {
                string password     = requestParameters["password"].ToString();
                string passwordconf = requestParameters["passwordconf"].ToString();
                response = "Success";
                if (passwordconf != password)
                {
                    response = "Passwords do not match";
                }
                else
                {
                    IAuthenticationService authService = webInterface.Registry.RequestModuleInterface <IAuthenticationService>();
                    if (authService != null)
                    {
                        error = authService.SetPassword(user.PrincipalID, "UserAccount", password) ? "" : "Failed to set your password, try again later";
                    }
                    else
                    {
                        response = "No authentication service was available to change your password";
                    }
                }
                return(null);
            }
            else if (requestParameters.ContainsKey("Submit") &&
                     requestParameters["Submit"].ToString() == "SubmitEmailChange")
            {
                string email = requestParameters["email"].ToString();

                IUserAccountService userService = webInterface.Registry.RequestModuleInterface <IUserAccountService>();
                if (userService != null)
                {
                    user.Email = email;
                    userService.StoreUserAccount(user);
                    response = "Success";
                }
                else
                {
                    response = "No authentication service was available to change your password";
                }
                return(null);
            }
            else if (requestParameters.ContainsKey("Submit") &&
                     requestParameters["Submit"].ToString() == "SubmitDeleteUser")
            {
                string username = requestParameters["username"].ToString();
                string password = requestParameters["password"].ToString();

                ILoginService loginService = webInterface.Registry.RequestModuleInterface <ILoginService>();
                if (loginService.VerifyClient(UUID.Zero, username, "UserAccount", password))
                {
                    IUserAccountService userService = webInterface.Registry.RequestModuleInterface <IUserAccountService>();
                    if (userService != null)
                    {
                        userService.DeleteUser(user.PrincipalID, password, true, false);
                        response = "Successfully deleted account.";
                    }
                    else
                    {
                        response = "User service unavailable, please try again later";
                    }
                }
                else
                {
                    response = "Wrong username or password";
                }
                return(null);
            }
            vars.Add("ErrorMessage", error);
            vars.Add("ChangeUserInformationText", translator.GetTranslatedString("ChangeUserInformationText"));
            vars.Add("ChangePasswordText", translator.GetTranslatedString("ChangePasswordText"));
            vars.Add("NewPasswordText", translator.GetTranslatedString("NewPasswordText"));
            vars.Add("NewPasswordConfirmationText", translator.GetTranslatedString("NewPasswordConfirmationText"));
            vars.Add("ChangeEmailText", translator.GetTranslatedString("ChangeEmailText"));
            vars.Add("NewEmailText", translator.GetTranslatedString("NewEmailText"));
            vars.Add("UserNameText", translator.GetTranslatedString("UserNameText"));
            vars.Add("PasswordText", translator.GetTranslatedString("PasswordText"));
            vars.Add("DeleteUserText", translator.GetTranslatedString("DeleteUserText"));
            vars.Add("DeleteText", translator.GetTranslatedString("DeleteText"));
            vars.Add("DeleteUserInfoText", translator.GetTranslatedString("DeleteUserInfoText"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));

            return(vars);
        }
Esempio n. 57
0
        public byte [] NewAgentInventoryRequestVariablePrice(string path, Stream request, OSHttpRequest httpRequest,
                                                             OSHttpResponse httpResponse)
        {
            OSDMap map        = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
            string asset_type = map ["asset_type"].AsString();
            int    charge     = 0;
            int    resourceCost;

            if (!ChargeUser(asset_type, map, out charge, out resourceCost))
            {
                map = new OSDMap();
                map ["uploader"] = "";
                map ["state"]    = "error";
                return(OSDParser.SerializeLLSDXmlBytes(map));
            }
            OSDMap resp = InternalNewAgentInventoryRequest(map, httpRequest, httpResponse);

            resp ["resource_cost"] = resourceCost;
            resp ["upload_price"]  = charge; //Set me if you want to use variable cost stuff

            return(OSDParser.SerializeLLSDXmlBytes(map));
        }
Esempio n. 58
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);
        }
Esempio n. 59
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>();

            string error = "";

            if (requestParameters.ContainsKey("username") && requestParameters.ContainsKey("password"))
            {
                string username = requestParameters["username"].ToString();
                string password = requestParameters["password"].ToString();

                ILoginService loginService = webInterface.Registry.RequestModuleInterface <ILoginService>();
                if (loginService.VerifyClient(UUID.Zero, username, "UserAccount", password))
                {
                    UUID        sessionID = UUID.Random();
                    UserAccount account   =
                        webInterface.Registry.RequestModuleInterface <IUserAccountService>()
                        .GetUserAccount(null, username);
                    Authenticator.AddAuthentication(sessionID, account);
                    if (account.UserLevel > 0)
                    {
                        Authenticator.AddAdminAuthentication(sessionID, account);
                    }
                    httpResponse.AddCookie(new System.Web.HttpCookie("SessionID", sessionID.ToString())
                    {
                        Expires = DateTime.MinValue,
                        Path    = ""
                    });

                    response = "<h3>Successfully logged in, redirecting to main page</h3>" +
                               "<script language=\"javascript\">" +
                               "setTimeout(function() {window.location.href = \"index.html\";}, 0);" +
                               "</script>";
                }
                else
                {
                    response = "<h3>Failed to verify user name and password</h3>";
                }
                return(null);
            }

            vars.Add("ErrorMessage", error);
            vars.Add("Login", translator.GetTranslatedString("Login"));
            vars.Add("UserNameText", translator.GetTranslatedString("UserName"));
            vars.Add("PasswordText", translator.GetTranslatedString("Password"));
            vars.Add("ForgotPassword", translator.GetTranslatedString("ForgotPassword"));
            vars.Add("Submit", translator.GetTranslatedString("Login"));

            return(vars);
        }
Esempio n. 60
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("WorldMap", translator.GetTranslatedString("WorldMap"));
            vars.Add("WorldMapText", translator.GetTranslatedString("WorldMapText"));

            return(vars);
        }