FRIHOST • FORUMS • SEARCH • FAQ • TOS • BLOGS • COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Help me: I wanna develop an alarm script using PHP





jmlworld
Hi, guys, how are you all?

Question 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!
Manofgames
I presume you're using shoutcast?
http://www.hotscripts.com/search?q=shoutcast&cat=PHP&imageField.x=0&imageField.y=0

There are a few scripts which are what you seem to be wanting.
They will ping the shoutcast server. If the server returns the ping, then the server's online, so it will show one image.

It's more reliable than having to set the time manually.
Star Wars Fanatic
Well, that wouldn't be to hard, just use an if statement that checks the time:



Code:

$checktime = strtotime('Sun, 29 Feb 2007 17:00:00');
$othertime = strtotime('Sun, 29 Feb 2007 19:00:00');
$nowtime = time();
if($checktime < $nowtime < $othertime)  {
  // execute radio code here
}
else  {
  // don't show banner
}



That code isn't tested, but I think it will work, if anything, the time stuff might be wrong, but it gives you the basic idea of what you can do.

Edit: Or you could do what Manofgames suggested, it probably works better if you are using shoutcast...
jmlworld
Manofgames wrote:
I presume you're using shoutcast?
http://www.hotscripts.com/search?q=shoutcast&cat=PHP&imageField.x=0&imageField.y=0

There are a few scripts which are what you seem to be wanting.
They will ping the shoutcast server. If the server returns the ping, then the server's online, so it will show one image.

It's more reliable than having to set the time manually.


Manofgames, thanks for your hint, I couldn't understand show cast, as it’s a complex script, and I don't want to replace my whole website with showcast's. Only that I want is to run a banner that activates at the exact time that a radio show on another webserver activates, the script checks a predefined time and when its that exact time a banner shows up and stays online until the time approaches the end of the radio show. e.g. it shows up on every Sunday at 5:00pm and lasts until 8:00 pm, when its Sunday, 8:00 PM, the banner deactivates, so no one will see it again until the next Sunday.

I don't want to replace my CMS with newer one as I want to place the banner on the front page. So if I use showcast, its to replace my whole CMS.

Any suggestions else?
jmlworld
Star Wars Fanatic wrote:
Well, that wouldn't be to hard, just use an if statement that checks the time:

Code:

$checktime = strtotime('Sun, 29 Feb 2007 17:00:00');
$othertime = strtotime('Sun, 29 Feb 2007 19:00:00');
$nowtime = time();
if($checktime < $nowtime < $othertime)  {
  // execute radio code here
}
else  {
  // don't show banner
}



That code isn't tested, but I think it will work, if anything, the time stuff might be wrong, but it gives you the basic idea of what you can do.

Edit: Or you could do what Manofgames suggested, it probably works better if you are using shoutcast...


Thanx, Star Wars. Your code is useful, but it's one-time-use. Its only a fixed day and month based script.

But, I tried to use it like this way:

Code:

// Some code to assign variables with the server time and date

$checktime = strtotime('Sun, $currentDate $currentMonth $currentYear 17:00:00');
$othertime = strtotime('Sun, $currentDate $currentMonth $currentYear 19:00:00');
$nowtime = time();
if($checktime < $nowtime < $othertime)  {
  // execute radio code here
}
else  {
  // don't show banner
}


I thought this could help me if set properly. But its not functioning right now.

Any suggestions, please.
manav
i think u should run a cron job to display the banner specified by u...

frih supportd cron jobs....
jmlworld
manav wrote:
i think u should run a cron job to display the banner specified by u...

frih supportd cron jobs....


Sorry, I won't run the script on Frih, it's just for another web server, If anyone knows, pls help!
Diablosblizz
Any host that has CPanel or Directadmin (possibly others) will have Cron Jobs. A cron job would probably be best for you.
jmlworld
Diablosblizz wrote:
Any host that has CPanel or Directadmin (possibly others) will have Cron Jobs. A cron job would probably be best for you.


What I want is a PHP Code, that displays a banner on my site, e.g. I use PHP-Fusin and I want to creat a custom panel, so as to display banner if the time in Melbourne is 5:00 PM and day = Sunday, it becomes active, until 7:00 pm, then it deactivates itself.

Clear?

Please, where are the PHP geeks, developers and code masters?

Looking forward!
MrBlueSky
When you do this:

Code:

$checktime = strtotime('Sun, $currentDate $currentMonth $currentYear 17:00:00');
$othertime = strtotime('Sun, $currentDate $currentMonth $currentYear 19:00:00');
$nowtime = time();


it will propably not work because the values of $currentDate, etc. are not put into the string. You have to use double quotes:

Code:

$checktime = strtotime("Sun, $currentDate $currentMonth $currentYear 17:00:00");
$othertime = strtotime("Sun, $currentDate $currentMonth $currentYear 19:00:00");
$nowtime = time();


etc.

Try to see if that works.
jmlworld
Thanx MrBlueSky, but your code didn't work properly when i combined it with the rest of my code... I dunno if i was wrong with the way i arranged things

Your Code:

Code:

$checktime = strtotime("Sun, $currentDate $currentMonth $currentYear 17:00:00");
$othertime = strtotime("Sun, $currentDate $currentMonth $currentYear 19:00:00");
$nowtime = time();


The Result after I combined it with more code:

Code:

<?php

// code to execute the current time and date

$nowArray = getdate();
$cDate = $nowArray[date];
$cMonth = $nowArray[mon];
$cYear = $nowArray[year];

$checktime = strtotime("Tuesday, $cDate $cMonth $cYear 17:00:00");
$othertime = strtotime("Tuesday, $cDate $cMonth $cYear 18:00:00");
$nowtime = time();

if($checktime < $nowtime < $othertime)  {

// a code to display the radio show banner 
echo "radio is on";
}
else  {

// display offline message
  echo "radio is off";
}

?>


Please determine what's wrong with the above code...

Thanks alot
jmlworld
Still waiting you guys, are tired with my funny post? Admins, Moderators, Fans, Frihosters, where are you all? Rolling Eyes
Diablosblizz
jmlworld wrote:
Still waiting you guys, are tired with my funny post? Admins, Moderators, Fans, Frihosters, where are you all? Rolling Eyes


It would be most helpful if you tell us what type of error you are getting before we can assist you.
jmlworld
Diablosblizz wrote:
jmlworld wrote:
Still waiting you guys, are tired with my funny post? Admins, Moderators, Fans, Frihosters, where are you all? Rolling Eyes


It would be most helpful if you tell us what type of error you are getting before we can assist you.


Very Happy Thanx all, but I've already resolved the problem, may be it's useful to show you the code, here it is:

Code:

<?php
date_default_timezone_set('Australia/Melbourne');
if(date("l") == "Monday"){
 if(date("g") >= "5" && date("g") <= "7"){
  echo "Radio X is playing live <a href='http://radio.localhost/?radio=live' target='_blank'>Click here to listen</a>";
  }
  else{
  echo "Radio X is playing live <a href='http://radio.localhost/?radio=offline' target='_blank'>Click here to see the schedule</a>";
 
 }
}
?>

Nice heh?
Related topics
[tutor] How to protect images without htaccess using PHP
Using PHP
Includ Images using PHP.
How to start using PHP? Help!
I am trying to build a contact form using php and flash
Communicating between web pages
PHP Nuke Help
PHP Username And Password Login Script, Using those to creat
Using php to change content of a .txt
Access Java 1.6 Web service using php client
Help: Need a review script for PHP
How to code a simple blog using PHP
"Drop Down List Box" Using PHP and MySql
Help displaying pdfs using PHP
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.