.php script improvements