Exemplo n.º 1
0
        public string UserEditPostRequest(Environment env, UUID userID, string password)
        {
            m_log.DebugFormat("[Wifi]: UserEditPostRequest (password) {0}", userID);
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;
                UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, userID);
                if (account != null)
                {
                    if (password != string.Empty)
                    {
                        m_AuthenticationService.SetPassword(account.PrincipalID, password);
                    }

                    env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                    NotifyWithoutButton(env, _("The account has been updated.", env));
                    m_log.DebugFormat("[Wifi]: Updated account for user {0}", account.Name);
                }
                else
                {
                    NotifyWithoutButton(env, _("The account does not exist.", env));
                    m_log.DebugFormat("[Wifi]: Attempt at updating an inexistent account");
                }

                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 2
0
        public string InventoryGetRequest(Environment env)
        {
            if (!m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[Wifi]: warning: someone is trying to access UserAccountGetRequest and Wifi isn't isntalled!");
                return(m_WebApp.ReadFile(env, "index.html"));
            }

            m_log.DebugFormat("[Wifi]: InventoryGetRequest");
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo))
            {
                env.Session = sinfo;
                InventoryTreeNode tree = m_InventoryService.GetInventoryTree(sinfo.Account.PrincipalID);
                List <object>     loo  = new List <object>();
                //foreach (InventoryTreeNode n in tree.Children) // skip the artificial first level
                //{
                //    m_log.DebugFormat("[XXX] Adding {0}", n.Name);
                //    loo.Add(n);
                //}
                loo.Add(tree);

                env.Data  = loo;
                env.Flags = Flags.IsLoggedIn;
                env.State = State.InventoryListForm;
                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }
            else
            {
                return(m_WebApp.ReadFile(env, "index.html"));
            }
        }
Exemplo n.º 3
0
        public string UserDeletePostRequest(Environment env, UUID userID)
        {
            m_log.DebugFormat("[Wifi]: UserDeletePostRequest {0}", userID);
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;
                UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, userID);
                if (account != null)
                {
                    m_UserAccountService.DeleteAccount(UUID.Zero, userID);
                    m_InventoryService.DeleteUserInventory(userID);

                    env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                    NotifyWithoutButton(env, _("The account has been deleted.", env));
                    m_log.DebugFormat("[Wifi]: Deleted account for user {0}", account.Name);
                }
                else
                {
                    NotifyWithoutButton(env, _("Unable to delete account because it does not exist.", env));
                    m_log.DebugFormat("[Wifi]: Attempt at deleting an inexistent account");
                }

                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 4
0
        public string UserEditGetRequest(Environment env, UUID userID)
        {
            m_log.DebugFormat("[Wifi]: UserEditGetRequest {0}", userID);
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;
                env.Flags   = Flags.IsLoggedIn | Flags.IsAdmin;
                env.State   = State.UserEditForm;
                UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, userID);
                if (account != null)
                {
                    List <object> loo = new List <object>();
                    loo.Add(account);
                    env.Data = loo;
                }

                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 5
0
        public string GroupsEditGetRequest(Environment env, UUID groupID)
        {
            m_log.DebugFormat("[Wifi]: GroupsEditGetRequest {0}", groupID);
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                if (m_GroupsService != null)
                {
                    env.Session = sinfo;
                    env.Flags   = Flags.IsLoggedIn | Flags.IsAdmin;
                    env.State   = State.GroupEditForm;
                    GroupRecord group = m_GroupsService.GetGroupRecord(groupID);
                    if (group != null)
                    {
                        List <object> loo = new List <object>();
                        loo.Add(group);
                        env.Data = loo;
                    }
                }
                else
                {
                    m_log.WarnFormat("[Wifi]: No Groups service");
                }

                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
        public string UserAccountGetRequest(Environment env, UUID userID)
        {
            if (!m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[Wifi]: warning: someone is trying to access UserAccountGetRequest and Wifi isn't isntalled!");
                return(m_WebApp.ReadFile(env, "index.html"));
            }

            m_log.DebugFormat("[Wifi]: UserAccountGetRequest");
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo))
            {
                env.Session = sinfo;
                List <object> loo = new List <object>();
                loo.Add(sinfo.Account);
                env.Data  = loo;
                env.Flags = Flags.IsLoggedIn;
                env.State = State.UserAccountForm;
                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }
            else
            {
                return(m_WebApp.ReadFile(env, "index.html"));
            }
        }
Exemplo n.º 7
0
        public string RegionManagementGetRequest(Environment env)
        {
            m_log.DebugFormat("[Services]: RegionManagementGetRequest()");
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                List <GridRegion> regions = m_GridService.GetRegionsByName(UUID.Zero, "", 200);

                m_log.DebugFormat("[Services]: There are {0} regions", regions.Count);
                regions.ForEach(delegate(GridRegion gg)
                {
                    m_log.DebugFormat("[Services] {0}", gg.RegionName);
                });

                env.Session = sinfo;
                env.Data    = WebAppUtils.Objectify(regions);
                env.Flags   = Flags.IsAdmin | Flags.IsLoggedIn;
                env.State   = State.RegionManagementForm;
                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }
            else
            {
                return(m_WebApp.ReadFile(env, "index.html"));
            }
        }
Exemplo n.º 8
0
        public string HyperlinkGetRequest(Environment env)
        {
            m_log.Debug("[Wifi]: HyperlinkGetRequest");

            SessionInfo sinfo;

            if (TryGetSessionInfo(env.TheRequest, out sinfo))
            {
                env.Session = sinfo;
                env.Flags   = Flags.IsLoggedIn;
                if (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)
                {
                    env.Flags |= Flags.IsAdmin & Flags.AllowHyperlinks;
                }
                if (sinfo.Account.UserLevel >= m_WebApp.HyperlinksUserLevel)
                {
                    env.Flags |= Flags.AllowHyperlinks;
                }
                if ((env.Flags & Flags.AllowHyperlinks) == 0)
                {
                    env.State = State.HyperlinkList;
                }
                else
                {
                    env.State = State.HyperlinkListForm;
                }
                env.Data = GetHyperlinks(env, sinfo.Account.PrincipalID);

                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }
            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 9
0
        public string UserSearchPostRequest(Environment env, string terms)
        {
            m_log.DebugFormat("[Wifi]: UserSearchPostRequest");
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                if (terms != string.Empty)
                {
                    env.Session = sinfo;
                    env.Flags   = Flags.IsLoggedIn | Flags.IsAdmin;
                    env.State   = State.UserSearchFormResponse;
                    // Put the list in the environment
                    List <UserAccount> accounts = m_UserAccountService.GetActiveAccounts(UUID.Zero, terms, m_PendingIdentifier);
                    env.Data = WebAppUtils.Objectify <UserAccount>(accounts);

                    return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
                }
                else
                {
                    return(UserManagementGetRequest(env));
                }
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 10
0
        private string PadURLs(Environment env, string sid, string html)
        {
            if ((env.Flags & Flags.IsLoggedIn) == 0)
            {
                return(html);
            }

            return(WebAppUtils.PadURLs(sid, html));
        }
Exemplo n.º 11
0
        public string HyperlinkAddRequest(Environment env, string address, uint xloc, uint yloc)
        {
            m_log.Debug("[Wifi]: HyperlinkAddRequest");

            SessionInfo sinfo;

            if (TryGetSessionInfo(env.TheRequest, out sinfo))
            {
                env.Session = sinfo;
                env.Flags   = Flags.IsLoggedIn;
                if (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)
                {
                    env.Flags |= Flags.IsAdmin;
                }

                if (sinfo.Account.UserLevel >= m_WebApp.HyperlinksUserLevel ||
                    sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)
                {
                    if (address != string.Empty)
                    {
                        string reason;
                        if (WebAppUtils.IsValidRegionAddress(address))
                        {
                            UUID owner = sinfo.Account.PrincipalID;
                            if (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)
                            {
                                owner = UUID.Zero;
                            }
                            // Create hyperlink
                            xloc = xloc * Constants.RegionSize;
                            yloc = yloc * Constants.RegionSize;
                            if (m_GridService.TryLinkRegionToCoords(UUID.Zero, address, xloc, yloc, owner, out reason) == null)
                            {
                                reason = string.Format(_("Failed to link region: {0}", env), reason);
                            }
                            else
                            {
                                reason = string.Format(_("Region link to {0} established. (If this link already existed, then it will remain at the original location.)", env), address);
                            }
                        }
                        else
                        {
                            reason = _("Invalid region address.", env);
                        }
                        NotifyOK(env, reason, delegate(Environment e) { return(HyperlinkGetRequest(e)); });
                    }
                    else
                    {
                        return(HyperlinkGetRequest(env));
                    }
                }
                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }
            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 12
0
        public string HyperlinkDeletePostRequest(Environment env, UUID regionID)
        {
            m_log.DebugFormat("[Wifi]: HyperlinkDeletePostRequest {0}", regionID);

            SessionInfo sinfo;

            if (TryGetSessionInfo(env.TheRequest, out sinfo))
            {
                env.Session = sinfo;
                env.Flags   = Flags.IsLoggedIn;
                if (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)
                {
                    env.Flags |= Flags.IsAdmin;
                }
                if (sinfo.Account.UserLevel >= m_WebApp.HyperlinksUserLevel ||
                    sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)
                {
                    // Try to delete hyperlink
                    GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero, regionID);
                    if (region != null)
                    {
                        if ((sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel) ||
                            (region.EstateOwner == sinfo.Account.PrincipalID))
                        {
                            if (m_GridService.TryUnlinkRegion(region.RegionName))
                            {
                                NotifyOK(env,
                                         string.Format(_("Deleted region link {0}.", env), region.RegionName),
                                         delegate(Environment e) { return(HyperlinkGetRequest(e)); });
                            }
                            else
                            {
                                NotifyOK(env,
                                         string.Format(_("Deletion of region link {0} failed.", env), region.RegionName),
                                         delegate(Environment e) { return(HyperlinkGetRequest(e)); });
                            }
                        }
                        else
                        {
                            m_log.WarnFormat("[Wifi]: Unauthorized attempt to delete hyperlink {0}:{1} ({2}) by {3} ({4})",
                                             region.ExternalHostName, region.HttpPort, region.RegionName, sinfo.Account.Name, sinfo.Account.PrincipalID);
                        }
                    }
                    else
                    {
                        m_log.WarnFormat("[Wifi]: Attempt to delete an inexistent region link for UUID {0} by {1} ({2})",
                                         regionID, sinfo.Account.Name, sinfo.Account.PrincipalID);
                        NotifyOK(env, _("Region link not found.", env),
                                 delegate(Environment e) { return(HyperlinkGetRequest(e)); });
                    }
                }
                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }
            return(m_WebApp.ReadFile(env, "index.html"));
        }
        public string UserAccountPostRequest(Environment env, UUID userID, string email, string oldpassword, string newpassword, string newpassword2)
        {
            if (!m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[Wifi]: warning: someone is trying to access UserAccountPostRequest and Wifi isn't isntalled!");
                return(m_WebApp.ReadFile(env, "index.html"));
            }
            m_log.DebugFormat("[Wifi]: UserAccountPostRequest");
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo))
            {
                env.Session = sinfo;
                // We get the userID, but we only allow changes to the account of this session
                List <object> loo = new List <object>();
                loo.Add(sinfo.Account);
                env.Data = loo;

                bool updated = false;
                if (email != string.Empty && email.Contains("@") && sinfo.Account.Email != email)
                {
                    sinfo.Account.Email = email;
                    m_UserAccountService.StoreUserAccount(sinfo.Account);
                    updated = true;
                }

                string encpass = OpenSim.Framework.Util.Md5Hash(oldpassword);
                if ((newpassword != string.Empty) && (newpassword == newpassword2) &&
                    m_AuthenticationService.Authenticate(sinfo.Account.PrincipalID, encpass, 30) != string.Empty)
                {
                    m_AuthenticationService.SetPassword(sinfo.Account.PrincipalID, newpassword);
                    updated = true;
                }

                if (updated)
                {
                    env.Flags = Flags.IsLoggedIn;
                    NotifyWithoutButton(env, _("Your account has been updated.", env));
                    m_log.DebugFormat("[Wifi]: Updated account for user {0}", sinfo.Account.Name);
                    return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
                }

                // nothing was updated, really
                env.Flags = Flags.IsLoggedIn;
                env.State = State.UserAccountForm;
                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }
            else
            {
                m_log.DebugFormat("[Wifi]: Failed to get session info");
                return(m_WebApp.ReadFile(env, "index.html"));
            }
        }
Exemplo n.º 14
0
        public string HyperlinkDeleteGetRequest(Environment env, UUID regionID)
        {
            m_log.DebugFormat("[Wifi]: HyperlinkDeleteGetRequest {0}", regionID);

            SessionInfo sinfo;

            if (TryGetSessionInfo(env.TheRequest, out sinfo))
            {
                env.Session = sinfo;
                env.Flags   = Flags.IsLoggedIn;
                if (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)
                {
                    env.Flags |= Flags.IsAdmin;
                }
                if (sinfo.Account.UserLevel >= m_WebApp.HyperlinksUserLevel || (env.Flags & Flags.IsAdmin) != 0)
                {
                    GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero, regionID);
                    if (region != null)
                    {
                        if (((env.Flags & Flags.IsAdmin) != 0) || (region.EstateOwner == sinfo.Account.PrincipalID))
                        {
                            RegionInfo  link = new RegionInfo(region);
                            UserAccount user = sinfo.Account;
                            if (region.EstateOwner != user.PrincipalID)
                            {
                                user = m_UserAccountService.GetUserAccount(UUID.Zero, region.EstateOwner);
                            }
                            if (user != null)
                            {
                                link.RegionOwner = user.Name;
                            }
                            List <object> loo = new List <object>();
                            loo.Add(link);
                            env.State = State.HyperlinkDeleteForm;
                            env.Data  = loo;
                        }
                        else
                        {
                            m_log.WarnFormat("[Wifi]: Unauthorized attempt to delete hyperlink {0}:{1} ({2}) by {3} ({4})",
                                             region.ExternalHostName, region.HttpPort, region.RegionName, sinfo.Account.Name, sinfo.Account.PrincipalID);
                        }
                    }
                    else
                    {
                        m_log.WarnFormat("[Wifi]: Attempt to delete an inexistent region link for UUID {0} by {1} ({2})",
                                         regionID, sinfo.Account.Name, sinfo.Account.PrincipalID);
                        NotifyOK(env, _("Region link not found.", env),
                                 delegate(Environment e) { return(HyperlinkGetRequest(e)); });
                    }
                }
            }
            return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
        }
Exemplo n.º 15
0
        public string RegionManagementRestartPostRequest(Environment env)
        {
            Request     request = env.TheRequest;
            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;

                string url = m_WebApp.LoginURL;

                Hashtable hash = new Hashtable();
                if (m_ServerAdminPassword == null)
                {
                    m_log.Debug("[RegionManagementRestartPostRequest] No remote admin password was set in .ini file");
                }

                hash["password"] = m_ServerAdminPassword;
                IList paramList = new ArrayList();
                paramList.Add(hash);
                XmlRpcRequest xmlrpcReq = new XmlRpcRequest("admin_shutdown", paramList);

                XmlRpcResponse response = null;
                try
                {
                    //first, shutdown the server
                    response = xmlrpcReq.Send(url, 10000);

                    //then wait until the server is completely shutdown, then re-launch
                    System.Diagnostics.Process[] openSimProcess = System.Diagnostics.Process.GetProcessesByName("OpenSim");
                    openSimProcess[0].WaitForExit();
                    System.Diagnostics.Process.Start("OpenSim.exe");
                    env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                    env.State = State.RegionManagementSuccessful;
                }
                catch (Exception e)
                {
                    m_log.Debug("[Wifi]: Exception (2) " + e.Message);
                    env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                    env.State = State.RegionManagementUnsuccessful;
                }

                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 16
0
        public string ConsoleRequest(Environment env)
        {
            m_log.DebugFormat("[Wifi]: ConsoleRequest");
            SessionInfo sinfo;

            if (TryGetSessionInfo(env.TheRequest, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;
                env.Flags   = Flags.IsLoggedIn | Flags.IsAdmin;
                env.State   = State.Console;
                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 17
0
        public string RegionManagementShutdownPostRequest(Environment env)
        {
            //m_log.DebugFormat("[Wifi]: RegionManagementShutdownPostRequest");
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;

                //FIXME: don't hardcode url, get it from m_GridService
                //TODO: check if server is actually running first
                //TODO: add support for shutdown message parameter from html form
                string    url  = m_WebApp.LoginURL;
                Hashtable hash = new Hashtable();
                if (m_ServerAdminPassword == null)
                {
                    m_log.Debug("[RegionManagementShutdownPostRequest] No remote admin password was set in .ini file");
                }

                hash["password"] = m_ServerAdminPassword;
                IList paramList = new ArrayList();
                paramList.Add(hash);
                XmlRpcRequest xmlrpcReq = new XmlRpcRequest("admin_shutdown", paramList);

                XmlRpcResponse response = null;
                try
                {
                    response  = xmlrpcReq.Send(url, 10000);
                    env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                    env.State = State.RegionManagementSuccessful;
                }
                catch (Exception e)
                {
                    m_log.Debug("[Wifi]: Exception (1) " + e.Message);
                    env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                    env.State = State.RegionManagementUnsuccessful;
                }

                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 18
0
        public string LoginRequest(Environment env, string first, string last, string password)
        {
            if (!m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[Wifi]: warning: someone is trying to access LoginRequest and Wifi isn't installed!");
                return(m_WebApp.ReadFile(env, "index.html"));
            }

            m_log.DebugFormat("[Wifi]: LoginRequest {0} {1}", first, last);
            Request request = env.TheRequest;
            string  encpass = OpenSim.Framework.Util.Md5Hash(password);

            string      notification;
            string      authtoken = null;
            UserAccount account   = m_UserAccountService.GetUserAccount(UUID.Zero, first, last);

            if (account != null)
            {
                authtoken = m_AuthenticationService.Authenticate(account.PrincipalID, encpass, 30);
            }
            if (string.IsNullOrEmpty(authtoken))
            {
                notification = _("Login failed.", env);
            }
            else
            {
                // Successful login
                SessionInfo sinfo;
                sinfo.IpAddress = request.IPEndPoint.Address.ToString();
                sinfo.Sid       = authtoken;
                sinfo.Account   = account;
                sinfo.Notify    = new NotificationData();
                m_Sessions.Add(authtoken, sinfo, m_WebApp.SessionTimeout);
                env.TheRequest.Query["sid"] = authtoken;
                env.Session = sinfo;

                List <object> loo = new List <object>();
                loo.Add(account);
                env.Data     = loo;
                env.Flags    = Flags.IsLoggedIn;
                notification = string.Format(_("Welcome to {0}!", env), m_WebApp.GridName);
            }
            NotifyWithoutButton(env, notification);
            return(WebAppUtils.PadURLs(env, authtoken, m_WebApp.ReadFile(env, "index.html")));
        }
Exemplo n.º 19
0
        public string RegionManagementBroadcastPostRequest(Environment env, string message)
        {
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;

                string    url  = m_WebApp.LoginURL;
                Hashtable hash = new Hashtable();
                if (m_ServerAdminPassword == null)
                {
                    m_log.Debug("[RegionManagementBroadcastPostRequest] No remote admin password was set in .ini file");
                }

                hash["password"] = m_ServerAdminPassword;
                hash["message"]  = message;
                IList paramList = new ArrayList();
                paramList.Add(hash);
                XmlRpcRequest xmlrpcReq = new XmlRpcRequest("admin_broadcast", paramList);

                XmlRpcResponse response = null;
                try
                {
                    response  = xmlrpcReq.Send(url, 10000);
                    env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                    env.State = State.RegionManagementSuccessful;
                }
                catch (Exception e)
                {
                    m_log.Debug("[Wifi]: Exception (3) " + e.Message);
                    env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                    env.State = State.RegionManagementUnsuccessful;
                }

                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 20
0
        public string DefaultRequest(Environment env)
        {
            m_log.DebugFormat("[Wifi]: DefaultRequest");

            SessionInfo sinfo;

            if (TryGetSessionInfo(env.TheRequest, out sinfo))
            {
                env.Session = sinfo;
                env.Flags   = Flags.IsLoggedIn;
                env.State   = State.Default;
                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "splash.html")));
            }

            string    resourcePath = Localization.LocalizePath(env, "splash.html");
            Processor p            = new Processor(m_WebApp.WifiScriptFace, env);

            return(p.Process(WebAppUtils.ReadTextResource(resourcePath)));
        }
Exemplo n.º 21
0
        public string InventoryLoadGetRequest(Environment env)
        {
            m_log.DebugFormat("[Wifi]: InventoryLoadGetRequest");
            SessionInfo sinfo;

            if (TryGetSessionInfo(env.TheRequest, out sinfo))
            {
                env.Session = sinfo;
                env.Flags   = Flags.IsLoggedIn;

                string message = string.Format("{0} <img src=\"/wifi/images/loader.gif\" /><p>{1}</p>",
                                               _("Loading your inventory, please wait", env),
                                               _("If your browser does not automatically load the next page, then use the button, please.", env));
                NotifyWithRedirect(env, message, _("continue", env), 0, "/wifi/user/inventory",
                                   delegate(Environment e) { return(InventoryGetRequest(e)); });
                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }
            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 22
0
        public string UserManagementGetRequest(Environment env)
        {
            m_log.DebugFormat("[Wifi]: UserManagementGetRequest");
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;
                env.Flags   = Flags.IsLoggedIn | Flags.IsAdmin;
                env.State   = State.UserSearchForm;
                env.Data    = GetUserList(env, m_PendingIdentifier);
                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 23
0
        public string GroupsEditPostRequest(Environment env, UUID groupID, string name, string charter)
        {
            m_log.DebugFormat("[Wifi]: GroupsEditPostRequest {0} {1}", groupID, name);
            Request request = env.TheRequest;


            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;
                if (m_GroupsService != null)
                {
                    GroupRecord group = m_GroupsService.GetGroupRecord(groupID);
                    if (group != null)
                    {
                        // Update the group
                        group.GroupName = name;
                        group.Charter   = charter;
                        m_GroupsService.UpdateGroup(groupID, name, charter);

                        env.Flags = Flags.IsLoggedIn | Flags.IsAdmin;
                        NotifyWithoutButton(env, _("The group has been updated.", env));
                        m_log.DebugFormat("[Wifi]: Updated group {0}", group.GroupName);
                    }
                    else
                    {
                        NotifyWithoutButton(env, _("The group does not exist.", env));
                        m_log.DebugFormat("[Wifi]: Attempt at updating an inexistent group");
                    }

                    return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
                }
                else
                {
                    m_log.WarnFormat("[Wifi]: No Groups service");
                }
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 24
0
        public string GroupsDeletePostRequest(Environment env, UUID groupID)
        {
            m_log.DebugFormat("[Wifi]: GroupsDeletePostRequest {0}", groupID);
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;
                m_GroupsService.DeleteGroup(groupID);

                env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                NotifyWithoutButton(env, _("The group has been deleted.", env));
                m_log.DebugFormat("[Wifi]: Deleted group {0}", groupID);

                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 25
0
        public string UserEditPostRequest(Environment env, UUID userID, string first, string last, string email, int level, int flags, string title)
        {
            m_log.DebugFormat("[Wifi]: UserEditPostRequest {0}", userID);
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;
                UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, userID);
                if (account != null)
                {
                    // Update the account
                    account.FirstName = first;
                    account.LastName  = last;
                    account.Email     = email;
                    account.UserFlags = flags;
                    account.UserLevel = level;
                    account.UserTitle = title;
                    m_UserAccountService.StoreUserAccount(account);

                    env.Flags = Flags.IsLoggedIn | Flags.IsAdmin;
                    NotifyWithoutButton(env, _("The account has been updated.", env));
                    m_log.DebugFormat("[Wifi]: Updated account for user {0}", account.Name);
                }
                else
                {
                    NotifyWithoutButton(env, _("The account does not exist.", env));
                    m_log.DebugFormat("[Wifi]: Attempt at updating an inexistent account");
                }

                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 26
0
        public string UserActivateGetRequest(Environment env, UUID userID)
        {
            m_log.DebugFormat("[Wifi]: UserActivateGetRequest {0}", userID);
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;
                env.Flags   = Flags.IsLoggedIn | Flags.IsAdmin;
                NotifyWithoutButton(env, _("The account has been activated.", env));
                UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, userID);
                if (account != null)
                {
                    // Remove pending identifier in name
                    account.FirstName = account.FirstName.Replace(m_PendingIdentifier, "");

                    // Retrieve saved user data from serviceURLs and set them back to normal
                    string password = (string)account.ServiceURLs["Password"];
                    account.ServiceURLs.Remove("Password");

                    Object value;
                    if (account.ServiceURLs.TryGetValue("Avatar", out value))
                    {
                        account.ServiceURLs.Remove("Avatar");
                    }
                    string avatarType = (string)value;

                    CultureInfo[] languages = null;
                    if (account.ServiceURLs.TryGetValue("Language", out value))
                    {
                        languages = Localization.GetLanguageInfo((string)value);
                        account.ServiceURLs.Remove("Language");
                    }

                    // Save changes to user account
                    m_UserAccountService.StoreUserAccount(account);

                    // Create the inventory
                    m_InventoryService.CreateUserInventory(account.PrincipalID);

                    // Set the password
                    m_AuthenticationService.SetPassword(account.PrincipalID, password);

                    // Set the avatar
                    if (avatarType != null)
                    {
                        SetAvatar(env, account.PrincipalID, avatarType);
                    }

                    if (!string.IsNullOrEmpty(account.Email))
                    {
                        string message = string.Format("{0}\n\n{1} {2}\n{3} {4}\n\n{5} {6}",
                                                       _("Your account has been activated.", languages),
                                                       _("First name:", languages), account.FirstName,
                                                       _("Last name:", languages), account.LastName,
                                                       _("LoginURI:", languages), m_WebApp.LoginURL);
                        SendEMail(account.Email, _("Account activated", languages), message);
                    }
                }

                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 27
0
        public string TOSPostRequest(Environment env, string action, string userID, string sessionID)
        {
            if (!m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[Wifi]: warning: someone is trying to access InventoryPostRequest and Wifi isn't installed!");
                return(m_WebApp.ReadFile(env, "index.html"));
            }

            m_log.DebugFormat("[Wifi]: TOSPostRequest {0} {1} {2}", action, userID, sessionID);
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo))
            {
                env.Session = sinfo;

                if (action == "accept")
                {
                    AcceptTOS(env, userID);
                    if (sinfo.Account != null)
                    {
                        env.Flags = Flags.IsLoggedIn;
                    }
                    else
                    {
                        env.Flags = Flags.IsValidSession;
                    }

                    env.State = State.AcceptTOS;
                }
                else
                {
                    TOSData d = new TOSData();
                    d.UserID    = userID;
                    d.SessionID = sinfo.Sid;
                    List <object> loo = new List <object>();
                    loo.Add(d);
                    env.Data = loo;

                    if (sinfo.Account != null)
                    {
                        env.Flags = Flags.IsLoggedIn;
                    }
                    else
                    {
                        env.Flags = Flags.IsValidSession;
                    }


                    env.State = State.GetTOS;
                }

                if (sinfo.Account != null)
                {
                    env.Flags = Flags.IsLoggedIn;
                }

                return(WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")));
            }
            else
            {
                m_log.DebugFormat("[Wifi]: no session found");
                return(m_WebApp.ReadFile(env, "index.html"));
            }
        }