{
if (ftp == NULL)
return NULL;
- if (ftp->fd)
+ if (ftp->fd != -1)
close(ftp->fd);
ftp_gc(ftp);
free(ftp);
return 1;
}
+
+int
+ftp_site(ftpbuf_t *ftp, const char *cmd)
+{
+ if (ftp == NULL)
+ return 0;
+
+ if (!ftp_putcmd(ftp, "SITE", cmd))
+ return 0;
+ if (!ftp_getresp(ftp) || ftp->resp < 200 || ftp->resp >= 300)
+ return 0;
+
+ return 1;
+}
+
/* static functions */
int
/* deletes the file from the server */
int ftp_delete(ftpbuf_t *ftp, const char *path);
+/* sends a SITE command to the server */
+int ftp_site(ftpbuf_t *ftp, const char *cmd);
+
#endif
PHP_FE(ftp_mdtm, NULL)
PHP_FE(ftp_rename, NULL)
PHP_FE(ftp_delete, NULL)
+ PHP_FE(ftp_site, NULL)
PHP_FE(ftp_quit, NULL)
{NULL, NULL, NULL}
};
}
/* }}} */
+/* {{{ proto int ftp_site(int stream, string cmd)
+ Sends a SITE command to the server */
+PHP_FUNCTION(ftp_site)
+{
+ pval *arg1, *arg2;
+ ftpbuf_t *ftp;
+
+ /* arg1 - ftp
+ * arg2 - cmd
+ */
+ if ( ARG_COUNT(ht) != 2 ||
+ getParameters(ht, 2, &arg1, &arg2) == FAILURE)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ FTPBUF(ftp, arg1);
+ convert_to_string(arg2);
+
+ /* send the site command */
+ if (!ftp_site(ftp, arg2->value.str.val)) {
+ php_error(E_WARNING, "ftp_site: %s", ftp->inbuf);
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
/* {{{ proto int ftp_quit(int stream)
Closes the FTP stream */
PHP_FUNCTION(ftp_quit)
PHP_FUNCTION(ftp_mdtm);
PHP_FUNCTION(ftp_rename);
PHP_FUNCTION(ftp_delete);
+PHP_FUNCTION(ftp_site);
PHP_FUNCTION(ftp_quit);
#define phpext_ftp_ptr php_ftp_module_ptr