I know how you feel. I inherited the development of such a project. It stayed with me for a year and to be honest it made me the developer I am today. There is no better opportunity for personal advancement than working knee deep in shit.
Here are the things that helped me to most:
- identify which are the key files of the system. You will find them because the most of your work will be done in them
- create a local version of the project (including the database) and put it under version control
- work only on a small amount of files with small changes
- do not put anything inside the production version until you have it tested thoroughly, and then be ready to put the old version back
find out how the users of the system are handled (sessions , cookies). Create a super user and then when you need to test your code live on the system put it in a block like this:
if($_POST['your_registered_user_name']{
//Your live code being tested, which will be visible only to you when you are logged in
}
other users wont be able to feel the changes. This technique helped me a lot when I was unable to replace the system state on my local machine
write test, and follow strict engineering guidelines for all the code you are writing