Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Apr 2007
    Location
    Somewhere on Earth
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Help me: I wanna develop an alarm script using PHP

    Hi, guys, how are you all?

    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!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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?
    Last edited by mlseim; 12-23-2007 at 07:11 PM.

  • #3
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by jmlworld View Post
    Hi, guys, how are you all?

    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 Code:
    <?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

  • Users who have thanked Jesuspwnt for this post:

    jmlworld (12-24-2007)

  • #4
    New to the CF scene
    Join Date
    Apr 2007
    Location
    Somewhere on Earth
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up

    Quote Originally Posted by Jesuspwnt View Post
    hmm...

    how about...
    PHP Code:
    <?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
    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 Code:
    <?php
    date_default_timezone_set
    ('Australia/Melbourne');
    // rest of code 
    ?>
    2- It displays time to time

    PHP Code:
    <?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
    Last edited by jmlworld; 12-24-2007 at 06:41 AM. Reason: Code highlighgting

  • #5
    New to the CF scene
    Join Date
    Apr 2007
    Location
    Somewhere on Earth
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    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.

  • #6
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    no problem, just glad i could be of assistance,

  • #7
    New to the CF scene
    Join Date
    Apr 2007
    Location
    Somewhere on Earth
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Jesuspwnt View Post
    no problem, just glad i could be of assistance,
    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?
    Code is property...

  • #8
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Make this line:
    Code:
     if(date("g") >= "8" && date("g") <= "9"){
    Into this:
    Code:
     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.
    Last edited by ZoundZ; 12-25-2007 at 05:12 PM.

  • #9
    New to the CF scene
    Join Date
    Apr 2007
    Location
    Somewhere on Earth
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by ZoundZ View Post
    Make this line:
    Code:
     if(date("g") >= "8" && date("g") <= "9"){
    Into this:
    Code:
     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.
    Code is property...

  • #10
    New to the CF scene
    Join Date
    Apr 2007
    Location
    Somewhere on Earth
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    OK, What about minutes, e.g. 8:20 or 3:10, I got challenge there
    Code is property...

  • #11
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    You do? Have you read the manual page for the date() function?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •