private static string ChangeStyleForCurrentUrl(DataRow dr) { string text = dr["nav"].ToString(); string text2 = dr["url"].ToString().Trim(); if (Utils.InArray(text2, "/,index.aspx") && DNTRequest.GetPageName() == ((GeneralConfigInfo.Current.Indexpage == 0) ? "forumindex.aspx" : "website.aspx")) { return(Navs.ReplaceCurrentCssClass(text)); } if (!Utils.StrIsNullOrEmpty(text2) && HttpContext.Current.Request.RawUrl.ToString().Contains(text2)) { return(Navs.ReplaceCurrentCssClass(text)); } return(text); }
private string ChangeStyleForCurrentUrl() { var text = Content; var url = Url.Trim(); if (Utils.InArray(url, "/,index.aspx") && DNTRequest.GetPageName() == (GeneralConfigInfo.Current.Indexpage == 0 ? "forumindex.aspx" : "website.aspx")) { return(ReplaceCurrentCssClass(text)); } if (!url.IsNullOrEmpty() && HttpContext.Current.Request.RawUrl.ToString().Contains(url)) { return(ReplaceCurrentCssClass(text)); } return(text); }
/// <summary> /// 当前页面与导航栏匹配时改变样式 /// </summary> /// <param name="nav">菜单名称</param> /// <param name="url">链接地址</param> /// <returns></returns> private static string ChangeStyleForCurrentUrl(DataRow dr) { string nav = dr["nav"].ToString(); string url = dr["url"].ToString().Trim(); //如果url的值为/或者index.aspx,证明这个页面可能会是forumindex或者website.aspx if (Utils.InArray(url, "/,index.aspx") && DNTRequest.GetPageName() == (GeneralConfigs.GetConfig().Indexpage == 0 ? "forumindex.aspx" : "website.aspx")) { return(ReplaceCurrentCssClass(nav)); } if (!Utils.StrIsNullOrEmpty(url) && System.Web.HttpContext.Current.Request.RawUrl.ToString().Contains(url)) { return(ReplaceCurrentCssClass(nav)); } return(nav); }
/// <summary> /// 构造函数 /// </summary> public ArchiverPage() { config = GeneralConfigs.GetConfig(); if (config.Archiverstatus == 2 && DNTRequest.IsSearchEnginesGet())//启用,但当用户从搜索引擎点击时自动转向动态页面 { string url = OrganizeURL(HttpContext.Current.Request.Url); HttpContext.Current.Response.Redirect(url); } if (config.Archiverstatus == 3 && DNTRequest.IsBrowserGet()) //启用,但当用户使用浏览器访问时自动转向动态页面 { string url = OrganizeURL(HttpContext.Current.Request.Url); HttpContext.Current.Response.Redirect(url); } int onlineusercount = OnlineUsers.GetOnlineAllUserCount(); if (onlineusercount >= config.Maxonlines) { ShowError("抱歉,目前访问人数太多,你暂时无法访问论坛.", 0); } if (config.Nocacheheaders == 1) { HttpContext.Current.Response.Buffer = true; HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1); HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddDays(-1)); HttpContext.Current.Response.Expires = 0; HttpContext.Current.Response.CacheControl = "no-cache"; HttpContext.Current.Response.Cache.SetNoStore(); } OnlineUserInfo oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout); userid = oluserinfo.Userid; useradminid = oluserinfo.Adminid; // 如果论坛关闭且当前用户请求页面不是登录页面且用户非管理员, 则跳转至论坛关闭信息页 if (config.Closed == 1 && oluserinfo.Adminid != 1) { ShowError("", 1); } usergroupinfo = UserGroups.GetUserGroupInfo(oluserinfo.Groupid); // 如果不允许访问论坛则转向到tools/ban.htm if (usergroupinfo.Allowvisit != 1) { ShowError("抱歉, 您所在的用户组不允许访问论坛", 2); } // 如果IP访问列表有设置则进行判断 if (config.Ipaccess.Trim() != "") { string[] regctrl = Utils.SplitString(config.Ipaccess, "\n"); if (!Utils.InIPArray(DNTRequest.GetIP(), regctrl)) { ShowError("抱歉, 系统设置了IP访问列表限制, 您无法访问本论坛", 0); return; } } // 如果IP访问列表有设置则进行判断 if (config.Ipdenyaccess.Trim() != "") { string[] regctrl = Utils.SplitString(config.Ipdenyaccess, "\n"); if (Utils.InIPArray(DNTRequest.GetIP(), regctrl)) { ShowError("由于您严重违反了论坛的相关规定, 已被禁止访问.", 2); return; } } // 如果当前用户请求页面不是登录页面并且当前用户非管理员并且论坛设定了时间段,当时间在其中的一个时间段内,则跳转到论坛登录页面 if (oluserinfo.Adminid != 1 && DNTRequest.GetPageName() != "login.aspx") { if (Scoresets.BetweenTime(config.Visitbanperiods)) { ShowError("在此时间段内不允许访问本论坛", 2); return; } } HttpContext.Current.Response.Write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n"); if (config.Seokeywords != "") { HttpContext.Current.Response.Write("<meta name=\"keywords\" content=\"" + config.Seokeywords + "\" />\r\n"); } if (config.Seodescription != "") { HttpContext.Current.Response.Write("<meta name=\"description\" content=\"" + config.Seodescription + "\" />\r\n"); } HttpContext.Current.Response.Write(config.Seohead.Trim()); HttpContext.Current.Response.Write("\r\n<link href=\"dntarchiver.css\" rel=\"stylesheet\" type=\"text/css\" />"); if (config.Archiverstatus == 0) { ShowError("系统禁止使用Archiver", 3); HttpContext.Current.Response.End(); return; } }
/// <summary> /// 用户在线信息维护。判断当前用户的身份(会员还是游客),是否在在线列表中存在,如果存在则更新会员的当前动,不存在则建立. /// </summary> /// <param name="passwordkey">论坛passwordkey</param> /// <param name="timeout">在线超时时间</param> /// <param name="passwd">用户密码</param> public static OnlineUserInfo UpdateInfo(string passwordkey, int timeout, int uid, string passwd) { lock (SynObject) { OnlineUserInfo onlineuser = new OnlineUserInfo(); string ip = DNTRequest.GetIP(); int userid = TypeConverter.StrToInt(ForumUtils.GetCookie("userid"), uid); string password = (Utils.StrIsNullOrEmpty(passwd) ? ForumUtils.GetCookiePassword(passwordkey) : ForumUtils.GetCookiePassword(passwd, passwordkey)); // 如果密码非Base64编码字符串则怀疑被非法篡改, 直接置身份为游客 if (password.Length == 0 || !Utils.IsBase64String(password)) { userid = -1; } if (userid != -1) { onlineuser = GetOnlineUser(userid, password); //更新流量统计 if (!DNTRequest.GetPageName().EndsWith("ajax.aspx") && GeneralConfigs.GetConfig().Statstatus == 1) { Stats.UpdateStatCount(false, onlineuser != null); } if (onlineuser != null) { if (onlineuser.Ip != ip) { UpdateIP(onlineuser.Olid, ip); onlineuser.Ip = ip; return(onlineuser); } } else { // 判断密码是否正确 userid = Users.CheckPassword(userid, password, false); if (userid != -1) { Discuz.Data.OnlineUsers.DeleteRowsByIP(ip); CheckIp(ip); return(CreateUser(userid, timeout)); } else { CheckIp(ip); // 如密码错误则在在线表中创建游客 onlineuser = GetOnlineUserByIP(-1, ip); if (onlineuser == null) { return(CreateGuestUser(timeout)); } } } } else { onlineuser = GetOnlineUserByIP(-1, ip); //更新流量统计 if (!DNTRequest.GetPageName().EndsWith("ajax.aspx") && GeneralConfigs.GetConfig().Statstatus == 1) { Stats.UpdateStatCount(true, onlineuser != null); } if (onlineuser == null) { return(CreateGuestUser(timeout)); } } //onlineuser.Lastupdatetime = Utils.GetDateTime(); 为了客户端能够登录注释此句,如有问题再修改。 return(onlineuser); } }
/// <summary> /// 用户在线信息维护。判断当前用户的身份(会员还是游客),是否在在线列表中存在,如果存在则更新会员的当前动,不存在则建立. /// </summary> /// <param name="passwordkey">论坛passwordkey</param> /// <param name="timeout">在线超时时间</param> /// <param name="passwd">用户密码</param> public static OnlineUserInfo UpdateInfo(string passwordkey, int timeout, int uid, string passwd) { lock (SynObject) { OnlineUserInfo onlineuser = new OnlineUserInfo(); string ip = DNTRequest.GetIP(); int userid = Discuz.Forum.Users.GetUserIDFromCookie(); if (userid != -1) { onlineuser = GetOnlineUser(userid, Users.GetUserInfo(userid).Password); //更新流量统计 if (!DNTRequest.GetPageName().EndsWith("ajax.aspx") && GeneralConfigs.GetConfig().Statstatus == 1) { Stats.UpdateStatCount(false, onlineuser != null); } if (onlineuser != null) { if (onlineuser.Ip != ip) { UpdateIP(onlineuser.Olid, ip); onlineuser.Ip = ip; return(onlineuser); } } else { // 判断密码是否正确 userid = Users.CheckPassword(userid, Users.GetUserInfo(userid).Password, false); if (userid != -1) { DeleteRowsByIP(ip); return(CreateUser(userid, timeout)); } else { // 如密码错误则在在线表中创建游客 onlineuser = GetOnlineUserByIP(-1, ip); if (onlineuser == null) { return(CreateGuestUser(timeout)); } } } } else { onlineuser = GetOnlineUserByIP(-1, ip); //更新流量统计 if (!DNTRequest.GetPageName().EndsWith("ajax.aspx") && GeneralConfigs.GetConfig().Statstatus == 1) { Stats.UpdateStatCount(true, onlineuser != null); } if (onlineuser == null) { return(CreateGuestUser(timeout)); } } //UpdateLastTime(onlineuser.Olid); onlineuser.Lastupdatetime = Utils.GetDateTime(); return(onlineuser); } }
//public ArchiverPage() { } protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (this.config.Archiverstatus == 2 && IsSearchEnginesGet()) { Response.Redirect(this.OrganizeURL(Request.Url)); } if (this.config.Archiverstatus == 3 && IsBrowserGet()) { Response.Redirect(this.OrganizeURL(Request.Url)); } if (Online.Meta.Count >= this.config.Maxonlines) { this.ShowError("抱歉,目前访问人数太多,你暂时无法访问论坛.", 0); } if (this.config.Nocacheheaders == 1) { Response.Buffer = true; Response.ExpiresAbsolute = DateTime.Now.AddDays(-1.0); Response.Cache.SetExpires(DateTime.Now.AddDays(-1.0)); Response.Expires = 0; Response.CacheControl = "no-cache"; Response.Cache.SetNoStore(); } var onlineUserInfo = Online.UpdateInfo(); this.userid = onlineUserInfo.UserID; this.useradminid = (int)onlineUserInfo.AdminID; if (this.config.Closed == 1 && onlineUserInfo.AdminID != 1) { this.ShowError("", 1); } this.usergroupinfo = onlineUserInfo.Group; if (!this.usergroupinfo.AllowVisit) { this.ShowError("抱歉, 您所在的用户组 \"" + usergroupinfo.GroupTitle + "\" 不允许访问论坛", 2); } if (!config.Ipaccess.IsNullOrWhiteSpace() && !Utils.InIPArray(WebHelper.UserHost, Utils.SplitString(config.Ipaccess, "\n"))) { this.ShowError("抱歉, 系统设置了IP访问列表限制, 您无法访问本论坛", 0); return; } if (!config.Ipdenyaccess.IsNullOrWhiteSpace() && Utils.InIPArray(WebHelper.UserHost, Utils.SplitString(config.Ipdenyaccess, "\n"))) { this.ShowError("由于您严重违反了论坛的相关规定, 已被禁止访问.", 2); return; } if (onlineUserInfo.AdminID != 1 && DNTRequest.GetPageName() != "login.aspx" && Scoresets.BetweenTime(this.config.Visitbanperiods)) { this.ShowError("在此时间段内不允许访问本论坛", 2); return; } Response.Write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n "); if (!String.IsNullOrEmpty(config.Seokeywords)) { Response.Write("<meta name=\"keywords\" content=\"" + this.config.Seokeywords + "\" />\r\n"); } if (!String.IsNullOrEmpty(config.Seodescription)) { Response.Write("<meta name=\"description\" content=\"" + this.config.Seodescription + "\" />\r\n"); } Response.Write(this.config.Seohead.Trim()); Response.Write("\r\n<link href=\"dntarchiver.css\" rel=\"stylesheet\" type=\"text/css\" />"); if (this.config.Archiverstatus == 0) { this.ShowError("系统禁止使用Archiver", 3); Response.End(); } }
public static Online UpdateInfo(int uid = -1, string passwd = "") { var cfg = GeneralConfigInfo.Current; var passwordkey = cfg.Passwordkey; string iP = WebHelper.UserHost; int userid = GetCookie("userid").ToInt(uid); string pass = passwd.IsNullOrEmpty() ? GetCookiePassword(passwordkey) : GetCookiePassword(passwd, passwordkey); if (pass.Length == 0 || !Utils.IsBase64String(pass)) { userid = -1; } var online = Current; if (userid > 0) { // 根据用户ID和密码来验证在线信息 //var online = Online.GetOnlineUser(userid, pass); if (!DNTRequest.GetPageName().EndsWith("ajax.ashx") && cfg.Statstatus) { Stat.IncCount(false, online != null); } if (online != null) { if (online.UserID != userid) { var user = User.Check(userid, pass, false); if (user != null) { online.SetUser(user); } else { XTrace.WriteLine("用户ID={0} Pass={1}验证失败 当前登录{2}", userid, pass, online.UserID); online.SetGuest(); } } // 如果IP变了,更换一下 online.IP = iP; online.Save(); return(online); } else { CheckIp(iP); // 如果找不到在线信息,则准备登录 var user = User.Check(userid, pass, false); if (user != null) { return(Online.CreateUser(userid)); } XTrace.WriteLine("用户ID={0} Pass={1}验证失败", userid, pass); return(CreateGuestUser()); } } else { //var online = Online.FindByUserIDAndIP(-1, iP); if (!DNTRequest.GetPageName().EndsWith("ajax.ashx") && cfg.Statstatus) { Stat.IncCount(true, online != null); } if (online == null) { return(CreateGuestUser()); } return(online); } }