PHPiCalendar

From DreamHost

Jump to: navigation, search

Contents

About PHPiCalendar

From the PHPiCalendar documentation wiki:

"PHP iCalendar is a PHP-based iCalendar file viewer/parser to display iCalendar files in a Web browser. Its based on the IETF spec (http://www.ietf.org/rfc/rfc2445.txt). It displays iCalendar files in a nice logical, clean manner with day, week, month, and year navigation. It is available in 13 languages and includes support for printing, searching and RSS news feeds."

This will be a step-by-step tutorial to get PHPiCalendar (http://phpicalendar.net) working on Dreamhost with either a WebDAV directory enabled to put your calendars inside, or iCalendar+FTP if you can't get the WebDAV solution working.

There are actually two ways of getting this to work. The first requires only configuration on the server side and works for most calendar clients. If you use Apple's iCal and have trouble getting it to work, there is an iCal-only solution which doesn't require much on the server side and only a small plugin on the client side.

Server-side Cross-platform Configuration

Installation

  1. Download and unzip the latest version of PHPiCalendar from SourceForge (2.31 as of 2009-03-01)
  2. To get things running quickly, you may just want to simply create a subfolder in your main domain, i.e. http://www.yourdomain.com/icalendar/. If you would like, create a subdomain where you want to view your calendars using the Control Panel -> Domains section. (i.e. http://ical.yourdomain.com) Note that this will take some time to activate, so be patient!
  3. Make sure your domain does NOT have "Run PHP as CGI" set. To see if this is correct, to to Control Panel -> Domains -> Manage Domains
  4. Click "Edit" on the domain you'll be installing PHPiCalendar into
  5. Uncheck "Run PHP as CGI?"
  6. Click "change Fully Hosted Settings Now!"
  7. Once your domain or folder has been created, upload the files to
/home/yourusername/yourdomain.com/icalendar/
or
/home/yourusername/ical.yourdomain.com/

After you upload the files, you'll need to change permissions on the files to 755. From the command line, you'll enter

chmod -R 755 *
Note: The "Run PHP as CGI" option will likely not appear for you if you did not previously have it unchecked, because it has been disabled. The effect of running PHP as CGI is that PHPiCalendar will run using your own user permissions. The problem with this is that files posted via WebDAV belong to UID/GID dhapache/dhapache and have 640 permissions, so your user account won't be able to read the calendar files. One way to get dhapache, which has access to your calendars, to run PHPiCalendar in the absence of the control panel is to place the following in .htaccess (perhaps in the PHPiCalendar directory itself):
AddHandler application/x-httpd-php .php

PHPiCalendar WILL NOT WORK right away! Don't panic! We still have some things to do.

Setting up a WebDAV-enabled Calendar Directory

It's a good idea to create a separate directory just for your calendars outside of your PHPiCalendar install directory so that if you ever need to upgrade you can safely erase the entire install directory. (but backing up first, of course!  :) It's not a requirement, certainly, but for the purposes of this install guide, I'll assume this is what you want to do. Let's put the calendars in
/home/yourusername/yourdomain.com/mycalendars/
We wil now create and WebDAV-enable this directory. We're going to do this so that your favorite calendar application (Apple's iCal, Mozilla Sunbird, Mozilla Calendar Extension for FireFox, or whatever you use to create your calendars) can upload your calendar automagically to your server when you make changes to it.
  1. Go to Control Panel -> Goodies -> Htaccess/WebDAV.
  2. Select the domain where you'll be putting your calendars.
  3. Click "Set Up a New Directory"
  4. Enter mycalendars for your new calendars folder
  5. I strongly recommend enabling password protection on your directory.There may be a problem with step 5 - permissions errors have been reported with this enabled. Reviewing as of 12/4/05.
  6. Definitely check Enable WebDAV. That's the whole point, right?  :)
  7. You can skip the Directory "Name" box.
  8. Make sure to edit the default accounts to put in a username and password that you're going to use in your calendar creation application. WARNING: I know Apple's iCal has had some problems uploading using usernames and passwords that have strange characters in them, so don't get too crazy here. More detail is in the iCal discussion groups on Apple's site link to come.
  9. Don't worry about the rest of this page except for the fine print at the bottom: 'Warning: WebDAV-enabled directories will no longer be owned by you, and so cannot be accessed via FTP or the shell.. only through WebDAV!

This means that you won't be FTPing calendars back and forth, you'll be using your favorite calendar application to do the heavy lifting!

Note that this will take some time to activate, so be patient! Go watch the rest of that "Lost" episode on your Tivo and then come back to this.

Note 2:It's a good idea to test this by publishing some calendars from your calender-editing application first. Covering how to configure your calendar app to publish to your WebDAV directory is outside the scope of this tutorial, but look in your application's help file for "Publishing". You'll use the directory and the username and password you just created for this.

Changing config.inc.php

I will give the bare minimum of information just to get you up and running, but if you want more detail, I strongly advise you check out the PHPiCalendar Configuration Page.

You'll need to change a few things in config.inc.php. Fire up your favorite text editor and go to work. Note that the configuration system changed in version 2.3 to use a large hash instead of a series of variables.

  • Change the default calendar (this is optional, but I changed it so I only see one calendar at a time)
default_cal => 'calendarnamewithoutics';

Or replace 'calendarnamewithoutics' with $ALL_CALENDARS_COMBINED to open all calenders combined. Each calendar will display with a separate color. This is a nice feature.

  • Change the timezone using the info from the TIMEZONES file
timezone => 'America/New_York';
  • Change the seconds offset if you don't live near Dreamhost in California. This is the number of seconds between your time and Dreamhost's server's time. I'm in New Yawk City, which is 3 hours later. That's

3 hours * 60 mins / hr * 60 secs /min = 10800 secs

$second_offset = '10800';
  • Change the calendar path
calendar_path => '/home/yourusername/yourdomain.com/mycalendars';
  • Change the default path to the PHPiCalendar install directory
$default_path => 'http://www.yourdomain.com/icalendar/';

Brief Aside: I had problems with cookies and RSS subscribing (I think because the PHPiCalendar application tries to figure out the path and and gets it wrong because of the /home/.servername/yourusername/ nomenclature, so I specified a bunch of things that config.inc.php said to leave blank. Your mileage may vary, but when in doubt, specify full paths to things rather than letting the app figure it out. So I changed these additional things:

  • The cookie_uri, the HTTP URL to the PHP iCalendar directory
cookie_uri => 'http://www.yourdomain.com/icalendar';
  • The download_uri, the HTTP URL to your calendars directory
download_uri => 'http://www.yourdomain.com/mycalendars';

Viewing Your Calendars

This should be the easy part! Point your favorite browser to http://www.yourdomain.com/icalendar/ and enjoy!

Troubleshooting

PHPiCalendar has good error reporting (assuming you haven't turned it off - see below), and will usually give you a pretty good clue as to what's going on when the error occurred.

  • Apple's iCal has had some problems reported when publishing calendars and calendar groups that have a space or other "strange" characters in their name, and with WebDAV usernames and passwords that have "strange" characters also. Beware! If necessary, rename your calendar!
  • After I installed everything, I was seeing my calendars displayed with a whole bunch of ugly error messages displayed at the top which looked like this:
Warning: Invalid argument supplied for foreach() in 
/home/.server/myusername/mydomain.com/calendars/functions/template.php on line 273

and like this:

Warning: session_start(): Cannot send session cache limiter - headers already sent 
(output started at /home/.server/myusername/mydomain.com/icalendar/functions/userauth_functions.php:74) 
in /home/.server/myusername/mydomain.com/icalendar/functions/userauth_functions.php:74 on line 74

I searched around and found a fix on the PHPiCalendar message boards. Add this line to init.inc.php:

error_reporting(0);

This will turn off php's error reporting when using PHPiCalendar, and so your calendar will display error-free. This is not a proper fix, but it will get your calendars to display nicely.

[Additional]
The above errors are caused by session management, somehow. To actually fix them, instead of just making them disappear change $login_cookies to "yes" in your config.inc.php - this tells the calendar to use cookies to track user authentication. Be warned: This means that the login information is stored in an unencrypted cookie on the user's computer.

$login_cookies	= 'yes';

iCal-only (Fallback) Configuration

Install PHPiCalendar

  • Unpack the PHPiCalendar files in whatever directory you're installing to. I created a new subdomain, but this should work equally well in a directory off your main site.

Configure PHPiCalendar

  • PHPiCalendar is configured by default to use the /calendars subdirectory for calendars, so that's what you entered above. You can muck around in the config file and change this if you want.
  • I had to edit my config file to turn off cacheing. I haven't tracked down exactly why PHPiCalendar doesn't work with cacheing on DreamHost; I tried all manner of file permissions but it kept telling me it couldn't write to the directory. Lack of cacheing shouldn't be a huge deal unless you're getting thousands of hits to your calendar every day.

Configure iCal

  • Get Scalp from Pygmy software. Close iCal and install Scalp using its installer.
  • Run iCal. Choose your calendar, and select "Publish" from the "Calendar" menu. In this dialog, choose "Private Server". For setting the URL, you need to point it to the Unix path from which PHPiCalendar reads its iCal files. For instance, since I used a new top-level domain, my URL is: ftp://mattandchristy.net/ical.mattandchristy.net/calendars, but if I had put it in a subdirectory of my main site, the URL would look more like: ftp://mattandchristy.net/mattandchristy.net/PHPiCalendar/calendars. Enter your FTP username/password and click Publish. You should be all set!

Additional Support and Resources

Personal tools