Tuesday, November 11, 2008

PHPinally

We're experimenting in the WC this semester with consultation by discontinuous email. Students can upload up to five pages of whatever they are working on, the draft then zigs and zags (taking two lefts and then a right?) through the internet to a listserv account where five always-on consultants take turns commenting and returning drafts, usually within 24 hours after the draft is sent. The system seemed to be working fine until recently when we realized a flaw in the design of the upload form. Basically, the form allows students to 1.) upload a file or 2.) copy and paste a chunk of text into the form. 'Submit' The form then calls up a PHP script, which, when there is an uploaded file, puts the file in a temporary directory, builds the email message to the listserv, attaches the file, sends the email to the listserv, and finally clears the file from the temporary directory. That much seemed to be working fine for, oh, ten weeks, and we have 45 such consultations to show for it. But:

About a week ago, the form seemed to stop working. We experienced a lull in the previously steady stream of requests. I checked the files, and, sure enough, there was an unnamed .doc file camping out in the temporary directory. Did someone upload a nameless file? Seems so. But there was more. The form was not relaying messages that did not have attachments. Never did any complaints alert us to a problem, but the PHP script relied on an if... function (e.g., if(filea)) without an else.... IF the file was attached, all was smooth-going. ELSE...broken.

Sadly, I am not one of those PHP wizzes who can just glance the code and efficiently drum up the needed lines. Writing PHP is slow and agonizing--a reverse engineered grind. I re-draw the original script so that everything routes to my email address (so as not to bother the listserv with the sequence of test messages), then tweak the code, upload, and test. Well, I thought I had it up and running again on Saturday, but, lo and behold, I was wrong, so again today, straightaway from teaching class and two hours of face-to-face consulting, I was at it again, thunking my head against the immovable brick wall of a PHP script I could not figure out. And then, suddenly the office was all children's chorus and sun beams: I realized what was the matter, added the two or three lines (primarily a no_attachment function) and, for the last time, FTPed the mended script into place. Tested it from all directions, and it worked--a clear case of luck favoring the prepared desparate.

Bookmark and Share Posted by at November 11, 2008 9:30 PM to Technologies
Comments