|
Posted by Thorak on 03/21/07 20:28
On Mar 21, 10:07 am, "shimmyshack" <matt.fa...@gmail.com> wrote:
> On 20 Mar, 21:00, "Thorak" <diving...@gmail.com> wrote:
>
>
>
> > Im having a wierd problem with one of my php scripts opening a socket
> > connection with session variables. My page is continualy returning
>
> > Fatal error: Maximum execution time of 30 seconds exceeded in "bla bla
> > bla" line 43
> > line 43 is: $html .= fgets($fp, 4096);
>
> > The thing is this code below works for me if i remove the line:
>
> > $Headers .= "Cookie: ".$Cookie."\r\n";
>
> > problem is then i don't have my session data filling in the form
> > fields. As soon as I add this line so that the form fields can get the
> > information needed then i get this Maximum execution error.
>
> > I know im getting a result for: $Cookie = $_SERVER["HTTP_COOKIE"]
> > cause of the echo that is returned and does match the echo of the
> > session on all my other scripts.
>
> > I have tried using things like: stream_set_timeout($fp, 60); to
> > control this - but they dont seem to do anything. And changing the:
> > $fp = fsockopen($URL, 80, $errno, $errstr, 30); to $fp =
> > fsockopen($URL, 80, $errno, $errstr, 120);
>
> > /*
> > //==================================
> > //==============================
> > */
> > session_start();
>
> > $URL = "vinyl-design"; // localhost network connection
> > $Cookie = $_SERVER["HTTP_COOKIE"]; // gives
> > "PHPSESSID=c32fc53d15e03ba25f1ad6be035a7eb1"
>
> > $Page = 'interface2/order_details.php';
>
> > $fp = fsockopen($URL, 80, $errno, $errstr, 30);
>
> > // check if the website is found
> > if(!$fp) {
> > echo 'Failed opening socket connection!<br>'.$errstr.'('.
> > $errno.')';
>
> > }
>
> > else {
> > // write to the http server
> > $Headers = "GET /".$Page." HTTP/1.1\r\n";
> > $Headers .= "Host: ".$URL."\r\n";
> > $Headers .= "Content-Type: text/html\r\n";
> > $Headers .= "Cookie: ".$Cookie."\r\n";
> > $Headers .= "Connection: Close\r\n\r\n";
> > fwrite($fp, $Headers);
>
> > // read the website
> > while(!feof($fp)) {
> > stream_set_timeout($fp, 60);
>
> > // store the html into a variable
> > $html .= fgets($fp, 4096);
>
> > $info = stream_get_meta_data($fp); // get any error
> > information
> > while reading the data
>
> > if ($info['timed_out']) {
> > echo 'Connection timed out while trying to
> > read data!';
> > }
> > }
> > fclose($fp);
>
> > }
>
> > echo $html;
>
> > /*
> > //==============================
> > //==================================
> > */
>
> Use a proper fully qualified domain name not some vinyl-server host.
> change the hosts entry and use the REAL host you are going to use.
>
> Try sending a list of proper headers.
> Why are you sending
>
> $Headers .= "Content-Type: text/html\r\n";
> and
> $Headers .= "Connection: Close\r\n\r\n";
> typically thats what the server sends your user agent,
>
> and also do you know what requirements the servrer application has in
> terms of headers, use a proxy and browse round while logged in and
> then copy the headers that are sent by your browser into your script.
>
> They might look something like
>
> $eol = "\r\n";
> $Headers = "GET /".$Page." HTTP/1.1".$eol;
> $Headers .= "Host: ".$URL.$eol;
> $Headers .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT
> 5.1; en-GB; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3".$eol;
> $Headers .= "Accept: */*".$eol;
> $Headers .= "Accept-Language: en-GB,en,fr-MC;q=0.9,fr;q=0.9,it-
> IT;q=0.9,it;q=0.8,fr-FR;q=0.8,de-DE;q=0.8,de;q=0.7,en-US;q=0.7,pl-
> PL;q=0.6,pl;q=0.6,zh-SG;q=0.6,zh;q=0.5,pt-PT;q=0.5,pt;q=0.5,hu-
> HU;q=0.4,hu;q=0.4,sv-FI;q=0.4,sv;q=0.3,es-ES;q=0.3,es;q=0.3,nl-
> NL;q=0.2,nl;q=0.2,nl-BE;q=0.1,it-CH;q=0.1,en-ZA;q=0.1,en-us;q=0.0".
> $eol;
> $Headers .= "Accept-Encoding: gzip,deflate".$eol;
> $Headers .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7".$eol;
> $Headers .= "Keep-Alive: 300".$eol;
> $Headers .= "Proxy-Connection: keep-alive".$eol;
> $Headers .= "Referer: http://".$URL."/".$Page.".$eol;
> $Headers .= "Cookie: PHPSESSID=c32fc53d15e03ba25f1ad6be035a7eb1".$eol.
> $eol;
>
> also be careful when posting your session ID, if your IP can be
> guessed, people can easily make a connection to your application if
> you allow public connections and use it as you, with annoying results.
I cant change "vinyl-host" as this is an intranet site running on a
network - there is no WWW to be had.
This is what firefox is saying my header information is:
<!--
//=============================================
// Headers returned from Firefox
http://vinyl-design/interface2/order_details.php?OrderID=21425&CSR=Ryan&CustID=&Page=1&OldOrder=
GET /interface2/order_details.php?
OrderID=21425&CSR=Ryan&CustID=&Page=1&OldOrder= HTTP/1.1
Host: vinyl-design
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
Accept: text/xml,application/xml,application/xhtml+xml,text/
html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://vinyl-design/interface2/order_detail_pages.php?OrderID=21425&CustID=&OldOrder=&RecutOrder=
Cookie: PHPSESSID=c32fc53d15e03ba25f1ad6be035a7eb1
Cache-Control: max-age=0
HTTP/1.x 200 OK
Date: Tue, 20 Mar 2007 22:26:50 GMT
Server: Apache/1.3.31 (Win32)
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
X-Powered-By: PHP/4.3.4
Set-Cookie: PHPSESSID=c32fc53d15e03ba25f1ad6be035a7eb1; path=/
Keep-Alive: timeout=15, max=96
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
//=============================================
-->
[Back to original message]
|