fix php errors and replace deprecated ereg_replace