diff options
author | Derick Rethans <derick@php.net> | 2000-09-13 22:00:31 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2000-09-13 22:00:31 +0000 |
commit | c7d31495bf968e6709a47bc765256e11670e390d (patch) | |
tree | b1c964010fac2068451ef7db45141ada310dd5a7 | |
parent | a6bb6f5df3909915eb4f88a8a6d1af5d657d17d5 (diff) | |
download | php-git-c7d31495bf968e6709a47bc765256e11670e390d.tar.gz |
- Added ftp_exec to the ftp functions (thanks to <jhennebicq@i-d.net>)
@ Added ftp_exec to the ftp functions (thanks to <jhennebicq@i-d.net>)
@ (Derick)
-rw-r--r-- | ext/ftp/ftp.c | 14 | ||||
-rw-r--r-- | ext/ftp/ftp.h | 3 | ||||
-rw-r--r-- | ext/ftp/php_ftp.c | 31 | ||||
-rw-r--r-- | ext/ftp/php_ftp.h | 1 |
4 files changed, 49 insertions, 0 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index 45b01e799d..a750265fcc 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -315,6 +315,20 @@ ftp_pwd(ftpbuf_t *ftp) int +ftp_exec(ftpbuf_t *ftp, const char *cmd) +{ + if (ftp == NULL) + return 0; + if (!ftp_putcmd(ftp, "SITE EXEC", cmd)) + return 0; + if (!ftp_getresp(ftp) || ftp->resp != 200) + return 0; + + return 1; +} + + +int ftp_chdir(ftpbuf_t *ftp, const char *dir) { if (ftp == NULL) diff --git a/ext/ftp/ftp.h b/ext/ftp/ftp.h index ea9a25d047..2e3d1bc8d0 100644 --- a/ext/ftp/ftp.h +++ b/ext/ftp/ftp.h @@ -100,6 +100,9 @@ const char* ftp_syst(ftpbuf_t *ftp); /* returns the present working directory (NULL on error) */ const char* ftp_pwd(ftpbuf_t *ftp); +/* exec a command [special features], return true on success, false on error */ +int ftp_exec(ftpbuf_t *ftp, const char *cmd); + /* changes directories, return true on success, false on error */ int ftp_chdir(ftpbuf_t *ftp, const char *dir); diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index 233d707972..061b2aac6c 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -48,6 +48,7 @@ function_entry php_ftp_functions[] = { PHP_FE(ftp_pwd, NULL) PHP_FE(ftp_cdup, NULL) PHP_FE(ftp_chdir, NULL) + PHP_FE(ftp_exec, NULL) PHP_FE(ftp_mkdir, NULL) PHP_FE(ftp_rmdir, NULL) PHP_FE(ftp_nlist, NULL) @@ -272,6 +273,36 @@ PHP_FUNCTION(ftp_chdir) /* change directories */ if (!ftp_chdir(ftp, arg2->value.str.val)) { php_error(E_WARNING, "ftp_chdir: %s", ftp->inbuf); + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto int ftp_exec(int stream, string command) + Changes directories */ +PHP_FUNCTION(ftp_exec) +{ + pval *arg1, *arg2; + ftpbuf_t *ftp; + + /* arg1 - ftp + * arg2 - command + */ + if (ARG_COUNT(ht) != 2 || + getParameters(ht, 2, &arg1, &arg2) == FAILURE) + { + WRONG_PARAM_COUNT; + } + + convert_to_string(arg2); + + FTPBUF(ftp, arg1); + + /* change directories */ + if (!ftp_exec(ftp, arg2->value.str.val)) { + php_error(E_WARNING, "ftp_exec: %s", ftp->inbuf); RETURN_FALSE; } diff --git a/ext/ftp/php_ftp.h b/ext/ftp/php_ftp.h index e602fe79fc..79a8e16642 100644 --- a/ext/ftp/php_ftp.h +++ b/ext/ftp/php_ftp.h @@ -45,6 +45,7 @@ PHP_FUNCTION(ftp_login); PHP_FUNCTION(ftp_pwd); PHP_FUNCTION(ftp_cdup); PHP_FUNCTION(ftp_chdir); +PHP_FUNCTION(ftp_exec); PHP_FUNCTION(ftp_mkdir); PHP_FUNCTION(ftp_rmdir); PHP_FUNCTION(ftp_nlist); |