private void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int opnumber = DNTRequest.GetInt("opnumber", 0); int result = -1; #region 根据缓存更新选项更新相应的缓存数据 switch (opnumber) { case 1: { //重设管理组信息 AdminCaches.ReSetAdminGroupList(); result = 2; break; } case 2: { //重设用户组信息 AdminCaches.ReSetUserGroupList(); result = 3; break; } case 3: { //重设版主信息 AdminCaches.ReSetModeratorList(); result = 4; break; } case 4: { //重设指定时间内的公告列表 AdminCaches.ReSetAnnouncementList(); AdminCaches.ReSetSimplifiedAnnouncementList(); result = 5; break; } case 5: { //重设第一条公告 AdminCaches.ReSetSimplifiedAnnouncementList(); result = 6; break; } case 6: { //重设版块下拉列表 AdminCaches.ReSetForumListBoxOptions(); result = 7; break; } case 7: { //重设表情 AdminCaches.ReSetSmiliesList(); result = 8; break; } case 8: { //重设主题图标 AdminCaches.ReSetIconsList(); result = 9; break; } case 9: { //重设自定义标签 AdminCaches.ReSetCustomEditButtonList(); result = 10; break; } case 10: { //重设论坛基本设置 //AdminCaches.ReSetConfig(); result = 11; break; } case 11: { //重设论坛金币 AdminCaches.ReSetScoreset(); result = 12; break; } case 12: { //重设地址对照表 AdminCaches.ReSetSiteUrls(); result = 13; break; } case 13: { //重设论坛统计信息 AdminCaches.ReSetStatistics(); result = 14; break; } case 14: { //重设系统允许的附件类型和大小 AdminCaches.ReSetAttachmentTypeArray(); result = 15; break; } case 15: { //重设模板列表的下拉框html AdminCaches.ReSetTemplateListBoxOptionsCache(); result = 16; break; } case 16: { //重设在线用户列表图例 AdminCaches.ReSetOnlineGroupIconList(); result = 17; break; } case 17: { //重设友情链接列表 AdminCaches.ReSetForumLinkList(); result = 18; break; } case 18: { //重设脏字过滤列表 AdminCaches.ReSetBanWordList(); result = 19; break; } case 19: { //重设论坛列表 AdminCaches.ReSetForumList(); result = 20; break; } case 20: { //重设在线用户信息 AdminCaches.ReSetOnlineUserTable(); result = 21; break; } case 21: { //重设论坛整体RSS及指定版块RSS AdminCaches.ReSetRss(); result = 22; break; } case 22: { //重设论坛整体RSS AdminCaches.ReSetRssXml(); result = 23; break; } case 23: { //重设模板ID列表 AdminCaches.ReSetValidTemplateIDList(); result = 24; break; } case 24: { //重设有效用户表扩展字段 AdminCaches.ReSetValidScoreName(); result = 25; break; } case 25: { //重设勋章列表 AdminCaches.ReSetMedalsList(); result = 26; break; } case 26: { //重设数据链接串和表前缀 AdminCaches.ReSetDBlinkAndTablePrefix(); result = 27; break; } case 27: { //重设帖子列表 AdminCaches.ReSetAllPostTableName(); result = 28; break; } case 28: { //重设最后帖子表 AdminCaches.ReSetLastPostTableName(); result = 29; break; } case 29: { //重设广告列表 AdminCaches.ReSetAdsList(); result = 30; break; } case 30: { //重设用户上一次执行搜索操作时间 AdminCaches.ReSetStatisticsSearchtime(); result = 31; break; } case 31: { //重设用户一分钟内搜索次数 AdminCaches.ReSetStatisticsSearchcount(); result = 32; break; } case 32: { //重设用户头象列表 AdminCaches.ReSetCommonAvatarList(); result = 33; break; } case 33: { //重设干扰码字符串 AdminCaches.ReSetJammer(); result = 34; break; } case 34: { //重设魔力列表 AdminCaches.ReSetMagicList(); result = 35; break; } case 35: { //重设兑换比率可交易金币策略 AdminCaches.ReSetScorePaySet(); result = 36; break; } case 36: { //重设当前帖子表相关信息 AdminCaches.ReSetPostTableInfo(); result = 37; break; } case 37: { //重设全部版块精华主题列表 AdminCaches.ReSetDigestTopicList(16); result = 38; break; } case 38: { //重设全部版块热帖主题列表 AdminCaches.ReSetHotTopicList(16, 30); result = 39; break; } case 39: { //重设最近主题列表 AdminCaches.ReSetRecentTopicList(16); result = 40; break; } case 41: { //重设在线用户表 OnlineUsers.InitOnlineList(); result = 42; break; } case 42: { //重设导航弹出菜单 AdminCaches.ReSetNavPopupMenu(); result = -1; break; } } #endregion Response.Write(result); Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1); Response.Expires = -1; Response.End(); } }
protected override void ShowPage() { if (oluserinfo.Groupid == 4) { AddErrLine("你所在的用户组,为禁止发言"); return; } #region 临时帐号发帖 //int realuserid = -1; //bool tempaccountspost = false; //string tempusername = DNTRequest.GetString("tempusername"); //if (!Utils.StrIsNullOrEmpty(tempusername) && tempusername != username) //{ // realuserid = Users.CheckTempUserInfo(tempusername, DNTRequest.GetString("temppassword"), DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer")); // if (realuserid == -1) // { // AddErrLine("临时帐号登录失败,无法继续发帖。"); return; // } // else // { // userid = realuserid; // username = tempusername; // tempaccountspost = true; // } //} #endregion if (userid > 0) { userinfo = Users.GetShortUserInfo(userid); // if (userinfo != null) // { // usergroupinfo = UserGroups.GetUserGroupInfo(userinfo.Groupid); // usergroupid = usergroupinfo.Groupid; // useradminid = userinfo.Adminid; // } } #region 获取并检查版块信息 forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Layer == 0) { forum = new ForumInfo();//如果不初始化对象,则会报错 allowposttopic = false; AddErrLine("错误的论坛ID"); return; } pagetitle = Utils.RemoveHtml(forum.Name); enabletag = (config.Enabletag & forum.Allowtag) == 1; if (forum.Applytopictype == 1) //启用主题分类 topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } needaudit = UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo); smileyoff = 1 - forum.Allowsmilies; bbcodeoff = (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) ? 0 : 1; allowimg = forum.Allowimgcode; customeditbuttons = Caches.GetCustomEditButtonList(); #endregion #region 访问和发帖权限校验 if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = true; return; } if (!UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = true; return; } #endregion #region 附件信息绑定 //得到用户可以上传的文件类型 string attachmentTypeSelect = Attachments.GetAllowAttachmentType(usergroupinfo, forum); attachextensions = Attachments.GetAttachmentTypeArray(attachmentTypeSelect); attachextensionsnosize = Attachments.GetAttachmentTypeString(attachmentTypeSelect); //得到今天允许用户上传的附件总大小(字节) int MaxTodaySize = (userid > 0 ? MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid) : 0); attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;//今天可上传得大小 //是否有上传附件的权限 canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg); if (canpostattach && (userinfo != null && userinfo.Uid > 0) && apb != null && config.Enablealbum == 1 && (UserGroups.GetUserGroupInfo(userinfo.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0)) { caninsertalbum = true; albumlist = apb.GetSpaceAlbumByUserId(userid); } #endregion canhtmltitle = usergroupinfo.Allowhtmltitle == 1; #region 积分信息 creditstrans = Scoresets.GetTopicAttachCreditsTrans(); userextcreditsinfo = Scoresets.GetScoreSet(creditstrans); bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans()); #endregion #region 特殊主题权限判断 if (forum.Allowspecialonly > 0 &&!Utils.InArray(type, "poll,bonus,debate")) { AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表普通主题", forum.Name)); return; } if (!UserAuthority.PostSpecialAuthority(forum, type, ref msg)) { AddErrLine(msg); return; } if (!UserAuthority.PostSpecialAuthority(usergroupinfo, type, ref msg)) { AddErrLine(msg); needlogin = true; return; } if (type == "bonus") { int creditTrans = Scoresets.GetBonusCreditsTrans(); //当“交易积分设置”有效时(1-8的整数): if (creditTrans <= 0) { //AddErrLine(string.Format("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏", usergroupinfo.Grouptitle)); return; AddErrLine("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏"); return; } mybonustranscredits = Users.GetUserExtCredits(userid, creditTrans); } userGroupInfoList.Sort(delegate(UserGroupInfo x, UserGroupInfo y) { return (x.Readaccess - y.Readaccess) + (y.Groupid - x.Groupid); }); #endregion //发帖不受审核、过滤、灌水等限制权限 AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); disablepost = admininfo != null ? admininfo.Disablepostctrl : usergroupinfo.Disableperiodctrl; //如果是提交... if (ispost) { #region 判断是否是灌水 if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, userinfo, ref msg)) { AddErrLine(msg); return; } #endregion SetBackLink(string.Format("posttopic.aspx?forumid={0}&restore=1&type={1}", forumid, type)); ForumUtils.WriteCookie("postmessage", postmessage); #region 验证提交信息 //常规项验证 NormalValidate(admininfo, postmessage, userinfo); if (IsErr()) return; // 如果用户上传了附件,则检测用户是否有上传附件的权限 if (ForumUtils.IsPostFile()) { if (Utils.StrIsNullOrEmpty(Attachments.GetAttachmentTypeArray(attachmentTypeSelect))) AddErrLine("系统不允许上传附件"); if (!UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg)) AddErrLine(msg); } //发悬赏校验 int topicprice = 0; bool isbonus = type == "bonus"; ValidateBonus(ref topicprice, ref isbonus); //发特殊主题校验 ValidatePollAndDebate(); if (IsErr()) return; #endregion int hide = (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) ? 1 : 0; TopicInfo topicinfo = CreateTopic(admininfo, postmessage, isbonus, topicprice); if (IsErr()) return; PostInfo postinfo = CreatePost(topicinfo); if (IsErr()) return; #region 处理附件 //处理附件 StringBuilder sb = new StringBuilder(); AttachmentInfo[] attachmentinfo = null; string attachId = DNTRequest.GetFormString("attachid"); if (!string.IsNullOrEmpty(attachId)) { attachmentinfo = Attachments.GetNoUsedAttachmentArray(userid, attachId); Attachments.UpdateAttachment(attachmentinfo, topicinfo.Tid, postinfo.Pid, postinfo, ref sb, userid, config, usergroupinfo); } //加入相册 if (config.Enablealbum == 1 && apb != null) sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username)); #endregion #region 添加日志的操作 SpacePluginBase spb = SpacePluginProvider.GetInstance(); if (DNTRequest.GetFormString("addtoblog") == "on" && spb != null) { if (userid != -1 && userinfo.Spaceid > 0) spb.CreateTopic(topicinfo, postinfo, attachmentinfo); else AddMsgLine("您的个人空间尚未开通, 无法同时添加为日志"); } #endregion OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forum.Name, -1, ""); //添加帖子索引 PKS.Forum.Web.ForumExtension.SaveForumTopicToIndex(forum, topicinfo, postinfo); #region 设置提示信息和跳转链接 if (sb.Length > 0) { SetUrl(base.ShowTopicAspxRewrite(topicinfo.Tid, 0)); SetMetaRefresh(5); SetShowBackLink(true); if (infloat == 1) { AddErrLine(sb.ToString()); return; } else { sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表主题成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr>"); AddMsgLine(sb.Append("</table>").ToString()); } } else { SetShowBackLink(false); if (useradminid != 1) { //是否需要审核 if (UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo) || topicinfo.Displayorder == -2) { ForumUtils.WriteCookie("postmessage", ""); SetLastPostedForumCookie(); SetUrl(base.ShowForumAspxRewrite(forumid, forumpageid)); SetMetaRefresh(); AddMsgLine("发表主题成功, 但需要经过审核才可以显示. 返回该版块"); } else PostTopicSucceed(Forums.GetValues(forum.Postcredits), topicinfo, topicinfo.Tid); } else PostTopicSucceed(Forums.GetValues(forum.Postcredits), topicinfo, topicinfo.Tid); } #endregion //ForumUtils.WriteCookie("postmessage", ""); //SetLastPostedForumCookie(); //如果已登录就不需要再登录 if (needlogin && userid > 0) needlogin = false; } else //非提交操作 AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css"); }
protected override void ShowPage() { if (config.Enablemall == 0) //未启用交易模式 { AddErrLine("系统未开启交易模式, 当前页面暂时无法访问!"); return; } #region 临时帐号发帖 //int realuserid = -1; //string tempusername = DNTRequest.GetString("tempusername"); //if (tempusername != "" && tempusername != username) //{ // string temppassword = DNTRequest.GetString("temppassword"); // int question = DNTRequest.GetInt("question", 0); // string answer = DNTRequest.GetString("answer"); // realuserid = Users.CheckTempUserInfo(tempusername, temppassword, question, answer); // if (realuserid == -1) // { // AddErrLine("临时帐号登录失败,无法继续发帖。"); // return; // } // else // { // userid = realuserid; // username = tempusername; // usergroupinfo = UserGroups.GetUserGroupInfo(Users.GetShortUserInfo(userid).Groupid); // usergroupid = usergroupinfo.Groupid; // useradminid = Users.GetShortUserInfo(userid).Adminid; // } //} #endregion #region 获取分类对象信息 int categoryid = DNTRequest.GetInt("categoryid", -1); //如果是提交... if (ispost) { categoryid = DNTRequest.GetInt("goodscategoryid", -1); } if (categoryid > 0) { goodscategoryinfo = GoodsCategories.GetGoodsCategoryInfoById(categoryid); } if (goodscategoryinfo == null) { goodscategoryinfo = new Goodscategoryinfo(); goodscategoryinfo.Categoryid = -1; } if (goodscategoryinfo.Fid <= 0) { allowpostgoods = false; forumnav = ""; AddErrLine("错误的商品分类ID"); return; } #endregion canhtmltitle = config.Htmltitle == 1 && Utils.InArray(usergroupid.ToString(), config.Htmltitleusergroup); firstpagesmilies = Caches.GetSmiliesFirstPageCache(); //内容设置为空; message = ""; if (config.Enablemall == 1) //开启普通模式 { forumid = GoodsCategories.GetCategoriesFid(categoryid); forumnav = ""; if (forumid == -1) { allowpostgoods = false; AddErrLine("错误的商品分类ID"); return; } else { forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Layer == 0) { allowpostgoods = false; AddErrLine("错误的商品分类ID"); return; } if (forum.Istrade <= 0) { allowpostgoods = false; AddErrLine("当前版块不允许发布商品"); return; } forumname = forum.Name; pagetitle = Utils.RemoveHtml(forum.Name); forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); enabletag = (config.Enabletag & forum.Allowtag) == 1; } } else if (config.Enablemall == 2) //当为高级模式时 { pagetitle = "发布商品"; forumnav = ""; enabletag = true; forum = new ForumInfo(); forum.Allowsmilies = 1; forum.Allowbbcode = 1; } //得到用户可以上传的文件类型 StringBuilder sbAttachmentTypeSelect = new StringBuilder(); if (!usergroupinfo.Attachextensions.Trim().Equals("")) { sbAttachmentTypeSelect.Append("[id] in ("); sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions); sbAttachmentTypeSelect.Append(")"); } if (config.Enablemall == 1) //开启普通模式 { if (!forum.Attachextensions.Equals("")) { if (sbAttachmentTypeSelect.Length > 0) { sbAttachmentTypeSelect.Append(" AND "); } sbAttachmentTypeSelect.Append("[id] in ("); sbAttachmentTypeSelect.Append(forum.Attachextensions); sbAttachmentTypeSelect.Append(")"); } } attachextensions = Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()); attachextensionsnosize = Attachments.GetAttachmentTypeString(sbAttachmentTypeSelect.ToString()); //得到今天允许用户上传的附件总大小(字节) int MaxTodaySize = 0; if (userid > 0) { MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid); //今天已上传大小 } attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize; //今天可上传得大小 parseurloff = 0; bbcodeoff = 1; if (config.Enablemall == 1) //开启普通模式 { smileyoff = 1 - forum.Allowsmilies; allowimg = forum.Allowimgcode; if (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) { bbcodeoff = 0; } } // 如果当前用户非管理员并且论坛设定了禁止发布商品时间段,当前时间如果在其中的一个时间段内,不允许用户发布商品 if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1) { string visittime = ""; if (Scoresets.BetweenTime(config.Postbanperiods, out visittime)) { AddErrLine("在此时间段( " + visittime + " )内用户不可以发布商品"); return; } } if (config.Enablemall == 1) //开启普通模式 { if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } if (!Forums.AllowViewByUserId(forum.Permuserlist, userid)) //判断当前用户在当前版块浏览权限 { if (forum.Viewperm == null || forum.Viewperm == string.Empty) //当板块权限为空时,按照用户组权限 { if (useradminid != 1 && (usergroupinfo.Allowvisit != 1 || usergroupinfo.Allowtrade != 1)) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布商品的权限"); return; } } else//当板块权限不为空,按照板块权限 { if (!Forums.AllowView(forum.Viewperm, usergroupid)) { AddErrLine("您没有发布商品的权限"); return; } } } if (!Forums.AllowPostByUserID(forum.Permuserlist, userid)) //判断当前用户在当前版块发布商品权限 { if (forum.Postperm == null || forum.Postperm == string.Empty) //权限设置为空时,根据用户组权限判断 { // 验证用户是否有发布商品的权限 if (useradminid != 1 && usergroupinfo.Allowtrade != 1) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布商品的权限"); return; } } else//权限设置不为空时,根据板块权限判断 { if (!Forums.AllowPost(forum.Postperm, usergroupid)) { AddErrLine("您没有发布商品的权限"); return; } } } //是否有上传附件的权限 if (Forums.AllowPostAttachByUserID(forum.Permuserlist, userid)) { canpostattach = true; } else { if (forum.Postattachperm == "") { if (usergroupinfo.Allowpostattach == 1) { canpostattach = true; } } else { if (Forums.AllowPostAttach(forum.Postattachperm, usergroupid)) { canpostattach = true; } } } } else if (config.Enablemall == 2) //当为高级模式时 { canpostattach = true; allowimg = 1; smileyoff = 0; } ShortUserInfo user = Users.GetShortUserInfo(userid); if (canpostattach && user != null && apb != null && config.Enablealbum == 1 && (UserGroups.GetUserGroupInfo(user.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0)) { caninsertalbum = true; albumlist = apb.GetSpaceAlbumByUserId(userid); } else { caninsertalbum = false; } // 如果是受灌水限制用户, 则判断是否是灌水 AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); disablepost = 0; if (admininfo != null) { disablepost = admininfo.Disablepostctrl; } if (admininfo == null || admininfo.Disablepostctrl != 1) { int Interval = Utils.StrDateDiffSeconds(lastposttime, config.Postinterval); if (Interval < 0) { AddErrLine("系统规定发布商品间隔为" + config.Postinterval.ToString() + "秒, 您还需要等待 " + (Interval * -1).ToString() + " 秒"); return; } else if (userid != -1) { ShortUserInfo shortUserInfo = Discuz.Data.Users.GetShortUserInfo(userid); string joindate = (shortUserInfo != null) ? shortUserInfo.Joindate : ""; if (joindate == "") { AddErrLine("您的用户资料出现错误"); return; } Interval = Utils.StrDateDiffMinutes(joindate, config.Newbiespan); if (Interval < 0) { AddErrLine("系统规定新注册用户必须要在" + config.Newbiespan.ToString() + "分钟后才可以发布商品, 您还需要等待 " + (Interval * -1).ToString() + " 分"); return; } } } creditstrans = Scoresets.GetCreditsTrans(); userextcreditsinfo = Scoresets.GetScoreSet(creditstrans); if (userid > 0) { spaceid = Users.GetShortUserInfo(userid).Spaceid; } //如果不是提交... if (!ispost) { AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css"); smilies = Caches.GetSmiliesCache(); smilietypes = Caches.GetSmilieTypesCache(); customeditbuttons = Caches.GetCustomEditButtonList(); } else { SetBackLink(string.Format("postgoods.aspx?categoryid={0}&restore=1", categoryid)); string postmessage = DNTRequest.GetString("message"); ForumUtils.WriteCookie("postmessage", postmessage); if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } if (DNTRequest.GetString("title").Trim().Equals("")) { AddErrLine("商品标题不能为空"); } else if (DNTRequest.GetString("title").IndexOf(" ") != -1) { AddErrLine("商品标题不能包含全角空格符"); } else if (DNTRequest.GetString("title").Length > 60) { AddErrLine("商品标题最大长度为60个字符,当前为 " + DNTRequest.GetString("title").Length + " 个字符"); } if (postmessage.Equals("") || postmessage.Replace(" ", "").Equals("")) { AddErrLine("商品内容不能为空"); } if (admininfo != null && admininfo.Disablepostctrl != 1) { if (postmessage.Length < config.Minpostsize) { AddErrLine("您发表的内容过少, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字"); } else if (postmessage.Length > config.Maxpostsize) { AddErrLine("您发表的内容过多, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字"); } } //新用户广告强力屏蔽检查 if (config.Disablepostad == 1 || userid == -1) //如果开启新用户广告强力屏蔽检查或是游客 { if (userid == -1 || (config.Disablepostadpostcount != 0 && user.Posts <= config.Disablepostadpostcount) || (config.Disablepostadregminute != 0 && DateTime.Now.AddMinutes(-config.Disablepostadregminute) <= Convert.ToDateTime(user.Joindate))) { foreach (string regular in config.Disablepostadregular.Replace("\r", "").Split('\n')) { if (Posts.IsAD(regular, DNTRequest.GetString("title"), postmessage)) { AddErrLine("发布商品失败,商品内容中似乎有广告信息,请检查标题和内容,如有疑问请与管理员联系"); return; } } } } if (IsErr()) { return; } // 如果用户上传了附件,则检测用户是否有上传附件的权限 if (ForumUtils.IsPostFile()) { if (Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()).Trim() == "") { AddErrLine("系统不允许上传附件"); } if (config.Enablemall == 1) //开启普通模式 { if (!Forums.AllowPostAttachByUserID(forum.Permuserlist, userid)) { if (!Forums.AllowPostAttach(forum.Postattachperm, usergroupid)) { AddErrLine("您没有在该版块上传附件的权限"); } else if (usergroupinfo.Allowpostattach != 1) { AddErrLine(string.Format("您当前的身份 \"{0}\" 没有上传附件的权限", usergroupinfo.Grouptitle)); } } } } if (IsErr()) { return; } int iconid = DNTRequest.GetInt("iconid", 0); if (iconid > 15 || iconid < 0) { iconid = 0; } string curdatetime = Utils.GetDateTime(); Goodsinfo goodsinfo = new Goodsinfo(); //当在高级模式下则绑定相应店铺信息 if (config.Enablemall == 2) { Shopinfo shopinfo = Shops.GetShopByUserId(user.Uid); if (shopinfo != null) { goodsinfo.Shopid = shopinfo.Shopid; } } goodsinfo.Categoryid = goodscategoryinfo.Categoryid; goodsinfo.Parentcategorylist = goodscategoryinfo.Parentidlist; goodsinfo.Recommend = DNTRequest.GetString("recommend") == "on" ? 1 : 0; goodsinfo.Discount = DNTRequest.GetInt("discount", 0); goodsinfo.Selleruid = userid; goodsinfo.Seller = username; goodsinfo.Account = DNTRequest.GetString("account"); goodsinfo.Price = Convert.ToDecimal(DNTRequest.GetFormFloat("price", 1).ToString()); goodsinfo.Amount = DNTRequest.GetInt("amount", 0); goodsinfo.Quality = DNTRequest.GetInt("quality", 0); goodsinfo.Lid = DNTRequest.GetInt("locus_2", 0); goodsinfo.Locus = Locations.GetLocusByLID(goodsinfo.Lid); goodsinfo.Transport = DNTRequest.GetInt("transport", 0); if (goodsinfo.Transport != 0) { goodsinfo.Ordinaryfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_mail", 0).ToString()); goodsinfo.Expressfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_express", 0).ToString()); goodsinfo.Emsfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_ems", 0).ToString()); } goodsinfo.Itemtype = DNTRequest.GetInt("itemtype", 0); DateTime dateline; switch (DNTRequest.GetInt("_now", 0)) { case 1: dateline = Convert.ToDateTime(string.Format("{0} {1}:{2}:00", DNTRequest.GetString("_date"), DNTRequest.GetInt("_hour", 0), DNTRequest.GetInt("_minute", 0))); break; //设定 case 2: dateline = Convert.ToDateTime("1900-01-01 00:00:00"); break; //返回100年之后的日期作为"暂不设置" default: dateline = DateTime.Now; break; //立即 } goodsinfo.Dateline = dateline; goodsinfo.Expiration = Convert.ToDateTime(DNTRequest.GetString("expiration")); goodsinfo.Lastbuyer = ""; goodsinfo.Lasttrade = Convert.ToDateTime("1900-01-01 00:00:00"); goodsinfo.Lastupdate = Convert.ToDateTime(Utils.GetDateTime()); goodsinfo.Totalitems = 0; goodsinfo.Tradesum = 0; goodsinfo.Closed = 0; goodsinfo.Aid = 0; goodsinfo.Costprice = Convert.ToDecimal(DNTRequest.GetFormFloat("costprice", 1).ToString()); goodsinfo.Invoice = DNTRequest.GetInt("invoice", 0); goodsinfo.Repair = DNTRequest.GetInt("repair", 0); if (useradminid == 1) { goodsinfo.Message = Utils.HtmlEncode(postmessage); } else { goodsinfo.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage)); } goodsinfo.Otherlink = ""; int readperm = DNTRequest.GetInt("readperm", 0); goodsinfo.Readperm = readperm > 255 ? 255 : readperm; goodsinfo.Tradetype = DNTRequest.GetInt("tradetype", 0); if (goodsinfo.Tradetype == 1 && Utils.StrIsNullOrEmpty(goodsinfo.Account)) //当为支付宝在线支付方式下,如果"支付宝账户"为空时 { AddErrLine("请输入支付宝帐号信息。"); return; } goodsinfo.Viewcount = 0; goodsinfo.Displayorder = DNTRequest.GetString("displayorder") == "on" ? 0 : -3; if (config.Enablemall == 1) //当为版块交易帖是时 { if (forum.Modnewposts == 1 && useradminid != 1) { if (useradminid > 1) { if (disablepost != 1) { goodsinfo.Displayorder = -2; disablepost = 0; } } else { goodsinfo.Displayorder = -2; disablepost = 0; } } } goodsinfo.Smileyoff = smileyoff; if (smileyoff == 0 && forum.Allowsmilies == 1) { goodsinfo.Smileyoff = Utils.StrToInt(DNTRequest.GetString("smileyoff"), 0); } goodsinfo.Bbcodeoff = 1; if (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1) { goodsinfo.Bbcodeoff = Utils.StrToInt(DNTRequest.GetString("bbcodeoff"), 0); } goodsinfo.Parseurloff = Utils.StrToInt(DNTRequest.GetString("parseurloff"), 0); if (useradminid == 1) { goodsinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title")); } else { goodsinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title"))); } string htmltitle = DNTRequest.GetString("htmltitle").Trim(); if (htmltitle != string.Empty && Utils.HtmlDecode(htmltitle).Trim() != goodsinfo.Title) { goodsinfo.Magic = 11000; //按照 附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储 //例: 11001 } //标签(Tag)操作 string tags = DNTRequest.GetString("tags").Trim(); string[] tagsArray = null; if (enabletag && tags != string.Empty) { tagsArray = Utils.SplitString(tags, " ", true, 2, 10); if (tagsArray.Length > 0) { if (goodsinfo.Magic == 0) { goodsinfo.Magic = 10000; } goodsinfo.Magic = Utils.StrToInt(goodsinfo.Magic.ToString() + "1", 0); } } goodsinfo.Goodsid = Goods.CreateGoods(goodsinfo); //保存htmltitle if (canhtmltitle && htmltitle != string.Empty && htmltitle != goodsinfo.Title) { Goods.WriteHtmlSubjectFile(htmltitle, goodsinfo.Goodsid); } if (enabletag && tagsArray != null && tagsArray.Length > 0) { DbProvider.GetInstance().CreateGoodsTags(string.Join(" ", tagsArray), goodsinfo.Goodsid, userid, curdatetime); GoodsTags.WriteGoodsTagsCacheFile(goodsinfo.Goodsid); } StringBuilder sb = new StringBuilder(); sb.Remove(0, sb.Length); int watermarkstatus = (forum.Disablewatermark == 1) ? 0 : config.Watermarkstatus; Goodsattachmentinfo[] attachmentinfo = Discuz.Mall.MallUtils.SaveRequestFiles(categoryid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, watermarkstatus, config, "postfile"); if (attachmentinfo != null) { if (attachmentinfo.Length > config.Maxattachments) { AddErrLine("系统设置为每个商品附件不得多于" + config.Maxattachments + "个"); return; } int errorAttachment = GoodsAttachments.BindAttachment(attachmentinfo, goodsinfo.Goodsid, sb, goodsinfo.Categoryid, userid); int[] aid = GoodsAttachments.CreateAttachments(attachmentinfo); string tempMessage = GoodsAttachments.FilterLocalTags(aid, attachmentinfo, goodsinfo.Message); goodsinfo.Goodspic = (attachmentinfo.Length > 0) ? attachmentinfo[0].Filename : ""; if (!tempMessage.Equals(goodsinfo.Message)) { goodsinfo.Message = tempMessage; goodsinfo.Aid = aid[0]; } Goods.UpdateGoods(goodsinfo); UserCredits.UpdateUserExtCreditsByUploadAttachment(userid, aid.Length - errorAttachment); } //加入相册 #region 相册 if (config.Enablealbum == 1 && apb != null) { sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username)); } #endregion if (config.Enablemall == 1) //开启普通模式 { OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forumname, -1, ""); } if (sb.Length > 0) { SetShowBackLink(true); sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发布商品成功,但以下附件上传失败:</nobr></span><br /></td></tr>"); sb.Append("</table>"); SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid), sb.ToString()); } else { SetShowBackLink(false); if (config.Enablemall == 1 && forum.Modnewposts == 1 && useradminid != 1) { if (useradminid != 1) { if (disablepost == 1) { if (goodsinfo.Displayorder == -3) { SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但未上架. 您可到用户中心进行上架操作!"); } else { SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid), "发布商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回 " + forumname + "</a>)<br />"); } } else { SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但需要经过审核才可以显示. 返回商品列表"); } } else { SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 返回商品列表"); } } else { if (goodsinfo.Displayorder == -3) { SetUrlAndMsgLine(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1), "发布商品成功, 但未上架. 您可到用户中心进行上架操作!"); } else { SetUrlAndMsgLine(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid), "发布商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回</a>)<br />"); } } } ForumUtils.WriteCookie("postmessage", ""); } topicattachscorefield = 0; }
/// <summary> /// 创建并发送短消息 /// </summary> public void SendPM() { #region 创建并发送短消息 // 收件箱 if (useradminid == 1) { pm.Message = Utils.HtmlEncode(DNTRequest.GetString("message")); pm.Subject = Utils.HtmlEncode(DNTRequest.GetString("subject")); } else { pm.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("message"))); pm.Subject = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("subject"))); } if (useradminid != 1 && (ForumUtils.HasBannedWord(pm.Message) || ForumUtils.HasBannedWord(pm.Subject) || ForumUtils.HasAuditWord(pm.Message) || ForumUtils.HasAuditWord(pm.Subject))) { string bannedWord = ForumUtils.GetBannedWord(pm.Message) == string.Empty ? ForumUtils.GetBannedWord(pm.Subject) : ForumUtils.GetBannedWord(pm.Message); AddErrLine(string.Format("对不起, 您提交的内容包含不良信息 <font color=\"red\">{0}</font>, 因此无法提交, 请返回修改!", bannedWord)); return; } string Ignorepm = "," + Users.GetUserInfo(msgtoid).Ignorepm + ","; //禁止所有用户或当前用户在忽略列表内时 if (Ignorepm.IndexOf("{ALL}") >= 0 || Ignorepm.IndexOf("," + username + ",") >= 0) { AddErrLine("短消息发送失败!"); return; } pm.Message = ForumUtils.BanWordFilter(pm.Message); pm.Subject = ForumUtils.BanWordFilter(pm.Subject); pm.Msgto = DNTRequest.GetString("msgto"); pm.Msgtoid = msgtoid; pm.Msgfrom = username; pm.Msgfromid = userid; pm.New = 1; pm.Postdatetime = Utils.GetDateTime(); // 只将消息保存到草稿箱 if (!Utils.StrIsNullOrEmpty(DNTRequest.GetString("savetousercpdraftbox"))) { CreatePM(2, 0, "usercpdraftbox.aspx", "已将消息保存到草稿箱"); return; } else if (!Utils.StrIsNullOrEmpty(DNTRequest.GetString("savetosentbox")))// 发送消息且保存到发件箱 { CreatePM(0, 1, "usercpsentbox.aspx", "发送完毕, 且已将消息保存到发件箱"); } else// 发送消息但不保存到发件箱 { CreatePM(0, 0, "usercpinbox.aspx", "发送完毕"); } if (!IsErr()) { // 更新在线表中的用户最后发帖时间 OnlineUsers.UpdatePostPMTime(olid); //为在线用户更新短消息数 int targetolid = OnlineUsers.GetOlidByUid(pm.Msgtoid); if (targetolid > 0) { Users.UpdateUserNewPMCount(pm.Msgtoid, targetolid); } } #endregion }
/// <summary> /// 重置密码 /// </summary> public ActionResult ResetPwd() { string v = WebHelper.GetQueryString("v"); //解密字符串 string realV = SecureHelper.AESDecrypt(v, WorkContext.MallConfig.SecretKey); //数组第一项为uid,第二项为验证时间,第三项为随机值 string[] result = StringHelper.SplitString(realV); if (result.Length != 3) { return(HttpNotFound()); } int uid = TypeHelper.StringToInt(result[0]); DateTime time = TypeHelper.StringToDateTime(result[1]); PartUserInfo partUserInfo = Users.GetPartUserById(uid); if (partUserInfo == null) { return(PromptView("用户不存在")); } //判断验证时间是否过时 if (DateTime.Now.AddMinutes(-30) > time) { return(PromptView("此链接已经失效,请重新验证")); } //get请求 if (WebHelper.IsGet()) { ResetPwdModel model = new ResetPwdModel(); model.V = v; return(View(model)); } //ajax请求 string password = WebHelper.GetFormString("password"); string confirmPwd = WebHelper.GetFormString("confirmPwd"); StringBuilder errorList = new StringBuilder("["); //验证 if (string.IsNullOrWhiteSpace(password)) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "密码不能为空", "}"); } else if (password.Length < 4 || password.Length > 32) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "password", "密码必须大于3且不大于32个字符", "}"); } else if (password != confirmPwd) { errorList.AppendFormat("{0}\"key\":\"{1}\",\"msg\":\"{2}\"{3},", "{", "confirmPwd", "两次输入的密码不一样", "}"); } if (errorList.Length == 1) { //生成用户新密码 string p = Users.CreateUserPassword(password, partUserInfo.Salt); //设置用户新密码 Users.UpdateUserPasswordByUid(uid, p); //清空当前用户信息 WebHelper.DeleteCookie("bma"); Sessions.RemoverSession(WorkContext.Sid); OnlineUsers.DeleteOnlineUserBySid(WorkContext.Sid); return(AjaxResult("success", Url.Action("login"))); } else { return(AjaxResult("error", errorList.Remove(errorList.Length - 1, 1).Append("]").ToString(), true)); } }
protected override void ShowPage() { if (!DiscuzCloud.GetCloudServiceEnableStatus("connect")) { AddErrLine("QQ登录功能已关闭"); return; } switch (action) { case "access": if (!CheckCallbackSignature(DNTRequest.GetString("con_sig"))) { AddErrLine("非法请求"); return; } OAuthAccessTokenInfo tokenInfo = DiscuzCloud.GetConnectAccessTokenInfo(); if (tokenInfo == null) { AddErrLine("QQ登录过程中出现异常,请尝试再次登录"); return; } userconnectinfo = DiscuzCloud.GetUserConnectInfo(tokenInfo.Openid); if (userconnectinfo == null) { userconnectinfo = new UserConnectInfo(); userconnectinfo.OpenId = tokenInfo.Openid; userconnectinfo.Token = tokenInfo.Token; userconnectinfo.Secret = tokenInfo.Secret; userconnectinfo.AllowVisitQQUserInfo = DNTRequest.GetInt("con_is_user_info", 0); userconnectinfo.AllowPushFeed = DNTRequest.GetInt("con_is_feed", 0) == 1 ? 3 : 0; userconnectinfo.CallbackInfo = usedusernames + "&" + birthday + "&" + gender + "&" + email; DiscuzCloud.CreateUserConnectInfo(userconnectinfo); } else if (userconnectinfo.Uid > 0) { if (userid > 0) { SetBackLink("index.aspx"); AddErrLine(userconnectinfo.Uid != userid ? "该QQ已经绑定了其他帐号" : "该QQ用户已登录"); return; } ShortUserInfo userInfo = Users.GetShortUserInfo(userconnectinfo.Uid); string redirectUrl = ""; //如果userInfo==null,可能是管理员后台删除了这个帐号,则用户的ConnnectInfo也需要被解绑重置 if (userInfo == null) { DiscuzCloud.UnbindUserConnectInfo(userconnectinfo.OpenId); redirectUrl = HttpContext.Current.Request.RawUrl; } else { redirectUrl = forumpath + "index.aspx"; //如果云端的token和Secret发生改变,则更新本地保存的token和Secret if (tokenInfo.Token != userconnectinfo.Token || tokenInfo.Secret != userconnectinfo.Secret) { userconnectinfo.Token = tokenInfo.Token; userconnectinfo.Secret = tokenInfo.Secret; DiscuzCloud.UpdateUserConnectInfo(userconnectinfo); } LoginUser(userInfo); } HttpContext.Current.Response.Redirect(redirectUrl); HttpContext.Current.ApplicationInstance.CompleteRequest(); } else { string[] callbackInfo = userconnectinfo.CallbackInfo.Split('&'); if (callbackInfo.Length == 4) { usedusernames = string.IsNullOrEmpty(usedusernames) ? callbackInfo[0] : usedusernames; birthday = string.IsNullOrEmpty(birthday) ? callbackInfo[1] : birthday; gender = gender == 0 ? Utils.StrToInt(callbackInfo[2], 0) : gender; email = string.IsNullOrEmpty(email) ? callbackInfo[3] : email; } } UserBindConnectLog userBindLog = DiscuzCloud.GetUserConnectBindLog(userconnectinfo.OpenId); isbindoverflow = userBindLog != null && cloudconfig.Maxuserbindcount > 0 && userBindLog.BindCount >= cloudconfig.Maxuserbindcount; allowreg = config.Regstatus != 0 && cloudconfig.Allowconnectregister == 1 && !isbindoverflow; connectswitch = allowreg && userid < 0 ? 1 : 2; #region convert used username list byte[] bt = Convert.FromBase64String(usedusernames); usedusernames = System.Text.Encoding.Default.GetString(bt); #endregion avatarurl = string.Format("http://avatar.connect.discuz.qq.com/{0}/{1}", DiscuzCloudConfigs.GetConfig().Connectappid, userconnectinfo.OpenId); openid = userconnectinfo.OpenId; break; case "bind": if (ispost) { if (DNTRequest.GetString("bind_type") == "new") { RegisterAndBind(); } else { if (userid < 0) { BindForumExistedUser(); } else { BindLoginedUser(); } } } break; case "unbind": if (userid < 1) { AddErrLine("未登录用户无法进行该操作"); return; } userconnectinfo = DiscuzCloud.GetUserConnectInfo(userid); if (userconnectinfo == null) { AddErrLine("您并没有绑定过QQ,不需要执行该操作"); return; } if (ispost) { if (userconnectinfo.IsSetPassword == 0) { string passwd = DNTRequest.GetString("newpasswd"); if (string.IsNullOrEmpty(passwd)) { AddErrLine("您必须为帐号设置新密码才能解除绑定"); return; } if (passwd.Length < 6) { AddErrLine("密码不得少于6个字符"); return; } if (passwd != DNTRequest.GetString("confirmpasswd")) { AddErrLine("两次输入的新密码不一致"); return; } UserInfo userInfo = Users.GetUserInfo(userid); userInfo.Password = passwd; Users.ResetPassword(userInfo); //同步其他应用密码 Sync.UpdatePassword(userInfo.Username, userInfo.Password, ""); if (!Utils.StrIsNullOrEmpty(DNTRequest.GetString("changesecques"))) { Users.UpdateUserSecques(userid, DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer")); } ForumUtils.WriteCookie("password", ForumUtils.SetCookiePassword(userInfo.Password, config.Passwordkey)); OnlineUsers.UpdatePassword(olid, userInfo.Password); } DiscuzCloud.UnbindUserConnectInfo(userconnectinfo.OpenId); UserBindConnectLog bindLog = DiscuzCloud.GetUserConnectBindLog(userconnectinfo.OpenId); if (bindLog != null) { bindLog.Type = 2; DiscuzCloud.UpdateUserConnectBindLog(bindLog); } AddMsgLine("解绑成功"); string reurl = Utils.UrlDecode(ForumUtils.GetReUrl()); SetUrl(reurl.IndexOf("register.aspx") < 0 ? reurl : forumpath + "index.aspx"); SetMetaRefresh(); } break; default: if (isbindconnect) { AddErrLine("用户已登录"); return; } HttpContext.Current.Response.Redirect(DiscuzCloud.GetConnectLoginPageUrl(userid)); HttpContext.Current.ApplicationInstance.CompleteRequest(); break; } }
public override bool Run(CommandParameter commandParam, ref string result) { if (commandParam.GetDNTParam("auth_token") == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } string authToken = commandParam.GetDNTParam("auth_token").ToString().Replace("[", "+"); string a = Discuz.Common.DES.Decode(authToken, commandParam.AppInfo.Secret.Substring(0, 10)); string[] userstr = a.Split(','); if (userstr.Length != 3) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } int olid = Utils.StrToInt(userstr[0], -1); OnlineUserInfo oluser = OnlineUsers.GetOnlineUser(olid); if (oluser == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return(false); } string time = DateTime.Parse(oluser.Lastupdatetime).ToString("yyyy-MM-dd HH:mm:ss"); if (time != userstr[1]) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } byte[] md5_result = System.Security.Cryptography.MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(olid.ToString() + commandParam.AppInfo.Secret)); StringBuilder sessionkey_builder = new StringBuilder(); foreach (byte b in md5_result) { sessionkey_builder.Append(b.ToString("x2")); } string sessionkey = string.Format("{0}-{1}", sessionkey_builder.ToString(), oluser.Userid.ToString()); SessionInfo session = new SessionInfo(); session.SessionKey = sessionkey; session.UId = oluser.Userid; session.UserName = oluser.Username; session.Expires = Utils.StrToInt(userstr[2], 0); if (commandParam.Format == FormatType.JSON) { result = string.Format(@"{{""session_key"":""{0}"",""uid"":{1},""user_name"":""{2}"",""expires"":{3}}}", sessionkey, commandParam.LocalUid, session.UserName, session.Expires); } else { result = SerializationHelper.Serialize(session); } OnlineUsers.UpdateAction(olid, UserAction.Login.ActionID, 0, GeneralConfigs.GetConfig().Onlinetimeout); return(true); }
/// <summary> /// 初始化 /// </summary> /// <param name="e"></param> override protected void OnInit(EventArgs e) { base.OnInit(e); GeneralConfigInfo config = GeneralConfigs.GetConfig(); string bgcolor = DNTRequest.GetQueryString("bgcolor").Trim(); int textcolor = DNTRequest.GetQueryInt("textcolor", 1); string[] bgcolorArray = bgcolor.Split(','); Color bg = Color.White; if (bgcolorArray.Length == 1 && bgcolor != string.Empty) { bg = Utils.ToColor(bgcolor); } else if (bgcolorArray.Length == 3 && Utils.IsNumericArray(bgcolorArray)) { bg = Color.FromArgb(Utils.StrToInt(bgcolorArray[0], 255), Utils.StrToInt(bgcolorArray[1], 255), Utils.StrToInt(bgcolorArray[2], 255)); } VerifyImageInfo verifyimg = VerifyImageProvider.GetInstance(config.VerifyImageAssemly).GenerateImage(OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout).Verifycode, 120, 60, bg, textcolor); Bitmap image = verifyimg.Image; System.Web.HttpContext.Current.Response.ContentType = verifyimg.ContentType; image.Save(this.Response.OutputStream, verifyimg.ImageFormat); }
protected override void ShowPage() { #region 临时帐号发帖 //int realuserid = -1; //bool tempaccountspost = false; //string tempusername = DNTRequest.GetString("tempusername"); //if (!Utils.StrIsNullOrEmpty(tempusername) && tempusername != username) //{ // realuserid = Users.CheckTempUserInfo(tempusername, DNTRequest.GetString("temppassword"), DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer")); // if (realuserid == -1) // { // AddErrLine("临时帐号登录失败,无法继续发帖。"); // return; // } // else // { // userid = realuserid; // username = tempusername; // tempaccountspost = true; // } //} #endregion if (userid > 0) { userinfo = Users.GetShortUserInfo(userid); } #region 判断是否是灌水 AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); if (admininfo != null) { disablepost = admininfo.Disablepostctrl; } if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, userinfo, ref msg)) { if (continuereply != "") { AddErrLine("<b>回帖成功</b><br />由于" + msg + "后刷新继续"); } else { AddErrLine(msg); } return; } #endregion //获取主题帖信息 PostInfo postinfo = GetPostAndTopic(admininfo); if (IsErr()) { return; } forum = Forums.GetForumInfo(forumid); smileyoff = 1 - forum.Allowsmilies; bbcodeoff = (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) ? 0 : 1; allowimg = forum.Allowimgcode; needaudit = UserAuthority.NeedAudit(forum, useradminid, topic, userid, disablepost, usergroupinfo); #region 附件信息绑定 //得到用户可以上传的文件类型 string attachmentTypeSelect = Attachments.GetAllowAttachmentType(usergroupinfo, forum); attachextensions = Attachments.GetAttachmentTypeArray(attachmentTypeSelect); attachextensionsnosize = Attachments.GetAttachmentTypeString(attachmentTypeSelect); //得到今天允许用户上传的附件总大小(字节) int MaxTodaySize = (userid > 0 ? MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid) : 0); attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;//今天可上传得大小 //是否有上传附件的权限 canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg); if (canpostattach && (userinfo != null && userinfo.Uid > 0) && apb != null && config.Enablealbum == 1 && (UserGroups.GetUserGroupInfo(userinfo.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0)) { caninsertalbum = true; albumlist = apb.GetSpaceAlbumByUserId(userid); } #endregion if (!Utils.StrIsNullOrEmpty(forum.Password) && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } #region 访问和发帖权限校验 if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = true; return; } if (!UserAuthority.PostReply(forum, userid, usergroupinfo, topic)) { AddErrLine(topic.Closed == 1 ? "主题已关闭无法回复" : "您没有发表回复的权限"); needlogin = (topic.Closed == 1 ? false : true); return; } if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, userinfo, ref msg)) { AddErrLine(msg); return; } #endregion // 如果是受灌水限制用户, 则判断是否是灌水 if (admininfo != null) { disablepost = admininfo.Disablepostctrl; } if (forum.Templateid > 0) { templatepath = Templates.GetTemplateItem(forum.Templateid).Directory; } AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css"); customeditbuttons = Caches.GetCustomEditButtonList(); //如果是提交... if (ispost) { string backlink = (DNTRequest.GetInt("topicid", -1) > 0 ? string.Format("postreply.aspx?topicid={0}&restore=1&forumpage=" + forumpageid, topicid) : string.Format("postreply.aspx?postid={0}&restore=1&forumpage=" + forumpageid, postid)); if (!DNTRequest.GetString("quote").Equals("")) { backlink = string.Format("{0}"e={1}", backlink, DNTRequest.GetString("quote")); } SetBackLink(backlink); #region 验证提交信息 //常规项验证 NormalValidate(admininfo, postmessage, userinfo); if (IsErr()) { return; } #endregion //是否有上传附件的权限 canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg); // 产生新帖子 if (!string.IsNullOrEmpty(DNTRequest.GetFormString("toreplay_user").Trim())) { postmessage = DNTRequest.GetFormString("toreplay_user").Trim() + "\n\n" + postmessage; } postinfo = CreatePostInfo(postmessage); //获取被回复帖子的作者uid int replyUserid = postid > 0 ? Posts.GetPostInfo(topicid, postid).Posterid : postinfo.Posterid; postid = postinfo.Pid; if (IsErr()) { return; } //添加回复索引 PKS.Forum.Web.ForumExtension.SaveForumPostToIndex(forum, topic, postinfo); #region 当回复成功后,发送通知 if (postinfo.Pid > 0 && DNTRequest.GetString("postreplynotice") == "on") { Notices.SendPostReplyNotice(postinfo, topic, replyUserid); } #endregion //向第三方应用同步数据 Sync.Reply(postid.ToString(), topic.Tid.ToString(), topic.Title, postinfo.Poster, postinfo.Posterid.ToString(), topic.Fid.ToString(), ""); //更新主题相关信息 //UpdateTopicInfo(postmessage); #region 处理附件 //处理附件 StringBuilder sb = new StringBuilder(); AttachmentInfo[] attachmentinfo = null; string attachId = DNTRequest.GetFormString("attachid"); if (!string.IsNullOrEmpty(attachId)) { attachmentinfo = Attachments.GetNoUsedAttachmentArray(userid, attachId); Attachments.UpdateAttachment(attachmentinfo, topic.Tid, postinfo.Pid, postinfo, ref sb, userid, config, usergroupinfo); } //加入相册 if (config.Enablealbum == 1 && apb != null) { sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username)); } #endregion OnlineUsers.UpdateAction(olid, UserAction.PostReply.ActionID, forumid, forum.Name, topicid, topictitle); #region 设置提示信息和跳转链接 //辩论地址 if (topic.Special == 4) { SetUrl(Urls.ShowDebateAspxRewrite(topicid)); } else if (infloat == 0)//此处加是否弹窗提交判断是因为在IE6下弹窗提交会造成gettopicinfo, getpostlist(位于showtopic页面)被提交了两次 { SetUrl(string.Format("showtopic.aspx?forumpage={0}&topicid={1}&page=end&jump=pid#{2}", forumpageid, topicid, postid)); } if (DNTRequest.GetFormString("continuereply") == "on") { SetUrl("postreply.aspx?topicid=" + topicid + "&forumpage=" + forumpageid + "&continuereply=yes"); } if (sb.Length > 0) { UpdateUserCredits(Forums.GetValues(forum.Replycredits)); SetMetaRefresh(5); SetShowBackLink(true); if (infloat == 1) { AddErrLine(sb.ToString()); return; } else { AddMsgLine("<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表回复成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr></table>"); } } else { SetMetaRefresh(); SetShowBackLink(false); //上面已经进行用户组判断 if (postinfo.Invisible == 1) { AddMsgLine(string.Format("发表回复成功, 但需要经过审核才可以显示. {0}<br /><br />(<a href=\"" + base.ShowForumAspxRewrite(forumid, 0) + "\">点击这里返回 {1}</a>)", (DNTRequest.GetFormString("continuereply") == "on" ? "继续回复" : "返回该主题"), forum.Name)); } else { UpdateUserCredits(Forums.GetValues(forum.Replycredits)); MsgForward("postreply_succeed"); AddMsgLine(string.Format("发表回复成功, {0}<br />(<a href=\"" + base.ShowForumAspxRewrite(forumid, 0) + "\">点击这里返回 {1}</a>)<br />", (DNTRequest.GetFormString("continuereply") == "on" ? "继续回复" : "返回该主题"), forum.Name)); } } #endregion // 删除主题游客缓存 if (topic.Replies < (config.Ppp + 10)) { ForumUtils.DeleteTopicCacheFile(topicid); } //发送邮件通知 if (DNTRequest.GetString("emailnotify") == "on" && topic.Posterid != -1 && topic.Posterid != userid) { SendNotifyEmail(Users.GetShortUserInfo(topic.Posterid).Email.Trim(), postinfo, Utils.GetRootUrl(BaseConfigs.GetForumPath) + string.Format("showtopic.aspx?topicid={0}&page=end&jump=pid#{1}", topicid, postid)); } } }
public override bool Run(CommandParameter commandParam, ref string result) { if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.WEB) { result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList); return(false); } if (commandParam.LocalUid > 0) { result = Util.CreateErrorMessage(ErrorType.API_EC_USER_ONLINE, commandParam.ParamList); return(false); } if (!commandParam.CheckRequiredParams("user_name,password")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } if (LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), false) >= 5) { result = Util.CreateErrorMessage(ErrorType.API_EC_MORE_LOGIN_FAILED, commandParam.ParamList); return(false); } string loginName = commandParam.GetDNTParam("user_name").ToString(); string password = commandParam.GetDNTParam("password").ToString(); string passwordFormat = commandParam.CheckRequiredParams("password_format") ? commandParam.GetDNTParam("password_format").ToString() : ""; int expires = commandParam.GetIntParam("expires"); expires = expires > 0 ? expires : 999; int userId = -1; ShortUserInfo userInfo = new ShortUserInfo(); if (commandParam.GeneralConfig.Emaillogin == 1 && Utils.IsValidEmail(loginName)) { DataTable dt = Users.GetUserInfoByEmail(loginName); if (dt.Rows.Count == 0) { result = Util.CreateErrorMessage(ErrorType.API_EC_USER_NOT_EXIST, commandParam.ParamList); return(false); } if (dt.Rows.Count > 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SAME_USER_EMAIL, commandParam.ParamList); return(false); } loginName = dt.Rows[0]["username"].ToString(); userId = TypeConverter.ObjectToInt(dt.Rows[0]["uid"]); userInfo.Uid = userId; userInfo.Username = loginName; userInfo.Groupid = TypeConverter.ObjectToInt(dt.Rows[0]["groupid"]); userInfo.Groupexpiry = TypeConverter.ObjectToInt(dt.Rows[0]["groupexpiry"]); userInfo.Credits = TypeConverter.ObjectToInt(dt.Rows[0]["credits"]); userInfo.Email = dt.Rows[0]["email"].ToString(); userInfo.Password = dt.Rows[0]["password"].ToString(); } else { userId = Users.GetUserId(loginName); if (userId < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_USER_NOT_EXIST, commandParam.ParamList); return(false); } userInfo = Users.GetShortUserInfo(userId); } int uid = -1; if (passwordFormat == "") { switch (commandParam.GeneralConfig.Passwordmode) { case 0: //默认模式 { uid = Users.CheckPassword(loginName, password, true); break; } case 1: //动网兼容模式 { uid = Users.CheckDvBbsPassword(loginName, password); break; } } } else { uid = userInfo.Password == password ? userInfo.Uid : -1; } if (uid != userInfo.Uid) { LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), true); result = Util.CreateErrorMessage(ErrorType.API_EC_WRONG_PASSWORD, commandParam.ParamList); return(false); } #region 当前用户所在用户组为"禁止访问"或"等待激活"时 if ((userInfo.Groupid == 4 || userInfo.Groupid == 5) && userInfo.Groupexpiry != 0 && userInfo.Groupexpiry <= Utils.StrToInt(DateTime.Now.ToString("yyyyMMdd"), 0)) { //根据当前用户的积分获取对应积分用户组 UserGroupInfo groupInfo = CreditsFacade.GetCreditsUserGroupId(userInfo.Credits); Users.UpdateUserGroup(userInfo.Uid, userInfo.Groupid); } #endregion if (userInfo.Groupid == 5 || userInfo.Groupid == 8)// 5-禁止访问或者需要激活帐号的用户 { result = Util.CreateErrorMessage(ErrorType.API_EC_BANNED_USERGROUP, commandParam.ParamList); return(false); } #region 无延迟更新在线信息和相关用户信息 ForumUtils.WriteUserCookie(userInfo.Uid, expires, commandParam.GeneralConfig.Passwordkey, 0, -1); OnlineUserInfo oluserinfo = OnlineUsers.UpdateInfo(commandParam.GeneralConfig.Passwordkey, commandParam.GeneralConfig.Onlinetimeout, userInfo.Uid, ""); OnlineUsers.UpdateAction(oluserinfo.Olid, UserAction.Login.ActionID, 0); LoginLogs.DeleteLoginLog(DNTRequest.GetIP()); Users.UpdateUserCreditsAndVisit(userInfo.Uid, DNTRequest.GetIP()); #endregion result = "success"; result = commandParam.Format == FormatType.JSON ? string.Format("\"{0}\"", result) : SerializationHelper.Serialize(result); return(true); }
/// <summary> /// 获得会话 /// </summary> /// <returns></returns> public string GetSession() { string returnStr = ""; if (Signature != GetParam("sig").ToString()) { ErrorCode = (int)ErrorType.API_EC_SIGNATURE; return(returnStr); } if (GetParam("auth_token") == null) { ErrorCode = (int)ErrorType.API_EC_PARAM; return(returnStr); } string auth_token = GetParam("auth_token").ToString().Replace("[", "+"); string a = Discuz.Common.DES.Decode(auth_token, Secret.Substring(0, 10)); string[] userstr = a.Split(','); if (userstr.Length != 3) { ErrorCode = (int)ErrorType.API_EC_PARAM; return(returnStr); } int olid = Utils.StrToInt(userstr[0], -1); OnlineUserInfo oluser = OnlineUsers.GetOnlineUser(olid); if (oluser == null) { ErrorCode = (int)ErrorType.API_EC_SESSIONKEY; return(returnStr); } string time = DateTime.Parse(oluser.Lastupdatetime).ToString("yyyy-MM-dd HH:mm:ss"); if (time != userstr[1]) { ErrorCode = (int)ErrorType.API_EC_PARAM; return(returnStr); } byte[] md5_result = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(olid.ToString() + Secret)); StringBuilder sessionkey_builder = new StringBuilder(); foreach (byte b in md5_result) { sessionkey_builder.Append(b.ToString("x2")); } string sessionkey = string.Format("{0}-{1}", sessionkey_builder.ToString(), oluser.Userid.ToString()); SessionInfo session = new SessionInfo(); session.SessionKey = sessionkey; session.UId = oluser.Userid; session.UserName = oluser.Username; session.Expires = Utils.StrToInt(userstr[2], 0); if (Format == FormatType.JSON) { returnStr = string.Format(@"{{""session_key"":""{0}"",""uid"":{1},""user_name"":""{2}"",""expires"":{3}}}", sessionkey, Uid, session.UserName, session.Expires); } else { returnStr = SerializationHelper.Serialize(session); } OnlineUsers.UpdateAction(olid, UserAction.Login.ActionID, 0, GeneralConfigs.GetConfig().Onlinetimeout); return(returnStr); }
/// <summary> /// 为客户端创建令牌 /// </summary> /// <returns></returns> public string CreateToken() { string returnStr = ""; if (Signature != GetParam("sig").ToString()) { ErrorCode = (int)ErrorType.API_EC_SIGNATURE; return(returnStr); } //应用程序类型为Web的时候应用程序没有调用此方法的权限 if (this.App.ApplicationType == (int)ApplicationType.WEB) { ErrorCode = (int)ErrorType.API_EC_PERMISSION_DENIED; return(returnStr); } OnlineUserInfo oluserinfo = OnlineUsers.UpdateInfo(Config.Passwordkey, Config.Onlinetimeout); int olid = oluserinfo.Olid; string expires = string.Empty; DateTime expireUTCTime; TokenInfo token = new TokenInfo(); if (System.Web.HttpContext.Current.Request.Cookies["dnt"] == null || System.Web.HttpContext.Current.Request.Cookies["dnt"]["expires"] == null) { token.Token = ""; if (Format == FormatType.JSON) { returnStr = ""; } else { returnStr = SerializationHelper.Serialize(token); } return(returnStr); } expires = System.Web.HttpContext.Current.Request.Cookies["dnt"]["expires"].ToString(); ShortUserInfo userinfo = Discuz.Forum.Users.GetShortUserInfo(oluserinfo.Userid); expireUTCTime = DateTime.Parse(userinfo.Lastvisit).ToUniversalTime().AddSeconds(Convert.ToDouble(expires)); expires = Utils.ConvertToUnixTimestamp(expireUTCTime).ToString(); string time = string.Empty; if (oluserinfo == null) { time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } else { time = DateTime.Parse(oluserinfo.Lastupdatetime).ToString("yyyy-MM-dd HH:mm:ss"); } string authToken = Common.DES.Encode(string.Format("{0},{1},{2}", olid.ToString(), time, expires), this.Secret.Substring(0, 10)).Replace("+", "["); token.Token = authToken; if (Format == FormatType.JSON) { returnStr = authToken; } else { returnStr = SerializationHelper.Serialize(token); } return(returnStr); }
protected override void ShowPage() { if (config.Enablemall == 0) //未启用交易模式 { AddErrLine("系统未开启交易模式, 当前页面暂时无法访问!"); return; } #region 临时帐号发帖 //int realuserid = -1; //string tempusername = DNTRequest.GetString("tempusername"); //if (tempusername != "" && tempusername != username) //{ // string temppassword = DNTRequest.GetString("temppassword"); // int question = DNTRequest.GetInt("question", 0); // string answer = DNTRequest.GetString("answer"); // realuserid = Users.CheckTempUserInfo(tempusername, temppassword, question, answer); // if (realuserid == -1) // { // AddErrLine("临时帐号登录失败,无法继续发帖。"); // return; // } // else // { // userid = realuserid; // username = tempusername; // usergroupinfo = UserGroups.GetUserGroupInfo(Users.GetShortUserInfo(userid).Groupid); // usergroupid = usergroupinfo.Groupid; // useradminid = Users.GetShortUserInfo(userid).Adminid; // } //} #endregion canhtmltitle = true; firstpagesmilies = Caches.GetSmiliesFirstPageCache(); //内容设置为空; message = ""; int goodsid = DNTRequest.GetInt("goodsid", 0); // 如果商品交易日志不正确 if (goodsid <= 0) { AddErrLine("错误的商品ID."); return; } goodsinfo = Goods.GetGoodsInfo(goodsid); if (goodsinfo == null || goodsinfo.Goodsid <= 0) { AddErrLine("错误的商品ID."); return; } goodscategoryinfo = GoodsCategories.GetGoodsCategoryInfoById(goodsinfo.Categoryid); if (goodscategoryinfo == null && goodscategoryinfo.Fid <= 0) { goodscategoryinfo = new Goodscategoryinfo(); goodscategoryinfo.Categoryid = -1; } attachmentlist = GoodsAttachments.GetGoodsAttachmentsByGoodsid(goodsinfo.Goodsid); message = goodsinfo.Message; // 如果商品交易日志不正确 if (goodsinfo.Selleruid != userid) { AddErrLine("您不是当前商品的卖家!"); return; } allowpostgoods = true; if (config.Enablemall == 1) //开启普通模式 { forumid = GoodsCategories.GetCategoriesFid(goodsinfo.Categoryid); allowpostgoods = false; forumnav = ""; if (forumid == -1) { if (userid == goodsinfo.Selleruid) { forum = new ForumInfo(); forum.Attachextensions = ""; forum.Password = ""; forum.Permuserlist = ""; } else { AddErrLine("错误的商品分类ID"); return; } } else { forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Layer == 0) { AddErrLine("错误的商品分类ID"); return; } if (forum.Istrade <= 0) { AddErrLine("当前版块不允许编辑商品"); return; } forumname = forum.Name; pagetitle = Utils.RemoveHtml(forum.Name); forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); enabletag = (config.Enabletag & forum.Allowtag) == 1; } } else if (config.Enablemall == 2) //当为高级模式时 { pagetitle = "编辑商品"; forumnav = ""; enabletag = true; forum = new ForumInfo(); forum.Allowsmilies = 1; forum.Allowbbcode = 1; } //得到用户可以上传的文件类型 StringBuilder sbAttachmentTypeSelect = new StringBuilder(); if (!usergroupinfo.Attachextensions.Trim().Equals("")) { sbAttachmentTypeSelect.Append("[id] in ("); sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions); sbAttachmentTypeSelect.Append(")"); } if (config.Enablemall == 1) //开启普通模式 { if (!forum.Attachextensions.Equals("")) { if (sbAttachmentTypeSelect.Length > 0) { sbAttachmentTypeSelect.Append(" AND "); } sbAttachmentTypeSelect.Append("[id] in ("); sbAttachmentTypeSelect.Append(forum.Attachextensions); sbAttachmentTypeSelect.Append(")"); } } attachextensions = Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()); attachextensionsnosize = Attachments.GetAttachmentTypeString(sbAttachmentTypeSelect.ToString()); //得到今天允许用户上传的附件总大小(字节) int MaxTodaySize = 0; if (userid > 0) { MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid); //今天已上传大小 } attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize; //今天可上传得大小 parseurloff = 0; bbcodeoff = 1; if (config.Enablemall == 1) //开启普通模式 { smileyoff = 1 - forum.Allowsmilies; if (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) { bbcodeoff = 0; } allowimg = forum.Allowimgcode; if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } if (!Forums.AllowViewByUserId(forum.Permuserlist, userid)) //判断当前用户在当前版块浏览权限 { if (forum.Viewperm == null || forum.Viewperm == string.Empty) //当板块权限为空时,按照用户组权限 { if (useradminid != 1 && (usergroupinfo.Allowvisit != 1 || usergroupinfo.Allowtrade != 1)) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该版块的权限"); return; } } else//当板块权限不为空,按照板块权限 { if (!Forums.AllowView(forum.Viewperm, usergroupid)) { AddErrLine("您没有浏览该商品分类的权限"); return; } } } //当前用户是卖家时 if (goodsinfo.Selleruid == userid) { //当前用户是否有允许下载附件权限 if (Forums.AllowGetAttachByUserID(forum.Permuserlist, userid)) { allowviewattach = true; } else { if (forum.Getattachperm == null || forum.Getattachperm == string.Empty)//权限设置为空时,根据用户组权限判断 { // 验证用户是否有有允许下载附件权限 if (usergroupinfo.Allowgetattach == 1) { allowviewattach = true; } } else if (Forums.AllowGetAttach(forum.Getattachperm, usergroupid)) { allowviewattach = true; } } //是否有上传附件的权限 if (Forums.AllowPostAttachByUserID(forum.Permuserlist, userid)) { canpostattach = true; } else { if (forum.Postattachperm == "") { if (usergroupinfo.Allowpostattach == 1) { canpostattach = true; } } else { if (Forums.AllowPostAttach(forum.Postattachperm, usergroupid)) { canpostattach = true; } } } } } else if (config.Enablemall == 2) //当为高级模式时 { canpostattach = true; allowimg = 1; smileyoff = 0; } ShortUserInfo user = Users.GetShortUserInfo(userid); if (canpostattach && user != null && apb != null && config.Enablealbum == 1 && (UserGroups.GetUserGroupInfo(user.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0)) { caninsertalbum = true; albumlist = apb.GetSpaceAlbumByUserId(userid); } else { caninsertalbum = false; } if (Topics.GetMagicValue(goodsinfo.Magic, MagicType.HtmlTitle) == 1) { htmltitle = Goods.GetHtmlTitle(goodsinfo.Goodsid).Replace("\"", "\\\"").Replace("'", "\\'"); } if (enabletag && Topics.GetMagicValue(goodsinfo.Magic, MagicType.TopicTag) == 1) { foreach (TagInfo tag in GoodsTags.GetTagsListByGoods(goodsinfo.Goodsid)) { if (tag.Orderid > -1) { goodstags += string.Format(" {0}", tag.Tagname); } } goodstags = goodstags.Trim(); } // 如果是受灌水限制用户, 则判断是否是灌水 AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid); disablepost = (admininfo != null) ? admininfo.Disablepostctrl : 0; creditstrans = Scoresets.GetCreditsTrans(); userextcreditsinfo = Scoresets.GetScoreSet(creditstrans); if (userid > 0) { spaceid = Users.GetShortUserInfo(userid).Spaceid; } //如果不是提交... if (!ispost) { AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css"); smilies = Caches.GetSmiliesCache(); smilietypes = Caches.GetSmilieTypesCache(); customeditbuttons = Caches.GetCustomEditButtonList(); } else { SetBackLink(string.Format("postgoods.aspx?forumid={0}&restore=1", forumid)); string postmessage = DNTRequest.GetString("message"); ForumUtils.WriteCookie("postmessage", postmessage); if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } if (DNTRequest.GetString("title").Trim().Equals("")) { AddErrLine("商品标题不能为空"); } else if (DNTRequest.GetString("title").IndexOf(" ") != -1) { AddErrLine("商品标题不能包含全角空格符"); } else if (DNTRequest.GetString("title").Length > 60) { AddErrLine("商品标题最大长度为60个字符,当前为 " + DNTRequest.GetString("title").Length.ToString() + " 个字符"); } if (postmessage.Equals("") || postmessage.Replace(" ", "").Equals("")) { AddErrLine("商品内容不能为空"); } if (admininfo != null && admininfo.Disablepostctrl != 1) { if (postmessage.Length < config.Minpostsize) { AddErrLine("您发表的内容过少, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字"); } else if (postmessage.Length > config.Maxpostsize) { AddErrLine("您发表的内容过多, 系统设置要求商品内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字"); } } if (IsErr()) { return; } // 如果用户上传了附件,则检测用户是否有上传附件的权限 if (ForumUtils.IsPostFile()) { if (Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()).Trim() == "") { AddErrLine("系统不允许上传附件"); } if (config.Enablemall == 1) //开启普通模式 { if (!Forums.AllowPostAttachByUserID(forum.Permuserlist, userid)) { if (!Forums.AllowPostAttach(forum.Postattachperm, usergroupid)) { AddErrLine("您没有在该版块上传附件的权限"); } else if (usergroupinfo.Allowpostattach != 1) { AddErrLine(string.Format("您当前的身份 \"{0}\" 没有上传附件的权限", usergroupinfo.Grouptitle)); } } } } if (IsErr()) { return; } int iconid = DNTRequest.GetInt("iconid", 0); if (iconid > 15 || iconid < 0) { iconid = 0; } string curdatetime = Utils.GetDateTime(); goodsinfo.Shopid = 0; //商品分类原值 int oldgoodscategoryid = goodsinfo.Categoryid; //商品父分类原值 string oldparentcategorylist = goodsinfo.Parentcategorylist; //当商品分类发生变化时 if (DNTRequest.GetInt("goodscategoryid", 0) != 0 && goodsinfo.Categoryid != DNTRequest.GetInt("goodscategoryid", 0)) { goodsinfo.Categoryid = DNTRequest.GetInt("goodscategoryid", 0); goodsinfo.Parentcategorylist = GoodsCategories.GetParentCategoryList(goodsinfo.Categoryid); } goodsinfo.Recommend = DNTRequest.GetString("recommend") == "on" ? 1 : 0; goodsinfo.Discount = DNTRequest.GetInt("discount", 0); goodsinfo.Selleruid = userid; goodsinfo.Seller = username; goodsinfo.Account = DNTRequest.GetString("account"); goodsinfo.Price = Convert.ToDecimal(DNTRequest.GetFormFloat("price", 1).ToString()); goodsinfo.Amount = DNTRequest.GetInt("amount", 0); goodsinfo.Quality = DNTRequest.GetInt("quality", 0); if (DNTRequest.GetInt("locus_2", 0) != 0) { goodsinfo.Lid = DNTRequest.GetInt("locus_2", 0); goodsinfo.Locus = Locations.GetLocusByLID(goodsinfo.Lid); } goodsinfo.Transport = DNTRequest.GetInt("transport", 0); if (goodsinfo.Transport != 0) { goodsinfo.Ordinaryfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_mail", 0).ToString()); goodsinfo.Expressfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_express", 0).ToString()); goodsinfo.Emsfee = Convert.ToDecimal(DNTRequest.GetFormFloat("postage_ems", 0).ToString()); } goodsinfo.Itemtype = DNTRequest.GetInt("itemtype", 0); DateTime dateline; switch (DNTRequest.GetInt("_now", 0)) { case 1: dateline = Convert.ToDateTime(string.Format("{0} {1}:{2}:00", DNTRequest.GetString("_date"), DNTRequest.GetInt("_hour", 0), DNTRequest.GetInt("_minute", 0))); break; //设定 case 2: dateline = Convert.ToDateTime("1900-01-01 00:00:00"); break; //返回100年之后的日期作为"暂不设置" default: dateline = DateTime.Now; break; //立即 } goodsinfo.Dateline = dateline; goodsinfo.Expiration = Convert.ToDateTime(DNTRequest.GetString("expiration")); goodsinfo.Lastbuyer = ""; goodsinfo.Lastupdate = DateTime.Now; goodsinfo.Totalitems = 0; goodsinfo.Tradesum = 0; goodsinfo.Closed = 0; goodsinfo.Aid = 0; int displayorder = goodsinfo.Displayorder; goodsinfo.Displayorder = DNTRequest.GetString("displayorder") == "on" ? 0 : -3; if (config.Enablemall == 1) //当为版块交易帖是时 { if (forum.Modnewposts == 1 && useradminid != 1) { if (useradminid > 1) { if (disablepost != 1) { goodsinfo.Displayorder = -2; } } else { goodsinfo.Displayorder = -2; } } } goodsinfo.Costprice = Convert.ToDecimal(DNTRequest.GetFormFloat("costprice", 1).ToString()); goodsinfo.Invoice = DNTRequest.GetInt("invoice", 0); goodsinfo.Repair = DNTRequest.GetInt("repair", 0); if (useradminid == 1) { goodsinfo.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(postmessage)); } else { goodsinfo.Message = Utils.HtmlEncode(postmessage); } goodsinfo.Otherlink = ""; int readperm = DNTRequest.GetInt("readperm", 0); goodsinfo.Readperm = readperm > 255 ? 255 : readperm; goodsinfo.Tradetype = DNTRequest.GetInt("tradetype", 0); if (goodsinfo.Tradetype == 1 && Utils.StrIsNullOrEmpty(goodsinfo.Account)) //当为支付宝在线支付方式下,如果"支付宝账户"为空时 { AddErrLine("请输入支付宝帐号信息。"); return; } goodsinfo.Smileyoff = smileyoff; if (smileyoff == 0 && forum.Allowsmilies == 1) { goodsinfo.Smileyoff = Utils.StrToInt(DNTRequest.GetString("smileyoff"), 0); } goodsinfo.Bbcodeoff = 1; if (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1) { goodsinfo.Bbcodeoff = Utils.StrToInt(DNTRequest.GetString("bbcodeoff"), 0); } goodsinfo.Parseurloff = Utils.StrToInt(DNTRequest.GetString("parseurloff"), 0); if (useradminid == 1) { goodsinfo.Title = Utils.HtmlEncode(DNTRequest.GetString("title")); } else { goodsinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("title"))); } string htmltitle = DNTRequest.GetString("htmltitle").Trim(); if (htmltitle != string.Empty && Utils.HtmlDecode(htmltitle).Trim() != goodsinfo.Title) { goodsinfo.Magic = 11000; //按照 附加位/htmltitle(1位)/magic(3位)/以后扩展(未知位数) 的方式来存储 //例: 11001 } //标签(Tag)操作 string tags = DNTRequest.GetString("tags").Trim(); string[] tagsArray = null; if (enabletag && tags != string.Empty) { tagsArray = Utils.SplitString(tags, " ", true, 2, 10); if (tagsArray.Length > 0) { if (goodsinfo.Magic == 0) { goodsinfo.Magic = 10000; } goodsinfo.Magic = Utils.StrToInt(goodsinfo.Magic.ToString() + "1", 0); } } Goods.UpdateGoods(goodsinfo, oldgoodscategoryid, oldparentcategorylist); if (displayorder != goodsinfo.Displayorder) //当发生变化时 { if (displayorder < 0 && goodsinfo.Displayorder > 0) //该商品转为上架 { DbProvider.GetInstance().UpdateCategoryGoodsCounts(goodsinfo.Categoryid, goodsinfo.Parentcategorylist, 1); } else if (displayorder >= 0 && goodsinfo.Displayorder < 0) //该商品转为下架(或进入回收站/待审核状态) { DbProvider.GetInstance().UpdateCategoryGoodsCounts(goodsinfo.Categoryid, goodsinfo.Parentcategorylist, -1); } } //保存htmltitle if (canhtmltitle && htmltitle != string.Empty && htmltitle != goodsinfo.Title) { Goods.WriteHtmlSubjectFile(htmltitle, goodsinfo.Goodsid); } if (enabletag && tagsArray != null && tagsArray.Length > 0) { DbProvider.GetInstance().CreateGoodsTags(string.Join(" ", tagsArray), goodsinfo.Goodsid, userid, curdatetime); GoodsTags.WriteGoodsTagsCacheFile(goodsinfo.Goodsid); } StringBuilder sb = new StringBuilder(); sb.Remove(0, sb.Length); //编辑帖子时如果进行了批量删除附件 string delAttId = DNTRequest.GetFormString("deleteaid"); if (delAttId != string.Empty) { if (Utils.IsNumericList(delAttId))//如果要删除的附件ID列表为数字数组 { GoodsAttachments.DeleteGoodsAttachment(delAttId); } } //编辑帖子时如果进行了更新附件操作 string updatedAttId = DNTRequest.GetFormString("attachupdatedid"); //被更新的附件Id列表 string updateAttId = DNTRequest.GetFormString("attachupdateid"); //所有已上传的附件Id列表 string[] descriptionArray = DNTRequest.GetFormString("attachupdatedesc").Split(','); //所有已上传的附件的描述 string[] readpermArray = DNTRequest.GetFormString("attachupdatereadperm").Split(','); //所有已上传得附件的阅读权限 ArrayList updateAttArrayList = new ArrayList(); if (updateAttId != string.Empty) { foreach (string s in updateAttId.Split(',')) { if (!Utils.InArray(s, delAttId, ","))//已上传的附件Id不在被删除的附件Id列表中时 { updateAttArrayList.Add(s); } } } string[] updateAttArray = (string[])updateAttArrayList.ToArray(typeof(string)); if (updateAttId != string.Empty)//原来有附件 { int watermarkstate = config.Watermarkstatus; if (forum.Disablewatermark == 1) { watermarkstate = 0; } string[] updatedAttArray = updatedAttId.Split(','); string filekey = "attachupdated"; //保存新的文件 Goodsattachmentinfo[] attArray = Discuz.Mall.MallUtils.SaveRequestFiles( goodsinfo.Categoryid, config.Maxattachments + updateAttArray.Length, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, watermarkstate, config, filekey); if (Utils.IsNumericArray(updateAttArray)) { for (int i = 0; i < updateAttArray.Length; i++) //遍历原来所有附件 { string attachmentId = updateAttArray[i]; if (Utils.InArray(attachmentId, updatedAttArray)) //附件文件被更新 { if (Utils.InArray(attachmentId, delAttId, ",")) //附件进行了删除操作, 则不操作此附件,即使其也被更新 { continue; } //更新附件 int attachmentUpdatedIndex = GetAttachmentUpdatedIndex(attachmentId, updatedAttArray); //获取此次上传的被更新附件在数组中的索引 if (attachmentUpdatedIndex > -1) //附件索引存在 { if (attArray[attachmentUpdatedIndex].Sys_noupload.Equals(string.Empty)) //由此属性为空可以判断上传成功 { //获取将被更新的附件信息 Goodsattachmentinfo attachmentInfo = GoodsAttachments.GetGoodsAttachmentsByAid(Utils.StrToInt(updatedAttArray[attachmentUpdatedIndex], 0)); if (attachmentInfo != null) { if (attachmentInfo.Filename.Trim().ToLower().IndexOf("http") < 0) { //删除原来的文件 File.Delete(Utils.GetMapPath(BaseConfigs.GetForumPath + "upload/" + attachmentInfo.Filename)); } //记住Aid以便稍后更新 attArray[attachmentUpdatedIndex].Aid = attachmentInfo.Aid; attArray[attachmentUpdatedIndex].Description = descriptionArray[i]; int att_readperm = Utils.StrToInt(readpermArray[i], 0); att_readperm = att_readperm > 255 ? 255 : att_readperm; attArray[attachmentUpdatedIndex].Readperm = att_readperm; attArray[attachmentUpdatedIndex].Categoryid = attachmentInfo.Categoryid; attArray[attachmentUpdatedIndex].Goodscount = attachmentInfo.Goodscount; attArray[attachmentUpdatedIndex].Goodsid = attachmentInfo.Goodsid; GoodsAttachments.SaveGoodsAttachment(attArray[attachmentUpdatedIndex]); } } else //上传失败的附件,稍后提示 { sb.Append("<tr><td align=\"left\">"); sb.Append(attArray[attachmentUpdatedIndex].Attachment); sb.Append("</td>"); sb.Append("<td align=\"left\">"); sb.Append(attArray[attachmentUpdatedIndex].Sys_noupload); sb.Append("</td></tr>"); } } } else //仅修改了阅读权限和描述等 { if (Utils.InArray(updateAttArray[i], delAttId, ",")) { continue; } if ((attachmentlist[i].Readperm.ToString() != readpermArray[i]) || (attachmentlist[i].Description.Trim() != descriptionArray[i])) { int att_readperm = Utils.StrToInt(readpermArray[i], 0); att_readperm = att_readperm > 255 ? 255 : att_readperm; GoodsAttachments.SaveGoodsAttachment(Utils.StrToInt(updateAttArray[i], 0), att_readperm, descriptionArray[i]); } } } } } int watermarkstatus = config.Watermarkstatus; if (forum.Disablewatermark == 1) { watermarkstatus = 0; } Goodsattachmentinfo[] attachmentinfo = Discuz.Mall.MallUtils.SaveRequestFiles(forumid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, watermarkstatus, config, "postfile"); if (attachmentinfo != null) { if (attachmentinfo.Length > config.Maxattachments) { AddErrLine("系统设置为每个商品附件不得多于" + config.Maxattachments + "个"); return; } int errorAttachment = GoodsAttachments.BindAttachment(attachmentinfo, goodsinfo.Goodsid, sb, goodsinfo.Categoryid, userid); int[] aid = GoodsAttachments.CreateAttachments(attachmentinfo); string tempMessage = GoodsAttachments.FilterLocalTags(aid, attachmentinfo, goodsinfo.Message); if (attachmentinfo.Length == (System.Web.HttpContext.Current.Request.Files.Count - 2)) { goodsinfo.Goodspic = attachmentinfo[0].Filename; goodsinfo.Aid = aid[0]; } if (!tempMessage.Equals(goodsinfo.Message)) { goodsinfo.Message = tempMessage; } Goods.UpdateGoods(goodsinfo); UserCredits.UpdateUserExtCreditsByUploadAttachment(userid, aid.Length - errorAttachment); } //加入相册 if (config.Enablealbum == 1 && apb != null) { sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username)); } if (config.Enablemall == 1) //开启普通模式 { OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forumname, -1, ""); } if (sb.Length > 0) { SetUrl(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid)); SetMetaRefresh(5); SetShowBackLink(true); sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发布商品成功,但以下附件上传失败:</nobr></span><br /></td></tr>"); sb.Append("</table>"); AddMsgLine(sb.ToString()); } else { SetShowBackLink(false); if (config.Enablemall == 1 && forum.Modnewposts == 1 && useradminid != 1) { if (useradminid != 1) { if (disablepost == 1) { if (goodsinfo.Displayorder == -3) { SetUrl(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1)); SetMetaRefresh(5); AddMsgLine("编辑商品成功, 但未上架. 您可到用户中心进行上架操作!"); } else { SetUrl(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid)); SetMetaRefresh(); AddMsgLine("编辑商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回 " + forumname + "</a>)<br />"); } } else { SetUrl(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1)); SetMetaRefresh(); AddMsgLine("编辑商品成功, 但需要经过审核才可以显示. 返回商品列表"); } } else { SetUrl(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1)); SetMetaRefresh(); AddMsgLine("发布商品成功, 返回商品列表"); } } else { if (goodsinfo.Displayorder == -3) { SetUrl(base.ShowGoodsListAspxRewrite(goodsinfo.Categoryid, 1)); SetMetaRefresh(5); AddMsgLine("编辑商品成功, 但未上架. 您可到用户中心进行上架操作!"); } else { SetUrl(base.ShowGoodsAspxRewrite(goodsinfo.Goodsid)); SetMetaRefresh(); AddMsgLine("编辑商品成功, 返回该商品<br />(<a href=\"" + base.ShowGoodsAspxRewrite(goodsinfo.Goodsid) + "\">点击这里返回</a>)<br />"); } } } ForumUtils.WriteCookie("postmessage", ""); } topicattachscorefield = 0; }
private string condition = ""; //查询条件 protected override void ShowPage() { if (config.Enablemall == 0) //未启用交易模式 { AddErrLine("系统未开启交易模式, 当前页面暂时无法访问!"); return; } else { goodscategoryfid = Discuz.Mall.GoodsCategories.GetGoodsCategoryWithFid(); } forumnav = ""; forumallowrss = 0; if (categoryid <= 0) { AddErrLine("无效的商品分类ID"); return; } if (config.Enablemall == 2) //开启高级模式 { AddLinkRss("mallgoodslist.aspx?categoryid=" + categoryid, "商品列表"); AddErrLine("当前页面在开启商城(高级)模式下无法访问, 系统将会重定向到商品列表页面!"); return; } goodscategoryinfo = GoodsCategories.GetGoodsCategoryInfoById(categoryid); if (goodscategoryinfo != null && goodscategoryinfo.Categoryid > 0) { forumid = GoodsCategories.GetCategoriesFid(goodscategoryinfo.Categoryid); } else { AddErrLine("无效的商品分类ID"); return; } ///得到广告列表 ///头部 headerad = Advertisements.GetOneHeaderAd("", forumid); footerad = Advertisements.GetOneFooterAd("", forumid); pagewordad = Advertisements.GetPageWordAd("", forumid); doublead = Advertisements.GetDoubleAd("", forumid); floatad = Advertisements.GetFloatAd("", forumid); mediaad = Advertisements.GetMediaAd(templatepath, "", forumid); disablepostctrl = 0; if (userid > 0 && useradminid > 0) { admingroupinfo = AdminGroups.GetAdminGroupInfo(usergroupid); } if (admingroupinfo != null) { this.disablepostctrl = admingroupinfo.Disablepostctrl; } if (forumid == -1) { AddLinkRss("tools/rss.aspx", "最新商品"); AddErrLine("无效的商品分类ID"); return; } else { forum = Forums.GetForumInfo(forumid); // 检查是否具有版主的身份 if (useradminid > 0) { ismoder = Moderators.IsModer(useradminid, userid, forumid); } #region 对搜索条件进行检索 string orderStr = "goodsid"; if (DNTRequest.GetString("search").Trim() != "") //进行指定查询 { //所在城市信息 cond = DNTRequest.GetInt("locus_2", -1); if (cond < 1) { condition = ""; } else { locus = Locations.GetLocusByLID(cond); condition = "AND [lid] = " + cond; } //排序的字段 order = DNTRequest.GetInt("order", -1); switch (order) { case 2: orderStr = "expiration"; //到期日 break; case 1: orderStr = "price"; //商品价格 break; default: orderStr = "goodsid"; break; } if (DNTRequest.GetInt("direct", -1) == 0) { direct = 0; } } #endregion if (forum == null) { if (config.Rssstatus == 1) { AddLinkRss("tools/rss.aspx", Utils.EncodeHtml(config.Forumtitle) + " 最新商品"); } AddErrLine("不存在的商品分类ID"); return; } //当版块有外部链接时,则直接跳转 if (forum.Redirect != null && forum.Redirect != string.Empty) { System.Web.HttpContext.Current.Response.Redirect(forum.Redirect); return; } if (forum.Istrade <= 0) { AddErrLine("当前版块不允许商品交易"); forumnav = ""; return; } if (forum.Fid < 1) { if (config.Rssstatus == 1 && forum.Allowrss == 1) { AddLinkRss("tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新商品"); } AddErrLine("不存在的商品分类ID"); return; } if (config.Rssstatus == 1) { AddLinkRss("tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新商品"); } forumname = forum.Name; pagetitle = Utils.RemoveHtml(forum.Name); subforumcount = forum.Subforumcount; forumnav = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname); navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname); //更新页面Meta中的Description项, 提高SEO友好性 UpdateMetaInfo(config.Seokeywords, forum.Description, config.Seohead); // 是否显示版块密码提示 1为显示, 0不显示 showforumlogin = 1; // 如果版块未设密码 if (forum.Password == "") { showforumlogin = 0; } else { // 如果检测到相应的cookie正确 if (Utils.MD5(forum.Password) == ForumUtils.GetCookie("forum" + forumid.ToString() + "password")) { showforumlogin = 0; } else { // 如果用户提交的密码正确则保存cookie if (forum.Password == DNTRequest.GetString("forumpassword")) { ForumUtils.WriteCookie("forum" + forumid.ToString() + "password", Utils.MD5(forum.Password)); showforumlogin = 0; } } } if (!Forums.AllowViewByUserId(forum.Permuserlist, userid)) //判断当前用户在当前版块浏览权限 { if (forum.Viewperm == null || forum.Viewperm == string.Empty) //当板块权限为空时,按照用户组权限 { if (useradminid != 1 && (usergroupinfo.Allowvisit != 1 || usergroupinfo.Allowtrade != 1)) { AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该商品分类的权限"); if (userid == -1) { needlogin = true; } return; } } else //当板块权限不为空,按照板块权限 { if (!Forums.AllowView(forum.Viewperm, usergroupid)) { AddErrLine("您没有浏览该商品分类的权限"); if (userid == -1) { needlogin = true; } return; } } } ////判断是否有发主题的权限 if (userid > -1 && Forums.AllowPostByUserID(forum.Permuserlist, userid)) { canposttopic = true; } if (forum.Postperm == null || forum.Postperm == string.Empty) //权限设置为空时,根据用户组权限判断 { // 验证用户是否有发表交易的权限 if (usergroupinfo.Allowtrade == 1) { canposttopic = true; } } else if (Forums.AllowPost(forum.Postperm, usergroupid)) { canposttopic = true; } // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖 if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1) { string visittime = ""; if (Scoresets.BetweenTime(config.Postbanperiods, out visittime)) { canposttopic = false; } } if (newpmcount > 0) { pmlist = PrivateMessages.GetPrivateMessageListForIndex(userid, 5, 1, 1); showpmhint = Convert.ToInt32(Users.GetShortUserInfo(userid).Newsletter) > 4; } //得到子分类JSON格式 subcategoriesjson = GoodsCategories.GetSubCategoriesJson(categoryid); //得到当前用户请求的页数 pageid = DNTRequest.GetInt("page", 1); //获取主题总数 goodscount = Goods.GetGoodsCount(categoryid, condition); // 得到gpp设置 if (gpp <= 0) { gpp = config.Gpp; } if (gpp <= 0) { gpp = 16; } //修正请求页数中可能的错误 if (pageid < 1) { pageid = 1; } if (forum.Layer > 0) { //获取总页数 pagecount = goodscount % gpp == 0 ? goodscount / gpp : goodscount / gpp + 1; if (pagecount == 0) { pagecount = 1; } if (pageid > pagecount) { pageid = pagecount; } goodslist = Goods.GetGoodsInfoList(categoryid, gpp, pageid, condition, orderStr, direct); ForumUtils.WriteCookie("referer", string.Format("showgoodslist.aspx?categoryid={0}&page={1}&order={2}&direct={3}&locus2={4}&search={5}", categoryid.ToString(), pageid.ToString(), orderStr, direct, cond, DNTRequest.GetString("search"))); //得到页码链接 if (DNTRequest.GetString("search") == "") { if (categoryid == 0) { if (config.Aspxrewrite == 1) { pagenumbers = Utils.GetStaticPageNumbers(pageid, pagecount, "showgoodslist-" + categoryid.ToString(), config.Extname, 8); } else { pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showgoodslist.aspx?categoryid=" + categoryid.ToString(), 8); } } else //当有类型条件时 { pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showgoodslist.aspx?categoryid=" + categoryid, 8); } } else { pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "showgoodslist.aspx?search=" + DNTRequest.GetString("search") + "&order=" + 2 + "&direct=" + direct + "&categoryid=" + categoryid + "&locus_2=" + cond, 8); } } } forumlistboxoptions = Caches.GetForumListBoxOptionsCache(); OnlineUsers.UpdateAction(olid, UserAction.ShowForum.ActionID, forumid, forumname, -1, ""); showforumonline = false; onlineiconlist = Caches.GetOnlineGroupIconList(); if (forumtotalonline < config.Maxonlinelist || DNTRequest.GetString("showonline") == "yes") { showforumonline = true; onlineuserlist = OnlineUsers.GetForumOnlineUserCollection(forumid, out forumtotalonline, out forumtotalonlineguest, out forumtotalonlineuser, out forumtotalonlineinvisibleuser); } if (DNTRequest.GetString("showonline") == "no") { showforumonline = false; } ForumUtils.UpdateVisitedForumsOptions(forumid); visitedforumsoptions = ForumUtils.GetVisitedForumsOptions(config.Visitedforums); //因为目前还未提供RSS功能,所以下面两项为0 forumallowrss = 0; }
protected override void ShowPage() { pagetitle = "用户控制面板"; if (!IsLogin()) { return; } if (DNTRequest.IsPost()) { UserInfo userInfo = Users.GetUserInfo(userid); string newpassword = DNTRequest.GetString("newpassword"); //第三方加密验证模式 if (config.Passwordmode > 1 && PasswordModeProvider.GetInstance() != null) { if (!PasswordModeProvider.GetInstance().CheckPassword(userInfo, DNTRequest.GetString("oldpassword"))) { AddErrLine("您的原密码错误"); return; } } else if (Users.CheckPassword(userid, DNTRequest.GetString("oldpassword"), true) == -1) { AddErrLine("您的原密码错误"); return; } if (newpassword != DNTRequest.GetString("newpassword2")) { AddErrLine("新密码两次输入不一致"); return; } if (Utils.StrIsNullOrEmpty(newpassword)) { newpassword = DNTRequest.GetString("oldpassword"); } if (newpassword.Length < 6) { AddErrLine("密码不得少于6个字符"); return; } userInfo.Password = newpassword; Users.ResetPassword(userInfo); //同步其他应用密码 Sync.UpdatePassword(userInfo.Username, userInfo.Password, ""); if (!Utils.StrIsNullOrEmpty(DNTRequest.GetString("changesecques"))) { Users.UpdateUserSecques(userid, DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer")); } ForumUtils.WriteCookie("password", ForumUtils.SetCookiePassword(userInfo.Password, config.Passwordkey)); OnlineUsers.UpdatePassword(olid, userInfo.Password); SetUrl("usercpnewpassword.aspx"); SetMetaRefresh(); SetShowBackLink(true); AddMsgLine("修改密码完毕, 同时已经更新了您的登录信息"); } }
protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); this.ValidateRequest = false; WorkContext.IsHttpAjax = WebHelper.IsAjax(); WorkContext.IP = WebHelper.GetIP(); WorkContext.RegionInfo = Regions.GetRegionByIP(WorkContext.IP); WorkContext.RegionId = WorkContext.RegionInfo.RegionId; WorkContext.Url = WebHelper.GetUrl(); WorkContext.UrlReferrer = WebHelper.GetUrlReferrer(); //获得用户唯一标示符sid WorkContext.Sid = MallUtils.GetSidCookie(); WorkContext.Openid = ""; if (WorkContext.Sid.Length == 0) { //生成sid WorkContext.Sid = Sessions.GenerateSid(); //将sid保存到cookie中 MallUtils.SetSidCookie(WorkContext.Sid); } PartUserInfo partUserInfo; //获得用户id int uid = MallUtils.GetUidCookie(); if (uid < 1)//当用户为游客时 { //创建游客 partUserInfo = Users.CreatePartGuest(); BrnMall.Core.WeiXinConfig wxconfig = BrnMall.Core.BMAConfig.WeiXinConfig; #region 获取用户openid //if (Request.QueryString["code"] == null) //{ // string host = Request.Url.Host; // string path = Request.Path; // string url = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect", wxconfig.AppID, System.Web.HttpUtility.UrlEncode("http://" + host + path)); // Response.Redirect(url); //} //else //{ // //BrnMall.Core.WeiXinConfig wxconfig = BrnMall.Core.BMAConfig.WeiXinConfig; // string code = Request.QueryString["code"];//获取授权code // // string openIdUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + wxconfig.AppID + "&secret=" + wxconfig.AppSecret + "&code=" + code + "&grant_type=authorization_code"; // string openIdUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + wxconfig.AppID + "&secret=" + wxconfig.AppSecret + "&code=" + code + "&grant_type=authorization_code"; // string content = ""; // try // { // content = BrnMall.Core.WeiXinHelp.GetPage(openIdUrl, ""); // } // catch // { // Response.Write("code:" + code + "这边错了"); // } // string openid = "";//根据授权 获取当前人的openid // try // { // openid = BrnMall.Core.WeiXinHelp.GetJsonValue(content, "openid"); // } // catch // { // Response.Write("code:" + code + "||||content" + content); // } // Senparc.Weixin.MP.AdvancedAPIs.User.UserInfoJson dic = null; // dic = Senparc.Weixin.MP.AdvancedAPIs.UserApi.Info(WeiXinHelp.IsExistAccess_Token2(), openid); // if (dic.subscribe == 1) // { // //获取用户 // //try // //{ // //BMALog.Instance.Write("openid:" + openid); // partUserInfo = Users.GetPartUserByOpenid(openid); // if (partUserInfo != null) // { // MallUtils.SetUserCookie(partUserInfo, 30); // //WorkContext.EncryptPwd= MallUtils.GetCookiePassword(); // } // else//不存在 // { // //partUserInfo = Users.CreatePartGuest(); // //WorkContext.EncryptPwd = string.Empty; // //MallUtils.SetUidCookie(-1); // //MallUtils.SetCookiePassword(""); // UserInfo userinfo = new UserInfo(); // userinfo.Pid = 3; // userinfo.Openid = dic.openid; // userinfo.NickName = dic.nickname; // userinfo.UserName = dic.nickname; // userinfo.Password = Users.CreateUserPassword("Migewan123", "1"); // userinfo.Avatar = dic.headimgurl; // userinfo.UserLevel = 0; // userinfo.PayCredits = 0; // userinfo.RankCredits = 0; // userinfo.VerifyEmail = 0; // userinfo.VerifyMobile = 0; // userinfo.Salt = Randoms.CreateRandomValue(6); // userinfo.LastVisitIP = WebHelper.GetIP(); // userinfo.MallAGid = 1;//非管理员组 // //userinfo.LastVisitRgId = Regions.GetRegionByIP(userinfo.LastVisitIP); // userinfo.LastVisitTime = DateTime.Now; // userinfo.RegisterIP = WebHelper.GetIP(); // userinfo.RegisterTime = DateTime.Now; // Users.CreateUser(userinfo); // partUserInfo = Users.GetPartUserByOpenid(openid); // MallUtils.SetUserCookie(partUserInfo, 30); // } // } //} #endregion #region 测试 ////string openid = "oD-R9wWHGhJ3rcRgX7sbU5W0s9sU"; string openid = "oD-R9wbVoaX-B-7kmk7sz1nz_-bc"; partUserInfo = Users.GetPartUserByOpenid(openid); if (partUserInfo != null) { MallUtils.SetUserCookie(partUserInfo, 30); //WorkContext.EncryptPwd= MallUtils.GetCookiePassword(); } else//不存在 { partUserInfo = Users.CreatePartGuest(); WorkContext.EncryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } #endregion } else//当用户为会员时 { //获得保存在cookie中的密码 string encryptPwd = MallUtils.GetCookiePassword(); //防止用户密码被篡改为危险字符 if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd)) { //创建游客 partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } else { partUserInfo = Users.GetPartUserByUidAndPwd(uid, MallUtils.DecryptCookiePassword(encryptPwd)); if (partUserInfo != null) { //发放登陆积分 // Credits.SendLoginCredits(ref partUserInfo, DateTime.Now); } else//当会员的账号或密码不正确时,将用户置为游客 { partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } } WorkContext.EncryptPwd = encryptPwd; } //try //{ //设置用户等级 if (UserRanks.IsBanUserRank(partUserInfo.UserRid) && partUserInfo.LiftBanTime <= DateTime.Now) { UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits); Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid); partUserInfo.UserRid = userRankInfo.UserRid; } //当用户被禁止访问时重置用户为游客 if (partUserInfo.UserRid == 1) { partUserInfo = Users.CreatePartGuest(); WorkContext.EncryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } //} //catch //{ // Response.Write("我的错"); //} //try //{ WorkContext.PartUserInfo = partUserInfo; WorkContext.Pid = partUserInfo.Pid; WorkContext.Userno = partUserInfo.Userno; WorkContext.UserLevel = partUserInfo.UserLevel; WorkContext.Openid = partUserInfo.Openid; WorkContext.Addtime = partUserInfo.Addtime; WorkContext.IsReal = partUserInfo.IsReal; WorkContext.Uid = partUserInfo.Uid; WorkContext.UserName = partUserInfo.UserName; WorkContext.UserEmail = partUserInfo.Email; WorkContext.UserMobile = partUserInfo.Mobile; WorkContext.Password = partUserInfo.Password; WorkContext.NickName = partUserInfo.NickName; WorkContext.Avatar = partUserInfo.Avatar; WorkContext.PayCreditName = Credits.PayCreditName; WorkContext.PayCreditCount = partUserInfo.PayCredits; WorkContext.RankCreditName = Credits.RankCreditName; WorkContext.RankCreditCount = partUserInfo.RankCredits; Core.BLL.SendBag bllsendbag = new Core.BLL.SendBag(); //全部红包 //WorkContext.CollarBag = bllsendbag.GetRecordSum(" Receiverid="+ partUserInfo.Uid ); //已领红包 WorkContext.NoCollarBag = bllsendbag.GetRecordSum(" Receiverid=" + partUserInfo.Uid + " and Status=0");; //未领红包 WorkContext.HaCollarBag = 0; WorkContext.UserRid = partUserInfo.UserRid; WorkContext.UserRankInfo = UserRanks.GetUserRankById(partUserInfo.UserRid); //WorkContext.UserRTitle = WorkContext.UserRankInfo.Title; switch (WorkContext.UserLevel) { case 1: WorkContext.UserRTitle = "银卡会员"; break; case 2: WorkContext.UserRTitle = "金卡会员"; break; case 3: WorkContext.UserRTitle = "钻石会员"; break; default: WorkContext.UserRTitle = "普通会员"; break; } //设置用户商城管理员组 WorkContext.MallAGid = partUserInfo.MallAGid; WorkContext.MallAdminGroupInfo = MallAdminGroups.GetMallAdminGroupById(partUserInfo.MallAGid); WorkContext.MallAGTitle = WorkContext.MallAdminGroupInfo.Title; //设置当前控制器类名 WorkContext.Controller = RouteData.Values["controller"].ToString().ToLower(); //设置当前动作方法名 WorkContext.Action = RouteData.Values["action"].ToString().ToLower(); WorkContext.PageKey = string.Format("/{0}/{1}", WorkContext.Controller, WorkContext.Action); WorkContext.ImageCDN = WorkContext.MallConfig.ImageCDN; WorkContext.CSSCDN = WorkContext.MallConfig.CSSCDN; WorkContext.ScriptCDN = WorkContext.MallConfig.ScriptCDN; //在线总人数 WorkContext.OnlineUserCount = OnlineUsers.GetOnlineUserCount(); //在线游客数 WorkContext.OnlineGuestCount = OnlineUsers.GetOnlineGuestCount(); //在线会员数 WorkContext.OnlineMemberCount = WorkContext.OnlineUserCount - WorkContext.OnlineGuestCount; //搜索词 WorkContext.SearchWord = string.Empty; //购物车中商品数量 WorkContext.CartProductCount = Carts.GetCartProductCountCookie(); //} //catch (Exception ex) //{ // Response.Write("赋值时:"+ex.ToString()); //} }
private void SaveUserInfo_Click(object sender, EventArgs e) { #region 保存用户信息 if (this.CheckCookie()) { int uid = DNTRequest.GetInt("uid", -1); string errorInfo = ""; if (!AllowEditUserInfo(uid, true)) { return; } if (userName.Text != ViewState["username"].ToString()) { if (AdminUsers.GetUserId(userName.Text) > 0) { base.RegisterStartupScript("", "<script>alert('您所输入的用户名已被使用过, 请输入其他的用户名!');</script>"); return; } } if (userName.Text == "") { base.RegisterStartupScript("", "<script>alert('用户名不能为空!');</script>"); return; } if (groupid.SelectedValue == "0") { base.RegisterStartupScript("", "<script>alert('您未选中任何用户组!');</script>"); return; } userInfo = AdminUsers.GetUserInfo(uid); userInfo.Username = userName.Text; userInfo.Nickname = nickname.Text; userInfo.Accessmasks = Convert.ToInt32(accessmasks.SelectedValue); //当用户组发生变化时则相应更新用户的管理组字段 if (userInfo.Groupid.ToString() != groupid.SelectedValue) { userInfo.Adminid = UserGroups.GetUserGroupInfo(int.Parse(groupid.SelectedValue)).Radminid; } //userInfo.Avatarshowid = 0; if ((bday.Text == "0000-00-00") || (bday.Text == "0000-0-0") | (bday.Text.Trim() == "")) { userInfo.Bday = ""; } else { if (!Utils.IsDateString(bday.Text.Trim())) { base.RegisterStartupScript("", "<script>alert('用户生日不是有效的日期型数据!');</script>"); return; } else { userInfo.Bday = bday.Text; } } if (!Users.ValidateEmail(email.Text, uid)) { base.RegisterStartupScript("", "<script>alert('当前用户的邮箱地址已被使用过, 请输入其他的邮箱!');</script>"); return; } userInfo.Email = email.Text; userInfo.Gender = Convert.ToInt32(gender.SelectedValue); //userInfo.Groupexpiry = Convert.ToInt32(groupexpiry.Text);后台操作为永久禁言和永久禁访 userInfo.Groupexpiry = 0; userInfo.Extgroupids = extgroupids.GetSelectString(","); if ((groupid.SelectedValue != "1") && (userInfo.Uid == BaseConfigs.GetFounderUid)) { base.RegisterStartupScript("", "<script>alert('创始人的所属用户组不能被修改为其它组!');window.location.href='global_edituser.aspx?uid=" + DNTRequest.GetString("uid") + "';</script>"); return; } userInfo.Groupid = Convert.ToInt32(groupid.SelectedValue); userInfo.Invisible = Convert.ToInt32(invisible.SelectedValue); userInfo.Joindate = joindate.Text; userInfo.Lastactivity = lastactivity.Text; userInfo.Lastip = lastip.Text; userInfo.Lastpost = lastpost.Text; userInfo.Lastvisit = lastvisit.Text; userInfo.Newpm = Convert.ToInt32(newpm.SelectedValue); userInfo.Newsletter = (ReceivePMSettingType)GetNewsLetter(); userInfo.Oltime = Convert.ToInt32(oltime.Text); userInfo.Pageviews = Convert.ToInt32(pageviews.Text); userInfo.Pmsound = Convert.ToInt32(pmsound.Text); userInfo.Posts = Convert.ToInt32(posts.Text); userInfo.Ppp = Convert.ToInt32(ppp.Text); userInfo.Regip = regip.Text; userInfo.Digestposts = Convert.ToInt32(digestposts.Text); if (secques.SelectedValue == "1") { userInfo.Secques = ""; //清空安全码 } userInfo.Showemail = Convert.ToInt32(showemail.SelectedValue); userInfo.Sigstatus = Convert.ToInt32(sigstatus.SelectedValue); userInfo.Templateid = Convert.ToInt32(templateid.SelectedValue); userInfo.Tpp = Convert.ToInt32(tpp.Text); if (Utils.IsNumeric(extcredits1.Text.Replace("-", ""))) { userInfo.Extcredits1 = float.Parse(extcredits1.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits2.Text.Replace("-", ""))) { userInfo.Extcredits2 = float.Parse(extcredits2.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits3.Text.Replace("-", ""))) { userInfo.Extcredits3 = float.Parse(extcredits3.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits4.Text.Replace("-", ""))) { userInfo.Extcredits4 = float.Parse(extcredits4.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits5.Text.Replace("-", ""))) { userInfo.Extcredits5 = float.Parse(extcredits5.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits6.Text.Replace("-", ""))) { userInfo.Extcredits6 = float.Parse(extcredits6.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits7.Text.Replace("-", ""))) { userInfo.Extcredits7 = float.Parse(extcredits7.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits8.Text.Replace("-", ""))) { userInfo.Extcredits8 = float.Parse(extcredits8.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } //根据公式计算用户的总积分,并更新 userInfo.Credits = UserCredits.GetUserCreditsByUserInfo(userInfo); //判断用户组是否为积分用户组。如果是的话,就用当前积分更新。 if (UserGroups.IsCreditUserGroup(userInfo.Groupid)) { userInfo.Groupid = UserCredits.GetCreditsUserGroupId(userInfo.Credits).Groupid; } //用户扩展信息 userInfo.Website = website.Text; userInfo.Icq = icq.Text; userInfo.Qq = qq.Text; userInfo.Yahoo = yahoo.Text; userInfo.Msn = msn.Text; userInfo.Skype = skype.Text; userInfo.Location = location.Text; userInfo.Customstatus = customstatus.Text; //userInfo.Avatar = avatar.Text; //userInfo.Avatarheight = Convert.ToInt32(avatarheight.Text); //userInfo.Avatarwidth = Convert.ToInt32(avatarwidth.Text); userInfo.Bio = bio.Text; if (signature.Text.Length > UserGroups.GetUserGroupInfo(userInfo.Groupid).Maxsigsize) { errorInfo = "更新的签名长度超过 " + UserGroups.GetUserGroupInfo(userInfo.Groupid).Maxsigsize + " 字符的限制,未能更新。"; } else { userInfo.Signature = signature.Text; //签名UBB转换HTML PostpramsInfo _postpramsinfo = new PostpramsInfo(); _postpramsinfo.Showimages = UserGroups.GetUserGroupInfo(userInfo.Groupid).Allowsigimgcode; _postpramsinfo.Sdetail = signature.Text; userInfo.Sightml = UBB.UBBToHTML(_postpramsinfo); } userInfo.Realname = realname.Text; userInfo.Idcard = idcard.Text; userInfo.Mobile = mobile.Text; userInfo.Phone = phone.Text; userInfo.Medals = DNTRequest.GetString("medalid"); if (IsEditUserName.Checked && userName.Text != ViewState["username"].ToString()) { AdminUsers.UserNameChange(userInfo, ViewState["username"].ToString()); //用户重命名同步 Discuz.Forum.Sync.RenameUser(userInfo.Uid, ViewState["username"].ToString(), userInfo.Username, ""); } if (AdminUsers.UpdateUserAllInfo(userInfo)) { OnlineUsers.DeleteUserByUid(userInfo.Uid); //移除该用户的在线信息,使之重建在线表信息 if (ViewState["Groupid"].ToString() != userInfo.Groupid.ToString()) { if (userInfo.Groupid == 4) { if (AlbumPluginProvider.GetInstance() != null) { AlbumPluginProvider.GetInstance().Ban(userInfo.Uid); } if (SpacePluginProvider.GetInstance() != null) { SpacePluginProvider.GetInstance().Ban(userInfo.Uid); } } else { if (AlbumPluginProvider.GetInstance() != null) { AlbumPluginProvider.GetInstance().UnBan(userInfo.Uid); } if (SpacePluginProvider.GetInstance() != null) { SpacePluginProvider.GetInstance().UnBan(userInfo.Uid); } } } //if (userName.Text != ViewState["username"].ToString()) //{ // AdminUsers.UserNameChange(userInfo, ViewState["username"].ToString()); //} //删除头像 if (delavart.Checked) { Avatars.DeleteAvatar(userInfo.Uid.ToString()); } AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台编辑用户", "用户名:" + userName.Text); if (errorInfo == "") { base.RegisterStartupScript("PAGE", "window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';"); } else { base.RegisterStartupScript("PAGE", "alert('" + errorInfo + "');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';"); } } else { base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';</script>"); } } #endregion }
protected override void ShowPage() { GetPostAds(forumid); if (userid > 0 && useradminid > 0) { AdminGroupInfo admingroupinfo = AdminGroups.GetAdminGroupInfo(usergroupid); if (admingroupinfo != null) { disablepostctrl = admingroupinfo.Disablepostctrl; } } #region 获取版块信息 if (forumid == -1) { AddLinkRss(forumpath + "tools/rss.aspx", "最新主题"); AddErrLine("无效的版块ID"); return; } forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Fid < 1) { if (config.Rssstatus == 1) { AddLinkRss(forumpath + "tools/rss.aspx", Utils.EncodeHtml(config.Forumtitle) + " 最新主题"); } AddErrLine("不存在的版块ID"); return; } #endregion if (config.Rssstatus == 1) { AddLinkRss(forumpath + "tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新主题"); } if (JumpUrl(forum)) { return; } needaudit = UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo); // 检查是否具有版主的身份 if (useradminid > 0) { ismoder = Moderators.IsModer(useradminid, userid, forumid); } //设置搜索和排序条件 SetSearchCondition(); showforumlogin = IsShowForumLogin(forum); pagetitle = Utils.RemoveHtml(forum.Name); navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname); forumnav = ShowForumAspxRewrite(ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname).Replace("\"showforum", "\"" + forumurl + "showforum"), forumid, pageid); topicextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans()); bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans()); #region 主题分类设置 if (forum.Applytopictype == 1) //启用主题分类 { topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); } if (forum.Viewbytopictype == 1) //允许按类别浏览 { topictypeselectlink = Forums.GetCurrentTopicTypesLink(forum.Fid, forum.Topictypes, forumurl + "showforum.aspx"); } #endregion //更新页面Meta中的keyword,description项, 提高SEO友好性 UpdateMetaInfo(Utils.StrIsNullOrEmpty(forum.Seokeywords) ? config.Seokeywords : forum.Seokeywords, Utils.StrIsNullOrEmpty(forum.Seodescription) ? forum.Description : forum.Seodescription, config.Seohead); //设置编辑器状态 SetEditorState(); #region 访问和发帖权限校验 if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = userid == -1; return; } canposttopic = UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg); // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖 if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1) { string visittime = ""; if (canposttopic && Scoresets.BetweenTime(config.Postbanperiods, out visittime)) { canposttopic = false; } isnewbie = UserAuthority.CheckNewbieSpan(userid); } //是否显示快速发主题编辑器(全局权限判定,版块权限判定,是否是游客,游客需要显示,登录用户是否允许发主题且已过新手见习期) if ((config.Fastpost == 1 || config.Fastpost == 3) && forum.Allowspecialonly <= 0 && (userid < 0 || (canposttopic && !isnewbie))) { canquickpost = true; } #endregion // 得到子版块列表 if (forum.Subforumcount > 0) { subforumlist = Forums.GetSubForumCollection(forumid, forum.Colcount, config.Hideprivate, usergroupid, config.Moddisplay); } if (!forum.Rules.Equals("")) { forum.Rules = UBB.ParseSimpleUBB(forum.Rules);//替换版规中的UBB } //获取主题总数 topiccount = Topics.GetTopicCount(forumid, true, condition); #region 设置分页及主题列表信息 // 得到Tpp设置 if (tpp <= 0) { tpp = config.Tpp; } // 得到Ppp设置 if (ppp <= 0) { ppp = config.Ppp; } //修正请求页数中可能的错误 if (pageid < 1) { pageid = 1; } int toptopicpagecount = 0; if (forum.Layer > 0) { //获取当前页置顶主题列表 DataRow dr = Topics.GetTopTopicListID(forumid); if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString())) { topiccount = topiccount + TypeConverter.ObjectToInt(dr["tid0Count"]); } //获取总页数 pagecount = topiccount % tpp == 0 ? topiccount / tpp : topiccount / tpp + 1; if (pagecount == 0) { pagecount = 1; } if (pageid > pagecount) { pageid = pagecount; } if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString())) { toptopiccount = TypeConverter.ObjectToInt(dr["tidCount"]); if (toptopiccount > tpp * (pageid - 1)) { toptopiclist = Topics.GetTopTopicList(forumid, tpp, pageid, dr["tid"].ToString(), forum.Autoclose, forum.Topictypeprefix); toptopicpagecount = toptopiccount / tpp; } if (toptopicpagecount >= pageid || (pageid == 1 && toptopicpagecount != toptopiccount)) { topiclist = GetTopicInfoList(tpp - toptopiccount % tpp, pageid - toptopicpagecount, 0); } else { topiclist = GetTopicInfoList(tpp, pageid - toptopicpagecount, toptopiccount % tpp); } } else { toptopicpagecount = 0; topiclist = GetTopicInfoList(tpp, pageid, 0); } if (toptopiclist != null & toptopiclist.Count > 0) { this.Context.MaskUserName(toptopiclist, oluserinfo); } if (topiclist != null & topiclist.Count > 0) { this.Context.MaskUserName(topiclist, oluserinfo); } //如果topiclist为空则更新当前论坛帖数 if (topiclist == null || topiclist.Count == 0 || topiclist.Count > topiccount) { Forums.SetRealCurrentTopics(forum.Fid); } SetPageNumber(); //当版块数大于一个并且当版块数量为一个时不是版块自身时显示下拉菜单 showvisitedforumsmenu = visitedforums != null && ((visitedforums.Length == 1 && visitedforums[0].Fid != forumid) || visitedforums.Length > 1); SetVisitedForumsCookie(); //保存查看版块的页数 Utils.WriteCookie("forumpageid", pageid.ToString(), 30); //判断是否需要生成游客缓存页面 IsGuestCachePage(); } #endregion #region 替换版规中的UBB forum.Description = UBB.ParseSimpleUBB(forum.Description); #endregion #region 更新在线信息 OnlineUsers.UpdateAction(olid, UserAction.ShowForum.ActionID, forumid, forum.Name, -1, ""); if ((forumtotalonline < config.Maxonlinelist && (config.Whosonlinestatus == 2 || config.Whosonlinestatus == 3)) || DNTRequest.GetString("showonline") == "yes") { showforumonline = true; onlineuserlist = OnlineUsers.GetForumOnlineUserCollection(forumid, out forumtotalonline, out forumtotalonlineguest, out forumtotalonlineuser, out forumtotalonlineinvisibleuser); } //if (DNTRequest.GetString("showonline") != "no") //{ // showforumonline = false; //} if (DNTRequest.GetString("showonline") == "no") { showforumonline = false; } #endregion //修正版主列表 if (forum.Moderators.Trim() != "") { string moderHtml = string.Empty; foreach (string m in forum.Moderators.Split(',')) { moderHtml += string.Format("<a href=\"{0}userinfo.aspx?username={1}\">{2}</a>,", forumpath, Utils.UrlEncode(m), m); } forum.Moderators = moderHtml.TrimEnd(','); } ForumUtils.UpdateVisitedForumsOptions(forumid); }
/// <summary> /// 构造函数 /// </summary> public ArchiverPage() { if (config.Archiverstatus == 2 && DNTRequest.IsSearchEnginesGet())//启用,但当用户从搜索引擎点击时自动转向动态页面 { HttpContext.Current.Response.Redirect(OrganizeURL(HttpContext.Current.Request.Url)); } if (config.Archiverstatus == 3 && DNTRequest.IsBrowserGet())//启用,但当用户使用浏览器访问时自动转向动态页面 { HttpContext.Current.Response.Redirect(OrganizeURL(HttpContext.Current.Request.Url)); } if (OnlineUsers.GetOnlineAllUserCount() >= 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() != "" && !Utils.InIPArray(DNTRequest.GetIP(), Utils.SplitString(config.Ipaccess, "\n"))) { ShowError("抱歉, 系统设置了IP访问列表限制, 您无法访问本论坛", 0); return; } // 如果IP访问列表有设置则进行判断 if (config.Ipdenyaccess.Trim() != "" && Utils.InIPArray(DNTRequest.GetIP(), Utils.SplitString(config.Ipdenyaccess, "\n"))) { ShowError("由于您严重违反了论坛的相关规定, 已被禁止访问.", 2); return; } // 如果当前用户请求页面不是登录页面并且当前用户非管理员并且论坛设定了时间段,当时间在其中的一个时间段内,则跳转到论坛登录页面 if (oluserinfo.Adminid != 1 && DNTRequest.GetPageName() != "login.aspx" && 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> private void RegisterAndBind() { if (userid > 0) { AddErrLine("当前已有用户登录,无法注册"); return; } if (config.Regstatus < 1 || cloudconfig.Allowconnectregister == 0) { AddErrLine("论坛当前禁止新的QQ会员登录"); return; } string tmpUserName = DNTRequest.GetString(config.Antispamregisterusername); string email = DNTRequest.GetString(config.Antispamregisteremail).Trim().ToLower(); string tmpBday = DNTRequest.GetString("bday").Trim(); string errorMessage = ""; if (!Users.PageValidateUserName(tmpUserName, out errorMessage) || !Users.PageValidateEmail(email, false, out errorMessage)) { AddErrLine(errorMessage); return; } //用户注册模板中,生日可以单独用一个名为bday的文本框, 也可以分别用bday_y bday_m bday_d三个文本框, 用户可不填写 if (!Utils.IsDateString(tmpBday) && !string.IsNullOrEmpty(tmpBday)) { AddErrLine("生日格式错误, 如果不想填写生日请置空"); return; } //如果用户名符合注册规则, 则判断是否已存在 if (Users.GetUserId(tmpUserName) > 0) { AddErrLine("请不要重复提交!"); return; } //读取当前用户的OPENID信息 userconnectinfo = DiscuzCloud.GetUserConnectInfo(openid); if (userconnectinfo == null || userconnectinfo.Uid > 0) { AddErrLine("Connect信息异常,登录失败,请尝试再次登录"); return; } UserBindConnectLog bindLog = DiscuzCloud.GetUserConnectBindLog(userconnectinfo.OpenId); if (cloudconfig.Maxuserbindcount != 0 && bindLog != null && (bindLog.Type != 1 && bindLog.BindCount >= cloudconfig.Maxuserbindcount)) { AddErrLine("当前QQ用户解绑次数过多,无法绑定新注册的用户"); return; } UserInfo userInfo = CreateUser(tmpUserName, email, tmpBday); userconnectinfo.Uid = userInfo.Uid; DiscuzCloud.UpdateUserConnectInfo(userconnectinfo); if (bindLog == null) { bindLog = new UserBindConnectLog(); bindLog.OpenId = userconnectinfo.OpenId; bindLog.Uid = userconnectinfo.Uid; bindLog.Type = 1; bindLog.BindCount = 1; DiscuzCloud.CreateUserConnectBindLog(bindLog); } else { bindLog.BindCount++; bindLog.Uid = userconnectinfo.Uid; bindLog.Type = 1; DiscuzCloud.UpdateUserConnectBindLog(bindLog); } #region 发送欢迎信息 if (config.Welcomemsg == 1) { // 收件箱 PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo(); privatemessageinfo.Message = config.Welcomemsgtxt; privatemessageinfo.Subject = "欢迎您的加入! (请勿回复本信息)"; privatemessageinfo.Msgto = userInfo.Username; privatemessageinfo.Msgtoid = userInfo.Uid; privatemessageinfo.Msgfrom = PrivateMessages.SystemUserName; privatemessageinfo.Msgfromid = 0; privatemessageinfo.New = 1; privatemessageinfo.Postdatetime = Utils.GetDateTime(); privatemessageinfo.Folder = 0; PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0); } #endregion //发送同步数据给应用程序 Sync.UserRegister(userInfo.Uid, userInfo.Username, userInfo.Password, ""); //如果用户选择使用QZone头像 if (cloudconfig.Allowuseqzavater == 1 && DNTRequest.GetString("use_qzone_avatar") == "1") { QZoneAvatar qz = new QZoneAvatar(); qz.AsyncGetAvatar(userconnectinfo); } SetUrl("index.aspx"); SetShowBackLink(false); //如果不是需要管理员审核的注册,页面延时刷新为2秒,否则是5秒 SetMetaRefresh(config.Regverify != 2 ? 2 : 5); Statistics.ReSetStatisticsCache(); if (config.Regverify != 2) { CreditsFacade.UpdateUserCredits(userInfo.Uid); ForumUtils.WriteUserCookie(userInfo, -1, config.Passwordkey); Utils.WriteCookie("bindconnect", "true");//将当前登录用户是否绑定QQ互联的状态设置为true OnlineUsers.UpdateAction(olid, UserAction.Register.ActionID, 0, config.Onlinetimeout); AddMsgLine("QQ登录成功,继续浏览"); } else { AddMsgLine("QQ数据绑定完成, 但需要系统管理员审核您的帐户后才可登录使用"); } notifyscript = GetNotifyScript(userconnectinfo, userInfo.Username, userInfo.Bday, userInfo.Gender, userInfo.Email, userInfo.Showemail, DNTRequest.GetInt("useqqavatar", 2), "register"); }
public void LogUser(User user) { ViewBag.UserName = user.UserName; OnlineUsers.AddSessionUser(user); ViewBag.UserName = OnlineUsers.GetSessionUser().UserName; }
public ChatController(MessageService messageService, OnlineUsers onlineUsers, IHubContext <ChatHub> hubContext) { _messageService = messageService; _onlineUsers = onlineUsers; _hubContext = hubContext; }
public ActionResult Logout() { OnlineUsers.RemoveSessionUser(); return(RedirectToAction("Login", "Users")); }
protected override void ShowPage() { //获取主题信息 topic = GetTopicInfo(); if (topic == null) { return; } topicid = topic.Tid; forumid = topic.Fid; forum = Forums.GetForumInfo(forumid); if (forum == null) { AddErrLine("不存在的版块ID"); return; } //验证不通过则返回 if (!ValidateInfo() || IsErr()) { return; } int price = GetTopicPrice(topic); if (topic.Special == 0 && price > 0) { HttpContext.Current.Response.Redirect(forumpath + "buytopic.aspx?topicid=" + topic.Tid); return; } if (postid > 0 && Posts.GetPostInfo(topicid, postid) == null) { AddErrLine("该帖可能已被删除 " + string.Format("<a href=\"{0}\">[返回主题]</a>", ShowTopicAspxRewrite(topicid, 1))); return; } //将版块加入到已访问版块列表中 ForumUtils.SetVisitedForumsCookie(forumid.ToString()); if (userid > 0) { userInfo = Users.GetShortUserInfo(userid); } if (topic.Identify > 0) { topicidentify = Caches.GetTopicIdentify(topic.Identify); } pagetitle = string.Format("{0} - {1}", topic.Title, Utils.RemoveHtml(forum.Name)); ///得到广告列表 GetForumAds(forum.Fid); IsModer(); //获取主题类型 Caches.GetTopicTypeArray().TryGetValue(topic.Typeid, out topictypes); topictypes = Utils.StrIsNullOrEmpty(topictypes) ? "" : "[" + topictypes + "]"; userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans()); score = Scoresets.GetValidScoreName(); scoreunit = Scoresets.GetValidScoreUnit(); navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname); //编辑器状态 EditorState(); string[] customauthorinfo = config.Customauthorinfo.Split('|'); postleftshow = customauthorinfo[0].Split(','); //帖子左边要显示的用户信息项目 userfaceshow = customauthorinfo[1].Split(','); //头像上方要显示的项目 //if (newpmcount > 0) // pmlist = PrivateMessages.GetPrivateMessageListForIndex(userid, 5, 1, 1); onlyauthor = (onlyauthor == "1" || onlyauthor == "2") ? onlyauthor : "0"; // 获取分页相关信息 BindPageCountAndId(); GetPostAds(GetPostPramsInfo(price), postlist.Count); #region 获取特殊主题相关信息 bonuslogs = Bonus.GetLogs(topic); if (topic.Special == 1)//获取投票信息 { GetPollInfo(); } if (topic.Special == 4) //获取辩论信息 { GetDebateInfo(); } #endregion enabletag = (config.Enabletag & forum.Allowtag) == 1; //if (enabletag) // relatedtopics = Topics.GetRelatedTopicList(topicid, 5); //更新页面Meta信息 if (postlist != null && postlist.Count > 0) { UpdateMetaInfo(Utils.RemoveHtml(postlist[0].Message)); } //判断是否需要生成游客缓存页面 IsGuestCachePage(); //更新主题查看次数和在线用户信息 TopicStats.Track(topicid, 1); Topics.MarkOldTopic(topic); topicviews = topic.Views + 1 + (config.TopicQueueStats == 1 ? TopicStats.GetStoredTopicViewCount(topic.Tid) : 0); OnlineUsers.UpdateAction(olid, UserAction.ShowTopic.ActionID, forumid, forum.Name, topicid, topic.Title); //如果是从 if (DNTRequest.GetInt("fromfav", 0) > 0) { Favorites.UpdateUserFavoriteViewTime(userid, topicid); } //UserCredits.UpdateUserCredits(userInfo);此方法与后台积分设置中的条目不匹配,故注释 }
public void UserLoggedOut(string userName) { OnlineUsers.Remove(userName); OfflineUsers.Add(userName); OnPropertyChanged(nameof(OfflineUsers)); }
protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); this.ValidateRequest = false; WorkContext.IsHttpAjax = WebHelper.IsAjax(); WorkContext.IP = WebHelper.GetIP(); WorkContext.RegionInfo = Regions.GetRegionByIP(WorkContext.IP); WorkContext.RegionId = WorkContext.RegionInfo.RegionId; WorkContext.Url = WebHelper.GetUrl(); WorkContext.UrlReferrer = WebHelper.GetUrlReferrer(); //获得用户唯一标示符sid WorkContext.Sid = MallUtils.GetSidCookie(); if (WorkContext.Sid.Length == 0) { //生成sid WorkContext.Sid = Sessions.GenerateSid(); //将sid保存到cookie中 MallUtils.SetSidCookie(WorkContext.Sid); } PartUserInfo partUserInfo; //获得用户id int uid = MallUtils.GetUidCookie(); if (uid < 1)//当用户为游客时 { //创建游客 partUserInfo = Users.CreatePartGuest(); } else//当用户为会员时 { //获得保存在cookie中的密码 string encryptPwd = MallUtils.GetCookiePassword(); //防止用户密码被篡改为危险字符 if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd)) { //创建游客 partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } else { partUserInfo = Users.GetPartUserByUidAndPwd(uid, MallUtils.DecryptCookiePassword(encryptPwd)); if (partUserInfo != null) { //发放登录积分 Credits.SendLoginCredits(ref partUserInfo, DateTime.Now); } else//当会员的账号或密码不正确时,将用户置为游客 { partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } } WorkContext.EncryptPwd = encryptPwd; } //设置用户等级 if (UserRanks.IsBanUserRank(partUserInfo.UserRid) && partUserInfo.LiftBanTime <= DateTime.Now) { UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits); Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid); partUserInfo.UserRid = userRankInfo.UserRid; } //当用户被禁止访问时重置用户为游客 if (partUserInfo.UserRid == 1) { partUserInfo = Users.CreatePartGuest(); WorkContext.EncryptPwd = string.Empty; MallUtils.SetUidCookie(-1); MallUtils.SetCookiePassword(""); } WorkContext.PartUserInfo = partUserInfo; WorkContext.Uid = partUserInfo.Uid; WorkContext.UserName = partUserInfo.UserName; WorkContext.UserEmail = partUserInfo.Email; WorkContext.UserMobile = partUserInfo.Mobile; WorkContext.Password = partUserInfo.Password; WorkContext.NickName = partUserInfo.NickName; WorkContext.Avatar = partUserInfo.Avatar; WorkContext.PayCreditName = Credits.PayCreditName; WorkContext.PayCreditCount = partUserInfo.PayCredits; WorkContext.RankCreditName = Credits.RankCreditName; WorkContext.RankCreditCount = partUserInfo.RankCredits; WorkContext.UserRid = partUserInfo.UserRid; WorkContext.UserRankInfo = UserRanks.GetUserRankById(partUserInfo.UserRid); WorkContext.UserRTitle = WorkContext.UserRankInfo.Title; //设置用户商城管理员组 WorkContext.MallAGid = partUserInfo.MallAGid; WorkContext.MallAdminGroupInfo = MallAdminGroups.GetMallAdminGroupById(partUserInfo.MallAGid); WorkContext.MallAGTitle = WorkContext.MallAdminGroupInfo.Title; //设置当前控制器类名 WorkContext.Controller = RouteData.Values["controller"].ToString().ToLower(); //设置当前动作方法名 WorkContext.Action = RouteData.Values["action"].ToString().ToLower(); WorkContext.PageKey = string.Format("/{0}/{1}", WorkContext.Controller, WorkContext.Action); WorkContext.ImageCDN = WorkContext.MallConfig.ImageCDN; WorkContext.CSSCDN = WorkContext.MallConfig.CSSCDN; WorkContext.ScriptCDN = WorkContext.MallConfig.ScriptCDN; //在线总人数 WorkContext.OnlineUserCount = OnlineUsers.GetOnlineUserCount(); //在线游客数 WorkContext.OnlineGuestCount = OnlineUsers.GetOnlineGuestCount(); //在线会员数 WorkContext.OnlineMemberCount = WorkContext.OnlineUserCount - WorkContext.OnlineGuestCount; //搜索词 WorkContext.SearchWord = string.Empty; //购物车中商品数量 WorkContext.CartProductCount = Carts.GetCartProductCountCookie(); }
protected override void ShowPage() { //获取主题信息 topic = GetTopicInfo(); if (topic == null || IsErr()) { return; } //未结束的悬赏 if (topic.Special != 3) { HttpContext.Current.Response.Redirect(BaseConfigs.GetForumPath + ShowTopicAspxRewrite(topic.Tid, 1)); return; } topicid = topic.Tid; forumid = topic.Fid; forum = Forums.GetForumInfo(forumid); if (forum == null) { AddErrLine("不存在的版块ID"); return; } pagetitle = string.Format("{0} - {1}", topic.Title, Utils.RemoveHtml(forum.Name)); //得到广告列表 GetForumAds(forum.Fid); //检查是否具有版主的身份 IsModer(); //验证不通过则返回 if (!ValidateInfo()) { return; } //编辑器状态 EditorState(); navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname); bonuslogs = Bonus.GetLogs(topic); if (topic.Moderated > 0) { moderactions = TopicAdmins.GetTopicListModeratorLog(topicid); } Caches.GetTopicTypeArray().TryGetValue(topic.Typeid, out topictypes); topictypes = topictypes != "" ? "[" + topictypes + "]" : ""; if (newpmcount > 0) { pmlist = PrivateMessages.GetPrivateMessageListForIndex(userid, 5, 1, 1); } score = Scoresets.GetValidScoreName(); scoreunit = Scoresets.GetValidScoreUnit(); GetPostAds(GetPostPramsInfo(), postlist.Count); if (postlist.Count <= 0) { AddErrLine("读取信息失败"); return; } //更新页面Meta信息 UpdateMetaInfo(Utils.RemoveHtml(postlist[0].Message)); //更新主题查看次数和在线用户信息 TopicStats.Track(topicid, 1); Topics.MarkOldTopic(topic); topicviews = topic.Views + 1 + (config.TopicQueueStats == 1 ? TopicStats.GetStoredTopicViewCount(topic.Tid) : 0); OnlineUsers.UpdateAction(olid, UserAction.ShowTopic.ActionID, forumid, forum.Name, topicid, topic.Title); BindDownloadAttachmentTip(); ForumUtils.WriteCookie("referer", string.Format("showbonus.aspx?topicid={0}", topicid.ToString())); }
protected override void ShowPage() { pagetitle = "用户注册"; if (userid != -1) { SetUrl(BaseConfigs.GetForumPath); SetMetaRefresh(); SetShowBackLink(false); AddMsgLine("不能重复注册用户"); ispost = true; createuser = "******"; agree = "yes"; return; } if (config.Regstatus < 1) { AddErrLine("论坛当前禁止新用户注册"); return; } allowinvite = Utils.InArray(config.Regstatus.ToString(), "2,3"); #region 用户IP判断 string msg = Users.CheckRegisterDateDiff(DNTRequest.GetIP()); if (msg != null) { AddErrLine(msg); return; } //if (config.Regctrl > 0) //{ // ShortUserInfo userinfo = Users.GetShortUserInfoByIP(DNTRequest.GetIP()); // if (userinfo != null) // { // int Interval = Utils.StrDateDiffHours(userinfo.Joindate, config.Regctrl); // if (Interval <= 0) // { // AddErrLine("抱歉, 系统设置了IP注册间隔限制, 您必须在 " + (Interval * -1) + " 小时后才可以注册"); // return; // } // } //} //if (config.Ipregctrl.Trim() != "") //{ // string[] regctrl = Utils.SplitString(config.Ipregctrl, "\n"); // if (Utils.InIPArray(DNTRequest.GetIP(), regctrl)) // { // ShortUserInfo userinfo = Users.GetShortUserInfoByIP(DNTRequest.GetIP()); // if (userinfo != null) // { // int Interval = Utils.StrDateDiffHours(userinfo.Joindate, 72); // if (Interval < 0) // { // AddErrLine("抱歉, 系统设置了特殊IP注册限制, 您必须在 " + (Interval * -1) + " 小时后才可以注册"); // return; // } // } // } //} #endregion //如果提交了用户注册信息... if (!Utils.StrIsNullOrEmpty(createuser) && ispost) { SetShowBackLink(true); InviteCodeInfo inviteCode = null; if (allowinvite) { if (config.Regstatus == 3 && invitecode == "") { AddErrLine("邀请码不能为空!"); return; } if (invitecode != "") { inviteCode = Invitation.GetInviteCodeByCode(invitecode.ToUpper()); if (!Invitation.CheckInviteCode(inviteCode)) { AddErrLine("邀请码不合法或已过期!"); return; } } } string tmpUserName = DNTRequest.GetString(config.Antispamregisterusername); string email = DNTRequest.GetString(config.Antispamregisteremail).Trim().ToLower(); string tmpBday = DNTRequest.GetString("bday").Trim(); if (tmpBday == "") { tmpBday = string.Format("{0}-{1}-{2}", DNTRequest.GetString("bday_y").Trim(), DNTRequest.GetString("bday_m").Trim(), DNTRequest.GetString("bday_d").Trim()); } tmpBday = (tmpBday == "--" ? "" : tmpBday); ValidateUserInfo(tmpUserName, email, tmpBday); if (IsErr()) { return; } //如果用户名符合注册规则, 则判断是否已存在 if (Users.GetUserId(tmpUserName) > 0) { AddErrLine("请不要重复提交!"); return; } UserInfo userInfo = CreateUser(tmpUserName, email, tmpBday); #region 发送欢迎信息 if (config.Welcomemsg == 1) { // 收件箱 PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo(); privatemessageinfo.Message = config.Welcomemsgtxt; privatemessageinfo.Subject = "欢迎您的加入! (请勿回复本信息)"; privatemessageinfo.Msgto = userInfo.Username; privatemessageinfo.Msgtoid = userInfo.Uid; privatemessageinfo.Msgfrom = PrivateMessages.SystemUserName; privatemessageinfo.Msgfromid = 0; privatemessageinfo.New = 1; privatemessageinfo.Postdatetime = Utils.GetDateTime(); privatemessageinfo.Folder = 0; PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0); } #endregion //发送同步数据给应用程序 Sync.UserRegister(userInfo.Uid, userInfo.Username, userInfo.Password, ""); SetUrl("index.aspx"); SetShowBackLink(false); SetMetaRefresh(config.Regverify == 0 ? 2 : 5); Statistics.ReSetStatisticsCache(); if (inviteCode != null) { Invitation.UpdateInviteCodeSuccessCount(inviteCode.InviteId); if (config.Regstatus == 3) { if (inviteCode.SuccessCount + 1 >= inviteCode.MaxCount) { Invitation.DeleteInviteCode(inviteCode.InviteId); } } } if (config.Regverify == 0) { UserCredits.UpdateUserCredits(userInfo.Uid); ForumUtils.WriteUserCookie(userInfo, -1, config.Passwordkey); OnlineUsers.UpdateAction(olid, UserAction.Register.ActionID, 0, config.Onlinetimeout); MsgForward("register_succeed"); AddMsgLine("注册成功, 返回登录页"); } else { if (config.Regverify == 1) { AddMsgLine("注册成功, 请您到您的邮箱中点击激活链接来激活您的帐号"); } else if (config.Regverify == 2) { AddMsgLine("注册成功, 但需要系统管理员审核您的帐户后才可登录使用"); } } //ManyouApplications.AddUserLog(userInfo.Uid, UserLogActionEnum.Add); agree = "yes"; } }
/// <summary> /// Admin ban user /// </summary> void AdminBan(OnlineUser user, CommandPacket command) { User backendUser = Users[user.Username]; var arguments = command.arguments; // Permission check if (backendUser.permissionLevel < 1) { PermissionDeniedMessage(user); return; } // Syntax check if (arguments.Count != 2) { ServerMessage( "server", user, langFile["command_arguments_error"] .Replace("$COUNT$", "2") ); return; } // Check if the user is exist if (!Users.ContainsKey(arguments[0])) { ServerMessage( "server", user, langFile["command_userNotExist"] .Replace("$NAME$", arguments[0]) ); return; } // Check permission level User target = Users[arguments[0]]; if (target.permissionLevel >= backendUser.permissionLevel) { ServerMessage( "server", user, langFile["command_higherPermission"] .Replace("$NICK$", target.nickname) .Replace("$NAME$", target.username) ); return; } // Convert time DateTime time; if (!TypeConvert.TryGetTime(arguments[1], out time)) { ServerMessage( "server", user, langFile["command_invalidTimeFormat"] ); return; } DateTime untilTime = DateTime.Now.AddTicks(time.Ticks); target.banTime = untilTime; Info( $"{backendUser.nickname}\\rr({backendUser.username}\\rr)" + $" banned {target.nickname}\\rr({target.username}\\rr)." ); Broadcast( "server", langFile["command_ban_broadcast"] .Replace("$NICK$", target.nickname) .Replace("$NAME$", target.username) .Replace("$TIME$", untilTime.ToString("yyyy/MM/dd HH:mm:ss")) ); if (OnlineUsers.ContainsKey(arguments[0])) { DisconnectMessage( OnlineUsers[arguments[0]], user.Username, langFile["command_ban_message"] .Replace("$TIME$", untilTime.ToString("yyyy/MM/dd HH:mm:ss")) ); Disconnect(arguments[0]); } }
/// <summary> /// Create a test online users object /// </summary> /// <returns></returns> static public OnlineUsers GetOnlineUsers() { OnlineUserInfo info = new OnlineUserInfo() { Username = string.Empty }; OnlineUser user = new OnlineUser() { User = info, }; OnlineUsers users = new OnlineUsers() { OnlineUser = new System.Collections.Generic.List<OnlineUser>(), OrderBy = OnlineUsersOrderBy.None.ToString() }; users.OnlineUser.Add(user); return users; }
public AdminPage() { if (!Page.IsPostBack) { this.RegisterAdminPageClientScriptBlock(); } config = GeneralConfigs.GetConfig(); // 如果IP访问列表有设置则进行判断 if (config.Adminipaccess.Trim() != "") { string[] regctrl = Utils.SplitString(config.Adminipaccess, "\n"); if (!Utils.InIPArray(DNTRequest.GetIP(), regctrl)) { Context.Response.Redirect(BaseConfigs.GetForumPath + "admin/syslogin.aspx"); return; } } // 获取用户信息 OnlineUserInfo oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout); UserGroupInfo usergroupinfo = AdminUserGroups.AdminGetUserGroupInfo(oluserinfo.Groupid); if (oluserinfo.Userid <= 0 || usergroupinfo.Radminid != 1) { Context.Response.Redirect(BaseConfigs.GetForumPath + "admin/syslogin.aspx"); return; } string secques = Users.GetUserInfo(oluserinfo.Userid).Secques; // 管理员身份验证 if (Context.Request.Cookies["dntadmin"] == null || Context.Request.Cookies["dntadmin"]["key"] == null || ForumUtils.GetCookiePassword(Context.Request.Cookies["dntadmin"]["key"].ToString(), config.Passwordkey) != (oluserinfo.Password + secques + oluserinfo.Userid.ToString())) { Context.Response.Redirect(BaseConfigs.GetForumPath + "admin/syslogin.aspx"); return; } else { HttpCookie cookie = HttpContext.Current.Request.Cookies["dntadmin"]; cookie.Values["key"] = ForumUtils.SetCookiePassword(oluserinfo.Password + secques + oluserinfo.Userid.ToString(), config.Passwordkey); cookie.Values["userid"] = oluserinfo.Userid.ToString(); cookie.Expires = DateTime.Now.AddMinutes(30); HttpContext.Current.Response.AppendCookie(cookie); } this.userid = oluserinfo.Userid; this.username = oluserinfo.Username; this.usergroupid = oluserinfo.Groupid; this.useradminid = (short)usergroupinfo.Radminid; this.grouptitle = usergroupinfo.Grouptitle; this.ip = DNTRequest.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; //} }