Event Handling
am 15.03.2010 07:59:43 von Alex Major
------=_NextPart_000_0009_01CAC40D.17A0BEF0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Greetings all,
I'm currently looking at building a web application, however I've run into
an area of development I've not come across before. The web site in its
basic form allows users to send cars from a point and then the car will
arrive at another point. When the car is set on its way, the start time,
travel duration and end time are all known and stored in a MySQL database,
what I would like to happen is that an event is triggered on the server at
the end time and then an e-mail is sent to the user. This should happen
regardless of whether someone is browsing the website or not.
I don't believe that I'll be able to solely use PHP, I have spent the
afternoon trying to look at potential solutions but I have to admit I've
drawn a blank. Google hasn't been helpful (64 pages so far), as any searches
related to "event handling" bring up a load of JavaScript tutorials/help for
'onclick' events etc. I have searched through the PHP documentation and
found "libevent" (http://www.php.net/manual/en/book.libevent.php ), I don't
believe that is what I require (although in all honesty the lack of
documentation on it means I'm quite in the dark as to its purpose). Another
potential candidate I came across was a PHP/Java bridge
(http://php-java-bridge.sourceforge.net/pjb/ ), whereby I could use the java
virtual machine, register events with it and then callback PHP scripts,
although this seems extremely long winded.
I was hoping that someone might have some experience with this kind of issue
and could point me in the right direction. I'm sure I've missed something
right in front of me.
Alex.
------=_NextPart_000_0009_01CAC40D.17A0BEF0--
Re: Event Handling
am 15.03.2010 08:37:13 von David Robley
Alex Major wrote:
> Greetings all,
>
> I'm currently looking at building a web application, however I've run into
> an area of development I've not come across before. The web site in its
> basic form allows users to send cars from a point and then the car will
> arrive at another point. When the car is set on its way, the start time,
> travel duration and end time are all known and stored in a MySQL database,
> what I would like to happen is that an event is triggered on the server at
> the end time and then an e-mail is sent to the user. This should happen
> regardless of whether someone is browsing the website or not.
>
> I don't believe that I'll be able to solely use PHP, I have spent the
> afternoon trying to look at potential solutions but I have to admit I've
> drawn a blank. Google hasn't been helpful (64 pages so far), as any
> searches related to "event handling" bring up a load of JavaScript
> tutorials/help for 'onclick' events etc. I have searched through the PHP
> documentation and found "libevent"
> (http://www.php.net/manual/en/book.libevent.php ), I don't believe that is
> what I require (although in all honesty the lack of documentation on it
> means I'm quite in the dark as to its purpose). Another potential
> candidate I came across was a PHP/Java bridge
> (http://php-java-bridge.sourceforge.net/pjb/ ), whereby I could use the
> java virtual machine, register events with it and then callback PHP
> scripts, although this seems extremely long winded.
>
> I was hoping that someone might have some experience with this kind of
> issue and could point me in the right direction. I'm sure I've missed
> something right in front of me.
>
> Alex.
I think what you want is something to trigger a php script every
$period-of-time; if your host supports it, cron is the means of executing
an application at regular intervals down to a minute granularity. There are
some web-based cron services also, but they may not have the same
granularity as a locally based cron.
Cheers
--
David Robley
"Wow!" barked Tom, with a bow.
Today is Prickle-Prickle, the 1st day of Discord in the YOLD 3176.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Event Handling
am 15.03.2010 08:40:32 von David Hutto
--00c09f9c9971f8d5450481d1fe9b
Content-Type: text/plain; charset=ISO-8859-1
--- On *Mon, 3/15/10, David Hutto * wrote:
From: David Hutto
Subject: Re: [PHP] Event Handling
To: php-general@lists.php.net, "Alex Major"
Date: Monday, March 15, 2010, 3:34 AM
--- On Mon, 3/15/10, Alex Major
>
wrote:
> From: Alex Major
>
> Subject: [PHP] Event Handling
> To: php-general@lists.php.net
> Date: Monday, March 15, 2010, 2:59 AM
> Greetings all,
>
> I'm currently looking at building a web application,
> however I've run into
> an area of development I've not come across before. The web
> site in its
> basic form allows users to send cars from a point and then
> the car will
> arrive at another point. When the car is set on its way,
> the start time,
> travel duration and end time are all known and stored in a
> MySQL database,
> what I would like to happen is that an event is triggered
> on the server at
> the end time and then an e-mail is sent to the user. This
> should happen
> regardless of whether someone is browsing the website or
> not.
>
> I don't believe that I'll be able to solely use PHP, I have
> spent the
> afternoon trying to look at potential solutions but I have
> to admit I've
> drawn a blank. Google hasn't been helpful (64 pages so
> far), as any searches
> related to "event handling" bring up a load of JavaScript
> tutorials/help for
> 'onclick' events etc. I have searched through the PHP
> documentation and
> found "libevent" (http://www.php.net/manual/en/book.libevent.php ), I
> don't
> believe that is what I require (although in all honesty the
> lack of
> documentation on it means I'm quite in the dark as to its
> purpose). Another
> potential candidate I came across was a PHP/Java bridge
> (http://php-java-bridge.sourceforge.net/pjb/ ), whereby
> I could use the java
> virtual machine, register events with it and then callback
> PHP scripts,
> although this seems extremely long winded.
>
> I was hoping that someone might have some experience with
> this kind of issue
> and could point me in the right direction. I'm sure I've
> missed something
> right in front of me.
>
> Alex.
>
>
I'm a noob at php myself, but what you might want to look at is cron jobs
and autoresponders. Here's an address to one I've messed with before:
infinite.ibasics.biz/ I believe it uses cron jobs, I've messed with a lot so
it's hard to recall.
You might want to have the web app insert the new info in the tables, and
have the cron job and script do the rest.
David
--00c09f9c9971f8d5450481d1fe9b--
Re: Event Handling
am 15.03.2010 09:24:18 von Midhun Girish
--00504502c721a61bcb0481d29cfa
Content-Type: text/plain; charset=ISO-8859-1
Hi ,
Just as David Hutto has said,What you need is the cronjob... Make a script
say "check.php" which checks the db to see if any new entries are made...
and if yes send the mail ...
now using the cronjob feature in linux os(which will be provided as a
service in your linux hosting cpanel), set a cronjob which calls the "
http://www.yoursite.com/check.php" URL every minute.... now a trigger will
be there every minute to the script and the emails will be send irrespective
of whether anyone is browsing the site or not.... hope it is clear...
Midhun Girish
Development Lead
MobAlive Technologies
On Mon, Mar 15, 2010 at 1:10 PM, David Hutto wrote:
>
> --- On *Mon, 3/15/10, David Hutto * wrote:
>
> From: David Hutto
> Subject: Re: [PHP] Event Handling
> To: php-general@lists.php.net, "Alex Major"
> Date: Monday, March 15, 2010, 3:34 AM
>
>
>
> --- On Mon, 3/15/10, Alex Major
>
http://us.mc453.mail.yahoo.com/mc/compose?to=php@allydm.co.u k>>
> wrote:
>
> > From: Alex Major
http://us.mc453.mail.yahoo.com/mc/compose?to=php@allydm.co.u k>
> >
> > Subject: [PHP] Event Handling
> > To: php-general@lists.php.net<
http://us.mc453.mail.yahoo.com/mc/compose?to=php-general@lis ts.php.net>
> > Date: Monday, March 15, 2010, 2:59 AM
> > Greetings all,
> >
> > I'm currently looking at building a web application,
> > however I've run into
> > an area of development I've not come across before. The web
> > site in its
> > basic form allows users to send cars from a point and then
> > the car will
> > arrive at another point. When the car is set on its way,
> > the start time,
> > travel duration and end time are all known and stored in a
> > MySQL database,
> > what I would like to happen is that an event is triggered
> > on the server at
> > the end time and then an e-mail is sent to the user. This
> > should happen
> > regardless of whether someone is browsing the website or
> > not.
> >
> > I don't believe that I'll be able to solely use PHP, I have
> > spent the
> > afternoon trying to look at potential solutions but I have
> > to admit I've
> > drawn a blank. Google hasn't been helpful (64 pages so
> > far), as any searches
> > related to "event handling" bring up a load of JavaScript
> > tutorials/help for
> > 'onclick' events etc. I have searched through the PHP
> > documentation and
> > found "libevent" (http://www.php.net/manual/en/book.libevent.php ), I
> > don't
> > believe that is what I require (although in all honesty the
> > lack of
> > documentation on it means I'm quite in the dark as to its
> > purpose). Another
> > potential candidate I came across was a PHP/Java bridge
> > (http://php-java-bridge.sourceforge.net/pjb/ ), whereby
> > I could use the java
> > virtual machine, register events with it and then callback
> > PHP scripts,
> > although this seems extremely long winded.
> >
> > I was hoping that someone might have some experience with
> > this kind of issue
> > and could point me in the right direction. I'm sure I've
> > missed something
> > right in front of me.
> >
> > Alex.
> >
> >
>
> I'm a noob at php myself, but what you might want to look at is cron jobs
> and autoresponders. Here's an address to one I've messed with before:
> infinite.ibasics.biz/ I believe it uses cron jobs, I've messed with a lot
so
> it's hard to recall.
>
> You might want to have the web app insert the new info in the tables, and
> have the cron job and script do the rest.
>
> David
--00504502c721a61bcb0481d29cfa--
Re: Re: Event Handling
am 15.03.2010 09:43:42 von Ashley Sheridan
--=-Fr38a98FWKnWffFjpUrn
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Mon, 2010-03-15 at 18:07 +1030, David Robley wrote:
> Alex Major wrote:
>
> > Greetings all,
> >
> > I'm currently looking at building a web application, however I've run into
> > an area of development I've not come across before. The web site in its
> > basic form allows users to send cars from a point and then the car will
> > arrive at another point. When the car is set on its way, the start time,
> > travel duration and end time are all known and stored in a MySQL database,
> > what I would like to happen is that an event is triggered on the server at
> > the end time and then an e-mail is sent to the user. This should happen
> > regardless of whether someone is browsing the website or not.
> >
> > I don't believe that I'll be able to solely use PHP, I have spent the
> > afternoon trying to look at potential solutions but I have to admit I've
> > drawn a blank. Google hasn't been helpful (64 pages so far), as any
> > searches related to "event handling" bring up a load of JavaScript
> > tutorials/help for 'onclick' events etc. I have searched through the PHP
> > documentation and found "libevent"
> > (http://www.php.net/manual/en/book.libevent.php ), I don't believe that is
> > what I require (although in all honesty the lack of documentation on it
> > means I'm quite in the dark as to its purpose). Another potential
> > candidate I came across was a PHP/Java bridge
> > (http://php-java-bridge.sourceforge.net/pjb/ ), whereby I could use the
> > java virtual machine, register events with it and then callback PHP
> > scripts, although this seems extremely long winded.
> >
> > I was hoping that someone might have some experience with this kind of
> > issue and could point me in the right direction. I'm sure I've missed
> > something right in front of me.
> >
> > Alex.
>
> I think what you want is something to trigger a php script every
> $period-of-time; if your host supports it, cron is the means of executing
> an application at regular intervals down to a minute granularity. There are
> some web-based cron services also, but they may not have the same
> granularity as a locally based cron.
>
>
> Cheers
> --
> David Robley
>
> "Wow!" barked Tom, with a bow.
> Today is Prickle-Prickle, the 1st day of Discord in the YOLD 3176.
>
>
You could store the end times in the database, and cron can run a script
that will check each of these times to find any that are within x
minutes that an email hasn't been sent out for. You'll need an extra
field to indicate whether an email has been sent or not.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-Fr38a98FWKnWffFjpUrn--
Re: Re: Event Handling
am 15.03.2010 09:58:19 von Midhun Girish
--001636d34a2b4dacf90481d31640
Content-Type: text/plain; charset=ISO-8859-1
hey ash,
do we need both of those checks ? ie the time and the flag? i think they
both do the same thing ie prevent duplicates.. am i right? and i think flag
would be a more reliable method coz it will ensure that the email will be
send even if the cron fails to execute for some time,....
Midhun Girish
Development Lead
MobAlive Technologies
Trivandrum
On Mon, Mar 15, 2010 at 2:13 PM, Ashley Sheridan
wrote:
> On Mon, 2010-03-15 at 18:07 +1030, David Robley wrote:
>
> > Alex Major wrote:
> >
> > > Greetings all,
> > >
> > > I'm currently looking at building a web application, however I've run
> into
> > > an area of development I've not come across before. The web site in its
> > > basic form allows users to send cars from a point and then the car will
> > > arrive at another point. When the car is set on its way, the start
> time,
> > > travel duration and end time are all known and stored in a MySQL
> database,
> > > what I would like to happen is that an event is triggered on the server
> at
> > > the end time and then an e-mail is sent to the user. This should happen
> > > regardless of whether someone is browsing the website or not.
> > >
> > > I don't believe that I'll be able to solely use PHP, I have spent the
> > > afternoon trying to look at potential solutions but I have to admit
> I've
> > > drawn a blank. Google hasn't been helpful (64 pages so far), as any
> > > searches related to "event handling" bring up a load of JavaScript
> > > tutorials/help for 'onclick' events etc. I have searched through the
> PHP
> > > documentation and found "libevent"
> > > (http://www.php.net/manual/en/book.libevent.php ), I don't believe
> that is
> > > what I require (although in all honesty the lack of documentation on it
> > > means I'm quite in the dark as to its purpose). Another potential
> > > candidate I came across was a PHP/Java bridge
> > > (http://php-java-bridge.sourceforge.net/pjb/ ), whereby I could use
> the
> > > java virtual machine, register events with it and then callback PHP
> > > scripts, although this seems extremely long winded.
> > >
> > > I was hoping that someone might have some experience with this kind of
> > > issue and could point me in the right direction. I'm sure I've missed
> > > something right in front of me.
> > >
> > > Alex.
> >
> > I think what you want is something to trigger a php script every
> > $period-of-time; if your host supports it, cron is the means of executing
> > an application at regular intervals down to a minute granularity. There
> are
> > some web-based cron services also, but they may not have the same
> > granularity as a locally based cron.
> >
> >
> > Cheers
> > --
> > David Robley
> >
> > "Wow!" barked Tom, with a bow.
> > Today is Prickle-Prickle, the 1st day of Discord in the YOLD 3176.
> >
> >
>
>
> You could store the end times in the database, and cron can run a script
> that will check each of these times to find any that are within x
> minutes that an email hasn't been sent out for. You'll need an extra
> field to indicate whether an email has been sent or not.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
--001636d34a2b4dacf90481d31640--
Re: Re: Event Handling
am 15.03.2010 09:59:44 von Ashley Sheridan
--=-YVylIrbk29GCJv4Q02W8
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Mon, 2010-03-15 at 14:28 +0530, Midhun Girish wrote:
> hey ash,
>
> do we need both of those checks ? ie the time and the flag? i think they
> both do the same thing ie prevent duplicates.. am i right? and i think flag
> would be a more reliable method coz it will ensure that the email will be
> send even if the cron fails to execute for some time,....
>
> Midhun Girish
> Development Lead
> MobAlive Technologies
> Trivandrum
>
>
> On Mon, Mar 15, 2010 at 2:13 PM, Ashley Sheridan
> wrote:
>
> > On Mon, 2010-03-15 at 18:07 +1030, David Robley wrote:
> >
> > > Alex Major wrote:
> > >
> > > > Greetings all,
> > > >
> > > > I'm currently looking at building a web application, however I've run
> > into
> > > > an area of development I've not come across before. The web site in its
> > > > basic form allows users to send cars from a point and then the car will
> > > > arrive at another point. When the car is set on its way, the start
> > time,
> > > > travel duration and end time are all known and stored in a MySQL
> > database,
> > > > what I would like to happen is that an event is triggered on the server
> > at
> > > > the end time and then an e-mail is sent to the user. This should happen
> > > > regardless of whether someone is browsing the website or not.
> > > >
> > > > I don't believe that I'll be able to solely use PHP, I have spent the
> > > > afternoon trying to look at potential solutions but I have to admit
> > I've
> > > > drawn a blank. Google hasn't been helpful (64 pages so far), as any
> > > > searches related to "event handling" bring up a load of JavaScript
> > > > tutorials/help for 'onclick' events etc. I have searched through the
> > PHP
> > > > documentation and found "libevent"
> > > > (http://www.php.net/manual/en/book.libevent.php ), I don't believe
> > that is
> > > > what I require (although in all honesty the lack of documentation on it
> > > > means I'm quite in the dark as to its purpose). Another potential
> > > > candidate I came across was a PHP/Java bridge
> > > > (http://php-java-bridge.sourceforge.net/pjb/ ), whereby I could use
> > the
> > > > java virtual machine, register events with it and then callback PHP
> > > > scripts, although this seems extremely long winded.
> > > >
> > > > I was hoping that someone might have some experience with this kind of
> > > > issue and could point me in the right direction. I'm sure I've missed
> > > > something right in front of me.
> > > >
> > > > Alex.
> > >
> > > I think what you want is something to trigger a php script every
> > > $period-of-time; if your host supports it, cron is the means of executing
> > > an application at regular intervals down to a minute granularity. There
> > are
> > > some web-based cron services also, but they may not have the same
> > > granularity as a locally based cron.
> > >
> > >
> > > Cheers
> > > --
> > > David Robley
> > >
> > > "Wow!" barked Tom, with a bow.
> > > Today is Prickle-Prickle, the 1st day of Discord in the YOLD 3176.
> > >
> > >
> >
> >
> > You could store the end times in the database, and cron can run a script
> > that will check each of these times to find any that are within x
> > minutes that an email hasn't been sent out for. You'll need an extra
> > field to indicate whether an email has been sent or not.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
Consider a cron script that runs every 10 minutes. You'll want to check
the db for cars that are due to arrive within just over 10 minutes. The
flag is there more for you own clarification that the email has been
sent. What if the cron fails, or you restart your server, or the script
your cron calls is just running a little slowly?
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-YVylIrbk29GCJv4Q02W8--
Re: Re: Event Handling
am 15.03.2010 10:08:27 von Ashley Sheridan
--=-uUhc90Ow9JEtOs2jYd3c
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Mon, 2010-03-15 at 14:40 +0530, Midhun Girish wrote:
> ok so we have a script which checks if any cars have arrived within
> last 10 minutes... if yes, a mail will be send..... suppose the server
> fails for 30 minutes.... so when the cron comes next time, we will
> have to check for cars which arrived within last 40 minutes and not
> 10.. right... so how will we set a time limit in the script? its
> variable na.. but the flag is ok.. you can send a mail to all db
> entries which have flag 0 and then update the flag to 1.
>
>
> Midhun Girish
> Development Lead
> MobAlive Technologies
>
>
>
> On Mon, Mar 15, 2010 at 2:29 PM, Ashley Sheridan
> wrote:
>
>
> On Mon, 2010-03-15 at 14:28 +0530, Midhun Girish wrote:
>
> > hey ash,
> >
> > do we need both of those checks ? ie the time and the flag? i think they
> > both do the same thing ie prevent duplicates.. am i right? and i think flag
> > would be a more reliable method coz it will ensure that the email will be
> > send even if the cron fails to execute for some time,....
> >
> > Midhun Girish
> > Development Lead
> > MobAlive Technologies
> > Trivandrum
> >
> >
> > On Mon, Mar 15, 2010 at 2:13 PM, Ashley Sheridan
> > wrote:
> >
> > > On Mon, 2010-03-15 at 18:07 +1030, David Robley wrote:
> > >
> > > > Alex Major wrote:
> > > >
> > > > > Greetings all,
> > > > >
> > > > > I'm currently looking at building a web application, however I've run
> > > into
> > > > > an area of development I've not come across before. The web site in its
> > > > > basic form allows users to send cars from a point and then the car will
> > > > > arrive at another point. When the car is set on its way, the start
> > > time,
> > > > > travel duration and end time are all known and stored in a MySQL
> > > database,
> > > > > what I would like to happen is that an event is triggered on the server
> > > at
> > > > > the end time and then an e-mail is sent to the user. This should happen
> > > > > regardless of whether someone is browsing the website or not.
> > > > >
> > > > > I don't believe that I'll be able to solely use PHP, I have spent the
> > > > > afternoon trying to look at potential solutions but I have to admit
> > > I've
> > > > > drawn a blank. Google hasn't been helpful (64 pages so far), as any
> > > > > searches related to "event handling" bring up a load of JavaScript
> > > > > tutorials/help for 'onclick' events etc. I have searched through the
> > > PHP
> > > > > documentation and found "libevent"
> > > > > (http://www.php.net/manual/en/book.libevent.php ), I don't believe
> > > that is
> > > > > what I require (although in all honesty the lack of documentation on it
> > > > > means I'm quite in the dark as to its purpose). Another potential
> > > > > candidate I came across was a PHP/Java bridge
> > > > > (http://php-java-bridge.sourceforge.net/pjb/ ), whereby I could use
> > > the
> > > > > java virtual machine, register events with it and then callback PHP
> > > > > scripts, although this seems extremely long winded.
> > > > >
> > > > > I was hoping that someone might have some experience with this kind of
> > > > > issue and could point me in the right direction. I'm sure I've missed
> > > > > something right in front of me.
> > > > >
> > > > > Alex.
> > > >
> > > > I think what you want is something to trigger a php script every
> > > > $period-of-time; if your host supports it, cron is the means of executing
> > > > an application at regular intervals down to a minute granularity. There
> > > are
> > > > some web-based cron services also, but they may not have the same
> > > > granularity as a locally based cron.
> > > >
> > > >
> > > > Cheers
> > > > --
> > > > David Robley
> > > >
> > > > "Wow!" barked Tom, with a bow.
> > > > Today is Prickle-Prickle, the 1st day of Discord in the YOLD 3176.
> > > >
> > > >
> > >
> > >
> > > You could store the end times in the database, and cron can run a script
> > > that will check each of these times to find any that are within x
> > > minutes that an email hasn't been sent out for. You'll need an extra
> > > field to indicate whether an email has been sent or not.
> > >
> > > Thanks,
> > > Ash
> > > http://www.ashleysheridan.co.uk
> > >
> > >
> > >
>
>
>
>
> Consider a cron script that runs every 10 minutes. You'll want
> to check the db for cars that are due to arrive within just
> over 10 minutes. The flag is there more for you own
> clarification that the email has been sent. What if the cron
> fails, or you restart your server, or the script your cron
> calls is just running a little slowly?
>
>
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
>
Just search for anything that has a date previous to the current
(indicating the car arrived)
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-uUhc90Ow9JEtOs2jYd3c--
Re: Re: Event Handling
am 15.03.2010 10:10:28 von Midhun Girish
--001636e0acccc12cdd0481d341e0
Content-Type: text/plain; charset=ISO-8859-1
ok so we have a script which checks if any cars have arrived within last 10
minutes... if yes, a mail will be send..... suppose the server fails for 30
minutes.... so when the cron comes next time, we will have to check for cars
which arrived within last 40 minutes and not 10.. right... so how will we
set a time limit in the script? its variable na.. but the flag is ok.. you
can send a mail to all db entries which have flag 0 and then update the flag
to 1.
Midhun Girish
Development Lead
MobAlive Technologies
On Mon, Mar 15, 2010 at 2:29 PM, Ashley Sheridan
wrote:
> On Mon, 2010-03-15 at 14:28 +0530, Midhun Girish wrote:
>
> hey ash,
>
> do we need both of those checks ? ie the time and the flag? i think they
> both do the same thing ie prevent duplicates.. am i right? and i think flag
> would be a more reliable method coz it will ensure that the email will be
> send even if the cron fails to execute for some time,....
>
> Midhun Girish
> Development Lead
> MobAlive Technologies
> Trivandrum
>
>
> On Mon, Mar 15, 2010 at 2:13 PM, Ashley Sheridan
> wrote:
>
> > On Mon, 2010-03-15 at 18:07 +1030, David Robley wrote:
> >
> > > Alex Major wrote:
> > >
> > > > Greetings all,
> > > >
> > > > I'm currently looking at building a web application, however I've run
> > into
> > > > an area of development I've not come across before. The web site in its
> > > > basic form allows users to send cars from a point and then the car will
> > > > arrive at another point. When the car is set on its way, the start
> > time,
> > > > travel duration and end time are all known and stored in a MySQL
> > database,
> > > > what I would like to happen is that an event is triggered on the server
> > at
> > > > the end time and then an e-mail is sent to the user. This should happen
> > > > regardless of whether someone is browsing the website or not.
> > > >
> > > > I don't believe that I'll be able to solely use PHP, I have spent the
> > > > afternoon trying to look at potential solutions but I have to admit
> > I've
> > > > drawn a blank. Google hasn't been helpful (64 pages so far), as any
> > > > searches related to "event handling" bring up a load of JavaScript
> > > > tutorials/help for 'onclick' events etc. I have searched through the
> > PHP
> > > > documentation and found "libevent"
> > > > (http://www.php.net/manual/en/book.libevent.php ), I don't believe
> > that is
> > > > what I require (although in all honesty the lack of documentation on it
> > > > means I'm quite in the dark as to its purpose). Another potential
> > > > candidate I came across was a PHP/Java bridge
> > > > (http://php-java-bridge.sourceforge.net/pjb/ ), whereby I could use
> > the
> > > > java virtual machine, register events with it and then callback PHP
> > > > scripts, although this seems extremely long winded.
> > > >
> > > > I was hoping that someone might have some experience with this kind of
> > > > issue and could point me in the right direction. I'm sure I've missed
> > > > something right in front of me.
> > > >
> > > > Alex.
> > >
> > > I think what you want is something to trigger a php script every
> > > $period-of-time; if your host supports it, cron is the means of executing
> > > an application at regular intervals down to a minute granularity. There
> > are
> > > some web-based cron services also, but they may not have the same
> > > granularity as a locally based cron.
> > >
> > >
> > > Cheers
> > > --
> > > David Robley
> > >
> > > "Wow!" barked Tom, with a bow.
> > > Today is Prickle-Prickle, the 1st day of Discord in the YOLD 3176.
> > >
> > >
> >
> >
> > You could store the end times in the database, and cron can run a script
> > that will check each of these times to find any that are within x
> > minutes that an email hasn't been sent out for. You'll need an extra
> > field to indicate whether an email has been sent or not.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
>
>
> Consider a cron script that runs every 10 minutes. You'll want to check the
> db for cars that are due to arrive within just over 10 minutes. The flag is
> there more for you own clarification that the email has been sent. What if
> the cron fails, or you restart your server, or the script your cron calls is
> just running a little slowly?
>
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
--001636e0acccc12cdd0481d341e0--
Re: Event Handling
am 15.03.2010 10:17:44 von Lester Caine
Alex Major wrote:
> I'm currently looking at building a web application, however I've run into
> an area of development I've not come across before. The web site in its
> basic form allows users to send cars from a point and then the car will
> arrive at another point. When the car is set on its way, the start time,
> travel duration and end time are all known and stored in a MySQL database,
The question HAS to be asked ... how do you know the actual travel time ;)
I think I would be expecting to have to enter something on arrival ....
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Event Handling
am 15.03.2010 10:41:04 von David Hutto
--0016e68ee1570692890481d3ae50
Content-Type: text/plain; charset=ISO-8859-1
On Mon, Mar 15, 2010 at 5:17 AM, Lester Caine wrote:
> Alex Major wrote:
>
>> I'm currently looking at building a web application, however I've run into
>> an area of development I've not come across before. The web site in its
>> basic form allows users to send cars from a point and then the car will
>> arrive at another point. When the car is set on its way, the start time,
>> travel duration and end time are all known and stored in a MySQL database,
>>
>
> The question HAS to be asked ... how do you know the actual travel time ;)
> I think I would be expecting to have to enter something on arrival ....
>
> --
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
You could judge the ETA if the shipping was tracked through GPS.
--0016e68ee1570692890481d3ae50--
Re: Event Handling
am 15.03.2010 12:31:34 von Jochem Maas
Op 3/15/10 8:24 AM, Midhun Girish schreef:
> Hi ,
> Just as David Hutto has said,What you need is the cronjob... Make a script
> say "check.php" which checks the db to see if any new entries are made...
> and if yes send the mail ...
>
> now using the cronjob feature in linux os(which will be provided as a
> service in your linux hosting cpanel), set a cronjob which calls the "
> http://www.yoursite.com/check.php" URL every minute.... now a trigger will
> be there every minute to the script and the emails will be send irrespective
> of whether anyone is browsing the site or not.... hope it is clear...
>
use cron - yes
have cron call a web URL - no, instead just call the script via the php CLI sapi,
e.g. a cmdline as follows in cron:
/usr/env php /path/to/your/check.php &> /dev/null
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Event Handling
am 15.03.2010 13:00:39 von David Hutto
--00163630f67337a2f40481d5a1dd
Content-Type: text/plain; charset=ISO-8859-1
On Mon, Mar 15, 2010 at 7:31 AM, Jochem Maas wrote:
> Op 3/15/10 8:24 AM, Midhun Girish schreef:
> > Hi ,
> > Just as David Hutto has said,What you need is the cronjob... Make a
> script
> > say "check.php" which checks the db to see if any new entries are made...
> > and if yes send the mail ...
> >
> > now using the cronjob feature in linux os(which will be provided as a
> > service in your linux hosting cpanel), set a cronjob which calls the "
> > http://www.yoursite.com/check.php" URL every minute.... now a trigger
> will
> > be there every minute to the script and the emails will be send
> irrespective
> > of whether anyone is browsing the site or not.... hope it is clear...
> >
>
> use cron - yes
> have cron call a web URL - no, instead just call the script via the php CLI
> sapi,
> e.g. a cmdline as follows in cron:
>
> /usr/env php /path/to/your/check.php &> /dev/null
>
I do believe removing the /dev/null will send error messages during the
building of the script, correct?
--00163630f67337a2f40481d5a1dd--
Re: Event Handling
am 15.03.2010 13:36:50 von Rene Veerman
+1..
Assuming you have had a 100% success rate of getting cars to their
destination on time for years;
If for some reason you can't set up a cron job, you _could_ have a
browser do the cron-ing for you; a page with an ajax script that kicks
off the check-for-recent-events script on the server.
granularity in milliseconds :)
if you have a windowing system on the server, you can run that browser
script on the server ;)
But if i were boss of such an operation, i'd have all cars outfitted
with gps, and have the gps monitoring app call up urls on my server to
indicate car status & location.
i agree this could be non-trivial, as something has to compare car
location gps coordinates to dropoff location coordinates, and if there
are many cars on the road, it's less than ideal to have the php server
do all the coordinate checking.
But there would be many benefits to a gps installation (with a "panic"
and "car-trouble" button in the vehicle).
RFID tags also might be a solution, one that could cost less to
install and operate.
On Mon, Mar 15, 2010 at 10:17 AM, Lester Caine wrote:
> Alex Major wrote:
>>
>> I'm currently looking at building a web application, however I've run into
>> an area of development I've not come across before. The web site in its
>> basic form allows users to send cars from a point and then the car will
>> arrive at another point. When the car is set on its way, the start time,
>> travel duration and end time are all known and stored in a MySQL database,
>
> The question HAS to be asked ... how do you know the actual travel time ;)
> I think I would be expecting to have to enter something on arrival ....
>
> --
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.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
Re: Event Handling
am 15.03.2010 13:38:51 von Jochem Maas
Op 3/15/10 12:00 PM, David Hutto schreef:
> On Mon, Mar 15, 2010 at 7:31 AM, Jochem Maas wrote:
>
>> Op 3/15/10 8:24 AM, Midhun Girish schreef:
>>> Hi ,
>>> Just as David Hutto has said,What you need is the cronjob... Make a
>> script
>>> say "check.php" which checks the db to see if any new entries are made...
>>> and if yes send the mail ...
>>>
>>> now using the cronjob feature in linux os(which will be provided as a
>>> service in your linux hosting cpanel), set a cronjob which calls the "
>>> http://www.yoursite.com/check.php" URL every minute.... now a trigger
>> will
>>> be there every minute to the script and the emails will be send
>> irrespective
>>> of whether anyone is browsing the site or not.... hope it is clear...
>>>
>>
>> use cron - yes
>> have cron call a web URL - no, instead just call the script via the php CLI
>> sapi,
>> e.g. a cmdline as follows in cron:
>>
>> /usr/env php /path/to/your/check.php &> /dev/null
>>
>
>
> I do believe removing the /dev/null will send error messages during the
> building of the script, correct?
>
the '&> /dev/null' redirects all output - I kind of make the assumption that the
script would be logging stuff to a file or something when in production.
so, yes, remove the redirection when your developing/testing the script.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Event Handling
am 15.03.2010 13:55:35 von Ashley Sheridan
--=-TnVTgDthaRlcjlMBen2S
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Mon, 2010-03-15 at 18:28 +0530, Midhun Girish wrote:
> rene "a page with an ajax script that kicks off the check-for-recent-events
> script on the server".. but that method is highly non reliable.... i dont
> think anyone will take that risk especially for an important web app....
> cron or any equivalent which runs on the server must be used instead of
> that..
>
>
> Midhun Girish
> Development Lead
> MobAlive Technologies
>
>
>
> On Mon, Mar 15, 2010 at 6:08 PM, Jochem Maas wrote:
>
> > Op 3/15/10 12:00 PM, David Hutto schreef:
> > > On Mon, Mar 15, 2010 at 7:31 AM, Jochem Maas
> > wrote:
> > >
> > >> Op 3/15/10 8:24 AM, Midhun Girish schreef:
> > >>> Hi ,
> > >>> Just as David Hutto has said,What you need is the cronjob... Make a
> > >> script
> > >>> say "check.php" which checks the db to see if any new entries are
> > made...
> > >>> and if yes send the mail ...
> > >>>
> > >>> now using the cronjob feature in linux os(which will be provided as a
> > >>> service in your linux hosting cpanel), set a cronjob which calls the "
> > >>> http://www.yoursite.com/check.php" URL every minute.... now a trigger
> > >> will
> > >>> be there every minute to the script and the emails will be send
> > >> irrespective
> > >>> of whether anyone is browsing the site or not.... hope it is clear...
> > >>>
> > >>
> > >> use cron - yes
> > >> have cron call a web URL - no, instead just call the script via the php
> > CLI
> > >> sapi,
> > >> e.g. a cmdline as follows in cron:
> > >>
> > >> /usr/env php /path/to/your/check.php &> /dev/null
> > >>
> > >
> > >
> > > I do believe removing the /dev/null will send error messages during the
> > > building of the script, correct?
> > >
> >
> > the '&> /dev/null' redirects all output - I kind of make the assumption
> > that the
> > script would be logging stuff to a file or something when in production.
> >
> > so, yes, remove the redirection when your developing/testing the script.
> >
> >
> >
I agree. Even setting a cron on a local computer to call home to a
server script would be preferable to Ajax calls.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-TnVTgDthaRlcjlMBen2S--
Re: Event Handling
am 15.03.2010 13:58:05 von Midhun Girish
--00504502bb37c6438b0481d66fdc
Content-Type: text/plain; charset=ISO-8859-1
rene "a page with an ajax script that kicks off the check-for-recent-events
script on the server".. but that method is highly non reliable.... i dont
think anyone will take that risk especially for an important web app....
cron or any equivalent which runs on the server must be used instead of
that..
Midhun Girish
Development Lead
MobAlive Technologies
On Mon, Mar 15, 2010 at 6:08 PM, Jochem Maas wrote:
> Op 3/15/10 12:00 PM, David Hutto schreef:
> > On Mon, Mar 15, 2010 at 7:31 AM, Jochem Maas
> wrote:
> >
> >> Op 3/15/10 8:24 AM, Midhun Girish schreef:
> >>> Hi ,
> >>> Just as David Hutto has said,What you need is the cronjob... Make a
> >> script
> >>> say "check.php" which checks the db to see if any new entries are
> made...
> >>> and if yes send the mail ...
> >>>
> >>> now using the cronjob feature in linux os(which will be provided as a
> >>> service in your linux hosting cpanel), set a cronjob which calls the "
> >>> http://www.yoursite.com/check.php" URL every minute.... now a trigger
> >> will
> >>> be there every minute to the script and the emails will be send
> >> irrespective
> >>> of whether anyone is browsing the site or not.... hope it is clear...
> >>>
> >>
> >> use cron - yes
> >> have cron call a web URL - no, instead just call the script via the php
> CLI
> >> sapi,
> >> e.g. a cmdline as follows in cron:
> >>
> >> /usr/env php /path/to/your/check.php &> /dev/null
> >>
> >
> >
> > I do believe removing the /dev/null will send error messages during the
> > building of the script, correct?
> >
>
> the '&> /dev/null' redirects all output - I kind of make the assumption
> that the
> script would be logging stuff to a file or something when in production.
>
> so, yes, remove the redirection when your developing/testing the script.
>
>
>
--00504502bb37c6438b0481d66fdc--
RE: Event Handling
am 15.03.2010 18:38:04 von Alex Major
Thanks to all for your help on this, it's been very interesting for me to
read.
The system needs to check arrivals in real time (give or take a second or
two), using a cron job every minute doesn't provide the real time checking I
would like.
However, when I then got to thinking about it, wouldn't this be an ideal
solution? I create a PHP script that loops for 60 seconds, checking the
database each second for new entries and processing them (meaning I get near
real time monitoring), and then have that PHP script called by a cron job
every minute.
The reason I think that could be a good solution for me, is that if the PHP
script crashed (for any reason), then at most it's 59 seconds before the
system kicks in again and begins processing all the queued arrivals. If I
coded a PHP script to loop infinitely processing things every second, it's
possible I wouldn't notice a crash for a considerable amount of time. The
proposed solution provides a good fail-safe, I think.
Does that solution seem sensible? Or overkill?
Thanks again for your help in this, it's quite novel for me.
-----Original Message-----
From: Ashley Sheridan [mailto:ash@ashleysheridan.co.uk]
Sent: 15 March 2010 12:56
To: Midhun Girish
Cc: Jochem Maas; David Hutto; php-general@lists.php.net; Alex Major
Subject: Re: [PHP] Event Handling
On Mon, 2010-03-15 at 18:28 +0530, Midhun Girish wrote:
> rene "a page with an ajax script that kicks off the
check-for-recent-events
> script on the server".. but that method is highly non reliable.... i dont
> think anyone will take that risk especially for an important web app....
> cron or any equivalent which runs on the server must be used instead of
> that..
>
>
> Midhun Girish
> Development Lead
> MobAlive Technologies
>
>
>
> On Mon, Mar 15, 2010 at 6:08 PM, Jochem Maas wrote:
>
> > Op 3/15/10 12:00 PM, David Hutto schreef:
> > > On Mon, Mar 15, 2010 at 7:31 AM, Jochem Maas
> > wrote:
> > >
> > >> Op 3/15/10 8:24 AM, Midhun Girish schreef:
> > >>> Hi ,
> > >>> Just as David Hutto has said,What you need is the cronjob... Make a
> > >> script
> > >>> say "check.php" which checks the db to see if any new entries are
> > made...
> > >>> and if yes send the mail ...
> > >>>
> > >>> now using the cronjob feature in linux os(which will be provided as
a
> > >>> service in your linux hosting cpanel), set a cronjob which calls the
"
> > >>> http://www.yoursite.com/check.php" URL every minute.... now a
trigger
> > >> will
> > >>> be there every minute to the script and the emails will be send
> > >> irrespective
> > >>> of whether anyone is browsing the site or not.... hope it is
clear...
> > >>>
> > >>
> > >> use cron - yes
> > >> have cron call a web URL - no, instead just call the script via the
php
> > CLI
> > >> sapi,
> > >> e.g. a cmdline as follows in cron:
> > >>
> > >> /usr/env php /path/to/your/check.php &> /dev/null
> > >>
> > >
> > >
> > > I do believe removing the /dev/null will send error messages during
the
> > > building of the script, correct?
> > >
> >
> > the '&> /dev/null' redirects all output - I kind of make the assumption
> > that the
> > script would be logging stuff to a file or something when in production.
> >
> > so, yes, remove the redirection when your developing/testing the script.
> >
> >
> >
I agree. Even setting a cron on a local computer to call home to a
server script would be preferable to Ajax calls.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Event Handling
am 15.03.2010 19:12:18 von Paul M Foster
On Mon, Mar 15, 2010 at 05:38:04PM -0000, Alex Major wrote:
> Thanks to all for your help on this, it's been very interesting for me to
> read.
>
> The system needs to check arrivals in real time (give or take a second or
> two), using a cron job every minute doesn't provide the real time checking I
> would like.
>
> However, when I then got to thinking about it, wouldn't this be an ideal
> solution? I create a PHP script that loops for 60 seconds, checking the
> database each second for new entries and processing them (meaning I get near
> real time monitoring), and then have that PHP script called by a cron job
> every minute.
>
> The reason I think that could be a good solution for me, is that if the PHP
> script crashed (for any reason), then at most it's 59 seconds before the
> system kicks in again and begins processing all the queued arrivals. If I
> coded a PHP script to loop infinitely processing things every second, it's
> possible I wouldn't notice a crash for a considerable amount of time. The
> proposed solution provides a good fail-safe, I think.
>
> Does that solution seem sensible? Or overkill?
>
> Thanks again for your help in this, it's quite novel for me.
I would think that the PHP CLI extension would need to be installed on
the server for this to work. I don't know that that's common. (I could
be completely wrong.)
I would recommend coding this in C, because it would use far less
resources.
Paul
--
Paul M. Foster
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Event Handling
am 16.03.2010 00:02:18 von Gabriel Sosa
Indeed. This is kinda offtopic but if you put a cron running with a
loop you will kill your server. I would recomend use libevent + ALARM
signal to process on a time basis. On the other hand using C would be
a nice aproach since you can put your script on an sleep mode until
the next alarm signal is trigered + less resources taken
Saludos
On 3/15/10, Paul M Foster wrote:
> On Mon, Mar 15, 2010 at 05:38:04PM -0000, Alex Major wrote:
>
>> Thanks to all for your help on this, it's been very interesting for me to
>> read.
>>
>> The system needs to check arrivals in real time (give or take a second or
>> two), using a cron job every minute doesn't provide the real time checking
>> I
>> would like.
>>
>> However, when I then got to thinking about it, wouldn't this be an ideal
>> solution? I create a PHP script that loops for 60 seconds, checking the
>> database each second for new entries and processing them (meaning I get
>> near
>> real time monitoring), and then have that PHP script called by a cron job
>> every minute.
>>
>> The reason I think that could be a good solution for me, is that if the
>> PHP
>> script crashed (for any reason), then at most it's 59 seconds before the
>> system kicks in again and begins processing all the queued arrivals. If I
>> coded a PHP script to loop infinitely processing things every second, it's
>> possible I wouldn't notice a crash for a considerable amount of time. The
>> proposed solution provides a good fail-safe, I think.
>>
>> Does that solution seem sensible? Or overkill?
>>
>> Thanks again for your help in this, it's quite novel for me.
>
> I would think that the PHP CLI extension would need to be installed on
> the server for this to work. I don't know that that's common. (I could
> be completely wrong.)
>
> I would recommend coding this in C, because it would use far less
> resources.
>
> Paul
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Sent from my mobile device
Gabriel Sosa
Si buscas resultados distintos, no hagas siempre lo mismo. - Einstein
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Event Handling
am 16.03.2010 00:02:34 von Ashley Sheridan
--=-hqXzvYhob7w8e1s9hUCh
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Mon, 2010-03-15 at 20:02 -0300, Gabriel Sosa wrote:
> Indeed. This is kinda offtopic but if you put a cron running with a
> loop you will kill your server. I would recomend use libevent + ALARM
> signal to process on a time basis. On the other hand using C would be
> a nice aproach since you can put your script on an sleep mode until
> the next alarm signal is trigered + less resources taken
>
> Saludos
>
> On 3/15/10, Paul M Foster wrote:
> > On Mon, Mar 15, 2010 at 05:38:04PM -0000, Alex Major wrote:
> >
> >> Thanks to all for your help on this, it's been very interesting for me to
> >> read.
> >>
> >> The system needs to check arrivals in real time (give or take a second or
> >> two), using a cron job every minute doesn't provide the real time checking
> >> I
> >> would like.
> >>
> >> However, when I then got to thinking about it, wouldn't this be an ideal
> >> solution? I create a PHP script that loops for 60 seconds, checking the
> >> database each second for new entries and processing them (meaning I get
> >> near
> >> real time monitoring), and then have that PHP script called by a cron job
> >> every minute.
> >>
> >> The reason I think that could be a good solution for me, is that if the
> >> PHP
> >> script crashed (for any reason), then at most it's 59 seconds before the
> >> system kicks in again and begins processing all the queued arrivals. If I
> >> coded a PHP script to loop infinitely processing things every second, it's
> >> possible I wouldn't notice a crash for a considerable amount of time. The
> >> proposed solution provides a good fail-safe, I think.
> >>
> >> Does that solution seem sensible? Or overkill?
> >>
> >> Thanks again for your help in this, it's quite novel for me.
> >
> > I would think that the PHP CLI extension would need to be installed on
> > the server for this to work. I don't know that that's common. (I could
> > be completely wrong.)
> >
> > I would recommend coding this in C, because it would use far less
> > resources.
> >
> > Paul
> >
> > --
> > Paul M. Foster
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
> Sent from my mobile device
>
> Gabriel Sosa
> Si buscas resultados distintos, no hagas siempre lo mismo. - Einstein
>
Using cron won't kill the server! Cron isn't only for scheduled tasks
but repeated ones as well and is perfect for running in the background
on a server all the time.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-hqXzvYhob7w8e1s9hUCh--