Help translating PHP to ASP

J

Jules

Is anyone able to translate the following PHP to ASP ? or come up with
something that would work.

The reason for the code is that I'm using Indexing service to create a
search engine on a company intranet. Unfortunately the Find.asp is
bringing back the location of the link as its place on the server (eg
C://Inetpub/www etc rather than a nice URL that works. I've been told
this code may help but its in PHP. Thanks
---------------------------

//Modify location root...
$location=str_replace("C:\inetpub\wwwroot\intranet\", "/", $location);
//Change \ to /...
$location=str_replace("\\", "/", $location);
//Output link to $location, named $documentName
print("<a href=\"" . $location . "\">" . $documentName . "</a>\n");

---------------------------
 
T

TomB

Can you show the asp code you are using?

However, a rough translation---I know nothing of PHP, so I can only guess
this is right.....

'sLocation is the filename of the document--such as
C:\inetpub\wwwroot\intranet\theDoc.doc
'which you want to convert to http://servername/intranet/theDoc.doc

'NOTE: I've set the protocol to xhttpx so that my newsreader doesn't change
it to a hyperlink. Obviously it should be just http

sLocation=Replace(sLocation,"C:\inetpub\wwwroot\intranet\","xhttpx://servern
ame/intranet/")
'another alternative
sLocation="xhttpx://servername/intranet/" &
Right(sLocation,len(sLocation)-instrrev(sLocation,"\")) 'untested, but I
think that's right
 
J

Jules

Thanks Tom, here's the asp code. Its the DISPLAY RESULTS section
which I'm having a problem with. The PATH and VPATH codes aren't
giving us a nice URL link but the exact path on the C drive.
-----------------

'These lines set the search parameters

FormScope = "/"
PageSize = 1000
MaxRecords=1000
SearchString = Request.Form("SearchString")
CatalogToSearch = "CidSearch"
SearchRankOrder="rank[d]"
OrigSearch=SearchString

'
' Create query object

set Q = Server.CreateObject("ixsso.Query")
set util = Server.CreateObject("ixsso.Util")
Q.Query = SearchString
Q.Catalog = CatalogToSearch
Q.SortBy = SearchRankOrder
Q.Columns = "DocTitle, vpath, filename, size, write, characterization,
rank, directory, path"
Q.MaxRecords = MaxRecords
'util.AddScopeToQuery Q, "/cid", "deep"

'
' Do query
'

set RS = Q.CreateRecordSet("nonsequential")
RS.PageSize = PageSize
response.write "<p>Your search for <b>" & OrigSearch & "</b> yielded "

If RS.RecordCount=0 then response.write "no results."
if RS.RecordCount=1 then response.write "1 result:"
If RS.RecordCount>1 then response.write RS.RecordCount & " results:"

response.write "<table
border=1><tr><td>Doctitle</td><td>Vpath</td><td>Filename</td>"
response.write "<td>Size</td><td>Write</td><td>Characterization</td><td>Rank</td>"
response.write "<td>Directory</td><td>Path</td></tr>"

'Display the results

Do While Not RS.EOF
' loop through the results.
' Build a hyperlink to the document
hlink = "<a href=" & RS("path") & """>" & RS("doctitle") & "</a>"
' Display attributes
response.write "<tr><td>" & hlink & "</td><td>" & RS("Vpath") &
"</td><td>"
response.write RS("filename") & "</td><td>" & RS("size") & "</td><td>"
& RS("write")
response.write "</td><td>" & RS("characterization") & "</td><td>" &
RS("rank")
response.write "</td><td>" & RS("directory") & "</td><td>" &
RS("path") & "</td><tr>"
'Get the next result
RS.MoveNext
Loop 'end of DO WHILE loop

response.write "</table>"
set rs=nothing
set q=nothing
set util=nothing
%>
 
T

Tom B

the vpath is returning the file path? As in, c:\blah blah blah\document.xls?
I've only set up index server once, and that was a while ago, but from what
I recall vpath should return the virtual path, hence the v.

Jules said:
Thanks Tom, here's the asp code. Its the DISPLAY RESULTS section
which I'm having a problem with. The PATH and VPATH codes aren't
giving us a nice URL link but the exact path on the C drive.
-----------------

'These lines set the search parameters

FormScope = "/"
PageSize = 1000
MaxRecords=1000
SearchString = Request.Form("SearchString")
CatalogToSearch = "CidSearch"
SearchRankOrder="rank[d]"
OrigSearch=SearchString

'
' Create query object

set Q = Server.CreateObject("ixsso.Query")
set util = Server.CreateObject("ixsso.Util")
Q.Query = SearchString
Q.Catalog = CatalogToSearch
Q.SortBy = SearchRankOrder
Q.Columns = "DocTitle, vpath, filename, size, write, characterization,
rank, directory, path"
Q.MaxRecords = MaxRecords
'util.AddScopeToQuery Q, "/cid", "deep"

'
' Do query
'

set RS = Q.CreateRecordSet("nonsequential")
RS.PageSize = PageSize
response.write "<p>Your search for <b>" & OrigSearch & "</b> yielded "

If RS.RecordCount=0 then response.write "no results."
if RS.RecordCount=1 then response.write "1 result:"
If RS.RecordCount>1 then response.write RS.RecordCount & " results:"

response.write "<table
border=1><tr><td>Doctitle</td><td>Vpath</td><td>Filename</td>"
response.write
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,079
Messages
2,570,574
Members
47,206
Latest member
Zenden

Latest Threads

Top