This is some really old PHP I wrote back in college. Please excuse the messiness.