Reputation: 23
I'm using this script to detect curl in a php page but it doesen't work... I always get "curl ua"
if ($usera = "curl")
echo "curl ua";
else
echo "no curl";
?>
Upvotes: 1
Views: 1954
Reputation: 720
The Useragent could be changed by user, but default settings could be recognized by:
function is_curl() {
if (stristr($_SERVER["HTTP_USER_AGENT"], 'curl'))
return true;
}
Upvotes: 0
Reputation: 39365
The exact curl user-agent string will be different based on version. For example this one:
curl/7.15.1 (i386-pc-win32) libcurl/7.15.1 OpenSSL/0.9.8a zlib/1.2.3
So what you can do is, check whether the curl
or libcurl
is existed in the agent string or not.
if(preg_match("/curl|libcurl/", $usera)){
// do something ...
}
But if the curl
client change the Agent String
, then you'll not be able to detect it. For example with below curl
request I am changing the user agent into Opera 9.0
curl -A "Opera 9.0" http://www.example.com/
Upvotes: 3