From: keith at ksmith dot com Operating system: Linux PHP version: 4.3.1 PHP Bug Type: Feature/Change Request Bug description: ftp 'quote' command not available _exec & _site seem redundant
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 bug report at http://bugs.php.net/?id=22970&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=22970&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=22970&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=22970&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=22970&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=22970&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=22970&r=support Expected behavior: http://bugs.php.net/fix.php?id=22970&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=22970&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=22970&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=22970&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22970&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=22970&r=dst IIS Stability: http://bugs.php.net/fix.php?id=22970&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=22970&r=gnused