コード例 #1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            currUser     = (DaikonUser)(Session["currUser"]);
            writerString = new StringWriter();
            xmlWriter    = new XmlTextWriter(writerString);
            xsltArgs     = new XsltArgumentList();

            FormsAuthenticationTicket tkt;
            string     cookiestr;
            HttpCookie ck;

            tkt = new FormsAuthenticationTicket(1, "newuser", DateTime.Now,
                                                DateTime.Now.AddMinutes(30), false, "your custom data");
            cookiestr = FormsAuthentication.Encrypt(tkt);
            ck        = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
            //			if (chkPersistCookie.Checked)
            //				ck.Expires=tkt.Expiration;
            ck.Path = FormsAuthentication.FormsCookiePath;
            Response.Cookies.Add(ck);

//            Response.Redirect("newuser.aspx", true);

            // Put user code to initialize the page here
            if (Request.Form["cmdRetrievePass"] != null)
            {
                UserLostPasswordFormHandler(sender, e);
            }
            else
            {
                UserLostPasswordForm(sender, e);
            }
        }
コード例 #2
0
        public void UserLostPasswordForm(object sender, System.EventArgs e)
        {
            DaikonUser editingUser = new DaikonUser();

            xslTemplate = ConfigurationManager.AppSettings["mainpageXslt"].ToString();
            string navbarXslTemplate = ConfigurationManager.AppSettings["navbarXslt"].ToString();

            if (Session["statusMessage1"] != null)
            {
                outputMessage1 = Session["statusMessage1"].ToString();
            }
            else
            {
                outputMessage1 = "";
            }
            if (Session["statusMessage2"] != null)
            {
                outputMessage2 = Session["statusMessage2"].ToString();
            }
            else
            {
                outputMessage2 = "";
            }

            StringReader         readerString;
            XmlDocument          xmlDoc             = new XmlDocument();
            XslCompiledTransform xslTransform       = new XslCompiledTransform();
            XslCompiledTransform xslTransformNavbar = new XslCompiledTransform();

            StringWriter     writerStringNavbar;
            XmlTextWriter    xmlWriterNavbar;
            XsltArgumentList xsltArgsNavbar;
            StringReader     readerStringNavbar;
            XmlDocument      xmlDocNavbar = new XmlDocument();

            writerStringNavbar = new StringWriter();
            xmlWriterNavbar    = new XmlTextWriter(writerStringNavbar);
            xsltArgsNavbar     = new XsltArgumentList();

            xmlWriter.Formatting       = Formatting.Indented;
            xmlWriterNavbar.Formatting = Formatting.Indented;
            //            xmlWriter.Settings.ConformanceLevel = ConformanceLevel.Fragment;
            //            xmlWriter.Settings.Encoding = Encoding.UTF8;

            //            xmlWriter.WriteStartDocument();
            //            xmlWriterNavbar.WriteStartDocument();

            xmlWriter.WriteStartElement("SAREroot");
            xmlWriterNavbar.WriteStartElement("SAREroot");

            DaikonGrantFieldValues staticVals = new DaikonGrantFieldValues();

            staticVals.DaikonGrantFieldValues(ConfigurationManager.ConnectionStrings["sareDaikonConnectionString"].ToString());

//            currUser.toXML(xmlWriter, "current");
//            currUser.toXML(xmlWriterNavbar, "current");

            xmlWriterNavbar.WriteEndElement();

            readerStringNavbar = new StringReader(writerStringNavbar.ToString());
            xmlDocNavbar.Load(readerStringNavbar);

            //			Response.Clear();
            Response.ContentType = "text/html";

            /*
             *                      XmlTextWriter xmlCache = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
             *                      xmlCache.Formatting = Formatting.Indented;
             */
            HtmlTextWriter htmlCache = new HtmlTextWriter(Response.Output);

            System.IO.StreamReader headerFile = new System.IO.StreamReader(this.MapPath(Page.TemplateSourceDirectory) + "\\includes\\header.inc");
            string htmlHeader = headerFile.ReadToEnd();

            headerFile.Close();

            System.IO.StreamReader navbarFile = new System.IO.StreamReader(this.MapPath(Page.TemplateSourceDirectory) + "\\includes\\leftsidebar.inc");
            string htmlNavbar = navbarFile.ReadToEnd();

            navbarFile.Close();

            System.IO.StreamReader footerFile = new System.IO.StreamReader(this.MapPath(Page.TemplateSourceDirectory) + "\\includes\\footer.inc");
            string htmlFooter = footerFile.ReadToEnd();

            footerFile.Close();

            xslTemplate = ConfigurationManager.AppSettings["retrievepassXslt"].ToString();

/*
 *                      htmlCache.Write(htmlHeader);
 *
 *                      htmlCache.Write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tbody><tr><td class=\"leftnav\" style=\"width: 159px; vertical-align: top;\">");
 *                      htmlCache.Write(htmlNavbar);
 *                      htmlCache.Write("</td><td class=\"copy\">");
 *
 *                      htmlCache.Write("<form method=\"post\" action=\"\" name=\"userInfo\">");
 *                      htmlCache.Write("<table style=\"text-align: left; width: 82%;\" border=\"1\" cellpadding=\"2\" cellspacing=\"2\">");
 *                      htmlCache.Write("<tbody>");
 *                      htmlCache.Write("<tr>");
 *                      htmlCache.Write("<td>Username or email address</td>");
 *                      htmlCache.Write("<td><input maxlength=\"255\" size=\"20\" name=\"userName\"></td>");
 *                      htmlCache.Write("</tr>");
 *                      htmlCache.Write("</tbody>");
 *                      htmlCache.Write("</table>");
 *                      htmlCache.Write("<p><br>");
 *                      htmlCache.Write("</p>");
 *          htmlCache.Write("<input type=\"submit\" value=\"Retrieve Username or Password\" name=\"cmdRetrievePass\" ID=\"cmdRetrievePass\">");
 *                      //			htmlCache.Write(Session["pageURL"]);
 *                      htmlCache.Write("</form></td></tr>");
 *                      htmlCache.Write(htmlFooter);
 *                      htmlCache.Write("</tbody></table>");
 *                      htmlCache.Write("</body></html>");
 *
 *                      htmlCache.Close();
 * */

            xmlWriter.WriteEndElement();

            xmlWriter.Flush();

            xsltArgs.AddParam("message", "", outputMessage1);
            xsltArgs.AddParam("message2", "", outputMessage2);

            readerString = new StringReader(writerString.ToString());
            xmlDoc.Load(readerString);

            htmlCache.Write(htmlHeader);

            htmlCache.Write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tbody><tr><td class=\"leftnav\" style=\"width: 159px; vertical-align: top;\">");

            xslTransformNavbar.Load(MapPath(Page.TemplateSourceDirectory) + navbarXslTemplate);
            xslTransformNavbar.Transform(xmlDocNavbar, xsltArgsNavbar, htmlCache);

            //htmlCache.Write(htmlNavbar);

            htmlCache.Write("</td><td class=\"copy\">");
            ///////

            //xslTransform.Load(MapPath(Page.TemplateSourceDirectory) + xslTemplate);
            string xsltFilePath = MapPath(Page.TemplateSourceDirectory);

            xslTransform.Load(xsltFilePath + xslTemplate);

            xslTransform.Transform(xmlDoc, xsltArgs, htmlCache);

            htmlCache.Write("</td></tr>");
            htmlCache.Write(htmlFooter);
            htmlCache.Write("</tbody></table>");
            htmlCache.Write("</body></html>");

            htmlCache.Close();
        }
コード例 #3
0
        public void UserCreateFormHandler(object sender, System.EventArgs e)
        {
            //			Response.Write("User Updated");
            DaikonUser editedUser;

            /*
             *                      string username;
             *                      string firstName;
             *                      string lastName;
             *                      string org;
             *                      string position;
             *                      string addrStreet;
             *                      string addrCity;
             *                      string addrState;
             *                      string addrZip;
             *                      string numPhone;
             *                      string email;
             *                      string website;
             */
            string username    = Request.Form["username"].Trim();
            string nameTitle   = Request.Form["nameTitle"];
            string firstName   = Request.Form["firstName"];
            string lastName    = Request.Form["lastName"];
            string namePostfix = Request.Form["namePostfix"];
            string org         = Request.Form["org"];
            string orgPosition = Request.Form["orgPosition"];
            string addrStreet1 = Request.Form["addrStreet1"];
            string addrStreet2 = Request.Form["addrStreet2"];
            string addrCity    = Request.Form["addrCity"];
            string addrState   = Request.Form["addrState"];
            string addrZip     = Request.Form["addrZip"];
            string addrZip4    = Request.Form["addrZip4"];
            string numPhone    = Request.Form["numPhone1"] + "-" + Request.Form["numPhone2"] + "-" + Request.Form["numPhone3"];
            string numFax      = Request.Form["numFax1"] + "-" + Request.Form["numFax2"] + "-" + Request.Form["numFax3"];
            string numCell     = Request.Form["numCell1"] + "-" + Request.Form["numCell2"] + "-" + Request.Form["numCell3"];
            string email       = Request.Form["email"];
            string website     = Request.Form["website"];
            bool   onEmailList = (bool)(Request.Form["sareMailList"] == "on");


            if (username.Length == 0 || firstName.Length == 0 || lastName.Length == 0 || org.Length == 0 || addrStreet1.Length == 0 || addrCity.Length == 0 ||
                addrZip.Length == 0 || email.Length == 0)
            {
                errorMsg = "Required Field(s) Missing";
                UserCreateForm(sender, e);
            }
            else
            {
                editedUser = new DaikonUser(username, nameTitle, firstName, lastName, namePostfix, org,
                                            orgPosition, addrStreet1, addrStreet2, addrCity, addrState,
                                            addrZip, addrZip4, numPhone, numFax, numCell, email, website, onEmailList);

                //			Response.Write(editedUser.showUser());

                //			Response.Write("Username: "******"username"] + "Password: "******"password"]);
                if (editedUser.saveNewUserToDB("new", Request.Form["password"], Request.Form["confpassword"]))
                {
                    Session["currUser"] = editedUser;
                    AccountCreateMailer(email, username, Request.Form["password"]);
                    //Response.Redirect("sare_main.aspx");
                    LoginToSystem(username, Request.Form["password"]);
                }
                else
                {
                    errorMsg = "The username '" + username.ToUpper() + "' and/or email address " + email + " already exists in the system. Visit " + ConfigurationManager.AppSettings["website"].ToString() + " to reset your password or retrieve your username.\n";
                    UserCreateForm(sender, e);
                }
            }
        }
コード例 #4
0
        public void UserCreateForm(object sender, System.EventArgs e)
        {
            FormsAuthenticationTicket tkt;
            string     cookiestr;
            HttpCookie ck;

            tkt       = new FormsAuthenticationTicket(1, "newuser", DateTime.Now, DateTime.Now.AddMinutes(30), false, "mySARE");
            cookiestr = FormsAuthentication.Encrypt(tkt);
            ck        = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
            ck.Path   = FormsAuthentication.FormsCookiePath;
            Response.Cookies.Add(ck);

            DaikonUser editingUser = new DaikonUser();

            //			Response.Clear();
            Response.ContentType = "text/html";

            /*
             *                      XmlTextWriter xmlCache = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
             *                      xmlCache.Formatting = Formatting.Indented;
             */
            HtmlTextWriter htmlCache = new HtmlTextWriter(Response.Output);

            System.IO.StreamReader headerFile = new System.IO.StreamReader(this.MapPath(Page.TemplateSourceDirectory) + "\\includes\\header_test.inc");
            string htmlHeader = headerFile.ReadToEnd();

            headerFile.Close();

            System.IO.StreamReader navbarFile = new System.IO.StreamReader(this.MapPath(Page.TemplateSourceDirectory) + "\\includes\\leftsidebar.inc");
            string htmlNavbar = navbarFile.ReadToEnd();

            navbarFile.Close();

            System.IO.StreamReader footerFile = new System.IO.StreamReader(this.MapPath(Page.TemplateSourceDirectory) + "\\includes\\footer.inc");
            string htmlFooter = footerFile.ReadToEnd();

            footerFile.Close();

            htmlCache.Write(htmlHeader);

            htmlCache.Write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tbody><tr><td class=\"leftnav\" style=\"width: 159px; vertical-align: top;\">");
            htmlCache.Write(htmlNavbar);
            htmlCache.Write("</td><td class=\"copy\">");

            htmlCache.Write("<form onsubmit=\"return validatePassword()\" method=\"post\" action=\"newuser.aspx?do=makeNew\" name=\"userDetails\">");
            htmlCache.Write("<table style=\"text-align: left; width: 82%;\" border=\"1\" cellpadding=\"2\" cellspacing=\"2\">");
            htmlCache.Write("<tbody>");
            htmlCache.Write("<tr>");

            if (errorMsg.Length > 0)
            {
                htmlCache.Write("<p><font color=\"red\">");
                htmlCache.Write(errorMsg);
                htmlCache.Write("</font></p>");
            }
            htmlCache.Write("<span class=\"pagetitle\">MySARE Registration</span><br/>");
            htmlCache.Write("<br/>Please fill in all required fields to register for MySARE.<br/>");
            htmlCache.Write("<p><strong>Note: Fields marked with an asterisk (<font color=\"red\"><b>*</b></font>) are required</strong></p>");
            htmlCache.Write("<td width=\"30%\">Title</td>");
            htmlCache.Write("<td width=\"70%\">");
            htmlCache.Write("<select name=\"nameTitle\">");
            htmlCache.Write("<option selected></option>");
            htmlCache.Write("<option>Mr</option>");
            htmlCache.Write("<option>Ms</option>");
            htmlCache.Write("<option>Mrs</option>");
            htmlCache.Write("<option>Dr</option>");
            htmlCache.Write("</select>");
            htmlCache.Write("</td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td><font color=\"red\"><b>*</b></font> First Name</td>");
            htmlCache.Write("<td><input maxlength=\"255\" size=\"25\" name=\"firstName\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td><font color=\"red\"><b>*</b></font> Last Name</td>");
            htmlCache.Write("<td><input maxlength=\"255\" size=\"25\" name=\"lastName\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td> Postfix (Jr., III, etc.)</td>");
            htmlCache.Write("<td><input size=\"10\" name=\"namePostfix\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td></td>");
            htmlCache.Write("<td></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td>Position</td>");
            htmlCache.Write("<td><input maxlength=\"255\" size=\"25\" name=\"orgPosition\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td><font color=\"red\"><b>*</b></font> Organization</td>");
            htmlCache.Write("<td><input maxlength=\"255\" size=\"25\" name=\"org\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td></td>");
            htmlCache.Write("<td></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td><font color=\"red\"><b>*</b></font> Address</td>");
            htmlCache.Write("<td><input maxlength=\"255\" size=\"50\" name=\"addrStreet1\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td> Address (cont.)</td>");
            htmlCache.Write("<td><input maxlength=\"255\" size=\"50\" name=\"addrStreet2\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td><font color=\"red\"><b>*</b></font> City</td>");
            htmlCache.Write("<td><input maxlength=\"255\" size=\"20\" name=\"addrCity\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td><font color=\"red\"><b>*</b></font> State</td>");
            htmlCache.Write("<td><select name=\"addrState\">");
            htmlCache.Write("<option value=\"AL\">Alabama</option>");
            htmlCache.Write("<option value=\"AK\">Alaska</option>");
            htmlCache.Write("<option value=\"AS\">American Samoa</option>");
            htmlCache.Write("<option value=\"AZ\">Arizona</option>");
            htmlCache.Write("<option value=\"AR\">Arkansas</option>");
            htmlCache.Write("<option value=\"CA\">California</option>");
            htmlCache.Write("<option value=\"CO\">Colorado</option>");
            htmlCache.Write("<option value=\"CT\">Connecticut</option>");
            htmlCache.Write("<option value=\"DE\">Delaware</option>");
            htmlCache.Write("<option value=\"DC\">District of Columbia</option>");
            htmlCache.Write("<option value=\"FL\">Florida</option>");
            htmlCache.Write("<option value=\"GA\">Georgia</option>");
            htmlCache.Write("<option value=\"GU\">Guam</option>");
            htmlCache.Write("<option value=\"HI\">Hawaii</option>");
            htmlCache.Write("<option value=\"ID\">Idaho</option>");
            htmlCache.Write("<option value=\"IL\">Illinois</option>");
            htmlCache.Write("<option value=\"IN\">Indiana</option>");
            htmlCache.Write("<option value=\"IA\">Iowa</option>");
            htmlCache.Write("<option value=\"KS\">Kansas</option>");
            htmlCache.Write("<option value=\"KY\">Kentucky</option>");
            htmlCache.Write("<option value=\"LA\">Louisiana</option>");
            htmlCache.Write("<option value=\"ME\">Maine</option>");
            htmlCache.Write("<option value=\"MD\">Maryland</option>");
            htmlCache.Write("<option value=\"MA\">Massachusetts</option>");
            htmlCache.Write("<option value=\"MI\">Michigan</option>");
            htmlCache.Write("<option value=\"FM\">Micronesia</option>");
            htmlCache.Write("<option value=\"MN\">Minnesota</option>");
            htmlCache.Write("<option value=\"MS\">Mississippi</option>");
            htmlCache.Write("<option value=\"MO\">Missouri</option>");
            htmlCache.Write("<option value=\"MT\">Montana</option>");
            htmlCache.Write("<option value=\"NE\">Nebraska</option>");
            htmlCache.Write("<option value=\"NV\">Nevada</option>");
            htmlCache.Write("<option value=\"NH\">New Hampshire</option>");
            htmlCache.Write("<option value=\"NJ\">New Jersey</option>");
            htmlCache.Write("<option value=\"NM\">New Mexico</option>");
            htmlCache.Write("<option value=\"NY\">New York</option>");
            htmlCache.Write("<option value=\"NC\">North Carolina</option>");
            htmlCache.Write("<option value=\"ND\">North Dakota</option>");
            htmlCache.Write("<option value=\"MP\">Northern Mariana Islands</option>");
            htmlCache.Write("<option value=\"OH\">Ohio</option>");
            htmlCache.Write("<option value=\"OK\">Oklahoma</option>");
            htmlCache.Write("<option value=\"OR\">Oregon</option>");
            htmlCache.Write("<option value=\"PA\">Pennsylvania</option>");
            htmlCache.Write("<option value=\"PR\">Puerto Rico</option>");
            htmlCache.Write("<option value=\"RI\">Rhode Island</option>");
            htmlCache.Write("<option value=\"SC\">South Carolina</option>");
            htmlCache.Write("<option value=\"SD\">South Dakota</option>");
            htmlCache.Write("<option value=\"TN\">Tennessee</option>");
            htmlCache.Write("<option value=\"TX\">Texas</option>");
            htmlCache.Write("<option value=\"UT\">Utah</option>");
            htmlCache.Write("<option value=\"VT\">Vermont</option>");
            htmlCache.Write("<option value=\"VI\">Virgin Islands</option>");
            htmlCache.Write("<option value=\"VA\">Virginia</option>");
            htmlCache.Write("<option value=\"WA\">Washington</option>");
            htmlCache.Write("<option value=\"WV\">West Virginia</option>");
            htmlCache.Write("<option value=\"WI\">Wisconsin</option>");
            htmlCache.Write("<option value=\"WY\">Wyoming</option>");

            htmlCache.Write("</select>");
            htmlCache.Write("</td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td><font color=\"red\"><b>*</b></font> Zip Code</td>");
            htmlCache.Write("<td><input onKeyPress=\"return isNumberKey(event)\" maxlength=\"5\" size=\"5\" name=\"addrZip\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td> Zip +4</td>");
            htmlCache.Write("<td><input onKeyPress=\"return isNumberKey(event)\" maxlength=\"4\" size=\"4\" name=\"addrZip4\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td></td>");
            htmlCache.Write("<td></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td><font color=\"red\"><b>*</b></font> Phone</td>");
            htmlCache.Write("<td><input onKeyPress=\"return isNumberKey(event)\" maxlength=\"3\" size=\"5\" name=\"numPhone1\">");
            htmlCache.Write("<input onKeyPress=\"return isNumberKey(event)\" maxlength=\"3\" size=\"5\" name=\"numPhone2\">");
            htmlCache.Write("<input onKeyPress=\"return isNumberKey(event)\" maxlength=\"4\" size=\"6\" name=\"numPhone3\"><br/>");
            htmlCache.Write("<input name=\"phoneCheck\" type=\"checkbox\">");
            htmlCache.Write("Does not have phone number");
            htmlCache.Write("</td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td>Fax</td>");
            htmlCache.Write("<td><input onKeyPress=\"return isNumberKey(event)\" maxlength=\"3\" size=\"5\" name=\"numFax1\">");
            htmlCache.Write("<input onKeyPress=\"return isNumberKey(event)\" maxlength=\"3\" size=\"5\" name=\"numFax2\">");
            htmlCache.Write("<input onKeyPress=\"return isNumberKey(event)\" maxlength=\"4\" size=\"6\" name=\"numFax3\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td>Cell</td>");
            htmlCache.Write("<td><input onKeyPress=\"return isNumberKey(event)\" maxlength=\"3\" size=\"5\" name=\"numCell1\">");
            htmlCache.Write("<input onKeyPress=\"return isNumberKey(event)\" maxlength=\"3\" size=\"5\" name=\"numCell2\">");
            htmlCache.Write("<input onKeyPress=\"return isNumberKey(event)\" maxlength=\"4\" size=\"6\" name=\"numCell3\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td></td>");
            htmlCache.Write("<td></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td><font color=\"red\"><b>*</b></font> E-mail Address</td>");
            htmlCache.Write("<td><input maxlength=\"255\" size=\"50\" name=\"email\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td>Website</td>");
            htmlCache.Write("<td><input maxlength=\"255\" size=\"50\" name=\"website\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td></td>");
            htmlCache.Write("<td></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td><font color=\"red\"><b>*</b></font> Username</td>");
            htmlCache.Write("<td><input maxlength=\"12\" size=\"12\" value=\" \"name=\"userName\" onblur=\"CheckMaxLength(this, 12);\">Username is limited to 12 characters</td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td><font color=\"red\"><b>*</b></font> Password</td>");
            htmlCache.Write("<td><input value=\"\" type=\"password\" size=\"10\" name=\"password\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("<tr>");
            htmlCache.Write("<td><font color=\"red\"><b>*</b></font> Confirm Password</td>");
            htmlCache.Write("<td><input type=\"password\" size=\"10\" name=\"passconf\"></td>");
            htmlCache.Write("</tr>");
            htmlCache.Write("</tbody>");
            htmlCache.Write("</table>");

            /*
             *          htmlCache.Write("<p><br>");
             *          htmlCache.Write("<input name=\"sareMailList\" type=\"checkbox\">");
             *          htmlCache.Write("I'd like to be on the SARE mailing list<br>");
             *          htmlCache.Write("<br>");
             *          htmlCache.Write("We will use your e-mail address to contact you about your SARE projects, resources and/or calendar events. This box will not affect those messages. Rather, SARE occasionally sends information about new books and bulletins. If you want to receive these mailings, check the box. We do NOT share our mailing list. <br>");
             *          htmlCache.Write("<br>");
             *          htmlCache.Write("</p>");
             */
            htmlCache.Write("<input type=\"submit\" value=\"Register\" name=\"cmdCreateNewAccount\" ID=\"cmdCreateNewAccount\">");
            htmlCache.Write("<br>");
            htmlCache.Write("<input type=\"reset\" value=\"Reset Form\" name=\"cmdResetNewUserDetails\" ID=\"cmdResetNewUserDetails\">");
            //			htmlCache.Write(Session["pageURL"]);
            htmlCache.Write("</form></td></tr>");
            htmlCache.Write(htmlFooter);
            htmlCache.Write("</tbody></table>");

            htmlCache.Write("<script type=\"text/javascript\">");
            htmlCache.Write("function isNumberKey(evt) {");
            htmlCache.Write("var charCode = (evt.which) ? evt.which : event.keyCode;");
            htmlCache.Write("if (charCode > 31 && (charCode < 48 || charCode > 57))");
            htmlCache.Write("return false;");
            htmlCache.Write("return true;");
            htmlCache.Write("}");
            htmlCache.Write("function validatePassword() { ");
            htmlCache.Write("var passwd = document.userDetails.password.value;");
            htmlCache.Write("var passcnf = document.userDetails.passconf.value;");
            htmlCache.Write(" if (document.userDetails.firstName.value.length == 0 || document.userDetails.lastName.value.length == 0 || document.userDetails.org.value.length == 0 || document.userDetails.addrStreet1.value.length == 0 || document.userDetails.addrCity.value.length == 0 || document.userDetails.addrZip.value.length == 0 || document.userDetails.addrZip.value.length == 0 || document.userDetails.addrZip.value.length == 0 || ((document.userDetails.numPhone1.value.length == 0 || document.userDetails.numPhone2.value.length == 0 || document.userDetails.numPhone3.value.length == 0) && document.userDetails.phoneCheck.checked == false) || document.userDetails.email.value.length == 0 || document.userDetails.userName.value.length == 0) {");
            htmlCache.Write("   alert(\"Required Field(s) Missing.\");");
            htmlCache.Write("   return false; }");
            htmlCache.Write(" else if(document.userDetails.password.value.length == 0) {");
            htmlCache.Write("   alert(\"Please enter a Valid password.\");");
            htmlCache.Write("   return false; }");
            htmlCache.Write(" else if(document.userDetails.passconf.value.length == 0) {");
            htmlCache.Write("   alert(\"Please retype the password.\");");
            htmlCache.Write("   return false; }");
            htmlCache.Write(" else if(passwd != passcnf) {");
            htmlCache.Write("   alert(\"Retyped password did not match.\");");
            htmlCache.Write("   return false; }");
            htmlCache.Write(" else");
            htmlCache.Write(" return true;}");

            htmlCache.Write("function CheckMaxLength(Object, MaxLen) ");
            htmlCache.Write("{");
            htmlCache.Write("if(Object.value.length >= MaxLen)");
            htmlCache.Write("{ ");
            htmlCache.Write("alert('Username is limited to 12 characters.');");
            htmlCache.Write("return false;");
            htmlCache.Write("}");
            htmlCache.Write("else");
            htmlCache.Write("{");
            htmlCache.Write("return true;");
            htmlCache.Write("}");
            htmlCache.Write("}");

            htmlCache.Write("</script>");

            htmlCache.Write("</body></html>");

            htmlCache.Close();
        }
コード例 #5
0
        protected void cmdLogin_ServerClick(object sender, System.EventArgs e)
        {
            string        userSQL;
            string        userConnString = ConfigurationManager.ConnectionStrings["sareDaikonConnectionString"].ToString();
            SqlConnection userConnection;

            SqlCommand    userCommand;
            SqlDataReader userDataReader;

            userConnection = new SqlConnection(userConnString);

            // connection string
            userConnection          = new SqlConnection(userConnString);
            userSQL                 = "DaikonCheckAcctLockForUser";
            userCommand             = new SqlCommand(userSQL, userConnection);
            userCommand.CommandType = CommandType.StoredProcedure;
            userCommand.Parameters.Add("@user", SqlDbType.VarChar, 12).Value = txtUserName.Value;

            userConnection.Open();

            userDataReader = userCommand.ExecuteReader();

            if (userDataReader.HasRows == true)
            {
                lblMsg.Text = "Account has being locked, please contact Regional Administrator.";
                userConnection.Dispose();
            }
            else
            {
                userConnection.Dispose();
                userCommand.Dispose();
                if (ValidateUser(txtUserName.Value, txtUserPass.Value))
                {
                    FormsAuthenticationTicket tkt;
                    string     cookiestr;
                    HttpCookie ck;
                    tkt = new FormsAuthenticationTicket(1, txtUserName.Value, DateTime.Now,
                                                        DateTime.Now.AddMinutes(120), false, "mySARE");
                    cookiestr = FormsAuthentication.Encrypt(tkt);
                    ck        = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
                    //				if (chkPersistCookie.Checked)
                    //					ck.Expires=tkt.Expiration;
                    ck.Path = FormsAuthentication.FormsCookiePath;
                    Response.Cookies.Add(ck);

                    DaikonUser newUser;

                    newUser = new DaikonUser(txtUserName.Value, (int)Session["sessionkey"], txtUserName.Value);
                    Session.Add("currUser", newUser);
                    //                Session.Timeout = int.Parse(ConfigurationManager.AppSettings["edituserXslt"]);

                    string strRedirect;
                    strRedirect = Request["ReturnUrl"];
                    if (strRedirect == null)
                    {
                        strRedirect = "sare_main.aspx";
                    }
                    //if (newUser.Roles.IsAdmin())
                    Response.Redirect(strRedirect, true);
                    //else
                    //lblMsg.Text = "The MySARE system will be shut down for migration to a new site on Thursday, April 14.";
                }
                else
                {
                    lblMsg.Text = "Log In Failed";
                    //Response.Redirect("login.aspx", true);
                    //Response.Write("Log In Failed");
                }
            }
        }