Öffentliche Methoden | |
| Ftp ($url) | |
| connect ($url) | |
| put ($source, $dest, $mode=FTP_BINARY) | |
| mkdirs ($strPath) | |
| close () | |
Öffentliche Attribute | |
| $verb | |
| $url | |
| $log = array() | |
| $mode = FTP_ASCII | |
| $passive = false | |
| $ok = true | |
Definiert in Zeile 30 der Datei Ftp.class.php.
| Ftp::close | ( | ) |
Schlie�en der FTP-Verbindung.
Sollte unbedingt aufgerufen werden, damit keine unn�tigen Sockets aufbleiben.
Definiert in Zeile 212 der Datei Ftp.class.php.
00213 { 00214 if ( !$this->ok ) // Noch alles ok? 00215 return; 00216 00217 if ( ! @ftp_quit( $this->verb ) ) 00218 { 00219 // Das Schlie�en der Verbindung hat nicht funktioniert. 00220 // Eigentlich k�nnten wir das ignorieren, aber wir sind anst�ndig und melden eine Fehler. 00221 $this->log[] = 'failed to close connection'; 00222 $this->ok = false; 00223 return; 00224 } 00225 }
| Ftp::connect | ( | $ | url | ) |
Definiert in Zeile 49 der Datei Ftp.class.php.
Benutzt $conf, $url und Logger::error().
Wird benutzt von Ftp().
00050 { 00051 $this->url = $url; 00052 00053 global $conf; 00054 00055 $conf_ftp = $conf['publish']['ftp']; 00056 $ftp = parse_url( $this->url ); 00057 00058 // Die projektspezifischen Werte gewinnen bei �berschneidungen mit den Default-Werten 00059 $ftp = array_merge($conf_ftp,$ftp); 00060 00061 // Nur FTP und FTPS (seit PHP 4.3) erlaubt 00062 if ( !ereg('^ftps?$',$ftp['scheme']) ) 00063 { 00064 $this->log[] = 'Unknown scheme in FTP Url: '.$ftp['scheme']; 00065 $this->log[] = 'Only FTP (and FTPS, if compiled in) are supported'; 00066 $this->ok = false; 00067 return; 00068 } 00069 00070 if ( function_exists('ftp_ssl_connect') && $ftp['scheme'] == 'ftps' ) 00071 $this->verb = @ftp_ssl_connect( $ftp['host'],$ftp['port'] ); 00072 else 00073 $this->verb = @ftp_connect( $ftp['host'],$ftp['port'] ); 00074 00075 if ( !$this->verb ) 00076 { 00077 $this->log[] = 'Cannot connect to '.$ftp['scheme'].'-server: '.$ftp['host'].':'.$ftp['port']; 00078 $this->ok = false; 00079 00080 Logger::error('Cannot connect to '.$ftp['host'].':'.$ftp['port']); 00081 return; 00082 } 00083 00084 $this->log[] = 'Connected to FTP server '.$ftp['host'].':'.$ftp['port']; 00085 00086 if ( empty($ftp['user']) ) 00087 $ftp['user'] = 'anonymous'; 00088 00089 if ( ! ftp_login( $this->verb,$ftp['user'],$ftp['pass'] ) ) 00090 { 00091 $this->log[] = 'Unable to login as user '.$ftp['user']; 00092 $this->ok = false; 00093 return; 00094 } 00095 00096 $this->log[] = 'Logged in as user '.$ftp['user']; 00097 00098 $pasv = (!empty($ftp['fragment']) && $ftp['fragment'] == 'passive' ); 00099 00100 $this->log[] = 'entering passive mode '.($pasv?'on':'off'); 00101 if ( ! ftp_pasv($this->verb,true) ) 00102 { 00103 $this->log[] = 'cannot switch PASV mode'; 00104 $this->ok = false; 00105 return; 00106 } 00107 00108 if ( !empty($ftp['query']) ) 00109 { 00110 parse_str( $ftp['query'],$ftp_var ); 00111 00112 if ( isset( $ftp_var['site'] ) ) 00113 { 00114 $site_commands = explode( ',',$ftp_var['site'] ); 00115 foreach( $site_commands as $cmd ) 00116 { 00117 $this->log .= 'executing SITE command: '.$cmd; 00118 00119 if ( ! @ftp_site( $this->verb,$cmd ) ) 00120 { 00121 $this->log[] = 'unable to do SITE command: '.$cmd; 00122 $this->ok = false; 00123 return; 00124 } 00125 } 00126 } 00127 } 00128 00129 $this->path = ereg_replace( '\/$','',$ftp['path']); 00130 00131 $this->log[] = 'Changing directory to '.$this->path; 00132 00133 if ( ! @ftp_chdir( $this->verb,$this->path ) ) 00134 { 00135 $this->log[] = 'unable CHDIR to directory: '.$this->path; 00136 $this->ok = false; 00137 return; 00138 } 00139 }
| Ftp::Ftp | ( | $ | url | ) |
| Ftp::mkdirs | ( | $ | strPath | ) |
Private Methode zum rekursiven Anlegen von Verzeichnissen.
| String | Pfad |
Definiert in Zeile 187 der Datei Ftp.class.php.
Wird benutzt von put().
00188 { 00189 if ( @ftp_chdir($this->verb,$strPath) ) 00190 return true; // Verzeichnis existiert schon :) 00191 00192 $pStrPath = dirname($strPath); 00193 00194 if ( !$this->mkdirs($pStrPath) ) 00195 return false; 00196 00197 if ( ! @ftp_mkdir($this->verb,$strPath) ) 00198 { 00199 $this->ok = false; 00200 $this->log[] = "failed to create remote directory: $strPath"; 00201 } 00202 00203 return $this->ok; 00204 }
| Ftp::put | ( | $ | source, | |
| $ | dest, | |||
| $ | mode = FTP_BINARY | |||
| ) |
Kopieren einer Datei vom lokalen System auf den FTP-Server.
| String | Quelle | |
| String | Ziel | |
| int | FTP-Mode (BINARY oder ASCII) |
Definiert in Zeile 149 der Datei Ftp.class.php.
00150 { 00151 if ( ! $this->ok ) 00152 return; 00153 00154 $ftp = parse_url( $this->url ); 00155 00156 $dest = $this->path.'/'.$dest; 00157 00158 $this->log .= "Copying file: $source -> $dest ...\n"; 00159 00160 if ( !@ftp_put( $this->verb,$dest,$source,$this->mode ) ) 00161 { 00162 if ( !$this->mkdirs( dirname($dest) ) ) 00163 return; // Fehler. 00164 00165 ftp_chdir( $this->verb,$this->path ); 00166 00167 if ( ! @ftp_put( $this->verb,$dest,$source,$mode ) ) 00168 { 00169 $this->ok = false; 00170 $this->log[] = 'FTP PUT failed...'; 00171 $this->log[] = 'source : '.$source; 00172 $this->log[] = 'destination: '.$dest; 00173 return; 00174 } 00175 00176 } 00177 }
| Ftp::$log = array() |
Definiert in Zeile 34 der Datei Ftp.class.php.
| Ftp::$mode = FTP_ASCII |
| Ftp::$ok = true |
Definiert in Zeile 38 der Datei Ftp.class.php.
| Ftp::$passive = false |
Definiert in Zeile 36 der Datei Ftp.class.php.
| Ftp::$url |
| Ftp::$verb |
Definiert in Zeile 32 der Datei Ftp.class.php.
1.5.8