openrat-cms

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

commit 27ee05c1c146e7cb8523ed41f5d0abd26dc68030
parent d7091916d153ee5f134433b91573a90f4876d71a
Author: Jan Dankert <devnull@localhost>
Date:   Sun, 10 Dec 2017 00:23:49 +0100

Kleiner Korrekturen: Kein ereg() mehr verwenden, Konstruktoren angepasst.

Diffstat:
util/Api.class.php | 1+
util/Ftp.class.php | 170++++++++++++++++++++++++++++++++++++++++---------------------------------------
util/Line.class.php | 12++++++------
util/Publish.class.php | 2+-
util/TreeElement.class.php | 2+-
util/Upload.class.php | 68++++++++++++++++++++++++++++++++++----------------------------------
6 files changed, 129 insertions(+), 126 deletions(-)

diff --git a/util/Api.class.php b/util/Api.class.php @@ -15,6 +15,7 @@ // 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. +use cms\model\Folder; /** diff --git a/util/Ftp.class.php b/util/Ftp.class.php @@ -32,13 +32,15 @@ class Ftp var $url; var $log = array(); - var $passive = false; - - var $ok = true; + var $passive = false; + var $ok = true; - // Konstruktor - function Ftp( $url ) + private $path; + + + // Konstruktor + function __construct( $url ) { $this->connect( $url ); } @@ -49,62 +51,62 @@ class Ftp { $this->url = $url; - global $conf; - + global $conf; + $conf_ftp = $conf['publish']['ftp']; $ftp = parse_url( $this->url ); - // Die projektspezifischen Werte gewinnen bei �berschneidungen mit den Default-Werten - $ftp = array_merge($conf_ftp,$ftp); + // Die projektspezifischen Werte gewinnen bei �berschneidungen mit den Default-Werten + $ftp = array_merge($conf_ftp,$ftp); // Nur FTP und FTPS (seit PHP 4.3) erlaubt - if ( !ereg('^ftps?$',@$ftp['scheme']) ) - { - $this->log[] = 'Unknown scheme in FTP Url: '.@$ftp['scheme']; - $this->log[] = 'Only FTP (and FTPS, if compiled in) are supported'; - $this->ok = false; - return; + if ( !in_array(@$ftp['scheme'],array('ftp','ftps')) ) + { + $this->log[] = 'Unknown scheme in FTP Url: '.@$ftp['scheme']; + $this->log[] = 'Only FTP (and FTPS, if compiled in) are supported'; + $this->ok = false; + return; } - if ( function_exists('ftp_ssl_connect') && $ftp['scheme'] == 'ftps' ) + if ( function_exists('ftp_ssl_connect') && $ftp['scheme'] == 'ftps' ) $this->verb = @ftp_ssl_connect( $ftp['host'],$ftp['port'] ); - else + else $this->verb = @ftp_connect( $ftp['host'],$ftp['port'] ); if ( !$this->verb ) { - $this->log[] = 'Cannot connect to '.$ftp['scheme'].'-server: '.$ftp['host'].':'.$ftp['port']; - $this->ok = false; - - Logger::error('Cannot connect to '.$ftp['host'].':'.$ftp['port']); + $this->log[] = 'Cannot connect to '.$ftp['scheme'].'-server: '.$ftp['host'].':'.$ftp['port']; + $this->ok = false; + + Logger::error('Cannot connect to '.$ftp['host'].':'.$ftp['port']); return; } $this->log[] = 'Connected to FTP server '.$ftp['host'].':'.$ftp['port']; - + if ( empty($ftp['user']) ) - { + { $ftp['user'] = 'anonymous'; $ftp['pass'] = 'openrat@openrat.de'; - } + } - if ( ! ftp_login( $this->verb,$ftp['user'],$ftp['pass'] ) ) + if ( ! ftp_login( $this->verb,$ftp['user'],$ftp['pass'] ) ) { - $this->log[] = 'Unable to login as user '.$ftp['user']; - $this->ok = false; + $this->log[] = 'Unable to login as user '.$ftp['user']; + $this->ok = false; return; } - + $this->log[] = 'Logged in as user '.$ftp['user']; - $pasv = (!empty($ftp['fragment']) && $ftp['fragment'] == 'passive' ); + $pasv = (!empty($ftp['fragment']) && $ftp['fragment'] == 'passive' ); $this->log[] = 'entering passive mode '.($pasv?'on':'off'); - if ( ! ftp_pasv($this->verb,true) ) + if ( ! ftp_pasv($this->verb,true) ) { - $this->log[] = 'cannot switch PASV mode'; - $this->ok = false; - return; + $this->log[] = 'cannot switch PASV mode'; + $this->ok = false; + return; } if ( !empty($ftp['query']) ) @@ -117,11 +119,11 @@ class Ftp foreach( $site_commands as $cmd ) { $this->log .= 'executing SITE command: '.$cmd; - + if ( ! @ftp_site( $this->verb,$cmd ) ) - { - $this->log[] = 'unable to do SITE command: '.$cmd; - $this->ok = false; + { + $this->log[] = 'unable to do SITE command: '.$cmd; + $this->ok = false; return; } } @@ -131,27 +133,27 @@ class Ftp $this->path = rtrim( $ftp['path'],'/' ); $this->log[] = 'Changing directory to '.$this->path; - + if ( ! @ftp_chdir( $this->verb,$this->path ) ) { - $this->log[] = 'unable CHDIR to directory: '.$this->path; - $this->ok = false; + $this->log[] = 'unable CHDIR to directory: '.$this->path; + $this->ok = false; return; - } + } } - - /** - * Kopieren einer Datei vom lokalen System auf den FTP-Server. - * - * @param String Quelle - * @param String Ziel - * @param int FTP-Mode (BINARY oder ASCII) + + /** + * Kopieren einer Datei vom lokalen System auf den FTP-Server. + * + * @param String Quelle + * @param String Ziel + * @param int FTP-Mode (BINARY oder ASCII) */ function put( $source,$dest ) - { - if ( ! $this->ok ) - return; + { + if ( ! $this->ok ) + return; $ftp = parse_url( $this->url ); @@ -171,71 +173,71 @@ class Ftp } Logger::debug("FTP PUT target:$dest mode:".(($mode==FTP_ASCII)?'ascii':'binary')); - + if ( !@ftp_put( $this->verb,$dest,$source,$mode ) ) { - if ( !$this->mkdirs( dirname($dest) ) ) + if ( !$this->mkdirs( dirname($dest) ) ) return; // Fehler. ftp_chdir( $this->verb,$this->path ); if ( ! @ftp_put( $this->verb,$dest,$source,$mode ) ) { - $this->ok = false; - $this->log[] = 'FTP PUT failed...'; - $this->log[] = 'source : '.$source; - $this->log[] = 'destination: '.$dest; + $this->ok = false; + $this->log[] = 'FTP PUT failed...'; + $this->log[] = 'source : '.$source; + $this->log[] = 'destination: '.$dest; return; } } } - - - /** - * Private Methode zum rekursiven Anlegen von Verzeichnissen. - * - * @param String Pfad + + + /** + * Private Methode zum rekursiven Anlegen von Verzeichnissen. + * + * @param String Pfad * @return boolean true, wenn ok */ function mkdirs( $strPath ) { if ( @ftp_chdir($this->verb,$strPath) ) return true; // Verzeichnis existiert schon :) - + $pStrPath = dirname($strPath); if ( !$this->mkdirs($pStrPath) ) return false; - if ( ! @ftp_mkdir($this->verb,$strPath) ) - { - $this->ok = false; - $this->log[] = "failed to create remote directory: $strPath"; - } - + if ( ! @ftp_mkdir($this->verb,$strPath) ) + { + $this->ok = false; + $this->log[] = "failed to create remote directory: $strPath"; + } + return $this->ok; } - - - /** - * Schlie�en der FTP-Verbindung.<br> - * Sollte unbedingt aufgerufen werden, damit keine unn�tigen Sockets aufbleiben. + + + /** + * Schlie�en der FTP-Verbindung.<br> + * Sollte unbedingt aufgerufen werden, damit keine unn�tigen Sockets aufbleiben. */ function close() { - if ( !$this->ok ) // Noch alles ok? - return; - + if ( !$this->ok ) // Noch alles ok? + return; + if ( ! @ftp_quit( $this->verb ) ) - { - // Das Schlie�en der Verbindung hat nicht funktioniert. - // Eigentlich k�nnten wir das ignorieren, aber wir sind anst�ndig und melden eine Fehler. - $this->log[] = 'failed to close connection'; - $this->ok = false; - return; + { + // Das Schlie�en der Verbindung hat nicht funktioniert. + // Eigentlich k�nnten wir das ignorieren, aber wir sind anst�ndig und melden eine Fehler. + $this->log[] = 'failed to close connection'; + $this->ok = false; + return; } } } diff --git a/util/Line.class.php b/util/Line.class.php @@ -4,7 +4,7 @@ * Darstellung einer Zeile in einem Freitext.<br> * <br> * Im Konstruktor wird die Zeile analysiert und es wird festgestellt, was - * die Zeile für einen Inhalt hat (z.B. ein Listenelement, eine Überschrift, usw.)<br> + * die Zeile f�r einen Inhalt hat (z.B. ein Listenelement, eine �berschrift, usw.)<br> * * @author Jan Dankert * @version $Revision$ @@ -12,7 +12,7 @@ */ class Line { - var $source; // Der ursprüngliche Inhalt + var $source; // Der urspr�ngliche Inhalt var $value; // Der textuelle Inhalt (sofern vorhanden) var $isDefinition = false; // Definitionseintrag @@ -20,9 +20,9 @@ class Line var $isNumberedList = false; // numerierte Liste var $indent = 0; // Einschubtiefe der Liste - var $isHeadline = false; // Überschrift - var $isHeadlineUnderline = false; // unterstrichene Überschrift - var $headlineLevel = 0; // Grad der Überschrift (1,2,3...) + var $isHeadline = false; // �berschrift + var $isHeadlineUnderline = false; // unterstrichene �berschrift + var $headlineLevel = 0; // Grad der �berschrift (1,2,3...) var $isTableOfContent = false; // Inhaltsverzeichnis @@ -41,7 +41,7 @@ class Line /** * Erzeugt einen Zeilenobjekt, der Text im Parameter wird dabei geparst. */ - function Line( $s ) + function __construct( $s ) { global $conf; $text_markup = $conf['editor']['text-markup']; diff --git a/util/Publish.class.php b/util/Publish.class.php @@ -97,7 +97,7 @@ class Publish * * @return Publish */ - function Publish() + function __construct() { global $conf; $confPublish = $conf['publish']; diff --git a/util/TreeElement.class.php b/util/TreeElement.class.php @@ -67,7 +67,7 @@ class TreeElement // Konstruktor - function TreeElement() + function __construct() { } } diff --git a/util/Upload.class.php b/util/Upload.class.php @@ -28,44 +28,44 @@ class Upload var $filename; var $extension; var $value; - var $size; + var $size; var $error = ''; - - - /** - * Stellt fest, ob der Upload geklappt hat. - * - * @return boolean - */ - function isValid() - { - return empty($this->error); - } - - - - /** - * Bearbeitet den Upload einer Datei.<br> - * Bei der Objekterzeugung wird die Datei bereits geladen.<br> - * - * @return Upload + + + /** + * Stellt fest, ob der Upload geklappt hat. + * + * @return boolean + */ + function isValid() + { + return empty($this->error); + } + + + + /** + * Bearbeitet den Upload einer Datei.<br> + * Bei der Objekterzeugung wird die Datei bereits geladen.<br> + * + * @return Upload */ - function Upload( $name='file' ) // Konstruktor - { + function __construct( $name='file' ) // Konstruktor + { global $FILES; - - if ( !isset($FILES[$name]) || - !isset($FILES[$name]['tmp_name']) || - !is_file($FILES[$name]['tmp_name']) ) - { - $this->error = 'No file received.'; - return; - } - + + if ( !isset($FILES[$name]) || + !isset($FILES[$name]['tmp_name']) || + !is_file($FILES[$name]['tmp_name']) ) + { + $this->error = 'No file received.'; + return; + } + $this->size = filesize($FILES[$name]['tmp_name']); - - $fh = fopen( $FILES[$name]['tmp_name'],'r' ); - + + $fh = fopen( $FILES[$name]['tmp_name'],'r' ); + $this->value = fread($fh,$this->size); fclose( $fh );