internal ISet <Int32sRef> ToFiniteStrings(BytesRef surfaceForm, TokenStreamToAutomaton ts2a) { // Analyze surface form: Automaton automaton = null; TokenStream ts = indexAnalyzer.GetTokenStream("", surfaceForm.Utf8ToString()); try { // Create corresponding automaton: labels are bytes // from each analyzed token, with byte 0 used as // separator between tokens: automaton = ts2a.ToAutomaton(ts); } finally { IOUtils.DisposeWhileHandlingException(ts); } ReplaceSep(automaton); automaton = ConvertAutomaton(automaton); if (Debugging.AssertsEnabled) { Debugging.Assert(SpecialOperations.IsFinite(automaton)); } // Get all paths from the automaton (there can be // more than one path, eg if the analyzer created a // graph using SynFilter or WDF): // TODO: we could walk & add simultaneously, so we // don't have to alloc [possibly biggish] // intermediate HashSet in RAM: return(SpecialOperations.GetFiniteStrings(automaton, maxGraphExpansions)); }
protected void btnSendEmail_Click(object sender, EventArgs e) { SpecialOperations operate = new SpecialOperations(); string checkCode = operate.generateRandomNum(6); Session["checkCode"] = checkCode; string body = "你的验证码是" + checkCode; //生成六位验证码发送至邮箱 string toEmail; if (txtEmail.Text != null && txtEmail.Text != "" && !operate.non_string_existed(txtEmail.Text, "@") && !operate.non_string_existed(txtEmail.Text, ".com")) { toEmail = txtEmail.Text; if (operate.EmailSend(body, toEmail)) { Response.Write("<script> alert('验证码已发送至邮箱,请及时查收!');</script> "); } else { Response.Write("<script> alert('验证码发送失败!');</script> "); } } else { Response.Write("<script> alert('邮箱格式不正确');</script> "); txtEmail.Text = null; } }
internal Automaton ToLevenshteinAutomata(Automaton automaton) { var @ref = SpecialOperations.GetFiniteStrings(automaton, -1); Automaton[] subs = new Automaton[@ref.Count]; int upto = 0; foreach (IntsRef path in @ref) { if (path.Length <= nonFuzzyPrefix || path.Length < minFuzzyLength) { subs[upto] = BasicAutomata.MakeString(path.Ints, path.Offset, path.Length); upto++; } else { Automaton prefix = BasicAutomata.MakeString(path.Ints, path.Offset, nonFuzzyPrefix); int[] ints = new int[path.Length - nonFuzzyPrefix]; Array.Copy(path.Ints, path.Offset + nonFuzzyPrefix, ints, 0, ints.Length); // TODO: maybe add alphaMin to LevenshteinAutomata, // and pass 1 instead of 0? We probably don't want // to allow the trailing dedup bytes to be // edited... but then 0 byte is "in general" allowed // on input (but not in UTF8). LevenshteinAutomata lev = new LevenshteinAutomata(ints, unicodeAware ? char.MAX_CODE_POINT : 255, transpositions); Automaton levAutomaton = lev.ToAutomaton(maxEdits); Automaton combined = BasicOperations.Concatenate(Arrays.AsList(prefix, levAutomaton)); combined.Deterministic = true; // its like the special case in concatenate itself, except we cloneExpanded already subs[upto] = combined; upto++; } } if (subs.Length == 0) { // automaton is empty, there is no accepted paths through it return(BasicAutomata.MakeEmpty()); // matches nothing } else if (subs.Length == 1) { // no synonyms or anything: just a single path through the tokenstream return(subs[0]); } else { // multiple paths: this is really scary! is it slow? // maybe we should not do this and throw UOE? Automaton a = BasicOperations.Union(Arrays.AsList(subs)); // TODO: we could call toLevenshteinAutomata() before det? // this only happens if you have multiple paths anyway (e.g. synonyms) BasicOperations.Determinize(a); return(a); } }
protected void btnPwdSet_Click(object sender, EventArgs e) { string number = txtNumber.Text; if (number == null || number == "") { Response.Write("<script> alert('请输入账号!');</script> "); txtPwdSet.Text = null; txtPwdSure.Text = null; } else { SQLOperation sqlOperate = new SQLOperation(); if (Session["checkCode"] == null) { Response.Write("<script> alert('请先获得验证码!');</script> "); } else if (txtCode.Text != Session["checkCode"].ToString()) { if (txtCode.Text == null || txtCode.Text == "") { Response.Write("<script> alert('请输入六位验证码!');</script> "); } else { Response.Write("<script> alert('验证码错误!');</script> "); txtNumber = null; txtPwdSet = null; txtPwdSure = null; } } else { if (txtPwdSet.Text != txtPwdSure.Text) { Response.Write("<script> alert('新密码不一致!');</script> "); txtPwdSet.Text = null; txtPwdSure.Text = null; } else if (txtPwdSet.Text == "" || txtPwdSet.Text == null) { Response.Write("<script> alert('密码不能为空!');</script> "); } else { SpecialOperations op = new SpecialOperations(); string pwd = op.MD5String(txtPwdSet.Text); sqlOperate.update(" users ", " password = '******'", " number='" + number + "'"); Response.Write("<script> alert('密码已修改,请重新登录!');location='MainPage.aspx'</script> "); Session["checkCode"] = null; } } } }
public virtual void TestIntersect() { for (int i = 0; i < NumIterations; i++) { string reg = AutomatonTestUtil.RandomRegexp(Random()); Automaton automaton = (new RegExp(reg, RegExpSyntax.NONE)).ToAutomaton(); CompiledAutomaton ca = new CompiledAutomaton(automaton, SpecialOperations.IsFinite(automaton), false); TermsEnum te = MultiFields.GetTerms(Reader, "field").Intersect(ca, null); Automaton expected = BasicOperations.Intersection(TermsAutomaton, automaton); SortedSet <BytesRef> found = new SortedSet <BytesRef>(); while (te.Next() != null) { found.Add(BytesRef.DeepCopyOf(te.Term)); } Automaton actual = BasicAutomata.MakeStringUnion(found); Assert.IsTrue(BasicOperations.SameLanguage(expected, actual)); } }
protected void btnLogin_Click(object sender, EventArgs e) { SpecialOperations operate = new SpecialOperations(); string number = txtNumber.Text; string pwd = operate.MD5String(txtPwd.Text); //md5加密 //SELECT 列名称 FROM 表名称 WHERE 列 运算符 值 string getPwd; SQLOperation sqlOperate = new SQLOperation(); DataTable dt = new DataTable(); dt = sqlOperate.select(" password,id ", " Users ", " number='" + number + "'"); if (dt.Rows.Count == 0) { Response.Write("<script> alert('账号不存在');</script> "); //if the database doesn't hava a line,can't find the user } else if ((getPwd = dt.Rows[0][0].ToString().Trim()) != pwd) { Response.Write("<script> alert('密码错误!');</script> "); txtPwd.Text = null; } else if ((getPwd = dt.Rows[0][0].ToString().Trim()) == pwd) { Session["NowUserId"] = dt.Rows[0][1].ToString().Trim(); dt = sqlOperate.select(" loginStatus ", " users ", " id =" + Session["NowUserId"].ToString()); string status = dt.Rows[0][0].ToString().Trim(); if (status == "下线") { sqlOperate.update(" users ", " loginstatus='在线' ", " id=" + Session["NowUserId"].ToString()); //change online status /* if(btnRememberPwd.Checked == true) * { * CookieOperation c*k = new CookieOperation(); * c*k.addUser(number, pwd); * }*/ Response.Write("<script> alert('登陆成功!');location= 'PersonalCenterPage.aspx'</script> "); } else { Response.Write("<script> alert('当前用户已经在线!');location= 'PersonalCenterPage.aspx'</script> "); } } }
protected void btnSendCode_Click(object sender, EventArgs e) { string number = txtNumber.Text; string getEmail; SpecialOperations operate = new SpecialOperations(); SQLOperation sqlOperate = new SQLOperation(); DataTable dt = new DataTable(); if (number == null || number == "") { Response.Write("<script> alert('请输入账号!');</script> "); txtPwdSet.Text = null; txtPwdSure.Text = null; } else { dt = sqlOperate.select(" email ", " users ", " number='" + number + "'"); if (dt.Rows.Count == 0) { Response.Write("<script> alert('账号不存在');</script> "); txtNumber.Text = null; } else { getEmail = dt.Rows[0][0].ToString(); Session["checkCode"] = operate.generateRandomNum(6); string body = "你的验证码是" + Session["checkCode"].ToString(); //生成六位验证码发送至邮箱 if (operate.EmailSend(body, getEmail)) { Response.Write("<script> alert('验证码已发送至邮箱,请及时查收!');</script> "); } else { Response.Write("<script> alert('验证码发送失败!');</script> "); } } } }
protected void btnRegister_Click(object sender, EventArgs e) { SpecialOperations operate = new SpecialOperations(); string number = operate.generateRandomNum(10); string sex; if (btnMan.Checked) { sex = btnMan.Text; } else if (btnWoman.Checked) { sex = btnWoman.Text; } else { sex = null; } string checkCode = Session["checkCode"].ToString(); bool emptyJudge = operate.nullString(txtName.Text) || operate.nullString(sex) || operate.nullString(txtEmail.Text) || operate.nullString(txtCode.Text) || operate.nullString(txtPwdSet.Text) || operate.nullString(txtPwdSure.Text); bool overLengthJudge = operate.overLength(txtName.Text, 20) || operate.overLength(txtEmail.Text, 20) || operate.overLength(txtCode.Text, 6) || operate.overLength(txtPwdSet.Text, 10); if (emptyJudge) { Response.Write("<script> alert('有内容尚未完成!');</script> "); } else if (overLengthJudge) { Response.Write("<script> alert('有内容超出限定长度!');</script> "); } else if (operate.not_equal(txtPwdSet.Text, txtPwdSure.Text)) { Response.Write("<script> alert('两次输入的密码不一致');</script> "); } else if (operate.not_equal(checkCode, txtCode.Text)) { Response.Write("<script> alert('验证码错误');</script> "); } else { SQLOperation sql = new SQLOperation(); // sql = new SQLOperation(); string nickname = txtName.Text; string password = operate.MD5String(txtPwdSet.Text); string loginstatus = "下线"; string email = txtEmail.Text; //' nickname ','number','password','loginstatus','name','sex','age','headpicture','email','birthday' string values = "N'" + nickname + "', " + "N'" + number + "','" + password + "',N'" + loginstatus + "','" + null + "',N'" + sex + "','" + null + "',' ~\\images\\default.png ','" + email + "','" + null + "'"; if (sql.add(" users ", values)) { DataTable dt = sql.select(" id ", " users ", " number = '" + number + "'"); string id = dt.Rows[0][0].ToString(); string zoneDefultValue = id + ",N'" + nickname + "的空间'"; //give a default name for zone //userid,name,classkind,amount sql.add(" classes ", " " + id + " ,'所有日志','日志',0,'F'"); //注册就得到一个存放所有日志的默认分类 sql.add(" a_album ", " " + id + ",'所有照片',0,null,null,'F'"); //注册的到一个默认相册 if (sql.add(" zoneInfo ", zoneDefultValue)) { Response.Write("<script> alert('注册成功你的账号是" + number + "');location= 'MainPage.aspx'</script> "); } } else { Response.Write("<script> alert('注册失败');</script>"); } /*全部清空*/ txtEmail.Text = null; txtCode.Text = null; txtPwdSet.Text = null; txtPwdSure.Text = null; txtName.Text = null; } }