private void BindData()
 {
     string key = "FloatNotifyContent";
     DataTable cacheAsDataTable = Shove._Web.Cache.GetCacheAsDataTable(key);
     if (cacheAsDataTable == null)
     {
         cacheAsDataTable = new Tables.T_FloatNotify().Open("", "", "[Order] asc,[DateTime] desc");
         if ((cacheAsDataTable != null) && (cacheAsDataTable.Rows.Count > 0))
         {
             Shove._Web.Cache.SetCache(key, cacheAsDataTable, 0xea60);
         }
     }
     this.g.DataSource = cacheAsDataTable;
     this.g.DataBind();
 }
Ejemplo n.º 2
0
    protected override void OnLoad(EventArgs e)
    {
        if (!base.IsPostBack)
        {
            new FirstUrl().Save();
        }
        this.PageUrl = base.Request.Url.AbsoluteUri;
        this._Site = new Sites()[1L];
        if (this._Site == null)
        {
            PF.GoError(1, "域名无效,限制访问", "SitePageBase");
        }
        else
        {
            this._User = Users.GetCurrentUser(this._Site.ID);
            if (this.isRequestLogin && (this._User == null))
            {
                PF.GoLogin(this.RequestLoginPage, this.isAtFramePageLogin);
            }
            else
            {
                try
                {
                    PlaceHolder holder = this.Page.FindControl("phHead") as PlaceHolder;
                    if (holder != null)
                    {
                        UserControl child = this.Page.LoadControl("~/Home/Room/UserControls/WebHead.ascx") as UserControl;
                        holder.Controls.Add(child);
                    }
                    PlaceHolder holder2 = this.Page.FindControl("phFoot") as PlaceHolder;
                    if (holder2 != null)
                    {
                        UserControl control2 = this.Page.LoadControl("~/Home/Room/UserControls/WebFoot.ascx") as UserControl;
                        holder2.Controls.Add(control2);
                    }
                }
                catch
                {
                }
                string str = ((base.Request.Url.Query == "") ? base.Request.Url.AbsoluteUri : base.Request.Url.AbsoluteUri.Replace(base.Request.Url.Query, "")).Replace(Utility.GetUrl(), "").Replace("/", "_").Replace(".aspx", "");
                if (str.StartsWith("_"))
                {
                    str = str.Remove(0, 1);
                }
                if (FloatNotifyPageList.IndexOf("," + str + ",") > -1)
                {
                    StringBuilder builder = new StringBuilder();
                    string key = "FloatNotifyContent";
                    DataTable cacheAsDataTable = Shove._Web.Cache.GetCacheAsDataTable(key);
                    if (cacheAsDataTable == null)
                    {
                        cacheAsDataTable = new Tables.T_FloatNotify().Open("", "", "[Order] asc,[DateTime] desc");
                        if ((cacheAsDataTable != null) && (cacheAsDataTable.Rows.Count > 0))
                        {
                            Shove._Web.Cache.SetCache(key, cacheAsDataTable, 0xea60);
                        }
                    }
                    bool flag = false;
                    int num = this._Site.SiteOptions["Opt_FloatNotifiesTime"].ToInt(3);
                    string name = "LastLoginShowFloatNotifyUserID";
                    switch (num)
                    {
                        case 1:
                            {
                                HttpCookie cookie = base.Request.Cookies[name];
                                if ((cookie != null) && !string.IsNullOrEmpty(cookie.Value))
                                {
                                    flag = true;
                                }
                                break;
                            }
                        case 2:
                            flag = DateTime.Now.Minute == 0;
                            break;

                        case 3:
                            flag = true;
                            break;
                    }
                    if (((cacheAsDataTable != null) && (cacheAsDataTable.Rows.Count > 0)) && flag)
                    {
                        DataRow[] rowArray = cacheAsDataTable.Select("isShow=1");
                        for (int i = 0; i < rowArray.Length; i++)
                        {
                            if (i == 2)
                            {
                                break;
                            }
                            int num4 = i + 1;
                            builder.Append("<font color='" + rowArray[i]["Color"].ToString() + "'>").Append(num4.ToString()).Append(".</font>").Append("<a href='").Append(rowArray[i]["Url"].ToString()).Append("' target='_blank' style='text-decoration: none;color:").Append(rowArray[i]["Color"].ToString()).Append(";' onmouseover=\"this.style.color='#ff6600';\" onmouseout=\"this.style.color='").Append(rowArray[i]["Color"].ToString()).Append("';\">").Append(rowArray[i]["Title"].ToString()).Append("</a><br />");
                        }
                        string html = HmtlManage.GetHtml(AppDomain.CurrentDomain.BaseDirectory + "Home/Web/Template/FloatNotify.html");
                        Label label = new Label();
                        int num5 = FloatNotifyTimeOut * 100;
                        label.Text = html.Replace("$FloatNotifyTimeOut$", num5.ToString()).Replace("$FloatNotifyContent$", builder.ToString());
                        try
                        {
                            base.Form.Controls.AddAt(0, label);
                        }
                        catch (Exception exception)
                        {
                            new Log("Page").Write(str + exception.Message);
                        }
                        HttpCookie cookie2 = new HttpCookie(name)
                        {
                            Value = "",
                            Expires = DateTime.Now.AddYears(-20)
                        };
                        try
                        {
                            HttpContext.Current.Response.Cookies.Add(cookie2);
                        }
                        catch
                        {
                        }
                    }
                }
                if (this.isAllowPageCache && (this.PageCacheSeconds > 0))
                {
                    base.Response.Cache.SetExpires(DateTime.Now.AddSeconds((double)this.PageCacheSeconds));
                    base.Response.Cache.SetCacheability(HttpCacheability.Server);
                    base.Response.Cache.VaryByParams["*"] = true;
                    base.Response.Cache.SetValidUntilExpires(true);
                    base.Response.Cache.SetVaryByCustom("SitePage");
                }
                base.OnLoad(e);
            }
        }
    }
Ejemplo n.º 3
0
    protected override void OnLoad(EventArgs e)
    {
        if (!this.IsPostBack)
        {
            //为 CPS 商家保存第一次访问的二级域名
            new FirstUrl().Save();
        }
        
        PageUrl = this.Request.Url.AbsoluteUri;

        #region 获取站点

        _Site = new Sites()[1];

        if (_Site == null)
        {
            PF.GoError(ErrorNumber.Unknow, "域名无效,限制访问", this.GetType().FullName);

            return;
        }

        #endregion

        #region 获取用户

        _User = Users.GetCurrentUser(_Site.ID);

        if (isRequestLogin && (_User == null))
        {
            PF.GoLogin(RequestLoginPage);

            return;
        }

        #endregion

        #region 加载头部和底部
        try
        {
            PlaceHolder phHead = Page.FindControl("phHead") as PlaceHolder;

            if (phHead != null)
            {
                UserControl Head = Page.LoadControl("~/Home/Room/UserControls/WebHead.ascx") as UserControl;
                Head.ID = "WebHead1";
                phHead.Controls.Add(Head);
            }


            PlaceHolder phFoot = Page.FindControl("phFoot") as PlaceHolder;

            if (phFoot != null)
            {
                UserControl Foot = Page.LoadControl("~/Home/Room/UserControls/WebFoot.ascx") as UserControl;
                phFoot.Controls.Add(Foot);
            }
        }
        catch { }

        #endregion

        #region 弹出广告

        string ClassName = (this.Request.Url.Query == "" ? this.Request.Url.AbsoluteUri : this.Request.Url.AbsoluteUri.Replace(this.Request.Url.Query, "")).Replace(Shove._Web.Utility.GetUrl(), "").Replace("/", "_").Replace(".aspx", "");

        if (ClassName.StartsWith("_"))
        {
            ClassName = ClassName.Remove(0, 1);
        }

        if (FloatNotifyPageList.IndexOf("," + ClassName + ",") > -1)
        {
            StringBuilder sb = new StringBuilder();

            string CacheKey = "FloatNotifyContent";
            DataTable dt = Shove._Web.Cache.GetCacheAsDataTable(CacheKey);

            if (dt == null)
            {
                dt = new DAL.Tables.T_FloatNotify().Open("", "", "[Order] asc,[DateTime] desc");

                if (dt != null && dt.Rows.Count > 0)
                {
                    Shove._Web.Cache.SetCache(CacheKey, dt, 60000);
                }
            }

            bool IsShow = false;
            int FloatNotifiesType = _Site.SiteOptions["Opt_FloatNotifiesTime"].ToInt(3);
            string LastLoginFloatNotifyKey = "LastLoginShowFloatNotifyUserID";

            switch (FloatNotifiesType)
            {
                case 1:
                    {
                        HttpCookie cookieLastLoginFloatNotify = Request.Cookies[LastLoginFloatNotifyKey];

                        if (cookieLastLoginFloatNotify != null && !String.IsNullOrEmpty(cookieLastLoginFloatNotify.Value))
                        {
                            IsShow = true;
                        }
                    } break;
                case 2:
                    {
                        IsShow = (DateTime.Now.Minute == 0);
                    } break;
                case 3:
                    {
                        IsShow = true;
                    } break;
            }

            if (dt != null && dt.Rows.Count > 0 && IsShow)
            {
                DataRow[] drs = dt.Select("isShow=1");

                for (int i = 0; i < drs.Length; i++)
                {
                    if (i == 2)
                    {
                        break;
                    }

                    sb.Append("<font color='" + drs[i]["Color"].ToString() + "'>").Append((i + 1).ToString()).Append(".</font>").Append("<a href='").Append(drs[i]["Url"].ToString()).Append("' target='_blank' style='text-decoration: none;color:").Append(drs[i]["Color"].ToString()).Append(";' onmouseover=\"this.style.color='#ff6600';\" onmouseout=\"this.style.color='").Append(drs[i]["Color"].ToString()).Append("';\">").Append(drs[i]["Title"].ToString()).Append("</a><br />");
                }

                string FloatNotify = HmtlManage.GetHtml(AppDomain.CurrentDomain.BaseDirectory + "Home/Web/Template/FloatNotify.html");

                Label label = new Label();

                label.Text = FloatNotify.Replace("$FloatNotifyTimeOut$", (FloatNotifyTimeOut * 100).ToString()).Replace("$FloatNotifyContent$", sb.ToString());

                try
                {
                    this.Form.Controls.AddAt(0, label);
                }
                catch (Exception ex)
                {
                    new Log("Page").Write(ClassName + ex.Message);
                }

                // 从 Cookie 中移除 浮出广告的UserID
                HttpCookie cookieLastLoginFloatNotify = new HttpCookie(LastLoginFloatNotifyKey);
                cookieLastLoginFloatNotify.Value = "";
                cookieLastLoginFloatNotify.Expires = DateTime.Now.AddYears(-20);

                try
                {
                    HttpContext.Current.Response.Cookies.Add(cookieLastLoginFloatNotify);
                }
                catch { }
            }
        }

        #endregion

        #region 缓存

        string PageName = this.GetType().FullName;

        try
        {
            PageName = PageName.Substring(4, PageName.Length - 9);
        }
        catch { }

        int SitePageCacheSeconds = Shove._Web.WebConfig.GetAppSettingsInt(PageName, -1);

        if (SitePageCacheSeconds > 0)
        {
            this.Response.Cache.SetExpires(DateTime.Now.AddSeconds(SitePageCacheSeconds));
            this.Response.Cache.SetCacheability(HttpCacheability.Server);
            this.Response.Cache.VaryByParams["*"] = true;
            this.Response.Cache.SetValidUntilExpires(true);
            this.Response.Cache.SetVaryByCustom("SitePage");
        }

        #endregion

        //HtmlMeta hm = new HtmlMeta();
        //hm.HttpEquiv = "X-UA-Compatible";
        //hm.Content = "IE=EmulateIE7";

        //Page.Header.Controls.Add(hm);

        base.OnLoad(e);
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string Title = tbName.Text.Trim();

        if (Title == "")
        {
            Shove._Web.JavaScript.Alert(this.Page, "请输入广告标题!");

            return;
        }

        string Url = tbUrl.Text.Trim();

        Regex regex = new Regex(@"([\w-]+\.)+[\w-]+.([^a-z])(/[\w- ./?%&=]*)?|[a-zA-Z0-9\-\.][\w-]+.([^a-z])(/[\w- ./?%&=]*)?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
        Match m = regex.Match(Url);

        if (!m.Success)
        {
            Shove._Web.JavaScript.Alert(this, "输入的URL地址格式错误,请仔细检查。");

            return;
        }

        int order = Shove._Convert.StrToInt(tbOrder.Text.Trim(), -1);

        if (order < 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, "顺序输入非法!");

            return;
        }

        DAL.Tables.T_FloatNotify fn = new DAL.Tables.T_FloatNotify();

        string color = Shove._Web.Utility.GetRequest("highlight_color");

        if (color == "")
        {
            color = "#000000";
        }

        fn.Order.Value = order;
        fn.Url.Value = Url;
        fn.Title.Value = Title;
        fn.Color.Value = color;

        long Result = fn.Insert();

        if (Result > 0)
        {
            //清除缓存
            string CacheKey = "FloatNotifyContent";
            Shove._Web.Cache.ClearCache(CacheKey);

            Shove._Web.JavaScript.Alert(this, "添加成功", "FloatNotifies.aspx");
        }
        else
        {
            Shove._Web.JavaScript.Alert(this, "添加失败");
        }
    }
    private void BindData()
    {
        HidID.Value = Shove._Web.Utility.GetRequest("ID");

        int id = Shove._Convert.StrToInt(HidID.Value, 0);

        if (id < 0)
        {
            PF.GoError(ErrorNumber.Unknow, "参数错误或数据被删除", this.Page.GetType().BaseType.FullName);

            return;
        }

        DataTable dt = new DAL.Tables.T_FloatNotify().Open("", "ID=" + id.ToString() + "", "");

        if (dt == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.Page.GetType().BaseType.FullName);

            return;
        }

        if (dt.Rows.Count == 0)
        {
            PF.GoError(ErrorNumber.Unknow, "参数错误或数据被删除", this.Page.GetType().BaseType.FullName);

            return;
        }

        DataRow dr = dt.Rows[0];

        tbName.Text = dr["Title"].ToString();
        tbUrl.Text = dr["Url"].ToString();
        tbOrder.Text = dr["Order"].ToString();
        cbisShow.Checked = Shove._Convert.StrToBool(dr["isShow"].ToString(), true);
        HidColor.Value = dr["Color"].ToString();
    }