Tuesday, February 24, 2009

First Real Crack at PHP5

So I haven't written PHP code in a while, but I figured I'd take a crack at setting up some REST services. The last site (the SAVSERV) I wrote was in PHP4 and being used to coding in JAVA and C, I found it pretty clumsy to use. Of course, at that time I was teaching myself PHP4 so I'm sure many horrible things were done. Things I will have to live with for the rest of my life), but I digress. Tonight I put together some PHP5 code for a simple REST login and wow, has it changed.


...
$sql = "SELECT loginid FROM logins WHERE username = '$username' AND password = '$hashedPass'";
try{
//TODO: put this into a common function
$result = DatabaseTools::runSelectQuery($sql);
if(mysql_num_rows($result) == 1)
{
$row = mysql_fetch_assoc($result);
Response::LoginSuccessResponse($row['loginid']);
}
else
{
Response::ErrorResponse(101,'Could not find your information in our system.');
}
} catch (Exception $e)
{
Response::ErrorResponse(101,$e->getMessage());
}
...


Now I am by no means a good PHP programmer. Self taught PHP4 in a few days and now PHP5 in about 3 hours really, so lay off me if things aren't perfect. But just look at that, actual classes and exception handling? Shocking. I swear, I felt like I was writing Java code. And the walkthrough that the PHP main site provides (http://us.php.net/zend-engine-2.php) is very easy to follow with lots of code samples. For anyone who is used to OOD, PHP5 is very easy to pick up and start going. Now if only I could find a nice project to teach myself Perl or Python...

Thursday, February 05, 2009

Review: This Film is Not Yet Rated

    Film censorship is a well known practice in Hollywood and has been for many years. People know it exists, but you don't really hear about it much. That is, unless your film gets the dreaded NC-17 rating. This film attempts to explain to people what they are missing by having a small group of people and the studios dictate what a film needs to be rated in order to get released. In some deep dark underground lair, there is a group of people that decide which films you see and don't see. Their names are kept secret. This is to protect them from outside influence, although they work with/are influenced by every major film studio and distributor in the country. This particular movie in itself isn't a groundbreaking documentary by any means, but it does get a message across. Yes, the private investigator bit is hokey. And by the end of some of the interviews, you feel like they director is just venting their frustration. But this film poses some intriguing questions to the audience. Why is heavy violence ok, but heavy sex not? Why is straight sex so much more acceptable than gay sex? Why is one scene in a movie distributed by Paramount ok, yet the same scene in an independent movie needs to be cut? Sure, we all know the MPAA is evil, but there is something more sinister about a small group of people controlling what America sees on the big screen. Oh, and yes, there are members of the major religious organizations involved as well.
    My main criticism of the film is what they left out. What I wanted to hear more about was the early days of film censorship. What was film like before they imposed these rules and how have the rules changed over time? Also, exploring the relationship of violence in movies to violence in real life a little more would have been interesting. Natural Born Killers is a great example. This film is a good start, but if you really want to know what is going on, pick up a copy of Obscene, Indecent, Immoral and Offensive: 100+ Years of Censored, Banned, and Controversial Films. All and all, I would recommend the movie to a friend as a way to open their eyes to the way the system works (or doesn't). But if they just want to see a good documentary, I'll point them to Man on Wire