Exemple #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Session["CaptchaImageText"] = CaptchaImage.GenerateRandomCode(random);
     }
 }
Exemple #2
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (!User.Identity.IsAuthenticated)
     {
         if (tbxCode.Text == Session["CaptchaImageText"].ToString())
         {
             Response.Redirect("Newsletter.aspx?add=" + tbxEmail.Text);
         }
         else
         {
             Session["CaptchaImageText"] = CaptchaImage.GenerateRandomCode(random);
             CustomValidator1.IsValid    = false;
         }
     }
     else
     {
         string[] sEmails = tbxAddEmails.Text.Split(';');
         SmtpMail.SmtpServer = "relay-hosting.secureserver.net";
         MailMessage mm;
         foreach (string s in sEmails)
         {
             try
             {
                 DataLayer.AddNewsletterEmail(s.Replace(" ", ""));
             }
             catch
             {
                 DataLayer.CloseConn();
             }
         }
         Response.Write("<h3>Emails added successfully.</h3><a href=\"Default.aspx\">(Click here to continue.)</a>");
         Response.Flush();
         Response.Close();
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        DataLayer dl = new DataLayer();

        if (User.Identity.IsAuthenticated)
        {
            loggedinpanels.Controls.Add(new LiteralControl("<div style=\"width:250px;\" class=\"contenttitle\">Featured Member</div><div class=\"contentpanel\">"));
            DataTable dtRandomMember = dl.GetRandomMember();
            loggedinpanels.Controls.Add(new LiteralControl("<table style=\"width:100%;\"><tr><td style=\"font-size:13px;text-align:center;\"><a href=\"Profile.aspx?member=" + dtRandomMember.Rows[0].ItemArray[0].ToString() + "\"><img style=\"border-width:0px;\" src=\"MakeThumbnail.aspx?size=100&image=images/MemberAvatars/" + dtRandomMember.Rows[0].ItemArray[3].ToString() + "\" /></a><br /><a href=\"Profile.aspx?member=" + dtRandomMember.Rows[0].ItemArray[0].ToString() + "\">View Profile</a></td><td style=\"padding-left:5px;font-size:13px;width:100%;\"><b>Name:</b> " + dtRandomMember.Rows[0].ItemArray[2].ToString() + "<br /><br /><b>Location:</b> " + dtRandomMember.Rows[0].ItemArray[17].ToString() + "<br /><br /><b>Business:</b> " + dtRandomMember.Rows[0].ItemArray[8].ToString() + "<br /><br />"));
            if (dtRandomMember.Rows[0].ItemArray[6].ToString() != "")
            {
                loggedinpanels.Controls.Add(new LiteralControl("<center><a href=\"" + dtRandomMember.Rows[0].ItemArray[6].ToString() + "\">Visit Website</a></center>"));
            }
            loggedinpanels.Controls.Add(new LiteralControl("</td></tr></table></div>"));
        }

        DataTable dtMemberAd = dl.GetRandomAd();

        loggedinpanels.Controls.Add(new LiteralControl("<div class=\"contenttitle\">Member Ad</div><div style=\"text-align:center;\" class=\"contentpanel\"><a href=\"" + dtMemberAd.Rows[0].ItemArray[2].ToString() + "\"><img style=\"width:230px; border-width:0px;\" src=\"" + dtMemberAd.Rows[0].ItemArray[1].ToString() + "\" /></a></div>"));

        if (!this.IsPostBack)
        {
            Session["CaptchaImageText"] = CaptchaImage.GenerateRandomCode(random);
        }
    }
Exemple #4
0
    protected void btnAddComment_Click(object sender, EventArgs e)
    {
        if (Session["CaptchaImageText"].ToString() == tbxCode.Text)
        {
            if (tbxAddComment.Text.Length > 0)
            {
                DataLayer.AddComment(iBlogID, tbxUsername.Text, tbxAddComment.Text.Replace("\r", "<br />").Replace("\n", ""), DateTime.Now, tbxWebsite.Text);

                DataTable dtBlog = DataLayer.GetBlogsBy_blogID(iBlogID);

                SmtpMail.SmtpServer = "relay-hosting.secureserver.net";
                MailMessage mm = new MailMessage();
                mm.BodyFormat = MailFormat.Html;
                mm.To         = "*****@*****.**";
                mm.From       = "*****@*****.**";
                mm.Subject    = "New Blog Comment";
                mm.Body       = tbxUsername.Text + " posted a comment on your blog titled: " + dtBlog.Rows[0].ItemArray[1].ToString() + "<br />Here it is below:<br /><br />";
                mm.Body      += tbxAddComment.Text.Replace("\r", "<br />").Replace("\n", "");
                try
                {
                    SmtpMail.Send(mm);
                }
                catch
                { }

                Response.Redirect("http://www.fordscleaning.com/Blog.aspx?blog=" + iBlogID.ToString());
            }
        }
        else
        {
            cvCode.IsValid = false;
            Session["CaptchaImageText"] = CaptchaImage.GenerateRandomCode(random);
        }
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (User.Identity.IsAuthenticated)
            {
                admin.Visible = true;
            }
            else
            {
                admin.Visible = false;
            }
            DataLayer dl      = new DataLayer();
            int       iPostID = Convert.ToInt32(Request.QueryString["bid"]);
            DataTable dtPost  = dl.GetPost(iPostID);

            PostTitle.InnerText = dtPost.Rows[0].ItemArray[2].ToString();
            PostDate.InnerText  = Convert.ToDateTime(dtPost.Rows[0].ItemArray[1]).ToString("D");
            PostBody.InnerHtml  = dtPost.Rows[0].ItemArray[3].ToString();
            DataTable dtComments = dl.GetComments(iPostID);

            commentcount.InnerText = dtComments.Rows.Count.ToString();
            foreach (DataRow dr in dtComments.Rows)
            {
                comments.Controls.Add(new LiteralControl("<div style=\"background-color:#535684;margin-bottom:5px;padding:5px;\"><table style=\"width:100%;\"><td style=\"text-align:center;vertical-align:top;font-weight:bold;width:20%;border-right:solid 3px #313462;\">"));
                if (dr.ItemArray[4].ToString() != "nosite")
                {
                    comments.Controls.Add(new LiteralControl("<a href=\"" + dr.ItemArray[4].ToString() + "\">"));
                }
                comments.Controls.Add(new LiteralControl(dr.ItemArray[2].ToString()));
                if (dr.ItemArray[4].ToString() != "nosite")
                {
                    comments.Controls.Add(new LiteralControl("</a>"));
                }
                comments.Controls.Add(new LiteralControl("</td><td style=\"vertical-align:top;padding-left:10px;width:70%;\">" + dr.ItemArray[5].ToString() + "<br /><br />" + dr.ItemArray[3].ToString()));
                if (User.Identity.IsAuthenticated)
                {
                    comments.Controls.Add(new LiteralControl("</td><td style=\"vertical-align:middle;border-left:solid 3px #313462;text-align:center;width:10%;\">"));
                    lbtnDelete                  = new LinkButton();
                    lbtnDelete.ID               = dr.ItemArray[0].ToString();
                    lbtnDelete.Text             = "X";
                    lbtnDelete.CausesValidation = false;
                    lbtnDelete.OnClientClick    = "return confirm('Are you sure you want to delete this comment?');";
                    lbtnDelete.Click           += new EventHandler(lbtnDelete_Click);
                    comments.Controls.Add(lbtnDelete);
                }
                comments.Controls.Add(new LiteralControl("</td></tr></table></div>"));
            }

            if (!this.IsPostBack)
            {
                Session["CaptchaImageText"] = CaptchaImage.GenerateRandomCode(random);
            }
        }
Exemple #6
0
        public void ProcessRequest(HttpContext context)
        {
            string _capchaCode = CaptchaImage.GenerateRandomCode(CaptchaType.AlphaNumeric, 6);

            context.Session["capcha"] = _capchaCode;
            CaptchaImage c = new CaptchaImage(_capchaCode, 138, 40, "Tahoma", Color.White, Color.Orange);

            context.Response.ClearContent();
            context.Response.ContentType = "image/jpeg";
            MemoryStream ms = new MemoryStream();

            c.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            context.Response.OutputStream.Write(ms.ToArray(), 0, Convert.ToInt32(ms.Length));
            ms.Close();
            context.Response.End();
        }
Exemple #7
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        try
        {
            if (!loginSuccessfully)
            {
                tbValidCode.Text = "";

                //在Cookie中放置一个随机数用作验证码。
                Response.Cookies["AreYouHuman"].Value = StringSecurity.DESEncrypt(CaptchaImage.GenerateRandomCode());
            }
        }
        catch (Exception ex)
        {
            log.Error(null, ex);
            throw;
        }
    }
Exemple #8
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (tbxCode.Text == Session["CaptchaImageText"].ToString())
        {
            if (this.IsValid)
            {
                SmtpMail.SmtpServer = "relay-hosting.secureserver.net";

                MailMessage mm = new MailMessage();
                mm.BodyFormat = MailFormat.Html;
                mm.To         = "*****@*****.**";
                mm.Cc         = "*****@*****.**";
                mm.From       = "*****@*****.**";
                mm.Subject    = "New Job Bid Request";
                mm.Body       = "You have a new job bid request.<br /><br />";
                mm.Body      += "Customer Information";
                mm.Body      += "<br />Name: " + tbxName.Text;
                mm.Body      += "<br />Phone: " + tbxPhone.Text;
                mm.Body      += "<br />Email: " + tbxEmail.Text;
                mm.Body      += "<br /><br />Type of cleaning: " + ddlCleaningType.SelectedValue.ToString();
                mm.Body      += "<br /><br />Brief Job Description:<br />";
                mm.Body      += tbxDescription.Text;
                mm.Body      += "<br /><br />How they heard about us:<br />";
                mm.Body      += ddlHearAboutUs.SelectedValue.ToString();

                try
                {
                    SmtpMail.Send(mm);
                    Response.Write("<div style=\"color:#009900;text-align:center;\"><h2>REQUEST SUCCESSFUL! One of our representatives will contact you soon.</h2><a href=\"http://www.fordscleaning.com\">(Click here to continue)</a></div>");
                }
                catch
                {
                    Response.Write("<div style=\"color:#ff0000;text-align:center;\"><h2>Something went wrong. Please call (801)404-0848 to speak with one of our representatives. We apologize for the inconvenience.</h2><a href=\"http://www.fordscleaning.com\">(Click here to continue)</a></div>");
                }
                Response.Flush();
                Response.Close();
            }
        }
        else
        {
            Session["CaptchaImageText"] = CaptchaImage.GenerateRandomCode(random);
            CustomValidator3.IsValid    = false;
        }
    }
Exemple #9
0
        void SaveArticle()
        {
            try
            {
                if (CDHelper.Config.EnableLoginAuhenCode == "true" && this.ValidateTextBox.Text != Request.Cookies["AreYouHuman"].Value)
                {
                    Messages.ShowError("错误:您输入的验证码不正确,请重新输入!");
                    // Clear the input and create a new random code.
                    this.ValidateTextBox.Text             = "";
                    Response.Cookies["AreYouHuman"].Value = CaptchaImage.GenerateRandomCode();
                    return;
                }

                string ownerId = OwnerID;
                if (ownerId == null)
                {
                    ownerId = ChannelDropDownList.SelectedValue;
                }

                if (String.IsNullOrEmpty(ownerId))
                {
                    Messages.ShowError("文章栏目不能为空!");
                    return;
                }

                Article a = ThisArticle;
                a.Description = DescriptionTextBox.Value;
                a.Title       = TitleTextBox.Value;
                a.SubTitle    = SubTitleTextBox.Value;
                a.Color       = ddlColor.SelectedValue;
                a.FontStyle   = chkItalic.Checked ? "Italic" : "";
                a.FontWeight  = chkBold.Checked ? "Bold" : "";
                //a.ID = ArticleID;
                if (IndexTextBox.Value.Trim() == "")
                {
                    a.Index = 0;
                }
                else
                {
                    a.Index = Convert.ToInt32(IndexTextBox.Value);
                }
                a.Source        = SourceTextBox.Value;
                a.AllowComments = AllowCommentsCheckBox.Checked ? 1 : 0;
                //if (IsShowCheckBox.Checked)
                //{
                //    a.EnumState = StateMgr.StateInitialize();
                //    a.EnumState = StateMgr.StateProcess(a.EnumState, EnumLibrary.Business.HomeRecommend, 1);
                //}
                //a.IsShow = IsShowCheckBox.Checked ? 1 : 0;
                a.Author      = AuthorTextBox.Value;
                a.State       = Convert.ToInt32(StateDropDownList.SelectedValue);
                a.ContentType = Convert.ToInt32(ActicleTypeDropDownList.SelectedValue);
                //a.IsImage = (TypeOfArticle)a.ContentType == TypeOfArticle.QuoteArticle || (TypeOfArticle)a.ContentType == TypeOfArticle.ShareArticle ? 1 : 0;
                a.ContentUrl     = ContentUrlTextBox.Value;
                a.Content        = We7Helper.ConvertPageBreakFromVisualToChar(ContentTextBox.Value);
                a.KeyWord        = KeywordTextBox.Value;
                a.DescriptionKey = DescriptionKeyTextBox.Value;

                if (GeneralConfigs.GetConfig().AllowParentArticle&& !string.IsNullOrEmpty(ParentArticleID.Value))
                {
                    a.ParentID = ParentArticleID.Value;
                }
                else
                {
                    a.ParentID = We7Helper.EmptyGUID;
                }

                if (UpdatedTextBox.Value.Trim() == "")
                {
                    a.Updated = DateTime.Now;
                }
                else
                {
                    a.Updated = Convert.ToDateTime(UpdatedTextBox.Value);
                }
                if (txtInvalidDate.Value != "")
                {
                    a.Overdue = Convert.ToDateTime(txtInvalidDate.Value.Trim());
                }
                else
                {
                    GeneralConfigInfo si = GeneralConfigs.GetConfig();
                    int OverdueDateTime  = si.OverdueDateTime;
                    a.Overdue = a.Updated.AddDays(OverdueDateTime);
                }
                if (ArticleID == null)
                {
                    a.AccountID = AccountID;
                    a.OwnerID   = ownerId;
                    Channel ch = ChannelHelper.GetChannel(ownerId, null);
                    if (ch.FullUrl != null && ch.FullUrl != "")
                    {
                        a.ChannelFullUrl = ch.FullUrl;
                    }
                    if (ch.Process != null && ch.Process == "1")
                    {
                        a.State = 2;
                    }
                    //a.ChannelName = ch.ChannelName;
                    /*这儿把上面一句注了,改成了下面的。上面一句与老系统不兼容*/
                    a.ChannelName     = ch.Name;
                    a.FullChannelPath = ch.FullPath;
                    //int type = StateMgr.GetStateValue(ch.EnumState, EnumLibrary.Business.ChannelContentType);
                    //a.EnumState = StateMgr.StateProcess(a.EnumState, EnumLibrary.Business.ArticleType, type);
                    // a.State = 0;

                    //如果禁用
                    if (StateDropDownList.SelectedValue == "0")
                    {
                        a.state = 0;
                    }
                    Article article = ArticleHelper.AddArticles(a);
                    // 往全文检索里插入数据

                    ArticleIndexHelper.InsertData(article.ID, 0);

                    #region 自动提交一审(mxy2011-10-18)
                    if (ch.Process != null && ch.Process == "1" && StateDropDownList.SelectedValue != "0")
                    {
                        Processing ap = ArticleProcessHelper.GetArticleProcess(article);
                        if (ap.ArticleState != ArticleStates.Checking)
                        {
                            string accName = AccountHelper.GetAccount(AccountID, new string[] { "LastName" }).LastName;
                            ap.ProcessState     = ProcessStates.FirstAudit;
                            ap.ProcessDirection = ((int)ProcessAction.Next).ToString();
                            ap.ProcessAccountID = AccountID;
                            ap.ApproveName      = accName;
                            ArticleProcessHelper.SaveFlowInfoToDB(article, ap);
                        }
                    }
                    #endregion

                    //记录日志
                    string content = string.Format("新建文章:“{0}”", a.Title);
                    AddLog("新建文章", content);
                }
                else
                {
                    Channel  ch     = ChannelHelper.GetChannel(ownerId, null);
                    string[] fields = new string[] { "Description", "Title", "Content", "Updated", "Index", "Source", "AllowComments", "Author", "State", "IsShow", "IsImage", "SubTitle", "ContentUrl", "ContentType", "IsDeleted", "Overdue", "KeyWord", "DescriptionKey", "ParentID", "FullChannelPath", "ChannelFullUrl", "Color", "FontWeight", "FontStyle" };

                    ArticleHelper.UpdateArticle(a, fields);

                    // 往全文检索里更新数据
                    ArticleIndexHelper.InsertData(a.ID, 0);

                    if (ch.Process != null && ch.Process == "1" && StateDropDownList.SelectedValue != "0")
                    {
                        Processing ap = ArticleProcessHelper.GetArticleProcess(a);
                        if (ap.ArticleState != ArticleStates.Checking && ap.ProcessState != ProcessStates.EndAudit)
                        {
                            //编辑审核启用
                            if (ch.Process != null && ch.Process == "1" && StateDropDownList.SelectedValue != "0")
                            {
                                a.State = 2;
                                ArticleHelper.UpdateArticle(a, new string[] { "State" });
                            }

                            string accName = AccountHelper.GetAccount(AccountID, new string[] { "LastName" }).LastName;
                            ap.ProcessState     = ProcessStates.FirstAudit;
                            ap.ProcessDirection = ((int)ProcessAction.Next).ToString();
                            ap.ProcessAccountID = AccountID;
                            ap.ApproveName      = accName;
                            ArticleProcessHelper.SaveFlowInfoToDB(a, ap);
                        }
                    }
                    //记录日志
                    string content = string.Format("修改了文章“{0}”", a.Title);
                    AddLog("编辑文章", content);
                }

                string rawurl = We7Helper.RemoveParamFromUrl(Request.RawUrl, "saved");
                if (!String.IsNullOrEmpty(ArticleID))
                {
                    rawurl = We7Helper.AddParamToUrl(rawurl, "saved", "1");
                    rawurl = We7Helper.AddParamToUrl(rawurl, "Submit", "1");
                }
                else
                {
                    rawurl = We7Helper.RemoveParamFromUrl(Request.RawUrl, "oid");
                    rawurl = We7Helper.RemoveParamFromUrl(rawurl, "ParentID");
                    rawurl = We7Helper.AddParamToUrl(rawurl, "id", a.ID);
                    rawurl = We7Helper.AddParamToUrl(rawurl, "Submit", "0");
                }

                Response.Redirect(rawurl);
            }
            catch (FormatException)
            {
                Messages.ShowError("无法保存文章信息:可能是文章排序或修改日期格式不正确。");
                return;
            }
            catch (Exception ex)
            {
                Messages.ShowError("无法保存文章信息:" + ex.Message);
            }
        }
Exemple #10
0
 private void GenerateRandomCode()
 {
     Response.Cookies["AreYouHuman"].Value = CaptchaImage.GenerateRandomCode();
 }
Exemple #11
0
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            string        u      = Request["u"];
            string        pwd    = Request["p"];
            string        r      = Request["r"];
            string        _code  = Request["code"];
            string        _email = Request["email"];
            StringBuilder sb     = new StringBuilder();
            string        subact = Request["subact"];

            switch (subact)
            {
            case "logout":
                Security.LogOut();
                sb.AppendFormat("1");
                break;

            case "changePass":
                #region changePass: Đổi mật khẩu
                if (!string.IsNullOrEmpty(u))
                {
                    pwd = maHoa.EncryptString(pwd, u);
                    if (MemberDal.UpdatePasswordByCode(u, _code, pwd))
                    {
                        sb.Append("1");
                    }
                    else
                    {
                        sb.Append("0");
                    }
                }
                else
                {
                    sb.Append("0");
                }
                break;

                #endregion
            case "recovery":
                #region recovery: Lấy lại mật khẩu
                if (!string.IsNullOrEmpty(u))
                {
                    string e = MemberDal.SelectEmailByUserName(u).Email;
                    if (!string.IsNullOrEmpty(e))
                    {
                        string newPass = CaptchaImage.GenerateRandomCode(CaptchaType.Numeric, 5);
                        MemberDal.UpdateCodeByUsername(u, newPass);
                        sendEmailDele _dele = new sendEmailDele(sendmail);
                        _dele.BeginInvoke(e, "Ma xac nhan", string.Format("Username:{0}<br/>Ma xac nhan: {1}", e, newPass), null, null);
                        sb.Append("1");
                    }
                    else
                    {
                        sb.Append("0");
                    }
                }
                else
                {
                    sb.Append("0");
                }
                break;

                #endregion
            default:

                bool ok = Security.Login(u, pwd, r.ToLower());
                if (ok)
                {
                    sb.AppendFormat(u);
                }
                else
                {
                    sb.AppendFormat("0");
                }
                break;
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
Exemple #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (Request.UserHostAddress == "98.202.119.104")
        //{
        //    plmplayer.Visible = false;
        //}

        DataLayer dl = new DataLayer();

        //loggedinpanels.Controls.Add(new LiteralControl("<div class=\"formtitle\">KRNX&nbsp;Podcast!</div><div class=\"formpanel\"><center><object class=\"playerpreview\" type=\"application/x-shockwave-flash\" data=\"player_mp3_multi.swf\" width=\"200\" height=\"100\"><param name=\"movie\" value=\"player_mp3_multi.swf\" /><param name=\"FlashVars\" value=\"mp3=/KRNX/Ep01.mp3|/KRNX/Ep02.mp3|/KRNX/Ep03.mp3&amp;title=KRNX 01 - What is Referral NetworX?|KRNX 02 - Why Relationships Are Important|KRNX 03 - Relationship Marketing&amp;bgcolor1=598959&amp;bgcolor2=73B472\" /></object><br /></center></div>"));

        if (User.Identity.IsAuthenticated)
        {
            loggedoutpanels.Visible  = false;
            loggedoutcontent.Visible = false;

            DataTable dtMotivator = dl.GetLastSentDailyMotivator();
            if (dtMotivator.Rows.Count > 0)
            {
                loggedincontent.Controls.Add(new LiteralControl("<div class=\"contenttitle\">Daily Motivator</div><div class=\"contentpanel\">"));
                string sYouTubeLink = dtMotivator.Rows[0].ItemArray[5].ToString();
                if (sYouTubeLink != "No Video.")
                {
                    sYouTubeLink = sYouTubeLink.Replace(".com/watch?v=", ".com/v/");
                    loggedincontent.Controls.Add(new LiteralControl("<center><object width=\"425\" height=\"344\"><param name=\"movie\" value=\"" + sYouTubeLink + "&amp;hl=en_US&amp;fs=1&amp;\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"" + sYouTubeLink + "&amp;hl=en_US&amp;fs=1&amp;\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"425\" height=\"344\"></embed></object></center>"));
                }
                loggedincontent.Controls.Add(new LiteralControl("<center>" + dtMotivator.Rows[0].ItemArray[4].ToString() + "</center></div>"));
            }

            DataTable dtBlog = dl.GetLatestBlog();
            if (dtBlog.Rows.Count > 0)
            {
                string sBody = "<i>No Summary</i>";
                if (dtBlog.Rows[0].ItemArray[4].ToString().Contains('~'))
                {
                    sBody = dtBlog.Rows[0].ItemArray[4].ToString();
                    sBody = sBody.Remove(sBody.IndexOf('~'));
                }
                loggedincontent.Controls.Add(new LiteralControl("<div class=\"contenttitle\">Latest Blog</div><div class=\"contentpanel\"><table style=\"width:100%;\"><tr><td><div style=\"font-size:35px;font-family:arial;\"><a class=\"navlink\" href=\"Blog.aspx?bid=" + dtBlog.Rows[0].ItemArray[0].ToString() + "\">" + dtBlog.Rows[0].ItemArray[3].ToString() + "</a></div><div>Posted by <a href=\"Profile.aspx?member=" + dtBlog.Rows[0].ItemArray[1].ToString() + "\">" + dl.GetFullMemberNameBy_Email(dtBlog.Rows[0].ItemArray[1].ToString()) + "</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;" + Convert.ToDateTime(dtBlog.Rows[0].ItemArray[2]).ToString("D") + "</div><br /><div>" + sBody + "<br /><br /><b><a class=\"navlink\" href=\"Blog.aspx?bid=" + dtBlog.Rows[0].ItemArray[0].ToString() + "\">(Read More)</a></b></div></td></tr></table></div>"));
            }

            loggedincontent.Controls.Add(new LiteralControl("<div class=\"contenttitle\">Check Out Our Latest Articles!</div><div style=\"font-size:25px;text-align:center;\" class=\"contentpanel\">"));
            DataTable dtArticles = dl.GetFiveLatestArticles();
            foreach (DataRow dr in dtArticles.Rows)
            {
                loggedincontent.Controls.Add(new LiteralControl("<a class=\"navlink\" style=\"text-decoration:underline;\" href=\"Article.aspx?aid=" + dr.ItemArray[0].ToString() + "\">" + dr.ItemArray[2].ToString() + "</a> <span style=\"font-size:14px;\">by <a href=\"Profile.aspx?member=" + dr.ItemArray[4].ToString() + "\">" + dl.GetFullMemberNameBy_Email(dr.ItemArray[4].ToString()) + "</a></span><hr />"));
            }
            loggedincontent.Controls.Add(new LiteralControl("</div>"));

            //logged in panels

            loggedinpanels.Controls.Add(new LiteralControl("<div class=\"contenttitle\">Featured Member</div><div class=\"contentpanel\">"));
            DataTable dtRandomMember = dl.GetRandomMember();
            loggedinpanels.Controls.Add(new LiteralControl("<table style=\"width:100%;\"><tr><td style=\"font-size:13px;text-align:center;\"><a href=\"Profile.aspx?member=" + dtRandomMember.Rows[0].ItemArray[0].ToString() + "\"><img style=\"border-width:0px;\" src=\"MakeThumbnail.aspx?size=100&image=images/MemberAvatars/" + dtRandomMember.Rows[0].ItemArray[3].ToString() + "\" /></a><br /><a href=\"Profile.aspx?member=" + dtRandomMember.Rows[0].ItemArray[0].ToString() + "\">View Profile</a></td><td style=\"padding-left:5px;font-size:13px;width:100%;\"><b>Name:</b> " + dtRandomMember.Rows[0].ItemArray[2].ToString() + "<br /><br /><b>Location:</b> " + dtRandomMember.Rows[0].ItemArray[17].ToString() + "<br /><br /><b>Business:</b> " + dtRandomMember.Rows[0].ItemArray[8].ToString() + "<br /><br />"));
            if (dtRandomMember.Rows[0].ItemArray[6].ToString() != "")
            {
                loggedinpanels.Controls.Add(new LiteralControl("<center><a href=\"" + dtRandomMember.Rows[0].ItemArray[6].ToString() + "\">Visit Website</a></center>"));
            }
            loggedinpanels.Controls.Add(new LiteralControl("</td></tr></table></div>"));

            DataTable dtMemberAd = dl.GetRandomAd();
            loggedinpanels.Controls.Add(new LiteralControl("<div class=\"contenttitle\">Member Ad</div><div style=\"text-align:center;\" class=\"contentpanel\"><a href=\"" + dtMemberAd.Rows[0].ItemArray[2].ToString() + "\"><img style=\"width:230px; border-width:0px;\" src=\"" + dtMemberAd.Rows[0].ItemArray[1].ToString() + "\" /></a></div>"));

            loggedinpanels.Controls.Add(new LiteralControl("<div class=\"contenttitle\">Popular Topics</div><div style=\"font-size:15px;\" class=\"contentpanel\"><ul>"));
            DataTable dtTopics = dl.GetFiveTopics();
            foreach (DataRow dr in dtTopics.Rows)
            {
                loggedinpanels.Controls.Add(new LiteralControl("<li style=\"display:list-item;margin:0px;background-color:transparent;border-width:0px;\"><a href=\"Topic.aspx?topic=" + dr.ItemArray[0].ToString() + "\">" + dr.ItemArray[4].ToString() + "</a></li>"));
            }
            loggedinpanels.Controls.Add(new LiteralControl("</ul></div>"));
        }
        else
        {
            DataTable dtMotivator = dl.GetLastSentDailyMotivator();
            if (dtMotivator.Rows.Count > 0)
            {
                dailymotivator.Controls.Add(new LiteralControl("<div class=\"contenttitle\">Daily Motivator</div><div class=\"contentpanel\">"));
                string sYouTubeLink = dtMotivator.Rows[0].ItemArray[5].ToString();
                if (sYouTubeLink != "No Video.")
                {
                    sYouTubeLink = sYouTubeLink.Replace(".com/watch?v=", ".com/v/");
                    dailymotivator.Controls.Add(new LiteralControl("<center><object width=\"425\" height=\"344\"><param name=\"movie\" value=\"" + sYouTubeLink + "&amp;hl=en_US&amp;fs=1&amp;\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"" + sYouTubeLink + "&amp;hl=en_US&amp;fs=1&amp;\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"425\" height=\"344\"></embed></object></center>"));
                }
                dailymotivator.Controls.Add(new LiteralControl("<center>" + dtMotivator.Rows[0].ItemArray[4].ToString() + "</center></div>"));
            }

            DataTable dtBlog = dl.GetLatestBlog();
            if (dtBlog.Rows.Count > 0)
            {
                string sBody = "<i>No Summary</i>";
                if (dtBlog.Rows[0].ItemArray[4].ToString().Contains('~'))
                {
                    sBody = dtBlog.Rows[0].ItemArray[4].ToString();
                    sBody = sBody.Remove(sBody.IndexOf('~'));
                }
                latestblog.Controls.Add(new LiteralControl("<div class=\"contenttitle\">Latest Blog</div><div class=\"contentpanel\"><table style=\"width:100%;\"><tr><td><div style=\"font-size:35px;font-family:arial;\"><a class=\"navlink\" href=\"Blog.aspx?bid=" + dtBlog.Rows[0].ItemArray[0].ToString() + "\">" + dtBlog.Rows[0].ItemArray[3].ToString() + "</a></div><div>Posted by <a href=\"Profile.aspx?member=" + dtBlog.Rows[0].ItemArray[1].ToString() + "\">" + dl.GetFullMemberNameBy_Email(dtBlog.Rows[0].ItemArray[1].ToString()) + "</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;" + Convert.ToDateTime(dtBlog.Rows[0].ItemArray[2]).ToString("D") + "</div><br /><div>" + sBody + "<br /><br /><b><a class=\"navlink\" href=\"Blog.aspx?bid=" + dtBlog.Rows[0].ItemArray[0].ToString() + "\">(Read More)</a></b></div></td></tr></table></div>"));
            }
            loggedoutcontent.Visible = true;
            lbWelcome_Click(null, null);
        }

        if (!this.IsPostBack)
        {
            Session["CaptchaImageText"] = CaptchaImage.GenerateRandomCode(random);
        }
    }
Exemple #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            iBlogID = Convert.ToInt32(Request.QueryString["blog"]);
        }
        catch
        {
            Response.Write("<h2>NO BLOG FOUND</h2>");
            Response.Flush();
            Response.Close();
        }

        if (!IsPostBack)
        {
            Session["CaptchaImageText"] = CaptchaImage.GenerateRandomCode(random);
        }

        DataTable dtBlog = DataLayer.GetBlogsBy_blogID(iBlogID);

        if (dtBlog.Rows.Count == 0)
        {
            Response.Write("<h2>NO BLOG FOUND</h2>");
            Response.Flush();
            Response.Close();
        }
        else
        {
            if (Convert.ToBoolean(dtBlog.Rows[0].ItemArray[4]))
            {
                Response.Write("<h2>NO BLOG FOUND</h2>");
                Response.Flush();
                Response.Close();
            }
        }

        blogtitle.InnerHtml   = dtBlog.Rows[0].ItemArray[1].ToString();
        Page.Title            = dtBlog.Rows[0].ItemArray[1].ToString();
        blogdate.InnerHtml    = dtBlog.Rows[0].ItemArray[3].ToString();
        blogcontent.InnerHtml = dtBlog.Rows[0].ItemArray[2].ToString().Replace("~", "");

        int iNumComments = DataLayer.GetCommentCountBy_blogID(iBlogID);

        blogdate.InnerHtml += " &nbsp " + iNumComments.ToString() + " Comments";

        blogedit.Controls.Add(new LiteralControl("<script type=\"text/javascript\" src=\"http://w.sharethis.com/button/sharethis.js#tabs=web%2Cpost%2Cemail&amp;charset=utf-8&amp;style=default&amp;publisher=9704f30f-b172-4e8c-afed-b53e027d8e5b&amp;popup=false\"></script>"));
        if ((User.Identity.Name.ToUpper() == "WALT") && (User.Identity.IsAuthenticated))
        {
            Button btnEdit = new Button();
            btnEdit.ID          = "btnEdit";
            btnEdit.Text        = "Edit";
            btnEdit.PostBackUrl = "http://www.fordscleaning.com/admin/AddEditBlog.aspx?blog=" + iBlogID.ToString();
            blogedit.Controls.Add(btnEdit);
        }

        comments.InnerHtml = "";
        DataTable dtComments = DataLayer.GetCommentsBy_blogID(iBlogID);
        bool      bColored   = true;

        foreach (DataRow dr in dtComments.Rows)
        {
            if (!Convert.ToBoolean(dr.ItemArray[5]))
            {
                LiteralControl lc = new LiteralControl();
                if (bColored)
                {
                    lc.Text += "<div class=\"comment\" style=\"background-color:#ffffcc;\">";
                }
                else
                {
                    lc.Text += "<div class=\"comment\" style=\"background-color:#ffffff;\">";
                }
                bColored = !bColored;
                lc.Text += "<table width=\"100%\"><tr><td rowspan=\"2\" width=\"200px\" valign=\"top\" align=\"center\" style=\"color:#000000; border-right: solid 1px #880000; padding: 10px;\"><b>";
                if (dr.ItemArray[6].ToString() != "")
                {
                    lc.Text += "<a href=\"" + dr.ItemArray[6].ToString() + "\">" + dr.ItemArray[2].ToString() + "</a>";
                }
                else
                {
                    lc.Text += dr.ItemArray[2].ToString();
                }
                lc.Text += "</b></td><td style=\"padding:10px;\" valign=\"top\">" + dr.ItemArray[3].ToString() + "</td></tr><tr><td style=\"text-align:right; vertical-align:bottom; font-size: 15px;\">" + dr.ItemArray[4].ToString() + " &nbsp ";
                comments.Controls.Add(lc);
                if ((User.Identity.Name.ToUpper() == "WALT") && (User.Identity.IsAuthenticated))
                {
                    btnDeleteComment        = new Button();
                    btnDeleteComment.Text   = "Delete Comment";
                    btnDeleteComment.Click += new EventHandler(btnDeleteComment_Click);
                    btnDeleteComment.ID     = dr.ItemArray[0].ToString();
                    comments.Controls.Add(btnDeleteComment);
                }
                lc = new LiteralControl("</td></tr></table></div>");
                comments.Controls.Add(lc);
            }
        }
    }
Exemple #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (User.Identity.IsAuthenticated)
        {
            loggedout.Visible = false;
            loggedin.Visible  = true;
        }
        else
        {
            loggedout.Visible = true;
            loggedin.Visible  = false;
        }

        if (!IsPostBack)
        {
            Session["CaptchaImageText"] = CaptchaImage.GenerateRandomCode(random);
        }

        if (Request.QueryString["remove"] != null)
        {
            string sRemove = Request.QueryString["remove"].ToString();
            try
            {
                DataLayer.RemoveNewsletterEmail(sRemove);

                SmtpMail.SmtpServer = "relay-hosting.secureserver.net";
                MailMessage mm = new MailMessage();
                mm.BodyFormat = MailFormat.Html;
                mm.To         = "*****@*****.**";
                mm.From       = "*****@*****.**";
                mm.Subject    = "Someone unsubscribed from your newsletter.";
                mm.Body       = sRemove + " unsubscribed from your newsletter.";
                try
                {
                    SmtpMail.Send(mm);
                }
                catch
                { }

                Response.Write("<h3>" + sRemove + " has been removed from our list. Have a great day!</h3>");
            }
            catch
            {
                Response.Write("<h3>" + sRemove + " is not on our list or is an invalid email address.</h3>");
                DataLayer.CloseConn();
            }
            Response.Flush();
            Response.Close();
        }

        if (Request.QueryString["add"] != null)
        {
            string sAdd = Request.QueryString["add"].ToString();
            try
            {
                DataLayer.AddNewsletterEmail(sAdd);
                Response.Write("<h3>Thank you for subscribing to our newsletter!</h3><a href=\"http://www.fordscleaning.com\">(Click here to continue.)</a>");
                SmtpMail.SmtpServer = "relay-hosting.secureserver.net";

                MailMessage mm = new MailMessage();
                mm.BodyFormat = MailFormat.Html;
                mm.To         = sAdd;
                mm.From       = "*****@*****.**";
                mm.Subject    = "Ford's Cleaning Weekly Newsletter";
                mm.Body       = "This email is to inform you of your subscription to our free weekly newsletter.<br /><br />";
                mm.Body      += "If you did not sign up for this or wish to discontinue for any other reason simply click the link below. Otherwise we hope you enjoy our newsletter!<br /><br />";
                mm.Body      += "<a href=\"http://www.fordscleaning.com/Newsletter.aspx?remove=" + sAdd + "\">http://www.fordscleaning.com/Newsletter.aspx?remove=" + sAdd + "</a>";

                try
                {
                    SmtpMail.Send(mm);
                }
                catch
                { }

                SmtpMail.SmtpServer = "relay-hosting.secureserver.net";
                mm            = new MailMessage();
                mm.BodyFormat = MailFormat.Html;
                mm.To         = "*****@*****.**";
                mm.From       = "*****@*****.**";
                mm.Subject    = "New Newsletter Subscription";
                mm.Body       = sAdd + " subscribed to your newsletter.";
                try
                {
                    SmtpMail.Send(mm);
                }
                catch
                { }
            }
            catch
            {
                Response.Write("<h3>It seems that email address is already on our list. Thanks for being a reader!</h3><a href=\"http://www.fordscleaning.com\">(Click here to continue.)</a>");
                DataLayer.CloseConn();
            }
            Response.Flush();
            Response.Close();
        }
    }
Exemple #15
0
        public override void KhoiTao(SqlConnection con)
        {
            bool login             = Security.IsAuthenticated();
            Page _Page             = new Page();
            ClientScriptManager cs = _Page.ClientScript;
            StringBuilder       sb = new StringBuilder();
            HttpContext         c  = HttpContext.Current;
            string _Usr            = c.Request["Usr"];
            string _Pwd            = c.Request["Pwd"];
            string _Rem            = c.Request["Rem"];
            string _Ten            = c.Request["Ten"];
            string _Email          = c.Request["Email"];
            string _ActiveCode     = c.Request["ActiveCode"];
            string _GioiTinh       = c.Request["GioiTinh"];

            switch (subAct)
            {
            case "Login":
                #region Login
                sb.Append(Security.Login(_Usr, _Pwd, _Rem).ToString());
                break;

                #endregion
            case "LogOut":
                #region LogOut
                Security.LogOut();
                break;

                #endregion
            case "Reg":
                #region Reg: Đăng ký
                if (!string.IsNullOrEmpty(_Email) && !string.IsNullOrEmpty(_Usr))
                {
                    string activeCode = CaptchaImage.GenerateRandomCode(CaptchaType.Numeric, 6);
                    User   Item       = new User();
                    Item.Active     = false;
                    Item.ActiveCode = activeCode;
                    Item.Email      = _Email;
                    Item.NgayTao    = DateTime.Now;
                    Item.Ten        = _Ten;
                    Item.RowId      = Guid.NewGuid();
                    Item.Username   = _Usr;
                    Item.GioiTinh   = Convert.ToBoolean(_GioiTinh);
                    Item.Pwd        = linh.common.maHoa.EncryptString(_Usr, _Usr);
                    Item            = UserDal.Insert(Item);
                    sendEmailDele dele = new sendEmailDele(omail.SendthongBao);
                    IAsyncResult  ar   = dele.BeginInvoke(_Email, "Căng tin (cangtin.com) - Email kích hoạt", string.Format(emailActiveBody, _Ten, Item.ActiveCode
                                                                                                                            , domain, _Email), null, null);
                    sb.Append(Item.ID.ToString());
                }
                break;

                #endregion
            case "ValidateEmail":
                #region ValidateEmail : Kiểm tra email
                if (!string.IsNullOrEmpty(_Email))
                {
                    sb.Append(MemberDal.ValidEmail(_Email).ToString());
                }
                break;

                #endregion
            case "ActiveByCode":
                #region AciveByCode : Kiểm tra ActiveCode
                if (!string.IsNullOrEmpty(_ActiveCode))
                {
                    bool ok = UserDal.ValidActiveCode(_ActiveCode, Security.Username);
                    if (!ok)
                    {
                        Security.Login(Security.Username, "True");
                        c.Session["c-user"] = null;
                    }
                    if (!string.IsNullOrEmpty(Request["type"]))
                    {
                        c.Response.Redirect(domain);
                    }
                    else
                    {
                        sb.Append(ok.ToString());
                    }
                }
                break;

                #endregion
            case "ReSendActiveEmail":
                #region ReSendActiveEmail : Gửi lại mail
                if (!string.IsNullOrEmpty(_Email))
                {
                    User Item = UserDal.SelectByUsername(Security.Username);
                    if (_Email != Item.Email)
                    {
                        if (UserDal.ValidEmail(_Email))
                        {
                            sb.Append("0");
                        }
                        else
                        {
                            UserDal.UpdateEmail(Security.Username, _Email);
                        }
                    }
                    sendEmailDele dele = new sendEmailDele(omail.SendthongBao);
                    IAsyncResult  ar   = dele.BeginInvoke(_Email, "Căng tin (cangtin.com) - Email kích hoạt", string.Format(emailActiveBody, _Ten, Item.ActiveCode
                                                                                                                            , domain, _Email), null, null);
                    rendertext("1");
                }
                break;

                #endregion
            case "ValidateUsername":
                #region ValidateUsername : Kiểm tra username
                if (!string.IsNullOrEmpty(_Usr))
                {
                    sb.Append(UserDal.ValidUsername(_Usr).ToString());
                }
                break;

                #endregion
            case "scpt":
                #region Nạp js
                sb.AppendFormat(@"{0}"
                                , cs.GetWebResourceUrl(typeof(authentication), "appStore.authorityStore.userMgr.js.js"));
                break;

                #endregion
            default: break;
            }
            Html = sb.ToString();
            base.KhoiTao(con);
        }
        public void ProcessRequest(HttpContext context)
        {
            StringBuilder sb              = new StringBuilder();
            string        act             = context.Request["act"];
            string        rqPlug          = context.Request["rqPlug"];
            string        imgSaveLoc      = context.Server.MapPath("~/lib/up/i/");
            string        imgTemp         = context.Server.MapPath("~/lib/up/temp/");
            string        docTemp         = context.Server.MapPath("~/lib/up/d/");
            string        imgSaveTintuc   = context.Server.MapPath("~/lib/up/tintuc/");
            string        imgSaveSanPham  = context.Server.MapPath("~/lib/up/sanpham/");
            string        imgSaveQuangCao = context.Server.MapPath("~/lib/up/quangcao/");
            string        imgSaveKTNN     = context.Server.MapPath("~/lib/up/KTNN/");

            string _height   = context.Request["height"];
            string _width    = context.Request["width"];
            string _PRowIdSP = context.Request["PRowIdSP"];

            switch (act)
            {
            case "loadPlug":
                #region loadPlug: nap plug
                if (rqPlug != null)
                {
                    sb.Append(PlugHelper.RenderHtml(rqPlug));
                }
                rendertext(sb);
                break;

                #endregion
            case "upload":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, imgten);
                    context.Request.Files[0].SaveAs(imgSaveLoc + imgten + "full" + img.Ext);

                    img.Crop(420, 560);
                    img.Save(imgSaveLoc + imgten + "420x560" + img.Ext);

                    img.Crop(240, 180);
                    img.Save(imgSaveLoc + imgten + "240x180" + img.Ext);

                    img.Crop(100, 100);
                    img.Save(imgSaveLoc + imgten + "100x100" + img.Ext);

                    img.Crop(50, 50);
                    img.Save(imgSaveLoc + imgten + img.Ext);

                    rendertext(imgten + img.Ext);
                }

                break;

                #endregion
            case "uploadQuangCao":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveQuangCao + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveQuangCao + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Save(imgSaveQuangCao + imgten + "source" + img.Ext);
                    img.Crop(int.Parse(_width), int.Parse(_height));
                    img.Save(imgSaveQuangCao + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }

                break;

                #endregion
            case "uploadSanPham":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveSanPham + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveSanPham + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Crop(400, 400);
                    img.Save(imgSaveSanPham + imgten + "400x400" + img.Ext);
                    img.Crop(400, 300);
                    img.Save(imgSaveSanPham + imgten + "400x300" + img.Ext);
                    img.Crop(200, 200);
                    img.Save(imgSaveSanPham + imgten + "200x200" + img.Ext);
                    img.Crop(90, 90);
                    img.Save(imgSaveSanPham + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }

                break;

                #endregion
            case "uploadTintuc":
                #region upload ?nh
                if (Security.IsAuthenticated())
                {
                    if (context.Request.Files[0] != null)
                    {
                        string imgten = Guid.NewGuid().ToString();
                        if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                        {
                            try
                            {
                                imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                                if (File.Exists(imgSaveTintuc + context.Request["oldFile"]))
                                {
                                    File.Delete(imgSaveTintuc + context.Request["oldFile"]);
                                }
                            }
                            finally
                            {
                            }
                        }
                        ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                        context.Request.Files[0].SaveAs(imgSaveTintuc + imgten + "full" + img.Ext);
                        img.Crop(180, 120);
                        img.Save(imgSaveTintuc + imgten + img.Ext);
                        rendertext(imgten + img.Ext);
                    }
                }
                break;

                #endregion
            case "uploadKTNN":
                #region upload ?nh
                if (Security.IsAuthenticated())
                {
                    if (context.Request.Files[0] != null)
                    {
                        string imgten = Guid.NewGuid().ToString();
                        if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                        {
                            try
                            {
                                imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                                if (File.Exists(imgSaveKTNN + context.Request["oldFile"]))
                                {
                                    File.Delete(imgSaveKTNN + context.Request["oldFile"]);
                                }
                            }
                            finally
                            {
                            }
                        }
                        ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                        img.Crop(730, 600);
                        img.Save(imgSaveKTNN + imgten + "730x600" + img.Ext);
                        img.Crop(420, 280);
                        img.Save(imgSaveKTNN + imgten + "420x280" + img.Ext);
                        img.Crop(130, 100);
                        img.Save(imgSaveKTNN + imgten + img.Ext);
                        rendertext(imgten + img.Ext);
                    }
                }
                break;

                #endregion
            case "uploadFlash":
                #region upload flash
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    if (Path.GetExtension(context.Request.Files[0].FileName).ToLower() == ".swf")
                    {
                        string flash = Guid.NewGuid().ToString();

                        context.Request.Files[0].SaveAs(context.Server.MapPath("~/lib/up/v/") + flash + Path.GetExtension(context.Request.Files[0].FileName));
                        rendertext(flash + Path.GetExtension(context.Request.Files[0].FileName));
                    }
                    else
                    {
                        ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                        img.Crop(420, 280);
                        img.Save(imgSaveLoc + imgten + "420x280" + img.Ext);
                        img.Crop(130, 100);
                        img.Save(imgSaveLoc + imgten + img.Ext);
                        img.Crop(370, 90);
                        img.Save(imgSaveLoc + imgten + "370x90" + img.Ext);
                        rendertext(imgten + img.Ext);
                    }
                }

                break;

                #endregion
            case "uploadFull":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Save(imgSaveLoc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
                break;

                #endregion
            case "uploadfileDkLuong":
                #region upload tài li?u
                //if (!loggedIn) rendertext("403");
                if (context.Request.Files[0] != null)
                {
                    string foldername = Guid.NewGuid().ToString().Replace("-", "");
                    string filename   = Path.GetFileNameWithoutExtension(context.Request.Files[0].FileName);
                    string fileType   = Path.GetExtension(context.Request.Files[0].FileName);
                    Directory.CreateDirectory(docTemp + foldername);
                    context.Request.Files[0].SaveAs(docTemp + foldername + "/" + filename + fileType);
                    //context.Request.Files[0].SaveAs(docTemp +  filename + fileType);
                    Files item = new Files();
                    item.Download = 0;
                    item.MimeType = fileType;
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.Username;
                    item.Path     = filename;
                    item.PID      = Guid.NewGuid();
                    item.RowId    = Guid.NewGuid();
                    item.Size     = context.Request.Files[0].ContentLength;
                    item.Ten      = filename;
                    item.ThuMuc   = foldername;
                    item.VB_ID    = 0;
                    item          = FilesDal.Insert(item);
                    rendertext(item.ID.ToString());
                }
                break;

                #endregion
            case "download":
                string _F_ID = context.Request["ID"];
                if (!string.IsNullOrEmpty(_F_ID))
                {
                    Files item = FilesDal.SelectById(Convert.ToInt32(_F_ID));
                    context.Response.Buffer = true;
                    context.Response.Clear();
                    context.Response.AddHeader("content-disposition", "attachment; filename=\"" + item.Ten + item.MimeType + "\"");
                    context.Response.ContentType = "octet/stream";
                    //Response.ContentType = "application/ms-word";
                    context.Response.WriteFile(context.Server.MapPath("~/lib/up/d/") + item.ThuMuc + "/" + item.Path + item.MimeType);
                }
                break;

            case "uploadvideo":
                if (Security.IsAuthenticated())
                {
                    if (context.Request.Files[0] != null)
                    {
                        string imgten         = Guid.NewGuid().ToString();
                        string strVideoRender = "";
                        context.Request.Files[0].SaveAs(context.Server.MapPath("~/lib/up/v/") + imgten + Path.GetExtension(context.Request.Files[0].FileName));
                        string _hinhanh = "";
                        string fWmv     = "";
                        if (Path.GetExtension(context.Request.Files[0].FileName).ToLower() == ".flv")
                        {
                            fWmv = WMV_encode(context, imgten + Path.GetExtension(context.Request.Files[0].FileName), "320", "240", "64", "44100");
                            context.Request.Files[0].SaveAs(context.Server.MapPath("~/lib/up/v/") + fWmv);
                            _hinhanh = CreatImg(context, fWmv, imgten + Path.GetExtension(context.Request.Files[0].FileName));
                            System.IO.File.Delete(context.Server.MapPath("~/lib/up/v/") + fWmv);
                        }
                        else
                        {
                            fWmv = FLV_encode(context, imgten + Path.GetExtension(context.Request.Files[0].FileName), "320", "240", "64", "44100");

                            fWmv     = context.Request.Files[0].FileName;
                            _hinhanh = CreatImg(context, imgten + Path.GetExtension(context.Request.Files[0].FileName), imgten + Path.GetExtension(context.Request.Files[0].FileName));
                        }
                        rendertext(_hinhanh + ";" + imgten + Path.GetExtension(context.Request.Files[0].FileName));
                    }
                }

                break;

            case "DelOldFlash":
                System.IO.File.Delete(context.Server.MapPath("~/lib/up/v/") + Path.GetExtension(context.Request.Files[0].FileName));
                System.IO.File.Delete(context.Server.MapPath("~/lib/up/i/") + Path.GetExtension(context.Request.Files[0].FileName));
                break;

            case "MultiuploadImg":
                #region UploadAnh
                if (context.Request.Files[0] != null)
                {
                    ImageProcess img        = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    string       foldername = Guid.NewGuid().ToString().Replace("-", "");
                    string       imgten     = Guid.NewGuid().ToString();
                    Directory.CreateDirectory(imgSaveSanPham + foldername);

                    context.Request.Files[0].SaveAs(imgSaveSanPham + foldername + "/" + imgten + "full" + img.Ext);
                    img.Crop(400, 400);

                    img.Save(imgSaveSanPham + foldername + "/" + imgten + "400x400" + img.Ext);
                    img.Crop(75, 75);

                    img.Save(imgSaveSanPham + foldername + "/" + imgten + img.Ext);
                    Files item = new Files();
                    item.Download = 0;
                    item.MimeType = img.Ext;
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.Username;
                    item.Path     = imgten + img.Ext;
                    item.PID      = new Guid(_PRowIdSP);
                    item.RowId    = Guid.NewGuid();
                    item.Size     = context.Request.Files[0].ContentLength;
                    item.Ten      = imgten;
                    item.ThuMuc   = foldername;
                    item.VB_ID    = 0;
                    item          = FilesDal.Insert(item);
                    rendertext(sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(item)));
                }
                break;

                #endregion
            case "loadPlugDirect":
                if (!string.IsNullOrEmpty(rqPlug))
                {
                    string _IPlugType = rqPlug;
                    Type   type       = Type.GetType(_IPlugType);
                    IPlug  _IPlug     = (IPlug)(Activator.CreateInstance(type));
                    _IPlug.ImportPlugin();
                    UserControl uc   = (UserControl)(_IPlug);
                    Page        page = new Page();
                    page.EnableViewState = false;
                    HtmlForm form = new HtmlForm();
                    form.ID = "__t";
                    page.Controls.Add(form);
                    form.Controls.Add(uc);
                    StringWriter tw = new StringWriter();
                    HttpContext.Current.Server.Execute(page, tw, true);
                }
                break;

            case "capcha":
                #region capcha
                string _capchaCode = CaptchaImage.GenerateRandomCode(CaptchaType.AlphaNumeric, 3);
                context.Session["capcha"] = _capchaCode;
                CaptchaImage c = new CaptchaImage(_capchaCode, 200, 50, "Tahoma", Color.White, Color.Orange);
                context.Response.ClearContent();
                context.Response.ContentType = "image/jpeg";
                MemoryStream ms = new MemoryStream();
                c.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                context.Response.OutputStream.Write(ms.ToArray(), 0, Convert.ToInt32(ms.Length));
                ms.Close();
                context.Response.End();
                break;

                #endregion
            default:
                #region macdinh
                context.Response.Write(DateTime.Now.ToString("hh:mm"));
                break;
                #endregion
            }
        }
Exemple #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            Session["CaptchaImageText"] = CaptchaImage.GenerateRandomCode(random);
        }

        if (!User.Identity.IsAuthenticated)
        {
            anonymousbox.Visible  = true;
            anonymousbox2.Visible = true;
            cbxThumbsUp.Visible   = false;
        }
        else
        {
            anonymousbox.Visible  = false;
            anonymousbox2.Visible = false;
        }

        int iPageNumber = 0;

        if (Request.QueryString["p"] != null)
        {
            iPageNumber = Convert.ToInt32(Request.QueryString["p"]);
        }

        int iBlogID = 0;

        if (Request.QueryString["bid"] == null)
        {
            Response.Redirect("Blogs.aspx", true);
        }
        else
        {
            iBlogID = Convert.ToInt32(Request.QueryString["bid"]);
        }

        DataLayer dl        = new DataLayer();
        int       iMaxPages = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(dl.GetBlogCommentCount(iBlogID)) / 15m));

        pageNav1.NumPages = iMaxPages;
        pageNav2.NumPages = iMaxPages;
        DataTable dtBlog = dl.GetBlogBy_BlogID(iBlogID);

        if (dtBlog.Rows.Count == 0)
        {
            this.Title          = "No Blog Found";
            blogtitle.InnerText = "No Blog Found";
            addcomment.Visible  = false;
        }
        else
        {
            if (dtBlog.Rows[0].ItemArray[5].ToString() == "Members Only")
            {
                if (!User.Identity.IsAuthenticated)
                {
                    Session["resultColor"]     = "#ff0000";
                    Session["resultTitle"]     = "Members Only";
                    Session["resultMessage"]   = "This is a members only blog.<br />You must log in first.";
                    Session["resultReturnURL"] = "Blogs.aspx";
                    Response.Redirect("Result.aspx", true);
                }
            }

            DataTable dtComments = dl.GetFifteenBlogCommentsBy_Page(iPageNumber, iBlogID);

            if (User.Identity.IsAuthenticated)
            {
                if (dl.GaveBlogThumbsUpAlready(iBlogID, User.Identity.Name) || (User.Identity.Name.ToLower() == dtBlog.Rows[0].ItemArray[1].ToString().ToLower()))
                {
                    cbxThumbsUp.Visible = false;
                }
                else
                {
                    cbxThumbsUp.Visible = true;
                }
            }

            this.Title            = dtBlog.Rows[0].ItemArray[3].ToString();
            blogtitle.InnerText   = dtBlog.Rows[0].ItemArray[3].ToString();
            postedby.InnerHtml    = "Posted by <a href=\"Profile.aspx?member=" + dtBlog.Rows[0].ItemArray[1].ToString() + "\">" + dl.GetFullMemberNameBy_Email(dtBlog.Rows[0].ItemArray[1].ToString()) + "</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;" + Convert.ToDateTime(dtBlog.Rows[0].ItemArray[2]).ToString("D") + "&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;" + dl.GetBlogCommentCount(Convert.ToInt32(dtBlog.Rows[0].ItemArray[0])) + " Comment(s)&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<!-- AddThis Button BEGIN --><script type=\"text/javascript\">var addthis_pub=\"chevex\"; var addthis_hide_embed = true;</script><a href=\"http://www.addthis.com/bookmark.php?v=20\" onmouseover=\"return addthis_open(this, '', '[URL]', '[TITLE]')\" onmouseout=\"addthis_close()\" onclick=\"return addthis_sendto()\"><img src=\"http://s7.addthis.com/static/btn/sm-share-en.gif\" width=\"83\" height=\"16\" alt=\"Bookmark and Share\" style=\"border:0;\"/></a><script type=\"text/javascript\" src=\"http://s7.addthis.com/js/200/addthis_widget.js\"></script><!-- AddThis Button END -->";
            blogcontent.InnerHtml = dtBlog.Rows[0].ItemArray[4].ToString().Replace("~", "") + "<br /><br /><b>" + dl.GetBlogThumbsUpCount(iBlogID).ToString() + " Thumbs Up!</b>";

            bool bColored = true;
            foreach (DataRow dr in dtComments.Rows)
            {
                string sEmail     = "";
                string sLink      = "";
                string sAvatar    = "";
                string sName      = "";
                string sSignature = "";

                if (dr.ItemArray[1].ToString().StartsWith("ANON"))
                {
                    string[] sSplit = dr.ItemArray[1].ToString().Split('|');
                    sLink   = sSplit[2];
                    sAvatar = "images/MemberAvatars/no_avatar.gif";
                    sName   = sSplit[1];
                }
                else
                {
                    DataTable dtMember = dl.GetMemberBy_Email(dr.ItemArray[1].ToString());

                    sEmail     = dtMember.Rows[0].ItemArray[0].ToString();
                    sLink      = "Profile.aspx?member=" + sEmail;
                    sAvatar    = "images/MemberAvatars/" + dtMember.Rows[0].ItemArray[3].ToString();
                    sName      = dtMember.Rows[0].ItemArray[2].ToString();
                    sSignature = dtMember.Rows[0].ItemArray[18].ToString();
                }

                comments.Controls.Add(new LiteralControl("<div style=\""));
                if (bColored)
                {
                    comments.Controls.Add(new LiteralControl("background-color:#CCDDCC"));
                    bColored = false;
                }
                else
                {
                    comments.Controls.Add(new LiteralControl("background-color:#FFFFFF"));
                    bColored = true;
                }
                comments.Controls.Add(new LiteralControl(";padding:10px;\"><table style=\"width:100%;\"><tr><td rowspan=\"2\" style=\"vertical-align:top;text-align:center;font-size:17px;font-weight:bold;padding-right:15px;border-right:solid 2px #333333;width:150px;\">"));
                if (sLink != "")
                {
                    comments.Controls.Add(new LiteralControl("<a style=\"text-decoration:none;\" href=\"" + sLink + "\">"));
                }
                comments.Controls.Add(new LiteralControl("<img style=\"border-width:0px;\" src=\"MakeThumbnail.aspx?size=150&image=" + sAvatar + "\" />"));
                if (sLink != "")
                {
                    comments.Controls.Add(new LiteralControl("</a>"));
                }
                comments.Controls.Add(new LiteralControl("<br /><br />"));
                if (sLink != "")
                {
                    comments.Controls.Add(new LiteralControl("<a href=\"" + sLink + "\">"));
                }
                comments.Controls.Add(new LiteralControl(sName));
                if (sLink != "")
                {
                    comments.Controls.Add(new LiteralControl("</a>"));
                }
                if (dr.ItemArray[1].ToString().StartsWith("ANON"))
                {
                    comments.Controls.Add(new LiteralControl("<br />(guest)"));
                }
                comments.Controls.Add(new LiteralControl("</td><td style=\"text-align:left;vertical-align:top;padding-left:15px;\">" + dr.ItemArray[3].ToString().Replace("\r", "<br />").Replace("\n", "") + "<br /><br />----------------------------------<br />" + sSignature + "</td></tr><tr><td style=\"vertical-align:bottom;padding-left:15px;padding-top:15px;\"><table cellpadding=\"0\" cellspacing=\"0\" style=\"width:100%;\"><tr><td style=\"text-align:left;vertical-align:bottom;font-size:12px;font-weight:bold;\">" + dr.ItemArray[2].ToString()));
                if (Convert.ToBoolean(dr.ItemArray[5]))
                {
                    comments.Controls.Add(new LiteralControl("&nbsp&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<img style=\"width:25px;\" src=\"images/ThumbsUp.png\" />"));
                }
                comments.Controls.Add(new LiteralControl("</td><td style=\"text-align:right;vertical-align:bottom;\">"));
                if (User.Identity.IsAuthenticated)
                {
                    if ((User.Identity.Name.ToLower() == dr.ItemArray[1].ToString().ToLower()) || (dl.IsMemberAdmin(User.Identity.Name)) || (dl.IsMemberModerator(User.Identity.Name)))
                    {
                        lbDelete                  = new LinkButton();
                        lbDelete.Text             = "Delete Comment";
                        lbDelete.ID               = dr.ItemArray[0].ToString();
                        lbDelete.Click           += new EventHandler(lbDelete_Click);
                        lbDelete.CausesValidation = false;
                        comments.Controls.Add(lbDelete);
                    }
                }
                comments.Controls.Add(new LiteralControl("</td></tr></table></td></tr></table></div>"));
            }
        }

        if (User.Identity.IsAuthenticated)
        {
            loggedinpanels.Controls.Add(new LiteralControl("<div style=\"width:250px;\" class=\"contenttitle\">Featured Member</div><div class=\"contentpanel\">"));
            DataTable dtRandomMember = dl.GetRandomMember();
            loggedinpanels.Controls.Add(new LiteralControl("<table style=\"width:100%;\"><tr><td style=\"font-size:13px;text-align:center;\"><a href=\"Profile.aspx?member=" + dtRandomMember.Rows[0].ItemArray[0].ToString() + "\"><img style=\"border-width:0px;\" src=\"MakeThumbnail.aspx?size=100&image=images/MemberAvatars/" + dtRandomMember.Rows[0].ItemArray[3].ToString() + "\" /></a><br /><a href=\"Profile.aspx?member=" + dtRandomMember.Rows[0].ItemArray[0].ToString() + "\">View Profile</a></td><td style=\"padding-left:5px;font-size:13px;width:100%;\"><b>Name:</b> " + dtRandomMember.Rows[0].ItemArray[2].ToString() + "<br /><br /><b>Location:</b> " + dtRandomMember.Rows[0].ItemArray[17].ToString() + "<br /><br /><b>Business:</b> " + dtRandomMember.Rows[0].ItemArray[8].ToString() + "<br /><br />"));
            if (dtRandomMember.Rows[0].ItemArray[6].ToString() != "")
            {
                loggedinpanels.Controls.Add(new LiteralControl("<center><a href=\"" + dtRandomMember.Rows[0].ItemArray[6].ToString() + "\">Visit Website</a></center>"));
            }
            loggedinpanels.Controls.Add(new LiteralControl("</td></tr></table></div>"));
        }

        DataTable dtMemberAd = dl.GetRandomAd();

        loggedinpanels.Controls.Add(new LiteralControl("<div class=\"contenttitle\">Member Ad</div><div style=\"text-align:center;\" class=\"contentpanel\"><a href=\"" + dtMemberAd.Rows[0].ItemArray[2].ToString() + "\"><img style=\"width:230px; border-width:0px;\" src=\"" + dtMemberAd.Rows[0].ItemArray[1].ToString() + "\" /></a></div>"));

        if (User.Identity.IsAuthenticated)
        {
            loggedinpanels.Controls.Add(new LiteralControl("<div style=\"width:250px;\" class=\"contenttitle\">Popular Topics</div><div style=\"font-size:15px;\" class=\"contentpanel\"><ul>"));
            DataTable dtTopics = dl.GetFiveTopics();
            foreach (DataRow dr in dtTopics.Rows)
            {
                loggedinpanels.Controls.Add(new LiteralControl("<li><a href=\"Topic.aspx?topic=" + dr.ItemArray[0].ToString() + "\">" + dr.ItemArray[4].ToString() + "</a></li>"));
            }
            loggedinpanels.Controls.Add(new LiteralControl("</ul></div>"));
        }
    }