I did something like that for a newsletter sending script. Basiclly, I
had two scripts:

a) AddEdit.php that would list the newsletter's items and allow it to send
b) Send.php that was a script I ran on the background

When pressed "Send" on AddEdit, it would do something like

$tempName = tempnam( '/tmp', 'newsletter' );
$fp = fopen( $tempName, 'w+' );
fputs( $fp, "#!/bin/sh\n/path/to/script/Send.php 12 &\n" );
fclose( $fp );
chmod( $tempName, 0755 );
system( $tempName . ' &' );

That way, it would launch the second script into the background,
checking if the script altered the newsletter's state for "Sent"
everytime a user saw the newsletter's details.

Hope it helped.

On 7/16/05, Rory Browne <[EMAIL PROTECTED]> wrote:
> On 7/16/05, rouvas <[EMAIL PROTECTED]> wrote:
> > Hi Liang,
> >
> > trying to get conclusive results with browsers is futile. Use a command-line
> > tool (like curl) to invoke the web pages and get the results. Or you can use
> Although personally I think that telnet-to-port-80 would be a better
> idea, in this case when you're trying to check what is outputted
> first. Either that or a TCP sniffer.
> 
> I also agree with the microtime() suggestion, mentioned below. It will
> get you around the problem of caches - which is a major problem for
> something like this. I'm not sure what the situation with apache is
> regarding caches.
> 
> > PHP's own function to query the web server and do your own timing with
> > microtime() function or another suitable for your purposes.
> >
> > In order for flush() results to reach you (in a browser) they have to pass
> > from multiple caches like PHP's, Apache's, the occasional proxies and 
> > finally
> > the browser's own cache. So you cannot get dependaple results measuring 
> > times
> > or responses from your browser. Try the methods above.
> >
> > And a final tip... When Rasmus speaks, you don't question him:-) Period.
> 
> Unless you didn't understand what he said and want clarification.
> 
> 
> >
> > Have a nice day,
> > -Stathis
> >
> > On Saturday 16 July 2005 04:41, Liang ZHONG wrote:
> > > Hi Rasmus,
> > >
> > > You are right. It was the problem with the browser. I used Mozilla Firefox
> > > to try, and do not know what consideration it just serialized the 
> > > identical
> > > url http requests. I then turned to use 2 IE 6.0 windows, 2 tabs within
> > > Maxthon browser, one IE windows and one Firefox, to test. Then I got the
> > > conclusion as you told. Thank you very much for the help.
> > >
> > > BTW, I could not get the flush() work, neither flush() with ob_flush(). I
> > > tried almost all methods mentioned in the followed posts under
> > > http://us2.php.net/flush, but none of them can really pushed the buffer
> > > out. The site is configurated with http://liang.ns2user.info/php/info.php
> > > on Red head, kernel 2.4.29. What can I do to get it work?
> > >
> > > Thank you again.
> > >
> > > >Liang ZHONG wrote:
> > > > > Could you please explain it a little bit more?
> > > > > I did test this way.
> > > > >
> > > > > The code is the same for a.php and b.php
> > > > > <?php
> > > > >
> > > > >        sleep(20);
> > > > >        print  Done. <br />";
> > > > >
> > > > > ?>
> > > > >
> > > > > I place request from 2 browser windows.
> > > > > First time, I placed with http://baseURL/a.php with both 2 browsers,
> > > > > starting times have 5 second interval. Then the first "Done" shows
> > > > > after 20 seconds and the second "Done" shows 20 seconds after the 
> > > > > first
> > > >
> > > >"Done".
> > > >
> > > > > Then, I placed one browser with http://baseURL/a.php and the second 
> > > > > one
> > > > > with http://baseURL/b.php, with starting time of 5 second interval.
> > > > > Then I got the first browser showing "Done" after 20 seconds and 5
> > > > > seconds later, the second browser showed "Done", too.
> > > > >
> > > > > Thus it seems that the apache can spoon out multiple php interpreters
> > > > > responding to http requests, while php can not deal with concurrent
> > > > > process from one program.
> > > >
> > > >I have no idea what you did to configure it this way.  I wouldn't even
> > > >know how to do that if you asked me to.  As far as PHP is concerned it
> > > >has no idea which processes are handling which script files at any one
> > > >point.  So whether you request a.php and b.php at the same time or a.php
> > > >twice at the same time, it makes absolutely no difference to PHP.  If
> > > >you are really seeing this, then the limitation is in your browser or
> > > >somewhere else.  Try making a.php output stuff so it becomes easier to
> > > >see.  As in for($i=0;$i<20;$i++) { echo $i; flush(); sleep(1); }
> > > >You should see the counter start counting as soon as you hit the page.
> > > >
> > > >-Rasmus
> > > >
> > > >--
> > > >PHP General Mailing List (http://www.php.net/)
> > > >To unsubscribe, visit: http://www.php.net/unsub.php
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to