...

View Full Version : Help me: I wanna develop an alarm script using PHP



jmlworld
12-23-2007, 05:28 PM
Hi, guys, how are you all?

:confused: I'm trying to make a PHP alarm script that executes an alarm once a week. For example: I want to run a radio show banner which is active only when the radio show time comes online. In other words, an onlnie radio comes online once a week, and I want to develope a banner code that will show the radio when its the live broadcasting time, so everyone online can see it, and when the radio show ends, the banner deactivates automatically.

This is similar to an alarm script that shows something at specific time.

If the time in Melbourne is 5:00 PM and day = Sunday, it becomes active, until 7:00 pm, then it deactives itself.

Help me please, I know you guys, you are genius!

--------------
Cool Waitng 4 2night!

mlseim
12-23-2007, 07:07 PM
I'm sort of wondering this .... why not just check for it when someone
visits your site and/or refreshes the screen on your site?

Sort of like when someone sends you a private message on this forum.
If you refresh your screen, you'll get the "private message" alert at the top.

You can either check your server time, or go out to the radio website and
look for some indication by reading their HTML source. Display the banner
when your page loads if the time matches or the show is live.

========

Another Option ...

Using a CRON job.

Either with your webhost or a remote CRON service like this: http://www.webbasedcron.com/

The CRON runs a script on your server at a specifed time each week.

If you're not sure when the radio program starts, or the "live radio"
program is "hit or miss", you would need to have CRON run a script
on your server every 15 minutes or so. The script on your server
would somehow look for something on the radio site to see if the
show is live or not.

=================

In either case, if someone is viewing your website and does NOT refresh
their screen when the show starts, there is no way for you to "break-in"
and display the banner. Well, maybe with Javascripting you could do
something. Set a cookie with PHP and read it with Javascripting while
they are viewing the page. Kinda awkward maybe?

Jesuspwnt
12-23-2007, 11:30 PM
Hi, guys, how are you all?

:confused: I'm trying to make a PHP alarm script that executes an alarm once a week. For example: I want to run a radio show banner which is active only when the radio show time comes online. In other words, an onlnie radio comes online once a week, and I want to develope a banner code that will show the radio when its the live broadcasting time, so everyone online can see it, and when the radio show ends, the banner deactivates automatically.

This is similar to an alarm script that shows something at specific time.

If the time in Melbourne is 5:00 PM and day = Sunday, it becomes active, until 7:00 pm, then it deactives itself.

Help me please, I know you guys, you are genius!

--------------
Cool Waitng 4 2night!

hmm...

how about...


<?php
date_default_timezone_set('EST');
if(date("l") == "Sunday"){
if(date("g") >= "5" && date("g") <= "7"){
echo "<img src=http://example.com/images/radio_banner.jpg>";
}
}
?>


Let me know if it works

jmlworld
12-24-2007, 06:34 AM
hmm...

how about...


<?php
date_default_timezone_set('EST');
if(date("l") == "Sunday"){
if(date("g") >= "5" && date("g") <= "7"){
echo "<img src=http://example.com/images/radio_banner.jpg>";
}
}
?>


Let me know if it works
:thumbsup:Jesuspwnt, Thanx for your helpful reply, It works fine.

From now, your code helped me in three ways:

1- I can choose specific timezone since i have this function:



<?php
date_default_timezone_set('Australia/Melbourne');
// rest of code
?>

2- It displays time to time



<?php
if(date("l") == "Monday"){
if(date("g") >= "8" && date("g") <= "9"){
echo "Radio Show Banner IMG";
}
}
?>


3- It's short enough and useful

Thanx again, Jesuspwnt. You are codemaster!

JMLWorld

jmlworld
12-24-2007, 07:16 AM
I'm sort of wondering this .... why not just check for it when someone
visits your site and/or refreshes the screen on your site?

Sort of like when someone sends you a private message on this forum.
If you refresh your screen, you'll get the "private message" alert at the top.

You can either check your server time, or go out to the radio website and
look for some indication by reading their HTML source. Display the banner
when your page loads if the time matches or the show is live.

========

Another Option ...

Using a CRON job.

Either with your webhost or a remote CRON service like this: http://www.webbasedcron.com/

The CRON runs a script on your server at a specifed time each week.

If you're not sure when the radio program starts, or the "live radio"
program is "hit or miss", you would need to have CRON run a script
on your server every 15 minutes or so. The script on your server
would somehow look for something on the radio site to see if the
show is live or not.

=================

In either case, if someone is viewing your website and does NOT refresh
their screen when the show starts, there is no way for you to "break-in"
and display the banner. Well, maybe with Javascripting you could do
something. Set a cookie with PHP and read it with Javascripting while
they are viewing the page. Kinda awkward maybe?
Mlseim, Thanx sir. Jesuspwnt, resolved the problem and I'm using his code now. The reason I avoided using crons is that I'm using normal ad rotator in the frontpage of my website. Therefore the radio banner is mixed among other bannes displaying at the same spot randomly.

No matter if the visitor refreshes his browser or not, I may force them by making autorefresh script on the homepage in every 10 inactive minutes.

Thank you replaying.

Jesuspwnt
12-24-2007, 10:16 AM
no problem, just glad i could be of assistance, :D:D

jmlworld
12-25-2007, 05:01 PM
no problem, just glad i could be of assistance, :D:D
Hey, Jesuspwnt, One question please...

How Can I choose between AM and PM, for example I want my code to display at 5pm - 7pm, so i don't want it display the wrong time, like 5am - 7am...

How can i do that?

ZoundZ
12-25-2007, 05:08 PM
Make this line:

if(date("g") >= "8" && date("g") <= "9"){

Into this:

if(date("g") >= "8" && date("g") <= "9" && date("a") == "am"){

If you want it to go at 8 pm, change the am to the pm at the end of that line.

jmlworld
12-28-2007, 09:45 AM
Make this line:

if(date("g") >= "8" && date("g") <= "9"){

Into this:

if(date("g") >= "8" && date("g") <= "9" && date("a") == "am"){

If you want it to go at 8 pm, change the am to the pm at the end of that line.

Thanx alor ZoundZ, it works.

jmlworld
12-29-2007, 07:46 AM
OK, What about minutes, e.g. 8:20 or 3:10, I got challenge there

Inigoesdr
12-29-2007, 08:55 AM
You do? Have you read the manual page for the date() (http://php.net/date) function?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum