Beispiel #1
0
 protected void Unnamed_Click(object sender, EventArgs e)
 {
     UserDB ins=new UserDB();
     crypt c = new crypt();
     List<String> ret = ins.Read_Login(Request.Cookies["logincookie"]["nickname"], c.GetMd5Hash(cp.Text));
     if (ret.Count != 0)
     {
         if (np.Text != npc.Text)
         {
             warn.Text = "New Password and Confirmation must match!";
             warn.Visible = true;
         }
         else
         {
             ret = new List<String>();
             ret.Add(Request.Cookies["logincookie"]["nickname"]);
             ret.Add(c.GetMd5Hash(cp.Text));
             ret.Add(c.GetMd5Hash(np.Text));
             ins.Update_Password(ret);
         }
     }
     else
     {
         warn.Text = "Current password incorrect!";
         warn.Visible = true;
     }
 }
        //Login
        protected void Button1_Click(object sender, EventArgs e)
        {
            UserDB ins=new UserDB();
                crypt c = new crypt();
                List<String> ret = ins.Read_Login(lname.Text, c.GetMd5Hash(pwd.Text));

                    if (ret.Count != 0)
                    {
                        logintext.Text = "Logged in as " + ret[0].Split(((char)007))[1];
                        logintext.Visible = true;
                        LogoutKlick.Visible = true;

                        HttpCookie nc = new HttpCookie("logincookie");
                        nc.Values.Add("nickname", ret[0].Split(((char)007))[1]);
                        nc.Values.Add("id", ret[0].Split(((char)007))[0]);
                        nc.Values.Add("type", ret[0].Split(((char)007))[2]);
                        nc.Expires = DateTime.Now.AddMinutes(15);
                        Response.Cookies.Add(nc);
                    }
                    else
                    {
                        logintext.Text = "Invalid login data";
                        logintext.Visible = true;
                    }
        }
Beispiel #3
0
 protected void usc(object sender, EventArgs e)
 {
     UserDB ins = new UserDB();
     if (ca.SelectedValue != "3")
     {
         if (ca.SelectedValue == "2") ins.Update_User(uss.SelectedValue, "moderator");
         else ins.Update_User(uss.SelectedValue, "regular");
     }
     else
     {
         ins.Delete_User(uss.SelectedValue);
     }
 }
Beispiel #4
0
        protected void Unnamed_Click(object sender, EventArgs e)
        {
            UserDB ins=new UserDB();
            List<String> ls = ins.Read_Users();
            for (int i = 1; i < ls.Count;i++ )
            {
                if (user.Text == ls[i].Split(((char)007))[0] || email.Text == ls[i].Split(((char)007))[1])
                {
                    if (user.Text == ls[i].Split(((char)007))[0])
                    {
                        warn.Text = "Chosen username already in use. Please choose a different username.";
                    }
                    else
                    {
                        warn.Text = "Chosen email already in use. Please choose a different email.";
                    }
                    warn.Visible = true;
                    break;
                }
                else if(i + 1 == ls.Count)
                {
                    ls = new List<String>();
                    ls.Add(user.Text);
                    crypt c = new crypt();
                    ls.Add(c.GetMd5Hash(pwd.Text));
                    ls.Add(email.Text);
                    ins.Create_New_User(ls);

                    MailMessage nm = new MailMessage();
                    nm.From = new MailAddress("*****@*****.**");
                    nm.To.Add(new MailAddress(email.Text));
                    nm.Subject = "Your new ITP5-Gaming-Website Account";
                    nm.Body = "Your new account has been created. Your Username is " + user.Text + " and your password is " + pwd.Text + " Greetings, The Website-Team";
                    SmtpClient smtp = new SmtpClient("smtp.gmail.com");
                    smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "project5SMTP");
                    smtp.EnableSsl = true;
                    smtp.Send(nm);

                    warn.Text = "Your account was successfully created. Check your email address for your username and password.";
                    warn.Visible = true;
                }
            }
        }
Beispiel #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     HttpCookie nc = Request.Cookies["logincookie"];
     if (nc != null)
     {
         paneltext.Visible = false;
         reg.Visible = true;
         if (nc["type"] == "moderator" || nc["type"] == "admin") mod.Visible = true;
         if (nc["type"] == "admin")
         {
             adm.Visible = true;
             UserDB ins = new UserDB();
             List<String> ls = ins.Read_Users();
             for (int i = 0; i < ls.Count; i++)
             {
                 if (ls[i].Split(((char)007))[0] != nc["nickname"])
                 {
                     uss.Items.Add(new ListItem(ls[i].Split(((char)007))[0] + " is " + ls[i].Split(((char)007))[3], ls[i].Split(((char)007))[2]));
                 }
             }
         }
     }
 }