modifyed getsubstr.php