Closed Thread Icon

Topic awaiting preservation: php, getimagesize(http//...) with allow_url_fopen OFF Pages that link to <a href="https://ozoneasylum.com/backlink?for=27255" title="Pages that link to Topic awaiting preservation: php, getimagesize(http//...) with allow_url_fopen OFF" rel="nofollow" >Topic awaiting preservation: php, getimagesize(http//...) with allow_url_fopen OFF\

 
Author Thread
GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 01-05-2006 18:30

hi, i was wondering if there is a possibility to do a php->getimagesize of an image on another machine, but with the allow_url_fopen set to OFF. (Dreamhost configuration)

my idea is to use php->curl but i had no success so far.

any ideas?

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 01-05-2006 18:53

ok, i just found a solution myself:

code:
$ch = curl_init("http://www.someadress/img.gif");
$filename="/somewriteablepath/test/yxc";
$fp = fopen($filename, "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);

fclose($fp);


print_r(getimagesize($filename));



Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 01-05-2006 22:03

now... what happens if that script runs multiple times at the same time?

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 01-05-2006 22:09

dunno.

can a php-script really run at the same time?

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 01-06-2006 00:26

yeah if you get separate requests.

I think his point is to use flock on the filehandle to prevent this from occuring.



.:[ Never resist a perfect moment ]:.

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 01-06-2006 09:30

No!
The point is to
a) use tempfiles (php->temp_name() or such...)
a1) chmod the tempfile to 600.
b) Use php->ignore_user_abort (true)
c) delete the tmp file at the end. (perhaps with php->register_shutdown_function()

that way
you're
a) not opening a security hole (replacing your file with a gd buffer overflowing jpeg, then chmoding it 444 so you won't be able to write to it)
b) allowing multiple scripts to run at the same time
c) not blocking all other scripts while the first one's running.

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 01-06-2006 11:10

how do i get the file path of the php->tmpfile ? cause php->getimagesize only takes file paths and not file handles.

sorry guys, but i still dont get your point with the multiple scripts running at once. this piece of code exists in only one php file, and after the temp file has been read with php->getimagesize i dont need it anymore, so it can be overwritten the next time the script runs.

« BackwardsOnwards »

Show Forum Drop Down Menu