"bitten on the behind by the leavings of a shonkmeister"
My own shonky code (over 10 years of PHP, there's plenty of shonk to go around) aside, the worst I'd ever seen was (ironically) right at the beginning of my PHP 'career'.
Joined a small marketing company as a Front-End web dev (with not a lot of 'server-side' knowledge), with the proviso that I'd 'learn up' the server-side as well. After about 6 months I'm working on the front end of a website that is completely AJAX driven (client's demanded it - don't ask), and the content management system is being built by the self-proclaimed PHP Guru in the office who's been there a year or two. He'd been working on this project for 6 months apparently, trying to get the (home-brewed) CMS working correctly (IIRC - it was again AJAX driven with PHP backend over a MySQL db).
For some reason known only to himself and Beelzebub, he'd decided that instead of saving html markup into the db cell for each page of the site (or some other normalised system), the text was saved as "text-string|paragraph-type|text-string|paragraph-type|etc|etc|etc" eg: "Page Title|h1|Page intro copy|block-para|Paragraph 2 copy|para|" etc..... Lists were particularly fun to decipher.
I had to parse these strings to make them display on the site - he had to ensure that each individual string, and it's paragraph type was editable (and without fucking up special characters) - which is what he'd been struggling with for 6 months.
Eventually they had 'discussions' with him, he left, and I got lumbered with it.
Finished the CMS off 2 weeks later (albeit still on the same horrendous database structure), including fixing the encoding issues (still not sure why it was hard just to check that everything was configured to use the same character encoding configuration!) and learnt a hell of a lot..... only for the client to go under a week later!