Ejemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string username = TextBox1.Text;
            string password = TextBox2.Text;

            if (username.Equals("adminy") && password.Equals("greatscott"))
            {
                Cookie.Save(Response, "mySiteAccount", username, 365);
                Cookie.Save(Response, "mySiteAccountPassword", password, 365);

                Session["username"] = username;

                Response.Redirect("Admin.aspx");
                return;
            }

            var acct = new KeyClueAccount(username);

            if (acct.Valid && acct.Password.Equals(password))
            {
                Cookie.Save(Response, "mySiteAccount", username, 365);
                Cookie.Save(Response, "mySiteAccountPassword", password, 365);

                Session["username"] = username;

                Response.Redirect("Default.aspx");
            }
        }
Ejemplo n.º 2
0
        protected bool GetAccountCookie()
        {
            string acct = Cookie.Load(Request, "mySiteAccount");

            if ("adminy".Equals(acct))
            {
                return(true);
            }
            if (!acct.Equals(""))
            {
                Account = new KeyClueAccount(acct);
                if (!Account.Valid)
                {
                    Account = null;
                    return(false);
                }
                string pwd = Cookie.Load(Request, "mySiteAccountPassword");
                if (!pwd.Equals(Account.Password))
                {
                    Account = null;
                    return(false);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
        protected override void finishPageLoad()
        {
            base.finishPageLoad();

            string username = Cookie.Load(Request, "mySiteAccount");

            if (!"adminy".Equals(username))
            {
                logOut();
                return;
            }

            var acct = new KeyClueAccount("Zoo");

            TextBox1.Text = acct.Stage.ToString();

            acct          = new KeyClueAccount("Geo");
            TextBox2.Text = acct.Stage.ToString();

            acct          = new KeyClueAccount("Mech");
            TextBox3.Text = acct.Stage.ToString();

            acct          = new KeyClueAccount("Chem");
            TextBox4.Text = acct.Stage.ToString();

            acct          = new KeyClueAccount("Civil");
            TextBox5.Text = acct.Stage.ToString();
        }
Ejemplo n.º 4
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            var acct = new KeyClueAccount("Zoo");

            acct.Stage = int.Parse(TextBox1.Text);
            acct.Write();
            acct       = new KeyClueAccount("Geo");
            acct.Stage = int.Parse(TextBox2.Text);
            acct.Write();
            acct       = new KeyClueAccount("Mech");
            acct.Stage = int.Parse(TextBox3.Text);
            acct.Write();
            acct       = new KeyClueAccount("Chem");
            acct.Stage = int.Parse(TextBox4.Text);
            acct.Write();
            acct       = new KeyClueAccount("Civil");
            acct.Stage = int.Parse(TextBox5.Text);
            acct.Write();
            logOut();
        }
Ejemplo n.º 5
0
        protected override void finishPageLoad()
        {
            base.finishPageLoad();

            Label1.Text = Cookie.Load(Request, "mySiteAccount");

            string username = Label1.Text;
            var    acct     = new KeyClueAccount(username);

            if (acct.BStage == 1)
            {
                Label2.Visible      = false;
                LinkButton1.Visible = false;
            }

            string strReq = Request.QueryString["file"];

            if ("20130108.zip".Equals(strReq))
            {
                string path = "E:\\KeyClueFiles\\";
                switch (acct.Stage)
                {
                default:
                case 0: path += "stage0"; break;

                case 1: path += "stage1"; break;

                case 2: path += "stage2"; break;

                case 3: path += "stage3"; break;
                }
                path += "\\20130108.zip";
                //path = Server.MapPath(path);
                var f = new System.IO.FileInfo(path);
                if (f.Exists)
                {
                    Response.Clear();
                    Response.AddHeader("Content-Disposition", "attachment; filename=20130108.zip");
                    Response.AddHeader("Content-Length", f.Length.ToString());
                    Response.ContentType = "application/octet-stream";
                    Response.WriteFile(f.FullName);
                    Response.End();
                }
                else
                {
                    Response.Write("This file does not exist.");
                }
            }
            else if (acct.BStage == 0 && "20130103.zip".Equals(strReq))
            {
                string path = "E:\\KeyClueFiles\\dummy\\20130103.zip";
                var    f    = new System.IO.FileInfo(path);
                if (f.Exists)
                {
                    Response.Clear();
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + strReq);
                    Response.AddHeader("Content-Length", f.Length.ToString());
                    Response.ContentType = "application/octet-stream";
                    Response.WriteFile(f.FullName);
                    Response.End();
                }
                else
                {
                    Response.Write("This file does not exist.");
                }
            }
            else if (strReq != null && !"".Equals(strReq))
            {
                string path = "E:\\KeyClueFiles\\dummy\\dummy.zip";
                var    f    = new System.IO.FileInfo(path);
                if (f.Exists)
                {
                    Response.Clear();
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + strReq);
                    Response.AddHeader("Content-Length", f.Length.ToString());
                    Response.ContentType = "application/octet-stream";
                    Response.WriteFile(f.FullName);
                    Response.End();
                }
                else
                {
                    Response.Write("This file does not exist.");
                }
            }
        }