Re: [PHP] fsockopen to spit out the HTTP's Location...
--- Scott Fletcher <[EMAIL PROTECTED]> wrote: > Application --> Web Browser/Web Server > Presentation --> HTTP/HTTPS/SSL and language (HTML/JavaScript, etc). > Session --> Browser-Server connection, etc. > Transport --> Port 80/Port 443, packet transfer control, etc. > Network --> IP Address/Internet/Router > Data Link --> Network card driver/binding > Physical --> Media stuffs (Network cable, wireless, etc). In this case, fsockopen() basically handles everything from the Transport layer down, and whatever you write needs to handle everything from the Session layer up. > > So, use header(). > > Yea, working on it Wish can make the 3rd party software come after > the header().. You don't have to. All you have to do is make sure no output comes before your 3rd party software. If you can't avoid this, you can put ob_start() at the very top, and PHP will buffer the output for you, so that headers aren't sent until the script terminates. Whatever works best for you. Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming Fall 2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
> Why not delete that part of the 3rd party code then? Or send your Location > header before you call it? Curl won't help you here, for the same reasons > that fsockopen won't work. Not sure about deleting the part of the 3rd party code though, I had thought about it alot and I had been itching for it. Can't say that I would remember this 2 months from now with the upgrading parting. Location header, it wouldn't hurt to move it around in the script. FletchSOD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
> > Sigh! Well, I guess all web browsers suck at it by the way! > Suck at what exactly? Not suck at receiving the HTTP commands from the webserver but suck at not receiving the HTTP commands from the PHP. :-) I understand how the browser/webserver communication work so no wonder why it doesn't work. Kind of make you jealous of the flash player that are both client and server side on the web-browser > What do you consider to be the network layer? This figure might be helpful > to you: http://shiflett.org/images/18fig06.jpg Application --> Web Browser/Web Server Presentation --> HTTP/HTTPS/SSL and language (HTML/JavaScript, etc). Session --> Browser-Server connection, etc. Transport --> Port 80/Port 443, packet transfer control, etc. Network --> IP Address/Internet/Router Data Link --> Network card driver/binding Physical --> Media stuffs (Network cable, wireless, etc). > Yeah, this is why everyone was interested - you're wrong. :-) Me wrong? Really! :-) > That code will throw an error is headers have already been sent. Headers > are sent as soon as output begins, so you can either set all of your > headers prior to any output or use output buffering with ob_start(). > > So, use header(). Yea, working on it Wish can make the 3rd party software come after the header().. FletchSOD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
--- Scott Fletcher <[EMAIL PROTECTED]> wrote: > Sigh! Well, I guess all web browsers suck at it by the way! Suck at what exactly? > Michal Migurski from other posting had explained that fsockopen() > do the TCP stuff or the Transport Layer. So, no wonder fsockopen() > can't get to the Network layer, like the IP Address stuff. What do you consider to be the network layer? This figure might be helpful to you: http://shiflett.org/images/18fig06.jpg > I don't want to use cURL because it take more time. A better reason is that it also cannot make a connection to a remote client. > And finally, for those of you who are dying to know the answer to > why I can't use the header(). It's the 3rd party coding that contain > the code, > > --snip-- > if(headers_sent()) > $this->Error(' '); > --snip-- Yeah, this is why everyone was interested - you're wrong. :-) That code will throw an error is headers have already been sent. Headers are sent as soon as output begins, so you can either set all of your headers prior to any output or use output buffering with ob_start(). So, use header(). Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming Fall 2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
>And finally, for those of you who are dying to know the answer to why I >can't use the header(). It's the 3rd party coding that contain the code, > >--snip-- >if(headers_sent()) >$this->Error(' '); >--snip-- Why not delete that part of the 3rd party code then? Or send your Location header before you call it? Curl won't help you here, for the same reasons that fsockopen won't work. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
See the reply to the Chris Shiflett's reply... "Michal Migurski" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >In plain english, can't use the header("Location: "), so have to use > >the fsockopen() instead. Just that header() is not allowed, don't ask me > >why. Just couldn't get the browser perform the HTTP LOCATION event. > >--snip-- > >$host = "192.168.0.2"; > >$port = 443; > >$url_str = "ssl://www.whatever.com?str1=true&str2=false&str3=true"; > > > >$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout = 30); > >--snip-- > > //send out to the browser. > > fputs($fp, "Location: ".$url_str."\r\n"); > > That won't get sent to the browser, it will get sent to 192.168.0.2, which > is (I guess) some machine behind your router. You can't initiate a TCP > connection -- what fsockopen does -- with the client's machine. > > I'll ask even though you said not to - Why doesn't header() work? > > - > michal migurski- contact info and pgp key: > sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
Boy! Everyone here is itching for an answer!!! :-) Sigh! Well, I guess all web browsers suck at it by the way!! Michal Migurski from other posting had explained that fsockopen() do the TCP stuff or the Transport Layer. So, no wonder fsockopen() can't get to the Network layer, like the IP Address stuff. I'll think of a workaround to the header() instead. I don't want to use cURL because it take more time. And finally, for those of you who are dying to know the answer to why I can't use the header(). It's the 3rd party coding that contain the code, --snip-- if(headers_sent()) $this->Error(' '); --snip-- FletchSOD "Chris Shiflett" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > --- Scott Fletcher <[EMAIL PROTECTED]> wrote: > > In plain english, can't use the header("Location: "), so have to > > use the fsockopen() instead. Just that header() is not allowed, don't > > ask me why. > > I'm asking anyway. :-) > > You cannot (thank goodness) connect to a remote client with fsockopen(), > so you can probably save yourself some trouble by forgetting this whole > approach. You need to focus on why header() is not working for you, > because this is the way to send HTTP headers to the client. > > Chris > > = > Chris Shiflett - http://shiflett.org/ > > PHP Security - O'Reilly > Coming Fall 2004 > HTTP Developer's Handbook - Sams > http://httphandbook.org/ > PHP Community Site > http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
--- Scott Fletcher <[EMAIL PROTECTED]> wrote: > In plain english, can't use the header("Location: "), so have to > use the fsockopen() instead. Just that header() is not allowed, don't > ask me why. I'm asking anyway. :-) You cannot (thank goodness) connect to a remote client with fsockopen(), so you can probably save yourself some trouble by forgetting this whole approach. You need to focus on why header() is not working for you, because this is the way to send HTTP headers to the client. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming Fall 2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
>In plain english, can't use the header("Location: "), so have to use >the fsockopen() instead. Just that header() is not allowed, don't ask me >why. Just couldn't get the browser perform the HTTP LOCATION event. >--snip-- >$host = "192.168.0.2"; >$port = 443; >$url_str = "ssl://www.whatever.com?str1=true&str2=false&str3=true"; > >$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout = 30); >--snip-- > //send out to the browser. > fputs($fp, "Location: ".$url_str."\r\n"); That won't get sent to the browser, it will get sent to 192.168.0.2, which is (I guess) some machine behind your router. You can't initiate a TCP connection -- what fsockopen does -- with the client's machine. I'll ask even though you said not to - Why doesn't header() work? - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
In plain english, can't use the header("Location: "), so have to use the fsockopen() instead. Just that header() is not allowed, don't ask me why. Just couldn't get the browser perform the HTTP LOCATION event. It does work when using fsockopen() for HTTP POST or GET as stated in the http://us2.php.net/manual/en/function.fsockopen.php with the user's comment. What could be more difficult than this? --snip-- $host = "192.168.0.2"; $port = 443; $url_str = "ssl://www.whatever.com?str1=true&str2=false&str3=true"; $fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout = 30); if(!$fp){ echo "$errstr ($errno)\n"; }else{ //send out to the browser. fputs($fp, "Location: ".$url_str."\r\n"); fclose($fp); } FletchSOD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
In plain english, can't use the header("Location: "), so have to use the fsockopen() instead. Just that header() is not allowed, don't ask me why. Just couldn't get the browser perform the HTTP LOCATION event. It does work when using fsockopen() for HTTP POST or GET as stated in the http://us2.php.net/manual/en/function.fsockopen.php with the user's comment. What could be more difficult than this? --snip-- $host = "192.168.0.2"; $port = 443; $url_str = "ssl://www.whatever.com?str1=true&str2=false&str3=true"; $fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout = 30); if(!$fp){ echo "$errstr ($errno)\n"; }else{ //send out to the browser. fputs($fp, "Location: ".$url_str."\r\n"); fclose($fp); } FletchSOD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fsockopen to spit out the HTTP's Location...
--- Scott Fletcher <[EMAIL PROTECTED]> wrote: > I haven't found the right wording to spit out the HTTP scripts to > the web browser through the fsockopen. I feel certain that I can help you, but unfortunately I can't seem to understand your question at all. Please understand that I'm not trying to criticize your question, but there are some things that confuse me. For example, HTTP is a protocol, and I must assume that you mean HTTP headers (rather than scripts). More importantly, unless you really know what you're doing and have a very specific environment, there is no way you can connect to the user using fsockopen(). > In this case, the "Location: " script. I can not use the php > header() function because of the FPDF strict checking. Can you explain this? Why can you not use header()? I think your assumption is wrong. I can't erally make out the rest of your message, but I think that if you can explain these statements, the rest might make more sense. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming Fall 2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fsockopen to spit out the HTTP's Location...
Hi! I haven't found the right wording to spit out the HTTP scripts to the web browser through the fsockopen. In this case, the "Location: " script. I can not use the php header() function because of the FPDF strict checking. (Freeware PDF). All I did was to create a PDF and put it on the webserver with nothing being outputted but FPDF have no way of knowing this and think I'm spitting out the PDF data because I'm using hte "Location: ", so I'm using fsockopen() instead. For now, when I tried to spit out the "Location: " from fsockopen(), nothing happen. So, what exactly should the HTTP script be?? Thanks, FletchSOD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php