file_exists enquiry:
| From: | Adam Delves | Date: | Mon, 24 Feb 2003 20:06:11 +0000 |
| Subject: | file_exists enquiry: | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-15894@lists.php.net to get a copy of this message | ||
I am using the file_exists function in my code and noticed that when I
use a variable from the $_GET array the file exists function strips the
slashes from quote marks in the passed argument. I discovered this
because I accidentally renamed a file '' on my web server.
I pass a variable file_name through the URL query string. When accessing
magic_quotes adds back slashes so the file name '' becomes ///'///' - I
don't know why it is escaped twice.
Using stripslashes() on it converts it to /'/' :
echo ( (int) file_exists (stripslahes ($_GET['file_name'])); // returns
1
echo ($_GET['file_name']); // returns \'\' - file name is incorrect
Using stripslashes twice converts it to '' :
echo ( (int) file_exists (stripslashes (stripslahes
($_GET['file_name']))); // returns 0 - even though this is the correct
file name
echo ($_GET['file_name']); // returns '' - as expected the correct file
name
It appears to me that the file_exists function is stripping the slashes
and expects quotes to be escaped visible in the GET and POST arrays.
Does this happen in all file system functions??
Thanks in advance;
ADAM