Öffentliche Methoden | |
| Publish () | |
| copy ($tmp_filename, $dest_filename) | |
| mkdirs ($strPath) | |
| close () | |
| clean () | |
| cleanFolder ($folderName) | |
Öffentliche Attribute | |
| $ftp | |
| $with_local = false | |
| $with_ftp = false | |
| $local_destdir = '' | |
| $content_negotiation = false | |
| $cut_index = false | |
| $cmd_after_publish = '' | |
| $publishedObjects = array() | |
| $log = array() | |
| $ok = true | |
Definiert in Zeile 34 der Datei Publish.class.php.
| Publish::clean | ( | ) |
Aufräumen des Zielverzeichnisses.
Es wird der komplette Zielordner samt Unterverzeichnissen durchsucht. Jede Datei, die länger existiert als der aktuelle Request alt ist, wird gelöscht.
Natürlich darf diese Funktion nur nach einem Gesamt-Veröffentlichen ausgeführt werden.
Definiert in Zeile 267 der Datei Publish.class.php.
Benutzt cleanFolder().
00268 { 00269 if ( $this->ok ) 00270 return; 00271 00272 if ( !empty($this->local_destdir) ) 00273 $this->cleanFolder($this->local_destdir); 00274 }
| Publish::cleanFolder | ( | $ | folderName | ) |
Aufräumen eines Verzeichnisses.
Dateien, die länger existieren als der aktuelle Request alt ist, werden gelöscht.
| String | Verzeichnis |
Definiert in Zeile 284 der Datei Publish.class.php.
Wird benutzt von clean().
00285 { 00286 $dh = opendir( $folderName ); 00287 00288 while( $file = readdir($dh) ) 00289 { 00290 if ( $file != '.' && $file != '..') 00291 { 00292 $fullpath = $folderName.'/'.$file; 00293 00294 // Wenn eine Datei beschreibbar und entsprechend alt 00295 // ist, dann entfernen 00296 if ( is_file($fullpath) && 00297 is_writable($fullpath) && 00298 filemtime($fullpath) < START_TIME ) 00299 unlink($fullpath); 00300 00301 // Bei Ordnern rekursiv absteigen 00302 if ( is_dir( $fullpath) ) 00303 { 00304 $this->cleanFolder($fullpath); 00305 @rmdir($fullpath); 00306 } 00307 } 00308 } 00309 }
| Publish::close | ( | ) |
Beenden des Veröffentlichungs-Vorganges.
Eine vorhandene FTP-Verbindung wird geschlossen.
Falls entsprechend konfiguriert, wird ein Systemkommando ausgeführt.
Definiert in Zeile 236 der Datei Publish.class.php.
00237 { 00238 if ( $this->with_ftp ) 00239 { 00240 $this->ftp->close(); 00241 } 00242 00243 // Ausführen des Systemkommandos. 00244 if ( !empty($this->cmd_after_publish) && $this->ok ) 00245 { 00246 $ausgabe = array(); 00247 $rc = false; 00248 exec( $this->cmd_after_publish,$ausgabe,$rc ); 00249 00250 if ( $rc != 0 ) // Wenn Returncode ungleich 0, dann Ausgabe ins Log schreiben und Fehler melden. 00251 { 00252 $this->log = $ausgabe; 00253 $this->log[] = 'OpenRat: System command failed - returncode is '.$rc; 00254 $this->ok = false; 00255 } 00256 } 00257 }
| Publish::copy | ( | $ | tmp_filename, | |
| $ | dest_filename | |||
| ) |
Kopieren einer Datei aus dem temporären Verzeichnis in das Zielverzeichnis.
Falls notwenig, wird ein Hochladen per FTP ausgeführt.
| String | $tmp_filename | |
| String | $dest_filename |
Definiert in Zeile 127 der Datei Publish.class.php.
00128 { 00129 if ( !$this->ok) 00130 return; 00131 00132 global $conf; 00133 $source = $tmp_filename; 00134 00135 if ( $this->with_local ) 00136 { 00137 $dest = $this->local_destdir.'/'.$dest_filename; 00138 00139 // Nicht kopieren, wenn 00140 // - Quelldatei nicht neuer als die Zieldatei 00141 if ( is_file($dest) && 00142 filemtime($source) <= filemtime($dest) ) 00143 return; 00144 00145 if (!@copy( $source,$dest )); 00146 { 00147 if ( ! $this->mkdirs( dirname($dest) ) ) 00148 return; 00149 00150 if (!@copy( $source,$dest )) 00151 { 00152 $this->ok = false; 00153 $this->log[] = 'failed copying local file:'; 00154 $this->log[] = 'source : '.$source; 00155 $this->log[] = 'destination: '.$dest; 00156 return; 00157 } 00158 } 00159 00160 if (!empty($conf['security']['chmod'])) 00161 { 00162 // CHMOD auf der Datei ausgeführen. 00163 if ( ! @chmod($dest,octdec($conf['security']['chmod'])) ) 00164 { 00165 $this->ok = false; 00166 $this->log[] = 'Unable to CHMOD file '.$dest; 00167 return; 00168 } 00169 } 00170 } 00171 00172 if ( $this->with_ftp ) // Falls FTP aktiviert 00173 { 00174 $dest = $dest_filename; 00175 $this->ftp->put( $source,$dest,FTP_ASCII ); 00176 00177 if ( ! $this->ftp->ok ) 00178 { 00179 $this->ok = false; 00180 $this->log[] = $this->ftp->log; 00181 } 00182 } 00183 }
| Publish::mkdirs | ( | $ | strPath | ) |
Rekursives Anlagen von Verzeichnisse Nett gemacht. Quelle: http://de3.php.net/manual/de/function.mkdir.php Thx to acroyear at io dot com
| String | Verzeichnis |
Definiert in Zeile 196 der Datei Publish.class.php.
Benutzt $conf.
Wird benutzt von copy().
00197 { 00198 global $conf; 00199 00200 if ( is_dir($strPath) ) 00201 return true; 00202 00203 $pStrPath = dirname($strPath); 00204 if ( !$this->mkdirs($pStrPath) ) 00205 return false; 00206 00207 if ( ! @mkdir($strPath,0777) ) 00208 { 00209 $this->ok = false; 00210 $this->log[] = 'Cannot create directory: '.$strPath; 00211 return false; 00212 } 00213 00214 // CHMOD auf dem Verzeichnis ausgeführen. 00215 if (!empty($conf['security']['chmod_dir'])) 00216 { 00217 if ( ! @chmod($strPath,octdec($conf['security']['chmod_dir'])) ) 00218 { 00219 $this->ok = false; 00220 $this->log[] = 'Unable to CHMOD directory: '.$strPath; 00221 return false; 00222 } 00223 } 00224 00225 00226 return $this->ok; 00227 }
| Publish::Publish | ( | ) |
Konstruktor.
Öffnet ggf. Verbindungen.
Definiert in Zeile 54 der Datei Publish.class.php.
Benutzt $conf und Session::getProject().
00055 { 00056 global $conf; 00057 $conf_project = $conf['publish']['project']; 00058 00059 $project = Session::getProject(); 00060 00061 // Feststellen, ob FTP benutzt wird. 00062 // Dazu muss FTP aktiviert sein (enable=true) und eine URL vorhanden sein. 00063 if ( @$conf['publish']['ftp']['enable'] && 00064 ( !empty($project->ftp_url) || 00065 isset($conf['publish']['ftp']['host']) ) ) 00066 { 00067 $this->with_ftp = true; 00068 $this->ftp = new Ftp( $project->ftp_url ); // Aufbauen einer FTP-Verbindung 00069 00070 if ( ! $this->ftp->ok ) // FTP-Verbindung ok? 00071 { 00072 $this->ok = false; 00073 $this->log = $this->ftp->log; 00074 return; // Ende. Ohne FTP brauchen wir nicht weitermachen. 00075 } 00076 00077 $this->ftp->passive = ( $project->ftp_passive == '1' ); 00078 } 00079 00080 $localDir = ereg_replace( '\/$','',$project->target_dir); 00081 if ( empty( $localDir)) 00082 $localDir = $project->name; 00083 00084 if ( $conf_project['override_publish_dir'] && $localDir != basename($localDir) ) 00085 $this->local_destdir = $localDir; 00086 else 00087 $this->local_destdir = $conf_project['publish_dir'].$localDir; 00088 00089 00090 // Sofort pruefen, ob das Zielverzeichnis ueberhaupt beschreibbar ist. 00091 if ( $this->local_destdir != '' ) 00092 { 00093 if ( !is_writeable( $this->local_destdir ) ) 00094 { 00095 $this->ok = false; 00096 $this->log[] = 'directory not writable: '.$this->local_destdir; 00097 $this->log[] = 'please correct the file permissions.'; 00098 return; 00099 } 00100 00101 $this->with_local = true; 00102 } 00103 00104 $this->content_negotiation = ( $project->content_negotiation == '1' ); 00105 $this->cut_index = ( $project->cut_index == '1' ); 00106 00107 if ( $conf_project['override_system_command'] && !empty($project->cmd_after_publish) ) 00108 $this->cmd_after_publish = $project->cmd_after_publish; 00109 else 00110 $this->cmd_after_publish = $conf_project['system_command']; 00111 00112 // Im Systemkommando Variablen ersetzen 00113 $this->cmd_after_publish = str_replace('{name}' ,$project->name ,$this->cmd_after_publish); 00114 $this->cmd_after_publish = str_replace('{dir}' ,$this->local_destdir ,$this->cmd_after_publish); 00115 $this->cmd_after_publish = str_replace('{dirbase}',basename($this->local_destdir),$this->cmd_after_publish); 00116 }
| Publish::$cmd_after_publish = '' |
Definiert in Zeile 42 der Datei Publish.class.php.
| Publish::$content_negotiation = false |
Definiert in Zeile 40 der Datei Publish.class.php.
| Publish::$cut_index = false |
Definiert in Zeile 41 der Datei Publish.class.php.
| Publish::$ftp |
Definiert in Zeile 36 der Datei Publish.class.php.
| Publish::$local_destdir = '' |
Definiert in Zeile 39 der Datei Publish.class.php.
| Publish::$log = array() |
Definiert in Zeile 44 der Datei Publish.class.php.
| Publish::$ok = true |
Definiert in Zeile 45 der Datei Publish.class.php.
| Publish::$publishedObjects = array() |
Definiert in Zeile 43 der Datei Publish.class.php.
| Publish::$with_ftp = false |
Definiert in Zeile 38 der Datei Publish.class.php.
| Publish::$with_local = false |
Definiert in Zeile 37 der Datei Publish.class.php.
1.5.8