private void cbMyFiles_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e) { string attachIds = e.Parameters[1].ToString(); switch (e.Parameters[0].ToLowerInvariant()) { case "del": 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]); } if ((uid == this.UserId && !(this.UserId == -1)) | Permissions.HasPerm(ForumInfo.Security.ModDelete, ForumUser.UserRoles) || UserInfo.IsSuperUser) { ac.Attach_Delete(aid, -1, uid); } } break; } PendingAttach = 0; plhMyFiles.Controls.Clear(); BindMyFiles(); System.IO.StringWriter stringWriter = new System.IO.StringWriter(); HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter); plhMyFiles.RenderControl(htmlWriter); string html = stringWriter.GetStringBuilder().ToString(); html = Utilities.LocalizeControl(html); LiteralControl lit = new LiteralControl(); lit.Text = html; lit.RenderControl(e.Output); }
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); }