Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Looking for cgi script to change content based on time of day

Reply
Thread Tools

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

 
 
danny
Guest
Posts: n/a
 
      08-22-2006
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.

 
Reply With Quote
 
 
 
 
Matt Garrish
Guest
Posts: n/a
 
      08-22-2006

danny wrote:

> 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

 
Reply With Quote
 
 
 
 
axel@white-eagle.invalid.uk
Guest
Posts: n/a
 
      08-22-2006
danny <(E-Mail Removed)> wrote:
> 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

 
Reply With Quote
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      08-22-2006
danny wrote:
> 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.. ; #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


--
David Filmer (http://DavidFilmer.com)

 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      08-23-2006
danny <(E-Mail Removed)> wrote:

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



perldoc -f localtime


> Any help would be great.



You're welcome.


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error: Only Content controls are allowed directly in a content page that contains Content controls. hazz ASP .Net 6 06-09-2010 01:54 PM
Now.day and day(now) returning the wrong day! Andy ASP .Net 1 11-06-2008 12:20 PM
what's wrong calling a Perl/CGI script in Perl/CGI script under Tomcat server? kath Perl Misc 4 04-09-2007 09:21 PM
Python-cgi or Perl-cgi script doubt praba kar Python 1 07-30-2005 08:25 AM
looking for a script yo compute time left before a fixed dat and time ed Javascript 0 07-16-2003 06:23 PM



Advertisments