Either phproxy or cgi proxy. Search google for either one.

PHProxy is the easiest to integrate/customize I would say.

You can download it here: http://www.sourceforge.net/projects/poxy/