HELP! transferring this short .asp-script to php....

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
dear all,

i got this script form a customer. in general, it recieves data which is send  
via http to a server and generates a .xml file from this data.

because i'm not familar with .asp, i'm totally lost transferring this script  
to php. i don't understand which way the data is recieved and how it's saved.  

as long this ia a very short script, i post it here. it would bne GREAT if  
someone could give me some tipps on how to migrate this whole thing to PHP  
and how it recieves the data via http.  

thanks a lot in advance,  

---------- [SCRIPT START] -----------

    dim objXML
    dim lngRet

    set objXML = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")

    on error resume next

    ' set basic XML parser settings
    objXML.Async = False
    ' optional beide Werte auf true
    objXML.ValidateOnParse = False
    objXML.resolveExternals = False

    Response.Expires = -1000

    ' V3.0(+) of XML parser allows loading of the Request object
    lngRet = objXML.Load(Request)
    if lngRet = True then
        call objXML.Save(Server.MapPath("LastReceivedDocument.xml"))

        response.write "<cXML><Response>" & _
                        "<Status code=" & chr(34) & "200" & chr(34) & " text=" &  
chr(34) & "OK" & chr(34) & "/>" & _
                        "</Response>" & _
        response.write "<cXML><Response><Status code='404' text='Error loading  
    end if

    set objXML = nothing

---------- [SCRIPT END] -----------

Re: HELP! transferring this short .asp-script to php....

Dino wrote:
Quoted text here. Click to load it
// declaring vars, ignore, you don't need to in PHP, although you
perhaps should.
Quoted text here. Click to load it
// ignore, this is creating an object which isn't available in PHP.
Perhaps use simpleXML

Quoted text here. Click to load it
// ignore all of the above.
Quoted text here. Click to load it
// build an XML object based on the request data... see below for my
comments about that

Quoted text here. Click to load it
// above should be obvious.
Quoted text here. Click to load it
// tidy up memory.
Quoted text here. Click to load it

Before I reply, I want to say I've never coded ASP in my life before,
so I can't see why you wouldn't be able to figure it out, but

The code seems to be serializing the request object, then returning a
little bit of XML to the browser, depending on the sucess of the
request object save operation.

Now, I'm not sure how you can do this in PHP quickly, but if you don't
need the saved files to be XML, you could use serialize($_REQUEST).
Otherwise I think you will have to loop through the request elements
and build the XML yourself, then save the file and return the relevant
XML depending on it's sucess.

Look at the code above, I've added some comments that might help you.

Re: HELP! transferring this short .asp-script to php....

On Mon, 24 Apr 2006 16:06:00 +0200, Treefrog wrote

Quoted text here. Click to load it

hello treefrog,

thanks for your help! the problem i had with the code was the way the data  
was transferred to the server. at fisrt, i tried to recieve the data with the  
$_POST and the $_GET array, but both were completely empty after the data was  
submitted by the shop system. this was very irritating because i did not  
understand how exactly the data was transferred (there was no doucmentation  
available, which made the whole thing ending up in try-and-error-sessions).  
AFAIK the $_REQUEST array combines $_GET, $_POST, $_COOKIE (and also $_FILES  
in PHP versions < 4.3.0). so i'm curious if the data can be found in the  
$_REQUEST array.

thanks a lot again,  

best regards,  

Site Timeline