Executing PHP Tasks While Letting A User Continue To Browse?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Good Man

    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.
  • robert

    #2
    Re: Executing PHP Tasks While Letting A User Continue To Browse?

    pop-up...meaning ie's createpopup, js window.open(), a div, or the result of
    target='go.proc ess.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" <heyho@letsgo.c om> wrote in message
    news:Xns97B179A C72B93sonicyout h@216.196.97.13 1...
    | 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.


    Comment

    • Good Man

      #3
      Re: Executing PHP Tasks While Letting A User Continue To Browse?

      "robert" <ab@no.spam-alama-ding-dong> wrote in
      news:56N3g.13$g O2.10@fe05.lga:
      [color=blue]
      > pop-up...meaning ie's createpopup, js window.open(), a div, or the
      > result of target='go.proc ess.it.php'?[/color]

      it's actually using javascript if i recall correctly (for the email
      delivery that is - the file streaming is just straight PHP script).

      [color=blue]
      > 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.[/color]

      i'll try the target=""; i use js currently to both open and close the
      window.

      [color=blue]
      > if you're not opposed to using frames, then that may be somthing to
      > think about too.[/color]

      i'd rather not, as these features are just one component of an overall
      site.

      [color=blue]
      > what browser are you testing this with?[/color]

      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.

      Comment

      • robert

        #4
        Re: Executing PHP Tasks While Letting A User Continue To Browse?


        "Good Man" <heyho@letsgo.c om> wrote in message
        news:Xns97B1819 26A78Csonicyout h@216.196.97.13 1...
        | "robert" <ab@no.spam-alama-ding-dong> wrote in
        | news:56N3g.13$g O2.10@fe05.lga:
        |
        | > pop-up...meaning ie's createpopup, js window.open(), a div, or the
        | > result of target='go.proc ess.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.


        Comment

        • Andy Jeffries

          #5
          Re: Executing PHP Tasks While Letting A User Continue To Browse?

          On Wed, 26 Apr 2006 10:57:59 -0500, Good Man wrote:[color=blue]
          > 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.[/color]

          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

          Comment

          • Good Man

            #6
            Re: Executing PHP Tasks While Letting A User Continue To Browse?

            Andy Jeffries <news@andyjeffr ies.co.uk> wrote in
            news:pan.2006.0 4.26.18.55.27.5 62055@andyjeffr ies.co.uk:

            [color=blue]
            > Let me guess, you use session_start() near the top of every page
            > (maybe through a include auto_prepended) .[/color]

            Why yes, I certainly do!

            [color=blue]
            > 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.[/color]

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

            Much thanks!!!!!

            Comment

            • Good Man

              #7
              Re: Executing PHP Tasks While Letting A User Continue To Browse?

              Good Man <heyho@letsgo.c om> wrote in news:Xns97B19AF A6FE94sonicyout h@
              216.196.97.131:
              [color=blue][color=green]
              >> Andy Jeffries <news@andyjeffr ies.co.uk> wrote in
              >> news:pan.2006.0 4.26.18.55.27.5 62055@andyjeffr ies.co.uk:[/color][/color]
              [color=blue][color=green]
              >> 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.[/color]
              >
              > As they say on those wacky tv-shows, "you the man".
              >
              > Much thanks!!!!![/color]


              oh, for future reference, I achieved this through:

              session_write_c lose();

              before sending anything to the browser/undertaking a big task.

              Comment

              • Andy Jeffries

                #8
                Re: Executing PHP Tasks While Letting A User Continue To Browse?

                On Wed, 26 Apr 2006 14:14:26 -0500, Good Man wrote:[color=blue][color=green]
                >> Let me guess, you use session_start() near the top of every page (maybe
                >> through a include auto_prepended) .[/color]
                >
                > Why yes, I certainly do!
                >[color=green]
                >> 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.[/color]
                >
                > As they say on those wacky tv-shows, "you the man".
                >
                > Much thanks!!!!![/color]

                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

                Comment

                • robert

                  #9
                  Re: Executing PHP Tasks While Letting A User Continue To Browse?


                  "Andy Jeffries" <news@andyjeffr ies.co.uk> wrote in message
                  news:pan.2006.0 4.26.20.09.07.8 25698@andyjeffr ies.co.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.


                  Comment

                  Working...