Solved

Php 2 asp two lines

Posted on 2004-10-01
17
687 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
  • 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
 

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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 25 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now