You need to Register for free and Login to post a message in the forum.

Forum

Subject: Decode DesktopHtml
Prev Next
You are not authorized to post a reply.

Author Messages
tjthay
DNN Creative Magazine Subscriber
Nuke Newbie
Nuke Newbie
Posts:8

16 Jan 2008 11:55 AM  
Let me preface this post with the fact that I know very little about ASP programming so please go easy on me.

I have a Text/HTML module for an announcment section in a newsletter that we send via a third party.  I am having trouble converting the encoded text which is stored in the HtmlText database.    We have set up a Text/HTML module for the clients to enter their announcement text in - as I understand it the content from the module is converted (encoded) upon insertion into the HtmlText database for security reasons thereby converting the brackets, quotes etc. into different characters.  As a result when I pull the data from db the text displays as the code.  The following test content displays as follows (the actual code instead of html):

This is a test announcement.


This is a test link.


 



which displays literally as:

This is a test announcement.

This is a test link.

 




I found a  function to convert the code back (decode) but it is not working.  Here is the code that I am attempting to use:

                <%
                DIM sql2
                sql2 =     "SELECT DesktopHtml FROM HtmlText WHERE ModuleID = 'x'"

                DIM objRS2
                Set objRS2 = Server.CreateObject("ADODB.Recordset")
                objRS2.Open sql2, objConn
                %>
               
                <%
                Dim sText
                Set sText= objRS2("DesktopHTML")
                %>
               
                <%
                Function HTMLDecode(sText)
                    Dim I
                    sText = Replace(sText, """, Chr(34))
                    sText = Replace(sText, "<"  , Chr(60))
                    sText = Replace(sText, ">"  , Chr(62))
                    sText = Replace(sText, "&" , Chr(38))
                    sText = Replace(sText, " ", Chr(32))
                    For I = 1 to 255
                        sText = Replace(sText, "&#" & I & ";", Chr(I))
                    Next
                    HTMLDecode = sText
                End Function
                %>
               
                <% Response.Write(sText) %>


Any assistance with this issue is greatly appreciated.

Travis


leesykes
DNN Creative Staff
Nuke Master III
Nuke Master III
Posts:3304

17 Jan 2008 8:52 AM  
I can't really help with the code for transforming the encoded characters into HTML, but if you wish to look at the characters a quick search in Google under "HTML characters" will bring up quite a few results, this is one of the sites:
http://www.natural-innovations.com/wa/doc-charset.html

Is it essential that you pull the data directly from the database?  You could just copy and paste the HTML code directly from the module.

there may be code within DotNetNuke that you could reuse to transform the characters, I am guessing you would need to look at the code related to the text HTML module and the text editor.

Does anyone else have any ideas?

Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/leesykes

Lee Sykes's Facebook Profile
tjthay
DNN Creative Magazine Subscriber
Nuke Newbie
Nuke Newbie
Posts:8

17 Jan 2008 11:36 AM  
Lee,

Thanks.  I want to try and pull directly from the database since we are pulling content from multiple sources to create a newsletter.  In this way my clients can manage their own aspect of the newsletter and it will be dynamically generated on my end.

My research has shown that the Text/HTML module inputs the data into the db by encoding (I think through a Stored Procedure - but my knowledge of SQL is less than that of ASP) thereby converting certain characters like <, > and ". 

I can easily pull the data back out but not sure why the replace function I am using is not working.  Hopefully just missing something simple in the code.   Probably could use the appropriate Stored Proc to decode although not sure how to implement that - it has to be something that the Text/HTML module is doing itself in order to display the code correctly but I wouldn't even know where to start to see how that module works.  Maybe someone could point me in the right direction there.

Any help is appreciated. 

Travis


jncraig
DNN Creative Staff
Nuke Master II
Nuke Master II
Posts:2318


17 Jan 2008 11:55 AM  
I took a quick look at some of the stored text for a couple of text/html modules. I don't think that the storage is for security purposes, but there are some characters that are replaced:

< <
> >
& &

If you change those, you'll probably get 95% or more of the changes that you need and the text will render correctly as html.

As for your substitutions, the Replace function is: Replace(Expression, WhatToReplace, ReplaceWithWhat)

So, I'd do things like: sText = Replace(sText, "<", "<")

Joe Craig
DNN Creative Support
Subscribe to the website
tjthay
DNN Creative Magazine Subscriber
Nuke Newbie
Nuke Newbie
Posts:8

17 Jan 2008 12:11 PM  
Okay I think I got it.  I was trying to implement a Function I found searching on Google.  Removing the Function Name and end and just going with a plain replace seems to work.  This is the code I am using now:

                // Pulls String from DB and sets to sText //
                <%
                Dim sText
                Set sText= objRS2("DesktopHTML")
                %>
               
                // Replaces the characters //
                  <%
                    Function HTMLDecode(sText) // Removed this line //
                    Dim I
                    sText = Replace(sText, """, Chr(34))
                    sText = Replace(sText, "<"  , Chr(60))
                    sText = Replace(sText, ">"  , Chr(62))
                    sText = Replace(sText, "&" , Chr(38))
                    sText = Replace(sText, " ", Chr(32))
                    For I = 1 to 255
                        sText = Replace(sText, "&#" & I & ";", Chr(I))
                    Next
                   End Function // Removed this line //
                %>
               
                // Writes the converted data to the page //
                <% Response.Write(sText) %>

Thanks to all for the ideas. 

Travis


jncraig
DNN Creative Staff
Nuke Master II
Nuke Master II
Posts:2318


17 Jan 2008 12:13 PM  
Oh, right! You defined the function, but you never called it. So much for quickly reading code...

Joe Craig
DNN Creative Support
Subscribe to the website
tjthay
DNN Creative Magazine Subscriber
Nuke Newbie
Nuke Newbie
Posts:8

17 Jan 2008 12:15 PM  
Sorry, just noticed that the post is replacing the values with the html version which makes the posts look funny. Looks like I'm trying to replace a < with a <. Not sure how to post without the system converting.

Travis
tjthay
DNN Creative Magazine Subscriber
Nuke Newbie
Nuke Newbie
Posts:8

17 Jan 2008 12:25 PM  
Joe,

Thanks. So just to complete the circle - you could leave the Function code in and use something like the following to display the converted text:

<% Response.Write(HTMLDecode(objRS2("DesktopHTML"))) %>

Thanks again for the help.

Travis

jncraig
DNN Creative Staff
Nuke Master II
Nuke Master II
Posts:2318


17 Jan 2008 12:29 PM  
Yep! This would be useful if you plan to use the decode function in other places.

Joe Craig
DNN Creative Support
Subscribe to the website
You are not authorized to post a reply.
Forums > Users Lounge > Everything Else > Decode DesktopHtml



ActiveForums 3.7

Latest Forum Posts

RE: EasyCGI help? by Dr Joe
I'll let you know how it works out. I think I opened up about 6 tickets with them so far. ...
RE: EasyCGI help? by derpir
Hi Joe amazing to say the least! I will change host to PowerDNN as soon as possible, seems to me t...
RE: EasyCGI help? by Dr Joe
Amazing - I'm going through this exact same thing with EasyCGI! I managed to successfully instal...
Running the local host installation after building the application by saintX
My localhost installation of DNN was running blameless. After I oppened the application with VWD it ...
RE: quick question by derpir
Hello Is it possible to buy two skins and combine them? for example put one skins visual attributes...
RE: Environment Variables by leesykes
Thanks for the info,
RE: How can i edit any module from front end by sanju_k1421
ok if i added an text html . now i want to fill into that have to log in ,but i want that an...
Module not working when logged off. by t.ramya85
Hi friends,I have created two modules which interact with each other and i have kept one module to b...
RE: Environment Variables by fandnet
There are many ways to use variables like what I was trying to use...But here is how I did it.DotNet...
RE: OpenForce '08 by mgordon
It was truly a great time.  I really feel this year was much better than last year.  I hope to ge th...
Environment Variables by fandnet
I am creating a simple module that registered users can use to send an email invitation to people wh...
RE: How can i edit any module from front end by leesykes
I'm not sure that I follow, could you provide an example?
RE: Development of modules by leesykes
Hello,Glad you find them useful, at the moment there are not any plans to go into Module Development...
RE: SQL Server 2008 Documents Module DotNetNuke by leesykes
Hello,Thanks for the tip. Yes both connection strings are in correctly and the user has full permiss...
RE: Now, portal creation problem by jncraig
Since you have other issues with installing modules, etc. I believe that you are correct that it's a...
RE: How do I display the current time by jncraig
The [CURRENTDATE] skin object has a DateFormat attribute. The examples give MMMM dd, yyyy as a typi...
RE: Now, portal creation problem by SupaHoopsa
Posted By jncraig on 18 Nov 2008 8:54 AMIf there are other errors related to the database, I would s...
RE: SQL Server 2008 Documents Module DotNetNuke by MobileNow
Make sure that both of the connection strings are the same in the web.config file. Also make sure t...
RE: Now, portal creation problem by jncraig
If there are other errors related to the database, I would start by looking there.  This could be so...
Un-installing SQL Server 2005 by leesykes
I'm in the process of un-installing SQL Server 2005 and while doing this it informs me that Full Tex...
DotNetNuke Modules
RSS Feeds