?
Solved

Php 2 asp two lines

Posted on 2004-10-01
17
Medium Priority
?
707 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
14 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Loops Section Overview
Screencast - Getting to Know the Pipeline

850 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