commit 76ddb483ca59715dc4b9f9fa3ca63f7b70722e42
parent 77b6d3a5c517eda8157c091d5e20ef1965dec735
Author: dankert <devnull@localhost>
Date: Sat, 24 Apr 2004 19:03:29 +0200
Initiale Version
Diffstat:
10 files changed, 909 insertions(+), 0 deletions(-)
diff --git a/serviceClasses/.htaccess b/serviceClasses/.htaccess
@@ -0,0 +1,2 @@
+order deny,allow
+deny from all+
\ No newline at end of file
diff --git a/serviceClasses/Api.class.php b/serviceClasses/Api.class.php
@@ -0,0 +1,78 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// 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.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2004-04-24 17:03:29 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+class Api
+{
+ var $output = '';
+
+ function db()
+ {
+ return db_connection();
+ }
+
+ function pageid()
+ {
+ echo 'WARNING: pageid() deprecated!<br>';
+ global $SESS;
+ return $SESS['objectid'];
+ }
+
+ function getObjectId()
+ {
+ global $SESS;
+ return $SESS['objectid'];
+ }
+
+ function getRootObjectId()
+ {
+ return Folder::getRootObjectId();
+ }
+
+ function folderid()
+ {
+ global $SESS;
+ return $SESS['folderid'];
+ }
+
+
+ function delOutput()
+ {
+ $this->output = '';
+ }
+
+ function output( $text )
+ {
+ $this->output .= $text;
+ }
+
+
+ function getOutput()
+ {
+ return $this->output;
+ }
+}+
\ No newline at end of file
diff --git a/serviceClasses/Ftp.class.php b/serviceClasses/Ftp.class.php
@@ -0,0 +1,190 @@
+<?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.
+#
+
+
+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 -> $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 );
+ }
+}
+
+
+?>+
\ No newline at end of file
diff --git a/serviceClasses/GlobalFunctions.class.php b/serviceClasses/GlobalFunctions.class.php
@@ -0,0 +1,65 @@
+<?php
+
+class GlobalFunctions
+{
+ function getIsoCodes()
+ {
+ global $conf_php;
+
+ $iso = parse_ini_file( './language/lang.ini.'.$conf_php );
+ asort( $iso );
+ return $iso;
+ }
+
+
+ function lang( $text )
+ {
+ global $SESS;
+ $text = strtoupper($text);
+
+ if ( isset( $SESS['lang'][$text] ) )
+ {
+ return $SESS['lang'][$text];
+ }
+ else
+ {
+ return( '?'.$text.'?' );
+ }
+ }
+
+
+ # Spracheinstellungen laden
+
+ function language_from_http()
+ {
+ global $SESS,
+ $HTTP_SERVER_VARS,
+ $conf_php,
+ $conf;
+
+ $languages = $HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'];
+ $languages = explode(',',$languages);
+ foreach( $languages as $l )
+ {
+ $l = substr($l,0,2);
+ if ( file_exists("./language/$l.ini.$conf_php") )
+ return( $l );
+ }
+
+ // Keine passende Sprache im HTTP-Header gefunden
+ return $conf['global']['default_language'];
+ }
+
+
+ function language_read( $l='' )
+ {
+ global $SESS,
+ $HTTP_SERVER_VARS,
+ $conf_php;
+
+ $l = language_from_http();
+ $SESS['lang'] = parse_ini_file( "./language/$l.ini.$conf_php" );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/serviceClasses/Html.class.php b/serviceClasses/Html.class.php
@@ -0,0 +1,59 @@
+<?php
+
+
+class Html
+{
+ function selectBox( $name,$values,$default='',$params=Array() )
+ {
+ $src = '<select size="1" name="'.$name.'"';
+ foreach( $params as $name=>$value )
+ $src .= " $name=\"$value\"";
+ $src .= '>';
+
+ foreach( $values as $key=>$value )
+ {
+ $src .= '<option value="'.$key.'"';
+ if ($key == $default)
+ $src .= ' selected="selected"';
+ $src .= '>'.$value.'</option>';
+ }
+ $src .= '</select>';
+
+ return $src;
+ }
+
+
+ function checkBox( $name,$value=false,$writable=true,$params=Array() )
+ {
+ $src = '<input type="checkbox" name="'.$name.'"';
+
+ foreach( $params as $name=>$val )
+ $src .= " $name=\"$val\"";
+
+ if ( !$writable )
+ $src .= ' disabled="disabled"';
+
+ if ( $value )
+ $src .= ' checked="checked"';
+
+ $src .= ' />';
+
+ return $src;
+ }
+
+
+ function url( $params )
+ {
+ $url = '';
+ foreach( $params as $var=>$value )
+ {
+ if ( $url == '' )
+ $url = '?';
+ else $url .= '&';
+
+ $url .= urlencode($var).'='.urlencode($value);
+ }
+ return 'do.'.CONF_PHP.$url;
+ }
+}
+?>+
\ No newline at end of file
diff --git a/serviceClasses/Logger.class.php b/serviceClasses/Logger.class.php
@@ -0,0 +1,137 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat 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.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2004-04-24 17:03:28 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+define('OR_LOG_LEVEL_DEBUG' ,1);
+define('OR_LOG_LEVEL_INFO' ,2);
+define('OR_LOG_LEVEL_WARNING',3);
+define('OR_LOG_LEVEL_ERROR' ,4);
+
+/**
+ * Schreiben eines Eintrages in die Logdatei
+ *
+ * @author $Author$
+ * @version $Rev: $
+ */
+class Logger
+{
+ /**
+ * Schreiben einer Debug-Meldung in die Logdatei
+ *
+ * @param message Log-Text
+ */
+ function debug( $message )
+ {
+ Logger::doLog( OR_LOG_LEVEL_DEBUG,$message );
+ }
+
+
+ /**
+ * Schreiben einer Information in die Logdatei
+ *
+ * @param message Log-Text
+ */
+ function info( $message )
+ {
+ Logger::doLog( OR_LOG_LEVEL_INFO,$message );
+ }
+
+
+ /**
+ * Schreiben einer Warnung in die Logdatei
+ *
+ * @param message Log-Text
+ */
+ function warning( $message )
+ {
+ $this->doLog( OR_LOG_LEVEL_WARN,$message );
+ }
+
+
+ /**
+ * Schreiben einer normalen Fehlermeldung in die Logdatei
+ *
+ * @param message Log-Text
+ */
+ function error( $message )
+ {
+ $this->doLog( OR_LOG_LEVEL_ERROR,$message );
+ }
+
+
+ /**
+ * Schreiben der Meldung in die Logdatei
+ *
+ * @author $Author$
+ * @param facility Schwere dieses Logdatei-Eintrages (z.B. warning)
+ * @param message Log-Text
+ * @access private
+ */
+ function doLog( $facility,$message )
+ {
+ global $conf;
+ global $SESS;
+
+ $filename = $conf['log']['file'];
+
+ if ( $filename == '' )
+ return;
+
+ if ( ! is_writable($filename) )
+ die( "logfile $filename is not writable by the server" );
+
+ $confLevel = strtoupper($conf['log']['level']);
+ $confLevelConstant = 'OR_LOG_LEVEL_'.$confLevel;
+ if ( !defined($confLevelConstant) )
+ die( "unknown log level $confLevel in config" );
+
+ if ( constant($confLevelConstant) > $facility )
+ return;
+
+ if ( isset($SESS['user']) )
+ $username = $SESS['user']['name'];
+ else $username = 'unknown';
+
+ $text = $conf['log']['format']; // Format der Logdatei lesen
+
+ // Ersetzen von Variablen
+ if ( $conf['log']['dns_lookup'] )
+ $text = str_replace( '%host',gethostbyaddr(getenv('REMOTE_ADDR')),$text );
+ else $text = str_replace( '%host',getenv('REMOTE_ADDR'),$text );
+ $text = str_replace( '%user' ,str_pad($username,8),$text );
+ $text = str_replace( '%level' ,str_pad($confLevel,5),$text );
+ $text = str_replace( '%agent' ,getenv('HTTP_USER_AGENT'),$text );
+ $text = str_replace( '%action',str_pad($SESS['action'],12),$text );
+ $text = str_replace( '%text' ,$message,$text );
+ $text = str_replace( '%time' ,date($conf['log']['date_format']),$text );
+
+ // Schreiben in Logdatei
+ error_log( $text."\n",3,$filename );
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/serviceClasses/Publish.class.php b/serviceClasses/Publish.class.php
@@ -0,0 +1,135 @@
+<?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.
+#
+
+
+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 > $dest<br>";
+ if (!copy( $source,$dest ));
+ {
+ $this->mkdirs( dirname($dest) );
+
+ if (!copy( $source,$dest ))
+ {
+ //echo "$source > $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();
+ }
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/serviceClasses/Sql.class.php b/serviceClasses/Sql.class.php
@@ -0,0 +1,125 @@
+<?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.
+#
+
+
+// Namen der Datenbanktabellen in Variablen schreiben
+//
+
+
+
+// Verwalten eines SQL-Statements
+class Sql
+{
+ var $query = '';
+ var $data = Array();
+
+ // Konstruktor, normalerweise setzen der SQL-Abfrage
+ function Sql( $query = '' )
+ {
+ $this->query = $query;
+ $this->data = array();
+
+ foreach( table_names() as $t=>$name )
+ {
+ $this->query = str_replace( '{'.$t.'}',$name,$this->query );
+ }
+ }
+
+
+ // Neues Setzen der SQL-Abfrage
+ function setQuery( $query = '' )
+ {
+ $this->query = $query;
+
+ foreach( table_names() as $t=>$name )
+ {
+ $this->query = str_replace( '{'.$t.'}',$name,$this->query );
+ }
+
+ foreach( $this->data as $name=>$data )
+ {
+ if ( $data['type']=='string' ) $this->setString($name,$data['value'] );
+ if ( $data['type']=='int' ) $this->setInt ($name,$data['value'] );
+ if ( $data['type']=='null' ) $this->setNull ($name );
+ }
+ }
+
+
+ function setVar( $name,$value )
+ {
+ if ( is_string($value) )
+ $this->setString( $name,$value );
+
+ if ( is_null($value) )
+ $this->setNull( $name );
+
+ if ( is_int($value) )
+ $this->setInt( $name,$value );
+ }
+
+
+ function setInt( $name,$value )
+ {
+ $this->data[ $name ] = array( 'type'=>'int','value'=>$value );
+ $this->query = str_replace( '{'.$name.'}',intval($value),$this->query );
+ }
+
+
+ function setString( $name,$value )
+ {
+ $this->data[ $name ] = array( 'type'=>'string','value'=>$value );
+
+ //if ( defined('CONF_ADDSLASHES') && CONF_ADDSLASHES )
+ $value = addslashes( $value );
+
+ $value = "'".$value."'";
+ $this->query = str_replace( '{'.$name.'}',$value,$this->query );
+ }
+
+
+ function setBoolean( $name,$value )
+ {
+ if ( $value )
+ $this->setInt( $name,1 );
+ else $this->setInt( $name,0 );
+ }
+
+
+ function setNull( $name )
+ {
+ $this->data[ $name ] = array( 'type'=>'null' );
+ $this->query = str_replace( '{'.$name.'}','NULL',$this->query );
+ }
+
+
+ function query()
+ {
+ return $this->getQuery();
+ }
+
+
+ function getQuery()
+ {
+ return $this->query;
+ }
+}
+
+
+?>+
\ No newline at end of file
diff --git a/serviceClasses/Text.class.php b/serviceClasses/Text.class.php
@@ -0,0 +1,46 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// 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.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2004-04-24 17:03:28 dankert
+// Initiale Version
+//
+// ---------------------------------------------------------------------------
+
+
+// Klasse fuer Textfunktionen
+class Text
+{
+ // Einen Text auf eine maximale Laenge beschränken.
+ //
+ // Falls Text zu lang ist wird mit '...' abgekürzt
+ //
+ function maxLaenge( $laenge,$text )
+ {
+ if ( strlen($text) > $laenge )
+ $text = substr($text,0,$laenge).'...';
+
+ return $text;
+ }
+}
+
+
+?>+
\ No newline at end of file
diff --git a/serviceClasses/Upload.class.php b/serviceClasses/Upload.class.php
@@ -0,0 +1,62 @@
+<?php
+// ---------------------------------------------------------------------------
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002-2004 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.
+// ---------------------------------------------------------------------------
+// $Log$
+// Revision 1.1 2004-04-24 17:03:28 dankert
+// Initiale Version
+//
+// Revision 1.1 2003/10/27 23:21:55 dankert
+// Methode(n) hinzugefügt: savevalue(), save()
+//
+// ---------------------------------------------------------------------------
+
+
+class Upload
+{
+ var $filename;
+ var $extension;
+ var $value;
+ var $size;
+
+ function Upload() // Konstruktor
+ {
+ global $FILES;
+
+ $this->size = filesize($FILES['file']['tmp_name']);
+
+ $fh = fopen( $FILES['file']['tmp_name'],'r' );
+ $this->value = fread($fh,$this->size);
+ fclose( $fh );
+
+ $this->filename = $FILES['file']['name'];
+ $this->extension = '';
+
+ $p = strrpos( $this->filename,'.' ); // Letzten Punkt suchen
+
+ if ($p!==false) // Wennn letzten Punkt gefunden, dann dort aufteilen
+ {
+ $this->extension = substr( $this->filename,$p+1 );
+ $this->filename = substr( $this->filename,0,$p );
+ }
+ }
+}
+
+?>+
\ No newline at end of file