Looking for cgi script to change content based on time of day

D

danny

I'm doing a website for a radio station. They want to display an image
of the dj that is presenting at a certain time on the home page. In
other words they want a script that displays a certain image depending
on the day of the week and the time of day. Their weekly schedule
doesn't change. Any help would be great.

Thank you,
Danny.
 
M

Matt Garrish

danny said:
I'm doing a website for a radio station. They want to display an image
of the dj that is presenting at a certain time on the home page. In
other words they want a script that displays a certain image depending
on the day of the week and the time of day. Their weekly schedule
doesn't change. Any help would be great.

This isn't the place to ask for pre-written code. There's jobs.perl.org
if you're in over your head and need a contractor, otherwise if you''d
explain why calling localtime and displaying an image based on the
output is causing you problems, and show what you've tried so far,
someone might be willing to help you with it.

Matt
 
A

axel

danny said:
I'm doing a website for a radio station. They want to display an image
of the dj that is presenting at a certain time on the home page. In
other words they want a script that displays a certain image depending
on the day of the week and the time of day. Their weekly schedule
doesn't change. Any help would be great.

What are you willing to pay for such a script?

This is not a place to expect people to do your work for free.
If you cannot even make an effort yourself, you are in the wrong job.

Axel
 
U

usenet

danny said:
they want a script that displays a certain image depending
on the day of the week and the time of day.

The "trick" is to decide how you will tell your program which DJ is
working which day/hour. There are LOTS of ways you can do that.

If your schedule is not very granular (ie, everything can be defined in
whole hours) you can incorporate something like this, which sacrifices
a small amount of efficiency (but over a very tiny data structure) for
something that's easy to define and easy to override for oddball
schedule changes. This creates a matrix (7 days x 24 hourly time
slots):

#!/usr/bin/perl
use strict; use warnings;
use CGI qw{ img };

my %dj_img;

foreach my $day(1..5) { #weekday schedule
map {$dj_img{$day}{$_} = 'fatguy.jpg' } ( 0.. 5); #Fred- m'night-6
map {$dj_img{$day}{$_} = 'barney.jpg' } ( 6.. 8); #Barney-morning
map {$dj_img{$day}{$_} = 'wilma.jpg' } ( 9..15); #Wilma- midday
map {$dj_img{$day}{$_} = 'betty.jpg' } (16..19); #Betty-afternoon
map {$dj_img{$day}{$_} = 'redhead.jpg' } (20..23); #Pebbles- night
}

foreach my $day(0,6) { #weekend schedule
map {$dj_img{$day}{$_} = 'bambam.jpg'} (0..9); #BamBam-w'end am
#etc.
}

# Now somewhere in our CGI script, we print the image tags:
print img( { -src => $dj_img{(localtime)[6]}{(localtime)[2]} });
# DAY HOUR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top