From c719dc0b1dd696e0cd6b51f09ee13c8263375f7c Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Wed, 07 Sep 2011 05:57:38 -0400
Subject: [PATCH] Fixed a warning in maildrop plugin.

---
 interface/lib/app.inc.php |   44 ++++++++++++++++++++++++++++++++++++--------
 1 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/interface/lib/app.inc.php b/interface/lib/app.inc.php
index 8694324..0690d5d 100644
--- a/interface/lib/app.inc.php
+++ b/interface/lib/app.inc.php
@@ -56,6 +56,15 @@
 
 		//* Start the session
 		if($this->_conf['start_session'] == true) {
+			
+			$this->uses('session');
+			session_set_save_handler(	array($this->session, 'open'),
+										array($this->session, 'close'),
+										array($this->session, 'read'),
+										array($this->session, 'write'),
+										array($this->session, 'destroy'),
+										array($this->session, 'gc'));
+			
 			session_start();
 
 			//* Initialize session variables
@@ -64,7 +73,12 @@
 			if(empty($_SESSION['s']['language'])) $_SESSION['s']['language'] = $conf['language'];
 		}
 
-		$this->uses('auth,plugin');
+		$this->uses('auth,plugin,functions');
+	}
+	
+	public function __destruct() {
+		session_write_close();
+		if(isset($this->db)) $this->db->closeConn();
 	}
 
 	public function uses($classes) {
@@ -123,8 +137,20 @@
 		//$this->uses("error");
 		//$this->error->message($msg, $priority);
 		if($stop == true) {
-			$content = file_get_contents(dirname(__FILE__) .
-					'/../web/themes/' . $_SESSION['s']['theme'] . '/templates/error.tpl.htm');
+			/*
+			 * We always have a error. So it is better not to use any more objects like
+			 * the template or so, because we don't know why the error occours (it could be, that
+			 * the error occours in one of these objects..)
+			 */
+			/*
+			 * Use the template inside the user-template - Path. If it is not found, fallback to the
+			 * default-template (the "normal" behaviour of all template - files)
+			 */
+			if (file_exists(dirname(__FILE__) . '/../web/themes/' . $_SESSION['s']['theme'] . '/templates/error.tpl.htm')) {
+				$content = file_get_contents(dirname(__FILE__) . '/../web/themes/' . $_SESSION['s']['theme'] . '/templates/error.tpl.htm');
+			} else {
+				$content = file_get_contents(dirname(__FILE__) . '/../web/themes/default/templates/error.tpl.htm');
+			}
 			if($next_link != '') $msg .= '<a href="'.$next_link.'">Next</a>';
 			$content = str_replace('###ERRORMSG###', $msg, $content);
 			die($content);
@@ -136,13 +162,15 @@
 
 	/** Translates strings in current language */
 	public function lng($text) {
+		global $conf;
 		if($this->_language_inc != 1) {
+			$language = (isset($_SESSION['s']['language']))?$_SESSION['s']['language']:$conf['language'];
 			//* loading global Wordbook
-			$this->load_language_file('/lib/lang/'.$_SESSION['s']['language'].'.lng');
+			$this->load_language_file('lib/lang/'.$language.'.lng');
 			//* Load module wordbook, if it exists
-			if(isset($_SESSION['s']['module']['name']) && isset($_SESSION['s']['language'])) {
-				$lng_file = '/web/'.$_SESSION['s']['module']['name'].'/lib/lang/'.$_SESSION['s']['language'].'.lng';
-				if(!file_exists(ISPC_ROOT_PATH.$lng_file)) $lng_file = '/web/'.$_SESSION['s']['module']['name'].'/lib/lang/en.lng';
+			if(isset($_SESSION['s']['module']['name'])) {
+				$lng_file = 'web/'.$_SESSION['s']['module']['name'].'/lib/lang/'.$language.'.lng';
+				if(!file_exists(ISPC_ROOT_PATH.'/'.$lng_file)) $lng_file = '/web/'.$_SESSION['s']['module']['name'].'/lib/lang/en.lng';
 				$this->load_language_file($lng_file);
 			}
 			$this->_language_inc = 1;
@@ -162,7 +190,7 @@
 		$filename = ISPC_ROOT_PATH.'/'.$filename;
 		if(substr($filename,-4) != '.lng') $this->error('Language file has wrong extension.');
 		if(file_exists($filename)) {
-			@include_once($filename);
+			@include($filename);
 			if(is_array($wb)) {
 				if(is_array($this->_wb)) {
 					$this->_wb = array_merge($this->_wb,$wb);

--
Gitblit v1.9.1