Improved platform detection logic in PHP script