public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary <string, object> (); string error = ""; UUID userID = httpRequest.Query.ContainsKey("userid") ? UUID.Parse(httpRequest.Query ["userid"].ToString()) : UUID.Parse(requestParameters ["userid"].ToString()); IUserAccountService userService = webInterface.Registry.RequestModuleInterface <IUserAccountService> (); UserAccount account = null; if (userService != null) { account = userService.GetUserAccount(null, userID); } var agentService = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector> (); IAgentInfo agent = agentService.GetAgent(userID); if (agent == null) { error = "No agent information is available"; } // Set user type if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitSetUserType") { string UserType = requestParameters ["UserType"].ToString(); int UserFlags = WebHelpers.UserTypeToUserFlags(UserType); // set the user account type if (account != null) { account.UserFlags = UserFlags; userService.StoreUserAccount(account); } else { response = "User account not found - Unable to update!'"; return(null); } if (agent != null) { agent.OtherAgentInformation ["UserFlags"] = UserFlags; agentService.UpdateAgent(agent); } else { response = "Agent information is not available! Has the user logged in yet?"; return(null); } IProfileConnector profileData = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector> (); if (profileData != null) { IUserProfileInfo profile = profileData.GetUserProfile(userID); if (profile == null) { profileData.CreateNewProfile(userID); profile = profileData.GetUserProfile(userID); } profile.MembershipGroup = WebHelpers.UserFlagToType(UserFlags, webInterface.EnglishTranslator); // membership is english profileData.UpdateUserProfile(profile); } response = "User account has been updated."; return(null); } // Password change if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitPasswordChange") { string password = requestParameters ["password"].ToString(); string passwordconf = requestParameters ["passwordconf"].ToString(); if (password != passwordconf) { response = "Passwords do not match"; } else { IAuthenticationService authService = webInterface.Registry.RequestModuleInterface <IAuthenticationService> (); if (authService != null) { response = authService.SetPassword(userID, "UserAccount", password) ? "Successfully set password" : "Failed to set your password, try again later"; } else { response = "No authentication service was available to change the account passwor!"; } } return(null); } // Email change if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitEmailChange") { string email = requestParameters ["email"].ToString(); if (account != null) { account.Email = email; userService.StoreUserAccount(account); response = "Successfully updated email"; } else { response = "No authentication service was available to change the email details!"; } return(null); } // Delete user if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitDeleteUser") { string username = requestParameters ["username"].ToString(); if (account != null) { if (username == account.Name) { userService.DeleteUser(account.PrincipalID, account.Name, "", false, false); response = "User has been successfully deleted"; } else { response = "The user name did not match!"; } } else { response = "No account details to verify user against!"; } return(null); } // Temp Ban user if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitTempBanUser") { int timeDays = int.Parse(requestParameters ["TimeDays"].ToString()); int timeHours = int.Parse(requestParameters ["TimeHours"].ToString()); int timeMinutes = int.Parse(requestParameters ["TimeMinutes"].ToString()); if (agent != null) { agent.Flags |= IAgentFlags.TempBan; DateTime until = DateTime.Now.AddDays(timeDays).AddHours(timeHours).AddMinutes(timeMinutes); agent.OtherAgentInformation ["Temperory BanInfo"] = until; agentService.UpdateAgent(agent); response = "User has been banned."; } else { response = "Agent information is not available! Has the user logged in yet?"; } return(null); } // Ban user if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitBanUser") { if (agent != null) { agent.Flags |= IAgentFlags.PermBan; agentService.UpdateAgent(agent); response = "User has been banned."; } else { response = "Agent information is not available! Has the user logged in yet?"; } return(null); } //UnBan user if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitUnbanUser") { if (agent != null) { agent.Flags &= ~IAgentFlags.TempBan; agent.Flags &= ~IAgentFlags.PermBan; agent.OtherAgentInformation.Remove("Temporary BanInfo"); agentService.UpdateAgent(agent); response = "User has been unbanned."; } else { response = "Agent information is not available! Has the user logged in yet?"; } return(null); } // Login as user if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitLoginAsUser") { Authenticator.ChangeAuthentication(httpRequest, account); webInterface.Redirect(httpResponse, "/"); return(vars); } // Kick user if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitKickUser") { string message = requestParameters ["KickMessage"].ToString(); if (account != null) { IGridWideMessageModule messageModule = webInterface.Registry.RequestModuleInterface <IGridWideMessageModule> (); if (messageModule != null) { messageModule.KickUser(account.PrincipalID, message); } response = "User has been kicked."; } else { response = "Unable to determine user to kick!"; } return(null); } // Message user if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitMessageUser") { string message = requestParameters ["Message"].ToString(); if (account != null) { IGridWideMessageModule messageModule = webInterface.Registry.RequestModuleInterface <IGridWideMessageModule> (); if (messageModule != null) { messageModule.MessageUser(account.PrincipalID, message); response = "User has been sent the message."; } } else { response = "User account details are unavailable to send the message!"; } return(null); } // page variables string bannedUntil = ""; bool userBanned = false; if (agent != null) { userBanned = ((agent.Flags & IAgentFlags.PermBan) == IAgentFlags.PermBan || (agent.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan); } bool TempUserBanned = false; if (userBanned) { if ((agent.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan && agent.OtherAgentInformation ["Temperory BanInfo"].AsDate() < DateTime.Now.ToUniversalTime()) { userBanned = false; agent.Flags &= ~IAgentFlags.TempBan; agent.Flags &= ~IAgentFlags.PermBan; agent.OtherAgentInformation.Remove("Temporary BanInfo"); agentService.UpdateAgent(agent); } else { DateTime bannedTime = agent.OtherAgentInformation ["Temporary BanInfo"].AsDate(); TempUserBanned = bannedTime != Util.UnixEpoch; bannedUntil = string.Format("{0} {1}", bannedTime.ToShortDateString(), bannedTime.ToLongTimeString()); } } bool userOnline = false; IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService> (); if (agentInfoService != null) { UserInfo Info = null; if (account != null) { Info = agentInfoService.GetUserInfo(account.PrincipalID.ToString()); } userOnline = Info != null && Info.IsOnline; } if (account != null) { vars.Add("EmailValue", account.Email); vars.Add("UserID", account.PrincipalID); vars.Add("UserName", account.Name); } else { vars.Add("EmailValue", ""); vars.Add("UserID", ""); vars.Add("UserName", ""); } vars.Add("UserOnline", userOnline); vars.Add("NotUserBanned", !userBanned); vars.Add("UserBanned", userBanned); vars.Add("TempUserBanned", TempUserBanned); vars.Add("BannedUntil", bannedUntil); vars.Add("ErrorMessage", error); vars.Add("ChangeUserInformationText", translator.GetTranslatedString("ChangeUserInformationText")); vars.Add("ChangePasswordText", translator.GetTranslatedString("ChangePasswordText")); vars.Add("NewPasswordText", translator.GetTranslatedString("NewPasswordText")); vars.Add("NewPasswordConfirmationText", translator.GetTranslatedString("NewPasswordConfirmationText")); vars.Add("ChangeEmailText", translator.GetTranslatedString("ChangeEmailText")); vars.Add("NewEmailText", translator.GetTranslatedString("NewEmailText")); vars.Add("UserNameText", translator.GetTranslatedString("UserNameText")); vars.Add("PasswordText", translator.GetTranslatedString("PasswordText")); vars.Add("DeleteUserText", translator.GetTranslatedString("DeleteUserText")); vars.Add("DeleteText", translator.GetTranslatedString("DeleteText")); vars.Add("DeleteUserInfoText", translator.GetTranslatedString("DeleteUserInfoText")); vars.Add("Submit", translator.GetTranslatedString("Submit")); vars.Add("Login", translator.GetTranslatedString("Login")); vars.Add("TypeUserNameToConfirm", translator.GetTranslatedString("TypeUserNameToConfirm")); vars.Add("AdminUserTypeInfoText", translator.GetTranslatedString("AdminUserTypeInfoText")); vars.Add("AdminSetUserTypeText", translator.GetTranslatedString("UserTypeText")); vars.Add("AdminLoginInAsUserText", translator.GetTranslatedString("AdminLoginInAsUserText")); vars.Add("AdminLoginInAsUserInfoText", translator.GetTranslatedString("AdminLoginInAsUserInfoText")); vars.Add("AdminDeleteUserText", translator.GetTranslatedString("AdminDeleteUserText")); vars.Add("AdminDeleteUserInfoText", translator.GetTranslatedString("AdminDeleteUserInfoText")); vars.Add("AdminUnbanUserText", translator.GetTranslatedString("AdminUnbanUserText")); vars.Add("AdminTempBanUserText", translator.GetTranslatedString("AdminTempBanUserText")); vars.Add("AdminTempBanUserInfoText", translator.GetTranslatedString("AdminTempBanUserInfoText")); vars.Add("AdminBanUserText", translator.GetTranslatedString("AdminBanUserText")); vars.Add("AdminBanUserInfoText", translator.GetTranslatedString("AdminBanUserInfoText")); vars.Add("BanText", translator.GetTranslatedString("BanText")); vars.Add("UnbanText", translator.GetTranslatedString("UnbanText")); vars.Add("TimeUntilUnbannedText", translator.GetTranslatedString("TimeUntilUnbannedText")); vars.Add("EdittingText", translator.GetTranslatedString("EdittingText")); vars.Add("BannedUntilText", translator.GetTranslatedString("BannedUntilText")); vars.Add("KickAUserInfoText", translator.GetTranslatedString("KickAUserInfoText")); vars.Add("KickAUserText", translator.GetTranslatedString("KickAUserText")); vars.Add("KickMessageText", translator.GetTranslatedString("KickMessageText")); vars.Add("KickUserText", translator.GetTranslatedString("KickUserText")); vars.Add("MessageAUserText", translator.GetTranslatedString("MessageAUserText")); vars.Add("MessageAUserInfoText", translator.GetTranslatedString("MessageAUserInfoText")); vars.Add("MessageUserText", translator.GetTranslatedString("MessageUserText")); List <Dictionary <string, object> > daysArgs = new List <Dictionary <string, object> > (); for (int i = 0; i <= 100; i++) { daysArgs.Add(new Dictionary <string, object> { { "Value", i } }); } List <Dictionary <string, object> > hoursArgs = new List <Dictionary <string, object> > (); for (int i = 0; i <= 23; i++) { hoursArgs.Add(new Dictionary <string, object> { { "Value", i } }); } List <Dictionary <string, object> > minutesArgs = new List <Dictionary <string, object> > (); for (int i = 0; i <= 59; i++) { minutesArgs.Add(new Dictionary <string, object> { { "Value", i } }); } vars.Add("Days", daysArgs); vars.Add("Hours", hoursArgs); vars.Add("Minutes", minutesArgs); vars.Add("DaysText", translator.GetTranslatedString("DaysText")); vars.Add("HoursText", translator.GetTranslatedString("HoursText")); vars.Add("MinutesText", translator.GetTranslatedString("MinutesText")); vars.Add("UserType", WebHelpers.UserTypeArgs(translator)); return(vars); }
public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary <string, object>(); var settings = webInterface.GetWebUISettings(); bool adminUser = Authenticator.CheckAdminAuthentication(httpRequest, Constants.USER_GOD_CUSTOMER_SERVICE); bool allowRegistration = settings.WebRegistration; bool anonymousLogins; // allow configuration to override the web settings var simBase = webInterface.Registry.RequestModuleInterface <ISimulationBase>(); IConfig loginServerConfig = simBase.ConfigSource.Configs["LoginService"]; if (loginServerConfig != null) { anonymousLogins = loginServerConfig.GetBoolean("AllowAnonymousLogin", allowRegistration); allowRegistration = (allowRegistration || anonymousLogins); } if (!adminUser && !allowRegistration) { vars.Add("ErrorMessage", ""); vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText")); vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled")); vars.Add("Registrations", false); vars.Add("NoRegistrations", true); return(vars); } if (requestParameters.ContainsKey("Submit")) { string AvatarName = requestParameters["AvatarName"].ToString(); string AvatarPassword = requestParameters["AvatarPassword"].ToString(); string AvatarPasswordCheck = requestParameters["AvatarPassword2"].ToString(); string FirstName = requestParameters["FirstName"].ToString(); string LastName = requestParameters["LastName"].ToString(); //removed - greythane - deemed not used //string UserAddress = requestParameters["UserAddress"].ToString(); //string UserZip = requestParameters["UserZip"].ToString(); string UserCity = requestParameters["UserCity"].ToString(); string UserEmail = requestParameters["UserEmail"].ToString(); string UserHomeRegion = requestParameters["UserHomeRegion"].ToString(); string UserDOBMonth = requestParameters["UserDOBMonth"].ToString(); string UserDOBDay = requestParameters["UserDOBDay"].ToString(); string UserDOBYear = requestParameters["UserDOBYear"].ToString(); string AvatarArchive = requestParameters.ContainsKey("AvatarArchive") ? requestParameters["AvatarArchive"].ToString() : ""; bool ToSAccept = requestParameters.ContainsKey("ToSAccept") && requestParameters["ToSAccept"].ToString() == "Accepted"; string UserType = requestParameters.ContainsKey("UserType") // only admins can set membership ? requestParameters ["UserType"].ToString() : "Resident"; // revise UserDOBMonth to a number UserDOBMonth = ShortMonthToNumber(UserDOBMonth); // revise Type flags int UserFlags = WebHelpers.UserTypeToUserFlags(UserType); // a bit of idiot proofing if (AvatarName == "") { response = "<h3>" + translator.GetTranslatedString("AvatarNameError") + "</h3>"; return(null); } if ((AvatarPassword == "") || (AvatarPassword != AvatarPasswordCheck)) { response = "<h3>" + translator.GetTranslatedString("AvatarPasswordError") + "</h3>"; return(null); } if (UserEmail == "") { response = "<h3>" + translator.GetTranslatedString("AvatarEmailError") + "</h3>"; return(null); } // Thish - Only one space is allowed in the name to seperate First and Last of the avatar name if (AvatarName.Split(' ').Length != 2) { response = "<h3>" + translator.GetTranslatedString("AvatarNameSpacingError") + "</h3>"; return(null); } // so far so good... if (ToSAccept) { AvatarPassword = Util.Md5Hash(AvatarPassword); IUserAccountService accountService = webInterface.Registry.RequestModuleInterface <IUserAccountService>(); UUID userID = UUID.Random(); string error = accountService.CreateUser(userID, settings.DefaultScopeID, AvatarName, AvatarPassword, UserEmail); if (error == "") { // set the user account type UserAccount userAcct = accountService.GetUserAccount(null, userID); userAcct.UserFlags = UserFlags; accountService.StoreUserAccount(userAcct); // create and save agent info IAgentConnector con = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector> (); con.CreateNewAgent(userID); IAgentInfo agent = con.GetAgent(userID); agent.OtherAgentInformation ["RLFirstName"] = FirstName; agent.OtherAgentInformation ["RLLastName"] = LastName; //agent.OtherAgentInformation ["RLAddress"] = UserAddress; agent.OtherAgentInformation ["RLCity"] = UserCity; //agent.OtherAgentInformation ["RLZip"] = UserZip; agent.OtherAgentInformation ["UserDOBMonth"] = UserDOBMonth; agent.OtherAgentInformation ["UserDOBDay"] = UserDOBDay; agent.OtherAgentInformation ["UserDOBYear"] = UserDOBYear; agent.OtherAgentInformation ["UserFlags"] = UserFlags; /*if (activationRequired) * { * UUID activationToken = UUID.Random(); * agent.OtherAgentInformation["WebUIActivationToken"] = Util.Md5Hash(activationToken.ToString() + ":" + PasswordHash); * resp["WebUIActivationToken"] = activationToken; * }*/ con.UpdateAgent(agent); // create user profile details IProfileConnector profileData = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector> (); if (profileData != null) { IUserProfileInfo profile = profileData.GetUserProfile(userID); if (profile == null) { profileData.CreateNewProfile(userID); profile = profileData.GetUserProfile(userID); } if (AvatarArchive != "") { profile.AArchiveName = AvatarArchive; List <AvatarArchive> avarchives = webInterface.Registry.RequestModuleInterface <IAvatarAppearanceArchiver>().GetAvatarArchives(); UUID snapshotUUID = UUID.Zero; foreach (var archive in avarchives) { if (archive.FolderName == AvatarArchive) { snapshotUUID = archive.Snapshot; } } if (snapshotUUID != UUID.Zero) { profile.Image = snapshotUUID; } } profile.MembershipGroup = WebHelpers.UserFlagToType(UserFlags, webInterface.EnglishTranslator); // membership is english profile.IsNewUser = true; profileData.UpdateUserProfile(profile); } IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService> (); Vector3 position = new Vector3(128, 128, 25); Vector3 lookAt = new Vector3(0, 0, 22); if (agentInfoService != null) { agentInfoService.SetHomePosition(userID.ToString(), (UUID)UserHomeRegion, position, lookAt); } vars.Add("ErrorMessage", "Successfully created account, redirecting to main page"); response = "<h3>Successfully created account, redirecting to main page</h3>" + "<script language=\"javascript\">" + "setTimeout(function() {window.location.href = \"index.html\";}, 3000);" + "</script>"; } else { vars.Add("ErrorMessage", "<h3>" + error + "</h3>"); response = "<h3>" + error + "</h3>"; } } else { response = "<h3>You did not accept the Terms of Service agreement.</h3>"; } return(null); } List <Dictionary <string, object> > daysArgs = new List <Dictionary <string, object> >(); for (int i = 1; i <= 31; i++) { daysArgs.Add(new Dictionary <string, object> { { "Value", i } }); } List <Dictionary <string, object> > yearsArgs = new List <Dictionary <string, object> >(); for (int i = 1950; i <= 2013; i++) { yearsArgs.Add(new Dictionary <string, object> { { "Value", i } }); } vars.Add("Days", daysArgs); vars.Add("Months", WebHelpers.ShortMonthSelections(translator)); //.monthsArgs); vars.Add("Years", yearsArgs); var sortBy = new Dictionary <string, bool>(); sortBy.Add("RegionName", true); var RegionListVars = new List <Dictionary <string, object> >(); var regions = Framework.Utilities.DataManager.RequestPlugin <IRegionData>().GetList((RegionFlags)0, RegionFlags.Hyperlink | RegionFlags.Foreign | RegionFlags.Hidden, null, null, sortBy); foreach (var region in regions) { RegionListVars.Add(new Dictionary <string, object> { { "RegionName", region.RegionName }, { "RegionUUID", region.RegionID } }); } vars.Add("RegionList", RegionListVars); vars.Add("UserHomeRegionText", translator.GetTranslatedString("UserHomeRegionText")); vars.Add("UserTypeText", translator.GetTranslatedString("UserTypeText")); vars.Add("UserType", WebHelpers.UserTypeArgs(translator)); vars.Add("AvatarArchive", WebHelpers.AvatarSelections(webInterface.Registry)); string tosLocation = ""; if (loginServerConfig != null && loginServerConfig.GetBoolean("UseTermsOfServiceOnFirstLogin", false)) { tosLocation = loginServerConfig.GetString("FileNameOfTOS", ""); tosLocation = PathHelpers.VerifyReadFile(tosLocation, ".txt", simBase.DefaultDataPath); } string ToS = "There are no Terms of Service currently. This may be changed at any point in the future."; if (tosLocation != "") { StreamReader reader = new StreamReader(Path.Combine(Environment.CurrentDirectory, tosLocation)); try { ToS = reader.ReadToEnd(); } finally { reader.Close(); } } // check for user name seed string[] m_userNameSeed = null; if (loginServerConfig != null) { string userNameSeed = loginServerConfig.GetString("UserNameSeed", ""); if (userNameSeed != "") { m_userNameSeed = userNameSeed.Split(','); } } Utilities.MarkovNameGenerator ufNames = new Utilities.MarkovNameGenerator(); Utilities.MarkovNameGenerator ulNames = new Utilities.MarkovNameGenerator(); string[] nameSeed = m_userNameSeed == null ? Utilities.UserNames : m_userNameSeed; string firstName = ufNames.FirstName(nameSeed, 3, 4); string lastName = ulNames.FirstName(nameSeed, 5, 6); string enteredName = firstName + " " + lastName; vars.Add("AvatarName", enteredName); vars.Add("ToSMessage", ToS); vars.Add("TermsOfServiceAccept", translator.GetTranslatedString("TermsOfServiceAccept")); vars.Add("TermsOfServiceText", translator.GetTranslatedString("TermsOfServiceText")); vars.Add("RegistrationsDisabled", ""); //vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled")); vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText")); vars.Add("AvatarNameText", translator.GetTranslatedString("AvatarNameText")); vars.Add("AvatarPasswordText", translator.GetTranslatedString("Password")); vars.Add("AvatarPasswordConfirmationText", translator.GetTranslatedString("PasswordConfirmation")); vars.Add("AvatarScopeText", translator.GetTranslatedString("AvatarScopeText")); vars.Add("FirstNameText", translator.GetTranslatedString("FirstNameText")); vars.Add("LastNameText", translator.GetTranslatedString("LastNameText")); vars.Add("UserAddressText", translator.GetTranslatedString("UserAddressText")); vars.Add("UserZipText", translator.GetTranslatedString("UserZipText")); vars.Add("UserCityText", translator.GetTranslatedString("UserCityText")); vars.Add("UserCountryText", translator.GetTranslatedString("UserCountryText")); vars.Add("UserDOBText", translator.GetTranslatedString("UserDOBText")); vars.Add("UserEmailText", translator.GetTranslatedString("UserEmailText")); vars.Add("Accept", translator.GetTranslatedString("Accept")); vars.Add("Submit", translator.GetTranslatedString("Submit")); vars.Add("SubmitURL", "register.html"); vars.Add("ErrorMessage", ""); vars.Add("Registrations", true); vars.Add("NoRegistrations", false); return(vars); }