clean php files from eval infection

I needed to help a friend to clean all his files from an eval type attack so I used the code bellow to clean all his files. In $str var I put the virus code that was injected (in my case a hidden redirected code)

You can download the code here and then run it through the webserver.
cleaner.php