Example #1
0
        public bool Add(UserGroupsInfo userGroupsInfo)
        {
            userGroupsInfo.GroupId = GetNewGroupId();
            Parameters parms = new Parameters();

            parms = GetProcdbComm(parms, userGroupsInfo);
            bool flag = false;

            try
            {
                if (DBHelper.ExecuteNonQueryProc("PR_UserManage_UserGroups_Add", parms) > 0)
                {
                    flag = true;
                }
            }
            catch
            {
                flag = false;
            }
            return(flag);
        }
Example #2
0
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            UserGroupsInfo userGroupById = UserGroups.GetUserGroupById(DataConverter.CLng(this.HdnGroupId.Value));

            userGroupById.GroupSetting = new Serialize <UserPurviewInfo>().SerializeField(this.UserIndividuation.PurviewInfo);
            switch (UserGroups.Update(userGroupById))
            {
            case DataActionState.Successed:
                AdminPage.WriteSuccessMsg("<li>设置" + userGroupById.GroupName + "会员组权限成功!</li>", "UserGroupManage.aspx");
                return;

            case DataActionState.Exist:
                break;

            case DataActionState.Unknown:
                AdminPage.WriteErrMsg("<li>设置" + userGroupById.GroupName + "会员组权限失败!</li>", "UserGroupManage.aspx");
                break;

            default:
                return;
            }
        }
Example #3
0
        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            UserGroupsInfo userGroupById;
            GroupType      type = (GroupType)Enum.Parse(typeof(GroupType), this.DropGropType.SelectedValue);

            if (this.HdnAction.Value == "Modify")
            {
                userGroupById = UserGroups.GetUserGroupById(DataConverter.CLng(this.HdnGroupId.Value));
            }
            else
            {
                userGroupById = new UserGroupsInfo();
            }
            userGroupById.GroupName   = this.TxtGroupName.Text;
            userGroupById.Description = this.TxtDescription.Text;
            userGroupById.GroupType   = type;
            DataActionState unknown = DataActionState.Unknown;

            if (this.Page.IsValid)
            {
                if (this.HdnAction.Value == "Modify")
                {
                    unknown = DataActionState.Exist;
                    if ((userGroupById.GroupName != this.HdnGroupName.Value) && UserGroups.GroupNameIsExist(userGroupById.GroupName))
                    {
                        this.ShowMessage(unknown);
                    }
                    unknown = UserGroups.Update(userGroupById);
                }
                else
                {
                    unknown        = UserGroups.Add(userGroupById);
                    this.m_groupId = userGroupById.GroupId;
                }
                this.ShowMessage(unknown);
            }
        }
        protected void BtnUpload_Click(object sender, EventArgs e)
        {
            int uploadSize = 0;

            if (!SiteConfig.SiteOption.EnableUploadFiles)
            {
                this.LblMessage.Text = "权限错误:你当前的网站没有开启上传功能,请检查你的网站配置。";
            }
            else
            {
                if (!PEContext.Current.Admin.Identity.IsAuthenticated)
                {
                    if (!PEContext.Current.User.Identity.IsAuthenticated)
                    {
                        UserGroupsInfo userGroupById = UserGroups.GetUserGroupById(-2);
                        if (string.IsNullOrEmpty(userGroupById.GroupSetting))
                        {
                            this.LblMessage.Text = "匿名会员组不存在!";
                            return;
                        }
                        UserPurviewInfo groupSetting = UserGroups.GetGroupSetting(userGroupById.GroupSetting);
                        if (groupSetting.IsNull)
                        {
                            this.LblMessage.Text = "匿名会员组没有进行权限设置!";
                            return;
                        }
                        if (!groupSetting.EnableUpload)
                        {
                            this.LblMessage.Text = "匿名会员组没有开启上传权限!";
                            return;
                        }
                        uploadSize = groupSetting.UploadSize;
                    }
                    else
                    {
                        if (!PEContext.Current.User.UserInfo.UserPurview.EnableUpload)
                        {
                            this.LblMessage.Text = "所属会员组没有开启上传权限!";
                            return;
                        }
                        uploadSize = PEContext.Current.User.UserInfo.UserPurview.UploadSize;
                    }
                }
                string str  = BasePage.RequestString("ReturnJSFunction");
                int    num2 = DataConverter.CLng(base.Request.Form["ThumbIndex"]);
                if (string.IsNullOrEmpty(str))
                {
                    str = "DealwithUpload";
                }
                StringBuilder builder = new StringBuilder();
                builder.Append("<script language=\"javascript\" type=\"text/javascript\">");
                if (!PEContext.Current.Admin.Identity.IsAuthenticated && (this.m_PhotoSize > uploadSize))
                {
                    this.m_PhotoSize = uploadSize;
                }
                int           num3     = 0;
                StringBuilder builder2 = new StringBuilder();
                for (int i = 0; i < 10; i++)
                {
                    num3++;
                    System.Web.UI.WebControls.FileUpload upload = (System.Web.UI.WebControls.FileUpload) this.FindControl("FileUpload" + i.ToString());
                    if (upload.HasFile)
                    {
                        string str2 = Path.GetExtension(upload.FileName).ToLower();
                        if (!this.CheckFilePostfix(str2.Replace(".", "")))
                        {
                            builder2.Append("文件" + upload.FileName + "上传文件类型不对!必须上传" + this.m_FileExtArr + @"的后缀名!\n");
                        }
                        else if (((int)upload.FileContent.Length) > (this.m_PhotoSize * 0x400))
                        {
                            builder2.Append("文件" + upload.FileName + "请上传小于" + this.m_PhotoSize.ToString() + @"KB的文件!\n");
                        }
                        else
                        {
                            string str3     = DataSecurity.MakeFileRndName() + i.ToString();
                            string filename = FileSystemObject.CreateFileFolder((VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir) + this.FileSavePath(upload.FileName)).Replace("//", "/"), HttpContext.Current) + str3 + str2;
                            upload.SaveAs(filename);
                            Thumbs.GetThumbsPath(this.m_ShowPath + str3 + str2, this.m_ShowPath + str3 + "_S" + str2);
                            if (this.m_Watermark)
                            {
                                WaterMark.AddWaterMark(this.m_ShowPath + str3 + str2);
                            }
                            EasyOne.Model.Accessories.FileInfo fileInfo = new EasyOne.Model.Accessories.FileInfo();
                            fileInfo.Name  = upload.FileName;
                            fileInfo.Path  = this.m_ShowPath + str3 + str2;
                            fileInfo.Size  = (int)upload.FileContent.Length;
                            fileInfo.Quote = 1;
                            Files.Add(fileInfo);
                            if (i == num2)
                            {
                                builder.Append("parent." + str + "ChangeThumbField(\"" + fileInfo.Path + "\",\"" + this.m_ShowPath + str3 + "_S" + str2 + "\");");
                            }
                            else
                            {
                                builder.Append("parent." + str + "DealwithUpload(\"" + fileInfo.Path + "\",\"" + fileInfo.Size.ToString() + "\",\"" + fileInfo.Id.ToString() + "\",\"" + this.m_ShowPath + str3 + "_S" + str2 + "\");");
                            }
                            builder2.Append("文件" + upload.FileName + @"上传成功!\n");
                        }
                    }
                }
                if (builder2.Length > 0)
                {
                    builder.Append("parent." + str + "ErrMessage(\"" + builder2.ToString() + "\");");
                }
                builder.Append("</script>");
                this.Page.ClientScript.RegisterStartupScript(base.GetType(), "UpdateParent", builder.ToString());
            }
        }
        protected void BtnUpload_Click(object sender, EventArgs e)
        {
            if (!this.FupFile.HasFile)
            {
                this.ReturnManage("上传失败,重新上传。");
                return;
            }
            int  uploadFileMaxSize = 0;
            int  uploadSize        = 0;
            bool flag  = false;
            bool flag2 = false;

            if (!SiteConfig.SiteOption.EnableUploadFiles)
            {
                this.ReturnManage("权限错误:对不起网站没有开启上传权限。");
                return;
            }
            if (!PEContext.Current.Admin.Identity.IsAuthenticated)
            {
                if (!PEContext.Current.User.Identity.IsAuthenticated)
                {
                    UserGroupsInfo userGroupById = UserGroups.GetUserGroupById(-2);
                    if (string.IsNullOrEmpty(userGroupById.GroupSetting))
                    {
                        this.ReturnManage("匿名会员组不存在!");
                        return;
                    }
                    UserPurviewInfo groupSetting = UserGroups.GetGroupSetting(userGroupById.GroupSetting);
                    if (groupSetting.IsNull)
                    {
                        this.ReturnManage("匿名会员组没有进行权限设置!");
                        return;
                    }
                    if (!groupSetting.EnableUpload)
                    {
                        this.ReturnManage("匿名会员组没有开启上传权限!");
                        return;
                    }
                    uploadSize = groupSetting.UploadSize;
                }
                else
                {
                    if (!PEContext.Current.User.UserInfo.UserPurview.EnableUpload)
                    {
                        this.ReturnManage("所属会员组没有开启上传权限!");
                        return;
                    }
                    uploadSize = PEContext.Current.User.UserInfo.UserPurview.UploadSize;
                }
            }
            string str = Path.GetExtension(this.FupFile.FileName).ToLower();

            if (!this.CheckFilePostfix(str.Replace(".", "")))
            {
                this.ReturnManage("上传文件类型不对!必须上传" + this.m_FileExtArr + "的后缀名!");
                return;
            }
            if (string.Compare(this.m_ModuleName, "Node", StringComparison.OrdinalIgnoreCase) == 0)
            {
                FieldInfo           fieldInfoByFieldName = Field.GetFieldInfoByFieldName(this.m_ModelId, this.m_FieldName);
                Collection <string> settings             = fieldInfoByFieldName.Settings;
                switch (fieldInfoByFieldName.FieldType)
                {
                case FieldType.PictureType:
                    uploadFileMaxSize = DataConverter.CLng(settings[1]);
                    flag2             = DataConverter.CBoolean(settings[4]);
                    flag = DataConverter.CBoolean(settings[5]);
                    goto Label_01EA;

                case FieldType.FileType:
                    uploadFileMaxSize = DataConverter.CLng(settings[0]);
                    goto Label_01EA;
                }
            }
            else
            {
                uploadFileMaxSize = SiteConfig.SiteOption.UploadFileMaxSize;
            }
Label_01EA:
            if (!PEContext.Current.Admin.Identity.IsAuthenticated && (uploadFileMaxSize > uploadSize))
            {
                uploadFileMaxSize = uploadSize;
            }
            if (((int)this.FupFile.FileContent.Length) > (uploadFileMaxSize * 0x400))
            {
                this.ReturnManage("请上传小于" + uploadFileMaxSize.ToString() + "KB的文件!");
            }
            else
            {
                string str2     = DataSecurity.MakeFileRndName();
                string filename = FileSystemObject.CreateFileFolder((VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir) + this.FileSavePath()).Replace("//", "/"), HttpContext.Current) + str2 + str;
                this.FupFile.SaveAs(filename);
                string thumbnailPath = "";
                if (flag)
                {
                    thumbnailPath = this.m_ShowPath + str2 + "_S" + str;
                    Thumbs.GetThumbsPath(this.m_ShowPath + str2 + str, thumbnailPath);
                }
                else
                {
                    thumbnailPath = this.m_ShowPath + str2 + str;
                }
                if (flag2)
                {
                    WaterMark.AddWaterMark(this.m_ShowPath + str2 + str);
                }
                EasyOne.Model.Accessories.FileInfo fileInfo = new EasyOne.Model.Accessories.FileInfo();
                fileInfo.Name  = this.FupFile.FileName;
                fileInfo.Path  = thumbnailPath;
                fileInfo.Size  = (int)this.FupFile.FileContent.Length;
                fileInfo.Quote = 1;
                if (string.Compare(this.m_ModuleName, "soft", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    Files.Add(fileInfo);
                }
                this.GetScriptByModuleName(fileInfo);
                this.ReturnManage("上传成功!");
            }
        }
Example #6
0
        protected override void OnLoad(EventArgs e)
        {
            HttpPostedFile file              = base.Request.Files["NewFile"];
            string         str               = Path.GetExtension(file.FileName).ToLower();
            string         uploaderType      = base.Request.Form["UploaderType"];
            bool           flag              = DataConverter.CBoolean(base.Request.Form["IsWatermark"]);
            bool           flag2             = DataConverter.CBoolean(base.Request.Form["IsThumb"]);
            int            modelId           = DataConverter.CLng(base.Request.Form["ModelId"]);
            string         str3              = DataSecurity.FilterBadChar(base.Request.Form["FieldName"]);
            string         allowSuffix       = "";
            int            uploadFileMaxSize = 0;
            int            uploadSize        = 0;
            string         customMsg         = "请检查网站信息配置是否设置允许的上传文件大小!";

            if (!SiteConfig.SiteOption.EnableUploadFiles)
            {
                this.SendResults(0xcc);
            }
            else
            {
                if (!PEContext.Current.Admin.Identity.IsAuthenticated)
                {
                    if (!PEContext.Current.User.Identity.IsAuthenticated)
                    {
                        UserGroupsInfo userGroupById = UserGroups.GetUserGroupById(-2);
                        if (string.IsNullOrEmpty(userGroupById.GroupSetting))
                        {
                            this.SendResults(1, "", "", "匿名会员组不存在!");
                            return;
                        }
                        UserPurviewInfo groupSetting = UserGroups.GetGroupSetting(userGroupById.GroupSetting);
                        if (groupSetting.IsNull)
                        {
                            this.SendResults(1, "", "", "匿名会员组没有进行权限设置!");
                            return;
                        }
                        if (!groupSetting.EnableUpload)
                        {
                            this.SendResults(1, "", "", "匿名会员组没有开启上传权限!");
                            return;
                        }
                        uploadSize = groupSetting.UploadSize;
                    }
                    else
                    {
                        if (!PEContext.Current.User.UserInfo.UserPurview.EnableUpload)
                        {
                            this.SendResults(1, "", "", "所属会员组没有开启上传权限!");
                            return;
                        }
                        uploadSize = PEContext.Current.User.UserInfo.UserPurview.UploadSize;
                    }
                }
                if ((file == null) || (file.ContentLength == 0))
                {
                    this.SendResults(0xca);
                }
                else
                {
                    if ((modelId == 0) || string.IsNullOrEmpty(str3))
                    {
                        if (!ConfigurationManager.AppSettings["EasyOne:DefaultUploadSuffix"].ToLower().Contains(str))
                        {
                            this.SendResults(1, "", "", "不允许上传动态页文件!");
                            return;
                        }
                        uploadFileMaxSize = SiteConfig.SiteOption.UploadFileMaxSize;
                    }
                    else
                    {
                        IList <FieldInfo> fieldListByModelId = ModelManager.GetFieldListByModelId(modelId);
                        if ((fieldListByModelId != null) && (fieldListByModelId.Count > 0))
                        {
                            foreach (FieldInfo info3 in fieldListByModelId)
                            {
                                if (string.CompareOrdinal(info3.FieldName, str3) == 0)
                                {
                                    allowSuffix = GetAllowSuffix(info3, uploaderType);
                                    if (info3.Settings.Count > 7)
                                    {
                                        uploadFileMaxSize = DataConverter.CLng(info3.Settings[7]);
                                    }
                                    break;
                                }
                            }
                        }
                        if (string.IsNullOrEmpty(allowSuffix))
                        {
                            this.SendResults(1, "", "", "字段内容控件没有填写允许上传的后缀!");
                            return;
                        }
                        if (!allowSuffix.Contains(str.Replace(".", "")))
                        {
                            this.SendResults(1, "", "", "这种文件类型不允许上传!只允许上传这几种文件类型:" + allowSuffix);
                            return;
                        }
                        customMsg = "请检查所属字段控件是否设置了允许上传文件大小!";
                    }
                    if (uploadFileMaxSize <= 0)
                    {
                        this.SendResults(1, "", "", customMsg);
                    }
                    else
                    {
                        if (!PEContext.Current.Admin.Identity.IsAuthenticated && (uploadFileMaxSize > uploadSize))
                        {
                            uploadFileMaxSize = uploadSize;
                        }
                        if (file.ContentLength > (uploadFileMaxSize * 0x400))
                        {
                            this.SendResults(1, "", "", "请上传小于" + uploadFileMaxSize.ToString() + "KB的文件!");
                        }
                        else
                        {
                            string str9;
                            int    errorNumber = 0;
                            string fileUrl     = "";
                            string str7        = DataSecurity.MakeFileRndName();
                            string str8        = str7 + str;
                            int    num5        = 0;
                            while (true)
                            {
                                str9 = Path.Combine(base.UserFilesDirectory, str8);
                                if (!File.Exists(str9))
                                {
                                    break;
                                }
                                num5++;
                                str8        = string.Concat(new object[] { Path.GetFileNameWithoutExtension(file.FileName), "(", num5, ")", Path.GetExtension(file.FileName) });
                                errorNumber = 0xc9;
                            }
                            file.SaveAs(str9);
                            fileUrl = base.UserFilesPath + str8;
                            if (!string.IsNullOrEmpty(uploaderType) && (string.CompareOrdinal(uploaderType, "Photo") == 0))
                            {
                                string oldValue = "";
                                if (base.Request.ApplicationPath.EndsWith("/", StringComparison.Ordinal))
                                {
                                    oldValue = ("/" + SiteConfig.SiteOption.UploadDir + "/").Replace("//", "/");
                                }
                                else
                                {
                                    oldValue = base.Request.ApplicationPath + "/" + SiteConfig.SiteOption.UploadDir;
                                }
                                if (flag2)
                                {
                                    string str11 = base.UserFilesPath + str7 + "_S" + str;
                                    Thumbs.GetThumbsPath(fileUrl.Replace(oldValue, ""), str11.Replace(oldValue, ""));
                                }
                                if (flag)
                                {
                                    WaterMark.AddWaterMark(fileUrl.Replace(oldValue, ""));
                                }
                            }
                            this.SendResults(errorNumber, fileUrl, str8);
                        }
                    }
                }
            }
        }