Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string   mycookie  = "";
            string   mysession = "";
            desclass mydes     = new desclass();

            try
            {
                mysession = Session["username"].ToString();
            }
            catch
            { mysession = null; }

            try
            {
                mycookie = Request.Cookies["name"].Value;
            }
            catch
            {
                mycookie = null;
            }
            string ownname = mydes.yanzheng(mycookie, mysession);

            if (ownname != null)
            {
                gloadmyname = ownname;
                mysql sql = new mysql();
                GridView1.DataSource = sql.viewcode(ownname, "", 1);
                GridView1.DataBind();
            }
            else
            {
                Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "login.aspx");
            }
        }
Пример #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string   name  = Text1.Value;
            string   pass  = Text2.Value;
            Boolean  isok  = false;
            mysql    sql   = new mysql();
            desclass mydes = new desclass();

            if (name == "" || pass == "")
            {
                Label3.Text = "用户名密码不能为空";
            }
            else
            {
                pass = mydes.EnCode(pass);
                pass = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pass, "MD5");
                isok = sql.login(name, pass, 1);
                if (isok == false)
                {
                    Label3.Text = "用户名或密码错误";
                }
                else
                {
                    string desname = mydes.EnCode(name);
                    Session["username"] = name;
                    HttpCookie myHttpCookie = new HttpCookie("name", desname);
                    myHttpCookie.HttpOnly = true;
                    Response.AppendCookie(myHttpCookie);
                    Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "viewcode.aspx");
                }
            }
        }
Пример #3
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            mysql sql = new mysql();

            sql.deletecode(GridView1.Rows[e.RowIndex].Cells[1].Text.ToString(), "", 2);

            Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "viewcode.aspx");
        }
Пример #4
0
        public void ProcessRequest(HttpContext context)
        {
            mysql  sql      = new mysql();
            string username = context.Request["username"];

            Boolean isusname = sql.login(username, "", 2);

            context.Response.Write(isusname);
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            xssfile  xf    = new xssfile();
            mysql    sql   = new mysql();
            desclass mydes = new desclass();
            string   flag  = "false";

            flag = Request["flag"];

            string mycookie  = "";
            string mysession = "";

            try
            {
                mysession = Session["username"].ToString();
            }
            catch
            { mysession = null; }

            try
            {
                mycookie = Request.Cookies["name"].Value;
            }
            catch
            {
                mycookie = null;
            }
            string ownname = mydes.yanzheng(mycookie, mysession);

            if (ownname != null)
            {
                if (flag == "true")
                {
                    string codetitle    = Request["codetitle"];
                    string codeducument = Request["codeducument"];
                    string beizhu       = Request["beizhu"];
                    string mynname      = ownname;
                    string yuancode     = codeducument;
                    codetitle = xf.filet(codetitle);
                    //   codeducument = xf.filet(codeducument);
                    beizhu = xf.filet(beizhu);

                    sql.createcode(mynname, codetitle, codeducument, beizhu, yuancode);

                    Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "viewcode.aspx");
                }
            }
            else
            {
                Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "login.aspx");
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string flag = "false";

            flag = Request["flag"];
            if (flag == "true")
            {
                string   name = "", psw = "", mail = "";
                mysql    sql   = new mysql();
                xssfile  xs    = new xssfile();
                desclass mydes = new desclass();
                name = Request["name"];
                psw  = Request["mima1"];
                mail = Request["mail"];



                if (name == "" || psw == "" || mail == "")
                {
                    Label4.Text = "用户名或密码或邮箱不能为空";
                }
                else
                {
                    name = xs.filet(name);
                    psw  = xs.filet(psw);
                    mail = xs.filet(mail);

                    Regex regn     = new Regex(@"^[A-Za-z0-9_]+$");
                    bool  nameisok = regn.IsMatch(name);
                    if (nameisok == false)
                    {
                        Response.Write("用户名必须是3 -16个字母,数字,下划线"); return;
                    }

                    Regex regm     = new Regex(@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
                    bool  mailisok = regn.IsMatch(mail);
                    if (nameisok == false)
                    {
                        Response.Write("邮箱格式不正确"); return;
                    }


                    psw = mydes.EnCode(psw);
                    psw = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(psw, "MD5");
                    sql.register(name, psw, mail);

                    createfile(name);

                    Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "login.aspx");
                }
            }
        }
Пример #7
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            mysql sql = new mysql();

            sql.deletecode(GridView1.Rows[e.RowIndex].Cells[0].Text.ToString(), gloadmyname, 1);
            string filename = sql.selectcode(GridView1.Rows[e.RowIndex].Cells[0].Text.ToString(), gloadmyname, 2);

            if (File.Exists(filename))
            {
                //如果存在则删除
                File.Delete(filename);
            }
            Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "viewcode.aspx");
        }
Пример #8
0
        public void ProcessRequest(HttpContext context)
        {
            mysql   sql    = new mysql();
            xssfile xs     = new xssfile();
            string  cookie = "";
            string  codeid = context.Request["codeid"];

            cookie = context.Request["cookie"];

            // cookie = xs.filet(cookie);

            sql.inster(cookie, codeid);
            sql.sendmail(codeid);
            context.Response.Write(" ");
        }
Пример #9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string code = "";
            mysql  sql  = new mysql();

            code = sql.selectcode(mycodeid, mynameis, 1);

            if (code != null)
            {
                Random       ran     = new Random();
                int          RandKey = ran.Next(100, 999);
                string       path    = System.Configuration.ConfigurationManager.AppSettings["localpath"].ToString() + mynameis + "\\" + DateTime.Now.ToFileTimeUtc() + RandKey.ToString() + ".js";
                FileStream   fs      = new FileStream(path, FileMode.Append);
                StreamWriter sw      = new StreamWriter(fs);
                sw.Write(code);
                sw.Close();
                fs.Close();
                Label1.Text = path;
                sql.deletecode(mycodeid, path, 3);
            }
        }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            desclass mydes     = new desclass();
            string   codeid    = Request["codeid"];
            string   mycookie  = "";
            string   mysession = "";

            try
            {
                mysession = Session["username"].ToString();
            }
            catch
            { mysession = null; }

            try
            {
                mycookie = Request.Cookies["name"].Value;
            }
            catch
            {
                mycookie = null;
            }
            string ownname = mydes.yanzheng(mycookie, mysession);

            if (ownname != null)
            {
                Label1.Text = "你好" + ownname;
                mysql sql = new mysql();
                if (codeid == "" || codeid == null)
                {
                    Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "viewcode.aspx"); return;
                }
                GridView1.DataSource = sql.viewcode(codeid, ownname, 2);
                GridView1.DataBind();
            }
            else
            {
                Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "login.aspx");
            }
        }
Пример #11
0
        public string yanzheng(string cookie, string sessinname)
        {
            mysql sql = new mysql();

            if (sessinname == "" || sessinname == null)
            {
                if (cookie == "" || cookie == null)
                {
                    return(null);
                }
                else
                {
                    string mycookie = DesDecrypt(cookie);
                    bool   isok     = sql.login(mycookie, "", 3);
                    if (isok == true)
                    {
                        return(mycookie);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            else
            {
                bool isok = sql.login(sessinname, "", 3);
                if (isok == true)
                {
                    return(sessinname);
                }
                else
                {
                    return(null);
                }
            }
        }
Пример #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request["FormView1$button1"].ToString() == "提交编辑代码")
                {
                    mysql   sql      = new mysql();
                    xssfile xs       = new xssfile();
                    string  beizhu   = Request["FormView1$beizhu"];
                    string  document = Request["FormView1$mycodedocument"];
                    string  title    = Request["FormView1$mycodename"];
                    string  codeid   = Request["codeid"];

                    beizhu = xs.filet(beizhu);
                    title  = xs.filet(title);


                    sql.updatecode(codeid, title, document, beizhu);

                    Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "success.html");
                    return;
                }
            }
            catch
            {
            }
            string   mycookie  = "";
            string   mysession = "";
            desclass mydes     = new desclass();

            try
            {
                mysession = Session["username"].ToString();
            }
            catch
            { mysession = null; }

            try
            {
                mycookie = Request.Cookies["name"].Value;
            }
            catch
            {
                mycookie = null;
            }
            string ownname = mydes.yanzheng(mycookie, mysession);

            if (ownname != null)
            {
                mycodeid = Request["codeid"];
                if (mycodeid == "" || mycodeid == null)
                {
                    Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "viewcode.aspx"); return;
                }
                mynameis = ownname;

                mysql sql = new mysql();

                FormView1.DataSource = sql.viewcode(mycodeid, ownname, 3);
                FormView1.DataBind();
            }
            else
            {
                Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "login.aspx");
            }
        }