Esempio n. 1
0
        /// <summary>
        /// Try to Login to the Forums
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void LoginBtnClick(object sender, EventArgs e)
        {
            // Encrypt Password
            this.textBox2.Text = Utility.EncodePassword(this.textBox2.Text).Replace("-", string.Empty).ToLower();

            var loginManager = new LoginManager(this.textBox1.Text, this.textBox2.Text);

            var welcomeMessage = this._ResourceManager.GetString("lblWelcome");
            var failedMessage = this._ResourceManager.GetString("lblFailed");

            if (loginManager.DoLogin(CacheController.Instance().UserSettings.ForumURL))
            {
                this.label3.Text = string.Format("{0}{1}", welcomeMessage, this.textBox1.Text);
                this.label3.ForeColor = Color.Green;
                this.LoginBtn.Enabled = false;

                SettingsHelper.SaveSetting("User", this.textBox1.Text);
                SettingsHelper.SaveSetting("Password", this.textBox2.Text);

                this.timer1.Enabled = true;
            }
            else
            {
                this.label3.Text = failedMessage;
                this.label3.ForeColor = Color.Red;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Auto login if User Credentials exists in Config file.
        /// if no Data show Login Form
        /// </summary>
        private void AutoLogin()
        {
            bool accountExists = false;
            var currentForumAccount = new ForumAccount();

            foreach (var forumAccount in CacheController.Instance().UserSettings.ForumsAccount.Where(
                    forumAccount =>
                        forumAccount.ForumURL.Equals(CacheController.Instance().UserSettings.CurrentForumUrl)).Where(
                        forumAccount => !string.IsNullOrEmpty(forumAccount.UserName) && !string.IsNullOrEmpty(forumAccount.UserPassWord)))
            {
                currentForumAccount = forumAccount;
                accountExists = true;
            }

            if (accountExists)
            {
                if (currentForumAccount.GuestAccount)
                {
                    this.cameThroughCorrectLogin = true;
                }
                else
                {
                    LoginManager lgnMgr = new LoginManager(currentForumAccount.UserName, currentForumAccount.UserPassWord);

                    if (lgnMgr.DoLogin(CacheController.Instance().UserSettings.CurrentForumUrl))
                    {
                        this.cameThroughCorrectLogin = true;
                    }
                    else
                    {
                        Login frmLgn = new Login();
                        frmLgn.ShowDialog(this);

                        DialogResult result = TopMostMessageBox.Show(
                            this._ResourceManager.GetString("mbExit"),
                            this._ResourceManager.GetString("mbExitTtl"),
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question);

                        if (result == DialogResult.Yes)
                        {
                            Application.Exit();
                        }
                    }
                }
            }
            else
            {
                Login frmLgn = new Login();
                frmLgn.ShowDialog(this);

                Application.Exit();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Tries to Login to the Forums
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void LoginBtnClick(object sender, EventArgs e)
        {
            if (this.ForumUrl.Text.StartsWith("http://"))
            {
                if (!this.ForumUrl.Text.EndsWith("/"))
                {
                    this.ForumUrl.Text += "/";
                }

                CacheController.Instance().UserSettings.CurrentForumUrl = this.ForumUrl.Text;
            }

            string welcomeString = this.rm.GetString("lblWelcome"), lblFailed = this.rm.GetString("lblFailed");

            if (this.GuestLogin.Checked)
            {
                this.UserNameField.Text = "Guest";
                this.PasswordField.Text = "Guest";

                this.label3.Text = string.Format("{0}{1}", welcomeString, this.UserNameField.Text);
                this.label3.ForeColor = Color.Green;
                this.LoginButton.Enabled = false;

                if (
                    CacheController.Instance().UserSettings.ForumsAccount.Any(
                        item => item.ForumURL == CacheController.Instance().UserSettings.CurrentForumUrl))
                {
                    CacheController.Instance().UserSettings.ForumsAccount.RemoveAll(
                        item => item.ForumURL == CacheController.Instance().UserSettings.CurrentForumUrl);
                }

                var forumsAccount = new ForumAccount
                {
                    ForumURL = CacheController.Instance().UserSettings.CurrentForumUrl,
                    UserName = this.UserNameField.Text,
                    UserPassWord = this.PasswordField.Text,
                    GuestAccount = false
                };

                CacheController.Instance().UserSettings.ForumsAccount.Add(forumsAccount);
                CacheController.Instance().UserSettings.CurrentUserName = this.UserNameField.Text;

                this.timer1.Enabled = true;
            }
            else
            {
                // Encrypt Password
                this.PasswordField.Text =
                    Utility.EncodePassword(this.PasswordField.Text).Replace("-", string.Empty).ToLower();

                var loginManager = new LoginManager(this.UserNameField.Text, this.PasswordField.Text);

                if (loginManager.DoLogin(CacheController.Instance().UserSettings.CurrentForumUrl))
                {
                    this.label3.Text = string.Format("{0}{1}", welcomeString, this.UserNameField.Text);
                    this.label3.ForeColor = Color.Green;
                    this.LoginButton.Enabled = false;

                    if (
                        CacheController.Instance().UserSettings.ForumsAccount.Any(
                            item => item.ForumURL == CacheController.Instance().UserSettings.CurrentForumUrl))
                    {
                        CacheController.Instance().UserSettings.ForumsAccount.RemoveAll(
                            item => item.ForumURL == CacheController.Instance().UserSettings.CurrentForumUrl);
                    }

                    var forumsAccount = new ForumAccount
                                            {
                                                ForumURL = CacheController.Instance().UserSettings.CurrentForumUrl,
                                                UserName = this.UserNameField.Text,
                                                UserPassWord = this.PasswordField.Text,
                                                GuestAccount = false
                                            };

                    CacheController.Instance().UserSettings.ForumsAccount.Add(forumsAccount);
                    CacheController.Instance().UserSettings.CurrentUserName = this.UserNameField.Text;

                    this.timer1.Enabled = true;
                }
                else
                {
                    this.label3.Text = lblFailed;
                    this.label3.ForeColor = Color.Red;
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Switches the current forum account to the forum Url
        /// </summary>
        /// <param name="forumUrl">The forum URL.</param>
        private void SwitchCurrentForumAccount(string forumUrl)
        {
            ForumAccount currentAccount = null;

            foreach (var forumAccount in
                CacheController.Instance().UserSettings.ForumsAccount.Where(forumAccount => forumUrl.StartsWith(forumAccount.ForumURL)).Where(
                    forumAccount =>
                    !string.IsNullOrEmpty(forumAccount.UserName) && !string.IsNullOrEmpty(forumAccount.UserPassWord)))
            {
                currentAccount = forumAccount;
            }

            if (currentAccount != null)
            {
                CacheController.Instance().UserSettings.CurrentForumUrl = currentAccount.ForumURL;
                CacheController.Instance().UserSettings.CurrentUserName = currentAccount.UserName;

                if (currentAccount.GuestAccount)
                {
                    this.cameThroughCorrectLogin = true;
                    this.CheckAccountMenu();
                }
                else
                {
                    var lgnMgr = new LoginManager(currentAccount.UserName, currentAccount.UserPassWord);

                    if (lgnMgr.DoLogin(CacheController.Instance().UserSettings.CurrentForumUrl))
                    {
                        this.cameThroughCorrectLogin = true;
                        this.CheckAccountMenu();
                    }
                    else
                    {
                        this.Visible = false;

                        Login frmLgn = new Login();
                        frmLgn.ShowDialog(this);

                        this.Visible = true;
                    }
                }
            }
            else
            {
                return;
            }

            var header = this._ResourceManager.GetString("ttlHeader");

            #if (PGRIPPER)
            Text = string.Format(
                "PG-Ripper {0}.{1}.{2}{3}{4}",
                Assembly.GetExecutingAssembly().GetName().Version.Major.ToString("0"),
                Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString("0"),
                Assembly.GetExecutingAssembly().GetName().Version.Build.ToString("0"),
                Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString("0"),
                string.Format("{0}{1}\" @ {2} ]", header, CacheController.Instance().UserSettings.CurrentUserName, CacheController.Instance().UserSettings.CurrentForumUrl));
            #elif (PGRIPPERX)
                Text = string.Format("PG-Ripper X {0}.{1}.{2}{3}{4}",
                    Assembly.GetExecutingAssembly().GetName().Version.Major.ToString("0"),
                    Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString("0"),
                    Assembly.GetExecutingAssembly().GetName().Version.Build.ToString("0"),
                    Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString("0"),
                    string.Format("{0}{1}\" @ {2} ]", header, CacheController.Instance().UserSettings.CurrentUserName, CacheController.Instance().UserSettings.CurrentForumUrl));
            #else
            Text = string.Format(
                "PG-Ripper {0}.{1}.{2}{3}{4}",
                Assembly.GetExecutingAssembly().GetName().Version.Major.ToString("0"),
                Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString("0"),
                Assembly.GetExecutingAssembly().GetName().Version.Build.ToString("0"),
                Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString("0"),
                string.Format(
                    "{0}{1}\" @ {2} ]", header, CacheController.Instance().UserSettings.CurrentUserName, CacheController.Instance().UserSettings.CurrentForumUrl));
            #endif
        }
Esempio n. 5
0
        /// <summary>
        /// Auto login if User Credentials exists in Config file.
        /// if no Data show Login Form
        /// </summary>
        public void AutoLogin()
        {
            if (CacheController.Instance().UserSettings.User != null && CacheController.Instance().UserSettings.Pass != null)
            {
                LoginManager lgnMgr = new LoginManager(CacheController.Instance().UserSettings.User, CacheController.Instance().UserSettings.Pass);

                if (lgnMgr.DoLogin(CacheController.Instance().UserSettings.ForumURL))
                {
                    this.cameThroughCorrectLogin = true;
                }
                else
                {
                    Login frmLgn = new Login();
                    frmLgn.ShowDialog(this);

                    DialogResult result = TopMostMessageBox.Show(
                        this._ResourceManager.GetString("mbExit"),
                        this._ResourceManager.GetString("mbExitTtl"),
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question);

                    if (result == DialogResult.Yes)
                    {
                        Application.Exit();
                    }
                }
            }
            else
            {
                Login frmLgn = new Login();
                frmLgn.ShowDialog(this);

                this.cameThroughCorrectLogin = false;
            }
        }