Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Scripting.FileSystemObject filename prob
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Scripting.FileSystemObject filename prob

 Post Reply Post Reply Page  12>
Author
Nathan View Drop Down
Groupie
Groupie


Joined: 08 January 2002
Location: Greece
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote Nathan Quote  Post ReplyReply Direct Link To This Post Topic: Scripting.FileSystemObject filename prob
    Posted: 16 May 2004 at 6:11am

I am using

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

to write asp files to my server (exporting posts from my Forum)

The code works fine, but if the strsubject (which is used for the file name) is for example: 'Walking on Corfu' instead of saving the file as: walking on corfu.asp

it changes it to:

walking &#111n corfu.asp

(whenever the file name contains the letters 'on', then they are replaced with &#111n )

How can I stop this happening?

Thanks for any help you can offer.

 

Nathan

Sample code as follows:

 

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

path = server.MapPath("posts/"& strsubject &".asp")
'illegal chars are then stripped out of the path file name
Set objTextStream = objFSO.OpenTextFile(path, fsoForWriting, True)

objTextStream.WriteLine "<html>"
objTextStream.WriteLine "<head>"

etc etc etc

objTextStream.Close

 

 

Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2004 at 6:45am
because on can be used to post malicious code, so WWF replaces on with &#111;n

I'm not sure what file the functon is in but it is in one of the files in the functions folder
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2004 at 7:01am
He's not talking about WWF It's a custom script...
Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2004 at 7:44am
yeah, but I think he saves the topics to files and then he uses the same page as WWF uses to save to the database
Back to Top
Nathan View Drop Down
Groupie
Groupie


Joined: 08 January 2002
Location: Greece
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote Nathan Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2004 at 10:18am

Thanks very much for your help so far.

Correct this is a custom script, but I have written a short bit of code to access the Forum SQL database in order to extract the Thread Subject title. For example:

 'Get the threads from the database
 'Create a record set object to the Threads held in the database
 Set rsThread = Server.CreateObject("ADODB.Recordset")

 'Initalise the strSQL variable with an SQL statement to query the database get the thread details

 strSQL = "EXECUTE wwfSpThreadDetails @lngTopicID = " & lngTopicID


 'Set the cursor type property of the record set to dynamic so we can naviagate through the record set
 rsThread.CursorType = 1

 'Query the database
 rsThread.Open strSQL, strCon 
  'Read in the thread subject forum ID and where the topic is locked
  strSubject = rsThread("Subject")
 
 
This strSubject string is then being used as the file name.

Nathan

 

Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2004 at 12:09pm
you have to do a reverse replace of the words that are beiing replaced before inserted into the database
Back to Top
Nathan View Drop Down
Groupie
Groupie


Joined: 08 January 2002
Location: Greece
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote Nathan Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2004 at 2:27pm

Fantasic. That's cured it - thanks very much.

Incidentally, you maybe interested in seeing the finished (badly written) code. Basically, it will export all of my forum threads to asp files, but with correct TITLE and META tags. The idea for this, is that I use the site search script (from Bruce), and now my site users can search my site pages and my forum threads at the same time - as they have been exported!  Works a treat and my users (and hopeful Google) love it!

www.agni.gr

thanks again for your help. Beers are on me if you happen to pop by.

Nathan

<!--#include file="common.asp" -->
<!--#include file="date_time_functions.inc" -->
<!--#include file="langauge_file.inc" -->
<!--#include file="forum_permissions.inc" -->

 


<%

 


Response.Buffer = True

'Dimension variables
Dim rsForum    'Holds the Database Recordset Variable for the topic details
Dim rsThread   'Holds the database recordset variable for the thread
Dim intForumID   'Holds the forum ID number
Dim strForumName  'Holds the forum name
'Dim lngTopicID   'Holds the topic number
Dim strSubject   'Holds the topic subject
Dim strUsername   'Holds the Username of the thread
Dim lngUserID   'Holds the ID number of the user
Dim dtmTopicDate  'Holds the date the thread was made
Dim strMessage   'Holds the message body of the thread
Dim lngMessageID  'Holds the message ID number
Dim strAuthorHomepage  'Holds the homepage of the Username if it is given
Dim strAuthorLocation  'Holds the location of the user if given
Dim strAuthorAvatar  'Holds the authors avatar 
Dim strAuthorSignature  'Holds the authors signature
Dim lngAuthorNumOfPosts  'Holds the number of posts the user has made to the forum
Dim dtmAuthorRegistration 'Holds the registration date of the user
Dim lngNumberOfViews  'Holds the number of times the topic has been viewed to save back to the database
Dim intStatus   'Holds the users interger status
Dim strStatus   'Holds the users status
Dim strMode   'Holds the mode of the page that is being passed
Dim intTopicPageNumber  'Holds the topic page position to link back to
Dim blnNoThread   'Set to true if there is no thread to view
Dim blnIsModerator  'Set to true if the user who posted the message is a forum moderator
Dim blnForumLocked  'Set to true if the forum is locked
Dim blnTopicLocked  'set to true if the topic is locked
Dim intThreadNo   'Holds the number of threads in the topic
Dim intPriority   'Holds the priority level of the topic
Dim strPostPage   'Holds the page the form is posted to
Dim intRecordPositionPageNum 'Holds the recorset page number to show the Threads for
Dim intTotalNumOfPages  'Holds the number of pages
Dim intRecordLoopCounter 'Holds the loop counter numeber
Dim intThreadPageLoopCounter 'Loop counter for other thread page link
Dim intTotalNumOfThreads 'Holds the total number of therads in this topic
Dim strAuthorIP   'Holds the authors IP
Dim strSearchKeywords  'Holds the keywords to search for
Dim sarySearchWord  'Array to hold the search words
Dim intHighlightLoopCounter 'Loop counter to loop through words and hightlight them


Dim poststext


 Const fsoForWriting = 2
 
 
dim path


 dim body, head
 dim textformat

 Dim title

 

for lngTopicID = 2000 to 2121

 'Get the threads from the database
 'Create a record set object to the Threads held in the database
 Set rsThread = Server.CreateObject("ADODB.Recordset")

 'Initalise the strSQL variable with an SQL statement to query the database get the thread details

 strSQL = "EXECUTE wwfSpThreadDetails @lngTopicID = " & lngTopicID


 'Set the cursor type property of the record set to dynamic so we can naviagate through the record set
 rsThread.CursorType = 1

 'Query the database
 rsThread.Open strSQL, strCon


 'If there is no topic in the database then display the appropraite mesasage
 If rsThread.EOF Then
 
  'If there are no thread's to display then display the appropriate error message
  strSubject = strTxtNoThreads


 'Else there are records returned by the database
 Else


  'Read in the thread subject forum ID and where the topic is locked
  strSubject = rsThread("Subject")
 
 
 End If

 

 

if not strSubject = strTxtNoThreads then
 
 Response.Write strSubject
 Response.Write "<BR>"

 Dim objFSO
 
 Dim objTextStream
 
 Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
 strsubject = Replace(strsubject, "?", " ", 1, -1, 1)
 strsubject = Replace(strsubject, ",", " ", 1, -1, 1)
 strsubject = Replace(strsubject, "\", " ", 1, -1, 1)
 strsubject = Replace(strsubject, "/", " ", 1, -1, 1)
 strsubject = Replace(strsubject, "'", " ", 1, -1, 1)
 strsubject = Replace(strsubject, ":", " ", 1, -1, 1)

 strsubject = Replace(strsubject, "&#111;", "o", 1, -1, 1)
 strsubject = Replace(strsubject, "&#146;", "", 1, -1, 1)
 strsubject = Replace(strsubject, "&#079;", "o", 1, -1, 1)

 path = server.MapPath("posts/"& strsubject &" - Corfu Post.asp")
 path = Replace(path, " ", "_", 1, -1, 1)
 
 Response.Write lngTopicID & " "
 Response.Write path
 Response.Write "<BR>"
 Response.Write "<BR>"

 Set objTextStream = objFSO.OpenTextFile(path, fsoForWriting, True)

 head = "<" & "%" & "Option Explicit" &  "%" & ">"

 

 title = strSubject & " Corfu Travel Guide Discussion Forum"
 title = Replace(title, " ", ",", 1, -1, 1)


 body="<!--#include virtual=" & "/message_boards/display_topic_threads2.asp" & " -->"
 


 'Display the contents of the text file
 objTextStream.WriteLine head
 objTextStream.WriteLine "<" & "%"
 objTextStream.WriteLine

 

 objTextStream.WriteLine "Dim lngTopicID"
 objTextStream.WriteLine "lngTopicID = " & lngTopicID

 objTextStream.WriteLine "%" & ">"

 objTextStream.WriteLine
 objTextStream.WriteLine "<html>"
 objTextStream.WriteLine "<head>"

 objTextStream.WriteLine "<title>" & strSubject & " - Corfu Travel Guide Discussion Forum </title>"
 objTextStream.WriteLine "<meta name=""keywords"" content=""" & title & """>"
 objTextStream.WriteLine "<meta name=""description"" content=""Corfu Forum Post - " & strSubject & """>"

 

 objTextStream.WriteLine "<meta http-equiv=""Cache-Control"" content=""no-cache"">"
 objTextStream.WriteLine "<meta name=""generator"" content=""Taverna Agni and Agni Travel - Corfu"">"
 objTextStream.WriteLine "<meta name=""revisit-after"" content=""3

Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post Posted: 20 May 2004 at 6:36am

sory, I don't drink beer!

 

I didn't read through the code either.. too much

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.