Source for file Ftp.php
Documentation is available at Ftp.php
6: * @copyright Copyright (c) 2004, 2010 David Grudl
7: * @license http://nettephp.com/license Nette license
8: * @link http://nettephp.com
16: * Access to a FTP server.
20: * $ftp->connect('ftp.example.com');
21: * $ftp->login('anonymous', 'example@example.com');
22: * $ftp->get('file.txt', 'README', Ftp::ASCII);
25: * @copyright Copyright (c) 2004, 2010 David Grudl
30: /**#@+ FTP constant alias */
56: throw new Exception("PHP extension FTP is not loaded.");
63: * Magic method (do not call directly).
64: * @param string method name
65: * @param array arguments
67: * @throws MemberAccessException
68: * @throws FtpException
74: $func =
$silent ?
substr($name, 3) :
$name;
75: static $aliases =
array(
76: 'sslconnect' =>
'ssl_connect',
77: 'getoption' =>
'get_option',
78: 'setoption' =>
'set_option',
79: 'nbcontinue' =>
'nb_continue',
80: 'nbfget' =>
'nb_fget',
81: 'nbfput' =>
'nb_fput',
85: $func =
'ftp_' .
(isset($aliases[$func]) ?
$aliases[$func] :
$func);
87: if (!function_exists($func)) {
88: return parent::__call($name, $args);
94: if ($func ===
'ftp_connect' ||
$func ===
'ftp_ssl_connect') {
95: $this->state =
array($name =>
$args);
96: $this->resource =
call_user_func_array($func, $args);
101: throw new FtpException("Not connected to FTP server. Call connect() or ssl_connect() first.");
104: if ($func ===
'ftp_login' ||
$func ===
'ftp_pasv') {
105: $this->state[$name] =
$args;
111: if ($func ===
'ftp_chdir' ||
$func ===
'ftp_cdup') {
112: $this->state['chdir'] =
array(ftp_pwd($this->resource));
126: * Reconnects to FTP server.
132: foreach ($this->state as $name =>
$args) {
140: * Checks if file or directory exists.
152: * Checks if directory exists.
158: $current =
$this->pwd();
170: * Recursive creates directories.
178: while (!empty($parts)) {
196: * FTP server exception.
198: * @package Nette\Web