replaced getExtension() with PHP < 5.3.6-friendly version.