openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit b1e1511ca15ef5f0d602c040be15a760675b791d
parent 9a0e2ad58dc89a82b47587c631c13178fcad220c
Author: dankert <devnull@localhost>
Date:   Tue, 30 Nov 2004 00:24:56 +0100

Korrektur Veroeffentlichung

Diffstat:
actionClasses/FileAction.class.php | 52++++++++++++++++++++++++----------------------------
actionClasses/FolderAction.class.php | 13++++++++-----
actionClasses/PageAction.class.php | 39++++++++++++++++++---------------------
objectClasses/File.class.php | 20+++++++++++++-------
objectClasses/Object.class.php | 48++++++++++++++++++++++++++++++------------------
objectClasses/Page.class.php | 61++++++++++++++++++++++++++++++++++++++++---------------------
serviceClasses/Ftp.class.php | 393+++++++++++++++++++++++++++++++++++++++----------------------------------------
serviceClasses/Publish.class.php | 265+++++++++++++++++++++++++++++++++++++------------------------------------------
8 files changed, 454 insertions(+), 437 deletions(-)

diff --git a/actionClasses/FileAction.class.php b/actionClasses/FileAction.class.php @@ -20,7 +20,10 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // --------------------------------------------------------------------------- // $Log$ -// Revision 1.8 2004-11-28 21:27:21 dankert +// Revision 1.9 2004-11-29 23:24:36 dankert +// Korrektur Veroeffentlichung +// +// Revision 1.8 2004/11/28 21:27:21 dankert // Bildbearbeitung erweitert // // Revision 1.7 2004/11/27 13:05:59 dankert @@ -104,28 +107,15 @@ class FileAction extends ObjectAction { global $SESS; - // Wenn Dateiname gefuellt, dann Datenbank-Update - if ( $this->getRequestVar('delete') != '' ) - { - // Datei loeschen - $this->file->delete(); - - $this->addNotice($this->file->getType(),$this->file->name,'DELETED','ok'); - unset( $SESS['objectid'] ); - } - else - { - // Eigenschaften speichern - $this->file->filename = $this->getRequestVar('filename' ); - $this->file->name = $this->getRequestVar('name' ); - $this->file->extension = $this->getRequestVar('extension'); - $this->file->desc = $this->getRequestVar('desc' ); - - $this->addNotice($this->file->getType(),$this->file->name,'PROP_SAVED','ok'); - $this->file->save(); - } + // Eigenschaften speichern + $this->file->filename = $this->getRequestVar('filename' ); + $this->file->name = $this->getRequestVar('name' ); + $this->file->extension = $this->getRequestVar('extension'); + $this->file->desc = $this->getRequestVar('desc' ); + + $this->addNotice($this->file->getType(),$this->file->name,'PROP_SAVED','ok'); + $this->file->save(); - $this->setTemplateVar('tree_refresh',true); $this->callSubAction('prop'); } @@ -169,7 +159,7 @@ class FileAction extends ObjectAction $format = $this->getRequestVar('format' ) ; $this->file->imageResize( intval($width),intval($height),$format,$jpegcompression ); - $this->file->save(); + $this->file->save(); // Um z.B. Groesse abzuspeichern $this->file->saveValue(); $this->addNotice($this->file->getType(),$this->file->name,'IMAGE_RESIZED','ok'); @@ -251,17 +241,23 @@ class FileAction extends ObjectAction */ function pub() { + $this->forward('file_pub'); + } + + + /** + * Datei ver?ffentlichen + */ + function pub2() + { $this->file->publish(); - $list = array(); foreach( $this->file->publish->publishedObjects as $o ) { - $list[] = $o['filename']; + $this->addNotice($o['type'],$o['full_filename'],'PUBLISHED','ok'); } - $this->setTemplateVar('filenames',$list); - - $this->forward('publish'); + $this->callSubaction('pub'); } } diff --git a/actionClasses/FolderAction.class.php b/actionClasses/FolderAction.class.php @@ -20,7 +20,10 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // --------------------------------------------------------------------------- // $Log$ -// Revision 1.14 2004-11-29 21:09:51 dankert +// Revision 1.15 2004-11-29 23:24:36 dankert +// Korrektur Veroeffentlichung +// +// Revision 1.14 2004/11/29 21:09:51 dankert // neue Methode pub2() // // Revision 1.13 2004/11/28 22:59:48 dankert @@ -286,7 +289,7 @@ class FolderAction extends ObjectAction $f = new File( $id ); $f->load(); $f->filename = ''; - $f->name = lang('COPY_OF').' '.$f->name; + $f->name = lang('GLOBAL_COPY_OF').' '.$f->name; $f->parentid = $targetObjectId; $f->add(); $f->copyValueFromFile( $id ); @@ -297,7 +300,7 @@ class FolderAction extends ObjectAction $p = new Page( $id ); $p->load(); $p->filename = ''; - $p->name = lang('COPY_OF').' '.$p->name; + $p->name = lang('GLOBAL_COPY_OF').' '.$p->name; $p->parentid = $targetObjectId; $p->add(); $p->copyValuesFromPage( $id ); @@ -308,7 +311,7 @@ class FolderAction extends ObjectAction $l = new Link( $id ); $l->load(); $l->filename = ''; - $l->name = lang('COPY_OF').' '.$l->name; + $l->name = lang('GLOBAL_COPY_OF').' '.$l->name; $l->parentid = $targetObjectId; $l->add(); $this->addNotice($o->getType(),$o->name,'COPIED','ok'); @@ -658,7 +661,7 @@ class FolderAction extends ObjectAction foreach( $publish->publishedObjects as $o ) { - $this->addNotice('',$o['filename'],'PUBLISHED','ok'); + $this->addNotice($o['type'],$o['full_filename'],'PUBLISHED','ok'); } $this->callSubaction( 'pub' ); diff --git a/actionClasses/PageAction.class.php b/actionClasses/PageAction.class.php @@ -20,7 +20,10 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // --------------------------------------------------------------------------- // $Log$ -// Revision 1.13 2004-11-27 09:55:54 dankert +// Revision 1.14 2004-11-29 23:24:36 dankert +// Korrektur Veroeffentlichung +// +// Revision 1.13 2004/11/27 09:55:54 dankert // Rechte-Funktionen entfernt, Anzahl Versionen in Elementliste // // Revision 1.12 2004/11/10 22:39:24 dankert @@ -228,23 +231,14 @@ class PageAction extends ObjectAction function propsave() { - if ($this->getRequestVar('name') != '') + if ( !empty($this->getRequestVar('name')) ) { - if ( $this->getRequestVar('delete') == '1' ) - { - $this->page->delete(); - $this->forward(''); - } - else - { - $this->page->name = $this->getRequestVar('name' ); - $this->page->filename = $this->getRequestVar('filename'); - $this->page->desc = $this->getRequestVar('desc' ); + $this->page->name = $this->getRequestVar('name' ); + $this->page->filename = $this->getRequestVar('filename'); + $this->page->desc = $this->getRequestVar('desc' ); - $this->page->save(); - } - $this->setTemplateVar('tree_refresh',true); - + $this->page->save(); + $this->addNotice($this->file->getType(),$this->file->name,'PROP_SAVED','ok'); } $this->callSubAction('prop'); @@ -544,17 +538,20 @@ class PageAction extends ObjectAction function pub() { + $this->forward('page_pub'); + } + + + function pub2() + { $this->page->publish(); - $list = array(); foreach( $this->page->publish->publishedObjects as $o ) { - $list[] = $o['filename']; + $this->addNotice($o['type'],$o['full_filename'],'PUBLISHED','ok'); } - $this->setTemplateVar('filenames',$list); - - $this->forward('publish'); + $this->callSubaction('pub'); } } diff --git a/objectClasses/File.class.php b/objectClasses/File.class.php @@ -20,7 +20,10 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // --------------------------------------------------------------------------- // $Log$ -// Revision 1.4 2004-11-28 21:28:05 dankert +// Revision 1.5 2004-11-29 23:24:36 dankert +// Korrektur Veroeffentlichung +// +// Revision 1.4 2004/11/28 21:28:05 dankert // Bildbearbeitung erweitert // // Revision 1.3 2004/11/10 22:45:24 dankert @@ -53,6 +56,7 @@ class File extends Object var $value = ''; var $extension = ''; var $log_filenames = array(); + var $fullFilename = ''; var $publish = null; /** @@ -81,13 +85,15 @@ class File extends Object */ function full_filename() { + if ( !empty($this->fullFilename) ) + return $this->fullFilename; + $filename = parent::full_filename(); - if ( $this->extension != '' ) - { + if ( !empty($this->extension) ) $filename .= '.'.$this->extension; - } + $this->fullFilename = $filename; return $filename; } @@ -113,7 +119,7 @@ class File extends Object function getProperties() { return array_merge( parent::getProperties(), - Array('full_filename'=>$this->full_filename(), + array('full_filename'=>$this->fullFilename, 'extension' =>$this->extension, 'size' =>$this->size, 'mimetype' =>$this->mimetype() ) ); @@ -511,8 +517,8 @@ class File extends Object $this->write(); $this->publish->copy( $this->tmpfile(),$this->full_filename() ); - -// $this->log_filenames = $this->publish->log_filenames; + + $this->publish->publishedObjects[] = $this->getProperties(); } } diff --git a/objectClasses/Object.class.php b/objectClasses/Object.class.php @@ -20,7 +20,10 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // --------------------------------------------------------------------------- // $Log$ -// Revision 1.8 2004-11-29 00:02:41 dankert +// Revision 1.9 2004-11-29 23:24:36 dankert +// Korrektur Veroeffentlichung +// +// Revision 1.8 2004/11/29 00:02:41 dankert // Bei L?schen von Objekten alle Referenzen in Tabelle or_link entfernen // // Revision 1.7 2004/11/28 22:32:52 dankert @@ -245,9 +248,6 @@ class Object $path.= $this->filename(); -// if ($this->extension() != '') -// $path.= '.'.$this->extension(); - return $path; } @@ -383,14 +383,15 @@ class Object if (count($row) == 0) die('fatal: objectid not found: '.$this->objectid); - $this->parentid = $row['parentid']; + $this->parentid = $row['parentid' ]; + $this->filename = $row['filename' ]; + $this->projectid = $row['projectid']; if ( intval($this->parentid) == 0 ) $this->isRoot = true; else $this->isRoot = false; - $this->checkFilename(); $this->name = 'n/a'; $this->create_date = $row['create_date']; @@ -398,7 +399,6 @@ class Object $this->lastchange_date = $row['lastchange_date']; $this->lastchange_userid = $row['lastchange_userid']; - $this->projectid = $row['projectid']; $this->isFolder = ( $row['is_folder'] == '1' ); $this->isFile = ( $row['is_file' ] == '1' ); @@ -414,7 +414,9 @@ class Object */ function setDatabaseRow( $row ) { - $this->parentid = $row['parentid']; + $this->parentid = $row['parentid' ]; + $this->projectid = $row['projectid']; + $this->filename = $row['filename' ]; if ( intval($this->parentid) == 0 ) $this->isRoot = true; @@ -425,8 +427,6 @@ class Object $this->lastchange_date = $row['lastchange_date' ]; $this->lastchange_userid = $row['lastchange_userid']; - $this->projectid = $row['projectid']; - $this->isFolder = ( $row['is_folder'] == '1' ); $this->isFile = ( $row['is_file' ] == '1' ); $this->isPage = ( $row['is_page' ] == '1' ); @@ -445,7 +445,6 @@ class Object $this->desc = $row['descr']; } - $this->checkFilename(); $this->checkName(); } @@ -660,7 +659,7 @@ class Object */ function checkFilename() { - if ( $this->filename == '' ) + if ( empty($this->filename) ) $this->filename = $this->objectid; $this->filename = trim(strtolower($this->filename)); @@ -674,27 +673,40 @@ class Object if ( $this->isRoot ) return; - $pf = new Folder( $this->parentid ); - - if ( $pf->hasFilename( $this->filename ) ) + if ( !$this->filenameIsUnique( $this->filename ) ) { $this->filename = $this->objectid; - if ( $pf->hasFilename( $this->filename ) ) + if ( !$this->filenameIsUnique( $this->filename ) ) $this->filename = md5(microtime()); } } + function filenameIsUnique( $filename ) + { + $db = db_connection(); + + $sql = new Sql('SELECT COUNT(*) FROM {t_object}'.' WHERE parentid={parentid} AND filename={filename} AND NOT id = {objectid}'); + + $sql->setString('parentid', $this->parentid); + $sql->setString('objectid', $this->objectid); + + $sql->setString('filename', $filename ); + + return( intval($db->getOne($sql->query)) == 0 ); + } + + /** * Pruefung auf Gueltigkeit des logischen Namens */ function checkName() { - if ( $this->name == '' ) + if ( empty($this->name) ) $this->name = $this->filename; - if ( $this->name == '' ) + if ( empty($this->name) ) $this->name = $this->objectid; } diff --git a/objectClasses/Page.class.php b/objectClasses/Page.class.php @@ -20,7 +20,10 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // --------------------------------------------------------------------------- // $Log$ -// Revision 1.10 2004-11-10 22:47:17 dankert +// Revision 1.11 2004-11-29 23:24:36 dankert +// Korrektur Veroeffentlichung +// +// Revision 1.10 2004/11/10 22:47:17 dankert // Methode copyValuesFromPage() zum Kopiern einer Seite // // Revision 1.9 2004/10/14 21:10:57 dankert @@ -83,6 +86,7 @@ class Page extends Object var $cut_index = false; var $default_language = false; var $link = false; + var $fullFilename = ''; var $log_filenames = array(); var $projectmodelid = 0; @@ -150,7 +154,7 @@ class Page extends Object function getProperties() { return array_merge( parent::getProperties(), - Array('full_filename'=>$this->full_filename(), + array('full_filename'=>$this->fullFilename, 'pageid' =>$this->pageid, 'templateid' =>$this->templateid ) ); } @@ -208,6 +212,8 @@ class Page extends Object $object = new Object( $objectid ); $object->objectLoad(); + $cut_index = ( is_object($this->publish) && $this->publish->cut_index ); + $content_negotiation = ( is_object($this->publish) && $this->publish->content_negotiation ); if ( $this->public ) { @@ -227,7 +233,9 @@ class Page extends Object $inhalt = $this->up_path(); $p = new Page( $objectid ); - $p->languageid = $this->languageid; + $p->languageid = $this->languageid; + $p->cut_index = $cut_index; + $p->content_negotiation = $content_negotiation; $p->load(); $inhalt .= $p->full_filename(); break; @@ -252,7 +260,9 @@ class Page extends Object case 'page': $p = new Page( $link->linkedObjectId ); - $p->languageid = $this->languageid; + $p->languageid = $this->languageid; + $p->cut_index = $cut_index; + $p->content_negotiation = $content_negotiation; $p->load(); $inhalt = $this->up_path(); $inhalt .= $p->full_filename(); @@ -527,25 +537,33 @@ class Page extends Object */ function full_filename() { - $filename = parent::full_filename(); + $filename = $this->path(); - if ( !$this->default_language ) - { - $l = new Language( $this->languageid ); - $l->load(); - $filename .= '.'.$l->isoCode; - } + if ( !empty($filename) ) + $filename .= '/'; - $t = new Template( $this->templateid ); - $t->projectmodelid = $this->modelid; - $t->load(); - $filename .= '.'.$t->extension; - - if ( $this->default_language ) - { + if ( !$this->cut_index || $this->filename != 'index' ) + { + $filename .= $this->filename(); + if ( !$this->default_language ) + { + $l = new Language( $this->languageid ); + $l->load(); + $filename .= '.'.$l->isoCode; + } + + $t = new Template( $this->templateid ); + $t->projectmodelid = $this->modelid; + $t->load(); $filename .= '.'.$t->extension; + + if ( $this->default_language ) + { + $filename .= '.'.$t->extension; + } } + $this->fullFilename = $filename; return $filename; } @@ -709,8 +727,8 @@ class Page extends Object if ( ! is_object($this->publish) ) $this->publish = new Publish(); - $this->content_negotiation = $this->publish->content_negotiation; - $this->cut_index = $this->publish->cut_index; + //$this->content_negotiation = $this->publish->content_negotiation; + //$this->cut_index = $this->publish->cut_index; $this->public = true; // Schleife ?ber alle Sprachvarianten @@ -727,8 +745,8 @@ class Page extends Object $this->generate(); $this->write(); - //echo $this->tmpfile().' &gt; '.$this->full_filename().'<br>'; $this->publish->copy( $this->tmpfile(),$this->full_filename() ); + $this->publish->publishedObjects[] = $this->getProperties(); } } @@ -751,6 +769,7 @@ class Page extends Object //echo $this->tmpfile().' &gt; '.$this->full_filename().'<br>'; $publish->copy( $this->tmpfile(),$this->full_filename() ); + $this->publish->publishedObjects[] = $this->getProperties(); } } diff --git a/serviceClasses/Ftp.class.php b/serviceClasses/Ftp.class.php @@ -1,198 +1,197 @@ -<?php -# -# DaCMS Content Management System -# Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -/** - * Darstellen einer FTP-Verbindung, das beinhaltet - * das Login, das Kopieren von Dateien sowie praktische - * FTP-Funktionen - * - * @author $Author$ - * @version $Revision$ - * @package openrat.services - */ -class Ftp -{ - var $verb; - var $url; - var $log; - var $mode=FTP_ASCII; - var $passive = false; - - - // Konstruktor - function Ftp( $url ) - { - $this->connect( $url ); - } - - - // Aufbauen der Verbindung - function connect( $url ) - { - $this->url = $url; - - global $db, - $SESS, - $t_project; - - $ftp = parse_url( $this->url ); - - // Wenn kein Port vorgegeben, dann Port 21 verwenden - if ( $ftp['port'] == '' ) - $ftp['port'] = '21'; - - // Nur FTP und FTPS (seit PHP 4.3) erlaubt - if ( !ereg('^ftps?$',$ftp['scheme']) ) - die( 'unknown scheme in FTP Url: '.$ftp['scheme'] ); - - $this->verb = ftp_connect( $ftp['host'],$ftp['port'] ); - - if ( !$this->verb ) - { - error('ERROR_FTP','ERROR_FTP_CANNOT_CONNECT_TO_SERVER','Cannot connect to '.$ftp['host'].':'.$ftp['port']); - } - - $this->log .= 'connecting ...'."\n"; - $this->log .= 'host: '.$ftp['host']."\n"; - $this->log .= 'port: '.$ftp['port']."\n"; - - $erg = ftp_login( $this->verb,$ftp['user'],$ftp['pass'] ); - - if ( !$erg ) - { - error('ERROR_FTP','ERROR_FTP_CANNOT_LOGIN','cannot login user: '.$ftp['user']); - } - - $this->log .= 'ok'."\n"; - $this->log .= 'login ...'."\n"; - $this->log .= 'user: '.$ftp['user']."\n"; - $this->log .= 'ok'."\n"; - - if ( $ftp['fragment'] == 'passive' ) - { - $this->log .= 'entering passive mode'."\n"; - $erg = ftp_pasv( $this->verb,true ); - - if ( !$erg ) - { - error('ERROR_FTP','ERROR_FTP_CANNOT_PASV_ON'); - } - } - else - { - $this->log .= 'no passive mode'."\n"; - $erg = ftp_pasv( $this->verb,false ); - - if ( !$erg ) - { - error('ERROR_FTP','ERROR_FTP_CANNOT_PASV_OFF'); - } - } - - if ( $ftp['query'] != '' ) - { - parse_str( $ftp['query'],$ftp_var ); - - if ( isset( $ftp_var['site'] ) ) - { - $site_commands = explode( ',',$ftp_var['site'] ); - foreach( $site_commands as $cmd ) - { - $this->log .= 'exec SITE command: '.$cmd."\n"; - ftp_site( $this->verb,$cmd ); - } - } - } - - $this->path = ereg_replace( '\/$','',$ftp['path']); - - $this->log .= 'Change directory to '.$this->path.'...'."\n"; - $erg = ftp_chdir( $this->verb,$this->path ); - - - if ( !$erg ) - { - error('ERROR_FTP','ERROR_FTP_UNABLE_TO_CHDIR','could not CHDIR to '.$this->path ); - } - $this->log .= 'ok'."\n"; - - - //echo "pwd ist".ftp_pwd( $this->verb ); - } - - - function put( $source,$dest,$mode=FTP_BINARY ) - { - $ftp = parse_url( $this->url ); - - $dest = $this->path.'/'.$dest; - - $this->log .= "Copying file: $source -&gt; $dest ...\n"; - if ( !ftp_put( $this->verb,$dest,$source,$this->mode ) ) - { - echo "ging nicht: $dest<br>"; - $this->log .= "Copying FAILED, checking path: ".dirname($dest)."\n"; - - $erg = $this->mkdirs( dirname($dest) ); - - if ( !$erg ) - { - error('ERROR_FTP','ERROR_FTP_UNABLE_TO_MKDIR','cannot create directoriy '.$ftp['path'].'/'.dirname($dest) ); - } - - ftp_chdir( $this->verb,$this->path ); - - $erg = ftp_put( $this->verb,$dest,$source,$mode ); - - if ( !$erg ) - { - error('ERROR_FTP','ERROR_FTP_UNABLE_TO_COPY','put failed from '.$source.' to '.$dest ); - } - - } - } - - - - // Rekursives Anlagen von Verzeichnisse - function mkdirs( $strPath ) - { - echo $strPath.'<br>'; - if ( ftp_chdir($this->verb,$strPath) ) - return true; - - $pStrPath = dirname($strPath); - if ( !$this->mkdirs($pStrPath) ) - return false; - - $this->log .= "Creating directory: $strPath ...\n"; - echo "lege an $strPath ...<br>"; - return ftp_mkdir($this->verb,$strPath); - } - - - function close() - { - ftp_quit( $this->verb ); - } -} - - +<?php +# +# DaCMS Content Management System +# Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +/** + * Darstellen einer FTP-Verbindung, das beinhaltet + * das Login, das Kopieren von Dateien sowie praktische + * FTP-Funktionen + * + * @author $Author$ + * @version $Revision$ + * @package openrat.services + */ +class Ftp +{ + var $verb; + var $url; + var $log = ''; + var $mode=FTP_ASCII; + var $passive = false; + + + // Konstruktor + function Ftp( $url ) + { + $this->connect( $url ); + } + + + // Aufbauen der Verbindung + function connect( $url ) + { + $this->url = $url; + + global $db, + $SESS, + $t_project; + + $ftp = parse_url( $this->url ); + + // Wenn kein Port vorgegeben, dann Port 21 verwenden + if ( empty($ftp['port']) ) + $ftp['port'] = '21'; + + // Nur FTP und FTPS (seit PHP 4.3) erlaubt + if ( !ereg('^ftps?$',$ftp['scheme']) ) + die( 'unknown scheme in FTP Url: '.$ftp['scheme'] ); + + $this->verb = ftp_connect( $ftp['host'],$ftp['port'] ); + + if ( !$this->verb ) + { + error('ERROR_FTP','ERROR_FTP_CANNOT_CONNECT_TO_SERVER','Cannot connect to '.$ftp['host'].':'.$ftp['port']); + } + + $this->log .= 'connecting ...'."\n"; + $this->log .= 'host: '.$ftp['host']."\n"; + $this->log .= 'port: '.$ftp['port']."\n"; + + $erg = ftp_login( $this->verb,$ftp['user'],$ftp['pass'] ); + + if ( !$erg ) + { + error('ERROR_FTP','ERROR_FTP_CANNOT_LOGIN','cannot login user: '.$ftp['user']); + } + + $this->log .= 'ok'."\n"; + $this->log .= 'login ...'."\n"; + $this->log .= 'user: '.$ftp['user']."\n"; + $this->log .= 'ok'."\n"; + + if ( !empty($ftp['fragment']) && $ftp['fragment'] == 'passive' ) + { + $this->log .= 'entering passive mode'."\n"; + $erg = ftp_pasv( $this->verb,true ); + + if ( !$erg ) + { + error('ERROR_FTP','ERROR_FTP_CANNOT_PASV_ON'); + } + } + else + { + $this->log .= 'no passive mode'."\n"; + $erg = ftp_pasv( $this->verb,false ); + + if ( !$erg ) + { + error('ERROR_FTP','ERROR_FTP_CANNOT_PASV_OFF'); + } + } + + if ( !empty($ftp['query']) ) + { + parse_str( $ftp['query'],$ftp_var ); + + if ( isset( $ftp_var['site'] ) ) + { + $site_commands = explode( ',',$ftp_var['site'] ); + foreach( $site_commands as $cmd ) + { + $this->log .= 'exec SITE command: '.$cmd."\n"; + ftp_site( $this->verb,$cmd ); + } + } + } + + $this->path = ereg_replace( '\/$','',$ftp['path']); + + $this->log .= 'Change directory to '.$this->path.'...'."\n"; + $erg = ftp_chdir( $this->verb,$this->path ); + + + if ( !$erg ) + { + error('ERROR_FTP','ERROR_FTP_UNABLE_TO_CHDIR','could not CHDIR to '.$this->path ); + } + $this->log .= 'ok'."\n"; + + + //echo "pwd ist".ftp_pwd( $this->verb ); + } + + + function put( $source,$dest,$mode=FTP_BINARY ) + { + $ftp = parse_url( $this->url ); + + $dest = $this->path.'/'.$dest; + + $this->log .= "Copying file: $source -&gt; $dest ...\n"; + if ( !@ftp_put( $this->verb,$dest,$source,$this->mode ) ) + { + $this->log .= "Copying FAILED, checking path: ".dirname($dest)."\n"; + + $erg = $this->mkdirs( dirname($dest) ); + + if ( !$erg ) + { + error('ERROR_FTP','ERROR_FTP_UNABLE_TO_MKDIR','cannot create directoriy '.$ftp['path'].'/'.dirname($dest) ); + } + + ftp_chdir( $this->verb,$this->path ); + + $erg = ftp_put( $this->verb,$dest,$source,$mode ); + + if ( !$erg ) + { + error('ERROR_FTP','ERROR_FTP_UNABLE_TO_COPY','put failed from '.$source.' to '.$dest ); + } + + } + } + + + + // Rekursives Anlagen von Verzeichnisse + function mkdirs( $strPath ) + { + echo $strPath.'<br>'; + if ( @ftp_chdir($this->verb,$strPath) ) + return true; + + $pStrPath = dirname($strPath); + if ( !$this->mkdirs($pStrPath) ) + return false; + + $this->log .= "Creating directory: $strPath ...\n"; + //echo "lege an $strPath ...<br>"; + return ftp_mkdir($this->verb,$strPath); + } + + + function close() + { + ftp_quit( $this->verb ); + } +} + + ?> \ No newline at end of file diff --git a/serviceClasses/Publish.class.php b/serviceClasses/Publish.class.php @@ -1,141 +1,126 @@ -<?php -# -# DaCMS Content Management System -# Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -/** - * Diese Klasse stellt stellt einige Eigenschaften des Projektes dar, welche fuer - * das Veroeffentlichen von Objekten nuetzlich sind - * @author $Author$ - * @version $Revision$ - * @package openrat.services - */ -class Publish -{ - var $ftp; - var $with_local = false; - var $with_ftp = false; - var $local_destdir = ''; - var $content_negotiation = false; - var $cut_index = false; - var $cmd_after_publish = ''; - var $publishedObjects = array(); - - // Konstruktor - function Publish() - { - global $SESS; - - $db = db_connection(); - - // Projektdaten ermitteln - $sql = new Sql( 'SELECT * FROM {t_project}'. - ' WHERE id={projectid}' ); - $sql->setInt( 'projectid',$SESS['projectid'] ); - $row = $db->getRow( $sql->query ); - - if ( $row['ftp_url'] != '' ) - { - $this->ftp = new Ftp( $row['ftp_url'] ); - $this->with_ftp = true; - - if ( $row['ftp_passive'] == '1' ) - $this->ftp->passive = true; - } - - $this->local_destdir = ereg_replace( '\/$','',$row['target_dir']); - - // Sofort prüfen, ob das Zielverzeichnis überhaupt beschreibbar ist. - if ( $this->local_destdir != '' ) - { - if ( !is_writeable( $this->local_destdir ) ) - { - message('ERROR','ERROR_DESTDIR_NOT_WRITEABLE','not writable: '.$this->local_destdir ); - } - - $this->with_local = true; - } - - if ( $row['content_negotiation'] == '1' ) - $this->content_negotiation = true; - - if ( $row['cut_index'] == '1' ) - $this->cut_index = true; - - $this->cms_after_publish = $row['cmd_after_publish']; - } - - function copy( $tmp_filename,$dest_filename ) - { - $source = $tmp_filename; - - if ( $this->with_local ) - { - $dest = $this->local_destdir.'/'.$dest_filename; - //echo "$source &gt; $dest<br>"; - if (!copy( $source,$dest )); - { - $this->mkdirs( dirname($dest) ); - - if (!copy( $source,$dest )) - { - //echo "$source &gt; $dest<br>"; - error('ERROR','ERROR_DESTDIR_NOT_WRITEABLE','cannot write file '.$dest); - } - } - } - - if ( $this->with_ftp ) - { - $dest = $dest_filename; - $this->ftp->put( $source,$dest,FTP_ASCII ); - } - - $this->publishedObjects[] = Array( 'filename'=>$dest_filename ); - } - - - // Rekursives Anlagen von Verzeichnisse - // Nett gemacht. - // Quelle: http://de3.php.net/manual/de/function.mkdir.php - // Thx to acroyear at io dot com - function mkdirs( $strPath ) - { - if ( is_dir($strPath) ) - return true; - - $pStrPath = dirname($strPath); - if ( !$this->mkdirs($pStrPath) ) - return false; - - //echo "lege an: $strPath<br>"; - return @mkdir($strPath,0755); - } - - - - function close() - { - if ( $this->with_ftp ) - { - $this->ftp->close(); - } - } -} - +<?php +# +# DaCMS Content Management System +# Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +/** + * Diese Klasse stellt stellt einige Eigenschaften des Projektes dar, welche fuer + * das Veroeffentlichen von Objekten nuetzlich sind + * @author $Author$ + * @version $Revision$ + * @package openrat.services + */ +class Publish +{ + var $ftp; + var $with_local = false; + var $with_ftp = false; + var $local_destdir = ''; + var $content_negotiation = false; + var $cut_index = false; + var $cmd_after_publish = ''; + var $publishedObjects = array(); + + // Konstruktor + function Publish() + { + $project = Session::getProject(); + + if ( !empty($project->ftp_url) ) + { + $this->ftp = new Ftp( $project->ftp_url ); + $this->with_ftp = true; + + $this->ftp->passive = ( $project->ftp_passive == '1' ); + } + + $this->local_destdir = ereg_replace( '\/$','',$project->target_dir); + + // Sofort pruefen, ob das Zielverzeichnis ueberhaupt beschreibbar ist. + if ( $this->local_destdir != '' ) + { + if ( !is_writeable( $this->local_destdir ) ) + { + die( 'directory not writable: '.$this->local_destdir ); + } + + $this->with_local = true; + } + + $this->content_negotiation = ( $project->content_negotiation == '1' ); + $this->cut_index = ( $project->cut_index == '1' ); + + $this->cmd_after_publish = $project->cmd_after_publish; + } + + function copy( $tmp_filename,$dest_filename ) + { + $source = $tmp_filename; + + if ( $this->with_local ) + { + $dest = $this->local_destdir.'/'.$dest_filename; + //echo "$source &gt; $dest<br>"; + if (!@copy( $source,$dest )); + { + $this->mkdirs( dirname($dest) ); + + if (!copy( $source,$dest )) + { + die('failed writing file: '.$dest); + } + } + } + + if ( $this->with_ftp ) + { + $dest = $dest_filename; + $this->ftp->put( $source,$dest,FTP_ASCII ); + } + } + + + // Rekursives Anlagen von Verzeichnisse + // Nett gemacht. + // Quelle: http://de3.php.net/manual/de/function.mkdir.php + // Thx to acroyear at io dot com + function mkdirs( $strPath ) + { + if ( is_dir($strPath) ) + return true; + + $pStrPath = dirname($strPath); + if ( !$this->mkdirs($pStrPath) ) + return false; + + //echo "lege an: $strPath<br>"; + return @mkdir($strPath,0755); + } + + + + function close() + { + if ( $this->with_ftp ) + { + $this->ftp->close(); + } + } +} + ?> \ No newline at end of file