Using PHPiCalendar with a Database

On this site I have set up phpicalendar to work with a database. Here is how I did it.

The first requirement I put on myself was simple: no modifications to PHPiCalendar. Why? Because I am lazy. I want to write this once and be done with it, not have to tweek it every time there is a PHPIC update. So instead of trying to make PHPIC read from a database, I made the ICS file be generated from a database.

See how that works? As long as PHPIC reads ical files (which I would think is always, since it is in the name…) this is going to work. So, how do we generate ICS files?

For that I used a AJAX trick. See in AJAX, you can’t use an XML file from a different server for security reasons. So what they do is generate it through PHP instead. And I did the same thing.

I made a php file which pulls the information from a database. Because I am using PHP, I can also just have one file and pull multiple calendars from it, using the old ?cal=this_one trick. So I can call holidays by saying ical.php?calendar=holiday, but readings by inputing ical.php?calendar=readings. Same file, all the calendars.

So then all you really need to do is generate a form that fills in the database. More information for ICS can be found here. I merely used the following parts, wanting to just work with the basics.

DTSTART, DTEND, SUMMARY, DESCRIPTION, UID, SEQUENCE, DTSTAMP, AMOUNTTIME, CATEGORY, ID, UPDATED, URL, LOCATION

I did also want to, as an admin of the site, be able to approve or dissapprove items. So I put in another field called APPROVED into the database. If the even is marked as unapproved, then it does not show up in the ICS file. Just a person between forms and data on the front page of my site. seemed a good idea, no?

This, of course added in another form, an admin form that would let me approve or dissapprove anything submitted. This was a basic form, really since only I was going to be seeing it. I simply change the DB variable of APPROVED from NO to YES. Then when the ical.php file pulls the information, the check code will keep it from, or now allow it to be published.

There was one issue with this whole adventure. Seems that PHPIC wouldn’t read the file being generated. Why? because it was a .php file. So I violated the first (and really only) rule of this little adventure and dug into the PHPIC code.

Now I figure this is probably some sort of security hole. I am just not entirely sure how.

A better solution would be to have the php file simply generate the ICS file each time the database is updated, rather than generate it on the fly. While there is a certain bit of safety with that, there is a certain bit of elegance with the single php file being able to provide all the desired calendars.

PS. The PHP file worked in iCal as well.

Protecting Your Computer

THIS IS AN OLD POST, this was written in 2008. there is better information out there. Still, back up your shit. Seriously. No one, not Dell, not Apple or Microsoft, not Google not Best Buy, no one NO ONE but you are responsible for your digital belongings. Your pictures, your music, your documents and emails, all of these things are yours, and you need to be proactive in keeping them safe.

-j

If you use a Windows computer you need to protect it from the internet. The following is by no means intended to be an end-all be all list. Nor is it one that will last forever. See the date of this post? If it has been longer than a year, I’d do some research to make sure these are still good solutions. Computer technologies don’t stop.

Firefox: (mozilla.com) Web Browser. The best thing you can do for your computer is not use Internet Explorer. Most viruses/ad/spyware comes in to your machine using exploits through IE. This is _not_ to say that Firefox is immune to this, or that this is the only way to be infected. This is a simple first step at protecting your machine.

AVG (Grisoft.com) Anti-virus. High quality, it will scan your system, scan incomming email and help clean and quarrentine infected files.

Adaware (lavasoftusa.com) Free. This removes ad/spyware from your computer. You know that random pop-up window that appears when you aren’t even in Internet Explorer? this will help with that.

Spybot Seek and Destroy (safer-networking.org) Search and Destroy () Free, use with adaware. Where Adaware shines with adware, spybot shines with spyware. Spyware is used to collect information from your computer and send it to another computer. This is usually bad.

Backup, backup, for the love of all that is holy, backup!

caveat emptor! Becareful of what you download! Where did you find it? Is the site reliable? Has the software been reviewed on other sites? Check these things out. A bad software download can cripple your machine.

Seriously. Back up. Get an external hard drive. Get a thumb drive. Burn CD’s or DVD’s. Print them out! Imagine this, if i came in and took a hammer to your hard drive, what would you lose? what would you need? Now take those things and back them up.

I am a Mac user. The luxury of that at this time is I don’t need any of these things. Linux too provides more security than a Windows machine. The trade-off? You would need to learn a new operating system. Not all your software can be found (and most would need to be repurchased).

Software for Writers, part one

I’ll probably write a few posts on this sort of stuff. There are so many tools out there availible for a writer (or any artist for that matter) it is hard to know what to pick. Most of my posts will be about free software. Why? Well, as a starting writer, free is a good thing.

The idea being that your creativity shouldn’t be hindered by your wallet. Perhaps you won’t have that sound studio, or that top of the line movie editing deck, but you can get tools that well get you there.

So let’s start with some basics.

You need a word processor. For a writer, this is a part of your creative process. For an artist in general there are countless reasons why you’ll need to sit in front of that blinking cursor, from resumes to reviews. There are two great choices out there that are both open source, and free.

AbiWord (http://abisource.com)

Simple. Light. Easy to use, but still powerful. AbiWord is just a word processor, but it does its job efficiently. Most of the tools you will need are here.

OpenOffice.org (http://openoffice.org)

This is a monolith. Openoffice.org is a competitor for Microsoft Office. It has a word processor, a spreadsheet app, presentation, even web and database tools. There are forums everywhere to help with the program.Templates, tutorials, all availble online. If you are thinking of buying an Office Suite, try this one first (it’s free!) and see what you think.

Both of these programs can save in either MS Word formats (.DOC) or in Open Document Format. The advantage of ODF is that it is an open standard, so you don’t have to worry about not being able to open them down the road. The disadvantage is that Word can’t open them natively, so you may have to convert to DOC or RTF before sending them out to friends or editors.

Are these the only two options? Not a chance. There are lots of open source word processors, and some closed source, but free ones, like Google Docs, for instance.

That’s a start, there will be more as we go along.