...

View Full Version : Tricky Php Timecode Issue for Radio Site - Willing to Pay for Solution



willvbcfc
12-09-2010, 04:13 PM
Hey all. This could be a long, but rewarding riddle to crack for you coders out there. I'm willing to offer whoever cracks it 20 ($31 or 23) which I'll transfer via paypal upon completion.

I'm currently making a site for my University's radio station and I'm doing it by using some advanced wordpress techniques and modding the hell out of plugins. Just to let you know now, I'm not a computer science student, but I have good self learned knowledge of html/css, but my php is a little sketchy.

Therefore, I've got a bit stuck on one particular feature. I am required to make an 'On Air Now' tab which displays the name and image of the show that is currently on air.

At the moment, I have the following code working well:


<?php
date_default_timezone_set('Europe/London');
$h = date('G'); //set variable $h to the hour of the day
$d = date('w'); //set variable $d to the day of the week.
$year = date('Y'); //set variable $year to the current year


//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.
//Enter show details for each hour within the parses.

// MON SCHEDULE
if ($d == 1 && $h >= 0 && $h < 1) { $showname = ' '; }
else if ($d == 1 && $h >= 1 && $h < 2) { $showname = ' '; }
else if ($d == 1 && $h >= 2 && $h < 3) { $showname = ' '; }
else if ($d == 1 && $h >= 3 && $h < 4) { $showname = ' '; }
else if ($d == 1 && $h >= 4 && $h < 5) { $showname = ' '; }
else if ($d == 1 && $h >= 5 && $h < 6) { $showname = ' '; }
else if ($d == 1 && $h >= 6 && $h < 7) { $showname = ' '; }
else if ($d == 1 && $h >= 7 && $h < 8) { $showname = ' '; }
else if ($d == 1 && $h >= 8 && $h < 9) { $showname = ' '; }
else if ($d == 1 && $h >= 9 && $h < 10) { $showname = ' '; }
else if ($d == 1 && $h >= 10 && $h < 11) { $showname = ' '; }
else if ($d == 1 && $h >= 11 && $h < 12) { $showname = ' '; }
else if ($d == 1 && $h >= 12 && $h < 13) { $showname = ' '; }
else if ($d == 1 && $h >= 13 && $h < 14) { $showname = ' '; }
else if ($d == 1 && $h >= 14 && $h < 15) { $showname = ' '; }
else if ($d == 1 && $h >= 15 && $h < 16) { $showname = ' '; }
else if ($d == 1 && $h >= 16 && $h < 17) { $showname = ' '; }
else if ($d == 1 && $h >= 17 && $h < 18) { $showname = ' '; }
else if ($d == 1 && $h >= 18 && $h < 19) { $showname = ' '; }
else if ($d == 1 && $h >= 19 && $h < 20) { $showname = ' '; }
else if ($d == 1 && $h >= 20 && $h < 21) { $showname = ' '; }
else if ($d == 1 && $h >= 21 && $h < 22) { $showname = ' '; }
else if ($d == 1 && $h >= 22 && $h < 23) { $showname = ' '; }
else if ($d == 1 && $h >= 23 && $h < 0) { $showname = ' '; }

// TUES SCHEDULE
if ($d == 2 && $h >= 0 && $h < 1) { $showname = ' '; }
else if ($d == 2 && $h >= 1 && $h < 2) { $showname = ' '; }
else if ($d == 2 && $h >= 2 && $h < 3) { $showname = ' '; }
else if ($d == 2 && $h >= 3 && $h < 4) { $showname = ' '; }
else if ($d == 2 && $h >= 4 && $h < 5) { $showname = ' '; }
else if ($d == 2 && $h >= 5 && $h < 6) { $showname = ' '; }
else if ($d == 2 && $h >= 6 && $h < 7) { $showname = ' '; }
else if ($d == 2 && $h >= 7 && $h < 8) { $showname = ' '; }
else if ($d == 2 && $h >= 8 && $h < 9) { $showname = ' '; }
else if ($d == 2 && $h >= 9 && $h < 10) { $showname = ' '; }
else if ($d == 2 && $h >= 10 && $h < 11) { $showname = ' '; }
else if ($d == 2 && $h >= 11 && $h < 12) { $showname = ' '; }
else if ($d == 2 && $h >= 12 && $h < 13) { $showname = ' '; }
else if ($d == 2 && $h >= 13 && $h < 14) { $showname = ' '; }
else if ($d == 2 && $h >= 14 && $h < 15) { $showname = ' '; }
else if ($d == 2 && $h >= 15 && $h < 16) { $showname = ' '; }
else if ($d == 2 && $h >= 16 && $h < 17) { $showname = ' '; }
else if ($d == 2 && $h >= 17 && $h < 18) { $showname = ' '; }
else if ($d == 2 && $h >= 18 && $h < 19) { $showname = ' '; }
else if ($d == 2 && $h >= 19 && $h < 20) { $showname = ' '; }
else if ($d == 2 && $h >= 20 && $h < 21) { $showname = ' '; }
else if ($d == 2 && $h >= 21 && $h < 22) { $showname = ' '; }
else if ($d == 2 && $h >= 22 && $h < 23) { $showname = ' '; }
else if ($d == 2 && $h >= 23 && $h < 0) { $showname = ' '; }

// WEDS SCHEDULE
if ($d == 3 && $h >= 0 && $h < 1) { $showname = ' '; }
else if ($d == 3 && $h >= 1 && $h < 2) { $showname = ' '; }
else if ($d == 3 && $h >= 2 && $h < 3) { $showname = ' '; }
else if ($d == 3 && $h >= 3 && $h < 4) { $showname = ' '; }
else if ($d == 3 && $h >= 4 && $h < 5) { $showname = ' '; }
else if ($d == 3 && $h >= 5 && $h < 6) { $showname = ' '; }
else if ($d == 3 && $h >= 6 && $h < 7) { $showname = ' '; }
else if ($d == 3 && $h >= 7 && $h < 8) { $showname = ' '; }
else if ($d == 3 && $h >= 8 && $h < 9) { $showname = ' '; }
else if ($d == 3 && $h >= 9 && $h < 10) { $showname = ' '; }
else if ($d == 3 && $h >= 10 && $h < 11) { $showname = ' '; }
else if ($d == 3 && $h >= 11 && $h < 12) { $showname = ' '; }
else if ($d == 3 && $h >= 12 && $h < 13) { $showname = ' '; }
else if ($d == 3 && $h >= 13 && $h < 14) { $showname = ' '; }
else if ($d == 3 && $h >= 14 && $h < 15) { $showname = ' '; }
else if ($d == 3 && $h >= 15 && $h < 16) { $showname = ' '; }
else if ($d == 3 && $h >= 16 && $h < 17) { $showname = ' '; }
else if ($d == 3 && $h >= 17 && $h < 18) { $showname = ' '; }
else if ($d == 3 && $h >= 18 && $h < 19) { $showname = ' '; }
else if ($d == 3 && $h >= 19 && $h < 20) { $showname = ' '; }
else if ($d == 3 && $h >= 20 && $h < 21) { $showname = ' '; }
else if ($d == 3 && $h >= 21 && $h < 22) { $showname = ' '; }
else if ($d == 3 && $h >= 22 && $h < 23) { $showname = ' '; }
else if ($d == 3 && $h >= 23 && $h < 0) { $showname = ' '; }

// THURS SCHEDULE
if ($d == 4 && $h >= 0 && $h < 1) { $showname = ' '; }
else if ($d == 4 && $h >= 1 && $h < 2) { $showname = ' '; }
else if ($d == 4 && $h >= 2 && $h < 3) { $showname = ' '; }
else if ($d == 4 && $h >= 3 && $h < 4) { $showname = ' '; }
else if ($d == 4 && $h >= 4 && $h < 5) { $showname = ' '; }
else if ($d == 4 && $h >= 5 && $h < 6) { $showname = ' '; }
else if ($d == 4 && $h >= 6 && $h < 7) { $showname = ' '; }
else if ($d == 4 && $h >= 7 && $h < 8) { $showname = ' '; }
else if ($d == 4 && $h >= 8 && $h < 9) { $showname = ' '; }
else if ($d == 4 && $h >= 9 && $h < 10) { $showname = ' '; }
else if ($d == 4 && $h >= 10 && $h < 11) { $showname = ' '; }
else if ($d == 4 && $h >= 11 && $h < 12) { $showname = ' '; }
else if ($d == 4 && $h >= 12 && $h < 13) { $showname = ' '; }
else if ($d == 4 && $h >= 13 && $h < 14) { $showname = 'Test'; }
else if ($d == 4 && $h >= 14 && $h < 15) { $showname = ' '; }
else if ($d == 4 && $h >= 15 && $h < 16) { $showname = ' '; }
else if ($d == 4 && $h >= 16 && $h < 17) { $showname = ' '; }
else if ($d == 4 && $h >= 17 && $h < 18) { $showname = ' '; }
else if ($d == 4 && $h >= 18 && $h < 19) { $showname = ' '; }
else if ($d == 4 && $h >= 19 && $h < 20) { $showname = ' '; }
else if ($d == 4 && $h >= 20 && $h < 21) { $showname = ' '; }
else if ($d == 4 && $h >= 21 && $h < 22) { $showname = ' '; }
else if ($d == 4 && $h >= 22 && $h < 23) { $showname = ' '; }
else if ($d == 4 && $h >= 23 && $h < 0) { $showname = ' '; }

// FRI SCHEDULE
if ($d == 5 && $h >= 0 && $h < 1) { $showname = ' '; }
else if ($d == 5 && $h >= 1 && $h < 2) { $showname = ' '; }
else if ($d == 5 && $h >= 2 && $h < 3) { $showname = ' '; }
else if ($d == 5 && $h >= 3 && $h < 4) { $showname = ' '; }
else if ($d == 5 && $h >= 4 && $h < 5) { $showname = ' '; }
else if ($d == 5 && $h >= 5 && $h < 6) { $showname = ' '; }
else if ($d == 5 && $h >= 6 && $h < 7) { $showname = ' '; }
else if ($d == 5 && $h >= 7 && $h < 8) { $showname = ' '; }
else if ($d == 5 && $h >= 8 && $h < 9) { $showname = ' '; }
else if ($d == 5 && $h >= 9 && $h < 10) { $showname = ' '; }
else if ($d == 5 && $h >= 10 && $h < 11) { $showname = ' '; }
else if ($d == 5 && $h >= 11 && $h < 12) { $showname = ' '; }
else if ($d == 5 && $h >= 12 && $h < 13) { $showname = ' '; }
else if ($d == 5 && $h >= 13 && $h < 14) { $showname = ' '; }
else if ($d == 5 && $h >= 14 && $h < 15) { $showname = ' '; }
else if ($d == 5 && $h >= 15 && $h < 16) { $showname = ' '; }
else if ($d == 5 && $h >= 16 && $h < 17) { $showname = ' '; }
else if ($d == 5 && $h >= 17 && $h < 18) { $showname = ' '; }
else if ($d == 5 && $h >= 18 && $h < 19) { $showname = ' '; }
else if ($d == 5 && $h >= 19 && $h < 20) { $showname = ' '; }
else if ($d == 5 && $h >= 20 && $h < 21) { $showname = ' '; }
else if ($d == 5 && $h >= 21 && $h < 22) { $showname = ' '; }
else if ($d == 5 && $h >= 22 && $h < 23) { $showname = ' '; }
else if ($d == 5 && $h >= 23 && $h < 0) { $showname = ' '; }


// SAT SCHEDULE
if ($d == 6 && $h >= 0 && $h < 1) { $showname = ' '; }
else if ($d == 6 && $h >= 1 && $h < 2) { $showname = ' '; }
else if ($d == 6 && $h >= 2 && $h < 3) { $showname = ' '; }
else if ($d == 6 && $h >= 3 && $h < 4) { $showname = ' '; }
else if ($d == 6 && $h >= 4 && $h < 5) { $showname = ' '; }
else if ($d == 6 && $h >= 5 && $h < 6) { $showname = ' '; }
else if ($d == 6 && $h >= 6 && $h < 7) { $showname = ' '; }
else if ($d == 6 && $h >= 7 && $h < 8) { $showname = ' '; }
else if ($d == 6 && $h >= 8 && $h < 9) { $showname = ' '; }
else if ($d == 6 && $h >= 9 && $h < 10) { $showname = ' '; }
else if ($d == 6 && $h >= 10 && $h < 11) { $showname = ' '; }
else if ($d == 6 && $h >= 11 && $h < 12) { $showname = ' '; }
else if ($d == 6 && $h >= 12 && $h < 13) { $showname = ' '; }
else if ($d == 6 && $h >= 13 && $h < 14) { $showname = ' '; }
else if ($d == 6 && $h >= 14 && $h < 15) { $showname = ' '; }
else if ($d == 6 && $h >= 15 && $h < 16) { $showname = ' '; }
else if ($d == 6 && $h >= 16 && $h < 17) { $showname = ' '; }
else if ($d == 6 && $h >= 17 && $h < 18) { $showname = ' '; }
else if ($d == 6 && $h >= 18 && $h < 19) { $showname = ' '; }
else if ($d == 6 && $h >= 19 && $h < 20) { $showname = ' '; }
else if ($d == 6 && $h >= 20 && $h < 21) { $showname = ' '; }
else if ($d == 6 && $h >= 21 && $h < 22) { $showname = ' '; }
else if ($d == 6 && $h >= 22 && $h < 23) { $showname = ' '; }
else if ($d == 6 && $h >= 23 && $h < 0) { $showname = ' '; }

// SUN SCHEDULE
if ($d == 0 && $h >= 0 && $h < 1) { $showname = ' '; }
else if ($d == 0 && $h >= 1 && $h < 2) { $showname = ' '; }
else if ($d == 0 && $h >= 2 && $h < 3) { $showname = ' '; }
else if ($d == 0 && $h >= 3 && $h < 4) { $showname = ' '; }
else if ($d == 0 && $h >= 4 && $h < 5) { $showname = ' '; }
else if ($d == 0 && $h >= 5 && $h < 6) { $showname = ' '; }
else if ($d == 0 && $h >= 6 && $h < 7) { $showname = ' '; }
else if ($d == 0 && $h >= 7 && $h < 8) { $showname = ' '; }
else if ($d == 0 && $h >= 8 && $h < 9) { $showname = ' '; }
else if ($d == 0 && $h >= 9 && $h < 10) { $showname = ' '; }
else if ($d == 0 && $h >= 10 && $h < 11) { $showname = ' '; }
else if ($d == 0 && $h >= 11 && $h < 12) { $showname = ' '; }
else if ($d == 0 && $h >= 12 && $h < 13) { $showname = ' '; }
else if ($d == 0 && $h >= 13 && $h < 14) { $showname = ' '; }
else if ($d == 0 && $h >= 14 && $h < 15) { $showname = ' '; }
else if ($d == 0 && $h >= 15 && $h < 16) { $showname = ' '; }
else if ($d == 0 && $h >= 16 && $h < 17) { $showname = ' '; }
else if ($d == 0 && $h >= 17 && $h < 18) { $showname = ' '; }
else if ($d == 0 && $h >= 18 && $h < 19) { $showname = ' '; }
else if ($d == 0 && $h >= 19 && $h < 20) { $showname = ' '; }
else if ($d == 0 && $h >= 20 && $h < 21) { $showname = ' '; }
else if ($d == 0 && $h >= 21 && $h < 22) { $showname = ' '; }
else if ($d == 0 && $h >= 22 && $h < 23) { $showname = ' '; }
else if ($d == 0 && $h >= 23 && $h < 0) { $showname = ' '; }


echo ''.$showname.'';

?>

Simple, yes? However, as I am to be leaving Uni at the end of this academic year, I can't count on the fact that the future site maintainers will be able to edit the php, which either way would be a long and boring process. Therefore, I need to automate the script to recognise which show is on air.

All of my show pages are defined by wordpress categories and I'm using a category meta plugin to display extra data.

Therefore, I presume I need to firstly query my show categories (all are a child of category ID 3) by the day and timecode meta that I have defined using the meta plugin:


get_terms_meta($category->term_id, 'dayvalue');

get_terms_meta($category->term_id, 'timecodestart');

get_terms_meta($category->term_id, 'timecodeend');

Then I need to use a function to say IF $dayvalue=1 (for Monday, 2 for Tuesday, 3 for Wednesday etc & 0 for Sunday) and if timecode start is, for example, >12 && <13 ...then it displays its category name and $categoryimage for that particular show.

I'll need to put that same code within the parses for every hour of every day.

That's the logic - I just don't know how to code it and there really isn't much about this area on the net!

As I said, I'm willing to offer the successful person a bit of money because this is quite a crucial part of my project that needs to be completed!

Either respond here or contact me on willvbcfc@gmail.com.

djm0219
12-09-2010, 04:46 PM
Right off the bat those details really need to be in a database table and not in the PHP file. There is a LOT of room for error having people update the script itself.

willvbcfc
12-09-2010, 05:01 PM
Right off the bat those details really need to be in a database table and not in the PHP file. There is a LOT of room for error having people update the script itself.

Mmh that would be better I agree, I can't really do that because of the wordpress limitations. I want it to be simple for people to create categories for each show, denote the time & images using meta data and from there they can post blog posts within them...

djm0219
12-09-2010, 05:54 PM
Why is WordPress a limitation? WordPress already has and uses a database so all you'd need is an additional table, a function to get the data out based on the current date and time and a "back end" page for adding and modifying the table with the details. Unless I'm really missing something in what you've described.

MattF
12-09-2010, 06:12 PM
get_terms_meta($category->term_id, 'dayvalue');

get_terms_meta($category->term_id, 'timecodestart');

get_terms_meta($category->term_id, 'timecodeend');


Post the output from one of those combinations.

willvbcfc
12-09-2010, 06:17 PM
Why is WordPress a limitation? WordPress already has and uses a database so all you'd need is an additional table, a function to get the data out based on the current date and time and a "back end" page for adding and modifying the table with the details. Unless I'm really missing something in what you've described.

Okay, that sounds promising - but slightly past my level of expertise.

If you could loosely outline what needs to be done, I'll search around google like a maniac and try and figure it out!

willvbcfc
12-09-2010, 06:38 PM
Post the output from one of those combinations

What do you mean by this?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum