Results 1 to 4 of 4

Thread: Cgi

  1. #1
    Join Date
    Mar 2004


    I have never worked with CGI before, and I have a cgi-bin now, so I need someone to give me step-by-step instructions of how to do the following please.

    I have several external style sheets all of which have different background images. I need to have a cgi script that automatically changes the script used every day, so that tomorrow, it will have a different design than today. How should I go about doing this?

    Please, any help would be GREATLY appreciated. Thank you.

  2. #2
    Join Date
    Jan 2003
    Here's a simple little Perl script that will do just as you wish.

    use strict;
    my $offset = 0;
    my $time = time + ($offset * 3600);
    my $day = qw/Sun Mon Tue Wed Thu Fri Sat/[(localtime($time))[6]];
    my %days = (Sun => 'sun.css',
                Mon => 'mon.css',
                Tue => 'tue.css',
                Wed => 'wed.css',
                Thu => 'thu.css',
                Fri => 'fri.css',
                Sat => 'sat.css');
    print "Content-Type: text/html\n\n";
    print qq`<link rel="stylesheet" type="text/css" href="$days{$day}" />`;

    ...just name the script rotate_css.pl, make sure the top line is the correct path to Perl on your server, put it in your cgi-bin, set permissions to 755 and replace the <link rel="stylesheet" type="text/css" href="mystyle.css"> in your pages with this:

    <!--#include virtual="/cgi-bin/rotate_css.pl" -->

    and make sure you rename your page(s) with a .shtml extension...

    also, adjust the sun.css, sat.css, etc to your own ...or rename them to match what I've written in the script...

    I've also added an offset variable, in case you want to adjust server time to your local time...just use a + or - number in hours to make the offset...

    -7 or +3

  3. #3
    Join Date
    Mar 2004
    Thanks so much! You are awesome.

  4. #4
    Join Date
    Jan 2003
    You're welcome...
    let me know if you have any questions on installation or configuration...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles