473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Executing PHP Tasks While Letting A User Continue To Browse?

Hi there

I was wondering if someone could help me out with the following two
situations.

In a lot of my web apps, it seems that if i launch a PHP script that takes
a long time to complete, the user is unable to browse/use the rest of the
website until the tasks completes. Is there a way to avoid this?

Specifically, app #1 let's a user choose which files to include in a zip
file, then PHP makes the .zip file on the server and streams it to the user
via fopen/fread. So, as the user is downloading a file on the side (it
presents them with the open/save dialog) they are unable to browse the rest
of the PHP-based site until the download completes; clicking on any links
to pages does nothing, the browser just sits there until the file has been
downloaded, THEN the screen advances.

I am experiencing a similar thing with a PHP mail delivery system. I tried
to create a work-around: a pop-up window that sends an 'exec' command to
the a php-script that sends the email to a few hundred recipients. Again,
even though this action is being done in a pop-up window (and via the
command line, no less), the user is paralyzed in the main window until the
action completes.

Can anyone tell me why this is happening, and what some workaround might
be?

Thanks.
Apr 26 '06 #1
8 1558
pop-up...meaning ie's createpopup, js window.open(), a div, or the result of
target='go.process.it.php'?

i usually use the target= and have some kind of message with an animated
image indicating processing is underway. when php is done processing
whatever it is, you can use js to give some kind of alert that it's done
and/or close the window. i haven't found that that ties up the other browser
windows.

if you're not opposed to using frames, then that may be somthing to think
about too.

what browser are you testing this with?

"Good Man" <he***@letsgo.com> wrote in message
news:Xn************************@216.196.97.131...
| Hi there
|
| I was wondering if someone could help me out with the following two
| situations.
|
| In a lot of my web apps, it seems that if i launch a PHP script that takes
| a long time to complete, the user is unable to browse/use the rest of the
| website until the tasks completes. Is there a way to avoid this?
|
| Specifically, app #1 let's a user choose which files to include in a zip
| file, then PHP makes the .zip file on the server and streams it to the
user
| via fopen/fread. So, as the user is downloading a file on the side (it
| presents them with the open/save dialog) they are unable to browse the
rest
| of the PHP-based site until the download completes; clicking on any links
| to pages does nothing, the browser just sits there until the file has been
| downloaded, THEN the screen advances.
|
| I am experiencing a similar thing with a PHP mail delivery system. I
tried
| to create a work-around: a pop-up window that sends an 'exec' command to
| the a php-script that sends the email to a few hundred recipients. Again,
| even though this action is being done in a pop-up window (and via the
| command line, no less), the user is paralyzed in the main window until the
| action completes.
|
| Can anyone tell me why this is happening, and what some workaround might
| be?
|
| Thanks.
Apr 26 '06 #2
"robert" <ab@no.spam-alama-ding-dong> wrote in
news:56*************@fe05.lga:
pop-up...meaning ie's createpopup, js window.open(), a div, or the
result of target='go.process.it.php'?
it's actually using javascript if i recall correctly (for the email
delivery that is - the file streaming is just straight PHP script).

i usually use the target= and have some kind of message with an
animated image indicating processing is underway. when php is done
processing whatever it is, you can use js to give some kind of alert
that it's done and/or close the window. i haven't found that that ties
up the other browser windows.
i'll try the target=""; i use js currently to both open and close the
window.

if you're not opposed to using frames, then that may be somthing to
think about too.
i'd rather not, as these features are just one component of an overall
site.

what browser are you testing this with?


ie and firefox.
I'm actually more upset/interested in the file-streaming preventing
additional usage, as opposed to the email delivery/new window thing.

Apr 26 '06 #3

"Good Man" <he***@letsgo.com> wrote in message
news:Xn************************@216.196.97.131...
| "robert" <ab@no.spam-alama-ding-dong> wrote in
| news:56*************@fe05.lga:
|
| > pop-up...meaning ie's createpopup, js window.open(), a div, or the
| > result of target='go.process.it.php'?
|
| it's actually using javascript if i recall correctly (for the email
| delivery that is - the file streaming is just straight PHP script).
|
|
| > i usually use the target= and have some kind of message with an
| > animated image indicating processing is underway. when php is done
| > processing whatever it is, you can use js to give some kind of alert
| > that it's done and/or close the window. i haven't found that that ties
| > up the other browser windows.
|
| i'll try the target=""; i use js currently to both open and close the
| window.
|
|
| > if you're not opposed to using frames, then that may be somthing to
| > think about too.
|
| i'd rather not, as these features are just one component of an overall
| site.
|
|
| > what browser are you testing this with?
|
| ie and firefox.
|
|
| I'm actually more upset/interested in the file-streaming preventing
| additional usage, as opposed to the email delivery/new window thing.

i understand. i had to lookup the exec function in php again b/c i was
almost certain there was an additional arg used to specify a wait time.
there isn't, which i find odd.

are you having the problem in both ie and firefox? while i love ff, i have
noticed some quirks like this...just not this one in particular.

i stay away from frames as much as possible as well. i really think the
target= method will work, however i don't see why window.open wouldn't
work - which is preferable since you have control over how the window
displays, and where. do you have the "dependant" property set to "no"...it
may default to "dependant=yes" in one browser, if it's not specified at all,
while in another it may be "dependant=no"...this would definitely give you
the symptoms you're describing.
Apr 26 '06 #4
On Wed, 26 Apr 2006 10:57:59 -0500, Good Man wrote:
Specifically, app #1 let's a user choose which files to include in a zip
file, then PHP makes the .zip file on the server and streams it to the
user via fopen/fread. So, as the user is downloading a file on the side
(it presents them with the open/save dialog) they are unable to browse the
rest of the PHP-based site until the download completes; clicking on any
links to pages does nothing, the browser just sits there until the file
has been downloaded, THEN the screen advances.


Let me guess, you use session_start() near the top of every page (maybe
through a include auto_prepended).

This has bitten me before, if you do that, other requests to open that
session file will block until the other request closes the session file
(i.e. at the end of your download script).

You could force the session finished/closed before doing any
long/non-interactive tasks. This releases the lock on the session file
for that session ID.

Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Apr 26 '06 #5
Andy Jeffries <ne**@andyjeffries.co.uk> wrote in
news:pa****************************@andyjeffries.c o.uk:

Let me guess, you use session_start() near the top of every page
(maybe through a include auto_prepended).
Why yes, I certainly do!

This has bitten me before, if you do that, other requests to open that
session file will block until the other request closes the session
file (i.e. at the end of your download script).

You could force the session finished/closed before doing any
long/non-interactive tasks. This releases the lock on the session
file for that session ID.


As they say on those wacky tv-shows, "you the man".

Much thanks!!!!!
Apr 26 '06 #6
Good Man <he***@letsgo.com> wrote in news:Xns97B19AFA6FE94sonicyouth@
216.196.97.131:
Andy Jeffries <ne**@andyjeffries.co.uk> wrote in
news:pa****************************@andyjeffries.c o.uk: You could force the session finished/closed before doing any
long/non-interactive tasks. This releases the lock on the session
file for that session ID.


As they say on those wacky tv-shows, "you the man".

Much thanks!!!!!

oh, for future reference, I achieved this through:

session_write_close();

before sending anything to the browser/undertaking a big task.
Apr 26 '06 #7
On Wed, 26 Apr 2006 14:14:26 -0500, Good Man wrote:
Let me guess, you use session_start() near the top of every page (maybe
through a include auto_prepended).


Why yes, I certainly do!
This has bitten me before, if you do that, other requests to open that
session file will block until the other request closes the session file
(i.e. at the end of your download script).

You could force the session finished/closed before doing any
long/non-interactive tasks. This releases the lock on the session file
for that session ID.


As they say on those wacky tv-shows, "you the man".

Much thanks!!!!!


No worries...

Glad that my previous misfortune has now helped someone else (I spent AGES
trying to track down why that was happening).

Cheers,
Andy

--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Apr 26 '06 #8

"Andy Jeffries" <ne**@andyjeffries.co.uk> wrote in message
news:pa****************************@andyjeffries.c o.uk...
| On Wed, 26 Apr 2006 14:14:26 -0500, Good Man wrote:
| >> Let me guess, you use session_start() near the top of every page (maybe
| >> through a include auto_prepended).
| >
| > Why yes, I certainly do!
| >
| >> This has bitten me before, if you do that, other requests to open that
| >> session file will block until the other request closes the session file
| >> (i.e. at the end of your download script).
| >>
| >> You could force the session finished/closed before doing any
| >> long/non-interactive tasks. This releases the lock on the session file
| >> for that session ID.
| >
| > As they say on those wacky tv-shows, "you the man".
| >
| > Much thanks!!!!!
|
| No worries...
|
| Glad that my previous misfortune has now helped someone else (I spent AGES
| trying to track down why that was happening).

i'll have to note this one...gj.
Apr 26 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bengt Richter | last post by:
We have where syntax in combination with suite expression syntax (bear with me, I think a good synergy will emerge ;-) ...
13
by: BK | last post by:
Can someone point me to a code sample that illustrates executing long running tasks (asynchronous) from a web application in ASP.NET? I assume that Web Services might come into play at some point,...
3
by: Peter Strřiman | last post by:
Hi. I have a web application that needs to run tasks at regular intervals. E.g. it must send out emails every night to people who subscribe to that service. I have come up with one solution,...
1
by: Rune Jacobsen | last post by:
Hi, I've been trying to figure this one out, but my experience just doesn't have what it takes... :| I am writing an application that reads an XML file and displays the contents in various...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.