Пример #1
0
        public static PathSecurityResult Check(string path)
        {
            var sep        = System.IO.Path.DirectorySeparatorChar;
            var result     = new PathSecurityResult();
            var pathToFind = path;

            if (pathToFind[pathToFind.Length - 1].ToString() != sep.ToString())
            {
                pathToFind = pathToFind + sep;
            }

            var site = FindFirst(pathToFind, SiteRepository.GetPaths());

            if (site == null)
            {
                result.Result = pathToFind.StartsWith(QPConfiguration.TempDirectory);
                return(result);
            }

            var images = $@"{sep}images";

            pathToFind = pathToFind.Replace(site.Path, string.Empty);
            if (pathToFind.StartsWith(images, CompareOption))
            {
                result.IsSite = true;
                pathToFind    = pathToFind.Replace(images, string.Empty);

                var checksiteFolderResult = CheckSiteFolder(pathToFind, site.Id);
                result.Result   = checksiteFolderResult.Result;
                result.FolderId = checksiteFolderResult.FolderId;
                return(result);
            }

            var contents = new Regex($@"^\{sep}contents\{sep}([\d]+)");
            var match    = contents.Match(pathToFind);

            if (match.Success)
            {
                var contentId = int.Parse(match.Groups[1].Value);
                pathToFind = pathToFind.Replace(match.Value, string.Empty);
                return(CheckContentFolder(pathToFind, contentId));
            }

            return(result);
        }
Пример #2
0
        private static PathSecurityResult CheckSiteFolder(string pathToFind, int siteId)
        {
            var result     = new PathSecurityResult();
            var factory    = new SiteFolderFactory();
            var siteFolder = FindLongest(pathToFind, factory.CreateRepository().GetPaths(siteId));

            if (siteFolder != null)
            {
                result.Result   = SecurityRepository.IsEntityAccessible(EntityTypeCode.SiteFolder, siteFolder.Id, ActionTypeCode.Update);
                result.FolderId = siteFolder.Id;
            }
            else
            {
                result.Result = SecurityRepository.IsEntityAccessible(EntityTypeCode.Site, siteId, ActionTypeCode.Update);
            }

            return(result);
        }
Пример #3
0
        public static PathSecurityResult Check(string path)
        {
            var result     = new PathSecurityResult();
            var pathToFind = path;

            if (pathToFind[pathToFind.Length - 1].ToString() != @"\")
            {
                pathToFind = pathToFind + @"\";
            }

            var site = FindFirst(pathToFind, SiteRepository.GetPaths());

            if (site == null)
            {
                result.Result = false;
                return(result);
            }

            var images = @"\images";

            pathToFind = pathToFind.Replace(site.Path, string.Empty);
            if (pathToFind.StartsWith(images, CompareOption))
            {
                result.IsSite = true;
                pathToFind    = pathToFind.Replace(images, string.Empty);

                var checksiteFolderResult = CheckSiteFolder(pathToFind, site.Id);
                result.Result   = checksiteFolderResult.Result;
                result.FolderId = checksiteFolderResult.FolderId;
                return(result);
            }

            var contents = new Regex(@"^\\contents\\([\d]+)");
            var match    = contents.Match(pathToFind);

            if (match.Success)
            {
                var contentId = int.Parse(match.Groups[1].Value);
                pathToFind = pathToFind.Replace(match.Value, string.Empty);
                return(CheckContentFolder(pathToFind, contentId));
            }

            return(result);
        }