By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,979 Members | 943 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,979 IT Pros & Developers. It's quick & easy.

Help translating PHP to ASP

P: n/a
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");

---------------------------
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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\in tranet\","xhttpx://servern
ame/intranet/")
'another alternative
sLocation="xhttpx://servername/intranet/" &
Right(sLocation,len(sLocation)-instrrev(sLocation,"\")) 'untested, but I
think that's right


"Jules" <ju***********@james-chapman.co.uk> wrote in message
news:63**************************@posting.google.c om...
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");

---------------------------

Jul 19 '05 #2

P: n/a
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
%>
Jul 19 '05 #3

P: n/a
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" <ju***********@james-chapman.co.uk> wrote in message
news:63**************************@posting.google.c om...
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
%>

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.