// remote.php on http://www.example.com/
<?php
function curl_access()
{ /*
some codes here to detect
this script accessed via
curl or direct and returns $r.
(without checking referrer or user agent)
*/
return $r;
}
$curl_access = curl_access();
if ($curl_access)
{ echo 'Accessed via CURL';
} else
{ echo 'Direct access';
}
?>
// some file on a server
<?php
$h = curl_init();
curl_setopt($c, CURLOPT_URL, "http://www.example.com/remote.php");
curl_exec($c); // returns 'Accessed via CURL'
curl_close($c);
?>
// remote.php on http://www.example.com/ <?php function curl_access() { /* some codes here to detect
Share
You can’t. An HTTP request is an HTTP request, and you’ve ruled out the obvious distinguishing characteristic of a request made by a browser (the contents of the user-agent header).