Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Re: Connection Handling/Redirect


Message #1 by "Adam Lang" <aalang@r...> on Tue, 2 Jan 2001 16:33:32 -0500
From the php.net manual. The following is a snippet.  I'll have the link to
read the full article.  Basically, you register a shutdown function that is
called if the script timesout or is aborted.  Inside that function is where
you test to the reason why it bombed out.

"Your script can also be terminated by the built-in script timer. The
default timeout is 30 seconds. It can be changed using the
max_execution_time php3.ini directive or the corresponding
php3_max_execution_time Apache .conf directive as well as with the
set_time_limit() function. When the timer expires the script will be aborted
and as with the above client disconnect case, if a shutdown function has
been registered it will be called. Within this shutdown function you can
check to see if a timeout caused the shutdown function to be called by
calling the connection_timeout() function. This function will return true if
a timeout caused the shutdown function to be called."

http://www.php.net/manual/features.connection-handling.php

But in the register function info, it says that no output is allowed to go
to the browser.  I guess this would include redirect since that is being
sent to the browser.  So... off the top of my head, I wonder if you can do
what you want to...

Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
http://www.rutgersinsurance.com
----- Original Message -----
From: "Kevin O'Connor" <mariotown@h...>
To: "professional php" <pro_php@p...>
Sent: Friday, December 29, 2000 3:45 PM
Subject: [pro_php] Re: Connection Handling/Redirect


> Hi!
> The header() function by itself wouldn't work because I need to determine
if
> the script has timed out before redirecting.  What I had started trying
was
> to determine if the script has timed out using the connection_status()
> function.  When a connection timeouts, connection_status() should return a
> 2, I believe.  So I tried something like this:
>
> if(connection_status() == 2) {
>      header ("Location: error.php");
> }
>
> But this didn't work.  The script timed out and I received a blank error
> page.  So then I tried this:
>
> register_shutdown_function("shutdown");
> function shutdown() {
> if(connection_status() == 2) {
> header("Location: error.php");
> }
> }
>
> But this didn't work.  What I thought it would do would be to run the
> function shutdown() when the script dies.  I still get a blank screen.
I'll
> keep trying.  Anymore ideas?
>
> I could have also tried testing to see if connection_timeout() returned
true
> on shutdown.  It didn't work either.
>
> I also can't send more time to the set_time_limit() function because the
> server I am on is running in safe mode and won't allow that.
>
> Let me know.  It seems like someone should know how to do this.
>
> Thanks!
> Kevin
>
> >From: Gabriele Bartolini <angusgb@t...>
> >Reply-To: "professional php" <pro_php@p...>
> >To: "professional php" <pro_php@p...>
> >Subject: [pro_php] Re: Connection Handling/Redirect
> >Date: Fri, 29 Dec 2000 12:58:45 +0100
> >
> >At 15.18 28/12/2000 -0500, you wrote:
> >>Hi!
> >>I was having some trouble trying to redirect to another page (an error
> >>page) after a script times out and was wondering if anyone has done
> >>this.  I have done redirects in PHP4 before so I know all the pitfalls
to
> >>look out for. Right now I have error_reporting set to to 0 so there
aren't
> >>any error messages displayed, but I don't want to see a blank page...I
> >>want to see my error page.
> >>
> >>Anybody got any ideas or sample code they could reply with?
> >
> >Ciao Kevin, I don't know if I have understood your problem. And my
solution
> >seems to be pretty easy, but have you tried to send an HTTP header
command,
> >containing the directive 'Location'?
> >
> >For instance, let's suppose your URL for error managing is
> >http://www.foo.com/error.php, you can write this:
> >
> ><?php
> >...
> >Header('Location: http://www.foo.com/error.php');
> >die;
> >
> >...
> >?>
> >
> >Of course, Header must be sent before anything else ... (spaces included)
> >
> >Let me know
> >-Gabriele
> >
> >--
> >Gabriele Bartolini, Web Programmer
> >angusgb@t... | http://space.tin.it/io/gabrbart
> >"The box said 'Requires Windows 95 or better.'
> >  I can't understand why it won't work on my Linux computer"


--- 
NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS?  Is FREE okay?
Visit EarthWeb for the latest in IT Management, Software Development, 
Web Development, Networking & Communications, and Hardware & Systems.  
Click on http://www.earthweb.com for FREE articles, tutorials,
and discussions from the experts.
---
You are currently subscribed to pro_php as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-pro_php-$subst('Recip.MemberIDChar')@p2p.wrox.com

  Return to Index