Ejemplo n.º 1
0
        /// <summary>
        ///     Invoked when the reset button is clicked.
        /// </summary>
        /// <param name="sender">Object that caused this event to be triggered.</param>
        /// <param name="e">Arguments explaining why this event occured.</param>
        private void resetButton_Click(object sender, EventArgs e)
        {
            string email = emailTextBox.Text;

            if (email == null || !email.Contains("@"))
            {
                MessageBox.Show("A valid email must be entered.", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                ProgressWindow progressWindow = new ProgressWindow("Reseting Password", "Contacting server");
                progressWindow.Marquee = true;
                progressWindow.Show();
                this.Enabled = false;

                FileDownloader downloader = new FileDownloader("http://www.binaryphoenix.com/index.php?action=fusionresetpassword&email=" + System.Web.HttpUtility.UrlEncode(email));
                downloader.Start();
                while (downloader.Complete == false)
                {
                    if (downloader.Error != "")
                    {
                        MessageBox.Show("An error occured while connecting to the server. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    Application.DoEvents();
                }

                this.Enabled = true;
                progressWindow.Dispose();

                ASCIIEncoding encoding = new ASCIIEncoding();
                string        response = encoding.GetString(downloader.FileData);
                if (response.ToLower() == "noaccount")
                {
                    MessageBox.Show("No account exists with the email that your provided.", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (response.ToLower() == "invalid")
                {
                    MessageBox.Show("The email you provided was invalid.", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (response.ToLower() == "valid")
                {
                    MessageBox.Show("An email has been sent to the email account we have in our database. It contains a link to a webpage you can reset your password at.", "Password Reset", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = DialogResult.OK;
                    Close();
                    return;
                }
                else
                {
                    MessageBox.Show("Unexpected value returned from server. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            DialogResult = DialogResult.Cancel;
            Close();
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Invoked when the login button is clicked.
        /// </summary>
        /// <param name="sender">Object that caused this event to be triggered.</param>
        /// <param name="e">Arguments explaining why this event occured.</param>
        private void loginButton_Click(object sender, EventArgs e)
        {
            string password = passwordTextBox.Text;
            string username = usernameTextBox.Text;

            if (password == null || password.Length < 6 ||
                username == null || username.Length < 6)
            {
                MessageBox.Show("A password and username must be entered. Both must be equal to or longer than 6 characters", "Invalid Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                ProgressWindow progressWindow = new ProgressWindow("Logging in", "Verifying login");
                progressWindow.Marquee = true;
                progressWindow.Show();
                this.Enabled = false;

                FileDownloader downloader = new FileDownloader("http://www.binaryphoenix.com/index.php?action=fusionverifylogin&username="******"&password="******"")
                    {
                        MessageBox.Show("An error occured while connecting to the server. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    Application.DoEvents();
                }

                this.Enabled = true;
                progressWindow.Dispose();

                ASCIIEncoding encoding = new ASCIIEncoding();
                string        response = encoding.GetString(downloader.FileData);
                if (response.ToLower() == "invalid")
                {
                    MessageBox.Show("The login given was invalid. If you have lost your password please click the password reset link.", "Invalid Login", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (response.ToLower() == "valid")
                {
                    MessageBox.Show("Your login was successfull.", "Valid Login", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Place the password / username in the config file if we are to remember them.
                    Fusion.GlobalInstance.CurrentUsername = username;
                    Fusion.GlobalInstance.CurrentPassword = password;
                    Fusion.GlobalInstance.RememberUser    = rememberMeCheckBox.Checked;

                    Close();
                }
                else
                {
                    MessageBox.Show("Unexpected value returned from server. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Invoked when the register button is clicked.
        /// </summary>
        /// <param name="sender">Object that caused this event to be triggered.</param>
        /// <param name="e">Arguments explaining why this event occured.</param>
        private void registerButton_Click(object sender, EventArgs e)
        {
            string email           = emailTextBox.Text;
            string displayName     = displaynameTextBox.Text;
            string username        = usernameTextBox.Text;
            string password        = passwordTextBox.Text;
            string confirmPassword = confirmPasswordTextBox.Text;

            if (email == null || !email.Contains("@"))
            {
                MessageBox.Show("A valid email must be entered.", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (username == null || username.Length < 6)
            {
                MessageBox.Show("A valid username must be entered.", "Invalid Username", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (password.ToLower() != confirmPassword.ToLower())
            {
                MessageBox.Show("Your passwords do not match.", "Invalid Password", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (password.Length < 6)
            {
                MessageBox.Show("A valid password must be entered.", "Invalid Password", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                ProgressWindow progressWindow = new ProgressWindow("Registering", "Contacting server");
                progressWindow.Marquee = true;
                progressWindow.Show();
                this.Enabled = false;

                FileDownloader downloader = new FileDownloader("http://www.binaryphoenix.com/index.php?action=fusionregister&email=" + System.Web.HttpUtility.UrlEncode(email) + "&username="******"&password="******"" ? ("&displayname=" + System.Web.HttpUtility.UrlEncode(displayName)) : ""));
                downloader.Start();
                while (downloader.Complete == false)
                {
                    if (downloader.Error != "")
                    {
                        MessageBox.Show("An error occured while connecting to the server. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    Application.DoEvents();
                }

                this.Enabled = true;
                progressWindow.Dispose();

                ASCIIEncoding encoding = new ASCIIEncoding();
                string        response = encoding.GetString(downloader.FileData);
                if (response.ToLower() == "usernameinuse")
                {
                    MessageBox.Show("An account already exists with the username that your provided.", "Invalid Register", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (response.ToLower() == "emailinuse")
                {
                    MessageBox.Show("An account already exists with the email that your provided.", "Invalid Register", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (response.ToLower() == "valid")
                {
                    MessageBox.Show("Your account has successfully been registered with the server and you have been logged in. We hope you like being a member of Binary Phoenix's community.", "Registration Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = DialogResult.OK;
                    Close();
                    Fusion.GlobalInstance.CurrentUsername = username;
                    Fusion.GlobalInstance.CurrentPassword = password;
                    return;
                }
                else
                {
                    MessageBox.Show("Unexpected value returned from server. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }