Exemplo n.º 1
0
        public string InstallPostRequest(Environment env, string password, string password2)
        {
            if (m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[AuroraWeb]: warning: someone is trying to change the god password in InstallPostRequest!");
                return m_WebApp.ReadFile(env, "index.html");
            }

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

            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");
        }
        public string UserAccountPostRequest(Environment env, UUID userID, string email, string oldpassword, string newpassword, string newpassword2)
        {
            if (!m_WebApp.IsInstalled)
            {
                MainConsole.Instance.DebugFormat("[AuroraWeb]: warning: someone is trying to access UserAccountPostRequest and Wifi isn't isntalled!");
                return m_WebApp.ReadFile(env, "index.html");
            }
            MainConsole.Instance.DebugFormat("[AuroraWeb]: UserAccountPostRequest");
            Request request = env.Request;

            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 = Util.Md5Hash(oldpassword);
                if ((newpassword != string.Empty) && (newpassword == newpassword2) &&
                    m_AuthenticationService.Authenticate(sinfo.Account.PrincipalID, "UserAccount",encpass, 30) != string.Empty)
                {
                    m_AuthenticationService.SetPassword(sinfo.Account.PrincipalID,"UserAccount", newpassword);
                    updated = true;
                }

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

                // nothing was updated, really
                env.Flags = Flags.IsLoggedIn;
                env.State = State.UserAccountForm;
                return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }
            else
            {
                MainConsole.Instance.DebugFormat("[AuroraWeb]: Failed to get session info");
                return m_WebApp.ReadFile(env, "index.html");
            }
        }
Exemplo n.º 3
0
        public string DefaultRequest(Environment env)
        {
            MainConsole.Instance.DebugFormat("[AuroraWeb]: DefaultRequest");

            SessionInfo sinfo;
            if (TryGetSessionInfo(env.Request, out sinfo))
            {
                env.Session = sinfo;
                env.Flags = Flags.IsLoggedIn;
                env.State = State.Default;
                return 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.º 4
0
        public byte[] Handle(string path, Stream requestData,
                RequestFactory.IOSHttpRequest httpRequest, WifiConsoleHandler.IOSHttpResponse httpResponse)
        {
            // path = /wifi/...
            //m_log.DebugFormat("[AuroraWeb]: path = {0}", path);
            //m_log.DebugFormat("[AuroraWeb]: 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("[INVENTORY HANDLER HANDLER GET]: resource {0}", resource);

            Request request = RequestFactory.CreateRequest(string.Empty, httpRequest);
            AuroraWeb.Environment env = new Environment(request);

            string result = m_WebApp.Services.InventoryGetRequest(env);

            return WebAppUtils.StringToBytes(result);
        }
Exemplo n.º 5
0
        public string HyperlinkAddRequest(Environment env, string address, uint xloc, uint yloc)
        {
            m_log.Debug("[AuroraWeb]: HyperlinkAddRequest");

            SessionInfo sinfo;
            if (TryGetSessionInfo(env.Request, 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 PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }
            return m_WebApp.ReadFile(env, "index.html");
        }
Exemplo n.º 6
0
 private static string _(string textId, Environment env)
 {
     return Localization.Translate(env, textId);
 }
Exemplo n.º 7
0
        public string HyperlinkGetRequest(Environment env)
        {
            m_log.Debug("[AuroraWeb]: HyperlinkGetRequest");

            SessionInfo sinfo;
            if (TryGetSessionInfo(env.Request, 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 PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }
            return m_WebApp.ReadFile(env, "index.html");
        }
Exemplo n.º 8
0
 private List<object> GetHyperlinks(Environment env, UUID owner)
 {
     string hyperlinks = AuroraWeb.WifiScriptFace.GetHyperlinks(null);
     List<UserAccount> links = new List<UserAccount>();
     if (hyperlinks != null)
     {
         foreach (UserAccount region in links)
         {
             UserAccount link = new UserAccount();
             if (m_WebApp.HyperlinksShowAll ||
                 (env.Flags & Flags.IsAdmin) != 0 )/*||
                 (link.RegionOwnerID == owner) ||
                 (link.RegionOwnerID == UUID.Zero))*/
             {
                 //if (link.RegionOwnerID != UUID.Zero)
                 //{
                     //UserAccount user = m_UserAccountService.GetUserAccount(UUID.Zero, link.RegionOwnerID);
                     //if (user != null)
                       //  link.RegionOwner = user.Name;
                 //}
                 links.Add(link);
             }
         }
     }
     return Objectify<RegionInfo>(links);
 }
Exemplo n.º 9
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);
            }

            return m_WebApp.ReadFile(env, "main-menu.html", env.Data);
        }
Exemplo n.º 10
0
        public string HyperlinkDeletePostRequest(Environment env, UUID regionID)
        {
            m_log.DebugFormat("[AuroraWeb]: HyperlinkDeletePostRequest {0}", regionID);

            SessionInfo sinfo;
            if (TryGetSessionInfo(env.Request, 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
                    var region = m_GridService.GetRegionByUUID(UUID.Zero, regionID);
                    if (region != null)
                    {
                        if ((sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)) //||(GridRegion.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 failed.", env)),
                                    delegate(Environment e) { return HyperlinkGetRequest(e); });
                        }
                        else
                            m_log.WarnFormat("[AuroraWeb]: Unauthorized attempt to delete hyperlink by {0} ({1})",
                                sinfo.Account.Name, sinfo.Account.PrincipalID);
                    }
                    else
                    {
                        m_log.WarnFormat("[AuroraWeb]: 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 PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }
            return m_WebApp.ReadFile(env, "index.html");
        }
Exemplo n.º 11
0
        private void SetAvatar(Environment env, UUID newUser, string avatarType)
        {
            UserAccount account = null;
            string[] parts = null;

            AuroraWeb.Avatar defaultAvatar = m_WebApp.DefaultAvatars.FirstOrDefault(av => av.Type.Equals(avatarType));
            if (defaultAvatar.Name != null)
                parts = defaultAvatar.Name.Split(new char[] { ' ' });

            if (parts == null || (parts != null && parts.Length != 2))
                return;

            account = m_UserAccountService.GetUserAccount(UUID.Zero, parts[0], parts[1]);
            if (account == null)
            {
                m_log.WarnFormat("[AuroraWeb]: Tried to get avatar of account {0} {1} but that account does not exist", parts[0], parts[1]);
                return;
            }

            AvatarData avatar = m_AvatarService.GetAvatar(account.PrincipalID);

            if (avatar == null)
            {
                m_log.WarnFormat("[AuroraWeb]: Avatar of account {0} {1} is null", parts[0], parts[1]);
                return;
            }

            m_log.DebugFormat("[AuroraWeb]: Creating {0} avatar (account {1} {2})", avatarType, parts[0], parts[1]);

            // Get and replicate the attachments
            // and put them in a folder named after the avatar type under Clothing
            string folderName = _("Default Avatar", env) + " " + _(defaultAvatar.PrettyType, env);
            UUID defaultFolderID = CreateDefaultAvatarFolder(newUser, folderName.Trim());

            if (defaultFolderID != UUID.Zero)
            {
                Dictionary<string, string> attchs = new Dictionary<string, string>();
                foreach (KeyValuePair<string, string> _kvp in avatar.Data)
                {
                    if (_kvp.Value != null)
                    {
                        string itemID = CreateItemFrom(_kvp.Value, newUser, defaultFolderID);
                        if (itemID != string.Empty)
                            attchs[_kvp.Key] = itemID;
                    }
                }

                foreach (KeyValuePair<string, string> _kvp in attchs)
                    avatar.Data[_kvp.Key] = _kvp.Value;

                m_AvatarService.SetAvatar(newUser, avatar);
            }
            else
                m_log.Debug("[AuroraWeb]: could not create folder " + folderName);

            // Set home and last location for new account
            // Config setting takes precedence over home location of default avatar
            PrepareHomeLocation();
            UUID homeRegion = AuroraWeb.Avatar.HomeRegion;
            Vector3 position = AuroraWeb.Avatar.HomeLocation;
            Vector3 lookAt = new Vector3();
            if (homeRegion == UUID.Zero)
            {
                LLLoginService.GridUserInfo userInfo = m_GridUserService.GetGridUserInfo(account.PrincipalID.ToString());
                if (userInfo != null)
                {
                    homeRegion = userInfo.HomeRegionID;
                    position = userInfo.HomePosition;
                    lookAt = userInfo.HomeLookAt;
                }
            }
            if (homeRegion != UUID.Zero)
            {
                m_GridUserService.SetHome(newUser.ToString(), homeRegion, position, lookAt);
                m_GridUserService.SetLastPosition(newUser.ToString(), UUID.Zero, homeRegion, position, lookAt);
            }
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        public byte[] Handle(string path, Stream requestData,
                RequestFactory.IOSHttpRequest httpRequest, WifiConsoleHandler.IOSHttpResponse httpResponse)
        {
            // path = /wifi/...
            //m_log.DebugFormat("[AuroraWeb]: path = {0}", path);
            //m_log.DebugFormat("[AuroraWeb]: 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("[INVENTORY HANDLER POST]: resource {0}", resource);

            StreamReader sr = new StreamReader(requestData);
            string body = sr.ReadToEnd();
            sr.Close();
            body = body.Trim();
            Dictionary<string, object> postdata =
                    WebUtils.ParseQueryString(body);

            Request request = RequestFactory.CreateRequest(string.Empty, httpRequest);
            AuroraWeb.Environment env = new Environment(request);

            string action = postdata.Keys.FirstOrDefault(key => key.StartsWith("action-"));
            if (action == null)
                action = string.Empty;
            else
                action = action.Substring("action-".Length);

            string folder = string.Empty;
            string newFolderName = string.Empty;
            List<string> nodes = new List<string>();
            List<string> types = new List<string>();

            if (postdata.ContainsKey("folder"))
                folder = postdata["folder"].ToString();
            if (postdata.ContainsKey("newFolderName"))
                newFolderName = postdata["newFolderName"].ToString();
            foreach (KeyValuePair<string, object> kvp in postdata)
            {
                if (kvp.Key.StartsWith("inv-"))
                {
                    nodes.Add(kvp.Key.Substring(4));
                    types.Add(kvp.Value.ToString());
                }
            }

            return WebAppUtils.StringToBytes(m_WebApp.Services.InventoryPostRequest(env, action, folder, newFolderName, nodes, types));
        }
Exemplo n.º 14
0
        public byte[] Handle(string path, Stream requestData,
                RequestFactory.IOSHttpRequest httpRequest, WifiConsoleHandler.IOSHttpResponse httpResponse)
        {
            // path = /wifi/...
            //m_log.DebugFormat("[AuroraWeb]: path = {0}", path);
            //m_log.DebugFormat("[AuroraWeb]: ip address = {0}", httpRequest.RemoteIPEndPoint);
            //foreach (object o in httpRequest.Query.Keys)
            //    m_log.DebugFormat("  >> {0}={1}", o, httpRequest.Query[o]);

            string resource = GetParam(path);
            //m_log.DebugFormat("[AuroraWeb]: resource {0}", resource);
            resource = Uri.UnescapeDataString(resource).Trim(WebAppUtils.DirectorySeparatorChars);

            Request request = RequestFactory.CreateRequest(resource, httpRequest);
            AuroraWeb.Environment env = new AuroraWeb.Environment(request);

            if (resource == string.Empty || resource.StartsWith("index."))
            {
                if (m_WebApp.StatisticsUpdateInterval != TimeSpan.Zero)
                    m_WebApp.Services.ComputeStatistics();

                httpResponse.ContentType = "text/html";

                return WebAppUtils.StringToBytes(m_WebApp.Services.DefaultRequest(env));
            }
            else
            {
                string resourcePath = System.IO.Path.Combine(WebApp.DocsPath, resource);
                string type = WebAppUtils.GetContentType(resource);
                httpResponse.ContentType = type;
                //m_log.DebugFormat("[AuroraWeb]: ContentType {0}", type);
                if (type.StartsWith("image"))
                    return WebAppUtils.ReadBinaryResource(resourcePath);

                if (type.StartsWith("application"))
                {
                    string res = WebAppUtils.ReadTextResource(resourcePath, true);
                    return WebAppUtils.StringToBytes(res);
                }
                if (type.StartsWith("text"))
                {
                    if (m_WebApp.StatisticsUpdateInterval != TimeSpan.Zero)
                        m_WebApp.Services.ComputeStatistics();

                    resourcePath = Localization.LocalizePath(env, resource);
                    Processor p = new Processor(m_WebApp.WifiScriptFace, env);
                    string res = p.Process(WebAppUtils.ReadTextResource(resourcePath));
                    if (res == string.Empty)
                        res = m_WebApp.Services.DefaultRequest(env);
                    return WebAppUtils.StringToBytes(res);
                }
            }

            httpResponse.ContentType = "text/plain";
            string result = "Boo!";
            return WebAppUtils.StringToBytes(result);
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
0
        public string HyperlinkDeleteGetRequest(Environment env, UUID regionID)
        {
            m_log.DebugFormat("[AuroraWeb]: HyperlinkDeleteGetRequest {0}", regionID);

            SessionInfo sinfo;
            if (TryGetSessionInfo(env.Request, 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)
                {
                    var region = m_GridService.GetRegionByUUID(UUID.Zero, regionID);
                    if (region != null)
                    {
                        GridRegion eOwner = null;
                        if (((env.Flags & Flags.IsAdmin) != 0)) //|| (eOwner == sinfo.Account.PrincipalID))
                        {
                            RegionInfo link = new RegionInfo(eOwner);
                            UserAccount user = sinfo.Account;
                            //if (user != 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("[AuroraWeb]: Unauthorized attempt to delete hyperlink by {0} ({1})",
                                sinfo.Account.Name, sinfo.Account.PrincipalID);
                    }
                    else
                    {
                        m_log.WarnFormat("[AuroraWeb]: 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 PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
        }
Exemplo n.º 17
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";
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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;
        }
Exemplo n.º 20
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;
        }
Exemplo n.º 21
0
        public string GetNotificationType(Environment env)
        {
            SessionInfo sinfo = env.Session;
            if (sinfo.Notify.FollowUp == null)
                return "hidden";

            return "submit";
        }
Exemplo n.º 22
0
        public byte[] Handle(string path, Stream requestData,
                RequestFactory.IOSHttpRequest httpRequest, WifiConsoleHandler.IOSHttpResponse httpResponse)
        {
            Request request = RequestFactory.CreateRequest(string.Empty, httpRequest);
            AuroraWeb.Environment env = new Environment(request);

            string resource = GetParam(path);
            //m_log.DebugFormat("[XXX]: resource {0}", resource);

            string result = m_WebApp.Services.InventoryLoadGetRequest(env);
            httpResponse.ContentType = "text/html";

            return WebAppUtils.StringToBytes(result);
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
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);
        }
Exemplo n.º 25
0
        public string GetConsoleUser(Environment env)
        {
            SessionInfo sinfo = env.Session;
            if (sinfo.Account != null && sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)
                return m_WebApp.ConsoleUser;

            return string.Empty;
        }
Exemplo n.º 26
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.Request);
                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;
        }
Exemplo n.º 27
0
        public string LogoutRequest(Environment env)
        {
            m_log.DebugFormat("[AuroraWeb]: LogoutRequest");
            Request request = env.Request;

            SessionInfo sinfo;
            if (TryGetSessionInfo(request, out sinfo))
            {
                m_Sessions.Remove(sinfo.Sid);
                m_AuthenticationService.Release(sinfo.Account.PrincipalID, "", sinfo.Sid);
            }

            env.State = State.Default;
            return m_WebApp.ReadFile(env, "index.html");
        }
Exemplo n.º 28
0
        public static 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);
        }
Exemplo n.º 29
0
        public string GetContent(Environment env)
        {
            //m_log.DebugFormat("[WifiScriptFace]: GetContent, flags {0} ({1})", env.State, (uint)env.State);

            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.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)
                //{
                //    string invListStr = string.Empty;
                //    if (env.Data.Count > 0)
                //    {
                //        InventoryTreeNode tree = (InventoryTreeNode)env.Data[0];
                //        if (tree.Children != null)
                //        {
                //            List<object> loo = new List<object>();
                //            foreach (InventoryTreeNode node in tree.Children)
                //            {
                //                m_log.DebugFormat("--> {0}", node.Name);
                //                loo.Add(node);
                //                invListStr += m_WebApp.ReadFile(env, "inventorylist.html", loo);
                //            }
                //            return invListStr;
                //        }
                //    }
                    return m_WebApp.ReadFile(env, "inventorylist.html", env.Data);
            //    }

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

            return string.Empty;
        }