Esempio n. 1
0
        /// <summary>
        /// 静态构造函数初始化相应实例和定时器
        /// </summary>
        static GeneralConfigs()
        {
            m_configinfo = GeneralConfigFileManager.LoadConfig();

            generalConfigTimer.AutoReset = true;
            generalConfigTimer.Enabled = true;
            generalConfigTimer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
            generalConfigTimer.Start();
        }
        /// <summary>
        /// 初始化文件修改时间和对象实例
        /// </summary>
        static GeneralConfigFileManager()
        {
            m_fileoldchange = System.IO.File.GetLastWriteTime(ConfigFilePath);

            try
            {
                m_configinfo = (GeneralConfigInfo)DefaultConfigFileManager.DeserializeInfo(ConfigFilePath, typeof(GeneralConfigInfo));
            }
            catch
            {
                if (File.Exists(ConfigFilePath))
                {
                    ReviseConfig();
                    m_configinfo = (GeneralConfigInfo)DefaultConfigFileManager.DeserializeInfo(ConfigFilePath, typeof(GeneralConfigInfo));
                }
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            config = GeneralConfigs.GetConfig();

            // 如果IP访问列表有设置则进行判断
            if (config.Adminipaccess.Trim() != "")
            {
                string[] regctrl = Utils.SplitString(config.Adminipaccess, "\n");
                if (!Utils.InIPArray(SASRequest.GetIP(), regctrl))
                {
                    Context.Response.Redirect(BaseConfigs.GetSitePath + "ManagePage/syslogin.aspx");
                    return;
                }
            }

            //获取当前用户的在线信息
            OnlineUserInfo oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
            olid = oluserinfo.Ol_id;

            #region 进行权限判断

            UserGroupInfo usergroupinfo = AdminUserGroups.AdminGetUserGroupInfo(oluserinfo.Ol_ug_id);
            if (oluserinfo.Ol_ps_id <= 0 || usergroupinfo.ug_pg_id != 1)
            {
                Context.Response.Redirect(BaseConfigs.GetSitePath + "ManagePage/syslogin.aspx");
                return;
            }

            string secques = Users.GetUserInfo(oluserinfo.Ol_ps_id).Ps_secques;
            // 管理员身份验证
            if (Context.Request.Cookies["sasadmin"] == null || Context.Request.Cookies["sasadmin"]["key"] == null || LogicUtils.GetCookiePassword(Context.Request.Cookies["sasadmin"]["key"].ToString(), config.Passwordkey) != (oluserinfo.Ol_password + secques + oluserinfo.Ol_ps_id))
            {
                Context.Response.Redirect(BaseConfigs.GetSitePath + "ManagePage/syslogin.aspx");
                return;
            }
            else
            {
                HttpCookie cookie = HttpContext.Current.Request.Cookies["sasadmin"];
                cookie.Values["key"] = LogicUtils.SetCookiePassword(oluserinfo.Ol_password + secques + oluserinfo.Ol_ps_id.ToString(), config.Passwordkey);
                cookie.Expires = DateTime.Now.AddMinutes(30);
                HttpContext.Current.Response.AppendCookie(cookie);
            }

            #endregion
        }
Esempio n. 4
0
 /// <summary>
 /// 序列化配置信息为XML
 /// </summary>
 /// <param name="configinfo">配置信息</param>
 /// <param name="configFilePath">配置文件完整路径</param>
 public static GeneralConfigInfo Serialiaze(GeneralConfigInfo configinfo, string configFilePath)
 {
     lock (lockHelper)
     {
         SerializationHelper.Save(configinfo, configFilePath);
     }
     return configinfo;
 }
Esempio n. 5
0
 /// <summary>
 /// 重设配置类实例
 /// </summary>
 public static void ResetConfig()
 {
     m_configinfo = GeneralConfigFileManager.LoadConfig();
 }
Esempio n. 6
0
        /// <summary>
        /// BasePage类构造函数
        /// </summary>
        public TaoBaoPage()
        {
            config = GeneralConfigs.GetConfig();
            taobaoconfig = TaoBaoConfigs.GetConfig();
            if (TaoBaoPluginProvider.GetInstance() != null)
            {
                tpb = TaoBaoPluginProvider.GetInstance();
            }
            //if (MallPluginProvider.GetInstance() == null)
            //    config.Enablemall = 0;
            userid = Utils.StrToInt(LogicUtils.GetCookie("userid"), -1);

            // 如果启用游客页面缓存,则对游客输出缓存页
            if (userid == -1 && config.Guestcachepagetimeout > 0 && GetUserCachePage(pagename))
                return;

            if (config.Nocacheheaders == 1)
            {
                System.Web.HttpContext.Current.Response.BufferOutput = false;
                System.Web.HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
                System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
                System.Web.HttpContext.Current.Response.Expires = 0;
                System.Web.HttpContext.Current.Response.CacheControl = "no-cache";
                System.Web.HttpContext.Current.Response.Cache.SetNoStore();
            }

            pmsound = Utils.StrToInt(LogicUtils.GetCookie("pmsound"), 0);

            mainnavigation = Navs.GetNavigationString(userid, useradminid);
            subnavigation = Navs.GetSubNavigation();
            mainnavigationhassub = Navs.GetMainNavigationHasSub();

            //校验用户是否可以访问站点
            if (!ValidateUserPermission())
                return;

            //更新用户在线时长
            if (userid != -1)
                OnlineUsers.UpdateOnlineTime(config.Oltimespan, userid);

            nowdate = Utils.GetDate();
            nowtime = Utils.GetTime();
            nowdatetime = Utils.GetDateTime();
            ispost = SASRequest.IsPost();
            isget = SASRequest.IsGet();
            link = "";
            script = "";

            isseccode = Utils.InArray(pagename, config.Seccodestatus);

            //校验验证码
            if (isseccode && ispost && !ValidateVerifyCode())
                return;

            //newtopicminute = config.Viewnewtopicminute;
            m_starttick = DateTime.Now;

            ShowPage();

            m_processtime = DateTime.Now.Subtract(m_starttick).TotalMilliseconds / 1000;
        }
Esempio n. 7
0
        /// <summary>
        /// BasePage类构造函数
        /// </summary>
        public BasePage()
        {
            config = GeneralConfigs.GetConfig();
            //if (SpacePluginProvider.GetInstance() == null)
            //    config.Enablespace = 0;
            if (AlbumPluginProvider.GetInstance() == null)
                config.Enablealbum = 0;
            //if (MallPluginProvider.GetInstance() == null)
            //    config.Enablemall = 0;
            LoadUrlConfig();
            userid = Utils.StrToInt(LogicUtils.GetCookie("userid"), -1);

            //清空当前页面查询统计
            #if DEBUG
            SAS.Data.DbHelper.QueryCount = 0;
            SAS.Data.DbHelper.QueryDetail = "";
            #endif

            // 如果启用游客页面缓存,则对游客输出缓存页
            if (userid == -1 && config.Guestcachepagetimeout > 0 && GetUserCachePage(pagename))
                return;
            AddMetaInfo(config.Seokeywords, config.Seodescription, config.Seohead);

            if (config.Nocacheheaders == 1)
            {
                System.Web.HttpContext.Current.Response.BufferOutput = false;
                System.Web.HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
                System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
                System.Web.HttpContext.Current.Response.Expires = 0;
                System.Web.HttpContext.Current.Response.CacheControl = "no-cache";
                System.Web.HttpContext.Current.Response.Cache.SetNoStore();
            }

            //当为forumlist.aspx或forumindex.aspx,可能出现在线并发问题,这时系统会延时2秒
            if ((pagename != "zshy.aspx") && (pagename != "index.aspx"))
                oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
            else
            {
                try
                {
                    oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                }
                catch
                {
                    System.Threading.Thread.Sleep(2000);
                    oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                }
            }

            userid = oluserinfo.Ol_ps_id;
            usergroupid = oluserinfo.Ol_ug_id;
            username = oluserinfo.Ol_name;
            password = oluserinfo.Ol_password;
            userkey = password.Length > 16 ? password.Substring(4, 8).Trim() : "";
            //lastposttime = oluserinfo.Lastposttime;
            lastpostpmtime = oluserinfo.Ol_lastpostpmtime;
            lastsearchtime = oluserinfo.Ol_lastsearchtime;
            olid = oluserinfo.Ol_id;

            //确保头像可以取到
            //if (userid > 0)
            //    useravatar = Avatars.GetAvatarUrl(userid.ToString(), AvatarSize.Small);

            if (Utils.InArray(SASRequest.GetString("selectedtemplateid"), Templates.GetValidTemplateIDList()))
                templateid = SASRequest.GetInt("selectedtemplateid", 0);
            else if (Utils.InArray(Utils.GetCookie(Utils.GetTemplateCookieName()), Templates.GetValidTemplateIDList()))
                templateid = Utils.StrToInt(Utils.GetCookie(Utils.GetTemplateCookieName()), config.Templateid);

            if (templateid == 0)
                templateid = config.Templateid;

            pmsound = Utils.StrToInt(LogicUtils.GetCookie("pmsound"), 0);

            usergroupinfo = UserGroups.GetUserGroupInfo(usergroupid);

            // 取得用户权限id,1管理员,2超版,3版主,0普通组,-1特殊组
            useradminid = usergroupinfo.ug_pg_id;

            mainnavigation = Navs.GetNavigationString(userid, useradminid);
            subnavigation = Navs.GetSubNavigation();
            mainnavigationhassub = Navs.GetMainNavigationHasSub();

            // 如果论坛关闭且当前用户请求页面不是登录页面且用户非管理员, 则跳转至论坛关闭信息页
            if (config.Closed == 1 && pagename != "login.aspx" && pagename != "logout.aspx" && pagename != "register.aspx" && useradminid != 1)
            {
                ShowMessage(1);
                return;
            }

            onlineusercount = (userid != -1) ? OnlineUsers.GetOnlineAllUserCount() : OnlineUsers.GetCacheOnlineAllUserCount();

            //校验用户是否可以访问站点
            if (!ValidateUserPermission())
                return;

            //更新用户在线时长
            if (userid != -1)
                OnlineUsers.UpdateOnlineTime(config.Oltimespan, userid);

            templatepath = Templates.GetTemplateItem(templateid).Directory;
            nowdate = Utils.GetDate();
            nowtime = Utils.GetTime();
            nowdatetime = Utils.GetDateTime();
            ispost = SASRequest.IsPost();
            isget = SASRequest.IsGet();
            link = "";
            script = "";

            templatelistboxoptions = Caches.GetTemplateListBoxOptionsCache();

            string originalTemplate = string.Format("<li><a href=\"###\" onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}'\">",
                                   "", BaseConfigs.GetSitePath, templateid);
            string newTemplate = string.Format("<li class=\"current\"><a href=\"###\" onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}'\">",
                                     BaseConfigs.GetSitePath, templateid);
            templatelistboxoptions = templatelistboxoptions.Replace(originalTemplate, newTemplate);

            isseccode = Utils.InArray(pagename, config.Seccodestatus);
            //headerad = Advertisements.GetOneHeaderAd("", 0);
            //footerad = Advertisements.GetOneFooterAd("", 0);

            //校验验证码
            if (isseccode && ispost && !ValidateVerifyCode())
                return;

            //newtopicminute = config.Viewnewtopicminute;
            m_starttick = DateTime.Now;

            Companies.GetCompanyCountSum(out allcount, out passcount, out todaycount, out waitcount);

            ShowPage();

            m_processtime = DateTime.Now.Subtract(m_starttick).TotalMilliseconds / 1000;

            querycount = SAS.Data.DbHelper.QueryCount;
            SAS.Data.DbHelper.QueryCount = 0;

            #if DEBUG
            querydetail = SAS.Data.DbHelper.QueryDetail;
            SAS.Data.DbHelper.QueryDetail = "";
            #endif
        }
Esempio n. 8
0
        public AdminPage()
        {
            if (!Page.IsPostBack)
            {
                this.RegisterAdminPageClientScriptBlock();
            }

            config = GeneralConfigs.GetConfig();
            taobaoconfig = TaoBaoConfigs.GetConfig();

            // 如果IP访问列表有设置则进行判断
            if (config.Adminipaccess.Trim() != "")
            {
                string[] regctrl = Utils.SplitString(config.Adminipaccess, "\n");
                if (!Utils.InIPArray(SASRequest.GetIP(), regctrl))
                {
                    Context.Response.Redirect(BaseConfigs.GetSitePath + "ManagePage/syslogin.aspx");
                    return;
                }
            }

            // 获取用户信息
            OnlineUserInfo oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
            UserGroupInfo usergroupinfo = AdminUserGroups.AdminGetUserGroupInfo(oluserinfo.Ol_ug_id);
            if (oluserinfo.Ol_ps_id <= 0 || usergroupinfo.ug_pg_id != 1)
            {
                Context.Response.Redirect(BaseConfigs.GetSitePath + "ManagePage/syslogin.aspx");
                return;
            }

            string secques = Users.GetUserInfo(oluserinfo.Ol_ps_id).Ps_secques;

            // 管理员身份验证
            if (Context.Request.Cookies["sasadmin"] == null || Context.Request.Cookies["sasadmin"]["key"] == null ||
                LogicUtils.GetCookiePassword(Context.Request.Cookies["sasadmin"]["key"].ToString(), config.Passwordkey) != (oluserinfo.Ol_password + secques + oluserinfo.Ol_ps_id.ToString()))
            {
                Context.Response.Redirect(BaseConfigs.GetSitePath + "ManagePage/syslogin.aspx");
                return;
            }
            else
            {
                HttpCookie cookie = HttpContext.Current.Request.Cookies["sasadmin"];
                cookie.Values["key"] = LogicUtils.SetCookiePassword(oluserinfo.Ol_password + secques + oluserinfo.Ol_ps_id.ToString(), config.Passwordkey);
                cookie.Values["userid"] = oluserinfo.Ol_ps_id.ToString();
                cookie.Expires = DateTime.Now.AddMinutes(90);
                HttpContext.Current.Response.AppendCookie(cookie);

            }

            this.userid = oluserinfo.Ol_ps_id;
            this.username = oluserinfo.Ol_name;
            this.usergroupid = oluserinfo.Ol_ug_id;
            this.useradminid = (short)usergroupinfo.ug_pg_id;
            this.grouptitle = usergroupinfo.ug_name;
            this.ip = SASRequest.GetIP();

            //当前窗口不在Index.aspx页面上的FRAME中,则重定向到该框架中
            //if (DNTRequest.GetPageName() != "runforumstatic.aspx")
            //{
            //    Context.Response.Write("<script>if(top.mainFrame==null) top.location.href='/admin/index.aspx?fromurl=" + Context.Request.RawUrl + "';</script>");
            //    Context.Response.End();
            //    return;
            //}
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UserName.Attributes.Remove("class");
            PassWord.Attributes.Remove("class");
            UserName.AddAttributes("style", "width:200px");
            PassWord.AddAttributes("style", "width:200px");

            config = GeneralConfigs.GetConfig();

            OnlineUserInfo oluserinfo = SAS.Logic.OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);

            olid = oluserinfo.Ol_id;

            if (!Page.IsPostBack)
            {
                #region 如果IP访问列表有设置则进行判断
                if (config.Adminipaccess.Trim() != "")
                {
                    string[] regctrl = Utils.SplitString(config.Adminipaccess, "\n");
                    if (!Utils.InIPArray(SASRequest.GetIP(), regctrl))
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.Append("<br /><br /><div style=\"width:100%\" align=\"center\"><div align=\"center\" style=\"width:600px; border:1px dotted #FF6600; background-color:#FFFCEC; margin:auto; padding:20px;\">");
                        sb.Append("<img src=\"images/hint.gif\" border=\"0\" alt=\"提示:\" align=\"absmiddle\" />&nbsp; 您的IP地址不在系统允许的范围之内</div></div>");
                        Response.Write(sb.ToString());
                        Response.End();
                        return;
                    }
                }
                #endregion

                #region 用户身份判断
                UserGroupInfo usergroupinfo = AdminUserGroups.AdminGetUserGroupInfo(oluserinfo.Ol_ug_id);
                if (oluserinfo.Ol_ps_id <= 0 || usergroupinfo.ug_pg_id != 1)
                {
                    string message = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
                    message += "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>无法确认您的身份</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
                    message += "<link href=\"styles/default.css\" type=\"text/css\" rel=\"stylesheet\"></head><script type=\"text/javascript\">if(top.location!=self.location){top.location.href = \"syslogin.aspx\";}</script><body><br /><br /><div style=\"width:100%\" align=\"center\">";
                    message += "<div align=\"center\" style=\"width:600px; border:1px dotted #FF6600; background-color:#FFFCEC; margin:auto; padding:20px;\"><img src=\"images/hint.gif\" border=\"0\" alt=\"提示:\" align=\"absmiddle\" width=\"11\" height=\"13\" /> &nbsp;";
                    message += "无法确认您的身份, 请<a href=\"../login.aspx\">登录</a></div></div></body></html>";
                    Response.Write(message);
                    Response.End();
                    return;
                }
                #endregion

                #region 显示相关页面登陆提交信息
                if (Context.Request.Cookies["sasadmin"] == null || Context.Request.Cookies["sasadmin"]["key"] == null ||
                    LogicUtils.GetCookiePassword(Context.Request.Cookies["sasadmin"]["key"].ToString(), config.Passwordkey) !=
                    (oluserinfo.Ol_password + SAS.Logic.Users.GetUserInfo(oluserinfo.Ol_ps_id).Ps_secques + oluserinfo.Ol_ps_id.ToString()))
                {
                    Msg.Text = "<p class=\"adlrt1 zi1\" style=\" float:right; letter-spacing:1px;\" align=\"absMiddle\"><span class=\"adlrt1tu adbg\"></span>请重新进行管理员登录</p>";
                }

                if (oluserinfo.Ol_ps_id > 0 && usergroupinfo.ug_pg_id == 1 && oluserinfo.Ol_name.Trim() != "")
                {
                    UserName.Text = oluserinfo.Ol_name;
                    UserName.AddAttributes("readonly", "true");
                    UserName.CssClass = "nofocus";
                    UserName.Attributes.Add("onfocus", "this.className='nofocus';");
                    UserName.Attributes.Add("onblur", "this.className='nofocus';");
                }

                if (SASRequest.GetString("result") == "1")
                {
                    Msg.Text = "<p class=\"adlrt1 zi1\" style=\" float:right; letter-spacing:1px;\" align=\"absMiddle\"><span class=\"adlrt1tu adbg\"></span>用户不存在或密码错误</p>";
                    return;
                }

                if (SASRequest.GetString("result") == "2")
                {
                    Msg.Text = "<p class=\"adlrt1 zi1\" style=\" float:right; letter-spacing:1px;\" align=\"absMiddle\"><span class=\"adlrt1tu adbg\"></span>用户不是管理员身分,因此无法登陆后台</p>";
                    return;
                }

                if (SASRequest.GetString("result") == "3")
                {
                    Msg.Text = "<p class=\"adlrt1 zi1\" style=\" float:right; letter-spacing:1px;\" align=\"absMiddle\"><span class=\"adlrt1tu adbg\"></span>验证码错误,请重新输入</p>";
                    return;
                }

                if (SASRequest.GetString("result") == "4")
                {
                    Msg.Text = "";
                    return;
                }
                #endregion
            }

            if (Page.IsPostBack)
                VerifyLoginInf();//对提供的信息进行验证
            else
                Response.Redirect("syslogin.aspx?result=4");
        }