cvs: pear /Net_FTP/Net FTP.php
| From: | Tobias Schlitt | Date: | Sun, 14 Mar 2004 13:23:36 +0000 |
| Subject: | cvs: pear /Net_FTP/Net FTP.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-17390@lists.php.net to get a copy of this message | ||
toby Sun Mar 14 08:23:36 2004 EDT
Modified files:
/pear/Net_FTP/Net FTP.php
Log:
* Fix bug #723: Timeout for connect cannot be set.
http://cvs.php.net/diff.php/pear/Net_FTP/Net/FTP.php?r1=1.10&r2=1.11&ty=u
Index: pear/Net_FTP/Net/FTP.php
diff -u pear/Net_FTP/Net/FTP.php:1.10 pear/Net_FTP/Net/FTP.php:1.11
--- pear/Net_FTP/Net/FTP.php:1.10 Sun Mar 14 08:14:59 2004
+++ pear/Net_FTP/Net/FTP.php Sun Mar 14 08:23:36 2004
@@ -14,7 +14,7 @@
// | Authors: Tobias Schlitt <toby@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: FTP.php,v 1.10 2004/03/14 13:14:59 toby Exp $
+// $Id: FTP.php,v 1.11 2004/03/14 13:23:36 toby Exp $
require_once 'PEAR.php';
@@ -979,6 +979,27 @@
}
/**
+ * Set the timeout for FTP operations
+ * Use this method to set a timeout for FTP operation. Timeout has to be an integer.
+ *
+ * @acess public
+ * @param int $timeout the timeout to use
+ * @return bool True on success, otherwise PEAR::Error
+ */
+
+ function setTimeout ( $timeout = 0 )
+ {
+ if (!is_int($timeout) || ($timeout < 0)) {
+ return PEAR::raiseError("Timeout $timeout is invalid, has to be an integer >=
0");
+ }
+ $res = @ftp_set_option($this->_handle, FTP_TIMEOUT_SEC, $timeout);
+ if (!$res) {
+ return PEAR::raiseError("Set timeout failed.");
+ }
+ return true;
+ }
+
+ /**
* Adds an extension to a mode-directory
* The mode-directory saves file-extensions coresponding to filetypes
* (ascii e.g.: 'php', 'txt', 'htm',...; binary e.g.:
'jpg', 'gif', 'exe',...).
@@ -1123,6 +1144,18 @@
return @$this->_file_extensions[$ext];
}
+ /**
+ * Get the currently set timeout.
+ * Returns the actual timeout set.
+ *
+ * @access public
+ * @return int The actual timeout
+ */
+
+ function getTimeout ( )
+ {
+ return ftp_get_option($this->_handle, FTP_TIMEOUT_SEC);
+ }
/**
* Adds a Net_FTP_Observer instance to the list of observers