commit 811c87b0bebcc119a75c6b37994fcde765a76ee1
parent 93c98a6932f69cd6cb147fe70ef2c97e86b4e31a
Author: dankert <devnull@localhost>
Date: Sun, 8 Nov 2009 02:03:33 +0100
bei FTP-PUT Textdateien in ASCII übertragen, Rest in BINARY.
Diffstat:
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/serviceClasses/Ftp.class.php b/serviceClasses/Ftp.class.php
@@ -32,7 +32,7 @@ class Ftp
var $verb;
var $url;
var $log = array();
- var $mode=FTP_ASCII;
+
var $passive = false;
var $ok = true;
@@ -149,7 +149,7 @@ class Ftp
* @param String Ziel
* @param int FTP-Mode (BINARY oder ASCII)
*/
- function put( $source,$dest,$mode=FTP_BINARY )
+ function put( $source,$dest )
{
if ( ! $this->ok )
return;
@@ -159,8 +159,21 @@ class Ftp
$dest = $this->path.'/'.$dest;
$this->log .= "Copying file: $source -> $dest ...\n";
+
+ $mode = FTP_BINARY;
+ $p = strrpos( basename($dest),'.' ); // Letzten Punkt suchen
+
+ if ($p!==false) // Wennn letzten Punkt gefunden, dann dort aufteilen
+ {
+ $extension = substr( basename($dest),$p+1 );
+ $type = config('mime-types',$extension);
+ if ( substr($type,0,5) == 'text/')
+ $mode = FTP_ASCII;
+ }
+
+ Logger::debug("FTP PUT target:$dest mode:".(($mode==FTP_ASCII)?'ascii':'binary'));
- if ( !@ftp_put( $this->verb,$dest,$source,$this->mode ) )
+ if ( !@ftp_put( $this->verb,$dest,$source,$mode ) )
{
if ( !$this->mkdirs( dirname($dest) ) )
return; // Fehler.
diff --git a/serviceClasses/Publish.class.php b/serviceClasses/Publish.class.php
@@ -191,16 +191,10 @@ class Publish
{
$dest = $this->local_destdir.'/'.$dest_filename;
- // Nicht kopieren, wenn
- // - Quelldatei nicht neuer als die Zieldatei
- if ( is_file($dest) &&
- filemtime($source) <= filemtime($dest) )
- return;
-
if (!@copy( $source,$dest ));
{
if ( ! $this->mkdirs( dirname($dest) ) )
- return;
+ return; // Fehler bei Verzeichniserstellung, also abbrechen.
if (!@copy( $source,$dest ))
{
@@ -208,13 +202,13 @@ class Publish
$this->log[] = 'failed copying local file:';
$this->log[] = 'source : '.$source;
$this->log[] = 'destination: '.$dest;
- return;
+ return; // Fehler beim Kopieren, also abbrechen.
}
}
if (!empty($conf['security']['chmod']))
{
- // CHMOD auf der Datei ausgef�hren.
+ // CHMOD auf der Datei ausfuehren.
if ( ! @chmod($dest,octdec($conf['security']['chmod'])) )
{
$this->ok = false;
@@ -227,7 +221,7 @@ class Publish
if ( $this->with_ftp ) // Falls FTP aktiviert
{
$dest = $dest_filename;
- $this->ftp->put( $source,$dest,FTP_ASCII );
+ $this->ftp->put( $source,$dest );
if ( ! $this->ftp->ok )
{