If you need to generate a calendar in
you do generate one. To generate an HTML file you specify
parameter. You specify the output file
parameter. Otherwise output will
go to standard output, e.g. the screen. You can specify
that a calendar be created for an entire year by putting
a two digit representation of the year at the end of the
command line. You can specify text to be used for both
the title of the webpage, i.e. what you commonly see in the top
line of your browser, and for the webpage heading by using
parameter. E.g. to create a file /tmp/mycalendar.html
for 2006 with a title and heading of "My 2006 Calendar", you
could use the command below. Remember, the case of the letters
you use for the parameter is significant. A
is not the same as a
pcal -H -o /tmp/mycalendar.html -C "2006 Calendar" 06
created by the above command. The program can also produce postscript
If a file exists by that name in the specified directory,
it will be overwritten. I've created a simple
generate-calendar, that takes 3 parameters, two of
which are optional, that will check if the output file exists.
If it does, it will prompt as to whether it should be overwritten.
Usage: generate-calendar -o output_file [-t title] [-y yy]
The script takes optional title and year arguments
-o specifies the HTML output file, e.g. /example/index.html
-t specifies the title and heading for the HTML file
If there is a space in the title enclose it in double quotes
-y specifies the year for the calendar, e.g. 06
If no year is specified, the calendar will be created only
for the current month
A companion program for pcal is
Lcal, which generates a graphical "lunar phase" calendar for an entire
Including Files in a Web Page with PHP
If you want to pull in code from other files into your webpages, you can
use the PHP
Suppose you want to include a header and footer file in each webpage you
create so that you don't have to type the same HTML code into each webpage
to get a standard header and footer for each webpage. You can create a
template directory beneath the root directory of your website and put two
files there: header.php and footer.php. The files can contain standard
HTML code, though of course you just have the snippets of code you need
not the <html>, <body>, and other tags you would have in a
For instance, suppose you just want to include a logo for your site
at the top of every page. You could create a header.php file with just
the following code.
<div id="header" align="center">
<img src="/images/mplogo-white.jpg" alt="MoonPoint Support Logo">
Let's suppose that you have two directories called examples and template
beneath the root directory for your website. You place all template files,
such as header.php, footer.php, menu.php, etc. in the template directory.
You want to place those in every webpage on your site. In the examples
directory you have a webpage titled mywebpage.php. To include the header
file in the page you could insert the following line at the appropriate place
in mywebpage.php. You would insert similar lines for any other files you
wished to include.
<?php include("../template/header.php"); ?>
Now, whenever you want to change the header file, you don't have to edit
every webpage on the site and make the needed changes. You just edit
But one caveat to this approach is that you have to keep in mind the
directory structure for the site every time you use the include function.
For instance you may have 8 levels of directories beneath the root directory
of your website. For a particular dirctory you might need to use
<?php include("../../../../../template/header.php"); ?>.
Keeping track of the number of dots and slashes you need can be a little
cumbersome. And, if you rearrange the directory structure for the site,
you may have to edit every webpage in the affected directories to put in
the appropriate number of dots and dashes for the new directory structure.
However, you could also insert the following code provided by
Paul Whitrow at
Include File Path Finder in the webpages instead.
Then instead of using PHP's include function to insert the header
file, you could place the incfile function in your webpages where you
want the header to appear, as below. Make sure you have inserted
the incfile function code shown above prior to the point where you call
<?php incfile("template/header.php"); ?>
You could use either
incfile("header.php");. The incfile function will check the
current directory, i.e. the one in which the webpage is located, for a
subdirectory named template with header.php within it if
you use the first form or will look for header.php within the current
directory if you use the second form. If it doesn't find the requested file,
then it will put a "../" in front of the directory path and try again.
If it still doesn't find header.php, it will prepend another "../" and try
again and so on.
So using including the incfile function in your webpages and calling it
to look for files you want to include will save you from figuring out
how many sets of dots and slashes you need to locate the file you want
to include and from having to edit webpages to modify the number of dots
and slashes should you alter the directory structure of your website.
One note of warning, though. The file you include must exist. Otherwise
your website visitors may see many repetitions of lines like the following
when they visit your webpages where you used incfile.
Warning: stat failed for ../../../../../../../../../../../../../../../../../../../.
in /www/mysite/examples/linux/test.php on line 22
PHP Include File Path Finder
By Paul Whitrow
September 28, 2005