Hey,
All of my sites got hacked too.
This code was found in some PHP files. Also, there were some files in root of each directory which begin tmp_ then random numbers like tmp_6576768676.php
Also, check all your .htaccess but make sure you scroll down and across as they modify .htaccess but the code is not straight after existing code.
I just spent 2 hours sorting out about 50 directories. I hope all is clear now.