public override byte[] Handle(string path, Stream requestData,
                IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            // path = /wifi/...
            //m_log.DebugFormat("[Wifi]: path = {0}", path);
            //m_log.DebugFormat("[Wifi]: ip address = {0}", httpRequest.RemoteIPEndPoint);
            //foreach (object o in httpRequest.Query.Keys)
            //    m_log.DebugFormat("  >> {0}={1}", o, httpRequest.Query[o]);

            string result = string.Empty;
            try
            {
                Request request = RequestFactory.CreateRequest(string.Empty, httpRequest, Localization.GetLanguageInfo(httpRequest.Headers.Get("accept-language")));
                Environment env = new Environment(request);

                result = m_WebApp.Services.LogoutRequest(env);

                httpResponse.ContentType = "text/html";
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[LOGOUT HANDLER]: Exception {0}: {1}", e.Message, e.StackTrace);
            }

            return WebAppUtils.StringToBytes(result);
        }
예제 #2
0
        public override byte[] Handle(string path, Stream requestData,
                                      IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            // path = /wifi/...
            //m_log.DebugFormat("[Wifi]: path = {0}", path);
            //m_log.DebugFormat("[Wifi]: ip address = {0}", httpRequest.RemoteIPEndPoint);
            //foreach (object o in httpRequest.Query.Keys)
            //    m_log.DebugFormat("  >> {0}={1}", o, httpRequest.Query[o]);
            httpResponse.ContentType = "text/html";
            string resource = GetParam(path);
            //m_log.DebugFormat("[USER ACCOUNT HANDLER GET]: resource {0}", resource);

            Request     request = RequestFactory.CreateRequest(string.Empty, httpRequest, Localization.GetLanguageInfo(httpRequest.Headers.Get("accept-language")));
            Environment env     = new Environment(request);

            string result = string.Empty;
            UUID   userID = UUID.Zero;

            if (resource == string.Empty || resource == "/")
            {
                result = m_WebApp.Services.NewAccountGetRequest(env);
            }
            else
            {
                //UUID.TryParse(resource.Trim(new char[] {'/'}), out userID);
                if (resource.Trim(new char[] { '/' }).StartsWith("edit"))
                {
                    result = m_WebApp.Services.UserAccountGetRequest(env, userID);
                }
            }

            return(WebAppUtils.StringToBytes(result));
        }
예제 #3
0
        public string GetAddonsMenu(Environment env)
        {
            if (!m_WebApp.IsInstalled)
            {
                return(string.Empty);
            }

            // are there any addons?
            if (m_WebApp.Addons.Count > 0)
            {
                SessionInfo sinfo = env.Session;
                if (sinfo.Account != null)
                {
                    if (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel) // Admin
                    {
                        StringBuilder str = new StringBuilder("<p class=\"nav-headline\">Addons menu</p><div id=\"addons-menu\">  <ul>");
                        str.Append(System.Environment.NewLine);
                        foreach (WifiAddon a in m_WebApp.Addons)
                        {
                            str.AppendFormat("  <li><a href=\"{0}\">{1}</a></li>{2}", a.Path, a.MenuAnchor, System.Environment.NewLine);
                        }

                        str.Append("  </ul></div>");

                        return(str.ToString());
                    }
                }
            }

            return(string.Empty);
        }
        public string ForgotPasswordPostRequest(Environment env, string email)
        {
            UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, email);

            if (account != null)
            {
                string token = m_AuthenticationService.GetToken(account.PrincipalID, 60);
                if (token != string.Empty)
                {
                    string url = m_WebApp.WebAddress + "/wifi/recover/" + token + "?email=" + HttpUtility.UrlEncode(email);

                    string message = string.Format("\n{0}\n{1}\n{2}",
                                                   string.Format(_("Your account is {0} {1}", env), account.FirstName, account.LastName),
                                                   _("Click here to reset your password:"******"Password Reset", env), message))
                    {
                        NotifyWithoutButton(env, _("Check your email. You must reset your password within 60 minutes.", env));
                    }
                    else
                    {
                        NotifyWithoutButton(env, _("Email could not be sent.", env));
                    }

                    return(m_WebApp.ReadFile(env, "index.html"));
                }
            }

            return(m_WebApp.ReadFile(env, "index.html"));
        }
예제 #5
0
        public static string GetInventoryChildren(this InventoryTreeNode node, IEnvironment env)
        {
            //Console.WriteLine(" GetInventoryChildren --> " + node.Name);
            if (node.Children == null)
            {
                return(string.Empty);
            }

            // else it's a folder
            string      invListStr = string.Empty;
            Environment env2       = (Environment)env;

            //Console.WriteLine(" GetInventoryChildren --> child count " + node.Children.Count);
            foreach (InventoryTreeNode child in node.Children)
            {
                // Create a new environment
                Environment newEnv = new Environment(env2.TheRequest);
                newEnv.Flags   = env2.Flags;
                newEnv.Session = env2.Session;
                newEnv.State   = env2.State;
                newEnv.Data    = new List <object>();
                newEnv.Data.Add(child);

                //Console.WriteLine("-------- " + child.Name + " ------");
                invListStr += WebApp.WebAppInstance.ReadFile(newEnv, "inventorylistitem.html");
            }

            return(invListStr);
        }
예제 #6
0
        public override byte[] Handle(string path, Stream requestData,
                                      IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            string result = string.Empty;

            try
            {
                Request     request = RequestFactory.CreateRequest(string.Empty, httpRequest, Localization.GetLanguageInfo(httpRequest.Headers.Get("accept-language")));
                Environment env     = new Environment(request);

                string resource = GetParam(path);
                //m_log.DebugFormat("[XXX]: resource {0}", resource);
                if (resource.StartsWith("/data/simulators"))
                {
                    result = m_WebApp.Services.ConsoleSimulatorsRequest(env);
                    httpResponse.ContentType = "application/xml";
                }
                else if (resource.StartsWith("/heartbeat"))
                {
                    result = m_WebApp.Services.ConsoleHeartbeat(env);
                    httpResponse.ContentType = "application/xml";
                }
                else
                {
                    result = m_WebApp.Services.ConsoleRequest(env);
                    httpResponse.ContentType = "text/html";
                }
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[CONSOLE HANDLER]: Exception {0}: {1}", e.Message, e.StackTrace);
            }

            return(WebAppUtils.StringToBytes(result));
        }
예제 #7
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"));
            }
        }
        public string InstallPostRequest(Environment env, string password, string password2)
        {
            if (m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[Wifi]: warning: someone is trying to change the god password in InstallPostRequest!");
                return m_WebApp.ReadFile(env, "index.html");
            }

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

            if (password == password2)
            {
                UserAccount god = m_UserAccountService.GetUserAccount(UUID.Zero, m_WebApp.AdminFirst, m_WebApp.AdminLast);
                if (god != null)
                {
                    m_AuthenticationService.SetPassword(god.PrincipalID, password);
                    // And this finishes the installation procedure
                    m_WebApp.IsInstalled = true;
                    NotifyWithoutButton(env,
                        string.Format(_("Your Wifi has been installed. The administrator account is {0} {1}", env),
                        m_WebApp.AdminFirst, m_WebApp.AdminLast));
                }
            }
            return m_WebApp.ReadFile(env, "index.html");
        }
예제 #9
0
        public string InstallPostRequest(Environment env, string password, string password2)
        {
            if (m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[Wifi]: warning: someone is trying to change the god password in InstallPostRequest!");
                return(m_WebApp.ReadFile(env, "index.html"));
            }

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

            if (password == password2)
            {
                UserAccount god = m_UserAccountService.GetUserAccount(UUID.Zero, m_WebApp.AdminFirst, m_WebApp.AdminLast);
                if (god != null)
                {
                    m_AuthenticationService.SetPassword(god.PrincipalID, password);
                    // And this finishes the installation procedure
                    m_WebApp.IsInstalled = true;
                    NotifyWithoutButton(env,
                                        string.Format(_("Your Wifi has been installed. The administrator account is {0} {1}", env),
                                                      m_WebApp.AdminFirst, m_WebApp.AdminLast));
                }
            }
            return(m_WebApp.ReadFile(env, "index.html"));
        }
예제 #10
0
        public string InventoryUploadRequest(Environment env, string pathtofile)
        {
            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]: InventoryPostRequest");
            Request request = env.TheRequest;

            SessionInfo sinfo;

            if (TryGetSessionInfo(request, out sinfo))
            {
                env.Session = sinfo;
                if (sinfo.Account.UserLevel >= m_WebApp.IARUserLevel)
                {
                    InventoryArchiveReader reader = new InventoryArchiveReader(m_InventoryService, m_AssetService, m_UserAccountService, sinfo.Account, "/", pathtofile, true);
                    reader.Execute();
                }

                // Send the [new] inventory list
                return(InventoryLoadGetRequest(env));
            }
            else
            {
                return(m_WebApp.ReadFile(env, "index.html"));
            }
        }
예제 #11
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"));
        }
예제 #12
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"));
        }
예제 #13
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"));
            }
        }
        public string ForgotPasswordPostRequest(Environment env, string email)
        {
            UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, email);
            if (account != null)
            {
                string token = m_AuthenticationService.GetToken(account.PrincipalID, 60);
                if (token != string.Empty)
                {
                    string url = m_WebApp.WebAddress + "/wifi/recover/" + token + "?email=" + HttpUtility.UrlEncode(email);

                    string message = string.Format("\n{0}\n{1}\n{2}",
                        string.Format(_("Your account is {0} {1}", env), account.FirstName, account.LastName),
                        _("Click here to reset your password:"******"Password Reset", env), message))
                        NotifyWithoutButton(env, _("Check your email. You must reset your password within 60 minutes.", env));
                    else
                        NotifyWithoutButton(env, _("Email could not be sent.", env));

                    return 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");
            }
        }
        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");
            }
        }
        public string GroupsDeleteGetRequest(Environment env, UUID groupID)
        {
            m_log.DebugFormat("[Wifi]: GroupsDeleteGetRequest {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.GroupDeleteForm;
                    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"));
            }
        }
예제 #19
0
        public override byte[] Handle(string path, Stream requestData,
                                      IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            // path = /wifi/...
            //m_log.DebugFormat("[Wifi]: path = {0}", path);
            //m_log.DebugFormat("[Wifi]: ip address = {0}", httpRequest.RemoteIPEndPoint);
            //foreach (object o in httpRequest.Query.Keys)
            //    m_log.DebugFormat("  >> {0}={1}", o, httpRequest.Query[o]);

            string result = string.Empty;

            try
            {
                Request     request = RequestFactory.CreateRequest(string.Empty, httpRequest, Localization.GetLanguageInfo(httpRequest.Headers.Get("accept-language")));
                Environment env     = new Environment(request);

                result = m_WebApp.Services.LogoutRequest(env);

                httpResponse.ContentType = "text/html";
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[LOGOUT HANDLER]: Exception {0}: {1}", e.Message, e.StackTrace);
            }

            return(WebAppUtils.StringToBytes(result));
        }
        public string GetMainMenu(Environment env)
        {
            if (!m_WebApp.IsInstalled)
            {
                return(m_WebApp.ReadFile(env, "main-menu-install.html"));
            }

            SessionInfo sinfo = env.Session;

            if (sinfo.Account != null)
            {
                if (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel) // Admin
                {
                    return(m_WebApp.ReadFile(env, "main-menu-admin.html"));
                }
                else if (sinfo.Account.UserLevel >= m_WebApp.HyperlinksUserLevel) // Privileged user
                {
                    return(m_WebApp.ReadFile(env, "main-menu-privileged.html"));
                }

                return(m_WebApp.ReadFile(env, "main-menu-users.html", env.Data));
            }

            return(m_WebApp.ReadFile(env, "main-menu.html", env.Data));
        }
예제 #21
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"));
        }
예제 #22
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"));
        }
예제 #23
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"));
        }
예제 #24
0
        public string GetMainMenu(Environment env)
        {
            if (!m_WebApp.IsInstalled)
            {
                return(m_WebApp.ReadFile(env, "main-menu-install.html"));
            }

            SessionInfo sinfo = env.Session;

            if (sinfo.Account != null)
            {
                if (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel) // Admin
                {
                    return(m_WebApp.ReadFile(env, "main-menu-admin.html"));
                }
                else if (sinfo.Account.UserLevel >= m_WebApp.HyperlinksUserLevel) // Privileged user
                {
                    return(m_WebApp.ReadFile(env, "main-menu-privileged.html"));
                }

                return(m_WebApp.ReadFile(env, "main-menu-users.html", env.Data));
            }

            // At the request of Ai Austin, I'm exposing this to users. But just this.
            string[] resources = WebApp.GetPaths("main-menu.html");
            return(WebAppUtils.ReadTextResource(resources, WebApp.MissingPage));
        }
예제 #25
0
        public string GetIARTransfers(Environment env)
        {
            if (env.Session.Account.UserLevel >= m_WebApp.IARUserLevel)
            {
                return(m_WebApp.ReadFile(env, "iars.html", env.Data));
            }

            return(string.Empty);
        }
        public string GetAddonsMenu(Environment env)
        {
            if (!m_WebApp.IsInstalled)
            {
                return(string.Empty);
            }

            // are there any addons?
            if (m_WebApp.Addons.Count > 0)
            {
                SessionInfo sinfo = env.Session;
                if (sinfo.Account != null)
                {
                    if (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel) // Admin
                    {
                        string        addons_menu = Translate(env, "Addons menu");
                        StringBuilder str         = new StringBuilder("<p class=\"nav-headline\">" + addons_menu + "</p><div id=\"addons-menu\">  <ul>");
                        str.Append(System.Environment.NewLine);
                        foreach (WifiAddon a in m_WebApp.Addons)
                        {
                            str.AppendFormat("  <li><a href=\"{0}\">{1}</a></li>{2}", a.Path, a.MenuAnchor, System.Environment.NewLine);
                        }

                        str.Append("  </ul></div>");

                        Processor p = new Processor(m_WebApp.WifiScriptFace, env);
                        return(p.Process(str.ToString()));
                    }
                    else // Everyone else
                    {
                        bool          atLeastOne  = false;
                        string        addons_menu = Translate(env, "Addons menu");
                        StringBuilder str         = new StringBuilder("<p class=\"nav-headline\">" + addons_menu + "</p><div id=\"addons-menu\">  <ul>");
                        str.Append(System.Environment.NewLine);
                        foreach (WifiAddon a in m_WebApp.Addons)
                        {
                            if (a.Privilege == PrivilegeLevel.AllUsers)
                            {
                                atLeastOne = true;
                                str.AppendFormat("  <li><a href=\"{0}\">{1}</a></li>{2}", a.Path, a.MenuAnchor, System.Environment.NewLine);
                            }
                        }
                        str.Append("  </ul></div>");

                        if (atLeastOne)
                        {
                            Processor p = new Processor(m_WebApp.WifiScriptFace, env);
                            return(p.Process(str.ToString()));
                        }

                        return(string.Empty);
                    }
                }
            }

            return(string.Empty);
        }
예제 #27
0
        public string GetHyperlinks(Environment env)
        {
            if (env.Data != null && env.Data.Count > 0)
            {
                return(m_WebApp.ReadFile(env, "linkregionlist.html", env.Data));
            }

            return(_("No linked regions found", env));
        }
예제 #28
0
        public string ConsoleSimulatorsRequest(Environment env)
        {
            m_log.Debug("[Wifi]: ConsoleSimulatorsRequest");
            string result = string.Empty;

            SessionInfo sinfo;

            if (TryGetSessionInfo(env.TheRequest, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                // Retrieve addresses of simulators (and the regions running on them)
                List <GridRegion>        allRegions = m_GridService.GetRegionsByName(UUID.Zero, "", 200);
                List <GridRegion>        hyperlinks = m_GridService.GetHyperlinks(UUID.Zero);
                IEnumerable <GridRegion> regions    = allRegions.Except(hyperlinks);

                NameValueCollection simulators = new NameValueCollection();
                if (regions != null)
                {
                    foreach (GridRegion region in regions)
                    {
                        string address = region.ExternalHostName + ':' + region.HttpPort;
                        simulators.Add(address, region.RegionName);
                    }
                }

                // Create an XML document with the result data
                XmlDocument xmldoc  = new XmlDocument();
                XmlNode     xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
                xmldoc.AppendChild(xmlnode);

                XmlElement rootElement = xmldoc.CreateElement("Wifi");
                xmldoc.AppendChild(rootElement);

                XmlElement simulatorsElement = xmldoc.CreateElement("Simulators");
                rootElement.AppendChild(simulatorsElement);

                foreach (string address in simulators.AllKeys)
                {
                    XmlElement simElement = xmldoc.CreateElement("Simulator");
                    simElement.SetAttribute("HostAddress", address);
                    simulatorsElement.AppendChild(simElement);

                    foreach (string regionName in simulators.GetValues(address))
                    {
                        XmlElement regionElement = xmldoc.CreateElement("Region");
                        simElement.AppendChild(regionElement);

                        XmlElement nameElement = xmldoc.CreateElement("Name");
                        nameElement.AppendChild(xmldoc.CreateTextNode(regionName));
                        regionElement.AppendChild(nameElement);
                    }
                }

                result = xmldoc.InnerXml;
            }
            return(result);
        }
예제 #29
0
        private string GetUserList(Environment env)
        {
            if (env.Data != null && env.Data.Count > 0)
            {
                return(m_WebApp.ReadFile(env, "userlist.html", env.Data));
            }

            return(_("No users found", env));
        }
예제 #30
0
        private string GetRegionManagementForm(Environment env)
        {
            if (env.Data != null && env.Data.Count > 0)
            {
                return(m_WebApp.ReadFile(env, "region-form.html", env.Data));
            }

            return(_("No regions found", env));
        }
        public string ConsoleSimulatorsRequest(Environment env)
        {
            m_log.Debug("[Wifi]: ConsoleSimulatorsRequest");
            string result = string.Empty;

            SessionInfo sinfo;
            if (TryGetSessionInfo(env.TheRequest, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                // Retrieve addresses of simulators (and the regions running on them)
                List<GridRegion> allRegions = m_GridService.GetRegionsByName(UUID.Zero, "", 200);
                List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(UUID.Zero);
                IEnumerable<GridRegion> regions = allRegions.Except(hyperlinks);

                NameValueCollection simulators = new NameValueCollection();
                if (regions != null)
                {
                    foreach (GridRegion region in regions)
                    {
                        string address = region.ExternalHostName + ':' + region.HttpPort;
                        simulators.Add(address, region.RegionName);
                    }
                }

                // Create an XML document with the result data
                XmlDocument xmldoc = new XmlDocument();
                XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
                xmldoc.AppendChild(xmlnode);

                XmlElement rootElement = xmldoc.CreateElement("Wifi");
                xmldoc.AppendChild(rootElement);

                XmlElement simulatorsElement = xmldoc.CreateElement("Simulators");
                rootElement.AppendChild(simulatorsElement);

                foreach (string address in simulators.AllKeys)
                {
                    XmlElement simElement = xmldoc.CreateElement("Simulator");
                    simElement.SetAttribute("HostAddress", address);
                    simulatorsElement.AppendChild(simElement);

                    foreach (string regionName in simulators.GetValues(address))
                    {
                        XmlElement regionElement = xmldoc.CreateElement("Region");
                        simElement.AppendChild(regionElement);

                        XmlElement nameElement = xmldoc.CreateElement("Name");
                        nameElement.AppendChild(xmldoc.CreateTextNode(regionName));
                        regionElement.AppendChild(nameElement);
                    }
                }

                result = xmldoc.InnerXml;
            }
            return result;
        }
예제 #32
0
        public override byte[] Handle(string path, Stream requestData,
                                      IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            // It's a POST, so we need to read the data on the stream, the lines after the blank line
            StreamReader sr   = new StreamReader(requestData);
            string       body = sr.ReadToEnd();

            sr.Close();
            body = body.Trim();

            httpResponse.ContentType = "text/html";

            string resource = GetParam(path);

            //m_log.DebugFormat("[XXX]: query String: {0}; resource: {1}", body, resource);

            try
            {
                // Here the data on the stream is transformed into a nice dictionary of keys & values
                Dictionary <string, object> postdata =
                    ServerUtils.ParseQueryString(body);

                string broadcast_message = String.Empty;
                if (postdata.ContainsKey("message"))
                {
                    broadcast_message = postdata["message"].ToString();
                }

                Request     req = RequestFactory.CreateRequest(resource, httpRequest, Localization.GetLanguageInfo(httpRequest.Headers.Get("accept-language")));
                Environment env = new Environment(req);

                string result = string.Empty;
                if (resource.Equals("/") || resource.Equals(string.Empty))
                {
                }
                else if (resource.StartsWith("/shutdown"))
                {
                    result = m_WebApp.Services.RegionManagementShutdownPostRequest(env);
                }
                else if (resource.StartsWith("/restart"))
                {
                    result = m_WebApp.Services.RegionManagementRestartPostRequest(env);
                }
                else if (resource.StartsWith("/broadcast"))
                {
                    result = m_WebApp.Services.RegionManagementBroadcastPostRequest(env, broadcast_message);
                }
                return(WebAppUtils.StringToBytes(result));
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[REGION MANAGEMENT POST HANDLER]: Exception {0}", e);
            }

            return(WebAppUtils.FailureResult());
        }
        public string NewAccountGetRequest(Environment env)
        {
            m_log.DebugFormat("[Wifi]: NewAccountGetRequest");
            Request request = env.TheRequest;

            env.State = State.NewAccountForm;
            env.Data = GetDefaultAvatarSelectionList();

            return m_WebApp.ReadFile(env, "index.html");
        }
예제 #34
0
        public string NewAccountGetRequest(Environment env)
        {
            m_log.DebugFormat("[Wifi]: NewAccountGetRequest");
            Request request = env.TheRequest;

            env.State = State.NewAccountForm;
            env.Data  = GetDefaultAvatarSelectionList();

            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"));
            }
        }
        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");
            }
        }
예제 #37
0
        public string GetConsolePass(Environment env)
        {
            SessionInfo sinfo = env.Session;

            if (sinfo.Account != null && sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)
            {
                return(m_WebApp.ConsolePass);
            }

            return(string.Empty);
        }
예제 #38
0
        public string GetUserName(Environment env)
        {
            SessionInfo sinfo = env.Session;

            if (sinfo.Account != null)
            {
                return(sinfo.Account.FirstName + " " + sinfo.Account.LastName);
            }

            return(_("Who are you?", env));
        }
예제 #39
0
        public string GetNotificationType(Environment env)
        {
            SessionInfo sinfo = env.Session;

            if (sinfo.Notify.FollowUp == null)
            {
                return("hidden");
            }

            return("submit");
        }
        public string ConsoleHeartbeat(Environment env)
        {
            m_log.DebugFormat("[Wifi]: ConsoleHeartbeat");
            SessionInfo sinfo;
            if (TryGetSessionInfo(env.TheRequest, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                // Reset session timer
                m_Sessions.Update(sinfo.Sid, sinfo, m_WebApp.SessionTimeout);
            }

            return string.Empty;
        }
        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");
        }
        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));
        }
        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");
        }
        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");
        }
        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"));
        }
        public override byte[] Handle(string path, Stream requestData,
                IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            // This is the content type of the response. Don't forget to set it to this in all your handlers.
            httpResponse.ContentType = "text/html";

            string resource = GetParam(path);
            //m_log.DebugFormat("[NOTIFY HANDLER]: resource {1}", resource);
            Request request = RequestFactory.CreateRequest(resource, httpRequest, Localization.GetLanguageInfo(httpRequest.Headers.Get("accept-language")));
            Environment env = new Environment(request);

            string result = string.Empty;
            try
            {
                result = m_WebApp.Services.NotifyRequest(env);
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[NOTIFY HANDLER]: Exception {0}: {1}", e.Message, e.StackTrace);
            }

            return WebAppUtils.StringToBytes(result);
        }
예제 #47
0
        public string GetUserEmail(Environment env)
        {
            SessionInfo sinfo = env.Session;
            if (sinfo.Account != null)
            {
                if (sinfo.Account.Email == string.Empty)
                    return _("No email on file", env);

                return sinfo.Account.Email;
            }

            return _("Who are you?", env);
        }
예제 #48
0
        public string GetRefresh(Environment env)
        {
            const string redirect = "<meta http-equiv=\"refresh\" content=\"{0}; URL={1}/?sid={2}\" />";

            if (env.State == State.Notification)
            {
                SessionInfo sinfo = env.Session;
                if (sinfo.Sid != null && sinfo.Notify.RedirectDelay >= 0)
                    return string.Format(redirect, sinfo.Notify.RedirectDelay, sinfo.Notify.RedirectUrl, sinfo.Sid);
            }
            return string.Empty;
        }
예제 #49
0
        public string GetPendingUserList(Environment env)
        {
            SessionInfo sinfo = env.Session;
            if (env.Data != null && env.Data.Count > 0 &&
                sinfo.Account != null && sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)
                return m_WebApp.ReadFile(env, "userpendinglist.html", env.Data);

            return string.Empty;
        }
예제 #50
0
        public string GetNotificationType(Environment env)
        {
            SessionInfo sinfo = env.Session;
            if (sinfo.Notify.FollowUp == null)
                return "hidden";

            return "submit";
        }
예제 #51
0
        private string GetUserList(Environment env)
        {
            if (env.Data != null && env.Data.Count > 0)
                return m_WebApp.ReadFile(env, "userlist.html", env.Data);

            return _("No users found", env);
        }
예제 #52
0
 private static string _(string textId, Environment env)
 {
     return Localization.Translate(env, textId);
 }
예제 #53
0
        public string GetContent(Environment env)
        {
            //m_log.DebugFormat("[WifiScriptFace]: GetContent, flags {0} ({1})", env.State, (uint)env.State);
            if ((uint)env.State < 50)
            {

                if (env.State == State.InstallForm)
                    return m_WebApp.ReadFile(env, "installform.html");

                if (env.State == State.ForgotPassword)
                    return m_WebApp.ReadFile(env, "forgotpasswordform.html");
                if (env.State == State.RecoveringPassword)
                    return m_WebApp.ReadFile(env, "recoveringpassword.html");
                //if (env.State == State.BadPassword)
                //    return "<p>The password must be at least 3 characters.</p>";

                if (env.State == State.NewAccountForm || env.State == State.NewAccountFormRetry)
                    return m_WebApp.ReadFile(env, "newaccountform.html", env.Data);

                if (env.State == State.Notification)
                    return m_WebApp.ReadFile(env, "notification.html", env.Data);

                if (env.State == State.GetTOS)
                    return m_WebApp.ReadFile(env, "tos.html", env.Data);

                if (env.State == State.AcceptTOS)
                    return "Thank you and enjoy your visit!";

                if ((env.Flags & Flags.IsLoggedIn) != 0)
                {
                    if (env.State == State.UserAccountForm)
                        return m_WebApp.ReadFile(env, "useraccountform.html", env.Data);

                    if (env.State == State.UserSearchForm)
                        return m_WebApp.ReadFile(env, "usersearchform.html", env.Data);
                    if (env.State == State.UserSearchFormResponse)
                        return GetUserList(env);

                    if (env.State == State.UserEditForm)
                        return m_WebApp.ReadFile(env, "usereditform.html", env.Data);

                    if (env.State == State.UserDeleteForm)
                        return m_WebApp.ReadFile(env, "userdeleteform.html", env.Data);

                    if (env.State == State.HyperlinkList)
                        return GetHyperlinks(env);
                    if (env.State == State.HyperlinkListForm)
                        return m_WebApp.ReadFile(env, "linkregionform.html", env.Data);
                    if (env.State == State.HyperlinkDeleteForm)
                        return m_WebApp.ReadFile(env, "linkregiondeleteform.html", env.Data);

                    if (env.State == State.RegionManagementForm)
                        return GetRegionManagementForm(env);
                    if (env.State == State.RegionManagementSuccessful)
                        return "Success! Back to <a href=\"/wifi/admin/regions\">Region Management Page</a>";
                    if (env.State == State.RegionManagementUnsuccessful)
                        return "Action could not be performed. Please check if the server is running.<br/>Back to <a href=\"/wifi/admin/regions\">Region Management Page</a>";

                    if (env.State == State.InventoryListForm)
                        return m_WebApp.ReadFile(env, "inventorylist.html", env.Data);

                    if (env.State == State.Console)
                        return m_WebApp.ReadFile(env, "console.html", env.Data);

                    if (env.State == State.GroupsList)
                        return m_WebApp.ReadFile(env, "groupslist.html", env.Data);
                    if (env.State == State.GroupEditForm)
                        return m_WebApp.ReadFile(env, "groupeditform.html", env.Data);
                    if (env.State == State.GroupDeleteForm)
                        return m_WebApp.ReadFile(env, "groupdeleteform.html", env.Data);

                }
            }
            else // try the addons
            {
                foreach (WifiAddon addon in m_WebApp.Addons)
                {
                    string result;
                    if ((result = addon.Addon.GetContent(env)) != null)
                        return result;
                }
            }

            return string.Empty;
        }
예제 #54
0
        public string GetUserImage(Environment env)
        {
            SessionInfo sinfo = env.Session;
            if (sinfo.Account != null)
            {
                // TODO
                return "/wifi/images/abstract-cool.jpg";
            }

            // TODO
            return "/wifi/images/abstract-cool.jpg";
        }
예제 #55
0
        public string GetUserName(Environment env)
        {
            SessionInfo sinfo = env.Session;
            if (sinfo.Account != null)
            {
                return sinfo.Account.FirstName + " " + sinfo.Account.LastName;
            }

            return _("Who are you?", env);
        }
예제 #56
0
        public string GetIARTransfers(Environment env)
        {
            if (env.Session.Account.UserLevel >= m_WebApp.IARUserLevel)
                return m_WebApp.ReadFile(env, "iars.html", env.Data);

            return string.Empty;
        }
예제 #57
0
        private string GetRegionManagementForm(Environment env)
        {
            if (env.Data != null && env.Data.Count > 0)
                return m_WebApp.ReadFile(env, "region-form.html", env.Data);

            return _("No regions found", env);
        }
예제 #58
0
        public string GetLoginLogout(Environment env)
        {
            if (!m_WebApp.IsInstalled)
                return string.Empty;

            SessionInfo sinfo = env.Session;
            if (sinfo.Account != null)
                return m_WebApp.ReadFile(env, "logout.html", env.Data);

            return m_WebApp.ReadFile(env, "login.html", env.Data);
        }
예제 #59
0
        public string GetHyperlinks(Environment env)
        {
            if (env.Data != null && env.Data.Count > 0)
                return m_WebApp.ReadFile(env, "linkregionlist.html", env.Data);

            return _("No linked regions found", env);
        }
예제 #60
0
        public string GetMainMenu(Environment env)
        {
            if (!m_WebApp.IsInstalled)
                return m_WebApp.ReadFile(env, "main-menu-install.html");

            SessionInfo sinfo = env.Session;
            if (sinfo.Account != null)
            {
                if (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel) // Admin
                    return m_WebApp.ReadFile(env, "main-menu-admin.html");
                else if (sinfo.Account.UserLevel >= m_WebApp.HyperlinksUserLevel) // Privileged user
                    return m_WebApp.ReadFile(env, "main-menu-privileged.html");

                return m_WebApp.ReadFile(env, "main-menu-users.html", env.Data);
            }

            // At the request of Ai Austin, I'm exposing this to users. But just this.
            string[] resources = WebApp.GetPaths("main-menu.html");
            return WebAppUtils.ReadTextResource(resources, WebApp.MissingPage);
        }