private void cbAdmin_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e) { if (!(CurrentUserType == CurrentUserTypes.Anon) && !(CurrentUserType == CurrentUserTypes.Auth)) { UserProfileController upc = new UserProfileController(); UserController uc = new UserController(); UserProfileInfo upi = uc.GetUser(PortalId, ForumModuleId, UID).Profile; if (upi != null) { upi.RewardPoints = Convert.ToInt32(e.Parameters[1]); upi.UserCaption = e.Parameters[2].ToString(); upi.SignatureDisabled = Convert.ToBoolean(e.Parameters[3]); upi.AvatarDisabled = Convert.ToBoolean(e.Parameters[4]); upi.TrustLevel = Convert.ToInt32(e.Parameters[5]); upi.AdminWatch = Convert.ToBoolean(e.Parameters[6]); upi.AttachDisabled = Convert.ToBoolean(e.Parameters[7]); upc.Profiles_Save(upi); } } }
public int Subscription_Update(int PortalId, int ModuleId, int ForumId, int TopicId, int Mode, int UserId, string UserRoles = "") { if (UserId == -1) { return -1; } if (string.IsNullOrEmpty(UserRoles)) { UserController uc = new UserController(); User uu = uc.GetUser(PortalId, ModuleId, UserId); UserRoles = uu.UserRoles; } var fc = new ForumController(); Forum fi = fc.Forums_Get(PortalId, ModuleId, ForumId, UserId, true, false, -1); if (Permissions.HasPerm(fi.Security.Subscribe, UserRoles)) { return Convert.ToInt32(DataProvider.Instance().Subscription_Update(PortalId, ModuleId, ForumId, TopicId, Mode, UserId)); } return -1; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); btnSave.Click += new System.EventHandler(btnSave_Click); nsPrefPageSize.Style.Add("float", "none"); nsPrefPageSize.EmptyMessageStyle.CssClass += "dnnformHint"; nsPrefPageSize.NumberFormat.DecimalDigits = 0; nsPrefPageSize.IncrementSettings.Step = 5; if (Request.QueryString["UserId"] == null) { UID = UserInfo.UserID; } else { UID = Convert.ToInt32(Request.QueryString["UserId"]); } //If UID <> UserInfo.UserID And Not UserInfo.IsInRole(PortalSettings.AdministratorRoleName) Then //End If UserProfileInfo ui = null; if (ui == null & UID > 0) { UserController up = new UserController(); ui = up.GetUser(PortalId, ForumModuleId, UID).Profile; } if (ui != null) { drpPrefDefaultSort.SelectedIndex = drpPrefDefaultSort.Items.IndexOf(drpPrefDefaultSort.Items.FindByValue(ui.PrefDefaultSort.Trim())); nsPrefPageSize.Value = ui.PrefPageSize; chkPrefJumpToLastPost.Checked = ui.PrefJumpLastPost; chkPrefTopicSubscribe.Checked = ui.PrefTopicSubscribe; //chkPrefUseAjax.Checked = .PrefUseAjax chkPrefBlockAvatars.Checked = ui.PrefBlockAvatars; chkPrefBlockSignatures.Checked = ui.PrefBlockSignatures; txtSignature.Text = ui.Signature; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); btnSave.Click += new System.EventHandler(btnSave_Click); nsPrefPageSize.Style.Add("float", "none"); nsPrefPageSize.EmptyMessageStyle.CssClass += "dnnformHint"; nsPrefPageSize.NumberFormat.DecimalDigits = 0; nsPrefPageSize.IncrementSettings.Step = 5; if (Request.QueryString["UserId"] == null) { UID = UserInfo.UserID; } else { UID = Convert.ToInt32(Request.QueryString["UserId"]); } //If UID <> UserInfo.UserID And Not UserInfo.IsInRole(PortalSettings.AdministratorRoleName) Then //End If UserProfileInfo ui = null; if (ui == null & UID > 0) { UserController up = new UserController(); ui = up.GetUser(PortalId, ForumModuleId, UID).Profile; } if (ui != null && !Page.IsPostBack) { drpPrefDefaultSort.SelectedIndex = drpPrefDefaultSort.Items.IndexOf(drpPrefDefaultSort.Items.FindByValue(ui.PrefDefaultSort.Trim())); nsPrefPageSize.Value = ui.PrefPageSize; chkPrefJumpToLastPost.Checked = ui.PrefJumpLastPost; chkPrefTopicSubscribe.Checked = ui.PrefTopicSubscribe; //chkPrefUseAjax.Checked = .PrefUseAjax chkPrefBlockAvatars.Checked = ui.PrefBlockAvatars; chkPrefBlockSignatures.Checked = ui.PrefBlockSignatures; txtSignature.Text = ui.Signature; } }
public int Subscription_Update(int PortalId, int ModuleId, int ForumId, int TopicId, int Mode, int UserId, string UserRoles = "") { if (UserId == -1) { return(-1); } if (string.IsNullOrEmpty(UserRoles)) { UserController uc = new UserController(); User uu = uc.GetUser(PortalId, ModuleId, UserId); UserRoles = uu.UserRoles; } var fc = new ForumController(); Forum fi = fc.Forums_Get(PortalId, ModuleId, ForumId, UserId, true, false, -1); if (Permissions.HasPerm(fi.Security.Subscribe, UserRoles)) { return(Convert.ToInt32(DataProvider.Instance().Subscription_Update(PortalId, ModuleId, ForumId, TopicId, Mode, UserId))); } return(-1); }
private void btnSave_Click(object sender, System.EventArgs e) { if (UserId == UID || (CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.SuperUser)) { UserProfileController upc = new UserProfileController(); UserController uc = new UserController(); UserProfileInfo upi = uc.GetUser(PortalId, ForumModuleId, UID).Profile; if (upi != null) { upi.PrefDefaultSort = Utilities.XSSFilter(drpPrefDefaultSort.SelectedItem.Value, true); upi.PrefPageSize = Convert.ToInt32(((Convert.ToInt32(nsPrefPageSize.Text) < 5) ? 5 : Convert.ToInt32(nsPrefPageSize.Text))); upi.PrefDefaultShowReplies = false; upi.PrefJumpLastPost = chkPrefJumpToLastPost.Checked; upi.PrefTopicSubscribe = chkPrefTopicSubscribe.Checked; upi.PrefSubscriptionType = SubscriptionTypes.Instant; upi.PrefUseAjax = false; upi.PrefBlockAvatars = chkPrefBlockAvatars.Checked; upi.PrefBlockSignatures = chkPrefBlockSignatures.Checked; if (MainSettings.AllowSignatures == 1 || MainSettings.AllowSignatures == 0) { upi.Signature = Utilities.XSSFilter(txtSignature.Text, true); upi.Signature = Utilities.StripHTMLTag(upi.Signature); upi.Signature = Utilities.HTMLEncode(upi.Signature); } else if (MainSettings.AllowSignatures == 2) { upi.Signature = Utilities.XSSFilter(txtSignature.Text, false); } upc.Profiles_Save(upi); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); UserProfileInfo ui = UserProfile; if (ui == null & UID > 0) { UserController up = new UserController(); ui = up.GetUser(PortalId, ForumModuleId, UID).Profile; } if (ui != null) { txtRewardPoints.Text = ui.RewardPoints.ToString(); txtUserCaption.Text = ui.UserCaption; chkDisableSignature.Checked = ui.SignatureDisabled; chkDisableAttachments.Checked = ui.AttachDisabled; chkDisableAvatar.Checked = ui.AvatarDisabled; chkMonitor.Checked = ui.AdminWatch; drpDefaultTrust.SelectedIndex = drpDefaultTrust.Items.IndexOf(drpDefaultTrust.Items.FindByValue(ui.TrustLevel.ToString())); txtRewardPoints.Attributes.Add("onkeypress", "return onlyNumbers(event);"); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); UserProfileInfo ui = UserProfile; if (ui == null & UID > 0) { UserController up = new UserController(); ui = up.GetUser(PortalId, ForumModuleId, UID).Profile; } if (ui != null) { txtRewardPoints.Text = ui.RewardPoints.ToString(); txtUserCaption.Text = ui.UserCaption; chkDisableSignature.Checked = ui.SignatureDisabled; chkDisableAttachments.Checked = ui.AttachDisabled; chkDisableAvatar.Checked = ui.AvatarDisabled; chkMonitor.Checked = ui.AdminWatch; drpDefaultTrust.SelectedIndex = drpDefaultTrust.Items.IndexOf(drpDefaultTrust.Items.FindByValue(ui.TrustLevel.ToString())); txtRewardPoints.Attributes.Add("onkeypress", "return onlyNumbers(event);"); } }
public HttpResponseMessage ToggleSecurity(ToggleSecurityDTO dto) { var db = new Data.Common(); var sb = new StringBuilder(); switch (dto.Action) { case "delete": { Permissions.RemoveObjectFromAll(dto.SecurityId, dto.SecurityType, dto.PermissionsId); return Request.CreateResponse(HttpStatusCode.OK); } case "addobject": { if (dto.SecurityType == 1) { var uc = new UserController(); var ui = uc.GetUser(PortalSettings.PortalId, dto.ModuleId, dto.SecurityId); dto.SecurityId = ui != null ? ui.UserId.ToString() : string.Empty; } else { if (dto.SecurityId.Contains(":")) dto.SecurityType = 2; } if (!(string.IsNullOrEmpty(dto.SecurityId))) { var permSet = db.GetPermSet(dto.PermissionsId, "View"); permSet = Permissions.AddPermToSet(dto.SecurityId, dto.SecurityType, permSet); db.SavePermSet(dto.PermissionsId, "View", permSet); } return Request.CreateResponse(HttpStatusCode.OK); } default: { var permSet = db.GetPermSet(dto.PermissionsId, dto.SecurityKey); if (dto.Action == "remove") permSet = Permissions.RemovePermFromSet(dto.SecurityId, dto.SecurityType, permSet); else permSet = Permissions.AddPermToSet(dto.SecurityId, dto.SecurityType, permSet); db.SavePermSet(dto.PermissionsId, dto.SecurityKey, permSet); return Request.CreateResponse(HttpStatusCode.OK, dto.Action + "|" + dto.ReturnId); } } }
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 = ps.TimeZoneOffset; 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.AuthorizedRoles)) { //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; }
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>"); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); //Put user code to initialize the page here try { byte[] bindata = null; bool canView = false; string sContentType = string.Empty; if (!Page.IsPostBack) { int AttachId = 0; int intPortalID = 0; int intModuleID = 0; if (Request.Params["AttachID"] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params["AttachID"])) { AttachId = Int32.Parse(Request.Params["AttachID"]); } else { AttachId = 0; } } else { AttachId = 0; } if (Request.Params["PortalID"] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params["PortalID"])) { intPortalID = Int32.Parse(Request.Params["PortalID"]); } else { intPortalID = 0; } } else { intPortalID = 0; } if (Request.Params["ModuleID"] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params["ModuleID"])) { intModuleID = Int32.Parse(Request.Params["ModuleID"]); } else { intModuleID = -1; } } else { intModuleID = -1; } IFileManager _fileManager = FileManager.Instance; IFileInfo _file = null; if (AttachId > 0) { DotNetNuke.Entities.Users.UserInfo ui = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(); //DotNetNuke.Modules.ActiveForums.Settings.LoadUser(objUserInfo.UserID, intPortalID, intModuleID) UserController uc = new UserController(); User u = uc.GetUser(intPortalID, intModuleID); Data.AttachController ac = new Data.AttachController(); AttachInfo ai = null; try { if (Request.UrlReferrer.AbsolutePath.Contains("HtmlEditorProviders") | (Request.UrlReferrer.AbsolutePath.Contains("afv") & Request.UrlReferrer.AbsolutePath.Contains("post"))) { ai = ac.Attach_Get(AttachId, -1, ui.UserID, false); } else { ai = ac.Attach_Get(AttachId, -1, ui.UserID, true); } } catch (Exception ex) { ai = ac.Attach_Get(AttachId, -1, ui.UserID, true); } if (ai == null) { ai = new AttachInfo(); _file = _fileManager.GetFile(AttachId); ai.AttachID = _file.FileId; ai.AllowDownload = true; ai.Filename = _file.FileName; ai.FileUrl = _file.PhysicalPath; ai.CanRead = "0;1;-3;-1;|||"; ai.ContentType = _file.ContentType; } if (ai != null & u != null) { Response.ContentType = ai.ContentType.ToString(); if (ai.FileData != null) { if (Permissions.HasAccess(ai.CanRead, u.UserRoles)) { bindata = (byte[])ai.FileData; Response.BinaryWrite(bindata); Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.HtmlEncode(ai.Filename.ToString())); } } else { if (Permissions.HasAccess(ai.CanRead, u.UserRoles)) { string fpath = string.Empty; string fName = string.Empty; if (string.IsNullOrEmpty(ai.FileUrl)) { fpath = Server.MapPath(PortalSettings.HomeDirectory + "activeforums_Attach/"); fpath += ai.Filename; fName = System.IO.Path.GetFileName(fpath); } else { _file = _fileManager.GetFile(ai.AttachID); fpath = _file.PhysicalPath; fName = _file.FileName; } if (System.IO.File.Exists(fpath)) { //Dim vpath As String //vpath = PortalSettings.HomeDirectory & "activeforums_Attach/" & Server.HtmlEncode(ai.Filename) FileStream fs = new FileStream(fpath, FileMode.Open, FileAccess.Read); long contentLength = 0; if (fs != null) { bindata = GetStreamAsByteArray(fs); fs.Close(); } string sExt = System.IO.Path.GetExtension(fName); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.HtmlEncode(fName)); Response.AddHeader("Content-Length", bindata.LongLength.ToString()); sContentType = ai.ContentType; switch (sExt.ToLowerInvariant()) { case ".png": sContentType = "image/png"; break; case ".jpg": case ".jpeg": sContentType = "image/jpeg"; break; case ".gif": sContentType = "image/gif"; break; case ".bmp": sContentType = "image/bmp"; break; } Response.ContentType = sContentType; Response.OutputStream.Write(bindata, 0, bindata.Length); Response.End(); } else { fpath = Server.MapPath(PortalSettings.HomeDirectory + "NTForums_Attach/"); fpath += ai.Filename; if (System.IO.File.Exists(fpath)) { string vpath = null; vpath = PortalSettings.HomeDirectory + "activeforums_Attach/" + Server.HtmlEncode(ai.Filename); Response.Redirect(Page.ResolveUrl(vpath)); } } } } } } } } catch (Exception ex) { } }
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); }
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>"); } }
private void cbPreview_Callback(object sender, CallBackEventArgs e) { switch (e.Parameters[0].ToLower()) { case "preview": var message = e.Parameters[1]; var topicTemplateID = ForumInfo.TopicTemplateId; message = Utilities.CleanString(PortalId, message, _allowHTML, _editorType, ForumInfo.UseFilter, ForumInfo.AllowScript, ForumModuleId, ImagePath, ForumInfo.AllowEmoticons); message = Utilities.ManageImagePath(message); var uc = new UserController(); var up = uc.GetUser(PortalId, ForumModuleId, UserId) ?? new User { UserId = -1, UserName = "******", Profile = {TopicCount = 0, ReplyCount = 0}, DateCreated = DateTime.Now }; message = TemplateUtils.PreviewTopic(topicTemplateID, PortalId, ForumModuleId, ForumTabId, ForumInfo, UserId, message, ImagePath, up, DateTime.Now, CurrentUserType, UserId, TimeZoneOffset); hidPreviewText.Value = message; break; } hidPreviewText.RenderControl(e.Output); }
public static string ParseProfileTemplate(string profileTemplate, int userId, int portalId, int moduleId, int currentUserId, int timeZoneOffset) { var uc = new UserController(); var up = uc.GetUser(portalId, moduleId, userId); return ParseProfileTemplate(profileTemplate, up, portalId, moduleId, string.Empty, CurrentUserTypes.Anon, false, false, false, string.Empty, currentUserId, timeZoneOffset); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); //Put user code to initialize the page here try { byte[] bindata = null; bool canView = false; string sContentType = string.Empty; if (!Page.IsPostBack) { int AttachId = 0; int intPortalID = 0; int intModuleID = 0; if (Request.Params["AttachID"] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params["AttachID"])) { AttachId = Int32.Parse(Request.Params["AttachID"]); } else { AttachId = 0; } } else { AttachId = 0; } if (Request.Params["PortalID"] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params["PortalID"])) { intPortalID = Int32.Parse(Request.Params["PortalID"]); } else { intPortalID = 0; } } else { intPortalID = 0; } if (Request.Params["ModuleID"] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params["ModuleID"])) { intModuleID = Int32.Parse(Request.Params["ModuleID"]); } else { intModuleID = -1; } } else { intModuleID = -1; } IFileManager _fileManager = FileManager.Instance; IFileInfo _file = null; if (AttachId > 0) { DotNetNuke.Entities.Users.UserInfo ui = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(); //DotNetNuke.Modules.ActiveForums.Settings.LoadUser(objUserInfo.UserID, intPortalID, intModuleID) UserController uc = new UserController(); User u = uc.GetUser(intPortalID, intModuleID); Data.AttachController ac = new Data.AttachController(); AttachInfo ai = null; try { if (Request.UrlReferrer.AbsolutePath.Contains("HtmlEditorProviders") | (Request.UrlReferrer.AbsolutePath.Contains("afv") & Request.UrlReferrer.AbsolutePath.Contains("post"))) { ai = ac.Attach_Get(AttachId, -1, ui.UserID, false); } else { ai = ac.Attach_Get(AttachId, -1, ui.UserID, true); } } catch (Exception ex) { ai = ac.Attach_Get(AttachId, -1, ui.UserID, true); } if (ai == null) { ai = new AttachInfo(); _file = _fileManager.GetFile(AttachId); ai.AttachID = _file.FileId; ai.AllowDownload = true; ai.Filename = _file.FileName; ai.FileUrl = _file.PhysicalPath; ai.CanRead = "0;1;-3;-1;|||"; ai.ContentType = _file.ContentType; } if (ai != null & u != null) { Response.ContentType = ai.ContentType.ToString(); if (ai.FileData != null) { if (Permissions.HasAccess(ai.CanRead, u.UserRoles)) { bindata = (byte[])ai.FileData; Response.BinaryWrite(bindata); Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.HtmlEncode(ai.Filename.ToString())); } } else { if (Permissions.HasAccess(ai.CanRead, u.UserRoles)) { string fpath = string.Empty; string fName = string.Empty; if (string.IsNullOrEmpty(ai.FileUrl)) { fpath = Server.MapPath(PortalSettings.HomeDirectory + "activeforums_Attach/"); fpath += ai.Filename; fName = System.IO.Path.GetFileName(fpath); } else { _file = _fileManager.GetFile(ai.AttachID); fpath = _file.PhysicalPath; fName = _file.FileName; } if (System.IO.File.Exists(fpath)) { //Dim vpath As String //vpath = PortalSettings.HomeDirectory & "activeforums_Attach/" & Server.HtmlEncode(ai.Filename) FileStream fs = new FileStream(fpath, FileMode.Open, FileAccess.Read); long contentLength = 0; if (fs != null) { bindata = GetStreamAsByteArray(fs); fs.Close(); } string sExt = System.IO.Path.GetExtension(fName); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.HtmlEncode(fName)); Response.AddHeader("Content-Length", bindata.LongLength.ToString()); sContentType = ai.ContentType; switch (sExt.ToLowerInvariant()) { case ".png": sContentType = "image/png"; break; case ".jpg": case ".jpeg": sContentType = "image/jpeg"; break; case ".gif": sContentType = "image/gif"; break; case ".bmp": sContentType = "image/bmp"; break; } Response.ContentType = sContentType; Response.OutputStream.Write(bindata, 0, bindata.Length); Response.End(); } else { fpath = Server.MapPath(PortalSettings.HomeDirectory + "NTForums_Attach/"); fpath += ai.Filename; if (System.IO.File.Exists(fpath)) { string vpath = null; vpath = PortalSettings.HomeDirectory + "activeforums_Attach/" + Server.HtmlEncode(ai.Filename); Response.Redirect(Page.ResolveUrl(vpath)); } } } } } } } } catch (Exception ex) { } }