diff options
Diffstat (limited to 'ext/standard/ftp_fopen_wrapper.c')
| -rw-r--r-- | ext/standard/ftp_fopen_wrapper.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index e408615b6..c2e3896dc 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ | Sara Golemon <pollita@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.85.2.4.2.6 2007/10/04 13:31:11 jani Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.85.2.4.2.9 2008/01/08 19:10:16 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -300,19 +300,21 @@ connect_errexit: /* {{{ php_fopen_do_pasv */ -static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, int ip_size, char **phoststart TSRMLS_DC) +static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, size_t ip_size, char **phoststart TSRMLS_DC) { char tmp_line[512]; int result, i; unsigned short portno; char *tpath, *ttpath, *hoststart=NULL; +#ifdef HAVE_IPV6 /* We try EPSV first, needed for IPv6 and works on some IPv4 servers */ php_stream_write_string(stream, "EPSV\r\n"); result = GET_FTP_RESULT(stream); /* check if we got a 229 response */ if (result != 229) { +#endif /* EPSV failed, let's try PASV */ php_stream_write_string(stream, "PASV\r\n"); result = GET_FTP_RESULT(stream); @@ -357,6 +359,8 @@ static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, int ip_siz tpath++; /* pull out the LSB of the port */ portno += (unsigned short) strtoul(tpath, &ttpath, 10); + +#ifdef HAVE_IPV6 } else { /* parse epsv command (|||6446|) */ for (i = 0, tpath = tmp_line + 4; *tpath; tpath++) { @@ -372,7 +376,8 @@ static unsigned short php_fopen_do_pasv(php_stream *stream, char *ip, int ip_siz /* pull out the port */ portno = (unsigned short) strtoul(tpath + 1, &ttpath, 10); } - +#endif + if (ttpath == NULL) { /* didn't get correct response from EPSV/PASV */ return 0; @@ -771,6 +776,7 @@ static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, char *url, int f ssb->sb.st_mode |= S_IFDIR; } + php_stream_write_string(stream, "TYPE I\r\n"); /* we need this since some servers refuse to accept SIZE command in ASCII mode */ php_stream_printf(stream TSRMLS_CC, "SIZE %s\r\n", (resource->path != NULL ? resource->path : "/")); result = GET_FTP_RESULT(stream); if (result < 200 || result > 299) { |
