Baleric 03-01-2006, 09:23 AM how would i make a site map in asp?
i have a pages folder, so should i just list all files in the directory?
is there a way i can only list certain files, like files with the extension .asp
or .html because i dont want to list my DB files and other admin pages or anything like that.
thanks in advance
-baleric
GoComplain 03-01-2006, 10:44 AM That would be kinda cool...
1. Us the FS to read everything on the server *.asp
2. Us the OpenText to read the title, keywords, and description
3. Have an admin page to update the sitemap.asp (you wouldn't want to do this each time the page loads, if you have a big site)
4. Place each file in a database
5. Everytime the sitemap.asp page is called create a tree with Title, url, and description
6. create a search for title, keywords, and description
It would take a little work, but that sounds like my next project.
Good idea
glenngv 03-01-2006, 10:59 AM This may be off-topic but your .mdb file should not be accessible in the browser. Otherwise, if someone was able to guess the filename of your db, he/she can download it. You should put the db file outside of your web root folder, the most recommended location is just above your web root folder.
db
|__data.mdb
wwwroot
|__*.asp
Then in the connection string in asp, you specify the path like this:
Server.MapPath("../db/data.mdb")
Baleric 03-01-2006, 09:09 PM gocomplain, im gunna give it a go, but if you end up getting it working can u paste the code so its available please,
glenngv, thanks for the advice, ill start to place the DB outside the pages folder :)
thanks guys.
-baleric
Baleric 03-01-2006, 09:19 PM <%
dim fs,fo,x
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder("d:/newsite/pages/")
for each x in fo.files
'Print the name of all files in the test folder
Response.write("<a href='" & x.Name & "' target='_new'>" & x.Name & "</a>" & "<br />" )
next
set fo=nothing
set fs=nothing
%>
here is the code i managed to find, now how do i make it list only *.asp files?
MetalStorm 03-01-2006, 11:36 PM Check that x.Name ends with .asp - try right().
Baleric 03-02-2006, 02:56 AM does anyone know how to do this?
glenngv 03-02-2006, 08:31 AM http://www.devguru.com/technologies/vbscript/13960.asp
Baleric 03-02-2006, 08:44 AM i still dont understand, right() makes it read the code from right to left,
but how does this help me? im trying to list all .asp files
Baleric 03-02-2006, 08:56 AM its alright i got it...
Baleric 03-02-2006, 09:10 AM Heres the code if anyone is interested<%
Dim strPath
Dim objFSO
Dim objFolder
Dim objItem
Dim strQuery
strPath = "/newsite/pages/" 'DIRECTORY'
strQuery = ".asp" 'FILETYPE'
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))
For Each file In objFolder.Files
fileSize = cint(file.size / 1000) 'convert into kilobytes and drop the decimal
If InStr(1, file.Name, strQuery, vbTextCompare) <> 0 Then
%>
<img src="../images/dotsupsmall2.gif" width=20 height=20>
<a href="<%= strPath & file.Name %>"><%= file.Name %></a> <%= filesize %>Kb <br>
<%
End If
Next 'objItem
Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
glenngv 03-02-2006, 09:40 AM Your solution will still show the files even if .asp is in between the filename.
Here's the solution using the Right function.
If LCase(Right(file.Name, 4)) = strQuery Then
Baleric 03-02-2006, 09:30 PM i just tryed it then, it doesnt list files that have asp in the filename i created a file called asp.html and it didnt show it :P
Archangel 03-02-2006, 09:54 PM His solution isn't meant to show all files with asp in the name. It shows only .asp files or whatever file extension you're looking for.
Baleric 03-02-2006, 10:13 PM im lost...
MetalStorm 03-03-2006, 11:04 AM You wouldn't want it to list all files with asp in the file name though? If you're just interested in .asp files.
eg.
tiajklasdjaspasdkjlasd.doc - isn't an ASP file, as far as you can tell from the extension it's a Word Document.
instr() will check to see if "asp" is anywhere in that file name so your script will guess that it's an ASP file.
Where as If LCase(Right(file.Name, 4)) = strQuery Then says 'If the last four characters of file.Name are strQuery (".asp") then display it.
So it won't show up my first example.
... asp.html isn't an ASP file is it? It's an HTML file.
Baleric 03-03-2006, 11:42 AM ... asp.html isn't an ASP file is it? It's an HTML file.
i relise this, that was the name i tested and it didnt come up even though it has asp in the filename...
o well dont worry, problem is resolved and everyone is happy :)
|
|