}
+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)
{
/* 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);
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)
/* 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;
}
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);