示例#1
0
 public MenuPermissions(AuthUser user ,int formID )
 {
     this.user = user;
     this.formID = formID;
     spacePremissions = AllSettings.Current.BackendPermissions;
     userPremissons = AllSettings.Current.ManageUserPermissionSet;
 }
示例#2
0
        public static string OutputIP(AuthUser operatorUser, string ip, int? outputPart)
        {
            int outPart;

            if (outputPart == null)
            {
                if (AllSettings.Current.BackendPermissions.Can(operatorUser, BackendPermissions.Action.Setting_AccessLimit))
                    outPart = int.MaxValue;
                else
                    outPart = AllSettings.Current.SiteSettings.ViewIPFields.GetValue(operatorUser);
            }
            else
                outPart = outputPart.Value;

            string[] ipPart = ip.Split('.');

            if (ipPart.Length < 4) return "";//TODO:ipv6
            switch (outPart)
            {
                case 0:
                    return "*.*.*.*";
                case 1:
                    return string.Concat(ipPart[0], ".*.*.*");
                case 2:
                    return string.Concat(ipPart[0], ".", ipPart[1], ".*.*");
                case 3:
                    return string.Concat(ipPart[0], ".", ipPart[1], ".", ipPart[2], ".*");
            }
            return ip;
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (AllSettings.Current.ManageUserPermissionSet.Can(My, ManageUserPermissionSet.ActionWithTarget.EditUserMedal, UserID) == false)
            {
                ShowError("您所在的用户组没有管理该用户图标的权限");
                return;
            }

            m_User = UserBO.Instance.GetAuthUser(UserID);

            if (m_User == null || m_User == Entities.User.Guest)
            {
                ShowError(new UserNotExistsError("id", UserID));
                return;
            }

            if (_Request.IsClick("save"))
            {
                Save();
            }

            if (_Request.IsClick("addmedal"))
            {
                AddMedal();
            }

            if (_Request.IsClick("deleteMedals"))
            {
                DeleteMedals();
            }
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!UserBO.Instance.CanEditUserProfile(My, UserID))
            {
                ShowError(new NoPermissionEditUserProfileError());
                return;
            }

            m_User = UserBO.Instance.GetAuthUser(UserID);

            if (m_User == null || m_User == Entities.User.Guest)
            {
                ShowError(new UserNotExistsError("id", UserID));
                return;
            }

            if (_Request.IsClick("save"))
            {
                SaveUserinfo();
            }

            else if (_Request.IsClick("clearavatar"))
            {
                ClearAvatar();
            }
        }
示例#5
0
        /// <summary>
        /// 实名认证
        /// </summary>
        /// <param name="targetUserIds"></param>
        /// <param name="realnameChecked">是否</param>
        public void AdminSetRealnameChaecked(AuthUser operatorUser, int targetUserId, bool realnameChecked, string remark,bool sendNotify)
        {
            if (operatorUser == User.Guest)
            {
                ThrowError(new NotLoginError());
                return;
            }

            if (!CanRealnameCheck(operatorUser))
            {
                ThrowError(new NoPermissionRealnameCheckError());
                return;
            }



            UserDao.Instance.SetRealnameChecked(operatorUser.UserID, targetUserId, realnameChecked,remark );

            if (sendNotify)
            {
                string content = realnameChecked ? "恭喜您已通过实名认证" : "您的实名认证被拒绝," + (!string.IsNullOrEmpty(remark) ? "原因:" + StringUtil.CutString(remark, 100) : "");
                AdminManageNotify notify = new AdminManageNotify(targetUserId, content);
                notify.UserID = targetUserId;
                NotifyBO.Instance.AddNotify(operatorUser, notify);
            }

            RemoveUserCache(targetUserId);

            if (realnameChecked)
            {
                if (OnUserRealnameChecked != null)
                {
                    AuthenticUser authenticUserInfo = GetAuthenticUserInfo(operatorUser, targetUserId);

                    if (authenticUserInfo != null)
                    {
                        OnUserRealnameChecked(targetUserId, authenticUserInfo.Realname, authenticUserInfo.IDNumber);
                    }
                    else
                    {
                        AuthUser user = GetAuthUser(targetUserId);
                        if (user != null)
                        {
                            OnUserRealnameChecked(targetUserId, user.Realname, string.Empty);
                        }
                    }
                }
            }
            else
            {
                if (OnUserCancelRealnameCheck != null)
                    OnUserCancelRealnameCheck(targetUserId);
            }
        }
示例#6
0
        public static string ParseForEdit(AuthUser operatorUser, int userID)
        {
            User user = UserBO.Instance.GetUser(userID);
            if (string.IsNullOrEmpty(user.Signature))
                return string.Empty;

            switch (UserBO.Instance.GetSignatureFormat(operatorUser))
            {
                case SignatureFormat.Html:
                    return user.Signature;
                case SignatureFormat.Ubb:
                    return HtmlToUbbParser.Html2Ubb(userID,  user.Signature);
                case SignatureFormat.Text:
                    return StringUtil.ClearAngleBracket(user.Signature);
                default:
                    return string.Empty;
            }
        }
示例#7
0
        public static DataForLogin GetAuthUserProxy(AuthUser authUser)
        {
            if (authUser == null)
                return null;

            DataForLogin authuserProxy = new DataForLogin();
            ConvertUserProxy(authuserProxy, authUser);

            authuserProxy.Password = authUser.Password;
            authuserProxy.PasswordFormat = (int)authUser.PasswordFormat;
            authuserProxy.UnreadMessages = authUser.UnreadMessages;
            authuserProxy.UnreadNotifies = GetUnreadNotifiesProxy(authUser.UnreadNotify);
            authuserProxy.IsActive = authUser.IsActive;

            authuserProxy.ExtendedFields = new List<UserExtendedValueProxy>();

            foreach (UserExtendedValue field in authUser.ExtendedFields)
            {
                authuserProxy.ExtendedFields.Add(GetUserExtendedValueProxy(field));
            }

            return authuserProxy;
        }
示例#8
0
 /// <summary>
 /// 只当纯判断是否回复过
 /// </summary>
 /// <param name="userID"></param>
 /// <returns></returns>
 public bool IsReplied(AuthUser operatorUser)
 {
     return(PostBOV5.Instance.IsRepliedThread(operatorUser, this));
 }
示例#9
0
        /// <summary>
        /// 获取用户的所有系统通知,包括已读未读的。
        /// </summary>
        /// <param name="operateUser">操作者</param>
        /// <param name="unreadIDs">返回集合内未读的系统通知编号</param>
        /// <returns></returns>
        public static SystemNotifyCollection GetMyAllSystemNotifies( AuthUser operateUser,out  List<int> unreadIDs )
        {
            SystemNotifyCollection allNotifys = Instance.AllSystemNotifys;

            SystemNotifyCollection myNotifys = new SystemNotifyCollection();
            UserRoleCollection myRoles = operateUser.Roles;
            unreadIDs = new List<int>();
            string myUserIDTag = string.Concat(",", operateUser.UserID, ",");

            foreach (SystemNotify notify in allNotifys)
            {
                if (!notify.Available)
                    continue;

                if (notify.ReceiveUserIDs.Contains(operateUser.UserID))
                {
                    if (!string.IsNullOrEmpty(notify.ReadUserIDs) && !notify.ReadUserIDs.Contains(myUserIDTag))//是否已读
                    {
                        unreadIDs.Add(notify.NotifyID);
                    }
                    myNotifys.Add(notify);
                }
                else
                {
                    foreach (UserRole ur in myRoles)
                    {
                        if (notify.ReceiveRoles.Contains(ur.RoleID))
                        {
                            if (!string.IsNullOrEmpty(notify.ReadUserIDs) && !notify.ReadUserIDs.Contains(myUserIDTag))//是否已读
                            {
                                unreadIDs.Add(notify.NotifyID);
                            }
                            myNotifys.Add(notify);
                            break;
                        }
                    }
                }
            }

            return myNotifys;
        }
示例#10
0
        private void Save()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("enddates");

            int[] medalIDs = _Request.GetList<int>("medalIDs2", Method.Post, new int[] { });

            Dictionary<int, DateTime> endDates = new Dictionary<int, DateTime>();
            Dictionary<int, string> urls = new Dictionary<int, string>();
            int i = 0;
            foreach (int id in medalIDs)
            {
                string dateString = _Request.Get("enddate_" + id, Method.Post);

                if (string.IsNullOrEmpty(dateString) == false)
                {
                    try
                    {
                        DateTime endDate = DateTime.Parse(dateString.Trim());

                        if (endDate < DateTimeUtil.Now)
                        {
                            msgDisplay.AddError("enddates", i, "过期时间必须大于当前时间");
                        }

                        endDates.Add(id, endDate);
                    }
                    catch
                    {
                        msgDisplay.AddError("enddates", i, "过期时间格式不正确");
                    }

                }
                else if (dateString == null)
                {

                }
                else
                    endDates.Add(id, DateTime.MaxValue);

                urls.Add(id, _Request.Get("url_" + id, Method.Post, string.Empty));

                i++;
            }

            if (msgDisplay.HasAnyError())
                return;

            try
            {
                using (ErrorScope es = new ErrorScope())
                {
                    if (!UserBO.Instance.UpdateUserMedals(My, UserID, endDates, urls))
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                    }
                    else
                    {
                        _Request.Clear(Method.Post);
                        m_User = UserBO.Instance.GetAuthUser(UserID);
                    }
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }

        }
示例#11
0
        public override bool Downloading(HttpContext context)
        {

            if (context.Request.QueryString["mode"] != null)
            {
                if (StringUtil.EqualsIgnoreCase(context.Request.QueryString["mode"], "image"))
                {
                    outputMode = OutputFileMode.Inline;
                }
                else
                {
                    outputMode = OutputFileMode.Attachment;

                    if (StringUtil.EqualsIgnoreCase(context.Request.QueryString["mode"], "media"))
                        isMedia = true;
                }

            }
            else
            {
                outputMode = OutputFileMode.Attachment;
            }

            operatorUser = User.Current;
            userID = operatorUser.UserID; //UserBO.Instance.GetCurrentUserID();

            //====处理3.0的附件============================================

            if (context.Request.QueryString["v"] == "3")
            {
                ProcessV30(context);
                return true;
            }

            //===================================================

            //预览或编辑器里显示 从网络硬盘里插入的附件
            if (context.Request.QueryString["diskfileID"] != null)
            {
                ProcessDiskFile(context);
                return true;
            }

            if (context.Request.QueryString["ID"] != null)
            {
                try
                {
                    attachmentID = int.Parse(context.Request.QueryString["ID"].Trim());
                }
                catch
                {
                    Context.ThrowError<InvalidParamError>(new InvalidParamError("ID"));
                    return false;
                    //Bbs3Globals.ShowError("error", "参数错误!", 0);
                }
            }
            else
            {
                Context.ThrowError<InvalidParamError>(new InvalidParamError("ID"));
                return false;
                //Bbs3Globals.ShowError("error", "参数错误!", 0);
            }

            //附件ID小于0,表示这是一个发帖时使用的临时文件
            if (attachmentID < 0)
            {
                if (isMedia)
                {
                    TempUploadFile tempFile = FileManager.GetUserTempUploadFile(userID, 0 - attachmentID);
                    if (tempFile == null)
                        return false;

                    int index = tempFile.FileName.LastIndexOf('.');
                    string fileType = tempFile.FileName.Substring(index, tempFile.FileName.Length - index);
                    ProcessMedia(context, fileType);
                }
                else if (false == OutputTempFile(context, userID, 0 - attachmentID, outputMode))
                {
                    ShowErrorMessage(context, "文件不存在,可能长时间没有发表导致被系统清理!", "临时文件不存在.gif");
                }
            }
            //附件ID大于0,表示这是一个真实的附件
            else
            {
                attachment = PostBOV5.Instance.GetAttachment(attachmentID, outputMode == OutputFileMode.Attachment);

                if (attachment == null)
                {
                    if (isMedia)
                        return false;
                    ShowErrorMessage(context, "该附件不存在,可能被移动或被删除!", "文件不存在.gif");
                    return false;
                }

                if (isMedia)
                {
                    ProcessMedia(context, "." + attachment.FileType);
                }

                string fileID = attachment.FileID;



                //处理3.0的 #attach:id#
                
                if (context.Request.QueryString["m"] != null)
                {
                    if (context.Request.QueryString["m"].ToLower() == "i" &&  MaxLabs.bbsMax.Ubb.PostUbbParserV5.isImage(attachment.FileType))
                    {
                        outputMode = OutputFileMode.Inline;
                    }
                }

                switch (Action(context))
                {
                    //case "buy":
                    //    ProcessBuy(context,fileID,null);
                    //    break;
                    default:
                        ProcessDownload(context, fileID);
                        //context.Response.End();
                        break;
                }
            }

            return true;
        }
示例#12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="username"></param>
        /// <param name="idCardImage"></param>
        public bool SaveUserRealnameData(AuthUser operatorUser,string idNumber, string realname,HttpPostedFile idCardFileFace,HttpPostedFile idCardFileBack)
        {
            if(operatorUser.UserID<=0)
            {
                ThrowError(new NotLoginError());
                return false;
            }

            if(!AllSettings.Current.NameCheckSettings.EnableRealnameCheck)
            {
                ThrowError(new CustomError("管理员未开启实名认证功能"));
                return false;
            }

            if (UserDao.Instance.CheckIdNumberExist(idNumber))
            { 
                ThrowError(new CustomError("idnumber","您输入的身份证号码已经存在"));
                return false;
            }

            AuthenticUser AuthenticUser = UserDao.Instance.GetAuthenticUser(operatorUser.UserID);

            if (AuthenticUser != null)
            {

                if (AuthenticUser.Processed == false)
                {
                    ThrowError(new CustomError("您的实名认证材料正在审核中请勿重复提交"));
                    return false;
                }

                if (AuthenticUser.Processed==true && operatorUser.RealnameChecked)
                {
                    ThrowError(new CustomError("您已经通过实名认证, 不可再更改身份信息"));
                    return false;
                }
            }

            realname = (string.Empty + realname).Trim();

            if(realname.Length<2||realname.Length>15)
            {
                ThrowError(new CustomError("realname", "姓名不能少于2个字符并且不能超过15个字符"));
                return false;
            }

            #region  中英文格式检查

            ////中文检查
            //bool formatchecked = false;
            //if (setting.CanChinese)
            //{
            //    if (Regex.IsMatch(realname, (@"^[\u4e00-\u9fa5\s]{2,8}$")))
            //    {
            //        formatchecked = true;
            //    }
            //}

            ////英文检查
            //if (setting.CanEnglish)
            //{
            //    if (Regex.IsMatch(realname, @"^[a-zA-Z]+\s{0,1}[a-zA-Z]+$"))
            //    {
            //        formatchecked = true;
            //    }
            //}

            //if (!setting.CanEnglish &&
            //    !setting.CanChinese &&
            //    !string.IsNullOrEmpty(realname)
            //   )
            //{
            //    //两种都不行 设置上 疏忽了, 那就没有限制
            //    formatchecked = true;
            //}

            //if (!formatchecked)
            //{
            //    ThrowError(new RealnameFormatError(realname, setting.CanChinese, setting.CanEnglish));
            //    return;
            //}

            #endregion

            if (!Regex.IsMatch(realname, (@"^[\u4e00-\u9fa5\s]{2,15}$")))
            {
                ThrowError(new CustomError("realname", "您输入的真实姓名包含无效的非中文字符"));
                return false;
            }

            string[] idCardInfo ;
            
            if( !IsIDCardNumber(idNumber,out idCardInfo))
            {
                ThrowError(new CustomError("idnumber","身份证号码无效"));
                return false;
            }

            string fullPathFace=string.Empty, fullPathBack= string.Empty;
            if (AllSettings.Current.NameCheckSettings.NeedIDCardFile)
            {
                bool saveFaceFile = true;
                bool saveBackFile = true;

                saveFaceFile = ValidateAndSavePostedFile(operatorUser, idCardFileFace, "idcardfileface", "face", out fullPathFace);
                saveBackFile = ValidateAndSavePostedFile(operatorUser, idCardFileBack, "idcardfileback", "back", out fullPathBack);

                if (saveBackFile == false || saveFaceFile == false)
                {
                    return false;
                }
            }

            Gender gender = StringUtil.TryParse<Gender>( idCardInfo[0]);
            DateTime birthday = StringUtil.TryParse<DateTime>(idCardInfo[1]);

            UserDao.Instance.SaveAuthenticUserInfo(operatorUser.UserID, realname, idNumber, fullPathFace,fullPathBack, birthday, gender, idCardInfo[2]);
            return true;
        }
示例#13
0
        public int DetectAuthenticInfo(AuthUser operatorUser, int userID, out List<string> photos)
        {
            photos = null;

            if (operatorUser.UserID <= 0)
            {
                ThrowError(new NotLoginError());
                return 4;
            }

            if (!CanRealnameCheck(operatorUser))
            {
                ThrowError(new NoPermissionRealnameCheckError());
                return 4;
            }

            AuthenticUser userInfo = GetAuthenticUserInfo(operatorUser, userID);

            if (userInfo == null)
            {
                ThrowError(new CustomError("没有该用户提交的实名认证材料"));
                return 4;
            }
            List<byte[]> photoData;
            int state = DetectAuthenticInfo(userInfo.Realname, userInfo.IDNumber, out photoData);

            if (state == 0)
            {
                photos = new List<string>();
                if (photoData != null)
                {
                    string photoString = "";
                    string temp;
                    string photoDirName = "Photos";
                    string photoPath = Globals.GetPath(SystemDirecotry.Upload_IDCard, photoDirName);
                    string virtualPath = Globals.GetVirtualPath(SystemDirecotry.Upload_IDCard, photoDirName);

                    if (!Directory.Exists(photoPath))
                    {
                        Directory.CreateDirectory(photoPath);
                    }

                    for (int i = 0; i < photoData.Count; i++)
                    {
                        string fileName = string.Format("{0}_{1}.jpg", userInfo.IDNumber, i);

                        if (photoString.Length > 0)
                            photoString += "|";

                        temp = UrlUtil.JoinUrl(virtualPath, fileName);
                        photoString += temp;

                        photos.Add(temp);

                        fileName = IOUtil.JoinPath(photoPath, fileName);
                        if (!File.Exists(fileName))
                            File.WriteAllBytes(fileName, photoData[i]);

                        if (photos.Count > 1) //多余的照片不要, 只要最多两张
                            break;
                    }

                    UserDao.Instance.UpdateAuthenticUserPhoto(userID, photoString,state);
                }
            }

            return state;
        }
示例#14
0
        /// <summary>
        /// 设置当前用户的隐身状态
        /// </summary>
        /// <param name="my"></param>
        /// <param name="isInvisible"></param>
        public void Update(AuthUser my, bool isInvisible)
        {
            int userID = my.UserID;

            if (userID > 0)
            {
                OnlineMember onlineMember;

                if (m_OnlineMemberTable.TryGetValue(userID, out onlineMember))
                    onlineMember.IsInvisible = isInvisible;
            }
        }
示例#15
0
文件: Forum.cs 项目: zhangbo27/bbsmax
 public bool IsVisitCheckPassed(AuthUser user)
 {
     return(ForumBO.Instance.IsVisitCheckPassed(user, this));
 }
示例#16
0
 public TempDataBox(AuthUser owner)
 {
     Owner = owner;
 }
示例#17
0
        public void Update(AuthUser my, RequestVariable request, OnlineAction action, int forumID, int threadID, string subject)
        {

            subject = StringUtil.CutString(subject, 20);



            int userID = my.UserID;
            string ip = request.IpAddress;

            bool addnew = false;

            //已经登录的用户
            if (userID > 0)
            {
                #region 已经登录的用户的处理

                OnlineMember onlineMember;
                if (m_OnlineMemberTable.TryGetValue(userID, out onlineMember) == false)
                {
                    string location = IPUtil.GetIpArea(ip);
                    RoleInOnline role = GetUserRoleInOnline(userID);
                    lock (m_OnlineMembers_Locker)
                    {
                        if (m_OnlineMemberTable.TryGetValue(userID, out onlineMember) == false)
                        {
                            #region 增加一个OnlineMember

                            DateTime now = DateTimeUtil.Now;

                            onlineMember = new OnlineMember();
                            onlineMember.UserID = userID;

                            onlineMember.Action = action;

                            onlineMember.Username = my.Username;
                            onlineMember.IsInvisible = my.IsInvisible;

                            onlineMember.IP = ip;
                            onlineMember.Location = location;

                            onlineMember.ForumID = forumID;
                            onlineMember.ThreadID = threadID;
                            onlineMember.ThreadSubject = subject;


                            onlineMember.Platform = request.Platform;
                            onlineMember.Browser = request.Browser;
                            onlineMember.CreateDate = now;
                            onlineMember.UpdateDate = now;
                            onlineMember.RoleSortOrder = role.SortOrder;
                            onlineMember.RoleIdentityIDString = my.RoleIdentityIDString;

                            m_OnlineMemberTable.Add(userID, onlineMember);
                            OnlineMemberCollection newOnlineMembers = new OnlineMemberCollection(m_OnlineMembers);
                            newOnlineMembers.Add(onlineMember);
                            m_OnlineMembers = newOnlineMembers;

                            if (forumID != 0)
                            {
                                lock (GetForumOnlineMemberLocker(forumID))
                                {
                                    //加入新的版块
                                    AddForumOnlineMember(forumID, onlineMember);
                                }
                            }

                            #endregion

                            addnew = true;
                        }
                    }
                }

                if (addnew == false)
                {
                    lock (onlineMember)
                    {
                        //ForumID为-1意味着其实已经删除,无需再更新
                        if (onlineMember.ForumID != -1)
                        {
                            #region 更新原来OnlineMember的值

                            onlineMember.Action = action;

                            onlineMember.Username = my.Username;
                            onlineMember.IsInvisible = my.IsInvisible;

                            if (my.RoleIdentityIDString != onlineMember.RoleIdentityIDString)
                            {
                                RoleInOnline role = GetUserRoleInOnline(userID);
                                onlineMember.RoleSortOrder = role.SortOrder;
                                onlineMember.RoleIdentityIDString = my.RoleIdentityIDString;
                            }

                            if (onlineMember.IP != ip)
                            {
                                onlineMember.IP = ip;
                                onlineMember.Location = IPUtil.GetIpArea(ip);
                            }

                            //-----------------

                            int oldForumID = onlineMember.ForumID;
                            onlineMember.ThreadID = threadID;
                            onlineMember.ThreadSubject = subject;

                            if (oldForumID != forumID)
                            {
                                if (oldForumID != 0 && forumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(oldForumID))
                                    {
                                        lock (GetForumOnlineMemberLocker(forumID))
                                        {
                                            //从原来的版块移除
                                            RemoveForumOnlineMember(oldForumID, onlineMember);
                                            //加入新的版块
                                            AddForumOnlineMember(forumID, onlineMember);
                                        }
                                    }
                                }
                                else if (oldForumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(oldForumID))
                                    {
                                        //从原来的版块移除
                                        RemoveForumOnlineMember(oldForumID, onlineMember);
                                    }
                                }
                                else if (forumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(forumID))
                                    {
                                        //加入新的版块
                                        AddForumOnlineMember(forumID, onlineMember);
                                    }
                                }
                                onlineMember.ForumID = forumID;
                            }


                            onlineMember.Platform = request.Platform;
                            onlineMember.Browser = request.Browser;
                            onlineMember.UpdateDate = DateTimeUtil.Now;

                            #endregion
                        }
                        else
                            LogHelper.CreateDebugLog("OnlineMember线程同步监视1");
                    }
                }

                #endregion

                //如果是已登陆状态,但客户端仍然提交了GuestID,则把这个GuestID移除
                //if (my.MachineIDIsNew == false)

                string guestID = my.GuestID;

                if (guestID != null)
                {
                    RemoveOnlineGuest(guestID);
                }
            }
            else
            //尚未登录的用户
            {
                //TODO : 暂不统计游客在线情况,因为可能存在溢出,下个版本改进



                #region 尚未登录的用户的处理


                bool isSpider = request.IsSpider;
                string guestID = my.BuildGuestID();

                OnlineGuest onlineGuest;
                if (m_OnlineGuestTable.TryGetValue(guestID, out onlineGuest) == false)
                {
                    string location = IPUtil.GetIpArea(ip);

                    lock (m_OnlineGuests_Locker)
                    {
                        //假如游客列表中还没有这个游客
                        if (m_OnlineGuestTable.TryGetValue(guestID, out onlineGuest) == false)
                        {
                            bool success = UpdateOnlineGuestIP(guestID, null, ip, isSpider);// AddGuestToIP(guestID, ip, request.IsSpider);
                            //bool success = true;

                            if (success)
                            {
                                #region 增加一个OnlineGuest

                                DateTime now = DateTimeUtil.Now;

                                onlineGuest = new OnlineGuest();
                                onlineGuest.GuestID = my.GuestID;
                                onlineGuest.IsSpider = isSpider;

                                onlineGuest.Action = action;

                                onlineGuest.IP = ip;
                                onlineGuest.Location = location;


                                onlineGuest.Platform = request.Platform;
                                onlineGuest.Browser = request.Browser;
                                onlineGuest.CreateDate = now;
                                onlineGuest.UpdateDate = now;

                                onlineGuest.ForumID = forumID;
                                onlineGuest.ThreadID = threadID;
                                onlineGuest.ThreadSubject = subject;

                                m_OnlineGuestTable.Add(guestID, onlineGuest);
                                OnlineGuestCollection newOnlineGuests = new OnlineGuestCollection(m_OnlineGuests);
                                newOnlineGuests.Add(onlineGuest);
                                m_OnlineGuests = newOnlineGuests;

                                if (forumID != 0)
                                {
                                    lock (GetForumOnlineGuestLocker(forumID))
                                    {
                                        //加入新的版块
                                        AddForumOnlineGuest(forumID, onlineGuest);
                                    }
                                }

                                #endregion

                                addnew = true;
                            }
                            else
                                return;
                        }
                    }
                }

                //如果只是更新原来的值,那么开始更新
                if (addnew == false)
                {
                    lock (onlineGuest)
                    {
                        //ForumID为-1表示其实这个对象已经从在线列表中移除了
                        if (onlineGuest.ForumID != -1)
                        {
                            #region 更新原来OnlineGuest的值

                            onlineGuest.Action = action;

                            //如果这个游客仅仅发生了IP变化,那么要更新IP表
                            if (onlineGuest.IP != ip)
                            {
                                UpdateOnlineGuestIP(guestID, onlineGuest.IP, ip, isSpider);

                                //RemoveGuestFromIP(guestID, onlineGuest.IP);
                                onlineGuest.IsSpider = isSpider;
                                onlineGuest.IP = ip;
                                onlineGuest.Location = IPUtil.GetIpArea(ip);
                                //AddGuestToIP(guestID, onlineGuest.IP, request.IsSpider);
                            }

                            //----------------------

                            int oldForumID = onlineGuest.ForumID;

                            if (oldForumID != forumID)
                            {
                                if (oldForumID != 0 && forumID != 0)
                                {
                                    lock (GetForumOnlineGuestLocker(oldForumID))
                                    {
                                        lock (GetForumOnlineGuestLocker(forumID))
                                        {
                                            //从原来的版块移除
                                            RemoveForumOnlineGuest(oldForumID, onlineGuest);
                                            //加入新的版块
                                            AddForumOnlineGuest(forumID, onlineGuest);
                                        }
                                    }
                                }
                                else if (oldForumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(oldForumID))
                                    {
                                        //从原来的版块移除
                                        RemoveForumOnlineGuest(oldForumID, onlineGuest);
                                    }
                                }
                                else if (forumID != 0)
                                {
                                    lock (GetForumOnlineMemberLocker(forumID))
                                    {
                                        //加入新的版块
                                        AddForumOnlineGuest(forumID, onlineGuest);
                                    }
                                }

                                onlineGuest.ForumID = forumID;
                            }


                            onlineGuest.Platform = request.Platform;
                            onlineGuest.Browser = request.Browser;
                            onlineGuest.UpdateDate = DateTimeUtil.Now;

                            onlineGuest.ThreadID = threadID;
                            onlineGuest.ThreadSubject = subject;
                            #endregion
                        }
                        else
                            LogHelper.CreateDebugLog("OnlineGuest线程同步监视1");
                    }

                }

                #endregion
            }


        }
示例#18
0
 /// <summary>
 /// 输出日期和时间
 /// </summary>
 /// <param name="time"></param>
 /// <returns></returns>
 public static string FormatDateTime(AuthUser user, DateTime time,bool outputSecond)
 {
     double dateDiff = GetTimeDiffrence(user.TimeZone);
     time = time.AddHours(dateDiff);
     return FormatDateTime(time, outputSecond);
 }
示例#19
0
 public static string GetFriendlyDateTime(AuthUser user, DateTime dateTime)
 {
     float timeDiff = 0.0f;
     //获取当前用户和服务器时间的时差
     timeDiff = UserBO.Instance.GetUserTimeDiffrence(user);
     //
     return GetFriendlyDateTime(dateTime, timeDiff, true);
 }
示例#20
0
        private void AddMedal()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("userMedal", "enddate");


            string idString = _Request.Get("userMedal", Method.Post, string.Empty).Trim();

            if (idString == string.Empty)
            {
                msgDisplay.AddError("userMedal", "请选择图标");
            }

            DateTime dateTime = DateTime.MaxValue;
            string dateString = _Request.Get("enddate", Method.Post, string.Empty).Trim();

            if (dateString == string.Empty)
                dateTime = DateTime.MaxValue;
            else
            {
                try
                {
                    dateTime = DateTime.Parse(dateString);
                }
                catch
                {
                    msgDisplay.AddError("enddate", "时间格式不正确");
                }
            }

            if (msgDisplay.HasAnyError())
            {
                return;
            }



            int medalID = 0;
            int levelID = 0;

            try
            {
                medalID = int.Parse(idString.Substring(0, idString.IndexOf('_')));
                levelID = int.Parse(idString.Substring(idString.IndexOf('_') + 1));
            }
            catch
            {
                msgDisplay.AddError("userMedal", "请选择图标");
                return;
            }

            string url = _Request.Get("url", Method.Post, string.Empty);
            try
            {
                using (ErrorScope es = new ErrorScope())
                {
                    if (!UserBO.Instance.AddMedalUsers(My, medalID, levelID, new int[] { UserID }, dateTime, url))
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                    }
                    else
                    {
                        _Request.Clear(Method.Post);
                        m_User = UserBO.Instance.GetAuthUser(UserID);
                    }
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }

        }
示例#21
0
        public AuthenticUserCollection GetAuthenticUsers( AuthUser operatorUser,AuthenticUserFilter filter,int pageNumber)
        {

            if (this.CanRealnameCheck(operatorUser))
            {

                if (filter.PageSize <= 0)
                    filter.PageSize = Consts.DefaultPageSize;

                if (pageNumber <= 0)
                    pageNumber = 1;

                return  UserDao.Instance.GetAuthenticUsers(filter, pageNumber);
            }
            else
            {
                ThrowError(new NoPermissionRealnameCheckError());
            }
            return new AuthenticUserCollection();
        }
示例#22
0
        public static UserProfileProxy GetUserProfileProxy(AuthUser user)
        {
            if (user == null)
                return null;

            UserProfileProxy proxy = new UserProfileProxy();
            proxy.UserID = user.UserID;
            proxy.Gender = (int)user.Gender;
            proxy.GenderName = user.GenderName;
            proxy.Birthday = user.Birthday;
            proxy.TimeZone = user.TimeZone;
            proxy.Signature = user.Signature;
            proxy.SignatureFormat = (int)user.SignatureFormat;
            proxy.ExtendedFields = new List<UserExtendedValueProxy>();

            foreach (UserExtendedValue item in user.ExtendedFields)
            {
                proxy.ExtendedFields.Add(GetUserExtendedValueProxy(item));
            }

            return proxy;
        }
示例#23
0
        public AuthenticUser GetAuthenticUserInfo( AuthUser operatorUser,int userID )
        {
            if (userID == operatorUser.UserID || UserBO.Instance.CanRealnameCheck(operatorUser))
            {
               return  UserDao.Instance.GetAuthenticUser(userID);
            }
            else
            {
               ThrowError(new NoPermissionRealnameCheckError());
                return null;
            }

        }
示例#24
0
 void UserBO_OnUserCreated(AuthUser newUser)
 {
     DataForNewUser data = ProxyConverter.GetDataForNewUser(newUser);
     CreateInstruct(0, InstructType.User_Create, data);
 }
示例#25
0
        private bool ValidateAndSavePostedFile(AuthUser operatorUser,HttpPostedFile postedFile, string errorName,string extraFileSuffix,out string fullPath)
        {
            fullPath = string.Empty;
            if (postedFile == null)
            {
                ThrowError(new CustomError(errorName, "请上传身份证" + (extraFileSuffix=="face"?"正面":"背面") + "扫描件"));
                return false;
            }

            List<string> allowedFileType = new List<string>(new string[] { ".jpg", ".png", ".gif" });

            byte[] data = new byte[postedFile.ContentLength];

            if (data.Length > AllSettings.Current.NameCheckSettings.MaxIDCardFileSize)
            {
                ThrowError(new CustomError(errorName, "身份证扫描件文件大小不能超过" + ConvertUtil.FormatSize(AllSettings.Current.NameCheckSettings.MaxIDCardFileSize)));
                return false;
            }

            postedFile.InputStream.Read(data, 0, data.Length);

            string fileType = Path.GetExtension(postedFile.FileName).ToLower();

            if (!allowedFileType.Contains(fileType) || !IOUtil.IsImageFile(data, ImageFileType.GIF | ImageFileType.JPG | ImageFileType.PNG))
            {
                ThrowError(new CustomError(errorName, "身份证扫描件格式不正确"));
                return false;
            }

            string newFileName = string.Format("{0}-{1}{2}", operatorUser.UserID, extraFileSuffix, ".config");
            string path = IOUtil.JoinPath(Globals.GetPath(SystemDirecotry.Upload_IDCard), operatorUser.UserID.ToString());

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path); //不做异常捕获
            }

            try
            {
                File.WriteAllBytes(IOUtil.JoinPath(path, newFileName), data);
            }
            catch (Exception ex)
            {
                ThrowError(new CustomError("发生了系统错误" + ex.Message));
                return false;
            }

            fullPath = IOUtil.JoinPath(Globals.GetVirtualPath(SystemDirecotry.Upload_IDCard),operatorUser.UserID.ToString(),newFileName);

            return true;

        }
示例#26
0
        /// <summary>
        /// 获取用户的未读系统通知
        /// </summary>
        /// <param name="operatorUser"></param>
        public static void GetMySystemNotifys(AuthUser operatorUser)
        {
            int maxID = 0;
            SystemNotifyCollection allNotifys = Instance.AllSystemNotifys;
            if (operatorUser.SystemNotifyVersion == Instance.NotifyVersion)
                return;
            
            SystemNotifyCollection myNotifys=new SystemNotifyCollection();
            UserRoleCollection myRoles = operatorUser.Roles;

            string myUserIDTag = string.Concat(",", operatorUser.UserID, ",");

            foreach (SystemNotify notify in allNotifys)
            {
                if (maxID < notify.NotifyID)
                    maxID = notify.NotifyID;
                if (!notify.Available)
                    continue;

                if (notify.NotifyID <= operatorUser.LastReadSystemNotifyID)//
                    continue;

                if (!string.IsNullOrEmpty(notify.ReadUserIDs) && notify.ReadUserIDs.Contains(myUserIDTag))//是否已读
                    continue;
                

                if (notify.ReceiveUserIDs.Contains(operatorUser.UserID))
                {
                    myNotifys.Add(notify);
                }
                else
                {
                    foreach (UserRole ur in myRoles)
                    {
                        if (notify.ReceiveRoles.Contains(ur.RoleID))
                        {
                            myNotifys.Add(notify);
                            break;
                        }
                    }
                }
            }

            operatorUser.SystemNotifys = myNotifys;
            operatorUser.SystemNotifyVersion = Instance.NotifyVersion;
            //user.LastReadSystemNotifyID = maxid;
            //UserBO.Instance.UpdateMaxSystemNotifyID(user.UserID, maxid);               
            //Instance.AllSystemNotifys
        }
示例#27
0
        public void Remove(AuthUser my)
        {
            int userID = my.UserID;

            //已经登录的用户
            if (userID > 0)
            {
                OnlineMember onlineMember;
                if (RemoveOnlineMember(userID, out onlineMember))
                    UserBO.Instance.UpdateOnlineTime(onlineMember);
            }
            else
            {
                string guestID = my.GuestID;

                if (guestID != null)
                    RemoveOnlineGuest(my.GuestID);
            }
        }
示例#28
0
        private void DeleteMedals()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();

            int[] medalIDs = _Request.GetList<int>("medalids", Method.Post, new int[0] { });

            List<int> ids = new List<int>();
            foreach (int id in medalIDs)
            {
                if (id != 0)
                    ids.Add(id);
            }

            try
            {
                using (ErrorScope es = new ErrorScope())
                {
                    if (!UserBO.Instance.DeleteUserMedals(My, UserID, ids))
                    {
                        es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                    }
                    else
                    {
                        _Request.Clear(Method.Post);
                        m_User = UserBO.Instance.GetAuthUser(UserID);
                    }
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }
示例#29
0
 public TempDataBox(AuthUser owner)
 {
     Owner = owner;
 }
示例#30
0
 /// <summary>
 /// 附件是否买过
 /// </summary>
 public bool IsBuyed(AuthUser operatorUser)
 {
     return(PostBOV5.Instance.IsBuyedAttachment(operatorUser, this));
 }
示例#31
0
        public static DataForNewUser GetDataForNewUser(AuthUser user)
        {

            if (user == null || user == User.Guest)
                return null;

            DataForNewUser userDataProxy = new DataForNewUser();
            ConvertUserProxy(userDataProxy, user);

            userDataProxy.GenderName = user.GenderName;
            userDataProxy.ExtendedFields = new List<UserExtendedValueProxy>();

            foreach (UserExtendedValue extendedValue in user.ExtendedFields)
            {
                userDataProxy.ExtendedFields.Add(GetUserExtendedValueProxy(extendedValue));
            }

            userDataProxy.IPAddress = user.LastVisitIP;
            userDataProxy.IsActive = user.IsActive;
            userDataProxy.Password = user.Password;
            userDataProxy.PasswordFormat = (int)user.PasswordFormat;
            userDataProxy.Signature = user.Signature;
            userDataProxy.SignatureFormat = (int)user.SignatureFormat;
            userDataProxy.TimeZone = user.TimeZone;
            userDataProxy.InviterID = user.InviterID;

            //getfriend

            FriendGroupCollection friendgroups = user.FriendGroups;
            userDataProxy.FriendGroups = new List<MaxLabs.Passport.Proxy.FriendGroupProxy>();

            foreach (FriendGroup fg in friendgroups)
            {
                MaxLabs.Passport.Proxy.FriendGroupProxy fgp = GetFriendGroupProxy(fg);
                userDataProxy.FriendGroups.Add(fgp);
                FriendCollection friends = FriendBO.Instance.GetFriends(user.UserID, fg.GroupID);

                foreach (MaxLabs.bbsMax.Entities.Friend friend in friends)
                {
                    fgp.Friends.Add(GetFriendProxy(friend));
                }
            }

            //getExtendedFields
            //userDataProxy.ExtendedFields = GetStringKeyValueList(user.ExtendedFields);

            return userDataProxy;
        }
示例#32
0
        private static string OnMatchAllAttach(Match match, AuthUser operatorUser, User postUser, int forumID, AttachmentCollection attachments, ForumSettingItem forumSetting
            , ref bool? hasViewAttachPermission, ref bool? canAlwaysViewContents, ref bool? allowImageTag, ref bool? allowAudioTag, ref bool? allowVideoTag, ref bool? allowFlashTag)
        {
            if (match.Success == false)
                return match.Value;

            string type = match.Groups["type"].Value;

            if (hasViewAttachPermission == null)
                hasViewAttachPermission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(forumID).Can(operatorUser, ForumPermissionSetNode.Action.ViewAttachment);

            if (!hasViewAttachPermission.Value)
            {
                string message;
                if (operatorUser.UserID == 0)
                {
                    message = "您是游客";
                }
                else
                {
                    message = string.Empty;
                }

                if (StringUtil.EqualsIgnoreCase(type, "img"))
                    return GetNopermissionStyle(string.Concat(message, "您没有权限查看该图片"));
                else if (StringUtil.EqualsIgnoreCase(type, "media"))
                    return GetNopermissionStyle(string.Concat(message, "您没有权限查看该多媒体"));
                else
                {
                    int attachID = int.Parse(match.Groups["id"].Value);
                    Attachment attachment = attachments.GetValue(attachID);
                    if (attachment != null)
                        return GetNoPermissonfileStyle(attachment.FileName, operatorUser.UserID == 0);
                    else
                        return match.Value;
                }
            }
            else
            {
                int attachID = int.Parse(match.Groups["id"].Value);
                Attachment attachment = attachments.GetValue(attachID);

                if (attachment == null)
                    return match.Value;

                if (canAlwaysViewContents == null)
                {
                    ForumPermissionSetNode forumPermission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(forumID);
                    canAlwaysViewContents = forumPermission.Can(operatorUser, ForumPermissionSetNode.Action.AlwaysViewContents);
                }

                if (StringUtil.EqualsIgnoreCase(type, "img"))
                {
                    if (allowImageTag == null)
                    {
                        allowImageTag = forumSetting.CreatePostAllowImageTag.GetValue(postUser);
                    }
                    if (allowImageTag.Value)
                    {
                        if (attachment.Price == 0 || attachment.UserID == operatorUser.UserID || canAlwaysViewContents.Value || attachment.IsBuyed(operatorUser) || attachment.IsOverSellDays(forumSetting))
                        {
                            //string info = string.Concat("<br /><img src=\"", attachment.FileIcon, "\" alt=\"\" /><a href=\"", BbsUrlHelper.GetAttachmentUrl(attachment.AttachmentID), "\">", attachment.FileName, "</a>  <span class=\"filesize gray\">(大小:", attachment.FileSizeFormat, "    下载次数:", attachment.TotalDownloads.ToString(), ")</span><br />");

                            string[] param = StringUtil.Split(match.Groups["param"].Value);
                            string width, height;
                            if (param.Length > 1)
                            {
                                width = param[0];
                                height = param[1];
                            }
                            else
                            {
                                width = string.Empty;
                                height = string.Empty;
                            }
                            return GetImageUrl(attachment.AttachmentID, false, width, height);
                        }
                        else
                        {
                            return string.Concat("<br /><img src=\"", attachment.FileIcon, "\" alt=\"\" />", attachment.FileName, " <span class=\"filesize gray\">(大小:", attachment.FileSizeFormat, "    下载次数:" + attachment.TotalDownloads.ToString(), ")</span><br />", GetNopermissionStyle("您需要购买后才能查看该图片"));
                        }
                    }
                    else
                        return ProcessAttach(attachment, operatorUser, forumSetting, canAlwaysViewContents.Value);
                }
                else if (StringUtil.EqualsIgnoreCase(type, "media"))
                {
                    if (attachment.Price == 0 || canAlwaysViewContents.Value || attachment.UserID == operatorUser.UserID || attachment.IsBuyed(operatorUser)
                        || attachment.IsOverSellDays(forumSetting))
                    {
                        string[] param = StringUtil.Split(match.Groups["param"].Value);
                        string width, height;
                        bool auto = false;
                        if (param.Length > 1)
                        {
                            width = param[0];
                            height = param[1];
                            if (param.Length > 2)
                            {
                                if (string.Compare(param[2], "1") == 0)
                                {
                                    auto = true;
                                }
                            }
                        }
                        else
                        {
                            width = string.Empty;
                            height = string.Empty;
                        }

                        //return string.Concat("<br /><img src=\"", attachment.FileIcon, "\" alt=\"\" />", "<a href=\"", BbsUrlHelper.GetAttachmentUrl(attachment.AttachmentID), "\">", attachment.FileName
                        //    , "</a>  <span class=\"filesize gray\">(大小:", attachment.FileSizeFormat, "    下载次数:", attachment.TotalDownloads, ")</span><br />"
                        //    , GetMediaContent(attachment, false, width, height, auto, forumSetting, user, ref allowAudioTag, ref allowVideoTag, ref allowFlashTag));

                        return GetMediaContent(attachment, false, width, height, auto, forumSetting, operatorUser, ref allowAudioTag, ref allowVideoTag, ref allowFlashTag);

                    }
                    else
                    {
                        return string.Concat("<br /><img src=\"", attachment.FileIcon, "\" alt=\"\" />", attachment.FileName, "<span class=\"filesize gray\">(大小:", attachment.FileSizeFormat
                            , "    下载次数:", attachment.TotalDownloads, ")</span><br />", GetNopermissionStyle("您需要购买后才能查看该多媒体"));
                    }
                }
                else
                {
                    return ProcessAttach(attachment, operatorUser, forumSetting, canAlwaysViewContents.Value);
                }
            }
        }
示例#33
0
 void UserBO_OnUserProfileChanged(AuthUser user)
 {
     CreateInstruct(user.UserID, InstructType.User_ChangeProfile, ProxyConverter.GetUserProfileProxy(user));
 }
示例#34
0
 private static string ProcessAttach(Attachment attachment, AuthUser operatorUser, ForumSettingItem forumSetting, bool canAlwaysViewContents)
 {
     if (attachment.Price == 0 || canAlwaysViewContents || attachment.UserID == operatorUser.UserID || attachment.IsBuyed(operatorUser) || attachment.IsOverSellDays(forumSetting))
     {
         return GetAttachUrl(attachment);
     }
     else//附件没购买,不显示。
     {
         return GetMustBuyFileLink(attachment.FileName);
     }
 }