示例#1
0
        void saveButton_Click(object sender, EventArgs e)
        {
            string    lift = "";
            gymstatDB mydb = new gymstatDB();

            switch (LiftSelector.SelectedIndex)
            {
            case 0:
                lift = "squats";
                break;

            case 1:
                lift = "press";
                break;

            case 2:
                lift = "deadlift";
                break;

            default:
                break;
            }
            WorkoutIDText.Text = "Submitted that you did set " + setBox.Text + " for " + repBox.Text + " reps at " + weightBox.Text + " doing " + lift;
            if (mydb.insertWorkout(lift, lastWorkout, setBox.Text, repBox.Text, weightBox.Text))
            {
                WorkoutIDText.Text = "Submitted that you did set " + setBox.Text + " for " + repBox.Text + " reps at " + weightBox.Text + " doing " + lift;
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string username = crypto.validateCookies(Request.Cookies);

            saveButton.Click += saveButton_Click;
            string date  = DateTime.Now.ToString("yyyy-MM-dd");
            string start = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            welcome.Text = "Welcome " + username + " " + date + " " + start;
            gymstatDB mydb = new gymstatDB();

            if (mydb.startWorkout(username))
            {
                lastWorkout = mydb.getLastWorkoutID(username);
                if (mydb.startWorkoutA(lastWorkout))
                {
                    if (mydb.enterStartTimes(lastWorkout, date, start))
                    {
                        WorkoutIDText.Text = "Created New Workout with Workout ID: " + lastWorkout + " " + LiftSelector.SelectedIndex.ToString();;
                    }
                }
            }
            else
            {
                WorkoutIDText.Text = "Failed to create workout";
            }
            LiftSelector.SelectedIndex.ToString();
        }
示例#3
0
        void logButton_Click(object sender, EventArgs e)
        {
            gymstatDB mydb = new gymstatDB();

            if (crypto.sha256_hash(passwordText.Text) == mydb.getHashedPassword(usernameText.Text))
            {
                crypto.installCookies(Response.Cookies, usernameText.Text, crypto.sha256_hash(passwordText.Text));
                Response.Redirect("LoginSuccess.aspx");
            }
        }
示例#4
0
        void registerButton_Click(object sender, EventArgs e)
        {
            gymstatDB mydb = new gymstatDB();

            if (mydb.registerNewUser(usernameText.Text, crypto.sha256_hash(passwordText.Text), crypto.sha256_hash(vpasswordText.Text)))
            {
                crypto.installCookies(Response.Cookies, usernameText.Text, crypto.sha256_hash(passwordText.Text));

                Response.Redirect("RegisterSuccess.aspx");
            }
            else
            {
                usernameText.Text  = "";
                passwordText.Text  = "";
                vpasswordText.Text = "";
                registerError.Text = "Username already Taken or passwords did not match, Try Again";
            }
        }
示例#5
0
        internal static bool validateCookies(HttpCookieCollection cook, bool test)
        {
            if ((cook["username"] != null) && cook["secureCookie"] != null)
            {
                gymstatDB mydb       = new gymstatDB();
                string    username   = cook["username"].Value;
                string    hashedpw   = mydb.getHashedPassword(username);
                string    trueHashed = crypto.sha256_hash(hashedpw + username);

                if (cook["secureCookie"].Value == trueHashed)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
示例#6
0
        internal static string validateCookies(HttpCookieCollection cook)
        {
            if ((cook["username"] != null) && cook["secureCookie"] != null)
            {
                gymstatDB mydb       = new gymstatDB();
                crypto    mycrypto   = new crypto();
                string    username   = cook["username"].Value;
                string    hashedpw   = mydb.getHashedPassword(username);
                string    trueHashed = crypto.sha256_hash(hashedpw + username);

                if (cook["secureCookie"].Value.StartsWith(trueHashed))
                {
                    return(username);
                }
                else
                {
                    return("");
                }
            }
            else
            {
                return("");
            }
        }