Modernized code to run on PHP 5.5 & removed all uses of deprecated eregi function.