]>
Commit | Line | Data |
---|---|---|
fb98beff ER |
1 | --- PHP_5_3/ext/standard/ftp_fopen_wrapper.c 2010/12/13 14:29:42 306341 |
2 | +++ PHP_5_3/ext/standard/ftp_fopen_wrapper.c 2010/12/13 16:53:26 306342 | |
3 | @@ -98,13 +98,33 @@ | |
4 | static int php_stream_ftp_stream_close(php_stream_wrapper *wrapper, php_stream *stream TSRMLS_DC) | |
5 | { | |
6 | php_stream *controlstream = (php_stream *)stream->wrapperdata; | |
7 | + int ret = 0; | |
8 | ||
9 | if (controlstream) { | |
10 | + if (strpbrk(stream->mode, "wa+")) { | |
11 | + char tmp_line[512]; | |
12 | + int result; | |
13 | + | |
14 | + /* For write modes close data stream first to signal EOF to server */ | |
15 | + stream->wrapperdata = NULL; | |
16 | + php_stream_close(stream); | |
17 | + stream = NULL; | |
18 | + | |
19 | + result = GET_FTP_RESULT(controlstream); | |
20 | + if (result != 226 && result != 250) { | |
21 | + php_error_docref(NULL TSRMLS_CC, E_WARNING, "FTP server error %d:%s", result, tmp_line); | |
22 | + ret = EOF; | |
23 | + } | |
24 | + } | |
25 | + | |
26 | php_stream_write_string(controlstream, "QUIT\r\n"); | |
27 | php_stream_close(controlstream); | |
28 | - stream->wrapperdata = NULL; | |
29 | + if (stream) { | |
30 | + stream->wrapperdata = NULL; | |
31 | + } | |
32 | } | |
33 | - return 0; | |
34 | + | |
35 | + return ret; | |
36 | } | |
37 | /* }}} */ | |
38 |