curl - Downloading an image that is hotlink protected -
i download image hotlink protected. how can forge http header curl referer coming own server?
i have tried command fails. i'm not familiar php , apreciated.
curl -a "mozilla/5.0" -l -b /tmp/c -c /tmp/c -s 'http://remote-site.com/image.jpg' > image.jpg   option looks curlopt_referer curl_setopt, or curl --referer not sure correct syntax.
edit 2 :
i got error saying curl_setopt() expects parameter 2 long. after removing mute option error gone.
to show image have tried code page remains blank.
$image = curl_exec($ch); curl_close($ch); fclose($fp); print '<img src="'.$image.'"/>';   edit 1:
the code have entered in wordpress post (i use plugin insert php)
[insert_php]  curl --referer http://www.domain.com/ -a "mozilla/5.0" -l -b /tmp -c /tmp -s 'http://www.domain.com/image.png' > image.png  [/insert_php]   the error have when load page :
parse error: syntax error, unexpected ‘<‘ in /public_html/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 8      
you should able specify referer option curl follows:
curl --referer http://remote-site.com/ -a "mozilla/5.0" -l -b /tmp/c -c /tmp/c -s 'http://remote-site.com/image.jpg' > image.jpg   the syntax of curl simply:
curl [options...] <url>   just noticed: since have specified silent mode -s, should specify output file --output <file> parameter. -s option cannot use output redirection (> image.jpg) since there no output begin with.
update:
you have insert php code between [insert_php] , [/insert_php] tags. string you're having there right not valid php code. have use curl_* functions provided php. code should this:
$ch = curl_init(); $fp = fopen("image.jpg", "w"); curl_setopt($ch, curlopt_url, "http://remote-site.com/image.jpg"); curl_setopt($ch, curlopt_mute, true); curl_setopt($ch, curlopt_useragent, "mozilla/5.0"); curl_setopt($ch, curlopt_file, $fp); curl_setopt($ch, curlopt_followlocation, true); curl_setopt($ch, curlopt_cookiefile, "/tmp/c"); curl_setopt($ch, curlopt_cookiejar, "/tmp/c"); curl_setopt($ch, curlopt_referer, "http://remote-site.com/"); curl_setopt($ch, curlopt_useragent, "mozilla/5.0"); curl_exec($ch); curl_close($ch); fclose($fp);      
Comments
Post a Comment