Its ugly, its gross.  Its also working.  I need the DBI code put back in to save the logs to mysql.  I'll get to that later unless someone wants to make it happen before I do.