public string InventoryGetRequest(AuroraWeb.Environment env) { if (!m_WebApp.IsInstalled) { m_log.DebugFormat("[AuroraWeb]: warning: someone is trying to access UserAccountGetRequest and Wifi isn't isntalled!"); return m_WebApp.ReadFile(env, "index.html"); } m_log.DebugFormat("[AuroraWeb]: InventoryGetRequest"); Request request = env.Request; 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 PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } else { return m_WebApp.ReadFile(env, "index.html"); } }
public string ForgotPasswordPostRequest(AuroraWeb.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(AuroraWeb.Environment env, UUID userID) { if (!m_WebApp.IsInstalled) { MainConsole.Instance.DebugFormat("[AuroraWeb]: warning: someone is trying to access UserAccountGetRequest and Wifi isn't isntalled!"); return m_WebApp.ReadFile(env, "index.html"); } MainConsole.Instance.DebugFormat("[AuroraWeb]: UserAccountGetRequest"); Request request = env.Request; 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 PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } else { return m_WebApp.ReadFile(env, "index.html"); } }
public string NewAccountGetRequest(AuroraWeb.Environment env) { m_log.DebugFormat("[AuroraWeb]: NewAccountGetRequest"); Request request = env.Request; env.State = State.NewAccountForm; env.Data = GetDefaultAvatarSelectionList(); return m_WebApp.ReadFile(env, "index.html"); }
public string RecoverPasswordGetRequest(AuroraWeb.Environment env, string email, string token) { UserAccount account = null; if (IsValidToken(email, token, out account)) { PasswordRecoveryData precovery = new PasswordRecoveryData(email, token); env.Data = new List<object>(); env.Data.Add(precovery); env.State = State.RecoveringPassword; return m_WebApp.ReadFile(env, "index.html"); } else { return "<p>" + _("Invalid token.", env) + "</p>"; } }
public string InventoryLoadGetRequest(AuroraWeb.Environment env) { MainConsole.Instance.DebugFormat("[AuroraWeb]: InventoryLoadGetRequest"); SessionInfo sinfo; if (TryGetSessionInfo(env.Request, out sinfo)) { env.Session = sinfo; env.Flags = Flags.IsLoggedIn; string message = string.Format("{0} <img src=\"/wifi/images/loader.gif\" /><p>{1}</p>", _("Loading your inventory, please wait", env), _("If your browser does not automatically load the next page, then use the button, please.", env)); NotifyWithRedirect(env, message, _("continue", env), 0, "/wifi/user/inventory", delegate(Environment e) { return InventoryGetRequest(e); }); return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } return m_WebApp.ReadFile(env, "index.html"); }
public string RegionManagementBroadcastPostRequest(AuroraWeb.Environment env, string message) { Request request = env.Request; 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("[AuroraWeb]: Exception " + e.Message); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; env.State = State.RegionManagementUnsuccessful; } return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } return m_WebApp.ReadFile(env, "index.html"); }
public string LoginRequest(AuroraWeb.Environment env, string first, string last, string password) { if (!m_WebApp.IsInstalled) { m_log.DebugFormat("[AuroraWeb]: warning: someone is trying to access LoginRequest and Wifi isn't installed!"); return m_WebApp.ReadFile(env, "index.html"); } m_log.DebugFormat("[AuroraWeb]: LoginRequest {0} {1}", first, last); Request request = env.Request; string encpass = 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 AuroraWeb.Services.NotificationData(); m_Sessions.Add(authtoken, sinfo, m_WebApp.SessionTimeout); env.Request.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); } AuroraWeb.Services.NotifyWithoutButton(env, notification); return PadURLs(env, authtoken, m_WebApp.ReadFile(env, "index.html")); }
public string ReadFile(AuroraWeb.Environment env, string path) { return ReadFile(env, path, env.Data); }
public string ForgotPasswordGetRequest(AuroraWeb.Environment env) { m_log.DebugFormat("[AuroraWeb]: ForgotPasswordGetRequest"); env.State = State.ForgotPassword; return m_WebApp.ReadFile(env, "index.html"); }
public string UserActivateGetRequest(AuroraWeb.Environment env, UUID userID) { m_log.DebugFormat("[AuroraWeb]: UserActivateGetRequest {0}", userID); Request request = env.Request; SessionInfo sinfo; if (TryGetSessionInfo(request, out sinfo) && (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)) { env.Session = sinfo; env.Flags = Flags.IsLoggedIn | Flags.IsAdmin; NotifyWithoutButton(env, _("The account has been activated.", env)); UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, userID); if (account != null) { // Remove pending identifier in name //account.FirstName = account.FirstName.Replace(m_PendingIdentifier, ""); // Retrieve saved user data from serviceURLs and set them back to normal string password = (string)account.ServiceURLs["Password"]; account.ServiceURLs.Remove("Password"); Object value; account.ServiceURLs.TryGetValue("Avatar", out value); account.ServiceURLs.Remove("Avatar"); string avatarType = (string)value; CultureInfo[] languages = null; if (account.ServiceURLs.TryGetValue("Language", out value)) languages = Localization.GetLanguageInfo((string)value); account.ServiceURLs.Remove("Language"); // Save changes to user account m_UserAccountService.StoreUserAccount(account); // Create the inventory m_InventoryService.CreateUserInventory(account.PrincipalID, true); // Set the password m_AuthenticationService.SetPassword(account.PrincipalID,"UserAccount", password); // Set the avatar if (avatarType != null) { SetAvatar(env, account.PrincipalID, avatarType); } if (account.Email != string.Empty) { string message = string.Format("{0}\n\n{1} {2}\n{3} {4}\n\n{5} {6}", _("Your account has been activated.", languages), _("First name:", languages), account.FirstName, _("Last name:", languages), account.LastName, _("LoginURI:", languages), m_WebApp.LoginURL); SendEMail(account.Email, _("Account activated", languages), message); } } return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } return m_WebApp.ReadFile(env, "index.html"); }
public string UserSearchPostRequest(AuroraWeb.Environment env, string terms) { m_log.DebugFormat("[AuroraWeb]: UserSearchPostRequest"); Request request = env.Request; 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 var accounts = m_UserAccountService.GetActiveAccounts(UUID.Zero, terms, m_PendingIdentifier); env.Data = Objectify<UserAccount>(null); return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } else return UserManagementGetRequest(env); } return m_WebApp.ReadFile(env, "index.html"); }
public string UserManagementGetRequest(AuroraWeb.Environment env) { m_log.DebugFormat("[AuroraWeb]: UserManagementGetRequest"); Request request = env.Request; SessionInfo sinfo; if (TryGetSessionInfo(request, out sinfo) && (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)) { env.Session = sinfo; env.Flags = Flags.IsLoggedIn | Flags.IsAdmin; env.State = State.UserSearchForm; env.Data = GetUserList(env, m_PendingIdentifier); return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } return m_WebApp.ReadFile(env, "index.html"); }
public string UserEditPostRequest(AuroraWeb.Environment env, UUID userID, string password) { m_log.DebugFormat("[AuroraWeb]: UserEditPostRequest (password) {0}", userID); Request request = env.Request; 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, "UserAccount",password); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; NotifyWithoutButton(env, _("The account has been updated.", env)); m_log.DebugFormat("[AuroraWeb]: Updated account for user {0}", account.Name); } else { NotifyWithoutButton(env, _("The account does not exist.", env)); m_log.DebugFormat("[AuroraWeb]: Attempt at updating an inexistent account"); } return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } return m_WebApp.ReadFile(env, "index.html"); }
public string NewAccountPostRequest(AuroraWeb.Environment env, string first, string last, string email, string password, string password2, string avatarType) { if (!m_WebApp.IsInstalled) { m_log.DebugFormat("[AuroraWeb]: warning: someone is trying to access NewAccountPostRequest and Wifi isn't installed!"); return m_WebApp.ReadFile(env, "index.html"); } m_log.DebugFormat("[AuroraWeb]: NewAccountPostRequest"); Request request = env.Request; if ((password != string.Empty) && (password == password2) && (first != string.Empty) && (last != string.Empty)) { UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, first, last); if (account == null) account = m_UserAccountService.GetUserAccount(UUID.Zero, m_PendingIdentifier + first, last); if (account == null) { Dictionary<string, object> urls = new Dictionary<string, object>(); if (m_WebApp.AccountConfirmationRequired) { //attach pending identifier to first name first = m_PendingIdentifier + first; // Store the password temporarily here urls["Password"] = password; urls["Avatar"] = avatarType; if (env.LanguageInfo != null) urls["Language"] = Localization.LanguageInfoToString(env.LanguageInfo); } // Create the account string name = first + " " + last; account = new UserAccount(UUID.Zero, name, email); account.ServiceURLs = urls; account.UserTitle = "Local User"; m_UserAccountService.StoreUserAccount(account); string notification = _("Your account has been created.", env); if (!m_WebApp.AccountConfirmationRequired) { // Create the inventory m_InventoryService.CreateUserInventory(account.PrincipalID, true); // Store the password m_AuthenticationService.SetPassword(account.PrincipalID, "",password); // Set avatar SetAvatar(env, account.PrincipalID, avatarType); } else if (m_WebApp.AdminEmail != string.Empty) { string message = string.Format( _("New account {0} {1} created in {2} is awaiting your approval.", m_WebApp.AdminLanguage), first, last, m_WebApp.GridName); message += "\n\n" + m_WebApp.WebAddress + "/wifi"; SendEMail( m_WebApp.AdminEmail, _("Account awaiting approval", m_WebApp.AdminLanguage), message); notification = _("Your account awaits administrator approval.", env); } AuroraWeb.Services.NotifyWithoutButton(env, notification); m_log.DebugFormat("[AuroraWeb]: Created account for user {0}", account.Name); } else { m_log.DebugFormat("[AuroraWeb]: Attempt at creating an account that already exists"); env.State = State.NewAccountForm; env.Data = GetDefaultAvatarSelectionList(); } } else { m_log.DebugFormat("[AuroraWeb]: did not create account because of password and/or user name problems"); env.State = State.NewAccountForm; env.Data = GetDefaultAvatarSelectionList(); } return m_WebApp.ReadFile(env, "index.html"); }
public string RecoverPasswordPostRequest(AuroraWeb.Environment env, string email, string token, string newPassword) { if (newPassword == null || newPassword.Length < 3) { env.State = State.RecoveringPassword; return m_WebApp.ReadFile(env, "index.html"); } ResetPassword(email, token, newPassword); NotifyWithoutButton(env, _("Your password has been reset.", env)); return m_WebApp.ReadFile(env, "index.html"); }
public string RegionManagementGetRequest(AuroraWeb.Environment env) { m_log.DebugFormat("[Services]: RegionManagementGetRequest()"); Request request = env.Request; SessionInfo sinfo; if (TryGetSessionInfo(request, out sinfo) && (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)) { var regions = m_GridService.GetRegionsByName(UUID.Zero, "", 200); MainConsole.Instance.DebugFormat("[Services]: There are {0} regions", regions.Count); //regions.ForEach(delegate(GridRegion region); //( // m_log.DebugFormat("[Services] {0}", gg.RegionName); //); env.Session = sinfo; //env.Data = Objectify(regions); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; env.State = State.RegionManagementForm; return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } else { return m_WebApp.ReadFile(env, "index.html"); } }
public string RegionManagementShutdownPostRequest(AuroraWeb.Environment env) { //m_log.DebugFormat("[AuroraWeb]: RegionManagementShutdownPostRequest"); Request request = env.Request; SessionInfo sinfo; if (TryGetSessionInfo(request, out sinfo) && (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)) { env.Session = sinfo; //FIXME: don't hardcode url, get it from m_GridService //TODO: check if server is actually running first //TODO: add support for shutdown message parameter from html form string url = m_WebApp.LoginURL; Hashtable hash = new Hashtable(); if (m_ServerAdminPassword == null) { m_log.Debug("[RegionManagementShutdownPostRequest] No remote admin password was set in .ini file"); } hash["password"] = m_ServerAdminPassword; IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest xmlrpcReq = new XmlRpcRequest("admin_shutdown", paramList); XmlRpcResponse response = null; try { response = xmlrpcReq.Send(url, 10000); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; env.State = State.RegionManagementSuccessful; } catch (Exception e) { m_log.Debug("[AuroraWeb]: Exception " + e.Message); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; env.State = State.RegionManagementUnsuccessful; } return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } return m_WebApp.ReadFile(env, "index.html"); }
public string RegionManagementRestartPostRequest(AuroraWeb.Environment env) { Request request = env.Request; SessionInfo sinfo; if (TryGetSessionInfo(request, out sinfo) && (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)) { env.Session = sinfo; string url = m_WebApp.LoginURL; Hashtable hash = new Hashtable(); if (m_ServerAdminPassword == null) { m_log.Debug("[RegionManagementRestartPostRequest] No remote admin password was set in .ini file"); } hash["password"] = m_ServerAdminPassword; IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest xmlrpcReq = new XmlRpcRequest("admin_shutdown", paramList); XmlRpcResponse response = null; try { //first, shutdown the server response = xmlrpcReq.Send(url, 10000); //then wait until the server is completely shutdown, then re-launch System.Diagnostics.Process[] openSimProcess = System.Diagnostics.Process.GetProcessesByName("OpenSim"); openSimProcess[0].WaitForExit(); System.Diagnostics.Process.Start("OpenSim.exe"); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; env.State = State.RegionManagementSuccessful; } catch (Exception e) { m_log.Debug("[AuroraWeb]: Exception " + e.Message); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; env.State = State.RegionManagementUnsuccessful; } return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } return m_WebApp.ReadFile(env, "index.html"); }
public string InventoryPostRequest(AuroraWeb.Environment env, string action, string folder, string newFolderName, List<string> nodes, List<string> types) { if (!m_WebApp.IsInstalled) { m_log.DebugFormat("[AuroraWeb]: warning: someone is trying to access InventoryPostRequest and Wifi isn't installed!"); return m_WebApp.ReadFile(env, "index.html"); } m_log.DebugFormat("[AuroraWeb]: InventoryPostRequest"); Request request = env.Request; SessionInfo sinfo; if (TryGetSessionInfo(request, out sinfo)) { env.Session = sinfo; if (action == "delete") Delete(sinfo.Account.PrincipalID, nodes, types); else if (action == "move") Move(sinfo.Account.PrincipalID, nodes, types, folder); else if (action == "new") NewFolder(sinfo.Account.PrincipalID, newFolderName, folder); // Send the [new] inventory list return InventoryLoadGetRequest(env); } else { return m_WebApp.ReadFile(env, "index.html"); } }
public string UserDeletePostRequest(AuroraWeb.Environment env, UUID userID) { m_log.DebugFormat("[AuroraWeb]: UserDeletePostRequest {0}", userID); Request request = env.Request; 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("[AuroraWeb]: Deleted account for user {0}", account.Name); } else { NotifyWithoutButton(env, _("Unable to delete account because it does not exist.", env)); m_log.DebugFormat("[AuroraWeb]: Attempt at deleting an inexistent account"); } return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } return m_WebApp.ReadFile(env, "index.html"); }
public string UserEditGetRequest(AuroraWeb.Environment env, UUID userID) { m_log.DebugFormat("[AuroraWeb]: UserEditGetRequest {0}", userID); Request request = env.Request; 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 PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } return m_WebApp.ReadFile(env, "index.html"); }
public string InstallGetRequest(AuroraWeb.Environment env) { env.State = State.InstallForm; return m_WebApp.ReadFile(env, "index.html"); }