protected override void OnLoad(EventArgs e)
 {
     this._Site = new Sites()[1L];
     if (this._Site == null)
     {
         PF.GoError(1, "域名无效,限制访问", base.GetType().FullName);
     }
     else
     {
         this._User = Users.GetCurrentUser(this._Site.ID);
         if (this.isRequestLogin && (this._User == null))
         {
             PF.GoLogin(this.RequestLoginPage, this.isAtFramePageLogin);
         }
         else if ((this.isRequestLogin && (this.RequestCompetences != "")) && !this._User.Competences.IsOwnedCompetences(this.RequestCompetences))
         {
             PF.GoError(3, "对不起,您没有足够的权限访问此页面", base.GetType().FullName);
         }
         else
         {
             this.PageUrl = base.Request.Url.AbsoluteUri;
             base.OnLoad(e);
         }
     }
 }
Beispiel #2
0
    protected override void OnLoad(EventArgs e)
    {
        #region 获取站点

        _Site = new Sites()[1];

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

            return;
        }

        #endregion

        #region 获取用户

        Users users = Users.GetCurrentUser(1);

        if (users == null)
        {
            PF.GoLogin(RequestLoginPage, false);

            return;
        }

        if (_User == null)
        {
            _User = Session["CpsAdminPageBase_Users"] as Users;
        }

        if (_User == null)
        {
            PF.GoLogin(RequestLoginPage, false);

            return;
        }

        #endregion

        #region 判断权限

        if (!users.Competences.IsOwnedCompetences(RequestCompetences))
        {
            PF.GoError(ErrorNumber.NotEnoughCompetence, "对不起,您没有足够的权限访问此页面", this.GetType().FullName);

            return;
        }

        #endregion

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

        PageUrl = this.Request.Url.AbsoluteUri;

        base.OnLoad(e);
    }
Beispiel #3
0
    protected override void OnLoad(EventArgs e)
    {
        #region 获取站点

        //_Site = new Sites()[Shove._Web.Utility.GetUrlWithoutHttp()];
        _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, isAtFramePageLogin);

            return;
        }

        #endregion

        #region 判断权限

        if (isRequestLogin && (RequestCompetences != "") && (!_User.Competences.IsOwnedCompetences(RequestCompetences)))
        {
            PF.GoError(ErrorNumber.NotEnoughCompetence, "对不起,您没有足够的权限访问此页面", this.GetType().FullName);

            return;
        }

        #endregion

        PageUrl = this.Request.Url.AbsoluteUri;

        base.OnLoad(e);
    }
    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, "域名无效,限制访问", base.GetType().FullName);
        }
        else
        {
            this._User = Users.GetCurrentUser(this._Site.ID);
            if (this.isRequestLogin && (this._User == null))
            {
                PF.GoLogin(this.RequestLoginPage);
            }
            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
                        {
                        }
                    }
                }
                string fullName = base.GetType().FullName;
                try
                {
                    fullName = fullName.Substring(4, fullName.Length - 9);
                }
                catch
                {
                }
                int appSettingsInt = WebConfig.GetAppSettingsInt(fullName, -1);
                if (appSettingsInt > 0)
                {
                    base.Response.Cache.SetExpires(DateTime.Now.AddSeconds((double)appSettingsInt));
                    base.Response.Cache.SetCacheability(HttpCacheability.Server);
                    base.Response.Cache.VaryByParams["*"] = true;
                    base.Response.Cache.SetValidUntilExpires(true);
                    base.Response.Cache.SetVaryByCustom("SitePage");
                }
                base.OnLoad(e);
            }
        }
    }
Beispiel #5
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 缓存

        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

        base.OnLoad(e);
    }
Beispiel #6
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);
    }