Bug #12004 Updated: problem with fopen over ftp and a related fgets
| From: | wez@php.net | Date: | Sat, 13 Apr 2002 19:47:17 +0000 |
| Subject: | Bug #12004 Updated: problem with fopen over ftp and a related fgets | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-4916@lists.php.net to get a copy of this message | ||
ID: 12004
Updated by: wez@php.net
Reported By: koenig@internet24.de
-Status: Analyzed
+Status: Assigned
Bug Type: *Directory/Filesystem functions
Operating System: linux
PHP Version: 4.0.5
-Assigned To:
+Assigned To: wez
New Comment:
We can probably do something about this with the new
streams architecture.
Assigning to myself.
Previous Comments:
------------------------------------------------------------------------
[2001-12-17 05:33:01] alan_k@php.net
browser changed the title for some reason...
------------------------------------------------------------------------
[2001-12-17 05:28:35] alan_k@php.net
The following patch will issue a warning for trying to open a ftp file
in anything other than read/write, - as no other methods are supported
by fopen(ftp)
as far as producing errors on 'writing to an ftp file opened read only'
- this is more complex as there is no indicators on the socket to tell
wheter it was opened read or write,
(internally the socket is opened rw as the actual connection is a 2 way
communication)
Index: ftp_fopen_wrapper.c
===================================================================
RCS file: /repository/php4/ext/standard/ftp_fopen_wrapper.c,v
retrieving revision 1.11
diff -u -r1.11 ftp_fopen_wrapper.c
--- ftp_fopen_wrapper.c 9 Sep 2001 13:29:18 -0000 1.11
+++ ftp_fopen_wrapper.c 17 Dec 2001 10:24:06 -0000
@@ -101,6 +101,14 @@
*issock = BAD_URL;
return NULL;
}
+ if (strcmp(mode, "r") && strcmp(mode, "w")) {
+ php_error(E_WARNING, "Invalid mode : ftp can only
access files in (r)ead or (w)rite mode");
+ php_url_free(resource);
+ *issock = BAD_URL;
+ return NULL;
+ }
+
+
/* use port 21 if one wasn't specified */
if (resource->port == 0)
resource->port = 21;
------------------------------------------------------------------------
[2001-10-20 22:40:26] sniper@php.net
Reproduced with PHP 4.1.0RC1
Seems like this is not supported at all..
--Jani
------------------------------------------------------------------------
[2001-07-10 06:07:36] koenig@internet24.de
Configure './configure'
'--with-apxs=/usr/local/apache/bin/apxs'
Command '--with-mysql' '--with-pgsql' '--with-zlib'
'--enable-ftp'
'--with-gd'
'--with-jpeg-dir=/usr/local/lib'
'--enable-versioning'
'--enable-track-vars=yes'
'--enable-url-includes'
'--enable-sysvshm'
'--enable-syscsem' '--with-gettext'
<?php
$file = "user:secret@somewhere.org/path/file.txt";
if (!($fp = fopen($file, "r+"))) {
echo "error: can't open file<br>";
exit;
}
fputs($fp, "test number one...");
fputs($fp, "test number two...");
fputs($fp, "etc...");
fclose($fp);
?>
-------------------------------
The problem is, that nothing is written in the file even though
fopen,fputs and
fclose do not return an error.
If you use fopen($file, "a+") the strings are written to file. But now
the problem is, that fopen tries to create that file even if it already
exists.
Ciao,
Tobias
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=12004&edit=1