Solved

Php 2 asp two lines

Posted on 2004-10-01
17
691 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Displaying number of records depdning on table contents - classic asp 13 37
API works for 1 result, need to make it many 30 66
Time/Date Query 11 37
Import csv files to MS SQL 5 73
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…
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/…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

13 Experts available now in Live!

Get 1:1 Help Now