?
Solved

Php 2 asp two lines

Posted on 2004-10-01
17
Medium Priority
?
705 Views
Last Modified: 2012-06-27
Hello

I have this php code

<?$auth=implode("",file("http://www.webscripting.info/veveicms/index.php?action=auth"))?>
<script>
document.write('<script language="javascript" src="http://www.webscripting.info/veveicms/index.php?action=nc&auth=<?=$auth?>&i=1&qn=all&Q=' + document.location.search +'"></s' + 'cript>');
</script>

Can soemone translate this to asp?
0
Comment
Question by:Crirus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 4
17 Comments
 
LVL 19

Expert Comment

by:peh803
ID: 12199378
Can you tell me a bit more about what you're trying to do?  

I know that the implode function in php is the same as the "join" function in ASP...join will take an array of values and join them together into a string based on an optional delimiter argument (default value for the delimiter is " ").

So, if you had the following array:
<%
Dim ArrayToJoin(3)
ArrayToJoin(0) = "Experts"
ArrayToJoin(1) = "Exchange"
ArrayToJoin(2) = "Is"
ArrayToJoin(3) = "Great!"
response.write (join(ArrayToJoin))
%>
The output would be:

Experts Exchange Is Great!

So this is the ASP equivalent to the implode function in php -- now regarding the argument you've got above:
  file("http://www.webscripting.info/veveicms/index.php?action=auth"))

What does this do?  Does this grab the contents of the response from the server's execution of that file?  

Hope this info helps a bit -- I'll continue to help if I can.

Regards,
peh803
0
 
LVL 19

Expert Comment

by:peh803
ID: 12199385
By the way, I just remembered that you can actually use "join" in php as a valid alias for the "implode" function...so maybe you're already familiar with it.

peh803
0
 
LVL 19

Expert Comment

by:peh803
ID: 12199405
Okay, so the "file" function in php splits each line of the given file into an array....

The way to do this in asp is as follows:

Dim objFSO, objTS
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Set objTS = objFSO.OpenTextFile(filename)

'Now, read the contents of the file into a string
Dim s
s = objTS.ReadAll

'Now, use split to load the contents of the file into an array
Dim aFile
aFile = split(s, vbCrLf)

You'll obviously want to point the script to your filename as necessary, etc.

For more info on this, please see the following link: http://aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=62

Thanks,
peh803
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Crirus
ID: 12199430
Forget about implode

I have file_get_content and accept url.
I read URL
I only need to output the result of URL read
0
 
LVL 19

Expert Comment

by:peh803
ID: 12199593
Okay, so if you only want to output the results of a url read, try this:

server.execute("myFilePath.asp?value1=abc&value2=123")

peh803
0
 
LVL 1

Expert Comment

by:flatsheep
ID: 12201136
Just a note on FileSystemObject, for use in ASP.

The FileSystemObject isn't considered "Thread-Safe".  And therefore Microsoft warn against using this "real-time" with web applications written in ASP.  It definitely isn't scaleable for high bandwidth sites.  Although I'm sure someone out there uses it with little issue :)

For low bandwidth sites, such as corporate Intranets/Extranet or admin scripts, then this is fine to use.   The recommended alternative is that your "predetermine" the data required.  So in your case you'd store the files in a DB, or XML file, etc.  Then write a server app to update the files on demand, when modified.

Hope this is of some useful knowledge.

DF
0
 

Author Comment

by:Crirus
ID: 12201604
I really want you to read my php code...
I'll explain again

I have a site. this site output a key
The key is sent back to the site within js to get data.

I need a way to read this key in auth variable and then output it back to browser in that js link.

That's all!
0
 
LVL 1

Expert Comment

by:flatsheep
ID: 12201771
OK, so if the auth is stored in a file, and you're basically reading it from this file.

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

<%

Dim strAuth, oXMLHTTP

Set oXMLHTTP = Server.CreateObject("Msxml2.XMLHTTP.4.0")
oXMLHTTP.Open("GET", "http://www.webscripting.info/veveicms/index.php?action=auth", false)
oXMLHTTP.Send
strAuth = oXMLHTTP.ResponseText

%>

<script>
document.write('<script language="javascript"  src="http://www.webscripting.info/veveicms/index.php?action=nc&auth=<%=strAuth%>&i=1&qn=all&Q=' + document.location.search +'"></script>');
</script>


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

I think that's what you want.

DF
0
 
LVL 1

Expert Comment

by:flatsheep
ID: 12201791
Sorry, I wrote the first sentance then realised the request was from a webpage.  So I used XMLHTTP.  So you'll need MSXML installed.

DF
0
 

Author Comment

by:Crirus
ID: 12206379
I dont want any dependince but default.
Can this asp code be written so it will run on any server?
0
 
LVL 1

Expert Comment

by:flatsheep
ID: 12207955
Any competent ISP would provide XMLHTTP as a standard. I've never not seen a case where it wasn't installed.

There may be a way using an ADO Stream object.  I'll see if I can dig out an example a bit later.

DF
0
 
LVL 1

Accepted Solution

by:
flatsheep earned 100 total points
ID: 12208475
With a little more research, I don't think using an ADO stream will be possible without installing more providers than standard.

XMLHTTP is your only option.

DF
0
 

Author Comment

by:Crirus
ID: 12752534
I want this deleted, nio one answered right

Crirus
0
 
LVL 1

Expert Comment

by:flatsheep
ID: 12756066
I gave a valid implemented solution that worked when tested.  I see no other method of providing a solution, as mentioned in my previous comment. By the rules of EE, this is still a valid answer and therefore points should be provided respectively.

DF
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question