version 1.1.1.1, 2012/02/21 23:47:56
|
version 1.1.1.5, 2014/06/15 20:03:48
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| PHP Version 5 | |
| PHP Version 5 | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1997-2012 The PHP Group | | | Copyright (c) 1997-2014 The PHP Group | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 3.01 of the PHP license, | |
| 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 | |
| that is bundled with this package in the file LICENSE, and is | |
Line 41
|
Line 41
|
#include "php_ftp.h" |
#include "php_ftp.h" |
#include "ftp.h" |
#include "ftp.h" |
|
|
static int le_ftpbuf; | static int le_ftpbuf; |
#define le_ftpbuf_name "FTP Buffer" |
#define le_ftpbuf_name "FTP Buffer" |
|
|
/* {{{ arginfo */ |
/* {{{ arginfo */ |
Line 607 PHP_FUNCTION(ftp_chmod)
|
Line 607 PHP_FUNCTION(ftp_chmod)
|
int filename_len; |
int filename_len; |
long mode; |
long mode; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rls", &z_ftp, &mode, &filename, &filename_len) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlp", &z_ftp, &mode, &filename, &filename_len) == FAILURE) { |
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
|
|
Line 660 PHP_FUNCTION(ftp_nlist)
|
Line 660 PHP_FUNCTION(ftp_nlist)
|
char **nlist, **ptr, *dir; |
char **nlist, **ptr, *dir; |
int dir_len; |
int dir_len; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_ftp, &dir, &dir_len) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp", &z_ftp, &dir, &dir_len) == FAILURE) { |
return; |
return; |
} |
} |
|
|
Line 784 PHP_FUNCTION(ftp_nb_fget)
|
Line 784 PHP_FUNCTION(ftp_nb_fget)
|
ftptype_t xtype; |
ftptype_t xtype; |
php_stream *stream; |
php_stream *stream; |
char *file; |
char *file; |
int file_len, ret; | int file_len; |
long mode, resumepos=0; | long mode, resumepos=0, ret; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrsl|l", &z_ftp, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) { |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrsl|l", &z_ftp, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) { |
return; |
return; |
Line 857 PHP_FUNCTION(ftp_get)
|
Line 857 PHP_FUNCTION(ftp_get)
|
int local_len, remote_len; |
int local_len, remote_len; |
long mode, resumepos=0; |
long mode, resumepos=0; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssl|l", &z_ftp, &local, &local_len, &remote, &remote_len, &mode, &resumepos) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &local, &local_len, &remote, &remote_len, &mode, &resumepos) == FAILURE) { |
return; |
return; |
} |
} |
|
|
Line 874 PHP_FUNCTION(ftp_get)
|
Line 874 PHP_FUNCTION(ftp_get)
|
#endif |
#endif |
|
|
if (ftp->autoseek && resumepos) { |
if (ftp->autoseek && resumepos) { |
outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); | outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", REPORT_ERRORS, NULL); |
if (outstream == NULL) { |
if (outstream == NULL) { |
outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); | outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", REPORT_ERRORS, NULL); |
} |
} |
if (outstream != NULL) { |
if (outstream != NULL) { |
/* if autoresume is wanted seek to end */ |
/* if autoresume is wanted seek to end */ |
Line 888 PHP_FUNCTION(ftp_get)
|
Line 888 PHP_FUNCTION(ftp_get)
|
} |
} |
} |
} |
} else { |
} else { |
outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); | outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", REPORT_ERRORS, NULL); |
} |
} |
|
|
if (outstream == NULL) { |
if (outstream == NULL) { |
Line 935 PHP_FUNCTION(ftp_nb_get)
|
Line 935 PHP_FUNCTION(ftp_nb_get)
|
mode = FTPTYPE_IMAGE; |
mode = FTPTYPE_IMAGE; |
#endif |
#endif |
if (ftp->autoseek && resumepos) { |
if (ftp->autoseek && resumepos) { |
outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); | outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt+" : "rb+", REPORT_ERRORS, NULL); |
if (outstream == NULL) { |
if (outstream == NULL) { |
outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); | outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", REPORT_ERRORS, NULL); |
} |
} |
if (outstream != NULL) { |
if (outstream != NULL) { |
/* if autoresume is wanted seek to end */ |
/* if autoresume is wanted seek to end */ |
Line 949 PHP_FUNCTION(ftp_nb_get)
|
Line 949 PHP_FUNCTION(ftp_nb_get)
|
} |
} |
} |
} |
} else { |
} else { |
outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); | outstream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "wt" : "wb", REPORT_ERRORS, NULL); |
} |
} |
|
|
if (outstream == NULL) { |
if (outstream == NULL) { |
Line 963 PHP_FUNCTION(ftp_nb_get)
|
Line 963 PHP_FUNCTION(ftp_nb_get)
|
|
|
if ((ret = ftp_nb_get(ftp, outstream, remote, xtype, resumepos TSRMLS_CC)) == PHP_FTP_FAILED) { |
if ((ret = ftp_nb_get(ftp, outstream, remote, xtype, resumepos TSRMLS_CC)) == PHP_FTP_FAILED) { |
php_stream_close(outstream); |
php_stream_close(outstream); |
|
ftp->stream = NULL; |
VCWD_UNLINK(local); |
VCWD_UNLINK(local); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf); |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf); |
RETURN_LONG(PHP_FTP_FAILED); |
RETURN_LONG(PHP_FTP_FAILED); |
} |
} |
|
|
if (ret == PHP_FTP_FINISHED) { | if (ret == PHP_FTP_FINISHED){ |
php_stream_close(outstream); |
php_stream_close(outstream); |
|
ftp->stream = NULL; |
} |
} |
|
|
RETURN_LONG(ret); |
RETURN_LONG(ret); |
Line 982 PHP_FUNCTION(ftp_nb_continue)
|
Line 984 PHP_FUNCTION(ftp_nb_continue)
|
{ |
{ |
zval *z_ftp; |
zval *z_ftp; |
ftpbuf_t *ftp; |
ftpbuf_t *ftp; |
int ret; | long ret; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_ftp) == FAILURE) { |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_ftp) == FAILURE) { |
return; |
return; |
Line 1003 PHP_FUNCTION(ftp_nb_continue)
|
Line 1005 PHP_FUNCTION(ftp_nb_continue)
|
|
|
if (ret != PHP_FTP_MOREDATA && ftp->closestream) { |
if (ret != PHP_FTP_MOREDATA && ftp->closestream) { |
php_stream_close(ftp->stream); |
php_stream_close(ftp->stream); |
|
ftp->stream = NULL; |
} |
} |
|
|
if (ret == PHP_FTP_FAILED) { |
if (ret == PHP_FTP_FAILED) { |
Line 1120 PHP_FUNCTION(ftp_put)
|
Line 1123 PHP_FUNCTION(ftp_put)
|
ftpbuf_t *ftp; |
ftpbuf_t *ftp; |
ftptype_t xtype; |
ftptype_t xtype; |
char *remote, *local; |
char *remote, *local; |
int remote_len, local_len; | long remote_len, local_len; |
long mode, startpos=0; |
long mode, startpos=0; |
php_stream *instream; |
php_stream *instream; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) { |
return; |
return; |
} |
} |
|
|
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); |
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); |
XTYPE(xtype, mode); |
XTYPE(xtype, mode); |
|
|
if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) { | if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", REPORT_ERRORS, NULL))) { |
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
|
|
Line 1173 PHP_FUNCTION(ftp_nb_put)
|
Line 1176 PHP_FUNCTION(ftp_nb_put)
|
ftpbuf_t *ftp; |
ftpbuf_t *ftp; |
ftptype_t xtype; |
ftptype_t xtype; |
char *remote, *local; |
char *remote, *local; |
int remote_len, local_len, ret; | int remote_len, local_len; |
long mode, startpos=0; | long mode, startpos=0, ret; |
php_stream *instream; |
php_stream *instream; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) { |
return; |
return; |
} |
} |
|
|
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); |
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); |
XTYPE(xtype, mode); |
XTYPE(xtype, mode); |
|
|
if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) { | if (!(instream = php_stream_open_wrapper(local, mode == FTPTYPE_ASCII ? "rt" : "rb", REPORT_ERRORS, NULL))) { |
RETURN_FALSE; |
RETURN_FALSE; |
} |
} |
|
|
Line 1214 PHP_FUNCTION(ftp_nb_put)
|
Line 1217 PHP_FUNCTION(ftp_nb_put)
|
|
|
if (ret != PHP_FTP_MOREDATA) { |
if (ret != PHP_FTP_MOREDATA) { |
php_stream_close(instream); |
php_stream_close(instream); |
|
ftp->stream = NULL; |
} |
} |
|
|
if (ret == PHP_FTP_FAILED) { |
if (ret == PHP_FTP_FAILED) { |
Line 1233 PHP_FUNCTION(ftp_size)
|
Line 1237 PHP_FUNCTION(ftp_size)
|
char *file; |
char *file; |
int file_len; |
int file_len; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_ftp, &file, &file_len) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp", &z_ftp, &file, &file_len) == FAILURE) { |
return; |
return; |
} |
} |
|
|
Line 1253 PHP_FUNCTION(ftp_mdtm)
|
Line 1257 PHP_FUNCTION(ftp_mdtm)
|
char *file; |
char *file; |
int file_len; |
int file_len; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_ftp, &file, &file_len) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp", &z_ftp, &file, &file_len) == FAILURE) { |
return; |
return; |
} |
} |
|
|