Ejemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                //Me.AFModID = MID


                if (Request.IsAuthenticated)
                {
                    btnSubmitLink.OnClientClick = "afQuickSubmit(); return false;";

                    AllowSubscribe = Permissions.HasPerm(ForumInfo.Security.Subscribe, ForumUser.UserRoles);
                }
                else
                {
                    reqUserName.Enabled  = true;
                    reqUserName.Text     = "<img src=\"" + ImagePath + "/images/warning.png\" />";
                    reqBody.Text         = "<img src=\"" + ImagePath + "/images/warning.png\" />";
                    reqSecurityCode.Text = "<img src=\"" + ImagePath + "/images/warning.png\" />";
                    btnSubmitLink.Click += ambtnSubmit_Click;

                    AllowSubscribe = false;
                }



                BoldText      = Utilities.GetSharedResource("[RESX:Bold]");
                ItalicsText   = Utilities.GetSharedResource("[RESX:Italics]");
                UnderlineText = Utilities.GetSharedResource("[RESX:Underline]");
                QuoteText     = Utilities.GetSharedResource("[RESX:Quote]");
                BoldDesc      = Utilities.GetSharedResource("[RESX:BoldDesc]");
                ItalicsDesc   = Utilities.GetSharedResource("[RESX:ItalicsDesc]");
                UnderlineDesc = Utilities.GetSharedResource("[RESX:UnderlineDesc]");
                QuoteDesc     = Utilities.GetSharedResource("[RESX:QuoteDesc]");
                CodeText      = Utilities.GetSharedResource("[RESX:Code]");
                CodeDesc      = Utilities.GetSharedResource("[RESX:CodeDesc]");
                ImageText     = Utilities.GetSharedResource("[RESX:Image]");
                ImageDesc     = Utilities.GetSharedResource("[RESX:ImageDesc]");

                if (UseFilter)
                {
                    btnToolBar.Visible = true;
                }
                else
                {
                    btnToolBar.Visible = false;
                }
                Subject             = Utilities.GetSharedResource("[RESX:SubjectPrefix]") + " " + Subject;
                trSubscribe.Visible = AllowSubscribe;
                if (!Request.IsAuthenticated && CanReply)
                {
                    trUsername.Visible = true;
                    bolIsAnon          = true;
                    trCaptcha.Visible  = true;
                }
                else
                {
                    trUsername.Visible = false;
                    trCaptcha.Visible  = false;
                    if (UserPrefTopicSubscribe || Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, this.UserId))
                    {
                        SubscribedChecked = " checked=true";
                    }
                }

                if (Utilities.InputIsValid(Request.Form["txtBody"]) && Request.IsAuthenticated & ((!(string.IsNullOrEmpty(Request.Form["hidReply1"])) && string.IsNullOrEmpty(Request.Form["hidReply2"])) | Request.Browser.IsMobileDevice))
                {
                    SaveQuickReply();
                }
            }
            catch (Exception exc)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage CreateSplit(CreateSplitDTO dto)
        {
            if (dto.NewTopicId == dto.OldTopicId)
            {
                return(Request.CreateResponse(HttpStatusCode.OK));
            }

            var portalSettings = PortalSettings;
            var userInfo       = portalSettings.UserInfo;
            var forumUser      = new UserController().GetUser(portalSettings.PortalId, ActiveModule.ModuleID, userInfo.UserID);

            var fc = new ForumController();

            var forum_out = fc.Forums_Get(portalSettings.PortalId, ActiveModule.ModuleID, 0, forumUser.UserId, false, true, dto.OldTopicId);
            var forum_in  = fc.GetForum(portalSettings.PortalId, ActiveModule.ModuleID, dto.NewForumId);

            if (forum_out != null && forum_in != null)
            {
                var perm = false;

                if (forum_out == forum_in)
                {
                    perm = Permissions.HasPerm(forum_out.Security.View, forumUser.UserRoles);
                }
                else
                {
                    perm = Permissions.HasPerm(forum_out.Security.View, forumUser.UserRoles) && Permissions.HasPerm(forum_in.Security.View, forumUser.UserRoles);
                }

                var modSplit = Permissions.HasPerm(forum_out.Security.ModSplit, forumUser.UserRoles);

                if (perm && modSplit)
                {
                    var tc = new TopicsController();

                    int topicId;

                    if (dto.NewTopicId < 1)
                    {
                        var subject      = Utilities.CleanString(portalSettings.PortalId, dto.Subject, false, EditorTypes.TEXTBOX, false, false, ActiveModule.ModuleID, string.Empty, false);
                        var replies      = dto.Replies.Split('|');
                        var rc           = new DotNetNuke.Modules.ActiveForums.DAL2.ReplyController();
                        var firstReply   = rc.Get(Convert.ToInt32(replies[0]));
                        var cc           = new ContentController();
                        var firstContent = cc.Get(firstReply.ContentId);
                        topicId = tc.Topic_QuickCreate(portalSettings.PortalId, ActiveModule.ModuleID, dto.NewForumId, subject, string.Empty, firstContent.AuthorId, firstContent.AuthorName, true, Request.GetIPAddress());
                        tc.Replies_Split(dto.OldTopicId, topicId, dto.Replies, true);
                    }
                    else
                    {
                        topicId = dto.NewTopicId;
                        tc.Replies_Split(dto.OldTopicId, topicId, dto.Replies, false);
                    }
                }
            }
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Ejemplo n.º 3
0
        public Task <HttpResponseMessage> UploadFile()
        {
            // This method uploads an attachment to a temporary directory and returns a JSON object containing information about the original file
            // including the temporary file name.  When the post is saved/updated, the temporary file is moved to the appropriate attachment directory


            // Have to a reference to these variables as the internal reference isn't available.
            // in the async result.
            var request        = Request;
            var portalSettings = PortalSettings;
            var userInfo       = portalSettings.UserInfo;
            var forumUser      = new UserController().GetUser(ActiveModule.PortalID, ActiveModule.ModuleID, userInfo.UserID);

            if (!request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotAcceptable));
            }

            const string uploadPath = "activeforums_Upload";

            var folderManager = FolderManager.Instance;

            if (!folderManager.FolderExists(ActiveModule.PortalID, uploadPath))
            {
                folderManager.AddFolder(ActiveModule.PortalID, uploadPath);
            }
            var folder = folderManager.GetFolder(ActiveModule.PortalID, uploadPath);

            var provider = new MultipartFormDataStreamProvider(folder.PhysicalPath);

            var task = request.Content.ReadAsMultipartAsync(provider).ContinueWith(t =>
            {
                if (t.IsFaulted || t.IsCanceled)
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }

                // Make sure a temp file was uploaded and that it exists
                var file = provider.FileData.FirstOrDefault();
                if (file == null || string.IsNullOrWhiteSpace(file.LocalFileName) || !File.Exists(file.LocalFileName))
                {
                    return(request.CreateErrorResponse(HttpStatusCode.NoContent, "No File Found"));
                }

                // Get the file name without the full path
                var localFileName = Path.GetFileName(file.LocalFileName).TextOrEmpty();

                // Check to make sure that a forum was specified and that the the user has upload permissions
                // This is only an initial check, it will be done again when the file is saved to a post.

                int forumId;
                if (!int.TryParse(provider.FormData["forumId"], out forumId))
                {
                    File.Delete(file.LocalFileName);
                    return(request.CreateErrorResponse(HttpStatusCode.BadRequest, "Forum Not Specified"));
                }

                // Make sure that we can find the forum and that attachments are allowed
                var fc    = new ForumController();
                var forum = fc.Forums_Get(ActiveModule.PortalID, ActiveModule.ModuleID, forumId, userInfo.UserID, true, true, -1);

                if (forum == null || !forum.AllowAttach)
                {
                    File.Delete(file.LocalFileName);
                    return(request.CreateErrorResponse(HttpStatusCode.BadRequest, "Forum Not Found"));
                }

                // Make sure the user has permissions to attach files
                if (forumUser == null || !Permissions.HasPerm(forum.Security.Attach, forumUser.UserRoles))
                {
                    File.Delete(file.LocalFileName);
                    return(request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Not Authorized"));
                }


                // Make sure that the file size does not exceed the limit (in KB) for the forum
                // Have to do this since content length is not available when using MultipartFormDataStreamProvider
                var di       = new DirectoryInfo(folder.PhysicalPath);
                var fileSize = di.GetFiles(localFileName)[0].Length;

                var maxAllowedFileSize = (long)forum.AttachMaxSize * 1024;

                if ((forum.AttachMaxSize > 0) && (fileSize > maxAllowedFileSize))
                {
                    File.Delete(file.LocalFileName);
                    return(request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "Exceeds Max File Size"));
                }


                // Get the original file name from the content disposition header
                var fileName = file.Headers.ContentDisposition.FileName.Replace("\"", "");

                if (string.IsNullOrWhiteSpace(fileName))
                {
                    File.Delete(file.LocalFileName);
                    return(request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "Invalid File"));
                }


                // Make sure we have an acceptable extension type.
                // Check against both the forum configuration and the host configuration
                var extension = Path.GetExtension(fileName).TextOrEmpty().Replace(".", string.Empty).ToLower();
                var isForumAllowedExtension = string.IsNullOrWhiteSpace(forum.AttachTypeAllowed) || forum.AttachTypeAllowed.Replace(".", "").Split(',').Any(val => val == extension);
                if (string.IsNullOrEmpty(extension) || !isForumAllowedExtension || !Host.AllowedExtensionWhitelist.IsAllowedExtension(extension))
                {
                    File.Delete(file.LocalFileName);
                    return(request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "File Type Not Allowed"));
                }

                const string newFileName = "{0}_{1}{2}";
                var fileNameOnly         = Path.GetFileNameWithoutExtension(fileName);
                var userFolder           = folderManager.GetUserFolder(userInfo);
                var attachmentFolder     = folderManager.GetFolder(userFolder.FolderID);
                var fileManager          = FileManager.Instance;
                IFileInfo ufile          = null;
                string sExt = Path.GetExtension(fileName);

                if (sExt.ToLower() == ".jpg" || sExt.ToLower() == ".bmp" || sExt.ToLower() == ".png" || sExt.ToLower() == ".jpeg")
                {
                    var sExtOut             = ".jpg";
                    ImageFormat imf, imfout = ImageFormat.Jpeg;

                    Image img = Image.FromFile(file.LocalFileName);
                    Image nimg;

                    var maxWidth  = forum.MaxAttachWidth;
                    var maxHeight = forum.MaxAttachHeight;

                    int imgWidth  = img.Width;
                    int imgHeight = img.Height;

                    var ratioWidth  = (double)imgWidth / maxWidth;
                    var ratioHeight = (double)imgHeight / maxHeight;

                    switch (sExt.ToLower())
                    {
                    case ".png":
                        {
                            imf = ImageFormat.Png;
                            if (!forum.ConvertingToJpegAllowed)
                            {
                                sExtOut = ".png";
                                imfout  = ImageFormat.Png;
                            }
                            break;
                        }

                    case ".bmp": imf = ImageFormat.Bmp; break;

                    default: imf = ImageFormat.Jpeg; break;
                    }

                    MemoryStream mst = new MemoryStream();

                    if (ratioWidth > 1 || ratioHeight > 1)
                    {
                        if (ratioWidth > ratioHeight)
                        {
                            imgWidth  = maxWidth;
                            imgHeight = (int)Math.Round(imgHeight / ratioWidth);
                        }
                        else if (ratioWidth < ratioHeight)
                        {
                            imgHeight = maxHeight;
                            imgWidth  = (int)Math.Round(imgWidth / ratioHeight);
                        }
                        else
                        {
                            imgWidth  = maxWidth;
                            imgHeight = maxHeight;
                        }
                    }

                    Bitmap res = new Bitmap(imgWidth, imgHeight);
                    using (Graphics gr = Graphics.FromImage(res))
                    {
                        gr.Clear(Color.Transparent);
                        gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                        gr.DrawImage(img, new Rectangle(0, 0, imgWidth, imgHeight), new Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
                        gr.Dispose();
                    }

                    img.Dispose();
                    res.Save(mst, imfout);
                    res.Dispose();

                    var index = 0;
                    fileName  = fileNameOnly + sExtOut;

                    while (fileManager.FileExists(attachmentFolder, fileName))
                    {
                        index++;
                        fileName = string.Format(newFileName, fileNameOnly, index, sExtOut);
                    }

                    ufile = fileManager.AddFile(attachmentFolder, fileName, (Stream)mst);
                    mst.Close();
                }
                else
                {
                    using (var fileStream = new FileStream(file.LocalFileName, FileMode.Open, FileAccess.Read))
                    {
                        var index = 0;
                        while (fileManager.FileExists(attachmentFolder, fileName))
                        {
                            index++;
                            fileName = string.Format(newFileName, fileNameOnly, index, sExt);
                        }

                        ufile = fileManager.AddFile(attachmentFolder, fileName, fileStream);
                    }
                }


                // IE<=9 Hack - can't return application/json
                var mediaType = "application/json";
                if (!request.Headers.Accept.Any(h => h.MediaType.Equals("application/json", StringComparison.OrdinalIgnoreCase)))
                {
                    mediaType = "text/html";
                }

                File.Delete(file.LocalFileName);

                if (ufile != null)
                {
                    var result = new ClientAttachment()
                    {
                        FileId      = ufile.FileId,
                        ContentType = file.Headers.ContentType.MediaType,
                        FileName    = fileName,
                        FileSize    = ufile.Size,
                        UploadId    = localFileName,
                    };

                    return(Request.CreateResponse(HttpStatusCode.Accepted, result, mediaType));
                }
                else
                {
                    return(request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "No File Found"));
                }
            });

            return(task);
        }
Ejemplo n.º 4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            btnCancel.Click += new System.EventHandler(btnCancel_Click);
            btnSend.Click   += new System.EventHandler(btnSend_Click);
            string warnImg = "<img src=\"" + ImagePath + "/images/warning.png\" />";

            reqEmail.Text   = warnImg;
            reqMessage.Text = warnImg;
            reqName.Text    = warnImg;
            reqSubject.Text = warnImg;
            regEmail.Text   = warnImg;
            regEmail.ValidationExpression = "\\b[a-zA-Z0-9._%\\-+']+@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]{2,4}\\b";
            string TopicSubject = string.Empty;

            if (TopicId > 0)
            {
                TopicsController tc = new TopicsController();
                TopicInfo        ti = tc.Topics_Get(PortalId, ModuleId, TopicId, ForumId, UserId, true);
                if (ti != null)
                {
                    if (Permissions.HasPerm(ForumInfo.Security.Read, ForumUser.UserRoles))
                    {
                        if (!Page.IsPostBack)
                        {
                            string SubjectDefault = GetSharedResource("[RESX:EmailSubjectDefault]");
                            TopicSubject   = ti.Content.Subject;
                            SubjectDefault = SubjectDefault.Replace("[SUBJECT]", ti.Content.Subject);

                            txtRecipSubject.Text = SubjectDefault;
                            string MessageDefault = GetSharedResource("[RESX:EmailMessageDefault]");
                            string sURL           = NavigateUrl(TabId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId });
                            if (MainSettings.UseShortUrls)
                            {
                                sURL = NavigateUrl(TabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId });
                            }
                            MessageDefault  = MessageDefault.Replace("[TOPICLINK]", sURL);
                            MessageDefault  = MessageDefault.Replace("[DISPLAYNAME]", UserProfiles.GetDisplayName(ModuleId, UserId, UserInfo.Username, UserInfo.FirstName, UserInfo.LastName, UserInfo.DisplayName));
                            txtMessage.Text = MessageDefault;
                        }
                    }
                    if (MainSettings.UseSkinBreadCrumb)
                    {
                        string sCrumb = "<a href=\"" + NavigateUrl(TabId, "", ParamKeys.GroupId + "=" + ForumGroupId) + "\">" + ForumInfo.GroupName + "</a>|";
                        if (MainSettings.UseShortUrls)
                        {
                            sCrumb += "<a href=\"" + NavigateUrl(TabId, "", ParamKeys.ForumId + "=" + ForumId) + "\">" + ForumInfo.ForumName + "</a>";
                            sCrumb += "|<a href=\"" + NavigateUrl(TabId, "", ParamKeys.TopicId + "=" + TopicId) + "\">" + TopicSubject + "</a>";
                        }
                        else
                        {
                            sCrumb += "<a href=\"" + NavigateUrl(TabId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topics }) + "\">" + ForumInfo.ForumName + "</a>";
                            sCrumb += "|<a href=\"" + NavigateUrl(TabId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId }) + "\">" + TopicSubject + "</a>";
                        }
                        if (Environment.UpdateBreadCrumb(Page.Controls, sCrumb))
                        {
                            bcUpdated = true;
                        }
                    }
                }
                else
                {
                    Response.Redirect(NavigateUrl(TabId));
                }
            }
        }
Ejemplo n.º 5
0
        private string BuildRSS(int PortalId, int TabId, int ModuleId, int intPosts, int ForumID, bool IngnoreSecurity, bool IncludeBody)
        {
            DotNetNuke.Entities.Portals.PortalController pc = new DotNetNuke.Entities.Portals.PortalController();
            DotNetNuke.Entities.Portals.PortalSettings   ps = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings();
            DotNetNuke.Entities.Users.UserInfo           ou = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
            UserController uc = new UserController();
            User           u  = uc.GetUser(PortalId, ModuleId);

            DataSet ds = DataProvider.Instance().UI_TopicsView(PortalId, ModuleId, ForumID, ou.UserID, 0, 20, ou.IsSuperUser, SortColumns.ReplyCreated);

            if (ds.Tables.Count > 0)
            {
                offSet = Convert.ToInt32(ps.TimeZone.BaseUtcOffset.TotalMinutes);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    return(string.Empty);
                }
                drForum = ds.Tables[0].Rows[0];

                drSecurity = ds.Tables[1].Rows[0];
                dtTopics   = ds.Tables[3];
                if (dtTopics.Rows.Count == 0)
                {
                    return(string.Empty);
                }
                bView = Permissions.HasPerm(drSecurity["CanView"].ToString(), u.UserRoles);
                bRead = Permissions.HasPerm(drSecurity["CanRead"].ToString(), u.UserRoles);
                StringBuilder sb = new StringBuilder(1024);
                if (bRead)
                {
                    ForumName        = drForum["ForumName"].ToString();
                    GroupName        = drForum["GroupName"].ToString();
                    ForumDescription = drForum["ForumDesc"].ToString();
                    //TopicsTemplateId = CInt(drForum("TopicsTemplateId"))
                    bAllowRSS = Convert.ToBoolean(drForum["AllowRSS"]);
                    if (bAllowRSS)
                    {
                        sb.Append("<?xml version=\"1.0\" ?>" + System.Environment.NewLine);
                        sb.Append("<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:cf=\"http://www.microsoft.com/schemas/rss/core/2005\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\">" + System.Environment.NewLine);
                        string[] Params = { ParamKeys.ForumId + "=" + ForumID, ParamKeys.ViewType + "=" + Views.Topics };
                        string   URL    = string.Empty;
                        if (Request.QueryString["asg"] == null)
                        {
                            URL = DotNetNuke.Common.Globals.NavigateURL(TabId, "", Params);
                        }
                        else if (SimulateIsNumeric.IsNumeric(Request.QueryString["asg"]))
                        {
                            Params = new string[] { "asg=" + Request.QueryString["asg"], ParamKeys.ForumId + "=" + ForumID, ParamKeys.ViewType + "=" + Views.Topics };
                            URL    = DotNetNuke.Common.Globals.NavigateURL(TabId, "", Params);
                        }

                        if (URL.IndexOf(Request.Url.Host) == -1)
                        {
                            URL = DotNetNuke.Common.Globals.AddHTTP(Request.Url.Host) + URL;
                        }
                        // build channel
                        sb.Append(WriteElement("channel", 1));
                        sb.Append(WriteElement("title", HttpUtility.HtmlEncode(ps.PortalName) + " " + ForumName, 2));
                        sb.Append(WriteElement("link", URL, 2));
                        sb.Append(WriteElement("description", ForumDescription, 2));
                        sb.Append(WriteElement("language", PortalSettings.DefaultLanguage, 2));
                        sb.Append(WriteElement("generator", "ActiveForums  5.0", 2));
                        sb.Append(WriteElement("copyright", PortalSettings.FooterText, 2));
                        sb.Append(WriteElement("lastBuildDate", "[LASTBUILDDATE]", 2));
                        if (!(ps.LogoFile == string.Empty))
                        {
                            string sLogo = "<image><url>http://" + Request.Url.Host + ps.HomeDirectory + ps.LogoFile + "</url>";
                            sLogo += "<title>" + ps.PortalName + " " + ForumName + "</title>";
                            sLogo += "<link>" + URL + "</link></image>";
                            sb.Append(sLogo);
                        }
                        foreach (DataRow dr in dtTopics.Rows)
                        {
                            if (DotNetNuke.Security.PortalSecurity.IsInRoles(PortalSettings.ActiveTab.TabPermissions.ToString("VIEW")))
                            {
                                //objModule = objModules.GetModule(ModuleId, TabId)
                                //If DotNetNuke.Security.PortalSecurity.IsInRoles(objModule.AuthorizedViewRoles) = True Then
                                //    sb.Append(BuildItem(dr, TabId, 2, IncludeBody, PortalId))
                                //End If
                                sb.Append(BuildItem(dr, TabId, 2, IncludeBody, PortalId));
                            }
                        }
                        sb.Append("<atom:link href=\"http://" + Request.Url.Host + HttpUtility.HtmlEncode(Request.RawUrl) + "\" rel=\"self\" type=\"application/rss+xml\" />");
                        sb.Append(WriteElement("/channel", 1));
                        sb.Replace("[LASTBUILDDATE]", LastBuildDate.ToString("r"));
                        sb.Append("</rss>");
                        //Cache.Insert("RSS" & ModuleId & ForumID, sb.ToString, Nothing, DateTime.Now.AddMinutes(dblCacheTimeOut), TimeSpan.Zero)
                        return(sb.ToString());
                    }
                }
            }


            return(string.Empty);
        }
Ejemplo n.º 6
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                UserController  uc = new UserController();
                User            ui = uc.GetUser(PortalSettings.PortalId, -1);
                ForumController fc = new ForumController();
                Forum           fi = fc.Forums_Get(Convert.ToInt32(Request.Params["ForumId"]), ui.UserId, true);

                if (fi != null)
                {
                    if (Permissions.HasPerm(fi.Security.Attach, ui.UserRoles))
                    {
                        if (inpFile.HasFile)
                        {
                            string sFile        = string.Empty;
                            string sExt         = string.Empty;
                            int    maxImgHeight = fi.AttachMaxHeight;
                            int    maxImgWidth  = fi.AttachMaxWidth;
                            string contentType  = inpFile.PostedFile.ContentType;
                            sFile = Path.GetFileName(inpFile.PostedFile.FileName).Replace(" ", "_");

                            sExt = Path.GetExtension(sFile);
                            if (sFile.Length >= 250)
                            {
                                sFile = sFile.Replace(sExt, string.Empty);
                                sFile = sFile.Substring(0, (250 - sExt.Length));
                                sFile = sFile + sExt;
                            }
                            sExt = sExt.Replace(".", string.Empty);
                            if (!(fi.AttachTypeAllowed.ToString().ToLower().Contains(sExt.ToLower())))
                            {
                                Response.Write("<script type=\"text/javascript\">window.top.af_setMessage('" + Utilities.GetSharedResource("[RESX:Error:BlockedFile]") + "');</script>");
                                return;
                            }
                            if (fi.AttachMaxSize > 0)
                            {
                                if ((inpFile.PostedFile.ContentLength / 1024.0) > fi.AttachMaxSize)
                                {
                                    Response.Write("<script type=\"text/javascript\">window.top.af_setMessage('" + string.Format(Utilities.GetSharedResource("[RESX:Error:FileTooLarge]"), fi.AttachMaxSize) + "');</script>");
                                    return;
                                }
                            }

                            Stream       inpStream     = inpFile.PostedFile.InputStream;
                            MemoryStream imgStream     = new MemoryStream();
                            bool         useMemStream  = false;
                            bool         allowDownload = true;
                            bool         displayInline = false;
                            if (sExt.ToLower() == "jpg" || sExt.ToLower() == "gif" || sExt.ToLower() == "bmp" || sExt.ToLower() == "png" || sExt.ToLower() == "jpeg")
                            {
                                useMemStream  = true;
                                imgStream     = (MemoryStream)(Images.CreateImageForDB(inpStream, maxImgHeight, maxImgWidth));
                                contentType   = "image/x-png";
                                allowDownload = false;
                                displayInline = true;
                            }

                            Data.AttachController ac = new Data.AttachController();
                            AttachInfo            ai = new AttachInfo();
                            ai.ContentId = -1;
                            ai.UserID    = ui.UserId;

                            ai.ContentType    = contentType;
                            ai.DisplayInline  = displayInline;
                            ai.AllowDownload  = allowDownload;
                            ai.ParentAttachId = 0;
                            if (fi.AttachStore == AttachStores.DATABASE)
                            {
                                if (useMemStream)
                                {
                                    ai.FileSize = Convert.ToInt32(imgStream.Length);
                                    ai.FileData = imgStream.ToArray();
                                }
                                else
                                {
                                    byte[] byteData = new byte[Convert.ToInt32(inpStream.Length - 1) + 1];
                                    inpStream.Read(byteData, 0, Convert.ToInt32(inpStream.Length));
                                    ai.FileSize = Convert.ToInt32(inpStream.Length);
                                    ai.FileData = byteData;
                                }
                                ai.Filename = sFile;
                            }
                            else
                            {
                                if (useMemStream)
                                {
                                    ai.FileSize = Convert.ToInt32(imgStream.Length);
                                    ai.Filename = SaveToFile(imgStream, sFile);
                                }
                                else
                                {
                                    byte[] byteData = new byte[Convert.ToInt32(inpStream.Length) + 1];
                                    inpStream.Read(byteData, 0, Convert.ToInt32(inpStream.Length));
                                    ai.FileSize = Convert.ToInt32(inpStream.Length);
                                    ai.Filename = SaveToFile(inpFile, sFile);
                                }
                            }
                            int attachId = ac.Attach_Save(ai);
                            Response.Write("<script type=\"text/javascript\">window.top.af_isUploaded(" + attachId.ToString() + ");</script>");
                        }
                    }
                    else
                    {
                        inpFile.Visible = false;
                    }
                }
                else
                {
                    inpFile.Visible = false;
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script type=\"text/javascript\">window.top.af_setMessage('" + ex.Message + "');</script>");
            }
        }
        public Task <HttpResponseMessage> UploadFile()
        {
            // This method uploads an attachment to a temporary directory and returns a JSON object containing information about the original file
            // including the temporary file name.  When the post is saved/updated, the temporary file is moved to the appropriate attachment directory


            // Have to a reference to these variables as the internal reference isn't available.
            // in the async result.
            var request        = Request;
            var portalSettings = PortalSettings;
            var userInfo       = portalSettings.UserInfo;
            var forumUser      = new UserController().GetUser(ActiveModule.PortalID, ActiveModule.ModuleID, userInfo.UserID);

            if (!request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotAcceptable));
            }

            const string uploadPath = "activeforums_Upload";

            var folderManager = FolderManager.Instance;

            if (!folderManager.FolderExists(ActiveModule.PortalID, uploadPath))
            {
                folderManager.AddFolder(ActiveModule.PortalID, uploadPath);
            }
            var folder = folderManager.GetFolder(ActiveModule.PortalID, uploadPath);

            var provider = new MultipartFormDataStreamProvider(folder.PhysicalPath);

            var task = request.Content.ReadAsMultipartAsync(provider).ContinueWith(t =>
            {
                if (t.IsFaulted || t.IsCanceled)
                {
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }

                // Make sure a temp file was uploaded and that it exists
                var file = provider.FileData.FirstOrDefault();
                if (file == null || string.IsNullOrWhiteSpace(file.LocalFileName) || !File.Exists(file.LocalFileName))
                {
                    return(request.CreateErrorResponse(HttpStatusCode.NoContent, "No File Found"));
                }

                // Get the file name without the full path
                var localFileName = Path.GetFileName(file.LocalFileName).TextOrEmpty();

                // Check to make sure that a forum was specified and that the the user has upload permissions
                // This is only an initial check, it will be done again when the file is saved to a post.

                int forumId;
                if (!int.TryParse(provider.FormData["forumId"], out forumId))
                {
                    File.Delete(file.LocalFileName);
                    return(request.CreateErrorResponse(HttpStatusCode.BadRequest, "Forum Not Specified"));
                }

                // Make sure that we can find the forum and that attachments are allowed
                var fc    = new ForumController();
                var forum = fc.Forums_Get(ActiveModule.PortalID, ActiveModule.ModuleID, forumId, userInfo.UserID, true, true, -1);

                if (forum == null || !forum.AllowAttach)
                {
                    File.Delete(file.LocalFileName);
                    return(request.CreateErrorResponse(HttpStatusCode.BadRequest, "Forum Not Found"));
                }

                // Make sure the user has permissions to attach files
                if (forumUser == null || !Permissions.HasPerm(forum.Security.Attach, forumUser.UserRoles))
                {
                    File.Delete(file.LocalFileName);
                    return(request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Not Authorized"));
                }


                // Make sure that the file size does not exceed the limit (in KB) for the forum
                // Have to do this since content length is not available when using MultipartFormDataStreamProvider
                var di       = new DirectoryInfo(folder.PhysicalPath);
                var fileSize = di.GetFiles(localFileName)[0].Length;

                var maxAllowedFileSize = (long)forum.AttachMaxSize * 1024;

                if ((forum.AttachMaxSize > 0) && (fileSize > maxAllowedFileSize))
                {
                    File.Delete(file.LocalFileName);
                    return(request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "Exceeds Max File Size"));
                }


                // Get the original file name from the content disposition header
                var fileName = file.Headers.ContentDisposition.FileName.Replace("\"", "");

                if (string.IsNullOrWhiteSpace(fileName))
                {
                    File.Delete(file.LocalFileName);
                    return(request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "Invalid File"));
                }


                // Make sure we have an acceptable extension type.
                // Check against both the forum configuration and the host configuration
                var extension = Path.GetExtension(fileName).TextOrEmpty().Replace(".", string.Empty).ToLower();
                var isForumAllowedExtension = string.IsNullOrWhiteSpace(forum.AttachTypeAllowed) || forum.AttachTypeAllowed.Replace(".", "").Split(',').Any(val => val == extension);
                if (string.IsNullOrEmpty(extension) || !isForumAllowedExtension || !Host.AllowedExtensionWhitelist.IsAllowedExtension(extension))
                {
                    File.Delete(file.LocalFileName);
                    return(request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "File Type Not Allowed"));
                }


                // IE<=9 Hack - can't return application/json
                var mediaType = "application/json";
                if (!request.Headers.Accept.Any(h => h.MediaType.Equals("application/json", StringComparison.OrdinalIgnoreCase)))
                {
                    mediaType = "text/html";
                }

                var result = new ClientAttachment()
                {
                    ContentType = file.Headers.ContentType.MediaType,
                    FileName    = fileName,
                    FileSize    = fileSize,
                    UploadId    = localFileName
                };

                return(Request.CreateResponse(HttpStatusCode.Accepted, result, mediaType));
            });

            return(task);
        }
Ejemplo n.º 8
0
        private void cbAttach_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
        {
            string attachIds = e.Parameters[1].ToString();

            switch (e.Parameters[0].ToLowerInvariant())
            {
            case "delcont":
            {
                if (SimulateIsNumeric.IsNumeric(e.Parameters[2]))
                {
                    int aid = Convert.ToInt32(e.Parameters[2]);
                    int uid = -1;
                    if (SimulateIsNumeric.IsNumeric(e.Parameters[3]))
                    {
                        uid = Convert.ToInt32(e.Parameters[3]);
                    }
                    if ((uid == this.UserId && !(this.UserId == -1)) | Permissions.HasPerm(ForumInfo.Security.ModDelete, ForumUser.UserRoles) || UserInfo.IsSuperUser)
                    {
                        Data.AttachController adb = new Data.AttachController();
                        adb.Attach_Delete(aid, ContentId);
                        //ac.Attach_Delete(aid, -1, uid)
                    }
                }
                break;
            }

            case "thumb":
            {
                if (SimulateIsNumeric.IsNumeric(e.Parameters[2]))
                {
                    int aid = Convert.ToInt32(e.Parameters[2]);
                    Data.AttachController ac = new Data.AttachController();
                    int uid = -1;
                    if (SimulateIsNumeric.IsNumeric(e.Parameters[3]))
                    {
                        uid = Convert.ToInt32(e.Parameters[3]);
                    }
                    AttachInfo ai = ac.Attach_Get(aid, -1, uid, false);
                    if (ai != null)
                    {
                        int w = Convert.ToInt32(e.Parameters[4]);
                        int h = Convert.ToInt32(e.Parameters[5]);
                        System.IO.MemoryStream imgStream = new System.IO.MemoryStream();
                        string fpath       = string.Empty;
                        int    fileSize    = 0;
                        string tmpFilename = string.Empty;
                        if (ai.FileData != null)
                        {
                            byte[] bindata = null;
                            bindata = (byte[])ai.FileData;
                            System.IO.MemoryStream memStream = new System.IO.MemoryStream(bindata);
                            imgStream   = (System.IO.MemoryStream)(Images.CreateImageForDB(memStream, h, w));
                            fileSize    = Convert.ToInt32(imgStream.Length);
                            tmpFilename = "thumb_" + ai.Filename;
                        }
                        else
                        {
                            fpath = Server.MapPath(PortalSettings.HomeDirectory + "activeforums_Attach/");
                            //fpath &= "thumb_" & ai.Filename
                            tmpFilename = "thumb_" + ai.Filename;
                            string sFullFile = fpath + tmpFilename;
                            int    i         = 0;

                            while (File.Exists(sFullFile))
                            {
                                i          += 1;
                                tmpFilename = i.ToString().PadLeft(3, '0') + "_thumb_" + ai.Filename;
                                sFullFile   = fpath + tmpFilename;
                            }
                            File.Copy(fpath + ai.Filename, sFullFile);
                            Images.CreateImage(sFullFile, h, w);
                            fileSize = (int)new FileInfo(sFullFile).Length;
                        }
                        AttachInfo aiThumb = new AttachInfo();
                        aiThumb.ContentId   = -1;
                        aiThumb.UserID      = ai.UserID;
                        aiThumb.Filename    = tmpFilename;
                        aiThumb.ContentType = "image/x-png";
                        aiThumb.FileSize    = fileSize;
                        if (ForumInfo.AttachStore == AttachStores.DATABASE)
                        {
                            aiThumb.FileData = imgStream.ToArray();
                            //File.Delete(fpath & "thumb_" & ai.Filename)
                        }
                        aiThumb.ParentAttachId = aid;
                        int thumbId = ac.Attach_Save(aiThumb);
                        attachIds += thumbId.ToString() + ";";
                        BindMyFiles();
                        if (Convert.ToBoolean(e.Parameters[4]))
                        {
                            string strHost = DotNetNuke.Common.Globals.AddHTTP(DotNetNuke.Common.Globals.GetDomainName(Request)) + "/";
                            string s       = "<script type=\"text/javascript\">";
                            string sInsert = string.Empty;
                            if (ForumInfo.AllowHTML && ForumInfo.EditorType != EditorTypes.TEXTBOX)
                            {
                                sInsert = "<a href=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + aid + "\" target=\"_blank\"><img src=" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + thumbId + " border=0 /></a>";
                            }
                            else
                            {
                                sInsert = "[THUMBNAIL:" + thumbId.ToString() + ":" + aid + "]";
                            }

                            s += "amaf_insertHTML('" + sInsert + "');";
                            s += "</script>";
                            LiteralControl litScript = new LiteralControl();
                            litScript.Text = s;
                            plhAttach.Controls.Add(litScript);
                        }
                    }
                }
                break;
            }

            case "inline":
            {
                if (SimulateIsNumeric.IsNumeric(e.Parameters[2]))
                {
                    int aid = Convert.ToInt32(e.Parameters[2]);
                    Data.AttachController ac = new Data.AttachController();
                    int uid = -1;
                    if (SimulateIsNumeric.IsNumeric(e.Parameters[3]))
                    {
                        uid = Convert.ToInt32(e.Parameters[3]);
                    }
                    AttachInfo ai = ac.Attach_Get(aid, -1, uid, false);
                    if (ai != null)
                    {
                        int opt = Convert.ToInt32(e.Parameters[4]);
                        if (opt == 0)
                        {
                            ai.DisplayInline = true;
                            ai.AllowDownload = false;
                        }
                        else
                        {
                            if (ai.AllowDownload)
                            {
                                ai.DisplayInline = true;
                                ai.AllowDownload = false;
                            }
                            else
                            {
                                ai.DisplayInline = false;
                                ai.AllowDownload = true;
                            }
                        }


                        ac.Attach_Save(ai);
                    }
                }
                break;
            }
            }

            BindAttach(attachIds);
            System.IO.StringWriter stringWriter = new System.IO.StringWriter();
            HtmlTextWriter         htmlWriter   = new HtmlTextWriter(stringWriter);

            plhAttach.RenderControl(htmlWriter);
            string html = stringWriter.GetStringBuilder().ToString();

            html = Utilities.LocalizeControl(html);
            LiteralControl lit = new LiteralControl();

            lit.Text = html;
            lit.RenderControl(e.Output);
        }
Ejemplo n.º 9
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (Permissions.HasPerm(ForumInfo.Security.Attach, ForumUser.UserRoles) || Permissions.HasPerm(ForumInfo.Security.ModEdit, ForumUser.UserRoles))
            {
                btnUpload.ImageUrl = ImagePath + "/images/upload16.png";
                btnUpload.ObjectId = "btnUpload";
                btnUpload.Text     = GetSharedResource("[RESX:Upload]");
                if (!cbAttach.IsCallback)
                {
                    BindAttach(string.Empty);
                    BindMyFiles();
                }
            }
        }
Ejemplo n.º 10
0
        private void SaveQuickReply()
        {
            SettingsInfo ms             = DataCache.MainSettings(ForumModuleId);
            int          iFloodInterval = MainSettings.FloodInterval;

            if (iFloodInterval > 0)
            {
                UserProfileInfo upi = ForumUser.Profile;
                if (upi != null)
                {
                    if (SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Second, upi.DateLastPost, DateTime.Now) < iFloodInterval)
                    {
                        Controls.InfoMessage im = new Controls.InfoMessage();
                        im.Message = "<div class=\"afmessage\">" + string.Format(GetSharedResource("[RESX:Error:FloodControl]"), iFloodInterval) + "</div>";
                        plhMessage.Controls.Add(im);
                        return;
                    }
                }
            }
            if (!Request.IsAuthenticated)
            {
                if ((!ctlCaptcha.IsValid) || txtUserName.Value == "")
                {
                    return;
                }
            }
            UserProfileInfo ui = new UserProfileInfo();

            if (UserId > 0)
            {
                ui = ForumUser.Profile;
            }
            else
            {
                ui.TopicCount   = 0;
                ui.ReplyCount   = 0;
                ui.RewardPoints = 0;
                ui.IsMod        = false;
                ui.TrustLevel   = -1;
            }
            bool UserIsTrusted = false;

            UserIsTrusted = Utilities.IsTrusted((int)ForumInfo.DefaultTrustValue, ui.TrustLevel, Permissions.HasPerm(ForumInfo.Security.Trust, ForumUser.UserRoles), ForumInfo.AutoTrustLevel, ui.PostCount);
            bool isApproved = false;

            isApproved = Convert.ToBoolean(((ForumInfo.IsModerated == true) ? false : true));
            if (UserIsTrusted || Permissions.HasPerm(ForumInfo.Security.ModApprove, ForumUser.UserRoles))
            {
                isApproved = true;
            }
            ReplyInfo       ri        = new ReplyInfo();
            ReplyController rc        = new ReplyController();
            int             ReplyId   = -1;
            string          sUsername = string.Empty;

            if (Request.IsAuthenticated)
            {
                switch (MainSettings.UserNameDisplay.ToUpperInvariant())
                {
                case "USERNAME":
                    sUsername = UserInfo.Username.Trim(' ');
                    break;

                case "FULLNAME":
                    sUsername = Convert.ToString(UserInfo.FirstName + " " + UserInfo.LastName).Trim(' ');
                    break;

                case "FIRSTNAME":
                    sUsername = UserInfo.FirstName.Trim(' ');
                    break;

                case "LASTNAME":
                    sUsername = UserInfo.LastName.Trim(' ');
                    break;

                case "DISPLAYNAME":
                    sUsername = UserInfo.DisplayName.Trim(' ');
                    break;

                default:
                    sUsername = UserInfo.DisplayName;
                    break;
                }
            }
            else
            {
                sUsername = Utilities.CleanString(PortalId, txtUserName.Value, false, EditorTypes.TEXTBOX, true, false, ForumModuleId, ThemePath, false);
            }

            //Dim sSubject As String = Server.HtmlEncode(Request.Form("txtSubject"))
            //If (UseFilter) Then
            //    sSubject = Utilities.FilterWords(PortalId,  ForumModuleId, ThemePath, sSubject)
            //End If
            string sBody = string.Empty;

            if (AllowHTML)
            {
                AllowHTML = IsHtmlPermitted(ForumInfo.EditorPermittedUsers, IsTrusted, Permissions.HasPerm(ForumInfo.Security.ModEdit, ForumUser.UserRoles));
            }
            sBody = Utilities.CleanString(PortalId, Request.Form["txtBody"], AllowHTML, EditorTypes.TEXTBOX, UseFilter, AllowScripts, ForumModuleId, ThemePath, ForumInfo.AllowEmoticons);
            DateTime createDate = DateTime.Now;

            ri.TopicId             = TopicId;
            ri.ReplyToId           = TopicId;
            ri.Content.AuthorId    = UserId;
            ri.Content.AuthorName  = sUsername;
            ri.Content.Body        = sBody;
            ri.Content.DateCreated = createDate;
            ri.Content.DateUpdated = createDate;
            ri.Content.IsDeleted   = false;
            ri.Content.Subject     = Subject;
            ri.Content.Summary     = string.Empty;
            ri.IsApproved          = isApproved;
            ri.IsDeleted           = false;
            ri.Content.IPAddress   = Request.UserHostAddress;
            ReplyId = rc.Reply_Save(PortalId, ri);
            //Check if is subscribed
            string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);

            DataCache.CacheClearPrefix(cachekey);


            // Subscribe or unsubscribe if needed
            if (AllowSubscribe && UserId > 0)
            {
                var subscribe           = Request.Params["chkSubscribe"] == "1";
                var currentlySubscribed = Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, UserId);

                if (subscribe != currentlySubscribed)
                {
                    // Will need to update this to support multiple subscrition types later
                    // Subscription_Update works as a toggle, so you only call it if you want to change the value.
                    var sc = new SubscriptionController();
                    sc.Subscription_Update(PortalId, ForumModuleId, ForumId, TopicId, 1, UserId, ForumUser.UserRoles);
                }
            }



            ControlUtils     ctlUtils = new ControlUtils();
            TopicsController tc       = new TopicsController();
            TopicInfo        ti       = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, -1, false);
            string           fullURL  = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, SocialGroupId);

            if (fullURL.Contains("~/") || Request.QueryString["asg"] != null)
            {
                fullURL = Utilities.NavigateUrl(TabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId });
            }
            if (fullURL.EndsWith("/"))
            {
                fullURL += "?" + ParamKeys.ContentJumpId + "=" + ReplyId;
            }
            if (isApproved)
            {
                //Send Subscriptions

                try
                {
                    //Dim sURL As String = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId})
                    Subscriptions.SendSubscriptions(PortalId, ForumModuleId, TabId, ForumId, TopicId, ReplyId, UserId);
                    try
                    {
                        Social amas = new Social();
                        amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, string.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId);
                        //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled And Not ForumInfo.ActiveSocialTopicsOnly Then
                        //    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read)
                        //Else
                        //    amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, sBody)
                        //End If
                    }
                    catch (Exception ex)
                    {
                        DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                    }
                }
                catch (Exception ex)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                }
                //Redirect to show post

                Response.Redirect(fullURL, false);
            }
            else if (isApproved == false)
            {
                List <Entities.Users.UserInfo> mods = Utilities.GetListOfModerators(PortalId, ForumId);
                NotificationType notificationType   = NotificationsController.Instance.GetNotificationType("AF-ForumModeration");
                string           subject            = Utilities.GetSharedResource("NotificationSubjectReply");
                subject = subject.Replace("[DisplayName]", UserInfo.DisplayName);
                subject = subject.Replace("[TopicSubject]", ti.Content.Subject);
                string body = Utilities.GetSharedResource("NotificationBodyReply");
                body = body.Replace("[Post]", sBody);
                string notificationKey = string.Format("{0}:{1}:{2}:{3}:{4}", TabId, ForumModuleId, ForumId, TopicId, ReplyId);

                Notification notification = new Notification();
                notification.NotificationTypeID = notificationType.NotificationTypeId;
                notification.Subject            = subject;
                notification.Body = body;
                notification.IncludeDismissAction = false;
                notification.SenderUserID         = UserInfo.UserID;
                notification.Context = notificationKey;

                NotificationsController.Instance.SendNotification(notification, PortalId, null, mods);

                var @params = new List <string> {
                    ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", "afmsg=pendingmod", ParamKeys.TopicId + "=" + TopicId
                };
                if (SocialGroupId > 0)
                {
                    @params.Add("GroupId=" + SocialGroupId);
                }
                Response.Redirect(Utilities.NavigateUrl(TabId, "", @params.ToArray()), false);
            }
            else
            {
                //Dim fullURL As String = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId})
                //If MainSettings.UseShortUrls Then
                //    fullURL = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId})
                //End If

                try
                {
                    Social amas = new Social();
                    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, string.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId);
                    //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled Then
                    //    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read)
                    //Else
                    //    amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, sBody)
                    //End If
                }
                catch (Exception ex)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                }
                Response.Redirect(fullURL, false);
            }

            //End If
        }