a) have to maintain it anyway (can't afford to lose job etc.)
or
b) are going to re-write it but don't have a definte spec to know what it has to do
then you are going to need to try and understand the code base. Here are some PHP specific tools to help you.
- Use XHGUI[1] (which is a fork of Facebooks XHProf) to profile the code as it runs. It can draw call-graphs for you (if you have Graphviz installed) which will help you to visuallise the code flow.
- Use PHPdoc[2] to generate API docs. This will help you get a simplified overview of the code to use as a reference.
- Use Xdebug[3] as you make changes and execute code to get more insight into how it is running and to trace variables etc. through the execution. You can use KCacheGrind [4] to visualise the output of Xdebug.
- Use a staging/development environment for everything you do with this code, and don't push any changes into to production until you really, really have to. When you do, use version control (e.g. Git, SVN etc.) and use an automated build system (Phing[5] is a great PHP specific one) to try and keep everything consistent.
Good luck! Quick plug : I'm currently writing a book [6] about PHP development (called PHP Everywhere : Programming beyond the web with PHP) which covers the tools above (albeit not for the kind of job you are taking on!). The one small mercy you may have when tackling a project like this is that it is written in PHP. PHP is usually quite a verbose language, which while it doesn't always produce sexy code, does mean that its straight forward to read and understand (at the local level!). An extra space here and there doesn't usually alter the meaning of the code as it does in some languages!
[1] https://github.com/preinheimer/xhprof [2] http://www.phpdoc.org/ [3] http://www.xdebug.org/ [4] http://kcachegrind.sourceforge.net [5] http://www.phing.info/ [6] http://leanpub.com/php