private void InitConfig() { CResource resource = Singleton <CResourceManager> .GetInstance().GetResource("Config/ParticleLimit", typeof(TextAsset), enResourceType.Numeric, false, true); if (resource == null) { return; } CBinaryObject cBinaryObject = resource.m_content as CBinaryObject; if (null == cBinaryObject) { return; } string text = StringHelper.ASCIIBytesToString(cBinaryObject.m_data); string[] array = text.Split(new char[] { '\r', '\n' }); array = Array.FindAll <string>(array, (string x) => !string.IsNullOrEmpty(x)); for (int i = 0; i < array.Length; i++) { string text2 = array[i]; if (!string.IsNullOrEmpty(text2)) { text2 = text2.Trim(); if (text2.Contains("//")) { text2 = text2.Substring(0, text2.IndexOf("//")); } text2 = text2.Trim(); if (!string.IsNullOrEmpty(text2)) { string[] array2 = text2.Split(new char[] { ':' }); if (array2 == null || array2.Length != 2) { return; } int[] array3 = new int[2]; for (int j = 0; j < array2.Length; j++) { array3[j] = Mathf.Abs(int.Parse(array2[j])); } if (array3[0] != 0 && array3[0] != 1) { return; } this.LIMIT_CONFIG[i] = array3[1]; } } } }
private void InitConfig() { CResource resource = Singleton <CResourceManager> .GetInstance().GetResource("Config/ParticleLimit", typeof(TextAsset), enResourceType.Numeric, false, true); if (resource != null) { CBinaryObject content = resource.m_content as CBinaryObject; if (null != content) { char[] separator = new char[] { '\r', '\n' }; foreach (string str2 in StringHelper.ASCIIBytesToString(content.m_data).Split(separator)) { if (!string.IsNullOrEmpty(str2)) { str2 = str2.Trim(); if (str2.Contains("//")) { str2 = str2.Substring(0, str2.IndexOf("//")); } str2 = str2.Trim(); if (!string.IsNullOrEmpty(str2)) { char[] chArray2 = new char[] { ':', ',' }; string[] strArray2 = str2.Split(chArray2); if ((strArray2 == null) || (strArray2.Length != 3)) { return; } int[] numArray = new int[3]; for (int i = 0; i < strArray2.Length; i++) { numArray[i] = Mathf.Abs(int.Parse(strArray2[i])); } if ((numArray[0] != 0) && (numArray[0] != 1)) { return; } if (numArray[1] >= numArray[2]) { return; } this.LIMIT_CONFIG[numArray[0]] = new int[] { numArray[1], numArray[2] }; } } } } } }
// Someone wants connect.kat. public void OnFileRequested(HttpRequest request, IDirectory directory) { request.Response.ResponseContent = new MemoryStream(); StreamWriter textWriter = new StreamWriter(request.Response.ResponseContent); try { // Grab various bits of data from the User object. // If we can't do that, complain. // While we're at it, decode the post data. User user; SecondLife client; StreamReader reader = new StreamReader(request.PostData); string qstring = reader.ReadToEnd(); reader.Dispose(); Dictionary <string, string> POST = AjaxLife.PostDecode(qstring); Guid key = new Guid(POST["session"]); // The session doesn't exist. Get upset. if (!this.users.ContainsKey(key)) { this.invalidSessionID(key, textWriter); return; } lock (this.users) { user = users[key]; } user.LastRequest = DateTime.Now; client = user.GetClient(); string first = ""; string last = ""; string pass = ""; // Decrypt the incoming login data string decrypted = StringHelper.ASCIIBytesToString(AjaxLife.RSA.Decrypt(StringHelper.HexStringToBytes(POST["logindata"]))); // Split it into its component parts. string[] data = decrypted.Split('\\'); // Get upset if the challenge was incorrect. if (data[0] == null || data[0] != user.Challenge) { throw new Exception("Invalid request."); } // Decode the login data. first = StringHelper.ASCIIBytesToString(StringHelper.FromBase64(data[1])); last = StringHelper.ASCIIBytesToString(StringHelper.FromBase64(data[2])); pass = data[3]; user.Signature = data[4]; // Check if they're banned first. if (AjaxLife.BannedUsers.IsBanned(first, last)) { textWriter.WriteLine("{success: false, message: \"You have been banned from AjaxLife by the administrator.\"}"); textWriter.Flush(); return; } LoginParams login = client.Network.DefaultLoginParams(first, last, pass, "AjaxLife", "Katharine Berry <*****@*****.**>"); login.Platform = "web"; login.Channel = "AjaxLife"; login.MAC = AjaxLife.MAC_ADDRESS; login.id0 = AjaxLife.ID0; login.Start = (POST["location"] != "arbitrary") ? POST["location"] : NetworkManager.StartLocation(POST["sim"], 128, 128, 20); // Pick the correct loginuri. lock (AjaxLife.LOGIN_SERVERS) login.URI = AjaxLife.LOGIN_SERVERS[POST["grid"]]; client.Settings.LOGIN_SERVER = login.URI; user.LindenGrid = POST["grid"].EndsWith("(Linden Lab)"); Console.WriteLine(login.FirstName + " " + login.LastName + " is attempting to log into " + POST["grid"] + " (" + login.URI + ")"); if (client.Network.Login(login)) { // Ensure that the challenge isn't matched by another request with the same SID. // We don't do this until after successful login because otherwise a second attempt will always fail. user.Challenge = null; AvatarTracker avatars = new AvatarTracker(client); Events events = new Events(user); user.Events = events; user.Avatars = avatars; // Register event handlers this.RegisterCallbacks(user); // De-ruth. client.Appearance.SetPreviousAppearance(false); // Pythagoras says that 181.0193m is the optimal view distance to see the whole sim. client.Self.Movement.Camera.Far = 181.0193f; // This doesn't seem to work. // client.Self.Movement.Camera.SetPositionOrientation(new LLVector3(128, 128, 0), 0, 0, 0); // Everything's happy. Log the requested message list, if any. if (POST.ContainsKey("events")) { user.ParseRequestedEvents(POST["events"]); } // If we got this far, it worked. Announce this. textWriter.WriteLine("{\"success\": 1}"); } else { // Return whatever errors may have transpired. textWriter.WriteLine("{success: false, message: " + AjaxLife.StringToJSON(client.Network.LoginMessage) + "}"); } } catch (Exception exception) { request.Response.ContentType = "text/plain"; textWriter.WriteLine(exception.Message); } textWriter.Flush(); }