Index: branches/2.8.x/CHANGELOG
===================================================================
--- branches/2.8.x/CHANGELOG	(revision 2132)
+++ branches/2.8.x/CHANGELOG	(revision 2133)
@@ -10,6 +10,10 @@
 # = Bugfix
 ! = Update/Change
 ===============================================================================
+01 Sep -2015 Build 2133 Manuela v.d.Decken(DarkViper)
++ new error_handler added
++ var/log/error.log added
++ new class LogRotation added
 01 Sep -2015 Build 2132 Manuela v.d.Decken(DarkViper)
 ! class WbDatabase: all deprecated methods now will trigger a E_USER_DEPRECATED error.
 23 Jun -2015 Build 2131 Manuela v.d.Decken(DarkViper)
Index: branches/2.8.x/wb/var/log/error.log
===================================================================
Index: branches/2.8.x/wb/admin/interface/version.php
===================================================================
--- branches/2.8.x/wb/admin/interface/version.php	(revision 2132)
+++ branches/2.8.x/wb/admin/interface/version.php	(revision 2133)
@@ -51,5 +51,5 @@
 
 // check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
 if(!defined('VERSION')) define('VERSION', '2.8.4');
-if(!defined('REVISION')) define('REVISION', '2132');
+if(!defined('REVISION')) define('REVISION', '2133');
 if(!defined('SP')) define('SP', '');
Index: branches/2.8.x/wb/framework/initialize.php
===================================================================
--- branches/2.8.x/wb/framework/initialize.php	(revision 2132)
+++ branches/2.8.x/wb/framework/initialize.php	(revision 2133)
@@ -236,11 +236,13 @@
             $bRetval = true;
         }
         $aBt= debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
+        $x = sizeof($aBt) -1;
+        $x = $x < 2 ? $x : 2;
         $sEntry = date('c').' '.'['.$sErrorType.'] '.str_replace(dirname(__DIR__), '', $sErrorFile).':['.$iErrorLine.'] '
-                . ' from '.str_replace(dirname(__DIR__), '', $aBt[2]['file']).':['.$aBt[2]['line'].'] '
-                . (@$aBt[2]['class'] ? $aBt[2]['class'].$aBt[2]['type'] : '').$aBt[2]['function'].' '
+                . ' from '.str_replace(dirname(__DIR__), '', $aBt[$x]['file']).':['.$aBt[$x]['line'].'] '
+                . (@$aBt[$x]['class'] ? $aBt[$x]['class'].$aBt[$x]['type'] : '').$aBt[$x]['function'].' '
                 . '"'.$sErrorText.'"'.PHP_EOL;
-        file_put_contents(dirname(__DIR__).'/temp/ERROR.LOG', $sEntry, FILE_APPEND);
+        file_put_contents(dirname(__DIR__).'/var/log/error.log', $sEntry, FILE_APPEND);
         return $bRetval;
     }
 /* ***************************************************************************************
@@ -307,6 +309,10 @@
     if(!function_exists('globalExceptionHandler')) {
         include(__DIR__.'/globalExceptionHandler.php');
     }
+// check logfiles and compress it if needed
+    $oLogRotate = new LogRotation($oReg);
+    $oLogRotate->execute();
+    unset($oLogRotate);
 // ---------------------------
 // get Database connection data from configuration
     $aSqlData = initGetDbConnectData($aCfg, $sDbConnectType);
@@ -339,15 +345,17 @@
                     case 'STRING_FILE_MODE':
                         $iTmp = ((intval(octdec($aRecords[$i]['value'])) & ~0111)|0600);
                         if(!defined('OCTAL_FILE_MODE')) { define('OCTAL_FILE_MODE', $iTmp); } // deprecated
-                        if(!defined('FILE_MODE_OCTAL')) { define('FILE_MODE_OCTAL', $iTmp); }
+                        if(!defined('FILE_MODE_OCTAL')) { define('FILE_MODE_OCTAL', $iTmp); } // deprecated
                         if(!defined('STRING_FILE_MODE')) { define('STRING_FILE_MODE', sprintf('0%03o', $iTmp)); } // deprecated
+                        if(!defined('FILE_MODE')) { define('FILE_MODE', $iTmp); }
                         if(!defined('FILE_MODE_STRING')) { define('FILE_MODE_STRING', sprintf('0%03o', $iTmp)); }
                         break;
                     case 'STRING_DIR_MODE':
                         $iTmp = (intval(octdec($aRecords[$i]['value'])) |0711);
                         if(!defined('OCTAL_DIR_MODE')) { define('OCTAL_DIR_MODE', $iTmp); } // deprecated
-                        if(!defined('DIR_MODE_OCTAL')) { define('DIR_MODE_OCTAL', $iTmp); }
+                        if(!defined('DIR_MODE_OCTAL')) { define('DIR_MODE_OCTAL', $iTmp); } // deprecated
                         if(!defined('STRING_DIR_MODE')) { define('STRING_DIR_MODE', sprintf('0%03o', $iTmp)); } // deprecated
+                        if(!defined('DIR_MODE')) { define('DIR_MODE', $iTmp); }
                         if(!defined('DIR_MODE_STRING')) { define('DIR_MODE_STRING', sprintf('0%03o', $iTmp)); }
                         break;
                     case 'PAGES_DIRECTORY':
@@ -463,6 +471,7 @@
 // load and activate new global translation table
     $oTrans = Translate::getInstance();
 /* initializise Translate old style *************************************************** */
+
     $oTrans->initialize(
         'en',
         (defined('DEFAULT_LANGUAGE') ? DEFAULT_LANGUAGE : ''),
@@ -471,19 +480,19 @@
 //        (Translate::CACHE_DISABLED|Translate::KEEP_MISSING),
         (DEBUG ? Translate::CACHE_DISABLED|Translate::KEEP_MISSING : 0)
     );
+
 /* initializise Translate new style *************************************************** */
 /*
     $oTrans->initialize(
-        new TranslateAdaptorWbOldStyle,
+        new TranslateAdaptorWbOldStyle($oReg),
         'en',
         (defined('DEFAULT_LANGUAGE') ? DEFAULT_LANGUAGE : ''),
         (defined('LANGUAGE') ? LANGUAGE : ''),
-//        (Translate::CACHE_DISABLED|Translate::KEEP_MISSING),
         (DEBUG ? Translate::CACHE_DISABLED|Translate::KEEP_MISSING : 0),
         $oReg->DirModeOctal,
         $oReg->TempPath
     );
- */
+*/
 /* ****** */
     $oReg->setDatabase(WbDatabase::getInstance());
     $oReg->setTranslate(Translate::getInstance());
Index: branches/2.8.x/wb/framework/LogRotation.php
===================================================================
--- branches/2.8.x/wb/framework/LogRotation.php	(nonexistent)
+++ branches/2.8.x/wb/framework/LogRotation.php	(revision 2133)
@@ -0,0 +1,173 @@
+<?php
+
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * LogRotation.php
+ *
+ * @category     Core
+ * @package      Core_logging
+ * @copyright    Manuela v.d.Decken <manuela@isteam.de>
+ * @author       Manuela v.d.Decken <manuela@isteam.de>
+ * @license      http://www.gnu.org/licenses/gpl.html   GPL License
+ * @version      0.0.1
+ * @revision     $Revision: $
+ * @lastmodified $Date: $
+ * @since        File available since 29.06.2015
+ * @description  handles logfiles and compress it if they are too big(like server logs)
+ */
+class LogRotation
+{
+    protected $iMaxLogfileSize = 20;   // size as MB
+    protected $iMaxLogfiles    = 10;   //
+    protected $iScanFrequency  = 3600; // scan each hour
+    protected $sLogPath        = '';   // AppPath + 'var/log'
+    protected $aLogFiles       = null; // like 'error.log'
+    protected $aLogFilesGz     = null; // like 'error.log.1.gz'
+
+/**
+ * constructor
+ * @param WbAdaptor $oReg
+ * @throws AppException
+ */
+    public function __construct(WbAdaptor $oReg)
+    {
+        $this->sLogPath = $oReg->VarPath.'log/';
+        if (!file_exists($this->sLogPath)) {
+            $iOldUmask = umask(0);
+            if (!mkdir($this->sLogPath, $oReg->FileMode, true)) {
+                throw new AppException('unable to create LogPath ['.$this->sLogPath.']');
+            }
+            umask($iOldUmask);
+        }
+    }
+/**
+ * proceed compression if needed
+ */
+    public function execute()
+    {
+        if ($this->checkSemaphore($this->sLogPath.'LOCK')) {
+            // scan for uncompressed log files
+            $this->aLogFiles = $this->scanForFiles($this->sLogPath);
+            foreach($this->aLogFiles as $sFile) {
+            // iterate matching log files
+                if ($this->isLogFileFull($this->sLogPath.$sFile)) {
+                // start processing if uncompressed file exceeds limit
+                    $aGzFiles = $this->scanForFiles($this->sLogPath, $sFile.'.*.gz');
+                    // rename existing gz files
+                    $this->renameExistingGzFiles($aGzFiles);
+                    // compress logfile into gz archive
+                    $this->compressFile($this->sLogPath.$sFile, $this->sLogPath.$sFile.'.0.gz');
+                    // remove logfile (next entry will create new one)
+                    unlink($this->sLogPath.$sFile);
+                }
+            }
+        }
+    }
+/**
+ *
+ * @param string $sSemaphoreFile file which holds the timestamp from last scan
+ * @return bool
+ * @throws AppException
+ */
+    protected function checkSemaphore($sSemaphoreFile)
+    {
+        // test if readable file exists
+        if (!is_readable($sSemaphoreFile)) {
+            // try to create with current timestamp
+            if (!touch($sSemaphoreFile)) {
+                throw new AppException('unable to create semaphore ['.$sSemaphoreFile.']');
+            }
+        } else {
+            // return true if it's time for next scan
+            return ((filemtime($sSemaphoreFile) + $this->iScanFrequency) > time());
+        }
+    }
+/**
+ * compress source file into target file
+ * @param string $sSourceFile
+ * @param string $sTargetFile
+ */
+    protected function compressFile($sSourceFile, $sTargetFile)
+    {
+        // try to write/create target file
+        if (touch($sTargetFile)) {
+            $oSource = gzopen($sSourceFile, 'rb');
+            $oTarget = gzopen($sTargetFile, 'wb9');
+            if ($oSource && $oTarget) {
+                while (!gzeof($oSource)) {
+                    // read 64k buffer
+                    $sBuff = gzread($oSource, 64*1024);
+                    $iBuffLen = strlen($sBuff);
+                    // write the buffer
+                    gzwrite($oTarget, $sBuff, $iBuffLen);
+                }
+                // close files and clear buffer
+                gzclose($oSource);
+                gzclose($oTarget);
+                unset($sBuff);
+            }
+        }
+    }
+/**
+ * rename files to index+1 and delete files with index >= iMaxLogfiles
+ * @param array $aGzFiles
+ * @param string $sBasefile
+ */
+    protected function renameExistingGzFiles(array $aGzFiles, $sBasefile)
+    {
+        natsort($aGzFiles);
+        $aGzFiles = array_merge(array_reverse($aGzFiles));
+        $sPattern = '/^'.preg_quote($sBasefile, '/').'\.([0-9]+)\.gz$/s';
+        foreach ($aGzFiles as $iKey=>$sFile) {
+            if ($iKey < $this->iMaxLogfiles) {
+                if (preg_match($sPattern, $sFile, $aMatch)) {
+                    $sNewFile = $sBasefile.'.'.(string)($aMatch[1]++).'.gz';
+                    rename($this->sLogPath.$sFile, $this->sLogPath.$sNewFile);
+                }
+            } else {
+                unlink($this->sLogPath.$sFile);
+            }
+        }
+    }
+/**
+ * check size of file
+ * @param string $sFile
+ * @return bool true if filesize greater than iMaxLogfileSize
+ */
+    protected function isLogFileFull($sFile)
+    {
+        $iSize = (int)floor(filesize($sFile) / pow(2, 20));
+        return ($iSize >= $this->iMaxLogfileSize);
+    }
+/**
+ * scan for log files
+ * @param string $sLogPath
+ * @param string $sPattern
+ * @return array  list of files
+ */
+    protected function scanForFiles($sLogPath, $sPattern = '*.log')
+    {
+        $sOldDir = getcwd();
+        chdir($sLogPath);
+        $aRetval = glob($sPattern, GLOB_NOSORT);
+        chdir($sOldDir);
+        return $aRetval;
+    }
+
+} // end of class LogRotation
