Example #1
0
        private void LoadSettings()
        {
            timeZone           = SiteUtils.GetUserTimeZone();
            virtualSourcePath  = $"~/Data/Sites/{siteSettings.SiteId.ToInvariantString()}/SharedFiles/";
            virtualHistoryPath = $"~/Data/Sites/{siteSettings.SiteId.ToInvariantString()}/SharedFiles/History/";

            lnkCancelFile.NavigateUrl   = SiteUtils.GetCurrentPageUrl();
            lnkCancelFolder.NavigateUrl = lnkCancelFile.NavigateUrl;


            //this page handles both folders and files
            //expected strItem examples are 23~folder and 13~file
            //the number portion is the ItemID of the folder or file
            if (strItem.IndexOf("~") > -1)
            {
                try
                {
                    char[]   separator = { '~' };
                    string[] args      = strItem.Split(separator);
                    itemId = int.Parse(args[0]);
                    type   = args[1];
                }
                catch { };
            }

            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(moduleId);

            config = new SharedFilesConfiguration(moduleSettings);

            divHistory.Visible = config.EnableVersioning;

            uploader.UploadButtonClientId = btnUpload.ClientID;
            uploader.ServiceUrl           = SiteRoot + "/SharedFiles/upload.ashx?pageid=" + pageId.ToInvariantString()
                                            + "&mid=" + moduleId.ToInvariantString()
                                            + "&ItemID=" + itemId.ToInvariantString();

            uploader.FormFieldClientId = hdnCurrentFolderId.ClientID;

            string refreshFunction = "function refresh" + moduleId.ToInvariantString()
                                     + " () { window.location.reload(true); } ";

            uploader.UploadCompleteCallback = $"refresh{moduleId.ToInvariantString()}";

            ScriptManager.RegisterClientScriptBlock(
                this,
                GetType(),
                $"refresh{moduleId.ToInvariantString()}",
                refreshFunction,
                true
                );

            AddClassToBody("sharedfilesedit");

            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];

            if (p == null)
            {
                return;
            }

            fileSystem = p.GetFileSystem();
        }
Example #2
0
        private void LoadSettings()
        {
            try
            {
                // this keeps the action from changing during ajax postback in folder based sites
                SiteUtils.SetFormAction(Page, Request.RawUrl);
            }
            catch (MissingMethodException)
            {
                //this method was introduced in .NET 3.5 SP1
            }

            virtualRoot           = WebUtils.GetApplicationRoot();
            moduleSettings        = ModuleSettings.GetModuleSettings(moduleId);
            currentUser           = SiteUtils.GetCurrentSiteUser();
            timeOffset            = SiteUtils.GetUserTimeOffset();
            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();

            module = new Module(moduleId);

            if (module.ModuleTitle.Length > 0)
            {
                litModuleTitle.Text     = Server.HtmlEncode(module.ModuleTitle);
                lblHtmlSettings.Visible = false;
            }

            pageSize = WebUtils.ParseInt32FromHashtable(moduleSettings, "HtmlVersionPageSizeSetting", pageSize);
            enableContentVersioning = WebUtils.ParseBoolFromHashtable(moduleSettings, "HtmlEnableVersioningSetting", HtmlEnableVersioningSetting);

            if ((siteSettings.ForceContentVersioning) || (WebConfigSettings.EnforceContentVersioningGlobally))
            {
                enableContentVersioning = true;
            }


            useExcerpt = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "HtmlUseExcerptSetting", false);



            useMoreLink = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "HtmlUseMoreLinkSetting", false);



            useMultipleItems = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "HtmlMultipleItemsSetting", false);



            if ((WebUser.IsAdminOrContentAdmin) || (SiteUtils.UserIsSiteEditor()))
            {
                isAdmin = true;
            }


            edContent.WebEditor.ToolBar = ToolBar.FullWithTemplates;


            if (moduleSettings.Contains("HtmlEditorHeightSetting"))
            {
                edContent.WebEditor.Height = Unit.Parse(moduleSettings["HtmlEditorHeightSetting"].ToString());
            }



            divHistoryDelete.Visible = (enableContentVersioning && isAdmin);

            pnlHistory.Visible = enableContentVersioning;

            if (enableContentVersioning)
            {
                SetupHistoryRestoreScript();
            }

            html = repository.Fetch(moduleId);
            if (html == null)
            {
                html            = new HtmlContent();
                html.ModuleId   = moduleId;
                html.ModuleGuid = module.ModuleGuid;
            }

            //if (this.itemId > -1)
            //{
            //    html = repository.Fetch(moduleId, itemId);
            //}
            //else
            //{
            //    if (useMultipleItems)
            //    {
            //        html = new HtmlContent();
            //        html.ModuleId = this.moduleId;
            //        html.CreatedBy = currentUser.UserId;
            //    }
            //    else
            //    {
            //        html = repository.Fetch(moduleId);
            //    }
            //}

            if ((!userCanEdit) && (userCanEditAsDraft))
            {
                btnUpdate.Visible      = false;
                btnUpdateDraft.Visible = true;
            }

            btnUpdateDraft.Text = Resource.EditHtmlUpdateDraftButton;

            if ((WebConfigSettings.EnableContentWorkflow) && (siteSettings.EnableContentWorkflow))
            {
                workInProgress = ContentWorkflow.GetWorkInProgress(this.module.ModuleGuid);
                //bool draftOnlyAccess = UserCanOnlyEditModuleAsDraft(moduleId);

                if (workInProgress != null)
                {
                    // let editors toggle between draft and live view in the editor
                    if (userCanEdit)
                    {
                        SetupWorkflowControls();
                    }

                    switch (workInProgress.Status)
                    {
                    case ContentWorkflowStatus.Draft:

                        //there is a draft version currently available, therefore dont allow the non draft version to be edited:
                        btnUpdateDraft.Visible = true;
                        btnUpdate.Visible      = false;
                        if (ViewMode == PageViewMode.WorkInProgress)
                        {
                            litModuleTitle.Text += " - " + Resource.ApprovalProcessStatusDraft;
                        }
                        break;

                    case ContentWorkflowStatus.ApprovalRejected:
                        //rejected content - allow update as draft only
                        btnUpdateDraft.Visible = true;
                        btnUpdate.Visible      = false;
                        if (ViewMode == PageViewMode.WorkInProgress)
                        {
                            litModuleTitle.Text += " - " + Resource.ApprovalProcessStatusRejected;
                        }
                        break;

                    case ContentWorkflowStatus.AwaitingApproval:
                        //pending approval - dont allow any edited:
                        // 2010-01-18 let editors update the draft if they want to before approving it.
                        btnUpdateDraft.Visible = userCanEdit;

                        btnUpdate.Visible = false;
                        if (ViewMode == PageViewMode.WorkInProgress)
                        {
                            litModuleTitle.Text += " - " + Resource.ApprovalProcessStatusAwaitingApproval;
                        }
                        break;
                    }
                }
                else
                {
                    //workInProgress is null there is no draft
                    if (userCanEdit)
                    {
                        btnUpdateDraft.Text    = Resource.CreateDraftButton;
                        btnUpdateDraft.Visible = true;
                    }
                }

                if ((userCanEdit) && (ViewMode == PageViewMode.Live))
                {
                    btnUpdateDraft.Visible = false;
                    btnUpdate.Visible      = true;
                }
            }
        }
Example #3
0
        private void LoadSettings()
        {
            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();
            mojoSetup.EnsureFolderGalleryFolder(siteSettings);

            pageId   = WebUtils.ParseInt32FromQueryString("pageid", -1);
            moduleId = WebUtils.ParseInt32FromQueryString("mid", -1);

            // previous value
            //~/Data/Sites/{0}/FolderGalleries/
            // changed to
            //~/Data/Sites/{0}/media/FolderGalleries/
            // 2013-04-04
            // did this to make more useful since that allows browsing the images from the wysiwyg editor

            //basePath = "~/Data/Sites/"
            //    + siteSettings.SiteId.ToInvariantString()
            //    + "/FolderGalleries/";
            basePath = string.Format(CultureInfo.InvariantCulture,
                                     FolderGalleryConfiguration.BasePathFormat,
                                     siteSettings.SiteId);

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            config         = new FolderGalleryConfiguration(moduleSettings);

            // this check is for backward compat with galleries previously created below ~/Data/Sites/{0}/FolderGalleries/
            if (config.GalleryRootFolder.Length > 0)
            {
                if (!config.GalleryRootFolder.StartsWith(basePath))
                {
                    // legacy path
                    basePath = "~/Data/Sites/"
                               + siteSettings.SiteId.ToInvariantString()
                               + "/FolderGalleries/";
                }
            }

            try
            {
                // ensure directory
                if (!Directory.Exists(Server.MapPath(basePath)))
                {
                    Directory.CreateDirectory(Server.MapPath(basePath));
                }
            }
            catch (IOException ex)
            {
                log.Error(ex);
            }

            //allowEditUsersToChangeFolderPath = WebUtils.ParseBoolFromHashtable(
            //    moduleSettings, "AllowEditUsersToChangeFolderPath", allowEditUsersToChangeFolderPath);

            //allowEditUsersToUpload = WebUtils.ParseBoolFromHashtable(
            //    moduleSettings, "AllowEditUsersToUpload", allowEditUsersToUpload);

            if (!WebUser.IsAdminOrContentAdmin)
            {
                pnlUpload.Visible = config.AllowEditUsersToUpload;
                pnlEdit.Visible   = config.AllowEditUsersToChangeFolderPath;
            }

            uploader.MaxFilesAllowed      = FolderGalleryConfiguration.MaxFilesToUploadAtOnce;
            uploader.AcceptFileTypes      = SecurityHelper.GetRegexValidationForAllowedExtensionsJqueryFileUploader(WebConfigSettings.ImageFileExtensions);
            uploader.UploadButtonClientId = btnUpload.ClientID;
            uploader.ServiceUrl           = SiteRoot + "/FolderGallery/upload.ashx?pageid=" + pageId.ToInvariantString()
                                            + "&mid=" + moduleId.ToInvariantString();
            uploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form

            string refreshFunction = "function refresh" + moduleId.ToInvariantString()
                                     + " () { window.location.href = '" + SiteUtils.GetCurrentPageUrl() + "'; } ";

            uploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString();

            ScriptManager.RegisterClientScriptBlock(
                this,
                this.GetType(), "refresh" + moduleId.ToInvariantString(),
                refreshFunction,
                true);


            AddClassToBody("foldergalleryedit");
        }
Example #4
0
        public void ProcessRequest(HttpContext context)
        {
            base.Initialize(context);

            if (!UserCanEditModule(ModuleId, Blog.FeatureGuid))
            {
                log.Info("User has no edit permission so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentSite == null)
            {
                log.Info("CurrentSite is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentUser == null)
            {
                log.Info("CurrentUser is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (FileSystem == null)
            {
                log.Info("FileSystem is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (Request.Files.Count == 0)
            {
                log.Info("Posted File Count is zero so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (Request.Files.Count > BlogConfiguration.MaxAttachmentsToUploadAtOnce)
            {
                log.Info("Posted File Count is higher than allowed so returning 404");
                Response.StatusCode = 404;
                return;
            }

            itemId = WebUtils.ParseInt32FromQueryString("ItemID", itemId);

            if (itemId == -1)
            {
                log.Info("No ItemID provided so returning 404");
                Response.StatusCode = 404;
                return;
            }

            module = GetModule(ModuleId, Blog.FeatureGuid);

            if (module == null)
            {
                log.Info("Module is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            blog = new Blog(itemId);
            if (blog.ModuleId != ModuleId)
            {
                log.Info("Invalid ItemID for module so returning 404");
                Response.StatusCode = 404;
                return;
            }

            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);

            config = new BlogConfiguration(moduleSettings);

            context.Response.ContentType = "text/plain";//"application/json";
            var r = new System.Collections.Generic.List <UploadFilesResult>();
            JavaScriptSerializer js = new JavaScriptSerializer();

            SiteUtils.EnsureFileAttachmentFolder(CurrentSite);
            string upLoadPath = SiteUtils.GetFileAttachmentUploadPath();

            for (int f = 0; f < Request.Files.Count; f++)
            {
                HttpPostedFile file = Request.Files[f];

                string ext = System.IO.Path.GetExtension(file.FileName);

                if (!SiteUtils.IsAllowedUploadBrowseFile(ext, WebConfigSettings.AllowedMediaFileExtensions))
                {
                    log.Info("file extension was " + ext + " so discarding file " + file.FileName);

                    r.Add(new UploadFilesResult()
                    {
                        Name         = file.FileName,
                        Length       = file.ContentLength,
                        Type         = file.ContentType,
                        ErrorMessage = string.Format(
                            CultureInfo.InvariantCulture,
                            GalleryResources.InvalidUploadExtensionFormat,
                            file.FileName,
                            WebConfigSettings.AllowedMediaFileExtensions.Replace("|", " "))
                    });

                    continue;
                }

                string mimeType = IOHelper.GetMimeType(ext).ToLower();

                FileAttachment a = new FileAttachment();
                a.CreatedBy      = CurrentUser.UserGuid;
                a.FileName       = System.IO.Path.GetFileName(file.FileName);
                a.ServerFileName = blog.ItemId.ToInvariantString() + a.FileName.ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);
                a.ModuleGuid     = blog.ModuleGuid;
                a.SiteGuid       = CurrentSite.SiteGuid;
                a.ItemGuid       = blog.BlogGuid;
                a.ContentLength  = file.ContentLength;
                a.ContentType    = mimeType;

                a.Save();

                string destPath = upLoadPath + a.ServerFileName;

                using (Stream s = file.InputStream)
                {
                    FileSystem.SaveFile(destPath, s, mimeType, true);
                }

                r.Add(new UploadFilesResult()
                {
                    //Thumbnail_url =
                    Name   = a.FileName,
                    Length = file.ContentLength,
                    Type   = mimeType
                });

                if (WebConfigSettings.LogAllFileServiceRequests)
                {
                    string userName = "******";
                    if (CurrentUser != null)
                    {
                        userName = CurrentUser.Name;
                    }
                    log.Info("File " + file.FileName + " uploaded by " + userName + " as a media attachment in the Blog");
                }
            }

            var uploadedFiles = new
            {
                files = r.ToArray()
            };

            var jsonObj = js.Serialize(uploadedFiles);

            context.Response.Write(jsonObj.ToString());
        }
Example #5
0
        public void ProcessRequest(HttpContext context)
        {
            base.Initialize(context);

            if (!UserCanEditModule(ModuleId, FolderGalleryConfiguration.FeatureGuid))
            {
                log.Info("User has no edit permission so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentSite == null)
            {
                log.Info("CurrentSite is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentUser == null)
            {
                log.Info("CurrentUser is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            // this feature only uses the actual system.io file system
            //if (FileSystem == null)
            //{
            //    log.Info("FileSystem is null so returning 404");
            //    Response.StatusCode = 404;
            //    return;
            //}

            if (Request.Files.Count == 0)
            {
                log.Info("Posted File Count is zero so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (Request.Files.Count > FolderGalleryConfiguration.MaxFilesToUploadAtOnce)
            {
                log.Info("Posted File Count is higher than configured limit so returning 404");
                Response.StatusCode = 404;
                return;
            }

            module = GetModule(ModuleId, FolderGalleryConfiguration.FeatureGuid);

            if (module == null)
            {
                log.Info("Module is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);

            config = new FolderGalleryConfiguration(moduleSettings);

            string imageFolderPath;

            if (config.GalleryRootFolder.Length > 0)
            {
                imageFolderPath = config.GalleryRootFolder;
            }
            else
            {
                imageFolderPath = string.Format(CultureInfo.InvariantCulture,
                                                FolderGalleryConfiguration.BasePathFormat,
                                                CurrentSite.SiteId);
            }

            context.Response.ContentType = "text/plain";//"application/json";
            var r = new System.Collections.Generic.List <UploadFilesResult>();
            JavaScriptSerializer js = new JavaScriptSerializer();

            try
            {
                for (int f = 0; f < Request.Files.Count; f++)
                {
                    HttpPostedFile file = Request.Files[f];

                    string ext         = Path.GetExtension(file.FileName);
                    string newFileName = Path.GetFileName(file.FileName);
                    if (SiteUtils.IsAllowedUploadBrowseFile(ext, ".jpg|.gif|.png|.jpeg"))
                    {
                        string newImagePath = VirtualPathUtility.Combine(imageFolderPath, newFileName);

                        if (File.Exists(Server.MapPath(newImagePath)))
                        {
                            File.Delete(Server.MapPath(newImagePath));
                        }

                        file.SaveAs(Server.MapPath(newImagePath));

                        //using (Stream s = file.InputStream)
                        //{
                        //    //FileSystem.SaveFile(newImagePath, s, file.ContentType, true);

                        //}


                        r.Add(new UploadFilesResult()
                        {
                            //Thumbnail_url =
                            Name   = newFileName,
                            Length = file.ContentLength,
                            Type   = file.ContentType
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }

            var uploadedFiles = new
            {
                files = r.ToArray()
            };

            var jsonObj = js.Serialize(uploadedFiles);

            context.Response.Write(jsonObj.ToString());
        }
Example #6
0
        public void ProcessRequest(HttpContext context)
        {
            base.Initialize(context);

            if (!UserCanEditModule(ModuleId, XmlConfiguration.FeatureGuid))
            {
                log.Info("User has no edit permission so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentSite == null)
            {
                log.Info("CurrentSite is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentUser == null)
            {
                log.Info("CurrentUser is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            // this feature only uses the actual system.io file system
            //if (FileSystem == null)
            //{
            //    log.Info("FileSystem is null so returning 404");
            //    Response.StatusCode = 404;
            //    return;
            //}

            if (Request.Files.Count == 0)
            {
                log.Info("Posted File Count is zero so returning 404");
                Response.StatusCode = 404;
                return;
            }

            module = GetModule(ModuleId, XmlConfiguration.FeatureGuid);

            if (module == null)
            {
                log.Info("Module is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);

            config = new XmlConfiguration(moduleSettings);

            HttpPostedFile file = Request.Files[0]; // only expecting one file per post

            string newFileName = Path.GetFileName(file.FileName).ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);

            string ext = Path.GetExtension(file.FileName).ToLowerInvariant();

            if (!SiteUtils.IsAllowedUploadBrowseFile(ext, ".xml|.xsl"))
            {
                log.Info("file extension was " + ext + " so returning 404");
                Response.StatusCode = 404;

                return;
            }

            context.Response.ContentType = "text/plain";//"application/json";
            var r = new System.Collections.Generic.List <UploadFilesResult>();
            JavaScriptSerializer js = new JavaScriptSerializer();


            string destPath;

            switch (ext)
            {
            case ".xml":
                string xmlBasePath = "~/Data/Sites/" + CurrentSite.SiteId.ToInvariantString() + "/xml/";
                destPath = Server.MapPath(xmlBasePath + newFileName);

                if (File.Exists(destPath))
                {
                    File.Delete(destPath);
                }

                file.SaveAs(destPath);

                break;

            case ".xsl":
                string xslBasePath = "~/Data/Sites/" + CurrentSite.SiteId.ToInvariantString() + "/xsl/";
                destPath = Server.MapPath(xslBasePath + newFileName);

                if (File.Exists(destPath))
                {
                    File.Delete(destPath);
                }

                file.SaveAs(destPath);

                break;
            }

            r.Add(new UploadFilesResult()
            {
                //Thumbnail_url =
                Name   = newFileName,
                Length = file.ContentLength,
                Type   = file.ContentType
            });

            var uploadedFiles = new
            {
                files = r.ToArray()
            };

            var jsonObj = js.Serialize(uploadedFiles);

            context.Response.Write(jsonObj.ToString());
        }
Example #7
0
        private void LoadSettings()
        {
            userCanEdit = UserCanEditModule(ModuleId);



            moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);

            config = new ForumConfiguration(moduleSettings);
            searchBoxTop.Visible = config.ShowForumSearchBox && !displaySettings.HideSearchOnForumView;

            if ((searchBoxTop.Visible) && (displaySettings.UseBottomSearchOnForumView))
            {
                searchBoxTop.Visible    = false;
                searchBoxBottom.Visible = true;
            }

            threadList.Forum          = forum;
            threadList.Config         = config;
            threadList.PageId         = PageId;
            threadList.ModuleId       = ModuleId;
            threadList.ItemId         = ItemId;
            threadList.PageNumber     = pageNumber;
            threadList.SiteRoot       = SiteRoot;
            threadList.NonSslSiteRoot = SiteUtils.GetInSecureNavigationSiteRoot();
            threadList.ImageSiteRoot  = ImageSiteRoot;
            threadList.IsEditable     = userCanEdit;

            threadListAlt.Forum          = forum;
            threadListAlt.Config         = config;
            threadListAlt.PageId         = PageId;
            threadListAlt.ModuleId       = ModuleId;
            threadListAlt.ItemId         = ItemId;
            threadListAlt.PageNumber     = pageNumber;
            threadListAlt.SiteRoot       = SiteRoot;
            threadListAlt.NonSslSiteRoot = threadList.NonSslSiteRoot;
            threadListAlt.ImageSiteRoot  = ImageSiteRoot;
            threadListAlt.IsEditable     = userCanEdit;

            if (displaySettings.UseAltThreadList)
            {
                threadList.Visible    = false;
                threadListAlt.Visible = true;
            }

            if (config.InstanceCssClass.Length > 0)
            {
                pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass);
            }

            AddClassToBody("forumview");

            if ((CurrentPage != null) && (CurrentPage.BodyCssClass.Length > 0))
            {
                AddClassToBody(CurrentPage.BodyCssClass);
            }

            if (ForumConfiguration.TrackFakeTopicUrlInAnalytics)
            {
                SetupAnalytics();
            }
        }
        private List <IndexItem> GetRecentContent()
        {
            List <IndexItem> recentContent = null;

            if (pageId == -1)
            {
                return(recentContent);
            }
            if (moduleId == -1)
            {
                return(recentContent);
            }

            pageSettings = CacheHelper.GetCurrentPage();
            module       = GetModule();

            if (module != null)
            {
                moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
                config         = new RecentContentConfiguration(moduleSettings);
                shouldRender   = config.EnableFeed;
                if (!shouldRender)
                {
                    return(null);
                }

                bool shouldRedirectToFeedburner = false;
                if (config.FeedburnerFeedUrl.Length > 0)
                {
                    shouldRedirectToFeedburner = true;
                    if ((Request.UserAgent != null) && (Request.UserAgent.Contains("FeedBurner")))
                    {
                        shouldRedirectToFeedburner = false; // don't redirect if the feedburner bot is reading the feed
                    }

                    Guid redirectBypassToken = WebUtils.ParseGuidFromQueryString("r", Guid.Empty);
                    if (redirectBypassToken == Global.FeedRedirectBypassToken)
                    {
                        shouldRedirectToFeedburner = false; // allows time for user to subscribe to autodiscovery links without redirecting
                    }
                }

                if (shouldRedirectToFeedburner)
                {
                    redirectUrl  = config.FeedburnerFeedUrl;
                    shouldRender = false;
                    return(null);
                }

                feedCacheTimeInMinutes = config.FeedCacheTimeInMinutes;
                channelTitle           = config.FeedChannelTitle;
                channelLink            = WebUtils.ResolveServerUrl(SiteUtils.GetCurrentPageUrl());
                channelDescription     = config.FeedChannelDescription;
                channelCopyright       = config.FeedChannelCopyright;
                channelManagingEditor  = config.FeedChannelManagingEditor;
                channelTimeToLive      = config.FeedTimeToLiveInMinutes;


                if (config.GetCreated)
                {
                    recentContent = IndexHelper.GetRecentCreatedContent(
                        siteSettings.SiteId,
                        config.GetFeatureGuids(),
                        DateTime.UtcNow.AddDays(-config.MaxDaysOldRecentItemsToGet),
                        config.MaxRecentItemsToGet);
                }
                else
                {
                    recentContent = IndexHelper.GetRecentModifiedContent(
                        siteSettings.SiteId,
                        config.GetFeatureGuids(),
                        DateTime.UtcNow.AddDays(-config.MaxDaysOldRecentItemsToGet),
                        config.MaxRecentItemsToGet);
                }
            }


            return(recentContent);
        }
Example #9
0
        private void LoadSettings()
        {
            virtualRoot = WebUtils.GetApplicationRoot();

            pageId                = WebUtils.ParseInt32FromQueryString("pageid", -1);
            moduleId              = WebUtils.ParseInt32FromQueryString("mid", -1);
            forumId               = WebUtils.ParseInt32FromQueryString("forumid", -1);
            threadId              = WebUtils.ParseInt32FromQueryString("thread", -1);
            postId                = WebUtils.ParseInt32FromQueryString("postid", -1);
            pageNumber            = WebUtils.ParseInt32FromQueryString("pagenumber", 1);
            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();
            timeOffset            = SiteUtils.GetUserTimeOffset();
            timeZone              = SiteUtils.GetUserTimeZone();

            isModerator    = UserCanEditModule(moduleId, Forum.FeatureGuid);
            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            config         = new ForumConfiguration(moduleSettings);

            postList.Config                 = config;
            postList.PageId                 = pageId;
            postList.ModuleId               = moduleId;
            postList.ItemId                 = forumId;
            postList.ThreadId               = threadId;
            postList.PageNumber             = pageNumber;
            postList.IsAdmin                = WebUser.IsAdmin;
            postList.IsCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles);
            postList.SiteRoot               = SiteRoot;
            postList.ImageSiteRoot          = ImageSiteRoot;
            postList.SiteSettings           = siteSettings;
            postList.IsEditable             = false;
            postList.IsSubscribedToForum    = true;

            postListAlt.Config                 = config;
            postListAlt.PageId                 = pageId;
            postListAlt.ModuleId               = moduleId;
            postListAlt.ItemId                 = forumId;
            postListAlt.ThreadId               = threadId;
            postListAlt.PageNumber             = pageNumber;
            postListAlt.IsAdmin                = postList.IsAdmin;
            postListAlt.IsCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles);
            postListAlt.SiteRoot               = SiteRoot;
            postListAlt.ImageSiteRoot          = ImageSiteRoot;
            postListAlt.SiteSettings           = siteSettings;
            postListAlt.IsEditable             = false;
            postListAlt.IsSubscribedToForum    = true;

            if (Request.IsAuthenticated)
            {
                theUser = SiteUtils.GetCurrentSiteUser();
                if (theUser != null)
                {
                    if (forumId > -1)
                    {
                        isSubscribedToForum = Forum.IsSubscribed(forumId, theUser.UserId);
                    }
                    if (threadId > -1)
                    {
                        isSubscribedToThread = ForumThread.IsSubscribed(threadId, theUser.UserId);
                    }
                }
            }

            if (isModerator)
            {
                edMessage.WebEditor.ToolBar = ToolBar.FullWithTemplates;
            }
            else if ((Request.IsAuthenticated) && (WebUser.IsInRoles(siteSettings.UserFilesBrowseAndUploadRoles)))
            {
                edMessage.WebEditor.ToolBar = ToolBar.ForumWithImages;
            }
            else
            {
                edMessage.WebEditor.ToolBar = ToolBar.Forum;
            }

            edMessage.WebEditor.SetFocusOnStart = true;
            edMessage.WebEditor.Height          = Unit.Parse("350px");

            if (config.UseSpamBlockingForAnonymous)
            {
                captcha.ProviderName        = siteSettings.CaptchaProvider;
                captcha.Captcha.ControlID   = "captcha" + moduleId.ToString(CultureInfo.InvariantCulture);
                captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
                captcha.RecaptchaPublicKey  = siteSettings.RecaptchaPublicKey;
            }

            forum = new Forum(forumId);

            if (displaySettings.UseAltPostList)
            {
                postList.Visible    = false;
                postListAlt.Visible = true;
            }

            AddClassToBody("editforumpost");
        }
Example #10
0
 private void LoadModuleSettings()
 {
     moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
     config         = new HtmlConfiguration(moduleSettings);
 }
Example #11
0
        private void RenderRSS(int moduleID)
        {
            /*
             *
             * For more info on RSS 2.0
             * http://www.feedvalidator.org/docs/rss2.html
             *
             * Fields not implemented yet:
             * <blogChannel:blogRoll>http://radio.weblogs.com/0001015/userland/scriptingNewsLeftLinks.opml</blogChannel:blogRoll>
             * <blogChannel:mySubscriptions>http://radio.weblogs.com/0001015/gems/mySubscriptions.opml</blogChannel:mySubscriptions>
             * <blogChannel:blink>http://diveintomark.org/</blogChannel:blink>
             * <lastBuildDate>Mon, 30 Sep 2002 11:00:00 GMT</lastBuildDate>
             * <docs>http://backend.userland.com/rss</docs>
             *
             */

            Response.ContentType = "text/xml";

            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(moduleID);
            Encoding  encoding       = new UTF8Encoding();

            XmlTextWriter xmlTextWriter = new XmlTextWriter(Response.OutputStream, encoding);

            xmlTextWriter.Formatting = Formatting.Indented;

            xmlTextWriter.WriteStartDocument();
            xmlTextWriter.WriteComment("RSS generated by Rainbow Portal Blog Module V 1.0 on " + DateTime.Now.ToLongDateString());
            xmlTextWriter.WriteStartElement("rss");

            xmlTextWriter.WriteStartAttribute("version", "http://rainbowportal.net/blogmodule");
            xmlTextWriter.WriteString("2.0");
            xmlTextWriter.WriteEndAttribute();

            xmlTextWriter.WriteStartElement("channel");

            /*
             *      RSS 2.0
             *      Required elements for channel are title link and description
             */
            xmlTextWriter.WriteStartElement("title");
            try
            {
                xmlTextWriter.WriteString(moduleSettings["MODULESETTINGS_TITLE_en-US"].ToString());
            }
            catch
            {
                //HACK: Get MODULESETTINGS_TITLE from where?
                xmlTextWriter.WriteString("Rainbow Blog");
            }
            xmlTextWriter.WriteEndElement();

            xmlTextWriter.WriteStartElement("link");
            xmlTextWriter.WriteString(Request.Url.ToString().Replace("DesktopModules/Blog/RSS.aspx", "DesktopDefault.aspx"));
            xmlTextWriter.WriteEndElement();

            xmlTextWriter.WriteStartElement("description");
            xmlTextWriter.WriteString(moduleSettings["Description"].ToString());
            xmlTextWriter.WriteEndElement();

            xmlTextWriter.WriteStartElement("copyright");
            xmlTextWriter.WriteString(moduleSettings["Copyright"].ToString());
            xmlTextWriter.WriteEndElement();

            // begin optional RSS 2.0 fields

            //ttl = time to live in minutes, how long a channel can be cached before refreshing from the source
            xmlTextWriter.WriteStartElement("ttl");
            xmlTextWriter.WriteString(moduleSettings["RSS Cache Time In Minutes"].ToString());
            xmlTextWriter.WriteEndElement();

            xmlTextWriter.WriteStartElement("managingEditor");
            xmlTextWriter.WriteString(moduleSettings["Author Email"].ToString());
            xmlTextWriter.WriteEndElement();

            xmlTextWriter.WriteStartElement("language");
            xmlTextWriter.WriteString(moduleSettings["Language"].ToString());
            xmlTextWriter.WriteEndElement();


            if (ConfigurationSettings.AppSettings.Get("webMaster") != null)
            {
                xmlTextWriter.WriteStartElement("webMaster");
                xmlTextWriter.WriteString(ConfigurationSettings.AppSettings.Get("webMaster"));
                xmlTextWriter.WriteEndElement();
            }
            xmlTextWriter.WriteStartElement("generator");
            xmlTextWriter.WriteString("Rainbow Portal Blog Module V 1.0");
            xmlTextWriter.WriteEndElement();

            BlogDB        blogDB = new BlogDB();
            SqlDataReader dr     = blogDB.GetBlogs(moduleID);

            try
            {
                //write channel items
                while (dr.Read())
                {
                    //beginning of blog entry
                    xmlTextWriter.WriteStartElement("item");

                    /*
                     * RSS 2.0
                     * All elements of an item are optional, however at least one of title or description
                     * must be present.
                     */

                    xmlTextWriter.WriteStartElement("title");
                    xmlTextWriter.WriteString(dr["Title"].ToString());
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("link");
                    xmlTextWriter.WriteString(Request.Url.ToString().Replace("RSS.aspx", "blogview.aspx") + "&ItemID=" + dr["ItemID"].ToString());
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("pubDate");
                    xmlTextWriter.WriteString(DateTime.Parse(dr["StartDate"].ToString()).ToString("dddd MMMM d yyyy hh:mm:ss tt zzz"));
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("guid");
                    xmlTextWriter.WriteString(Request.Url.ToString().Replace("RSS.aspx", "blogview.aspx") + "&ItemID=" + dr["ItemID"].ToString());
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("comments");
                    xmlTextWriter.WriteString(Request.Url.ToString().Replace("RSS.aspx", "blogview.aspx") + "&ItemID=" + dr["ItemID"].ToString());
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("description");
                    xmlTextWriter.WriteCData(Server.HtmlDecode((string)dr["Description"].ToString()));
                    xmlTextWriter.WriteEndElement();


                    //end blog entry
                    xmlTextWriter.WriteEndElement();
                }
            }
            finally
            {
                dr.Close();
            }

            //end of document
            xmlTextWriter.WriteEndElement();
            xmlTextWriter.Close();
        }
Example #12
0
        private void RenderRss(int moduleId)
        {
            Response.ContentType     = "text/xml";
            Response.ContentEncoding = System.Text.Encoding.UTF8;

            //Cynthia.Business.RssFeed feed = new Cynthia.Business.RssFeed(moduleId);
            Module    module         = GetModule();
            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(moduleId);

            feedListCacheTimeout = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "RSSFeedFeedListCacheTimeoutSetting", 3660);

            entryCacheTimeout = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "RSSFeedEntryCacheTimeoutSetting", 3620);

            maxDaysOld = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "RSSFeedMaxDayCountSetting", 90);

            maxEntriesPerFeed = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "RSSFeedMaxPostsPerFeedSetting", 90);

            EnableSelectivePublishing = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "EnableSelectivePublishing", EnableSelectivePublishing);


            DataView dv = FeedCache.GetRssFeedEntries(
                module.ModuleId,
                module.ModuleGuid,
                entryCacheTimeout,
                maxDaysOld,
                maxEntriesPerFeed,
                EnableSelectivePublishing).DefaultView;

            dv.Sort = "PubDate DESC";

            //if (EnableSelectivePublishing)
            //{
            //    dv.RowFilter = "Confirmed = true";
            //}

            RssChannel channel = new RssChannel();
            object     value   = GetModule();
            Module     m;

            if (value != null)
            {
                m = (Module)value;

                channel.Title         = m.ModuleTitle;
                channel.Description   = m.ModuleTitle;
                channel.LastBuildDate = channel.Items.LatestPubDate();
                channel.Link          = new System.Uri(SiteUtils.GetCurrentPageUrl());
            }
            else
            {
                // this prevents an error: Can't close RssWriter without first writing a channel.
                channel.Title         = "Not Found";
                channel.Description   = "Not Found";
                channel.LastBuildDate = DateTime.UtcNow;
                //channel.Link = new System.Uri(SiteUtils.GetCurrentPageUrl());
            }

            foreach (DataRowView row in dv)
            {
                bool confirmed = Convert.ToBoolean(row["Confirmed"]);
                if (!EnableSelectivePublishing)
                {
                    confirmed = true;
                }

                if (confirmed)
                {
                    RssItem item = new RssItem();


                    item.Title       = row["Title"].ToString();
                    item.Description = row["Description"].ToString();
                    item.PubDate     = Convert.ToDateTime(row["PubDate"]);
                    item.Link        = new System.Uri(row["Link"].ToString());
                    Trace.Write(item.Link.ToString());
                    item.Author = row["Author"].ToString();

                    channel.Items.Add(item);
                }
            }



            Rss.RssFeed rss = new Rss.RssFeed();
            rss.Encoding = System.Text.Encoding.UTF8;
            rss.Channels.Add(channel);
            rss.Write(Response.OutputStream);

            //Response.End();
        }
Example #13
0
        private void LoadSettings()
        {
            AddClassToBody($"webstore webstorecart {displaySettings.AdditionalBodyClass}");

            SiteUtils.AddNoIndexMeta(Page);

            commerceConfig  = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            if (moduleSettings != null)
            {
                config = new WebStoreConfiguration(moduleSettings);
            }

            litCartFooter.Text = config.CartPageFooter;

            if (Request.IsAuthenticated)
            {
                siteUser = SiteUtils.GetCurrentSiteUser();
            }

            store = StoreHelper.GetStore();
            if (store == null)
            {
                return;
            }

            if (
                (StoreHelper.UserHasCartCookie(store.Guid)) ||
                (Request.IsAuthenticated)
                )
            {
                cart = StoreHelper.GetCart();
            }

            //if we can't process cards internally there is no reason (except a free order) to go to the ConfirmOrder.aspx page
            //and the order can be processed wtithout the user signing in or if the user is already signed in
            if (
                ((!commerceConfig.CanProcessStandardCards) && (commerceConfig.WorldPayInstallationId.Length == 0))
                //&& ((Request.IsAuthenticated) || (canCheckoutWithoutAuthentication)) //moved login prompt to cart so we don't need to have a link to the confirmorder page
                )
            {
                //lnkConfirmOrder.Visible = false;
                litConfirmOrder.Visible = false;
            }

            if (cart == null)
            {
                pnlDiscountCode.Visible = false;
                //lnkConfirmOrder.Visible = false;
                litConfirmOrder.Visible = false;
                return;
            }

            if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0))
            {
                StoreHelper.EnsureValidDiscounts(store, cart);
            }

            if (store != null)
            {
                canCheckoutWithoutAuthentication = store.CanCheckoutWithoutAuthentication(cart);
            }

            cartList.Store           = store;
            cartList.ShoppingCart    = cart;
            cartList.CurrencyCulture = currencyCulture;
            cartList.DisplaySettings = displaySettings;

            cartListAlt.Store           = store;
            cartListAlt.ShoppingCart    = cart;
            cartListAlt.CurrencyCulture = currencyCulture;

            if (displaySettings.UseAltCartList)
            {
                cartList.Visible    = false;
                cartListAlt.Visible = true;
            }

            ConfigureCheckoutButtons();

            int countOfDiscountCodes = Discount.GetCountOfActiveDiscountCodes(store.ModuleGuid);

            pnlDiscountCode.Visible = (countOfDiscountCodes > 0);

            // don't show the discount code panel if the cart is empty
            if (cart.SubTotal == 0)
            {
                // allow checkout if cart has items (support checkout with free items)
                if (cart.CartOffers.Count == 0)
                {
                    //lnkConfirmOrder.Visible = false;
                    litConfirmOrder.Visible = false;
                }
                else
                {
                    //cart has free items
                    //lnkConfirmOrder.Visible = true;
                }
                //litOr.Visible = false;
                //btnPayPal.Visible = false;
                pnlDiscountCode.Visible = false;
            }

            // kill switch to disable discount codes (doesn't prevent use of ones already in the cart but prevents new uses
            bool disableDiscounts = false;

            ConfigHelper.GetBoolProperty("WebStoreDisabledDiscounts", disableDiscounts);
            if (disableDiscounts)
            {
                pnlDiscountCode.Visible = false;
            }
        }
Example #14
0
        private void LoadSettings()
        {
            pageId   = WebUtils.ParseInt32FromQueryString("pageid", -1);
            moduleId = WebUtils.ParseInt32FromQueryString("mid", true, -1);

            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            store = StoreHelper.GetStore();
            if (store == null)
            {
                return;
            }
            config = new WebStoreConfiguration(ModuleSettings.GetModuleSettings(store.ModuleId));

            siteUser = SiteUtils.GetCurrentSiteUser();

            productGuid = WebUtils.ParseGuidFromQueryString("prod", productGuid);

            if (productGuid == Guid.Empty)
            {
                return;
            }

            grdImages.Config        = config;
            grdImages.ReferenceGuid = productGuid;

            virtualRoot = WebUtils.GetApplicationRoot();

            upLoadPath = $"~/Data/Sites/{siteSettings.SiteId.ToInvariantString()}/webstoreproductfiles/";

            teaserFileBasePath = $"~/Data/Sites/{siteSettings.SiteId.ToInvariantString()}/webstoreproductpreviewfiles/";

            AddClassToBody("webstore webstoreproductedit");

            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];

            if (p == null)
            {
                log.Error($"Could not load file system provider {WebConfigSettings.FileSystemProvider}");
                return;
            }

            fileSystem = p.GetFileSystem();
            if (fileSystem == null)
            {
                log.Error($"Could not load file system from provider {WebConfigSettings.FileSystemProvider}");
                return;
            }

            if (!fileSystem.FolderExists(upLoadPath))
            {
                fileSystem.CreateFolder(upLoadPath);
            }

            if (!fileSystem.FolderExists(teaserFileBasePath))
            {
                fileSystem.CreateFolder(teaserFileBasePath);
            }


            productUploader.ServiceUrl = SiteRoot + "/WebStore/upload.ashx?pageid=" + pageId.ToInvariantString()
                                         + "&mid=" + moduleId.ToInvariantString()
                                         + "&prod=" + productGuid.ToString();

            productUploader.UploadButtonClientId = btnUpload.ClientID;

            productUploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form

            string refreshFunction = "function refresh" + moduleId.ToInvariantString()
                                     + " (data, errorsOccurred) { if(errorsOccurred === false) { $('#" + btnSave.ClientID + "').click(); } } ";

            productUploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString();

            ScriptManager.RegisterClientScriptBlock(
                this,
                this.GetType(), "refresh" + moduleId.ToInvariantString(),
                refreshFunction,
                true);

            teaserUploader.ServiceUrl = SiteRoot + "/WebStore/upload.ashx?type=teaser&pageid=" + pageId.ToInvariantString()
                                        + "&mid=" + moduleId.ToInvariantString()
                                        + "&prod=" + productGuid.ToString();

            teaserUploader.UploadButtonClientId   = btnUploadTeaser.ClientID;
            teaserUploader.FormFieldClientId      = hdnState.ClientID; // not really used but prevents submitting all the form
            teaserUploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString();

            ScriptConfig.IncludeColorBox = true;
        }
Example #15
0
        private void LoadSettings()
        {
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            pageSettings = CacheHelper.GetCurrentPage();
            //pageId = WebUtils.ParseInt32FromQueryString("pageid", -1);
            //moduleId = WebUtils.ParseInt32FromQueryString("mid", -1);
            //itemId = WebUtils.ParseInt32FromQueryString("ItemID", -1);
            //threadId = WebUtils.ParseInt32FromQueryString("thread", -1);

            FeedParameterParser feedParams = new FeedParameterParser();

            feedParams.Parse();

            pageId   = feedParams.PageId;
            moduleId = feedParams.ModuleId;
            itemId   = feedParams.ItemId;
            threadId = feedParams.ThreadId;

            // old format still supported for backward compat
            //  /Forums/RSS.aspx?mid=34&pageid=5
            //  /Forums/RSS.aspx?ItemID=2&mid=34&pageid=5
            //  /Forums/RSS.aspx?ItemID=2&mid=34&pageid=5&thread=10373

            // new format reduces to 2 params with the 2nd one a combination of ~ delimited: moduelid~itemId~threadid
            //  /Forums/RSS.aspx?pageid=5&m=34~-1~-1


            securityBypassGuid = WebUtils.ParseGuidFromQueryString("g", securityBypassGuid);
            //module = GetModule();

            //if ((moduleId == -1) || (module == null) || (siteSettings == null)) { return; }

            bypassPageSecurity = false;

            if ((securityBypassGuid != Guid.Empty) && (securityBypassGuid == WebConfigSettings.InternalFeedSecurityBypassKey))
            {
                bypassPageSecurity = true;
            }

            // this old security logic is not needed since we are filtering the items by page and module roles

            //if(
            //    (bypassPageSecurity)
            //    ||(WebUser.IsInRoles(pageSettings.AuthorizedRoles))
            //    || (WebUser.IsInRoles(module.ViewRoles))
            //    )
            //{
            //    canView = true;
            //}

            //if (!canView) { return; }

            //baseUrl = Request.Url.ToString().Replace("RSS.aspx", "Thread.aspx");

            if (WebConfigSettings.UseFoldersInsteadOfHostnamesForMultipleSites)
            {
                navigationSiteRoot = SiteUtils.GetNavigationSiteRoot();
                imageSiteRoot      = WebUtils.GetSiteRoot();
                cssBaseUrl         = imageSiteRoot;
            }
            else
            {
                navigationSiteRoot = SiteUtils.GetNavigationSiteRoot();
                imageSiteRoot      = navigationSiteRoot;
                cssBaseUrl         = WebUtils.GetSiteRoot();
            }


            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);

            maxDaysOld = WebUtils.ParseInt32FromHashtable(moduleSettings, "RSSFeedMaxDaysOldSetting", 90);

            entriesLimit = WebUtils.ParseInt32FromHashtable(moduleSettings, "RSSFeedMaxPostsSetting", 90);

            //Feedfetcher-Google
            isGoogleFeedReader = ((Request.UserAgent != null) && (Request.UserAgent.Contains("Feedfetcher-Google")));
        }
        private void LoadSettings()
        {
            virtualRoot = WebUtils.GetApplicationRoot();

            pageId                = WebUtils.ParseInt32FromQueryString("pageid", -1);
            moduleId              = WebUtils.ParseInt32FromQueryString("mid", -1);
            groupId               = WebUtils.ParseInt32FromQueryString("groupid", -1);
            topicId               = WebUtils.ParseInt32FromQueryString("topic", -1);
            postId                = WebUtils.ParseInt32FromQueryString("postid", -1);
            pageNumber            = WebUtils.ParseInt32FromQueryString("pagenumber", 1);
            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();
            timeOffset            = SiteUtils.GetUserTimeOffset();

            switch (siteSettings.AvatarSystem)
            {
            case "gravatar":
                allowGravatars = true;
                disableAvatars = true;
                break;

            case "internal":
                allowGravatars = false;
                disableAvatars = false;
                break;

            case "none":
            default:
                allowGravatars = false;
                disableAvatars = true;
                break;
            }

            if (Request.IsAuthenticated)
            {
                theUser = SiteUtils.GetCurrentSiteUser();
                if (groupId > -1)
                {
                    isSubscribedToGroup = Group.IsSubscribed(groupId, theUser.UserId);
                }
                if (topicId > -1)
                {
                    isSubscribedToTopic = GroupTopic.IsSubscribed(topicId, theUser.UserId);
                }
            }

            if (WebUser.IsAdminOrContentAdmin)
            {
                edMessage.WebEditor.ToolBar = ToolBar.FullWithTemplates;
            }
            else if ((Request.IsAuthenticated) && (WebUser.IsInRoles(siteSettings.UserFilesBrowseAndUploadRoles)))
            {
                edMessage.WebEditor.ToolBar = ToolBar.GroupWithImages;
            }
            else
            {
                edMessage.WebEditor.ToolBar = ToolBar.Group;
            }

            edMessage.WebEditor.SetFocusOnStart = true;
            edMessage.WebEditor.Height          = Unit.Parse("350px");

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);

            useSpamBlockingForAnonymous = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "GroupEnableAntiSpamSetting", useSpamBlockingForAnonymous);

            includePostBodyInNotification = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "IncludePostBodyInNotificationEmail", includePostBodyInNotification);



            if (useSpamBlockingForAnonymous)
            {
                captcha.ProviderName        = siteSettings.CaptchaProvider;
                captcha.Captcha.ControlID   = "captcha" + moduleId.ToString(CultureInfo.InvariantCulture);
                captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
                captcha.RecaptchaPublicKey  = siteSettings.RecaptchaPublicKey;
            }
        }
Example #17
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string isframe = string.Empty + Request["frame"];

            if (isframe != string.Empty)
            {
                MainPage.Visible    = true;
                iframePanel.Visible = false;

                string rif = string.Empty + Request["rif"];
                string cif = string.Empty + Request["cif"];

                if (cif != string.Empty && rif != string.Empty)
                {
                    RootImagesFolder.Value    = rif;
                    CurrentImagesFolder.Value = cif;
                }
                else
                {
                    Hashtable ms = ModuleSettings.GetModuleSettings(portalSettings.ActiveModule);
                    string    DefaultImageFolder = "default";
                    if (ms["MODULE_IMAGE_FOLDER"] != null)
                    {
                        DefaultImageFolder = ms["MODULE_IMAGE_FOLDER"].ToString();
                    }
                    else if (portalSettings.CustomSettings["SITESETTINGS_DEFAULT_IMAGE_FOLDER"] != null)
                    {
                        DefaultImageFolder = portalSettings.CustomSettings["SITESETTINGS_DEFAULT_IMAGE_FOLDER"].ToString();
                    }
                    RootImagesFolder.Value    = portalSettings.PortalPath + "/images/" + DefaultImageFolder;
                    RootImagesFolder.Value    = RootImagesFolder.Value.Replace("//", "/");
                    CurrentImagesFolder.Value = RootImagesFolder.Value;
                }

                UploadPanel.Visible = UploadIsEnabled;
                DeleteImage.Visible = DeleteIsEnabled;

                string FileErrorMessage = string.Empty;
                string ValidationString = ".*(";
                //[\.jpg]|[\.jpeg]|[\.jpe]|[\.gif]|[\.bmp]|[\.png])$"
                for (int i = 0; i < AcceptedFileTypes.Length; i++)
                {
                    ValidationString += "[\\." + AcceptedFileTypes[i] + "]";
                    if (i < (AcceptedFileTypes.Length - 1))
                    {
                        ValidationString += "|";
                    }
                    FileErrorMessage += AcceptedFileTypes[i];
                    if (i < (AcceptedFileTypes.Length - 1))
                    {
                        FileErrorMessage += ", ";
                    }
                }
                FileValidator.ValidationExpression = ValidationString + ")$";
                FileValidator.ErrorMessage         = FileErrorMessage;

                if (!IsPostBack)
                {
                    DisplayImages();
                }
            }
            else
            {
            }
        }
        /// <summary>
        /// Gets the editor.
        /// </summary>
        /// <param name="placeHolderHtmlEditor">
        /// The place holder HTML editor.
        /// </param>
        /// <param name="moduleId">
        /// The module ID.
        /// </param>
        /// <param name="showUpload">
        /// The show Upload.
        /// </param>
        /// <param name="PortalSettings">
        /// The portal Settings.
        /// </param>
        /// <returns>
        /// The HTML editor interface.
        /// </returns>
        public IHtmlEditor GetEditor(
            Control placeHolderHtmlEditor, int moduleId, bool showUpload, PortalSettings PortalSettings)
        {
            IHtmlEditor desktopText;
            var         moduleImageFolder = ModuleSettings.GetModuleSettings(moduleId)["MODULE_IMAGE_FOLDER"].ToString();

            // Grabs ID from the place holder so that a unique editor is on the page if more than one
            // But keeps same ID so that the information can be submitted to be saved. [CDT]
            var uniqueId = placeHolderHtmlEditor.ID;

            switch (this.Value)
            {
            case "TinyMCE Editor":
                var tinyMce = new TinyMCETextBox {
                    ImageFolder = moduleImageFolder
                };
                desktopText = tinyMce;
                break;

            case "FCKeditor":     // 9/8/2010
                var conector = Path.ApplicationRootPath("/app_support/FCKconnectorV2.aspx");
                var fckv2    = new FCKTextBoxV2
                {
                    ImageFolder        = moduleImageFolder,
                    BasePath           = Path.WebPathCombine(Path.ApplicationRoot, "aspnet_client/FCKeditorV2.6.6/"),
                    AutoDetectLanguage = false,
                    DefaultLanguage    = PortalSettings.PortalUILanguage.Name.Substring(0, 2),
                    ID = string.Concat("FCKTextBox", uniqueId),
                    ImageBrowserURL =
                        Path.WebPathCombine(
                            Path.ApplicationRoot,
                            string.Format(
                                "aspnet_client/FCKeditorV2.6.6/editor/filemanager/browser/default/browser.html?Type=Image%26Connector={0}",
                                conector)),
                    LinkBrowserURL =
                        Path.WebPathCombine(
                            Path.ApplicationRoot,
                            string.Format(
                                "aspnet_client/FCKeditorV2.6.6/editor/filemanager/browser/default/browser.html?Connector={0}",
                                conector))
                };

                // fckv2.EditorAreaCSS = PortalSettings.GetCurrentTheme().CssFile;
                desktopText = fckv2;
                break;

            case "Syrinx CkEditor":
                CkEditor.CkEditorJS = Path.WebPathCombine(
                    Path.ApplicationRoot, "aspnet_client/ckeditor/ckeditor.js");

                var sckvtb = new SyrinxCkTextBox
                {
                    ImageFolder    = moduleImageFolder,
                    BaseContentUrl = Path.WebPathCombine(Path.ApplicationRoot, "aspnet_client/ckeditor/"),
                    Resizable      = false,
                    Language       = PortalSettings.PortalUILanguage.TwoLetterISOLanguageName
                };

                desktopText = sckvtb;
                break;

            case "FreeTextBox":
                var freeText = new FreeTextBox
                {
                    ImageGalleryUrl =
                        Path.WebPathCombine(
                            Path.ApplicationFullPath,
                            "app_support/ftb.imagegallery.aspx?rif={0}&cif={0}&mID=" + moduleId),
                    ImageFolder      = moduleImageFolder,
                    ImageGalleryPath = Path.WebPathCombine(PortalSettings.PortalFullPath, moduleImageFolder),
                    ID                    = string.Concat("FreeText", uniqueId),
                    Language              = GetFtbLanguage(PortalSettings.PortalUILanguage.Name),
                    JavaScriptLocation    = ResourceLocation.ExternalFile,
                    ButtonImagesLocation  = ResourceLocation.ExternalFile,
                    ToolbarImagesLocation = ResourceLocation.ExternalFile,
                    SupportFolder         = Path.WebPathCombine(Path.ApplicationFullPath, "aspnet_client/FreeTextBox")
                };

                // freeText.ToolbarLayout =
                // "ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorPicker,FontBackColorPicker,FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat;CreateLink,Unlink|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;InsertRule|Delete,Cut,Copy,Paste;Undo,Redo,Print;InsertTable,InsertTableColumnAfter,InsertTableColumnBefore,InsertTableRowAfter,InsertTableRowBefore,DeleteTableColumn,DeleteTableRow,InsertImageFromGallery";
                desktopText = freeText;
                break;

            // case "Code Mirror Plain Text":
            default:
                var codeMirrorTextBox = new CodeMirrorTextBox();
                desktopText = codeMirrorTextBox;
                break;
            }

            placeHolderHtmlEditor.Controls.Add((Control)desktopText);
            return(desktopText);
        }
        private void LoadSettings()
        {
            pageId   = WebUtils.ParseInt32FromQueryString("pageid", -1);
            moduleId = WebUtils.ParseInt32FromQueryString("mid", -1);

            //if (Request.Form.Count > 0)
            //{
            //    submittedContent = Server.UrlDecode(Request.Form.ToString()); // this gets the full content of the post

            //}

            if (Request.Form["html"] != null)
            {
                submittedContent = Request.Form["html"];
                //log.Info("html does = " + Request.Form["html"]);
            }


            //using (Stream s = Request.InputStream)
            //{
            //    using (StreamReader sr = new StreamReader(s))
            //    {
            //        string requestBody = sr.ReadToEnd();
            //        requestBody = Server.UrlDecode(requestBody);
            //        log.Info("requestBody was " + requestBody);
            //        JObject jObj = JObject.Parse(requestBody);
            //        submittedContent = (string)jObj["html"];
            //    }
            //}

            module = GetHtmlModule();

            if (module == null)
            {
                return;
            }

            currentUser    = SiteUtils.GetCurrentSiteUser();
            repository     = new HtmlRepository();
            moduleSettings = ModuleSettings.GetModuleSettings(module.ModuleId);
            config         = new HtmlConfiguration(moduleSettings);

            enableContentVersioning = config.EnableContentVersioning;

            if ((CurrentSite.ForceContentVersioning) || (WebConfigSettings.EnforceContentVersioningGlobally))
            {
                enableContentVersioning = true;
            }

            userCanOnlyEditAsDraft = UserCanOnlyEditModuleAsDraft(module.ModuleId, HtmlContent.FeatureGuid);

            if ((WebConfigSettings.EnableContentWorkflow) && (CurrentSite.EnableContentWorkflow))
            {
                workInProgress = ContentWorkflow.GetWorkInProgress(module.ModuleGuid);
            }

            if (workInProgress != null)
            {
                switch (workInProgress.Status)
                {
                case ContentWorkflowStatus.Draft:

                    //there is a draft version currently available, therefore dont allow the non draft version to be edited:

                    if (ViewMode == PageViewMode.WorkInProgress)
                    {
                        editDraft = true;
                    }

                    break;

                case ContentWorkflowStatus.ApprovalRejected:
                    //rejected content - allow update as draft only

                    if (ViewMode == PageViewMode.WorkInProgress)
                    {
                        editDraft = true;
                    }
                    break;

                case ContentWorkflowStatus.AwaitingApproval:
                    //pending approval - dont allow any edited:
                    // 2010-01-18 let editors update the draft if they want to before approving it.
                    editDraft = !userCanOnlyEditAsDraft;
                    break;
                }
            }


            //for (int i = 0; i < Request.QueryString.Count; i++)
            //{
            //    log.Info(Request.QueryString.GetKey(i) + " query param = " + Request.QueryString.Get(i));
            //}

            //if (Request.Form["c"] != null)
            //{
            //    submittedContent = Request.Form["c"];
            //    log.Info("c does = " + Request.Form["c"]);
            //}

            // this shows that a large html content post appears as multiple params
            //for (int i = 0; i < Request.Form.Count; i++)
            //{
            //    log.Info(Request.Form.GetKey(i) + " form param " + i.ToInvariantString() + " = " + Request.Form.Get(i));
            //}
        }
Example #20
0
        protected virtual void LoadSettings()
        {
            siteRoot     = SiteUtils.GetNavigationSiteRoot();
            siteSettings = CacheHelper.GetCurrentSiteSettings();
            siteID       = siteSettings.SiteId;
            currentUser  = SiteUtils.GetCurrentSiteUser();

            var moduleSettings = ModuleSettings.GetModuleSettings(moduleID);

            if (moduleSettings != null)
            {
                bigConfig = new BIGConfig(moduleSettings);
            }

            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];

            if (p == null)
            {
                log.Error(string.Format(BetterImageGalleryResources.FileSystemProviderNotLoaded, WebConfigSettings.FileSystemProvider));
            }

            fileSystem = p.GetFileSystem();

            if (fileSystem == null)
            {
                log.Error(string.Format(BetterImageGalleryResources.FileSystemNotLoadedFromProvider, WebConfigSettings.FileSystemProvider));
            }

            // Media Folder
            //VirtualRoot isn't always media folder, depending on how the site is configured, so we'll make sure to use media folder

            mediaRootPath = fileSystem.VirtualRoot;
            if (!mediaRootPath.TrimEnd('/').EndsWith("media"))
            {
                mediaRootPath = mediaRootPath.TrimEnd('/') + "/media/";
            }

            // Gallery Module Folder
            galleryRootPath = mediaRootPath + "BetterImageGallery/";
            // Gallery Folder
            galleryPath = galleryRootPath + bigConfig.FolderPath.TrimEnd('/');

            // Creates the Gallery Module Folder if it doesn't exist
            if (!fileSystem.FolderExists(galleryRootPath))
            {
                fileSystem.CreateFolder(galleryRootPath);
            }

            // Creates the Gallery Module Folder if it doesn't exist
            if (!fileSystem.FolderExists(galleryPath))
            {
                Error = new BIGErrorResult
                {
                    Type    = "FolderNotFound",
                    Message = BetterImageGalleryResources.FolderNotFound
                };
            }

            // Creates module thumbnail cache folder if it doesn't exist
            if (!fileSystem.FolderExists(moduleThumbnailCachePath))
            {
                fileSystem.CreateFolder(moduleThumbnailCachePath);
            }
        }
Example #21
0
        private void LoadSettings()
        {
            pageID       = WebUtils.ParseInt32FromQueryString("pageid", -1);
            moduleId     = WebUtils.ParseInt32FromQueryString("mid", -1);
            categoryId   = WebUtils.ParseInt32FromQueryString("cat", categoryId);
            siteSettings = CacheHelper.GetCurrentSiteSettings();

            // newer implementation combines params as p=pageid~moduleid~categoryid
            string f = WebUtils.ParseStringFromQueryString("p", string.Empty);

            if ((f.Length > 0) && (f.Contains("~")))
            {
                List <string> parms = f.SplitOnCharAndTrim('~');

                if (parms.Count >= 1)
                {
                    int.TryParse(parms[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out pageID);
                }

                if (parms.Count >= 2)
                {
                    int.TryParse(parms[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out moduleId);
                }

                if (parms.Count >= 3)
                {
                    int.TryParse(parms[2], NumberStyles.Integer, CultureInfo.InvariantCulture, out categoryId);
                }
            }


            securityBypassGuid = WebUtils.ParseGuidFromQueryString("g", securityBypassGuid);
            attachmentBaseUrl  = SiteUtils.GetFileAttachmentUploadPath();
            pageSettings       = CacheHelper.GetPage(pageID);
            module             = GetModule();

            if ((moduleId == -1) || (module == null))
            {
                return;
            }

            bool bypassPageSecurity = false;

            if ((securityBypassGuid != Guid.Empty) && (securityBypassGuid == WebConfigSettings.InternalFeedSecurityBypassKey))
            {
                bypassPageSecurity = true;
            }

            if (
                (bypassPageSecurity) ||
                (WebUser.IsInRoles(pageSettings.AuthorizedRoles)) ||
                (WebUser.IsInRoles(module.ViewRoles))
                )
            {
                canView = true;
            }

            if (!canView)
            {
                return;
            }

            if (WebConfigSettings.UseFolderBasedMultiTenants)
            {
                navigationSiteRoot = SiteUtils.GetNavigationSiteRoot();
                blogBaseUrl        = navigationSiteRoot;
                imageSiteRoot      = WebUtils.GetSiteRoot();
                cssBaseUrl         = imageSiteRoot;
            }
            else
            {
                navigationSiteRoot = WebUtils.GetHostRoot();
                blogBaseUrl        = SiteUtils.GetNavigationSiteRoot();
                imageSiteRoot      = navigationSiteRoot;
                cssBaseUrl         = WebUtils.GetSiteRoot();
            }

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            config         = new BlogConfiguration(moduleSettings);

            if (config.FeedIsDisabled)
            {
                canView = false;
            }

            if ((config.FeedburnerFeedUrl.Length > 0) && (config.FeedburnerFeedUrl.StartsWith("http")) && (BlogConfiguration.UseRedirectForFeedburner))
            {
                shouldRedirectToFeedburner = true;
                if ((Request.UserAgent != null) && (Request.UserAgent.Contains("FeedBurner")))
                {
                    shouldRedirectToFeedburner = false; // don't redirect if the feedburner bot is reading the feed
                }

                Guid redirectBypassToken = WebUtils.ParseGuidFromQueryString("r", Guid.Empty);
                if (redirectBypassToken == Global.FeedRedirectBypassToken)
                {
                    shouldRedirectToFeedburner = false; // allows time for user to subscribe to autodiscovery links without redirecting
                }
            }
        }
Example #22
0
        private void RenderRss(RssGroup rssGroup)
        {
            Response.ContentType     = "application/xml";
            Response.ContentEncoding = System.Text.Encoding.UTF8;

            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(rssGroup.ModuleId);

            rssGroup.MaximumDays = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "RSSFeedMaxDaysOldSetting", 90);

            int entriesLimit = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "RSSFeedMaxPostsSetting", 90);

            int entryCount = 0;

            Rss.RssChannel channel = new Rss.RssChannel();
            string         baseUrl = Request.Url.ToString().Replace("RSS.aspx", "Topic.aspx");

            using (IDataReader posts = rssGroup.GetPostsForRss())
            {
                while ((posts.Read()) && (entryCount <= entriesLimit))
                {
                    Rss.RssItem item = new Rss.RssItem();

                    item.Title       = posts["Subject"].ToString();
                    item.Description = SiteUtils.ChangeRelativeUrlsToFullyQuailifiedUrls(navigationSiteRoot, imageSiteRoot, posts["Post"].ToString());
                    item.PubDate     = Convert.ToDateTime(posts["PostDate"]);

                    string target = baseUrl;

                    if (target.IndexOf("&topic=") < 0 && target.IndexOf("?topic=") < 0)
                    {
                        if (target.IndexOf("?") < 0)
                        {
                            target += "?topic=" + posts["TopicID"].ToString() + "#post" + posts["PostID"].ToString();
                        }
                        else
                        {
                            target += "&topic=" + posts["TopicID"].ToString() + "#post" + posts["PostID"].ToString();
                        }
                    }
                    item.Link = new System.Uri(target);

                    item.Author = posts["StartedBy"].ToString();

                    channel.Items.Add(item);
                    entryCount += 1;
                }
            }

            object value = GetModule();
            Module m;

            channel.LastBuildDate = channel.Items.LatestPubDate();
            channel.Link          = new System.Uri(groupUrl);

            if (value != null)
            {
                m = (Module)value;

                channel.Title       = m.ModuleTitle;
                channel.Description = m.ModuleTitle;
            }
            else
            {
                channel.Title       = siteSettings.SiteName;
                channel.Description = siteSettings.SiteName;
            }

            if (channel.Items.Count == 0)
            {
                Rss.RssItem item = new Rss.RssItem();

                item.Title       = "No Items Found";
                item.Description = "No items found";
                item.PubDate     = DateTime.UtcNow;

                item.Link = new System.Uri(navigationSiteRoot);

                item.Author = "system";

                channel.Items.Add(item);
            }


            Rss.RssFeed rss = new Rss.RssFeed();
            rss.BaseUrl = cssBaseUrl;

            rss.Encoding = System.Text.Encoding.UTF8;
            rss.Channels.Add(channel);
            rss.Write(Response.OutputStream);
            //Response.End();
        }
Example #23
0
        public void ProcessRequest(HttpContext context)
        {
            base.Initialize(context);

            if (!UserCanEditModule(ModuleId, Gallery.FeatureGuid))
            {
                log.Info("User has no edit permission so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentSite == null)
            {
                log.Info("CurrentSite is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentUser == null)
            {
                log.Info("CurrentUser is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (FileSystem == null)
            {
                log.Info("FileSystem is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (Request.Files.Count == 0)
            {
                log.Info("Posted File Count is zero so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (Request.Files.Count > GalleryConfiguration.MaxFilesToUploadAtOnce)
            {
                log.Info("Posted File Count is higher than allowed so returning 404");
                Response.StatusCode = 404;
                return;
            }

            module = GetModule(ModuleId, Gallery.FeatureGuid);

            if (module == null)
            {
                log.Info("Module is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            itemId = WebUtils.ParseInt32FromQueryString("ItemID", itemId);

            //if (Request.Form.Count > 0)
            //{
            //    string submittedContent = Server.UrlDecode(Request.Form.ToString()); // this gets the full content of the post
            //    log.Info("submitted data: " + submittedContent);
            //}


            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);

            config = new GalleryConfiguration(moduleSettings);

            string imageFolderPath;
            string fullSizeImageFolderPath;

            if (WebConfigSettings.ImageGalleryUseMediaFolder)
            {
                imageFolderPath = "~/Data/Sites/" + CurrentSite.SiteId.ToInvariantString() + "/media/GalleryImages/" + ModuleId.ToInvariantString() + "/";
            }
            else
            {
                imageFolderPath = "~/Data/Sites/" + CurrentSite.SiteId.ToInvariantString() + "/GalleryImages/" + ModuleId.ToInvariantString() + "/";
            }

            fullSizeImageFolderPath = imageFolderPath + "FullSizeImages/";
            string thumbnailPath = imageFolderPath + "Thumbnails/";

            context.Response.ContentType = "text/plain";//"application/json";
            var r = new System.Collections.Generic.List <UploadFilesResult>();
            JavaScriptSerializer js = new JavaScriptSerializer();

            for (int f = 0; f < Request.Files.Count; f++)
            {
                HttpPostedFile file = Request.Files[f];

                string ext = Path.GetExtension(file.FileName);
                if (SiteUtils.IsAllowedUploadBrowseFile(ext, WebConfigSettings.ImageFileExtensions))
                {
                    GalleryImage galleryImage;

                    if ((itemId > -1) && (Request.Files.Count == 1))
                    {
                        galleryImage = new GalleryImage(ModuleId, itemId);
                    }
                    else
                    {
                        galleryImage = new GalleryImage(ModuleId);
                    }

                    galleryImage.ModuleGuid      = module.ModuleGuid;
                    galleryImage.WebImageHeight  = config.WebSizeHeight;
                    galleryImage.WebImageWidth   = config.WebSizeWidth;
                    galleryImage.ThumbNailHeight = config.ThumbnailHeight;
                    galleryImage.ThumbNailWidth  = config.ThumbnailWidth;
                    galleryImage.UploadUser      = CurrentUser.Name;

                    galleryImage.UserGuid = CurrentUser.UserGuid;

                    string newFileName  = Path.GetFileName(file.FileName).ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);
                    string newImagePath = VirtualPathUtility.Combine(fullSizeImageFolderPath, newFileName);

                    if (galleryImage.ImageFile == newFileName)
                    {
                        // an existing gallery image delete the old one
                        FileSystem.DeleteFile(newImagePath);
                    }
                    else
                    {
                        // this is a new galleryImage instance, make sure we don't use the same file name as any other instance
                        int i = 1;
                        while (FileSystem.FileExists(VirtualPathUtility.Combine(fullSizeImageFolderPath, newFileName)))
                        {
                            newFileName = i.ToInvariantString() + newFileName;
                            i          += 1;
                        }
                    }

                    newImagePath = VirtualPathUtility.Combine(fullSizeImageFolderPath, newFileName);


                    using (Stream s = file.InputStream)
                    {
                        FileSystem.SaveFile(newImagePath, s, file.ContentType, true);
                    }


                    galleryImage.ImageFile     = newFileName;
                    galleryImage.WebImageFile  = newFileName;
                    galleryImage.ThumbnailFile = newFileName;
                    galleryImage.Save();
                    GalleryHelper.ProcessImage(galleryImage, FileSystem, imageFolderPath, file.FileName, config.ResizeBackgroundColor);

                    r.Add(new UploadFilesResult()
                    {
                        Thumbnail_url = WebUtils.ResolveServerUrl(thumbnailPath + newFileName),
                        Name          = newFileName,
                        Length        = file.ContentLength,
                        Type          = file.ContentType,
                        ReturnValue   = galleryImage.ItemId.ToInvariantString()
                    });
                }
            }

            var uploadedFiles = new
            {
                files = r.ToArray()
            };
            var jsonObj = js.Serialize(uploadedFiles);

            context.Response.Write(jsonObj.ToString());
        }
Example #24
0
        private void GetModuleSettings()
        {
            moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);

            ShowCategories = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogShowCategoriesSetting", false);

            BlogUseTagCloudForCategoriesSetting = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogUseTagCloudForCategoriesSetting", BlogUseTagCloudForCategoriesSetting);

            ShowArchives = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogShowArchiveSetting", false);

            NavigationOnRight = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogNavigationOnRightSetting", false);

            ShowStatistics = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogShowStatisticsSetting", true);

            ShowFeedLinks = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogShowFeedLinksSetting", true);

            ShowAddFeedLinks = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogShowAddFeedLinksSetting", true);

            AllowComments = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogAllowComments", true);

            showLeftContent = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "ShowPageLeftContentSetting", showLeftContent);

            showRightContent = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "ShowPageRightContentSetting", showRightContent);

            if (moduleSettings.Contains("DisqusSiteShortName"))
            {
                DisqusSiteShortName = moduleSettings["DisqusSiteShortName"].ToString();
            }

            if (DisqusSiteShortName.Length > 0)
            {
                stats.ShowCommentCount = false;
            }

            pnlStatistics.Visible = ShowStatistics;

            divNav.Visible = false;
            if (ShowArchives ||
                ShowAddFeedLinks ||
                ShowCategories ||
                ShowFeedLinks ||
                ShowStatistics)
            {
                divNav.Visible = true;
            }

            if (!divNav.Visible)
            {
                divblog.CssClass = "blogcenter-nonav";
            }

            countOfDrafts = Blog.CountOfDrafts(ModuleId);
        }
        private void LoadSettings()
        {
            pageId      = WebUtils.ParseInt32FromQueryString("pageid", pageId);
            moduleId    = WebUtils.ParseInt32FromQueryString("mid", moduleId);
            itemId      = WebUtils.ParseInt32FromQueryString("ItemID", itemId);
            commentGuid = WebUtils.ParseGuidFromQueryString("c", commentGuid);
            if (commentGuid == Guid.Empty)
            {
                return;
            }


            module = GetModule(moduleId, CommentsConfiguration.FeatureGuid);

            if (module == null)
            {
                return;
            }

            commentRepository = new CommentRepository();



            comment = commentRepository.Fetch(commentGuid);
            if ((comment.ContentGuid != module.ModuleGuid) || (comment.ModuleGuid != module.ModuleGuid))
            {
                module = null;
                return;
            }

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);

            config = new CommentsConfiguration(moduleSettings);

            currentUser = SiteUtils.GetCurrentSiteUser();

            userCanEdit = UserCanEditComment();

            commentEditor.SiteGuid       = CurrentSite.SiteGuid;
            commentEditor.SiteId         = CurrentSite.SiteId;
            commentEditor.SiteRoot       = SiteRoot;
            commentEditor.CommentsClosed = !config.AllowComments;
            //commentEditor.CommentUrl = Request.RawUrl;
            commentEditor.ContentGuid = module.ModuleGuid;
            //commentEditor.DefaultCommentTitle = defaultCommentTitle;
            commentEditor.FeatureGuid = CommentsConfiguration.FeatureGuid;
            commentEditor.ModuleGuid  = module.ModuleGuid;
            //commentEditor.NotificationAddresses = notificationAddresses;
            //commentEditor.NotificationTemplateName = notificationTemplateName;
            commentEditor.RequireCaptcha  = false;
            commentEditor.UserCanModerate = userCanEdit;
            //commentEditor.Visible = !commentsClosed;
            commentEditor.CurrentUser    = currentUser;
            commentEditor.UserComment    = comment;
            commentEditor.ShowRememberMe = false;

            commentEditor.UseCommentTitle = config.AllowCommentTitle;
            commentEditor.ShowUserUrl     = config.AllowWebSiteUrlForComments;

            //commentEditor.IncludeIpAddressInNotification = includeIpAddressInNotification;
            //commentEditor.ContainerControl = this;
        }
Example #26
0
        private void LoadSettings()
        {
            ThePost = new Blog(ItemId);
            module  = new Module(ModuleId, BasePage.CurrentPage.PageId);

            siteSettings = CacheHelper.GetCurrentSiteSettings();

            if (
                (module.ModuleId == -1) ||
                (ThePost.ModuleId == -1) ||
                (ThePost.ModuleId != module.ModuleId) ||
                (siteSettings == null)
                )
            {
                // query string params have been manipulated
                this.pnlBlog.Visible = false;
                AllowComments        = false;
                parametersAreInvalid = true;
                return;
            }
            ShowAddThisButton           = siteSettings.AddThisDotComUsername.Length > 0;
            RegexRelativeImageUrlPatern = SiteUtils.GetRegexRelativeImageUrlPatern();

            moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);

            GmapApiKey = SiteUtils.GetGmapApiKey();

            ShowCategories = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogShowCategoriesSetting", ShowCategories);

            BlogUseTagCloudForCategoriesSetting = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogUseTagCloudForCategoriesSetting", BlogUseTagCloudForCategoriesSetting);

            ShowArchives = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogShowArchiveSetting", ShowArchives);

            NavigationOnRight = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogNavigationOnRightSetting", NavigationOnRight);

            ShowStatistics = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogShowStatisticsSetting", ShowStatistics);

            ShowFeedLinks = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogShowFeedLinksSetting", ShowFeedLinks);

            ShowAddFeedLinks = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogShowAddFeedLinksSetting", ShowAddFeedLinks);

            UseCommentSpamBlocker = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogUseCommentSpamBlocker", UseCommentSpamBlocker);

            RequireAuthenticationForComments = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "RequireAuthenticationForComments", RequireAuthenticationForComments);

            AllowComments = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogAllowComments", AllowComments);

            EnableContentRatingSetting = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "EnableContentRatingSetting", EnableContentRatingSetting);

            EnableRatingCommentsSetting = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "EnableRatingCommentsSetting", EnableRatingCommentsSetting);

            ShowPostAuthorSetting = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "ShowPostAuthorSetting", ShowPostAuthorSetting);

            AllowWebSiteUrlForComments = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "AllowWebSiteUrlForComments", AllowWebSiteUrlForComments);

            HideDetailsFromUnauthencticated = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "HideDetailsFromUnauthencticated", HideDetailsFromUnauthencticated);

            ExcerptLength = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "BlogExcerptLengthSetting", ExcerptLength);

            if (moduleSettings.Contains("BlogExcerptSuffixSetting"))
            {
                ExcerptSuffix = moduleSettings["BlogExcerptSuffixSetting"].ToString();
            }

            if (moduleSettings.Contains("DisqusSiteShortName"))
            {
                DisqusSiteShortName = moduleSettings["DisqusSiteShortName"].ToString();
            }

            if (moduleSettings.Contains("CommentSystemSetting"))
            {
                CommentSystem = moduleSettings["CommentSystemSetting"].ToString();
            }

            if (moduleSettings.Contains("IntenseDebateAccountId"))
            {
                IntenseDebateAccountId = moduleSettings["IntenseDebateAccountId"].ToString();
            }

            CommentDateTimeFormat = DateFormat;
            if (moduleSettings.Contains("BlogDateTimeFormat"))
            {
                DateFormat = moduleSettings["BlogDateTimeFormat"].ToString().Trim();
                if (DateFormat.Length > 0)
                {
                    try
                    {
                        string d = DateTime.Now.ToString(DateFormat, CultureInfo.CurrentCulture);
                    }
                    catch (FormatException)
                    {
                        DateFormat = CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern;
                    }
                }
                else
                {
                    DateFormat = CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern;
                }
            }

            divCommentUrl.Visible = AllowWebSiteUrlForComments;

            ((CRating)Rating).Enabled       = EnableContentRatingSetting;
            ((CRating)Rating).AllowFeedback = EnableRatingCommentsSetting;
            ((CRating)Rating).ContentGuid   = ThePost.BlogGuid;

            if (moduleSettings.Contains("GoogleMapInitialMapTypeSetting"))
            {
                string gmType = moduleSettings["GoogleMapInitialMapTypeSetting"].ToString();
                try
                {
                    mapType = (MapType)Enum.Parse(typeof(MapType), gmType);
                }
                catch (ArgumentException) { }
            }

            GoogleMapHeightSetting = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "GoogleMapHeightSetting", GoogleMapHeightSetting);

            GoogleMapWidthSetting = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "GoogleMapWidthSetting", GoogleMapWidthSetting);

            GoogleMapInitialZoomSetting = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "GoogleMapInitialZoomSetting", GoogleMapInitialZoomSetting);


            GoogleMapEnableMapTypeSetting = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "GoogleMapEnableMapTypeSetting", false);

            GoogleMapEnableZoomSetting = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "GoogleMapEnableZoomSetting", false);

            GoogleMapShowInfoWindowSetting = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "GoogleMapShowInfoWindowSetting", false);

            GoogleMapEnableLocalSearchSetting = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "GoogleMapEnableLocalSearchSetting", false);

            GoogleMapEnableDirectionsSetting = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "GoogleMapEnableDirectionsSetting", false);

            if (moduleSettings.Contains("OdiogoFeedIDSetting"))
            {
                OdiogoFeedIDSetting = moduleSettings["OdiogoFeedIDSetting"].ToString();
            }

            addThisAccountId = BasePage.SiteInfo.AddThisDotComUsername;
            string altAddThisAccount = string.Empty;

            if (moduleSettings.Contains("BlogAddThisDotComUsernameSetting"))
            {
                altAddThisAccount = moduleSettings["BlogAddThisDotComUsernameSetting"].ToString().Trim();
            }

            if (altAddThisAccount.Length > 0)
            {
                addThisAccountId = altAddThisAccount;
            }

            useAddThisMouseOverWidget = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "BlogAddThisDotComUseMouseOverWidgetSetting", useAddThisMouseOverWidget);

            if (moduleSettings.Contains("BlogAddThisButtonImageUrlSetting"))
            {
                addThisButtonImageUrl = moduleSettings["BlogAddThisButtonImageUrlSetting"].ToString().Trim();
            }

            if (addThisButtonImageUrl.Length == 0)
            {
                addThisButtonImageUrl = "~/Data/SiteImages/addthissharebutton.gif";
            }

            if (moduleSettings.Contains("BlogAddThisCustomBrandSetting"))
            {
                addThisCustomBrand = moduleSettings["BlogAddThisCustomBrandSetting"].ToString().Trim();
            }

            if (addThisCustomBrand.Length == 0)
            {
                addThisCustomBrand = BasePage.SiteInfo.SiteName;
            }

            if (moduleSettings.Contains("BlogAddThisCustomOptionsSetting"))
            {
                addThisCustomOptions = moduleSettings["BlogAddThisCustomOptionsSetting"].ToString().Trim();
            }

            if (moduleSettings.Contains("BlogAddThisCustomLogoUrlSetting"))
            {
                addThisCustomLogoUrl = moduleSettings["BlogAddThisCustomLogoUrlSetting"].ToString().Trim();
            }

            if (moduleSettings.Contains("BlogAddThisCustomLogoBackColorSetting"))
            {
                addThisCustomLogoBackColor = moduleSettings["BlogAddThisCustomLogoBackColorSetting"].ToString().Trim();
            }

            if (moduleSettings.Contains("BlogAddThisCustomLogoForeColorSetting"))
            {
                addThisCustomLogoForeColor = moduleSettings["BlogAddThisCustomLogoForeColorSetting"].ToString().Trim();
            }

            if (moduleSettings.Contains("BlogCopyrightSetting"))
            {
                BlogCopyright = moduleSettings["BlogCopyrightSetting"].ToString();
            }

            if (moduleSettings.Contains("BlogAuthorSetting"))
            {
                BlogAuthor = moduleSettings["BlogAuthorSetting"].ToString().Trim();
            }
            BlogAuthor = BlogAuthor ?? "";

            pnlStatistics.Visible = ShowStatistics;

            divNav.Visible = false;
            if (ShowArchives ||
                ShowAddFeedLinks ||
                ShowCategories ||
                ShowFeedLinks ||
                ShowStatistics)
            {
                divNav.Visible = true;
            }

            if (!divNav.Visible)
            {
                divblog.CssClass = "blogcenter-nonav";
            }

            showLeftContent = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "ShowPageLeftContentSetting", showLeftContent);

            showRightContent = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "ShowPageRightContentSetting", showRightContent);

            if (ThePost.AllowCommentsForDays < 0)
            {
                pnlNewComment.Visible     = false;
                pnlCommentsClosed.Visible = true;
                AllowComments             = false;
            }

            if (ThePost.AllowCommentsForDays == 0)
            {
                pnlNewComment.Visible     = true;
                pnlCommentsClosed.Visible = false;
                AllowComments             = true;
            }

            if (ThePost.AllowCommentsForDays > 0)
            {
                DateTime endDate = ThePost.StartDate.AddDays((double)ThePost.AllowCommentsForDays);


                if (endDate > DateTime.UtcNow)
                {
                    pnlNewComment.Visible     = true;
                    pnlCommentsClosed.Visible = false;
                    AllowComments             = true;
                }
                else
                {
                    pnlNewComment.Visible     = false;
                    pnlCommentsClosed.Visible = true;
                    AllowComments             = false;
                }
            }

            if (AllowComments)
            {
                if ((RequireAuthenticationForComments) && (!Request.IsAuthenticated))
                {
                    AllowComments         = false;
                    pnlNewComment.Visible = false;
                    pnlCommentsRequireAuthentication.Visible = true;
                }
            }

            if (!UseCommentSpamBlocker)
            {
                pnlAntiSpam.Visible = false;
                captcha.Visible     = false;
                pnlNewComment.Controls.Remove(captcha);
            }

            //external comments service renderring
            loadExternalCommentService();

            if (!this.NavigationOnRight)
            {
                this.divNav.CssClass  = "blognavleft";
                this.divblog.CssClass = "blogcenter-leftnav";
            }

            if (Request.IsAuthenticated)
            {
                SiteUser currentUser = SiteUtils.GetCurrentSiteUser();
                this.txtName.Text = currentUser.Name;
                txtURL.Text       = currentUser.WebSiteUrl;
                ShowExcerptOnly   = false;
            }
            else
            {
                if ((HideDetailsFromUnauthencticated) && (ThePost.Description.Length > ExcerptLength))
                {
                    pnlDetails.Visible = false;
                    pnlExcerpt.Visible = true;
                    ShowExcerptOnly    = true;
                }

                if (CookieHelper.CookieExists("blogUser"))
                {
                    this.txtName.Text = CookieHelper.GetCookieValue("blogUser");
                }
                if (CookieHelper.CookieExists("blogUrl"))
                {
                    this.txtURL.Text = CookieHelper.GetCookieValue("blogUrl");
                }
            }
        }
Example #27
0
        public void ProcessRequest(HttpContext context)
        {
            base.Initialize(context);

            if (!UserCanEditModule(ModuleId, SharedFile.FeatureGuid))
            {
                log.Info("User has no edit permission so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentSite == null)
            {
                log.Info("CurrentSite is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentUser == null)
            {
                log.Info("CurrentUser is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (FileSystem == null)
            {
                log.Info("FileSystem is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (Request.Files.Count == 0)
            {
                log.Info("Posted File Count is zero so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (Request.Files.Count > SharedFilesConfiguration.MaxFilesToUploadAtOnce)
            {
                log.Info("Posted File Count is greater than allowed amount so returning 404");
                Response.StatusCode = 404;
                return;
            }

            module = GetModule(ModuleId, SharedFile.FeatureGuid);

            if (module == null)
            {
                log.Info("Module is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            itemId          = WebUtils.ParseInt32FromQueryString("ItemID", itemId);
            currentFolderId = WebUtils.ParseInt32FromQueryString("frmData", currentFolderId);


            virtualSourcePath  = "~/Data/Sites/" + CurrentSite.SiteId.ToInvariantString() + "/SharedFiles/";
            virtualHistoryPath = "~/Data/Sites/" + CurrentSite.SiteId.ToInvariantString() + "/SharedFiles/History/";

            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);

            config = new SharedFilesConfiguration(moduleSettings);


            context.Response.ContentType = "text/plain";//"application/json";
            var r = new System.Collections.Generic.List <UploadFilesResult>();
            JavaScriptSerializer js = new JavaScriptSerializer();


            if (!FileSystem.FolderExists(virtualSourcePath))
            {
                FileSystem.CreateFolder(virtualSourcePath);
            }

            for (int f = 0; f < Request.Files.Count; f++)
            {
                HttpPostedFile file = Request.Files[f];

                string fileName = Path.GetFileName(file.FileName);

                SharedFile sharedFile;
                if ((itemId > -1) && (Request.Files.Count == 1))
                {
                    // updating an existing file
                    sharedFile = new SharedFile(ModuleId, itemId);

                    if (config.EnableVersioning)
                    {
                        bool historyCreated = SharedFilesHelper.CreateHistory(sharedFile, FileSystem, virtualSourcePath, virtualHistoryPath);
                        if (historyCreated)
                        {
                            sharedFile.ServerFileName = System.Guid.NewGuid().ToString() + ".config";
                        }
                    }
                }
                else
                {   // new file
                    sharedFile = new SharedFile();
                }
                sharedFile.ModuleId         = ModuleId;
                sharedFile.ModuleGuid       = module.ModuleGuid;
                sharedFile.OriginalFileName = fileName;
                sharedFile.FriendlyName     = fileName;
                sharedFile.SizeInKB         = (file.ContentLength / 1024);
                sharedFile.FolderId         = currentFolderId;
                if (currentFolderId > -1)
                {
                    SharedFileFolder folder = new SharedFileFolder(ModuleId, currentFolderId);
                    sharedFile.FolderGuid = folder.FolderGuid;
                }
                sharedFile.UploadUserId = CurrentUser.UserId;
                sharedFile.UserGuid     = CurrentUser.UserGuid;
                sharedFile.UploadDate   = DateTime.UtcNow;

                sharedFile.ContentChanged += new ContentChangedEventHandler(sharedFile_ContentChanged);


                //file.SaveAs(Server.MapPath("~/Files/" + fileName));
                if (sharedFile.Save())
                {
                    string destPath = VirtualPathUtility.Combine(virtualSourcePath, sharedFile.ServerFileName);

                    using (Stream s = file.InputStream)
                    {
                        FileSystem.SaveFile(destPath, s, IOHelper.GetMimeType(Path.GetExtension(sharedFile.FriendlyName).ToLower()), true);
                    }
                }


                r.Add(new UploadFilesResult()
                {
                    //Thumbnail_url = savedFileName,
                    Name   = fileName,
                    Length = file.ContentLength,
                    Type   = file.ContentType
                });
            }

            CurrentPage.UpdateLastModifiedTime();
            CacheHelper.ClearModuleCache(ModuleId);
            SiteUtils.QueueIndexing();

            var uploadedFiles = new
            {
                files = r.ToArray()
            };
            var jsonObj = js.Serialize(uploadedFiles);

            context.Response.Write(jsonObj.ToString());
        }
        /// <summary>
        /// This method is called when the site index is rebuilt
        /// </summary>
        /// <param name="pageSettings"></param>
        /// <param name="indexPath"></param>
        public override void RebuildIndex(
            PageSettings pageSettings,
            string indexPath)
        {
            if (WebConfigSettings.DisableSearchIndex)
            {
                return;
            }
            if (pageSettings == null)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("pageSettings object passed to OfferSearchIndexBuilder.RebuildIndex was null");
                }
                return;
            }

            //don't index pending/unpublished pages
            if (pageSettings.IsPending)
            {
                return;
            }

            log.Info(Resources.WebStoreResources.WebStoreName + " indexing page - " + pageSettings.PageName);


            Guid             webStoreFeatureGuid = new Guid("0cefbf18-56de-11dc-8f36-bac755d89593");
            ModuleDefinition webStoreFeature     = new ModuleDefinition(webStoreFeatureGuid);

            List <PageModule> pageModules
                = PageModule.GetPageModulesByPage(pageSettings.PageId);

            // adding a try catch here because this is invoked even for non-implemented db platforms and it causes an error
            try
            {
                DataTable dataTable
                    = Offer.GetBySitePage(
                          pageSettings.SiteId,
                          pageSettings.PageId);

                foreach (DataRow row in dataTable.Rows)
                {
                    mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem();
                    indexItem.ModuleId = Convert.ToInt32(row["ModuleID"], CultureInfo.InvariantCulture);

                    Hashtable             moduleSettings = ModuleSettings.GetModuleSettings(indexItem.ModuleId);
                    WebStoreConfiguration config         = new WebStoreConfiguration();
                    if (moduleSettings != null)
                    {
                        config = new WebStoreConfiguration(moduleSettings);
                    }

                    if (!config.IndexOffersInSearch)
                    {
                        continue;
                    }

                    indexItem.SiteId              = pageSettings.SiteId;
                    indexItem.PageId              = pageSettings.PageId;
                    indexItem.PageName            = pageSettings.PageName;
                    indexItem.ViewRoles           = pageSettings.AuthorizedRoles;
                    indexItem.ModuleViewRoles     = row["ViewRoles"].ToString();
                    indexItem.FeatureId           = webStoreFeatureGuid.ToString();
                    indexItem.FeatureName         = webStoreFeature.FeatureName;
                    indexItem.FeatureResourceFile = webStoreFeature.ResourceFile;

                    indexItem.ItemKey = row["Guid"].ToString();

                    indexItem.ModuleTitle = row["ModuleTitle"].ToString();
                    indexItem.Title       = row["Name"].ToString();
                    indexItem.ViewPage    = row["Url"].ToString().Replace("/", string.Empty);

                    if (indexItem.ViewPage.Length > 0)
                    {
                        indexItem.UseQueryStringParams = false;
                    }
                    else
                    {
                        indexItem.ViewPage = "WebStore/OfferDetail.aspx";
                    }

                    indexItem.PageMetaDescription = row["MetaDescription"].ToString();
                    indexItem.PageMetaKeywords    = row["MetaKeywords"].ToString();

                    indexItem.CreatedUtc = Convert.ToDateTime(row["Created"]);
                    indexItem.LastModUtc = Convert.ToDateTime(row["LastModified"]);

                    indexItem.Content = row["Abstract"].ToString()
                                        + " " + row["Description"].ToString()
                                        + " " + row["MetaDescription"].ToString()
                                        + " " + row["MetaKeywords"].ToString();


                    // lookup publish dates
                    foreach (PageModule pageModule in pageModules)
                    {
                        if (indexItem.ModuleId == pageModule.ModuleId)
                        {
                            indexItem.PublishBeginDate = pageModule.PublishBeginDate;
                            indexItem.PublishEndDate   = pageModule.PublishEndDate;
                        }
                    }

                    mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem, indexPath);


                    if (debugLog)
                    {
                        log.Debug("Indexed " + indexItem.Title);
                    }
                }
            }
            catch { }
        }
Example #29
0
        private void LoadParams()
        {
            PageId = WebUtils.ParseInt32FromQueryString("pageid", PageId);
            //moduleId = WebUtils.ParseInt32FromQueryString("mid", moduleId);
            //ItemId = WebUtils.ParseInt32FromQueryString("ItemID", ItemId);
            //threadId = WebUtils.ParseInt32FromQueryString("thread", threadId);
            //PageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", PageNumber);

            threadParams = new ThreadParameterParser(this);
            threadParams.Parse();

            moduleId   = threadParams.ModuleId;
            ItemId     = threadParams.ItemId;
            threadId   = threadParams.ThreadId;
            PageNumber = threadParams.PageNumber;


            IsAdmin        = WebUser.IsAdmin;
            IsEditable     = UserCanEditModule(moduleId, Forum.FeatureGuid);
            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            config         = new ForumConfiguration(moduleSettings);

            postList.Config                 = config;
            postList.PageId                 = PageId;
            postList.ModuleId               = moduleId;
            postList.ItemId                 = ItemId;
            postList.ThreadId               = threadId;
            postList.PageNumber             = PageNumber;
            postList.IsAdmin                = IsAdmin;
            postList.IsCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles);
            postList.SiteRoot               = SiteRoot;
            postList.ImageSiteRoot          = ImageSiteRoot;
            postList.SiteSettings           = siteSettings;
            postList.IsEditable             = IsEditable;

            postListAlt.Config                 = config;
            postListAlt.PageId                 = PageId;
            postListAlt.ModuleId               = moduleId;
            postListAlt.ItemId                 = ItemId;
            postListAlt.ThreadId               = threadId;
            postListAlt.PageNumber             = PageNumber;
            postListAlt.IsAdmin                = IsAdmin;
            postListAlt.IsCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles);
            postListAlt.SiteRoot               = SiteRoot;
            postListAlt.ImageSiteRoot          = ImageSiteRoot;
            postListAlt.SiteSettings           = siteSettings;
            postListAlt.IsEditable             = IsEditable;

            if (Request.IsAuthenticated)
            {
                if (currentUser == null)
                {
                    currentUser = SiteUtils.GetCurrentSiteUser();
                }

                if ((currentUser != null) && (ItemId > -1))
                {
                    postList.UserId = currentUser.UserId;
                    postList.IsSubscribedToForum = Forum.IsSubscribed(ItemId, currentUser.UserId);

                    postListAlt.UserId = currentUser.UserId;
                    postListAlt.IsSubscribedToForum = postList.IsSubscribedToForum;
                }
            }

            if (displaySettings.UseAltPostList)
            {
                postList.Visible    = false;
                postListAlt.Visible = true;
            }

            if (displaySettings.OverrideThreadHeadingElement.Length > 0)
            {
                heading.HeadingTag = displaySettings.OverrideThreadHeadingElement;
            }

            AddClassToBody("forumthread");

            if (config.InstanceCssClass.Length > 0)
            {
                pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass);
            }

            if ((CurrentPage != null) && (CurrentPage.BodyCssClass.Length > 0))
            {
                AddClassToBody(CurrentPage.BodyCssClass);
            }
        }
        /// <summary>
        /// Gets the editor.
        /// </summary>
        /// <param name="PlaceHolderHTMLEditor">The place holder HTML editor.</param>
        /// <param name="moduleID">The module ID.</param>
        /// <param name="showUpload">if set to <c>true</c> [show upload].</param>
        /// <param name="portalSettings">The portal settings.</param>
        /// <returns></returns>
        public IHtmlEditor GetEditor(Control PlaceHolderHTMLEditor, int moduleID, bool showUpload,
                                     PortalSettings portalSettings)
        {
            IHtmlEditor DesktopText;
            string      moduleImageFolder = ModuleSettings.GetModuleSettings(moduleID)["MODULE_IMAGE_FOLDER"].ToString();

            // Grabs ID from the place holder so that a unique editor is on the page if more than one
            // But keeps same ID so that the information can be submitted to be saved. [CDT]
            string uniqueID = PlaceHolderHTMLEditor.ID;

            switch (Value)
            {
            case "FCKEditor V2":     // [email protected] 2004/11/09.
                FCKTextBoxV2 fckv2 = new FCKTextBoxV2();
                fckv2.ImageFolder        = moduleImageFolder;
                fckv2.BasePath           = Path.WebPathCombine(Path.ApplicationRoot, "aspnet_client/FCKEditorV2/");
                fckv2.AutoDetectLanguage = false;
                fckv2.DefaultLanguage    = portalSettings.PortalUILanguage.Name.Substring(0, 2);
//					fckv2.EditorAreaCSS = portalSettings.GetCurrentTheme().CssFile;
                fckv2.ID = string.Concat("FCKTextBox", uniqueID);
                string conector = Path.ApplicationRootPath("/app_support/FCKconnectorV2.aspx");
                fckv2.ImageBrowserURL =
                    Path.WebPathCombine(Path.ApplicationRoot,
                                        "aspnet_client/FCKEditorV2/editor/filemanager/browser.html?Type=Image&Connector=" +
                                        conector);
                fckv2.LinkBrowserURL =
                    Path.WebPathCombine(Path.ApplicationRoot,
                                        "aspnet_client/FCKEditorV2/editor/filemanager/browser.html?Connector=" +
                                        conector);
                DesktopText = ((IHtmlEditor)fckv2);
                break;

            case "FreeTextBox":
                FreeTextBox freeText = new FreeTextBox();
                freeText.ToolbarLayout =
                    "ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorPicker,FontBackColorPicker,FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat;CreateLink,Unlink|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;InsertRule|Delete,Cut,Copy,Paste;Undo,Redo,Print;InsertTable,InsertTableColumnAfter,InsertTableColumnBefore,InsertTableRowAfter,InsertTableRowBefore,DeleteTableColumn,DeleteTableRow,InsertImageFromGallery";
                freeText.ImageGalleryUrl =
                    Path.WebPathCombine(Path.ApplicationFullPath,
                                        "app_support/ftb.imagegallery.aspx?rif={0}&cif={0}&mID=" +
                                        moduleID.ToString());
                freeText.ImageFolder      = moduleImageFolder;
                freeText.ImageGalleryPath = Path.WebPathCombine(portalSettings.PortalFullPath, freeText.ImageFolder);
                freeText.ID       = string.Concat("FreeText", uniqueID);
                freeText.Language = getFtbLanguage(portalSettings.PortalUILanguage.Name);
                DesktopText       = ((IHtmlEditor)freeText);
                break;

            case "ActiveUp HtmlTextBox":
                HtmlTextBox h = new HtmlTextBox();
                h.ImageFolder = moduleImageFolder;
                DesktopText   = (IHtmlEditor)h;

                // Allow content editors to see the content with the same style that it is displayed in
                h.ContentCssFile = portalSettings.GetCurrentTheme().CssFile;

                // Custom Properties must come after control is added to placeholder
                h.EnsureToolsCreated();

                // Set the icons folder
                h.IconsDir = Path.WebPathCombine(Path.ApplicationRoot, "aspnet_client/ActiveUp/icons/");

                // Add the Help icon
                StringBuilder sbHelp = new StringBuilder();
                sbHelp.Append("var Help=window.open('");
                sbHelp.Append(Path.ApplicationRoot);
                sbHelp.Append("/aspnet_client/ActiveUp/");
                sbHelp.Append(
                    "htmltextbox_help.html', 'HTML_TextBox_Help', 'height=520, width=520, resizable=yes, scrollbars=yes, menubar=no, toolbar=no, directories=no, location=no, status=no');Help.moveTo('20', '20');");
                Custom openPage = new Custom();
                openPage.IconOff           = "help_off.gif";
                openPage.IconOver          = "help_off.gif";
                openPage.ClientSideOnClick = sbHelp.ToString();
                h.Toolbars[0].Tools.Add(openPage);

                // Add the image library
                Image imageLibrary = (Image)h.Toolbars[0].Tools["Image"];
                imageLibrary.AutoLoad = true;

                // Clear the directories collection because it is stored in ViewState and must be cleared or upload will result in display of multiple directories of the same name
                imageLibrary.Directories.Clear();
                imageLibrary.Directories.Add("images",
                                             HttpContext.Current.Server.MapPath(portalSettings.PortalFullPath +
                                                                                h.ImageFolder),
                                             portalSettings.PortalFullPath + h.ImageFolder + "/");

                if (!showUpload)
                {
                    imageLibrary.UploadDisabled = true;
                }
                break;

            case "Plain Text":
            default:
                DesktopText = (new TextEditor());
                break;
            }
            PlaceHolderHTMLEditor.Controls.Add(((Control)DesktopText));
            return(DesktopText);
        }