ID: 22970 Updated by: [EMAIL PROTECTED] Reported By: keith at ksmith dot com -Status: Open +Status: Closed Bug Type: Feature/Change Request Operating System: Linux PHP Version: 4.3.1 New Comment:
Thanks for the request, but we're a step ahead of you. ftp_raw() has already been added to the development branch of PHP (this means it'll show up in PHP5) and does almost exactly what your proposed ftp_quote would do (except for how it handles the response code). The documentation for this function exists in CVS, but the online manual hasn't been recompiled since its addition. Previous Comments: ------------------------------------------------------------------------ [2003-03-30 22:28:15] keith at ksmith dot com No ability to send arbitrary commands to ftp server like 'quote' command in ftp. Trivial addition. Also ftp_exec and ftp_site seem redundant. The former does a 'SITE EXEC' in front of command the latter does 'SITE' in front of command. The patch is trivial and available at: http://linuxap.ksmith.com/archive/misc/php-4.3.1-ftp_quote.patch I also include it here to 4.3.1. It should probably patch other versions as well: diff -urN php-4.3.1/ext/ftp/ftp.c php-4.3.1.new/ext/ftp/ftp.c --- php-4.3.1/ext/ftp/ftp.c 2002-10-12 18:40:46.000000000 -0700 +++ php-4.3.1.new/ext/ftp/ftp.c 2003-03-30 20:28:35.000000000 -0700 @@ -417,6 +417,22 @@ } /* }}} */ +/* {{{ ftp_quote + */ +int +ftp_quote(ftpbuf_t *ftp, const char *cmd) +{ + if (ftp == NULL) + return 0; + if (!ftp_putcmd(ftp, cmd, NULL)) + return 0; + if (!ftp_getresp(ftp) || ftp->resp != 200) + return 0; + + return 1; +} +/* }}} */ + /* {{{ ftp_chdir */ int diff -urN php-4.3.1/ext/ftp/ftp.h php-4.3.1.new/ext/ftp/ftp.h --- php-4.3.1/ext/ftp/ftp.h 2002-10-03 05:16:44.000000000 -0700 +++ php-4.3.1.new/ext/ftp/ftp.h 2003-03-30 20:45:03.000000000 -0700 @@ -179,6 +179,9 @@ /* sends a SITE command to the server */ int ftp_site(ftpbuf_t *ftp, const char *cmd); +/* sends an arbitrary command string to the server */ +int ftp_quote(ftpbuf_t *ftp, const char *cmd); + /* retrieves part of a file and saves its contents to outfp * returns true on success, false on error */ diff -urN php-4.3.1/ext/ftp/php_ftp.c php-4.3.1.new/ext/ftp/php_ftp.c --- php-4.3.1/ext/ftp/php_ftp.c 2002-12-05 23:08:21.000000000 -0700 +++ php-4.3.1.new/ext/ftp/php_ftp.c 2003-03-30 20:47:55.000000000 -0700 @@ -71,6 +71,7 @@ PHP_FE(ftp_rename, NULL) PHP_FE(ftp_delete, NULL) PHP_FE(ftp_site, NULL) + PHP_FE(ftp_quote, NULL) PHP_FE(ftp_close, NULL) PHP_FE(ftp_set_option, NULL) PHP_FE(ftp_get_option, NULL) @@ -1055,6 +1056,31 @@ } /* }}} */ +/* {{{ proto bool ftp_quote(resource stream, string cmd) + Sends an arbitrary command to the server */ +PHP_FUNCTION(ftp_quote) +{ + zval *z_ftp; + ftpbuf_t *ftp; + char *cmd; + int cmd_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_ftp, &cmd, &cmd_len) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name, le_ftpbuf); + + /* send the command */ + if (!ftp_quote(ftp, cmd)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf); + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + /* {{{ proto void ftp_close(resource stream) Closes the FTP stream */ PHP_FUNCTION(ftp_close) diff -urN php-4.3.1/ext/ftp/php_ftp.h php-4.3.1.new/ext/ftp/php_ftp.h --- php-4.3.1/ext/ftp/php_ftp.h 2002-10-03 04:33:05.000000000 -0700 +++ php-4.3.1.new/ext/ftp/php_ftp.h 2003-03-30 20:48:15.000000000 -0700 @@ -58,6 +58,7 @@ PHP_FUNCTION(ftp_rename); PHP_FUNCTION(ftp_delete); PHP_FUNCTION(ftp_site); +PHP_FUNCTION(ftp_quote); PHP_FUNCTION(ftp_close); PHP_FUNCTION(ftp_set_option); PHP_FUNCTION(ftp_get_option); ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22970&edit=1