You could change it by this one :
if ( isset($_GET['ajax']) && (int)$_GET['ajax'] != 1 )
I tried before HTTP_X_REQUESTED_WITH, i like this method but seems to be uncompatible with some server and particulary with MSIE (...)
To avoid page directly page call with ajax parameter (from a non ajax requester) i also modified tep_href_link in html_output.php but it is not needed in this contribution, but i still post the code :
html_output.php / tep_href_link
// Prevent non ajax loading / OLIVIER
//
$parameters = str_replace('&ajax=1', '', $parameters) ;
$parameters = str_replace('?ajax=1', '?', $parameters) ;