Re[2]: [PHP] slight quik question

From: Date: Mon, 07 Apr 2003 08:22:27 +0000
Subject: Re[2]: [PHP] slight quik question
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-142656@lists.php.net to get a copy of this message
Hi, Monday, April 7, 2003, 6:00:26 PM, you wrote: LKB> Be careful with that, a hacker could use it to gain access to sensitve LKB> files. Feeding it a name like "../foo/bar", for example, would provide LKB> access to path/to/foo/bar. LKB> Martin Towell wrote: >>something like: >> >>URL: http://site.com/get_image.php?name=image_name_here.jpg >> >>SRC: >><? >>if (file_exists("path/to/file/$name")) >> passthru("path/to/file/$name"); >>else >> passthru("path/to/file/nofile_image.gif"); >>?> >> >>(you'll need to check the spelling of passthru... maybe it's readfile() - or >>something...) >> >>-----Original Message----- >>From: daniel [mailto:daniel@electroteque.org] >>Sent: Monday, April 07, 2003 12:00 PM >>To: php-general@lists.php.net >>Subject: [PHP] slight quik question >> >> >>hi guys i have been working on a photo gallery script for some time now , i >>have some issues i may need help with , i have public and private galleries >>i >>am setting up , although the images are stored in the document directory and >> >>would still be viewable by accessing them directly instead of the gallery >>script , how would it be possible to store the images outside the web path >>and >>be viewable in the page without having to use gd to do it ? >> >> >> >> >> LKB> -- LKB> The above message is encrypted with double rot13 encoding. Any unauthorized attempt to LKB> decrypt it will be prosecuted to the full extent of the law. You can use getimagesize() to make sure it is an image file like this: SRC: <? if (file_exists("path/to/file/$name")( $im = getimagesize("path/to/file/$name"); if(!empty($im[0]) && !empty($im[1])){ passthru("path/to/file/$name"); else{ passthru("path/to/file/nofile_image.gif"); } else passthru("path/to/file/nofile_image.gif"); } ?> -- regards, Tom

« previous php.general (#142656) next »