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.

Blackberry Storm – A biased review

Let’s get this out of the way. I am a Mac guy, have been for years (except for some ‘experiments’ with windows in college, but isn’t that what college is for?). I wanted an iPhone before they were out. And, I want one now. There are three reasons why I will not have an iPhone: AT&T. Say what you want about Verizon, but their service is still the top. If I had an iPhone, I’d be greatful to get signal where I live.

Ok, so that is out of the way. I got a Storm on the first day. This was my first touch screen phone and my first Blackberry. The first day I owned it I spent learning how typesure keypad works and how to navigate the Blackberry OS. Everywhere I go I get “is that the new Blackberry?” and people asking about it, what I think, etc.

Here is what I think. I love it.

Let’s talk about the touch part, since that is the part that sets it aside from the iPhone, Instinct and any of the others. The screen registers your fingers as soon as you touch it. Keys will change to blue as you run your finger over them, but nothing will happen. You have to actually press the screen down for something to occur. The entire screen is a button. This reduced the number of mistakes I was making compared to the iPod Touch significantly.

There are three keyboard layouts. In vertical mode you can get either a SureType pad, or a normal phone pad (hit 6 three times for “O”). Suretype is RIM’s condensed QWERTY keyboard found on the Pearl. I was sure that I’d never figure out how to type with two letters on one key. A guy in line with me gave me some advice which has worked. “Just type,” he said, “the phone will figure out what you are trying to say.” And he was right. After a few days I can use it with some proficiency. The advantage is you can type with one hand in this manner. The other keyboard is the full QWERTY. You get this when you turn the phone on its side. Unlike the iPhone, however, you can get this keyboard in any program where you type. Actually you can pull up a keyboard at anytime by pulling it from the menu.

Speaking of menus, everything is pretty much menu driven. The ‘berry’ button (which I am sure has a much more technical name) opens the menu. You either press it again to select the highlighted option, or you select the one you want by clicking the screen.

The browser so far seems to work quite well. I used it the first day to show off the new Star Trek trailer from YouTube. Playback was good, even if the video was a bit stretched to fit the screen. Now, if you tap the screen, that is touch it but don’t push down, the browser will zoom. A feature that is useful at times, but too easy to do accidently. While the ‘real’ browser experience is nice, like my experience with the iPhone, in the end, mobile websites still work the best.

Messaging is where the Blackberry shines. There are reviews everywhere about Blackberry messaging, and from my experience, they are right. Coming from a Windows Mobile phone, it was a vast improvement. I have four email addresses set up on the phone, and push email is my new favorite thing. There are rumors of calDAV support coming to the Blackberry, which would allow syncing with Yahoo! and Google calendars (or any other calDAV ones as well).

I’ve used the media part a few times. It works pretty well. I do wish the volume control was a bit more precise. The screen is great for video and pictures. The phone has a 3.2 Megapixel camera with a flash. The pictures are good, even though there is a delay as the camera focuses. The phone can also take video at a decent resolution. Not sure I’d make a movie with it, but that doesn’t mean I haven’t thought about trying.

The OS is a multitasking OS. This means that if you have one program open, you can open others without having to close the first one. Now, this has had me digging though folders trying to figure out what an alert on the top of the screen was. (I had gotten an IM)

Ok, and as a final note, the blackberry can copy and paste. So there.

Artist Collaboration

There is a certain thrill, certain excitement when you work with others on something. Art is not generated in a vacuum. It comes from

Collaboration comes in several forms as well. There is the obvious, the “let’s get together and write a story together about Martian broadway performers who fight crime in their spare time.” And then yourself and your friend sit down and start to write. Sometimes you email, sometimes you use markers, always you fight and eat pizza. In the end is something that either you both hate or both love, and if you did a good job perhaps you both still speak to each other.

And your alien squirrel dopplegangers will make music.

The other kind is more of a moral support sorta collaboration. This one goes more like this: “HEY! GET YOUR ASS WRITING YOU LEFT ME HANGING AT THE END OF A CHAPTER AND I HATE YOU.” Or something similar.

Basically you send something to an artist friend and they read it. They send something to you to read as well and then together you write, using the other as a sounding board and a bit of motivation. Because sometimes getting off of our butts is the hardest part.

Have you seen my pen?

This type of collaboration is more important, I think. Working with someone is fun, creating a world/story/character/Metallica album with someone can bring ideas out, or together that might not have before.

But, by simply talking with other writers/artists/friends/doppleganger squirrles, you give yourself a sounding board. Maybe making your main character actually an exiled tomato isn’t the best idea… When we work together it also helps talk through the hard parts, the ones where you write yourself into a hole. Sometimes all you need is a rope. Sometimes you need a helicopter, some repellers, a bottle of Batman repellent spray and a six pack of Guinness (STAT!).

So find someone you trust, give them a story, take one of theirs, get working together.