homepage Welcome to WebmasterWorld Guest from 54.234.60.133
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
server side link timer script
rogie




msg:1273493
 1:40 pm on Jul 6, 2002 (gmt 0)

hello, i have a question please:
i'd like to make active a link on my page only at certain date n time (a link to a live streaming radio program), i've tried to place a javascript (below included) but the problem is that is going to recognize the client time, i'd like instead the script to recognize the server time to avoid the problem of time zone.

i wonder if there's a PHP script for doing that.

thank you in advance
rogie

here enclosed the java script to give you an idea:

<a href="radio.asf" onclick="return controllaData();">stream</a>

<script>
function controllaData() {
var today = new Date();
var start = new Date(2002,05,26,12,00,00,00);
var end = new Date(2002,05,26,12,05,00,00);
// month starts from 0 (january) upto 11 (december)
if (today<start today>end) {
alert("not broadcasting at the moment")
return false;
}
}

 

Knowles




msg:1273494
 10:30 pm on Jul 6, 2002 (gmt 0)

Here is what I have:

<?
$start=(mktime(24,0,0,07,06,2002));
$finish=(mktime(24,0,0,07,06,2002));

$date = getdate();

if ($start <= $date) {
echo ("Broadcasting right now!<br />");
}elseif ($finish >= $date) {
echo ("Broadcasting right now!<br />");
}else {
echo ("No broadcasting at the moment, sorry <br />");
}

?>

It always returns broadcasting but possibly someone can explain why. I am still working on it though.

Knowles




msg:1273495
 10:51 pm on Jul 6, 2002 (gmt 0)


<?
$shour = 17; //start hour
$ehour = 18; //end hour
$min = "";
$sec = "";
$month = 7; //month will have to be changed monthly
$day = 6; //day will have to be changed daily
$year = 2002; //will have to be changed yearly

$start=(mktime($shour,$min,$sec,$month,$day,$year));
$finish=(mktime($ehour,$min,$sec,$month,$day,$year));
$date = time();

if ($start <= $date && $finish >= $date) {
echo ("Broadcasting right now!<br />");
}else {
echo ("No broadcasting at the moment, sorry <br />");
}

?>

This works. But you have to change the date every day month or year depending on how often you broadcast. Simply change the broadcasting now to your link. Also change the BR tag to HTML 4.0 if you are not using XHTML.

Im going to try and get this cleaned up to work better we will see.

Knowles




msg:1273496
 10:57 pm on Jul 6, 2002 (gmt 0)

If a mod we be so nice as to delete my other two posts. Or at least the first one.

<?
$date = getdate();
$shour = 18; //start hour
$ehour = 19; //end hour
$min = "";
$sec = "";
$month = $date["mon"];
$day = $date["wday"];
$year = $date["year"];

$start=(mktime($shour,$min,$sec,$month,$day,$year));
$finish=(mktime($ehour,$min,$sec,$month,$day,$year));
$date = time();

if ($start <= $date && $finish >= $date) {
echo ("Broadcasting right now!<br />");
}else {
echo ("No broadcasting at the moment, sorry <br />");
}

?>

This is assuming you are doing an hour long broad cast. Let me know if that is not what the case is.

rogie




msg:1273497
 11:42 pm on Jul 6, 2002 (gmt 0)

<? $date = getdate();
$shour = 18; //start hour
$ehour = 19; //end hour
$min = "";
$sec = "";
$month = $date["mon"];
$day = $date["wday"];
$year = $date["year"];
$start=(mktime($shour,$min,$sec,$month,$day,$year)); $finish=(mktime($ehour,$min,$sec,$month,$day,$year)); $date = time(); if ($start <= $date && $finish >= $date) { echo ("Broadcasting right now!<br />"); }else { echo ("No broadcasting at the moment, sorry <br />"); } ?>

thank you knowles, but whatever time n date i put on, it keeps me saying: not broadcasting at the moment.
anyway, as per my request this is supposed to work on server time, isn't it?

Knowles




msg:1273498
 1:47 am on Jul 7, 2002 (gmt 0)

rogie sorry it was working for me but now its not for me. Ill work on it some more to see what I can figure out.

<added>
The issue seems to be the wday... when I changed to mday it started working

<?
$date = getdate();
$shour = 04; //start hour
$ehour = 05; //end hour
$min = "";
$sec = "";
$month = $date['mon'];
$day = $date['mday'];
$year = $date['year'];

$start=(mktime($shour,$min,$sec,$month,$day,$year));
$finish=(mktime($ehour,$min,$sec,$month,$day,$year));
$date = time();

if ($start <= $date && $finish >= $date) {
echo ("Broadcasting right now!<br />");
}else {
echo ("No broadcasting at the moment, sorry <br />");
}
?>

And yes it does pull of the server time. I tested on another server as well. It pulls the server time not the users time.

rogie




msg:1273499
 2:42 am on Jul 7, 2002 (gmt 0)

knowles, is working perfectly now but i have two questions:
-the date, how can i make the script working only at certain date(month-day-year)further to hours and mins.
-how can i show an hyperlink (e.g.: www.radio.asf)instead of the message "broadcasting right now" ?

thank you in advance for yr precious help.
rogie

Knowles




msg:1273500
 2:49 am on Jul 7, 2002 (gmt 0)

<?
$shour = 17; //start hour
$ehour = 18; //end hour
$min = "";
$sec = "";
$month = 7; //month will have to be changed monthly
$day = 6; //day will have to be changed daily
$year = 2002; //will have to be changed yearly

$start=(mktime($shour,$min,$sec,$month,$day,$year));
$finish=(mktime($ehour,$min,$sec,$month,$day,$year));
$date = time();

if ($start <= $date && $finish >= $date) {
echo ("<a href="radio.asf" onclick="return controllaData();">stream</a> <br />");
}else {
echo ("No broadcasting at the moment, sorry <br />");
}

?>
There you go. I wasnt sure on how often you broadcasted. This is going to require you to go in every time you finish a broad cast. Do you have any kind of set schedule? Once a month on the same day?
If so simply change the month and year back to the $date['mon'] and ['year'] and leave the date set to the actuall day of the month. Also readd this $date = getdate();. If its always changing youll just have to do an update to it all the time. It should be fairly customizable. If you like sticky me with your schedule and Ill fix it to that and send to you.

rogie




msg:1273501
 3:01 am on Jul 7, 2002 (gmt 0)

great! thank you so much knowles,
i should set up my schedule soon and the script looks fairly customizable so i believe there won't be any problem, i will let you know.
thank you very much.
rogie

p.s. do you like house music? if so send me yr address on pm and i will send you a mix cd of soulful and deep house.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved