cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Fake-referer and remote file-exist check & size-check using libcurl?...

From: Fernando Cassia <fcassia_at_compuserve.com>
Date: Thu, 27 Feb 2003 11:41:36 -0300

Hi there!

I was using a simple php script to check for a cookie and grab graphics
files from out of of the public_html root path, so on my website I
placed all image links as
www.mydomain.com/showfile.php?thefileIwant=something.jpg

First my script checked for the cookie (so the user was logged in) then
it checked if the file was there

 if (file_exists($thefileiwant))

and then if it did exist, the script sent headers to the browser with
the file type and size
 header("Content-type: image/jpeg");
 header("Content-length: " . filesize("$path/$thefileiwant"));

and finally sent the file to the browser
readfile ($thefileIwant);

Now, I really would like to move the images (which are very big and are
using most of my contracted hosting space), to a cheaper (still paid)
secondary hosting provider, but which insists that jpg images be linked
or embedded into html pages on their domain. My plan is to use libcurl
to fake the referer and grab the images from the remote server. The
problem is the "file exist" check and the "file size" check, since I'll
be dealing with files on a remote httpd server.

Question:

1) Can I use libcurl to replace the "file_size" function and query the
remote file size?. how?
2) How can I check if the remote file I'm querying exists (is a jpeg) or
instead the remote web server forwards me to the providers' 404 page?
3) Anyone cares to post a "fake-referer" http-get, first checking if the
file exists and its size?

Thanks and sorry for so many questions... I'm new to libcurl.

Regards
Fernando

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-02-27