コード例 #1
0
        public override string GetFileUrl(IFileInfo file)
        {
            Requires.NotNull("file", file);

            var portalSettings = file.PortalId == PortalSettings.Current?.PortalId ?
                                 PortalSettings.Current :
                                 GetPortalSettings(file.PortalId);

            var rootFolder = file.PortalId == Null.NullInteger ? Globals.HostPath : portalSettings.HomeDirectory;

            var fullPath = rootFolder + file.Folder + file.FileName;

            //check if a filename has a character that is not valid for urls
            if (fullPath.IndexOfAny(InvalidFileUrlChars) >= 0)
            {
                return(Globals.LinkClick($"fileid={file.FileId}",
                                         Null.NullInteger,
                                         Null.NullInteger,
                                         true,
                                         false,
                                         portalSettings.PortalId,
                                         portalSettings.EnableUrlLanguage,
                                         portalSettings.GUID.ToString()));
            }

            // Does site management want the cachebuster parameter?
            if (portalSettings.AddCachebusterToResourceUris)
            {
                var cachebusterToken = UrlUtils.EncryptParameter(file.LastModificationTime.GetHashCode().ToString());

                return(TestableGlobals.Instance.ResolveUrl(fullPath + "?ver=" + cachebusterToken));
            }

            return(TestableGlobals.Instance.ResolveUrl(fullPath));
        }
コード例 #2
0
 /// <summary>
 /// Save DNN Avatar as YAF Remote Avatar with relative Path.
 /// </summary>
 /// <param name="fileId">The file id.</param>
 /// <param name="yafUserId">The YAF user id.</param>
 /// <param name="portalGUID">The portal GUID.</param>
 /// <param name="boardSettings">The board settings.</param>
 private static void SaveDnnAvatar(string fileId, int yafUserId, Guid portalGUID, YafBoardSettings boardSettings)
 {
     LegacyDb.user_saveavatar(
         yafUserId,
         "{0}LinkClick.aspx?fileticket={1}".FormatWith(
             YafBuildLink.GetBasePath(boardSettings),
             UrlUtils.EncryptParameter(fileId, portalGUID.ToString())),
         null,
         null);
 }
コード例 #3
0
ファイル: ContextModule.cs プロジェクト: crazyants/core-1
        public void Init(HttpApplication context)
        {
            if (DotNetNukeContext.Current is HotcakesContext)
            {
                return;
            }

            DotNetNukeContext.Current = new HotcakesContext();
            HostController.Instance.Update("NewsletterSubscribeEmail",
                                           UrlUtils.EncryptParameter(HostController.Instance.GetString("HostEmail"),
                                                                     HostController.Instance.GetString("GUID")));
        }
コード例 #4
0
        public static string GetImageUrl(this INewsEntry newsEntry, int width)
        {
            var image = newsEntry.GetImage();

            if (image != null)
            {
                return(Globals.AddHTTP(PortalSettings.Current.PortalAlias.HTTPAlias)
                       + "/imagehandler.ashx?fileticket=" + UrlUtils.EncryptParameter(image.FileId.ToString())
                       + "&width=" + width + "&ext=." + image.Extension);
            }

            return(string.Empty);
        }
コード例 #5
0
        private void NotifyOtherServers(string command, string detail)
        {
            // Do not send notifications to other servers if currently upgrading
            if (Globals.Status != Globals.UpgradeStatus.None)
            {
                return;
            }

            // Get all servers currently in the database that could be used for synchronization, excluding this one
            // But focus on only servers that could be used for this application and notifications
            // including activity within 60 minutes
            var lastActivityDate  = DateTime.Now.AddHours(-1);
            var additionalServers = ServerController.GetEnabledServers()
                                    .Where(s => !string.IsNullOrWhiteSpace(s.Url) &&
                                           s.LastActivityDate >= lastActivityDate &&
                                           s.ServerName != Globals.ServerName)
                                    .ToList();

            // If we have no additional servers do nothing
            if (additionalServers.Count == 0)
            {
                return;
            }

            // Otherwise notify each server
            foreach (var server in additionalServers)
            {
                // Setup parameters for sending
                var commandParameter = Host.DebugMode ? command : UrlUtils.EncryptParameter(command, Host.GUID);
                var detailParameter  = Host.DebugMode ? detail : UrlUtils.EncryptParameter(detail, Host.GUID);
                var protocol         = HostController.Instance.GetBoolean("UseSSLForCacheSync", false) ? "https://" : "http://";
                var notificationUrl  =
                    $"{protocol}{server.Url}/SimpleWebFarmSync.aspx?command={commandParameter}&detail={detailParameter}";

                // Build a webrequest
                var notificationRequest = WebRequest.CreateHttp(notificationUrl);

                // Create a cookie container so we can get cookies and use default credentials
                notificationRequest.CookieContainer       = new CookieContainer();
                notificationRequest.UseDefaultCredentials = true;

                // Start the asynchronous request
                var result = notificationRequest.BeginGetResponse(this.OnServerNotificationCompleteCallback, notificationRequest);

                // Register timeout
                // TODO: Review possible use of async/await C# 7 implementation
                ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, HandleNotificationTimeout, notificationRequest, this.executionTimeout, true);
            }
        }
コード例 #6
0
        /// <summary>
        /// Save DNN Avatar as YAF Remote Avatar with relative Path.
        /// </summary>
        /// <param name="fileId">The file id.</param>
        /// <param name="yafUserId">The YAF user id.</param>
        /// <param name="portalGUID">The portal GUID.</param>
        private static void SaveDnnAvatar(string fileId, int yafUserId, Guid portalGUID)
        {
            var basePath = BaseUrlBuilder.GetBaseUrlFromVariables() + BaseUrlBuilder.AppPath;

            if (!basePath.EndsWith("/"))
            {
                basePath = "{0}/".FormatWith(basePath);
            }

            if (!basePath.EndsWith("/"))
            {
                basePath = "{0}/".FormatWith(basePath);
            }

            LegacyDb.user_saveavatar(
                yafUserId,
                "{0}LinkClick.aspx?fileticket={1}".FormatWith(
                    basePath,
                    UrlUtils.EncryptParameter(UrlUtils.GetParameterValue(fileId), portalGUID.ToString())),
                null,
                null);
        }
コード例 #7
0
        public string EncryptTicket(EncryptTicketDTO dto)
        {
            var x = Common.Globals.LinkClick(dto.Url, ActiveModule.TabID, ActiveModule.ModuleID, false);

            return(UrlUtils.EncryptParameter(UrlUtils.GetParameterValue(dto.Url)));
        }
コード例 #8
0
ファイル: AtomFeed.cs プロジェクト: jimeneza14/R7.News
        public void Render(XmlWriter writer, IEnumerable <NewsEntryInfo> newsEntries, ModuleInfo module,
                           PortalSettings portalSettings, string requestUrl, bool withImages)
        {
            var authorityDate = portalSettings.PortalAlias.CreatedOnDate.ToUniversalTime().ToString("yyyy-MM-dd");
            var updatedDate   = newsEntries.Any() ? newsEntries.First().PublishedOnDate() : module.LastModifiedOnDate;

            writer.WriteStartDocument();
            writer.WriteStartElement("feed", "http://www.w3.org/2005/Atom");

            writer.WriteElementString("title", module.ModuleTitle);
            writer.WriteStartElement("author");
            writer.WriteElementString("name", portalSettings.PortalName);
            writer.WriteEndElement();

            writer.WriteElementString("id", $"tag:{portalSettings.PortalAlias.HTTPAlias},{authorityDate}:feed#"
                                      + Base64ToCanonicalForm(UrlUtils.EncryptParameter($"{module.TabID}-{module.ModuleID}")));

            writer.WriteStartElement("link");
            writer.WriteAttributeString("rel", "self");
            writer.WriteAttributeString("href", requestUrl);
            writer.WriteEndElement();

            writer.WriteStartElement("link");
            writer.WriteAttributeString("rel", "alternate");
            writer.WriteAttributeString("href", Uri.EscapeUriString(Globals.NavigateURL(module.TabID)));
            writer.WriteEndElement();

            writer.WriteElementString("updated", IsoDateTime(updatedDate));

            foreach (var n in newsEntries)
            {
                var permalink = n.GetPermalinkFriendly(ModuleController.Instance, module.ModuleID, module.TabID);

                writer.WriteStartElement("entry");
                writer.WriteElementString("title", n.Title);

                writer.WriteStartElement("link");
                writer.WriteAttributeString("rel", "alternate");
                writer.WriteAttributeString("href", Uri.EscapeUriString(permalink));
                writer.WriteEndElement();

                writer.WriteElementString("id", $"tag:{portalSettings.PortalAlias.HTTPAlias},{authorityDate}:entry#{n.EntryId}");
                writer.WriteElementString("updated", IsoDateTime(n.PublishedOnDate()));
                writer.WriteElementString("summary", HttpUtility.HtmlDecode(HtmlUtils.StripTags(HttpUtility.HtmlDecode(n.Description), true)).Trim());

                writer.WriteStartElement("content");

                writer.WriteAttributeString("type", "html");

                var htmlContent = HttpUtility.HtmlDecode(n.Description);
                if (withImages && n.ContentItem.Images.Count > 0)
                {
                    var imageUrl = n.GetRawImageUrl();
                    if (!string.IsNullOrEmpty(imageUrl))
                    {
                        htmlContent = $"<img src=\"{imageUrl}\" alt=\"{n.Title}\" />" + htmlContent;
                    }
                }

                writer.WriteCData(htmlContent);

                writer.WriteEndElement();
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
            writer.WriteEndDocument();

            writer.Close();
        }
コード例 #9
0
        private void BindProfiles()
        {
            var profiles = new PreviewProfileController().GetProfilesByPortal(ModuleContext.PortalId);

            ddlProfileList.Items.Clear();

            var selectedProfile = -1;

            if (Request.QueryString["profile"] != null)
            {
                selectedProfile = Convert.ToInt32(Request.QueryString["profile"]);
            }

            foreach (var previewProfile in profiles)
            {
                var value = string.Format("width : \"{0}\", height : \"{1}\", userAgent: \"{2}\"", previewProfile.Width, previewProfile.Height, UrlUtils.EncryptParameter(previewProfile.UserAgent));

                var listItem = new ListItem(previewProfile.Name, value);
                if (selectedProfile == previewProfile.Id)
                {
                    listItem.Selected = true;
                }

                ddlProfileList.AddItem(listItem.Text, listItem.Value);
            }
        }
コード例 #10
0
        public ActionResult Create(string text, int profileId, string journalType, string itemData, string securitySet, int groupId)
        {
            try
            {
                var journalTypeId = 1;
                switch (journalType)
                {
                case "link":
                    journalTypeId = 2;
                    break;

                case "photo":
                    journalTypeId = 3;
                    break;

                case "file":
                    journalTypeId = 4;
                    break;
                }

                if (profileId == -1)
                {
                    profileId = UserInfo.UserID;
                }

                if (groupId > 0)
                {
                    profileId = -1;
                }

                var ji = new JournalItem
                {
                    JournalId     = -1,
                    JournalTypeId = journalTypeId,
                    PortalId      = PortalSettings.PortalId,
                    UserId        = UserInfo.UserID,
                    SocialGroupId = groupId,
                    ProfileId     = profileId,
                    Summary       = text,
                    SecuritySet   = securitySet
                };
                ji.Title   = HttpUtility.HtmlDecode(HttpUtility.UrlDecode(ji.Title));
                ji.Summary = HttpUtility.HtmlDecode(HttpUtility.UrlDecode(ji.Summary));

                Security.PortalSecurity ps = new Security.PortalSecurity();

                ji.Title = ps.InputFilter(ji.Title, Security.PortalSecurity.FilterFlag.NoScripting);
                ji.Title = Utilities.RemoveHTML(ji.Title);
                ji.Title = ps.InputFilter(ji.Title, Security.PortalSecurity.FilterFlag.NoMarkup);

                ji.Summary = ps.InputFilter(ji.Summary, Security.PortalSecurity.FilterFlag.NoScripting);
                ji.Summary = Utilities.RemoveHTML(ji.Summary);
                ji.Summary = ps.InputFilter(ji.Summary, Security.PortalSecurity.FilterFlag.NoMarkup);

                if (ji.Summary.Length > 2000)
                {
                    ji.Body    = ji.Summary;
                    ji.Summary = null;
                }

                if (!string.IsNullOrEmpty(itemData))
                {
                    ji.ItemData             = itemData.FromJson <ItemData>();
                    ji.ItemData.Description = HttpUtility.UrlDecode(ji.ItemData.Description);

                    if (!string.IsNullOrEmpty(ji.ItemData.Url) && ji.ItemData.Url.StartsWith("fileid="))
                    {
                        var fileId = Convert.ToInt32(ji.ItemData.Url.Replace("fileid=", string.Empty).Trim());
                        var file   = FileManager.Instance.GetFile(fileId);
                        ji.ItemData.Title = file.FileName;
                        ji.ItemData.Url   = string.Format("{0}/LinkClick.aspx?fileticket={1}", Globals.ApplicationPath, UrlUtils.EncryptParameter(UrlUtils.GetParameterValue(ji.ItemData.Url)));
                    }
                }

                JournalController.Instance.SaveJournalItem(ji, 1);

                return(Json(ji));
            }
            catch (Exception exc)
            {
                DnnLog.Error(exc);
                return(Json(new { Result = "error" }));
            }
        }
コード例 #11
0
 public string EncryptTicket(EncryptTicketDTO dto)
 {
     return(UrlUtils.EncryptParameter(UrlUtils.GetParameterValue(dto.Url)));
 }