diff --git a/OpenGridServices.UserServer/Main.cs b/OpenGridServices.UserServer/Main.cs index 53d3fb1c69..d7d6102324 100644 --- a/OpenGridServices.UserServer/Main.cs +++ b/OpenGridServices.UserServer/Main.cs @@ -107,9 +107,35 @@ namespace OpenGridServices.UserServer m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)"); break; - case "shutdown": + case "create user": + m_console.WriteLine("Creating new user profile"); + string tempfirstname; + string templastname; + string tempMD5Passwd; + + tempfirstname=m_console.CmdPrompt("First name: "); + templastname=m_console.CmdPrompt("Last name: "); + tempMD5Passwd=m_console.PasswdPrompt("Password: "); + + System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider(); + byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd); + bs = x.ComputeHash(bs); + System.Text.StringBuilder s = new System.Text.StringBuilder(); + foreach (byte b in bs) + { + s.Append(b.ToString("x2").ToLower()); + } + tempMD5Passwd = "$1$" + s.ToString(); + + UserProfile newuser=_profilemanager.CreateNewProfile(tempfirstname,templastname,tempMD5Passwd); + newuser.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f); + newuser.homepos = new LLVector3(128f,128f,23f); + _profilemanager.SaveUserProfiles(); + break; + + case "shutdown": m_console.Close(); - Environment.Exit(0); + Environment.Exit(0); break; } } diff --git a/OpenSim.Framework/UserProfileManagerBase.cs b/OpenSim.Framework/UserProfileManagerBase.cs index 73f325d9d6..c022feb54e 100644 --- a/OpenSim.Framework/UserProfileManagerBase.cs +++ b/OpenSim.Framework/UserProfileManagerBase.cs @@ -28,6 +28,22 @@ namespace OpenSim.Framework.User db.Close(); } + public virtual void SaveUserProfiles() // ZOMG! INEFFICIENT! + { + IObjectContainer db; + db = Db4oFactory.OpenFile("userprofiles.yap"); + IObjectSet result = db.Get(typeof(UserProfile)); + foreach (UserProfile userprof in result) { + db.Delete(userprof); + db.Commit(); + } + foreach (UserProfile userprof in UserProfiles.Values) { + db.Set(userprof); + db.Commit(); + } + db.Close(); + } + public UserProfile GetProfileByName(string firstname, string lastname) { foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys) @@ -86,8 +102,8 @@ namespace OpenSim.Framework.User newprofile.UUID = LLUUID.Random(); newprofile.Inventory.CreateRootFolder(newprofile.UUID, true); this.UserProfiles.Add(newprofile.UUID, newprofile); - return newprofile; - } + return newprofile; + } public virtual AgentInventory GetUsersInventory(LLUUID agentID) {