Welcome to WebProNews Breaking eBusiness and Search News
Advertise | Newsletter | Sitemap | News Feeds News Feed 
 WebProNews Search Part of the iEntry network iEntry inc. 

Simple Schedule

A.P. Lawrence
Expert Author
Published: 2006-03-07

WebProNews RSS Feed

I often get asked for web-based scheduling programs. I've done quite a few of them over the years, sometimes using scripts available from the web, but more often writing my own simply because I don't like modifying other people's code.

All of the calendar based schedules I've done start with the very simple files presented here. This base version doesn't have much flexibility: it lets you put in one note per day, and anyone who can access the schedule can overwrite that with new information. Obviously most businesses need additional features like multiple items, control of access, and probably much more. But this is the starting point we can build from.

As shown here, your web server needs to support SSI (Server Side Includes). Nowadays most of us would do this with php instead, but I still use the Perl methods because I'm old and stuck in my ways. Maybe I'll show a php version later.

The entire scheduling program consists of one web page. You can call it whatever you want, but the cgi-bin perl script needs to know where it can find it in your filesystem. The cgi script uses a Perl database to store scheduled events; that can be located anywhere also but of course has to be accessible by the user Apache is running as.

Note that the script serves two purposes: it is called to add items to the schedule and as a server side include to display scheduled events. In this version we have no pretty formatting or other niceties that almost certainly would be needed in a production version.

The script reads the web page and displays it when it is called for a specific day; this could have been done differently with a basically empty web page depending on a cgi script to provide the contents. However, this design lets unskilled people edit the web page without affecting the script.

The web page and associated script follow:

# sched.html
<html><head><title>Schedule</title></head><body bgcolor="lightgreen">

<script language="JavaScript">
<!-- yes this should look like this
function calendar() {
var now=today.getDate();
var tmonth=today.getMonth();
var tyear=today.getYear();
if (tyear < 1000) { tyear += 1900};
var d=new Date(year,month,"1");
var dd=new Date(year,nextmonth,"1");
var aday=(1000 * 60 * 60 * 24);
var ms=dd.getTime();
ms -= aday;
var lastday=dd.getDate();

var sd=d.getDay();

if (pmonth < 0) { pmonth=11; pyear--;}
if (nmonth > 11) {nmonth=0; nyear++;}
document.write("<h2>Calendar for ");
document.write(names[month] + " " + year);

document.write("<TABLE BORDER width="50%" cellwidth="14%" CELLpadding=8>");
var y=1;
for ( x=0; x < sd ; x++) {
var prinmonth=month+1;

for ( x=sd; x < lastday + sd; x++) {
document.write("<TD width="100" >" + "<a href="/cgi-bin/sched.pl?" +
prinmonth + "/" + y + "/" + year + "">" + y + "</a>" + "</td>");
if ((t % 7) == 0) { document.write("</TR><tr>")};

var argstr=location.search.substring(1,location.search.length);
var args= argstr.split('/');
var today=new Date();
if ( args[0] != "" ) {
  var rmonth=args[0];
  today=new Date(args[2],rmonth,args[1]);
var month=today.getMonth();
var nextmonth=month+1;
var nxmonth=month+2;
var prmonth=month;
var year=today.getYear();
if (year < 1000) { year += 1900};
var nxyear=year;
var pryear=year;
if (nextmonth > 12) {nextmonth=1};
if (nxmonth > 12) {nxmonth=1;nxyear++};
if (prmonth < 1) {prmonth=12;pryear--};
names=new Array("January","February","March","April","May","June","July",
var x=0;
document.write("<p><a href="/sched.html?");
document.write(prmonth + "/" + "01/" + pryear + "">Previous</a>");
document.write("<---------><a href="/sched.html?");
document.write(nxmonth + "/" + "01/" + nxyear + "">Next</a>");

// and this should look like this -->
<!--#include virtual="/cgi-bin/sched.pl" -->


use CGI qw(:standard);
use Time::Local;
$date=shift @ARGV;
$date=param('date') if not $date;
print "Content-TYPE: text/htmlnn";
if ($date) {
foreach (@stuff) {
print if not /<.body><.html>/;
$delete -= (3600 * 24 * 90);
@d=split ///,$date;
eval {$filedate=timelocal(0,0,0,$d[1],$d[0]-1,$d[2]-1900);} ;
dbmopen(%sched,"/home/schedules/schedules",0666) or print $!;
if (not $date ) {
    eval {$firstdate=timelocal(0,0,0,1,$d[4],$d[5]);} ;
    eval {$lastdate=timelocal(0,0,0,1,$d[4]+1,$d[5]+1);} ;
    print "<hr>";
$sched{$firstdate}=$schedule if $schedule;
print "<p>Listings for $date</p>";
foreach(sort keys %sched) {
  delete $sched{$_} if $_ < $delete;
  #delete $sched{$_};
  next if $_ < $firstdate;
  next if $_ > $lastdate;
  $now=localtime($_) if not $date;
  $now=~ s/00:00:00//;
  print "<br> $now $sched{$_}";

dbmclose %sched;
if ($date) {
print <<EOF;
<p><a href="/sched.html">Return to Full
<form method=post action="/cgi-bin/sched.pl">
<p>Add note for $date: <input type=text size=60 name="schedule">
<input type=hidden name="date" value="$date">
<p><input type=submit name="posting" value="Add">

print "</body></html>" if ($date);

That's all of it. It's simple, but can actually be easily expanded to much more complexity without a great deal of effort.

*Originally published at APLawrence.com

Add to | DiggThis | Yahoo! My Web


Receive Our Daily Email of Breaking eBusiness News

About the Author:
A.P. Lawrence provides SCO Unix and Linux consulting services http://www.pcunix.com

WebProNews RSS Feed

More Expert Articles Articles

Contact WebProNews


Targeted Information for Business
WebProNews is part of the iEntry network

Internet Business: Marketing: Small Business:
WebProNews MarketingNewz SmallBusinessNewz
WebProWorld AdvertisingDay PromoteNews
EcommNewz SalesNewz EntrepreneurNewz

Software: Search Engines: Web Design:
WebMasterFree Jayde B2B DesignNewz
NetworkingFiles SearchZA FlashNewz
SecurityConfig SearchNewz WebSiteNotes

Developer: IT Management: Security:
DevWebPro ITManagement SecurityProNews
DevNewz SysAdminNews SecurityConfig
TheDevWeb NetworkingFiles NetworkNewz

The iEntry Network consists of over 100 web publications reaching millions of Internet Professionals. Contact us to advertise.

 Advertise | Contact Us | Corporate | Newsletter | Sitemap | Submit an Article | News Feeds
 WebProNews is an iEntry, Inc. ® publication - $line) { echo $line ; } ?> All Rights Reserved
About WebProNews
WebProNews is the number one source for eBusiness News. Over 5 million eBusiness professionals read WebProNews and other iEntry business and tech publications.

WebProNews provides real-time coverage of internet business.

Free Email Newsletters:
WebProNews SearchNewz
WebProWorld DevWebPro
Marketing SecurityNews
Plus over 100 other newsletters!

Send me relevant info on products and services.

Ten most recent posts.

Featured Software

WebProNews in the News
View all recent mentions of WebProNews from around the world!

Recent Articles On ...
Google eBusiness
Yahoo Ask Jeeves
MSN Blogs
Search Engines Blogging
Affiliate Programs Marketing
eCommerce Advertising
eBay Sun Microsystems
AOL Adsense
Microsoft Adwords
Oracle IBM
Amazon Apple
SEO iPod
Adsense XBox
PR Adobe

iEntry.com WebProWorld RSS Feed WebProWorld Contact WebProNews Print Version Email a friend Bookmark us