public void ProcessRequest(HttpContext context)
        {
            string         tbxforgetAccount = context.Request.Form["tbxforgetAccount"].ToString().Trim();
            security       sec      = new security();
            Email          myEmail  = new Email();
            ForGetPassW_DB myForGet = new ForGetPassW_DB();

            if (tbxforgetAccount.ToString().Trim() == "")
            {
                context.Response.Write("請輸入E-mail");
                return;
            }
            else
            {
                //找出此EMAIL是否已註冊過
                DataTable dt = myForGet.SelectEmailExist(tbxforgetAccount.ToUpper());
                if (dt.Rows.Count == 1)
                {
                    //註冊過 寄信給此EMAIL更改連結 並變換QueryStr
                    /* 底下為本來密碼自動產生 不過規格取消 所以拿來用在querystring上 */
                    Random   rdm     = new Random();
                    string[] seeds   = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
                    int      strLen  = (int)rdm.Next(5, 11);
                    string   randStr = string.Empty;
                    for (int i = 0; i < strLen; i++)
                    {
                        randStr += seeds[rdm.Next(seeds.Length)].ToString().ToUpper();
                    }


                    StringBuilder sb = new StringBuilder();
                    sb.Append(@"您好:<br /><br />");
                    sb.Append(@"這封認證信函是由 工研院大檔案傳輸系統 所發出的。<br /><br />");
                    sb.Append(@"請點擊至下列網址修改您的密碼。<br /><br />");
                    sb.Append(@"<a href='" + AppConfig.MailUrl + "valid.aspx?vid=" + sec.encryptquerystring(randStr) + "'>" + AppConfig.MailUrl + "valid.aspx?vid=" + sec.encryptquerystring(randStr) + "</a><br /><br />");
                    myEmail.sendEmail(tbxforgetAccount, "[ITRI]工研院大檔案傳輸", sb.ToString(), "");
                    myForGet.UpdateMemberQueryStr(sec.encryptquerystring(randStr), dt.Rows[0]["mem_id"].ToString().Trim());
                    context.Response.Write("success");
                }
                else
                {
                    context.Response.Write("此帳號尚未註冊");
                    return;
                }
            }
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            string         tbxforgetAccount = context.Request.Form["tbxforgetAccount"].ToString().Trim();
            security       sec      = new security();
            Email          myEmail  = new Email();
            ForGetPassW_DB myForGet = new ForGetPassW_DB();

            if (tbxforgetAccount.ToString().Trim() == "")
            {
                context.Response.Write("Please enter E-mail");
                return;
            }
            else
            {
                //找出此EMAIL是否已註冊過
                DataTable dt = myForGet.SelectEmailExist(tbxforgetAccount.ToUpper());
                if (dt.Rows.Count == 1)
                {
                    //註冊過 寄信給此EMAIL更改連結 並變換QueryStr
                    /* 底下為本來密碼自動產生 不過規格取消 所以拿來用在querystring上 */
                    Random   rdm     = new Random();
                    string[] seeds   = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
                    int      strLen  = (int)rdm.Next(5, 11);
                    string   randStr = string.Empty;
                    for (int i = 0; i < strLen; i++)
                    {
                        randStr += seeds[rdm.Next(seeds.Length)].ToString().ToUpper();
                    }


                    StringBuilder sb = new StringBuilder();
                    sb.Append(@"Hello: <br /><br />");
                    sb.Append(@"This Certification letter is from ITRI Secured File Transfer System, <br /><br />");
                    sb.Append(@"Please click on the following URL to change your password.<br /><br />");
                    sb.Append(@"<a href='" + AppConfig.MailUrl + "enVersion/vaildEn.aspx?vid=" + sec.encryptquerystring(randStr) + "'>" + AppConfig.MailUrl + "enVersion/vaildEn.aspx?vid=" + sec.encryptquerystring(randStr) + "</a><br /><br />");
                    myEmail.sendEmail(tbxforgetAccount, "[ITRI]Notification from ITRI WebFTP - Password Assistance", sb.ToString(), "");
                    myForGet.UpdateMemberQueryStr(sec.encryptquerystring(randStr), dt.Rows[0]["mem_id"].ToString().Trim());
                    context.Response.Write("success");
                }
                else
                {
                    context.Response.Write("This E-mail has not been registered");
                    return;
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string tbxNameQ    = context.Request.Form["tbxNameQ"].ToString().Trim();
                string tbxAccountQ = context.Request.Form["tbxAccountQ"].ToString().Trim();
                string typeQ       = context.Request.Form["typeQ"].ToString().Trim();

                if (tbxNameQ.ToString().Trim() == "")
                {
                    context.Response.Write("請輸入中文姓名");
                    return;
                }

                if (tbxAccountQ.ToString().Trim() == "")
                {
                    context.Response.Write("請輸入電子郵件");
                    return;
                }

                if (!Common.IsVaildEmail(tbxAccountQ))
                {
                    context.Response.Write("Email格式錯誤");
                    return;
                }

                if (encode.sqlInjection(tbxNameQ))
                {
                    context.Response.Write("中文姓名包含不合法字元");
                    return;
                }

                DataTable dtEmail = Common.AccordEmailIsitFromITRI(tbxAccountQ, "");
                if (dtEmail.Rows.Count > 0)
                {
                    context.Response.Write("請輸入院外信箱");
                    return;
                }

                if (typeQ != "agree")
                {
                    context.Response.Write("您並未同意使用規約 無法接受您的申請");
                    return;
                }
                else
                {
                    Random      rdm     = new Random();
                    register_DB myreg   = new register_DB();
                    security    sec     = new security();
                    Email       myEmail = new Email();

                    DataTable dt = myreg.CheckEmailExist(tbxAccountQ);
                    if (dt.Rows.Count > 0)
                    {
                        context.Response.Write("此Email已註冊過帳號");
                        return;
                    }

                    /* 底下為本來密碼自動產生 不過規格取消 所以拿來用在querystring上 */
                    string[] seeds   = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
                    int      strLen  = (int)rdm.Next(5, 11);
                    string   randStr = string.Empty;
                    for (int i = 0; i < strLen; i++)
                    {
                        randStr += seeds[rdm.Next(seeds.Length)].ToString().ToUpper();
                    }

                    StringBuilder sb = new StringBuilder();
                    sb.Append(@"親愛的" + tbxNameQ + " 您好:<br /><br />");
                    sb.Append(@"這封認證信函是由 工研院大檔案傳輸系統 所發出的,您收到這封電子郵件可能是因為您註冊了新的帳號。<br /><br />");
                    sb.Append(@"請點擊至下列網址,即可通過會員認證並新增您的密碼。<br /><br />");
                    sb.Append(@"<a href='" + AppConfig.MailUrl + "valid.aspx?vid=" + sec.encryptquerystring(randStr) + "'>" + AppConfig.MailUrl + "valid.aspx?vid=" + sec.encryptquerystring(randStr) + "</a><br /><br />");
                    //sb.Append(@"");
                    //sb.Append(@"");
                    //sb.Append(@"");
                    //sb.Append(@"");
                    myEmail.sendEmail(tbxAccountQ, "[ITRI]工研院大檔案傳輸會員驗證", sb.ToString(), "");
                    myreg.INSERTmember(tbxAccountQ, tbxNameQ, sec.encryptquerystring(randStr));
                    context.Response.Write("success");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string tbxNameQ    = context.Request.Form["tbxNameQ"].ToString().Trim();
                string tbxAccountQ = context.Request.Form["tbxAccountQ"].ToString().Trim();
                string typeQ       = context.Request.Form["typeQ"].ToString().Trim();

                if (tbxNameQ.ToString().Trim() == "")
                {
                    context.Response.Write("Please enter your Name");
                    return;
                }

                if (tbxAccountQ.ToString().Trim() == "")
                {
                    context.Response.Write("Please enter your E-mail Address");
                    return;
                }

                if (!Common.IsVaildEmail(tbxAccountQ))
                {
                    context.Response.Write("Email format is not vaild");
                    return;
                }

                if (encode.sqlInjection(tbxNameQ))
                {
                    context.Response.Write("Name contains illegal characters");
                    return;
                }

                DataTable dtEmail = Common.AccordEmailIsitFromITRI(tbxAccountQ, "");
                if (dtEmail.Rows.Count > 0)
                {
                    context.Response.Write("Please enter E-mail without ITRI employee");
                    return;
                }

                if (typeQ != "agree")
                {
                    context.Response.Write("You have not agreed 'User agreement' yet");
                    return;
                }
                else
                {
                    Random      rdm     = new Random();
                    register_DB myreg   = new register_DB();
                    security    sec     = new security();
                    Email       myEmail = new Email();

                    DataTable dt = myreg.CheckEmailExist(tbxAccountQ);
                    if (dt.Rows.Count > 0)
                    {
                        context.Response.Write("This Email has been registered");
                        return;
                    }

                    /* 底下為本來密碼自動產生 不過規格取消 所以拿來用在querystring上 */
                    string[] seeds   = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
                    int      strLen  = (int)rdm.Next(5, 11);
                    string   randStr = string.Empty;
                    for (int i = 0; i < strLen; i++)
                    {
                        randStr += seeds[rdm.Next(seeds.Length)].ToString().ToUpper();
                    }

                    StringBuilder sb = new StringBuilder();
                    sb.Append(@"Dear" + tbxNameQ + " :<br /><br />");
                    sb.Append(@"This letter was sent by ITRIWebFTP system. You received this email because you've registered a new account.<br /><br />");
                    sb.Append(@" Please go to the url listed below to get your member verification.<br /><br />");
                    sb.Append(@"<a href='" + AppConfig.MailUrl + "enVersion/validEn.aspx?vid=" + sec.encryptquerystring(randStr) + "'>" + AppConfig.MailUrl + "valid.aspx?vid=" + sec.encryptquerystring(randStr) + "</a><br /><br />");
                    //sb.Append(@"");
                    //sb.Append(@"");
                    //sb.Append(@"");
                    //sb.Append(@"");
                    myEmail.sendEmail(tbxAccountQ, "[ITRI] WebFTP Account Notification ", sb.ToString(), "");
                    myreg.INSERTmember(tbxAccountQ, tbxNameQ, sec.encryptquerystring(randStr));
                    context.Response.Write("success");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }