]> granicus.if.org Git - php/commitdiff
MFB(r-1.74.2.13) Bug #25314 ASCII mode transfers behaving like binary when initiated...
authorSara Golemon <pollita@php.net>
Mon, 8 Sep 2003 22:40:12 +0000 (22:40 +0000)
committerSara Golemon <pollita@php.net>
Mon, 8 Sep 2003 22:40:12 +0000 (22:40 +0000)
ext/ftp/php_ftp.c

index 902b0565e424a27286b32b5a8c595598b16a1b1e..0d0d7e0ae945a93a8fd0e77a9aa84a9ed1e4c54f 100644 (file)
@@ -649,9 +649,9 @@ PHP_FUNCTION(ftp_get)
        }
 
        if (ftp->autoseek && resumepos) {
-               outstream = php_stream_open_wrapper(local, "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
+               outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
                if (outstream == NULL) {
-                       outstream = php_stream_open_wrapper(local, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
+                       outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
                }
                if (outstream != NULL) {
                        /* if autoresume is wanted seek to end */
@@ -663,7 +663,7 @@ PHP_FUNCTION(ftp_get)
                        }
                }
        } else {
-               outstream = php_stream_open_wrapper(local, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
+               outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
        }
 
        if (outstream == NULL)  {
@@ -707,9 +707,9 @@ PHP_FUNCTION(ftp_nb_get)
        }
 
        if (ftp->autoseek && resumepos) {
-               outstream = php_stream_open_wrapper(local, "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
+               outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
                if (outstream == NULL) {
-                       outstream = php_stream_open_wrapper(local, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
+                       outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
                }
                if (outstream != NULL) {
                        /* if autoresume is wanted seek to end */
@@ -721,7 +721,7 @@ PHP_FUNCTION(ftp_nb_get)
                        }
                }
        } else {
-               outstream = php_stream_open_wrapper(local, "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
+               outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL);
        }
 
        if (outstream == NULL)  {
@@ -902,7 +902,7 @@ PHP_FUNCTION(ftp_put)
        ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
        XTYPE(xtype, mode);
 
-       if (!(instream = php_stream_open_wrapper(local, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) {
+       if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) {
                RETURN_FALSE;
        }
 
@@ -955,7 +955,7 @@ PHP_FUNCTION(ftp_nb_put)
        ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf);
        XTYPE(xtype, mode);
 
-       if (!(instream = php_stream_open_wrapper(local, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) {
+       if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) {
                RETURN_FALSE;
        }