public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
		{
			int val = info.ButtonID;
			bool bResendGump = false;

			if (val <= 0)
				return;

			if (m_Account == null)
				return;

			try
			{
				TextRelay tr = info.GetTextEntry(0);
				string oldpassword = (tr == null ? null : tr.Text.Trim());

				if (oldpassword != null && oldpassword.Length != 0 && m_Account.CheckPassword(oldpassword))
				{
					//valid password, proceed
					switch (val)
					{
						case SET_EMAIL_BUTTON: //set email address
							{
								TextRelay tr1 = info.GetTextEntry(1);
								TextRelay tr2 = info.GetTextEntry(2);

								string newemail = (tr1 == null ? null : tr1.Text.Trim());
								string confirmnewemail = (tr2 == null ? null : tr2.Text.Trim());

								if (newemail == null || confirmnewemail == null ||
									newemail.Length == 0 || confirmnewemail.Length == 0)
								{
									m_From.SendMessage(0x35, "Please enter email and verify email.");
									bResendGump = true;
								}
								else if (newemail != confirmnewemail)
								{
									m_From.SendMessage(0x35, "Email input doesn't match");
									bResendGump = true;
								}
								else if (SMTP.SmtpDirect.CheckEmailAddy(newemail, false) == false)
								{
									m_From.SendMessage(0x35, "Entered address isn't a valid email address.");
									bResendGump = true;
								}
								else if (newemail.IndexOf('@', 2, newemail.Length - 5) == -1)
								{
									m_From.SendMessage(0x35, "Email address not of proper format");
									bResendGump = true;
								}
								else if (m_Account.AccountActivated && m_Account.EmailAddress != null && newemail.ToLower() == m_Account.EmailAddress.ToLower())
								{
									m_From.SendMessage(0x35, "Email address matches current email address.");
									bResendGump = true;
								}
								else
								{
									string newActivationKey = CreateActivationKey(8);

									//Send Email
									bool bSent = SendActivationEmail(newemail, newActivationKey, false);
									if (bSent)
									{
										string regSubject = "Email address change";
										string regBody = "Email address change made.\n";
										if (m_Account.AccountActivated == false)
										{
											regSubject = "Account Activation request";
											regBody = "Account Activation: Email address change made.\n";
										}
										regBody += "Info of from: \n";
										regBody += "\n";
										regBody += "Account: " + (m_Account == null ? "<unknown>" : m_Account.Username) + "\n";
										regBody += "Character: " + m_From.Name + "\n";
										regBody += "IP: " + sender.Address.ToString() + "\n";
										regBody += "Old Email: " + m_Account.EmailAddress + "\n";
										regBody += "New Email: " + newemail + "\n";
										regBody += "Activation Key: " + newActivationKey + "\n";
										regBody += "\n";

										Emailer mail = new Emailer();
										mail.SendEmail("*****@*****.**", regSubject, regBody, false);

										if (m_Account.AccountActivated &&
											newemail.ToLower() != m_Account.EmailAddress.ToLower())
										{
											string subject2 = "Angel Island Account email changed";
											string body2 = "\nThis email is being sent to notify that someone has changed your email for your ";
											body2 += "Angel Island account from ";
											body2 += m_Account.EmailAddress;
											body2 += " to ";
											body2 += newemail;
											body2 += "\n\nIf you did not request this change, please contact an Angel Island ";
											body2 += "administrator as soon as possible.";
											body2 += "\n\nRegards,\n  The Angel Island Team\n\n";

											mail = new Emailer();
											mail.SendEmail(m_Account.EmailAddress, subject2, body2, false);
										}

										//success
										string[] tmp = new string[m_Account.EmailHistory.Length + 1];
										tmp[0] = newemail;
										m_Account.EmailHistory.CopyTo(tmp, 1);
										m_Account.EmailHistory = tmp;

										m_Account.EmailAddress = newemail;

										m_Account.ActivationKey = newActivationKey;
										m_Account.AccountActivated = false;
										m_Account.LastActivationResendTime = DateTime.Now;


										//Notify user.
										m_From.SendMessage(0x35, "Email address accepted.");
										m_From.SendMessage(0x35, "An activation key has been sent to " + newemail);
										m_From.SendMessage(0x35, "After you get the key, use the [profile command again to complete activation.");
									}
									else
									{
										//failure
										//Notify user.
										m_From.SendMessage(0x35, "Error with email.");
										m_From.SendMessage(0x35, "Email address not changed.");
									}
								}

								break;
							}
						case RESEND_ACTIVATION:
							{
								if (m_Account.LastActivationResendTime + TimeSpan.FromHours(24.0) > DateTime.Now)
								{
									m_From.SendMessage(0x35, "You can only send an activation email once every 24 hours.");
								}
								else
								{
									string email = m_Account.EmailAddress;
									string key = m_Account.ActivationKey;
									bool bSent = SendActivationEmail(email, key, true);

									if (bSent)
									{
										m_Account.LastActivationResendTime = DateTime.Now;
										m_From.SendMessage(0x35, "The activation email has been resent to " + email);
									}
									else
									{
										m_From.SendMessage(0x35, "There was a problem resending the activation email to " + email);
										bResendGump = true;
									}
								}
								break;
							}
						case ENTER_ACTIVATION_KEY:
							{
								TextRelay tr1 = info.GetTextEntry(1);

								string activationEntry = (tr1 == null ? null : tr1.Text.Trim());

								if (activationEntry == m_Account.ActivationKey)
								{
									m_Account.AccountActivated = true;
									m_Account.ActivationKey = "";

									m_From.SendMessage(0x35, "Your account is now activated.");
								}
								else
								{
									m_From.SendMessage(0x35, "That is not the correct activation key.");
									m_From.SendMessage(0x35, "Make sure you have the correct capitalization.");
								}

								bResendGump = true;
								break;
							}
						case RESET_ACTIVATION_ATTEMPT:
							{
								m_Account.AccountActivated = false;
								m_Account.EmailAddress = "";
								m_Account.ActivationKey = "";

								m_From.SendMessage(0x35, "Your activation attempt has been reset.");
								bResendGump = true;
								break;
							}
						case SET_PASSWORD: //set password
							{
								TextRelay tr3 = info.GetTextEntry(3);
								TextRelay tr4 = info.GetTextEntry(4);

								string newpassword = (tr3 == null ? null : tr3.Text.Trim());
								string confirmnewpassword = (tr4 == null ? null : tr4.Text.Trim());

								if (newpassword == null || confirmnewpassword == null ||
									newpassword.Length == 0 || confirmnewpassword.Length == 0)
								{
									m_From.SendMessage(0x35, "Please enter new password and confirm new password.");
									bResendGump = true;
								}
								else if (newpassword != confirmnewpassword)
								{
									m_From.SendMessage(0x35, "Password input doesn't match");
									bResendGump = true;
								}
								else if (!m_Account.AccountActivated)
								{
									m_From.SendMessage(0x35, "You may not change your password until you activate your account by providing a email address.");
								}
								else if (newpassword.Length < 6)
								{
									m_From.SendMessage(0x35, "Your password must be at least 6 characters long.");
									bResendGump = true;
								}
								else if (newpassword.Length > 16)
								{
									m_From.SendMessage(0x35, "Your password can be at most 16 characters long.");
									bResendGump = true;
								}
								else if (newpassword.IndexOfAny(new char[] { ' ', '@' }) != -1)
								{
									m_From.SendMessage(0x35, "Your password cannot contain the following characters: <space>, @");
									bResendGump = true;
								}
								else
								{
									m_Account.SetPassword(newpassword);
									m_From.SendMessage(0x35, "New password set.");

									if (!m_Account.AccountActivated && oldpassword == m_Account.ActivationKey)
									{
										m_Account.AccountActivated = true;
										Console.WriteLine("Account {0} just got activated by entering the ActivationKey.", m_Account.Username);
									}

									if (m_Account.AccountActivated)
									{
										//Send Email
										string subject = "Account Information for Angel Island";
										string body = "\nYour password has been changed in game.\n";
										body += "It is now: " + newpassword;
										body += "\n\nYou can change your password using the [profile command.\n\n";
										body += "Regards,\n  The Angel Island Team\n\n";

										Emailer mail = new Emailer();
										if (mail.SendEmail(m_Account.EmailAddress, subject, body, false))
										{
											string regSubject = "Password change";
											string regBody = "Password change made.\n";
											regBody += "Info of from: \n";
											regBody += "\n";
											regBody += "Account: " + (m_Account == null ? "<unknown>" : m_Account.Username) + "\n";
											regBody += "Character: " + m_From.Name + "\n";
											regBody += "IP: " + sender.Address.ToString() + "\n";
											regBody += "Email: " + m_Account.EmailAddress + "\n";
											regBody += "New Password: "******"\n";
											regBody += "\n";

											mail = new Emailer();
											mail.SendEmail("*****@*****.**", regSubject, regBody, false);

											//Notify user
											m_From.SendMessage(0x35, "Your new password has been sent to " + m_Account.EmailAddress);
										}
										else
										{
											//Notify user
											m_From.SendMessage(0x35, "Error sending email to " + m_Account.EmailAddress + "!!");
										}
									}
								}
								break;
							}
						case SET_NOTIFICATION:
							{
								if (info.IsSwitched(5))
								{
									m_Account.DoNotSendEmail = false;
									m_From.SendMessage("Your account is set to receive email about Angel Island.");
								}
								else
								{
									m_Account.DoNotSendEmail = true;
									m_From.SendMessage("Your account is set to not receive email about Angel Island.");
								}
								bResendGump = true;
								break;
							}
					}
				}
				else
				{
					m_From.SendMessage(0x35, "Invalid password supplied");
					bResendGump = true;
				}
			}
			catch (Exception exception)
			{
				LogHelper.LogException(exception);
				Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!");
				Console.WriteLine("Exception caught in ProfileGump.OnResponse() : " + exception.Message);
				Console.WriteLine(exception.StackTrace);
				Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!");
			}

			if (bResendGump)
			{
				m_From.SendGump(new ProfileGump(m_From));
			}
		}
Exemple #2
0
		private static void ProcessFile(string filename)
		{
			//read in and parse file
			try
			{
				string acctname;
				string email;
				string ip;

				FileStream fs = new FileStream(filename, System.IO.FileMode.Open);
				XmlDocument config = new XmlDocument();
				config.Load(fs);
				fs.Close();
				XmlNode rootnode = config.SelectSingleNode("ROOT");
				XmlNode node = rootnode.SelectSingleNode("email");
				email = node.InnerText;
				node = rootnode.SelectSingleNode("username");
				acctname = node.InnerText;
				node = rootnode.SelectSingleNode("ip");
				ip = node.InnerText;

				WebAccountLogger.Log(string.Format("Going to try to add new account '{0}' from {1} with email {2}", acctname, ip, email));

				Account acct = Accounts.GetAccount( acctname );
				if ( acct == null ) //account doesn't exist - safe to add
				{
					//need to create a random password
					string password = CreateRandomPassword();//"xx1122";

					Account newAccount = CreateAccount(ip, acctname, password);
					if( newAccount != null )
					{
						m_bNewAccountsCreated = true;

						//newAccount.Comments.Add("Created from the web");
						newAccount.EmailAddress = email;
	
						WebAccountLogger.Log("added " + acctname + " successfully.");
						SendEmail(newAccount, password);

						string regSubject = "Account created from the web";
						string regBody = "Web Account Creation.\n";
						regBody += "Info: \n";
						regBody += "\n";
						regBody += "Account: " + newAccount.Username + "\n";
						regBody += "IP: " + ip + "\n";
						regBody += "Email: " + newAccount.EmailAddress + "\n";
						regBody += "New Password: "******"\n";
						regBody += "\n";

						Emailer mail = new Emailer();
						mail.SendEmail( "*****@*****.**", regSubject, regBody, false );

					}
					else
					{
						WebAccountLogger.Log("Creation of " + acctname + " failed.");
					}
				}
				else
				{
					WebAccountLogger.Log("Account '" + acctname + "' already Exists!  No new account added.");
				}

			}
			catch(Exception e)
			{
				LogHelper.LogException(e);
				WebAccountLogger.Log(e.Message);
				WebAccountLogger.Log(e.StackTrace);
			}
		}
		public static bool SendActivationEmail(string emailaddress, string activationKey, bool resend)
		{
			string subject = "Account Activation Information for Angel Island";

			if (resend) subject += " (resent)";

			string body = "\nThis email is intended to verify your email address.\n";
			body += "An activation key has been generated for your account.\n";
			body += "It is: " + activationKey;
			body += "\n\nTo complete the activation of your account, log on to Angel Island and use the [profile command again..";
			body += "Afterwards, you will be able to change your password using the [profile command.\n\n";
			body += "Regards,\n  The Angel Island Team\n\n";
			Emailer mail = new Emailer();

			return mail.SendEmail(emailaddress, subject, body, false);
		}
		public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
		{
			int val = info.ButtonID;

			if (val <= 0)
				return;

			Mobile from = m_From;

			switch (val)
			{
				case 1:
					string accountname = info.GetTextEntry(0).Text;
					m_From.SendMessage("You entered [{0}]", accountname);

					foreach (Accounting.Account a in Accounting.Accounts.Table.Values)
					{
						if (a != null)
						{
							if (a.Username.ToLower() == accountname.ToLower())
							{
								if (a.AccountActivated)
								{
									if ((DateTime.Now - a.ResetPasswordRequestedTime) < TimeSpan.FromDays(1.0))
									{
										m_From.SendMessage("Reset password already requested.");
									}
									else
									{
										string newResetPassword = Server.Gumps.ProfileGump.CreateActivationKey(8);
										if (SmtpDirect.CheckEmailAddy(a.EmailAddress, false) == true)
										{
											string subject = "Angel Island Account password reset request";
											string body = "\nSomeone has requested a password reset for your account.\n";
											body += "A new password has been generated for your account.\n";
											body += "It is: " + newResetPassword;
											body += "\n\nIf you did not request this reset password, log onto Angel Island with your normal ";
											body += "password and the reset request will be cancelled.  Also, please report this ";
											body += "to the staff of Angel Island.";
											body += "\n\nYou can change your password using the [profile command.\n\n";
											body += "Regards,\n  The Angel Island Team\n\n";

											Emailer mail = new Emailer();
											if (mail.SendEmail(a.EmailAddress, subject, body, false))
											{
												string regSubject = "Password reset request";
												string regBody = "Password reset reqest made.\n";
												regBody += "Info of from: \n";
												regBody += "\n";
												Accounting.Account from_account = m_From.Account as Accounting.Account;
												regBody += "Account: " + (from_account == null ? "<unknown>" : from_account.Username) + "\n";
												regBody += "Character: " + from.Name + "\n";
												regBody += "IP: " + sender.Address.ToString() + "\n";
												regBody += "\n";
												regBody += "Account requested for: " + a.Username + "\n";
												regBody += "Email: " + a.EmailAddress + "\n";
												regBody += "Reset password: "******"\n";
												regBody += "\n";
												mail.SendEmail("*****@*****.**", regSubject, regBody, false);

												a.ResetPassword = newResetPassword;
												m_From.SendMessage("Password reset request generated.");
												m_From.SendMessage("Email sent to account's email address.");
											}
											else
											{
												m_From.SendMessage("Error sending email to account's email.");
											}
										}
										else
										{
											m_From.SendMessage("Account email invalid, unable to reset password.");
										}
									}
								}
								else
								{
									m_From.SendMessage("Account not activated, unable to reset password.");
								}
								break;
							}
						}
					}

					break;
				default:
					break;
			}
		}
Exemple #5
0
		private void EmailCleanupWarning(Account a)
		{
			try
			{	// only on the production shard
				if (TestCenter.Enabled == false)
					if (a.EmailAddress != null && SmtpDirect.CheckEmailAddy(a.EmailAddress, false) == true)
					{
						string subject = "Angel Island: Your account will be deleted in about 5 days";
						string body = String.Format("\nThis message is to inform you that your account '{0}' will be deleted on {1} if it remains unused.\n\nIf you decide not to return to Angel Island, we would like wish you well and thank you for playing our shard.\n\nBest Regards,\n  The Angel Island Team\n\n", a.ToString(), DateTime.Now + TimeSpan.FromDays(5));
						Emailer mail = new Emailer();
						mail.SendEmail(a.EmailAddress, subject, body, false);
					}
			}
			catch (Exception ex)
			{
				LogHelper.LogException(ex);
			}
		}
Exemple #6
0
		private void EmailWarning()
		{
			try
			{	// only on the production shard
				if (TestCenter.Enabled == false)
					if (Owner != null && Owner.Account != null && Owner.Account as Accounting.Account != null)
					{
						Accounting.Account a = Owner.Account as Accounting.Account;
						if (a.EmailAddress != null && SmtpDirect.CheckEmailAddy(a.EmailAddress, false) == true)
						{
							string subject = "Angel Island: Your house is in danger of collapsing";
							string body = String.Format("\nThis message is to inform you that your house at {2} on the '{0}' account is in danger of collapsing (IDOC). If you do not return to refresh your house, it will fall on {1}.\n\nBest Regards,\n  The Angel Island Team\n\n",a.ToString(), DateTime.Now + TimeSpan.FromMinutes(m_DecayMinutesStored), BanLocation);
							Emailer mail = new Emailer();
							mail.SendEmail( a.EmailAddress, subject, body, false );
						}
					}
			}
			catch (Exception ex)
			{
				LogHelper.LogException(ex);
			}
		}
		private static Account CreateAccount(NetState state, string un, string pw)
		{
			if (un.Length == 0 || pw.Length == 0)
				return null;

			bool isSafe = true;

			for (int i = 0; isSafe && i < un.Length; ++i)
				isSafe = (un[i] >= 0x20 && un[i] < 0x80);

			for (int i = 0; isSafe && i < pw.Length; ++i)
				isSafe = (pw[i] >= 0x20 && pw[i] < 0x80);

			if (!isSafe)
				return null;

			IPAddress ip = state.Address;

			// turned off now that we allow 3 IPs per account
			/*string strIP = ip.ToString();
			int ipexception_numberallowed = 1;
			try
			{
				ipexception_numberallowed = Server.Accounting.IPException.GetIPException(strIP);
			}
			catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }*/

			int count = 0;

			foreach (Account a in Accounts.Table.Values)
			{
				if (a.LoginIPs.Length > 0)
				{
					for (int i = 0; i < a.LoginIPs.Length; i++)
					{
						try
						{
							if (a.LoginIPs[i].Equals(ip))
							{
								++count;
							}
						}
						catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
					}
				}
			}

			if (count >= MaxAccountsPerIP /*&& count >= ipexception_numberallowed*/ )
			{
				Console.WriteLine("Login: {0}: Account '{1}' not created, ip already has {2} account{3}.", state, un, MaxAccountsPerIP, MaxAccountsPerIP == 1 ? "" : "s");
				//Console.WriteLine( "Login: {0}: Account '{1}' not created, ip already has {2} account{3}.", state, un, count, count == 1 ? "" : "s" );
				return null;
			}

			//Audit email
			try
			{
				string regSubject = "Account Created Dynamically";
				string regBody = "Account created dynamically, auto-account.\n";
				regBody += "Info: \n";
				regBody += "\n";
				regBody += "Account: " + un + "\n";
				regBody += "IP: " + ip + "\n";
				regBody += "Password: "******"\n";
				regBody += "\n";
				Emailer mail = new Emailer();
				mail.SendEmail("*****@*****.**", regSubject, regBody, false);
			}
			catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }

			Console.WriteLine("Login: {0}: Creating new account '{1}'", state, un);
			return Accounts.AddAccount(un, pw);
		}