Index: t3lib/config_default.php
===================================================================
--- t3lib/config_default.php	(Revision 5730)
+++ t3lib/config_default.php	(Arbeitskopie)
@@ -231,6 +231,7 @@
 		'notificationPrefix' => '[TYPO3 Note]',	// String: Used to prefix the subject of mails sent in the taskcenter
 		'accessListRenderMode' => 'singlebox',	// Can be "singlebox", "checkbox" or blank. Refers to the "renderMode" for the selector boxes in be-groups configuration.
 		'explicitADmode' => 'explicitDeny',	// Sets the general allow/deny mode for selector box values. Value can be either "explicitAllow" or "explicitDeny", nothing else!
+		'TSconfigConditions' => 0,			// Boolean. When set it is possible to have TypoScript like conditions in BE Page/User/Group TS-Config
 		'niceFlexFormXMLtags' => TRUE,			// If set, the flexform XML will be stored with meaningful tags which can be validated with DTD schema. If you rely on custom reading of the XML from pre-4.0 versions you should set this to false if you don't like to change your reader code (internally it is insignificant since t3lib_div::xml2array() doesn't care for the tags if the index-attribute value is set)
 		'flexFormXMLincludeDiffBase' => TRUE,	// If set, an additional tag with index "vXX.vDEFbase" is created for translations in flexforms holding the value of the default language when translation was changed. Used to show diff of value. This setting will change whether the system thinks flexform XML looks clean. For example when FALSE XX.vDEFbase fields will be removed in cleaning while accepted if TRUE (of course)
 		'compactFlexFormXML' => 0,				// If set, the flexform XML will not contain indentation spaces making XML more compact
Index: t3lib/class.t3lib_tstemplate.php
===================================================================
--- t3lib/class.t3lib_tstemplate.php	(Revision 5730)
+++ t3lib/class.t3lib_tstemplate.php	(Arbeitskopie)
@@ -285,7 +285,7 @@
 	 */
 	function matching($cc)	{
 		if (is_array($cc['all']))	{
-			$matchObj = t3lib_div::makeInstance('t3lib_matchCondition');
+			$matchObj = t3lib_div::makeInstance('t3lib_matchCondition_frontend');
 			$matchObj->altRootLine=$cc['rootLine'];
 			foreach ($cc['all'] as $key => $pre) {
 				if ($matchObj->match($pre))	{
@@ -791,7 +791,7 @@
 		$constants->breakPointLN=intval($this->ext_constants_BRP);
 		$constants->setup = $this->const;
 		$constants->setup = $this->mergeConstantsFromPageTSconfig($constants->setup);
-		$matchObj = t3lib_div::makeInstance('t3lib_matchCondition');
+		$matchObj = t3lib_div::makeInstance('t3lib_matchCondition_frontend');
 		$matchObj->matchAlternative = $this->matchAlternative;
 		$matchObj->matchAll = $this->matchAll;		// Matches ALL conditions in TypoScript
 
Index: t3lib/class.t3lib_tsparser_tsconfig.php
===================================================================
--- t3lib/class.t3lib_tsparser_tsconfig.php	(Revision 0)
+++ t3lib/class.t3lib_tsparser_tsconfig.php	(Revision 0)
@@ -0,0 +1,202 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 1999-2007 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 2007 Kraft Bernhard (kraftb@kraftb.at)
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project 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.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script 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.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+/**
+ * A TS-Config parsing class which performs condition evaluation
+ *
+ * $Id$
+ *
+ * @author	Kraft Bernhard <kraftb@kraftb.at>
+ */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ */
+
+class t3lib_TSparser_TSconfig extends t3lib_TSparser {
+	/**
+	 * Parses the passed TS-Config using conditions and caching
+	 *
+	 * @param	integer	The uid of the page being handled
+	 * @param	array	The rootline of the page being handled
+	 * @param	string	The TSConfig being parsed
+	 * @param	string	The type of TSConfig (either "userTS" or "PAGES")
+	 * @return	array	Array containing the parsed TSConfig and a flag wheter the content was retrieved from cache
+	 * @access private
+	 * @see t3lib_TSparser
+	 */
+	public function parseTSconfig($TStext, $id, $rootLine, $type) {
+		$this->type = $type;
+		$this->id = $id;
+		$this->rootLine = $rootLine;
+		$hash = md5($type.':'.$TStext);
+		$cachedContent = $this->getHash($hash, 0);
+
+		if ($cachedContent) {
+			$storedData = unserialize($cachedContent);
+			$storedMD5 = substr($cachedContent, -strlen($hash));
+			$storedData['match'] = array();
+			$storedData = $this->matching($storedData);
+			$checkMD5 = md5(serialize($storedData));
+
+			if ($checkMD5 == $storedMD5) {
+				$res = array(
+					'TSconfig' => $storedData['TSconfig'],
+					'cached' => 1,
+				);
+			} else {
+				$shash = md5($checkMD5.$hash);
+				$cachedSpec = $this->getHash($shash, 0);
+				if ($cachedSpec) {
+					$storedData = unserialize($cachedSpec);
+					$res = array(
+						'TSconfig' => $storedData['TSconfig'],
+						'cached' => 1,
+					);
+				} else {
+					$storeData = $this->parseWithConditions($TStext);
+					$serData = serialize($storeData);
+					$this->storeHash($shash, $serData, $type.'_TSconfig');
+					$res = array(
+						'TSconfig' => $storeData['TSconfig'],
+						'cached' => 0,
+					);
+				}
+			}
+		} else {
+			$storeData = $this->parseWithConditions($TStext);
+			$serData = serialize($storeData);
+			$md5 = md5($serData);
+			$this->storeHash($hash, $serData.$md5, $type.'_TSconfig');
+			$res = array(
+				'TSconfig' => $storeData['TSconfig'],
+				'cached' => 0,
+			);
+		}
+		return $res;
+	}
+
+
+	/**
+	 * Retrieves the string content stored with hash key, $hash, in cache_hash
+	 * Wrapper to the functions by same name found in t3lib_page and t3lib_BEfunc
+	 * Usage: 1
+	 *
+	 * @param	string		Hash key, 32 bytes hex
+	 * @param	integer		$expTime represents the expire time in seconds. For instance a value of 3600 would allow cached content within the last hour, otherwise nothing is returned.
+	 * @return	string
+	 * @see t3lib_page::getHash()
+	 * @see t3lib_befunc::getHash()
+	 */
+	protected function getHash($hash, $expTime) {
+		if (TYPO3_MODE=='BE') {
+			return t3lib_BEfunc::getHash($hash, $expTime);
+		} elseif (TYPO3_MODE=='FE') {
+			if ($GLOBALS['TSFE']->sys_page) {
+					// After initialization of sys_page
+				return $GLOBALS['TSFE']->sys_page->getHash($hash, $expTime);
+			} else {
+					// When BE user is logged in while viewing frontend (FE-Editing) we have to use the t3lib_BEfunc
+					// method before TSFE->sys_page is initialized
+				return t3lib_BEfunc::getHash($hash, $expTime);
+			}
+		}
+	}
+
+
+	/**
+	 * Stores the string value $data in the 'cache_hash' table with the hash key, $hash, and visual/symbolic identification, $ident
+	 * Wrapper to the functions by same name found in t3lib_page and t3lib_BEfunc
+	 * Usage: 1
+	 *
+	 * @param	string		32 bit hash string (eg. a md5 hash of a serialized array identifying the data being stored)
+	 * @param	string		The data string. If you want to store an array, then just serialize it first.
+	 * @param	string		$ident is just a textual identification in order to inform about the content! May be 20 characters long.
+	 * @return	void
+	 * @see t3lib_page::storeHash()
+	 * @see t3lib_befunc::storeHash()
+	 */
+	protected function storeHash($hash, $data, $ident) {
+		if (TYPO3_MODE=='BE') {
+			t3lib_BEfunc::storeHash($hash, $data, $ident);
+		} elseif (TYPO3_MODE=='FE') {
+			if ($GLOBALS['TSFE']->sys_page) {
+					// After initialization of sys_page
+				$GLOBALS['TSFE']->sys_page->storeHash($hash, $data, $ident);
+			} else {
+					// When BE user is logged in while viewing frontend (FE-Editing) we have to use the t3lib_BEfunc
+					// method before TSFE->sys_page is initialized
+				t3lib_BEfunc::storeHash($hash, $data, $ident);
+			}
+		}
+	}
+
+
+	/**
+	 * Does the actual parsing using the parent objects "parse" method. Creates the match-Object
+	 *
+	 * @param	string	The TSConfig being parsed
+	 * @return	array	Array containing the parsed TSConfig, the encountered sectiosn, the matched sections
+	 * @access private
+	 */
+	protected function parseWithConditions($TSconfig) {
+		$matchObj = t3lib_div::makeInstance('t3lib_matchCondition_backend', $this);
+		$this->parse($TSconfig, $matchObj);
+		$storeData = array(
+			'TSconfig' => $this->setup,
+			'sections' => $this->sections,
+			'match' => $this->sectionsMatch,
+		);
+		return $storeData;
+	}
+
+
+	/**
+	 * Is just going through an array of conditions to determine which are matching (for getting correct cache entry)
+	 *
+	 * @param	array	An array containing the sectiosn to match
+	 * @return	array	The input array with matching sections filled into the "match" key
+	 * @access private
+	 */
+	protected function matching($cc) {
+		if (is_array($cc['sections'])) {
+			$matchObj = t3lib_div::makeInstance('t3lib_matchCondition_backend', $this);
+			foreach ($cc['sections'] as $key => $pre) {
+				if ($matchObj->match($pre)) {
+					$cc['match'][$key] = $pre;
+				}
+			}
+		}
+		return $cc;
+	}
+
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser_tsconfig.php']) {
+	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser_tsconfig.php']);
+}
+?>
\ No newline at end of file
Index: t3lib/class.t3lib_befunc.php
===================================================================
--- t3lib/class.t3lib_befunc.php	(Revision 5730)
+++ t3lib/class.t3lib_befunc.php	(Arbeitskopie)
@@ -1296,18 +1296,26 @@
 			return $TSdataArray;
 		}
 
-			// Parsing the user TS (or getting from cache)
-		$userTS = implode(chr(10) . '[GLOBAL]' . chr(10), $TSdataArray);
-		$hash = md5('pageTS:'.$userTS);
-		$cachedContent = t3lib_BEfunc::getHash($hash);
-		$TSconfig = array();
-		if (isset($cachedContent)) {
-			$TSconfig = unserialize($cachedContent);
+			// Parsing the page TS-Config (or getting from cache)
+		$pageTS = implode(chr(10) . '[GLOBAL]' . chr(10), $TSdataArray);
+		if ($GLOBALS['TYPO3_CONF_VARS']['BE']['TSconfigConditions']) {
+			$parseObj = t3lib_div::makeInstance('t3lib_TSparser_TSconfig');
+			$res = $parseObj->parseTSconfig($pageTS, $id, $rootLine, 'PAGES');
+			if ($res) {
+				$TSconfig = $res['TSconfig'];
+			}
 		} else {
-			$parseObj = t3lib_div::makeInstance('t3lib_TSparser');
-			$parseObj->parse($userTS);
-			$TSconfig = $parseObj->setup;
-			t3lib_BEfunc::storeHash($hash, serialize($TSconfig), 'PAGES_TSconfig');
+			$hash = md5('pageTS:' . $pageTS);
+			$cachedContent = t3lib_BEfunc::getHash($hash);
+			$TSconfig = array();
+			if (isset($cachedContent)) {
+				$TSconfig = unserialize($cachedContent);
+			} else {
+				$parseObj = t3lib_div::makeInstance('t3lib_TSparser');
+				$parseObj->parse($pageTS);
+				$TSconfig = $parseObj->setup;
+				t3lib_BEfunc::storeHash($hash, serialize($TSconfig), 'PAGES_TSconfig');
+			}
 		}
 
 			// get User TSconfig overlay
Index: t3lib/class.t3lib_matchcondition_frontend.php
===================================================================
--- t3lib/class.t3lib_matchcondition_frontend.php	(Revision 0)
+++ t3lib/class.t3lib_matchcondition_frontend.php	(Revision 0)
@@ -0,0 +1,436 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Oliver Hader <oliver@typo3.org>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project 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.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script 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.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+/**
+ * Contains class for Matching TypoScript conditions
+ *
+ * $Id: class.t3lib_matchcondition.php 5574 2009-06-08 15:20:28Z ohader $
+ * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
+ *
+ * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
+ */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+/**
+ * Matching TypoScript conditions for frontend disposal.
+ *
+ * Used with the TypoScript parser.
+ * Matches browserinfo, IPnumbers for use with templates
+ *
+ * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @package TYPO3
+ * @subpackage t3lib
+ * @see t3lib_TStemplate::matching(), t3lib_TStemplate::generateConfig()
+ */
+class t3lib_matchCondition_frontend extends t3lib_matchCondition {
+	/**
+	 * Constructor for this class
+	 *
+	 * @return	void
+	 */
+	function __construct()	{
+		global $TYPO3_CONF_VARS;
+
+		// Usage (ext_localconf.php):
+		// $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass'][] =
+		// 'EXT:my_ext/class.browserinfo.php:MyBrowserInfoClass';
+		// @todo: User class name specific hook, old hook is still valid for two release cycles, but is deprecated -- olly/20090721
+		if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass'])) {
+			foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass'] as $classRef) {
+				$this->hookObjectsArr[] = &t3lib_div::getUserObj($classRef, '');
+			}
+		}
+	}
+
+	/**
+	 * Evaluates a TypoScript condition given as input, eg. "[browser=net][...(other conditions)...]"
+	 *
+	 * @param	string		The condition to match against its criterias.
+	 * @return	boolean		Returns true or false based on the evaluation.
+	 * @see t3lib_tsparser::parse()
+	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=292&cHash=c6c7d43d2f
+	 */
+	protected function evaluateCondition($string) {
+		if (!is_array($this->altRootLine)) {
+			$this->altRootLine = array();
+		}
+		list($key, $value) = explode('=', $string, 2);
+		$key = trim($key);
+		$value = trim($value);
+		if (t3lib_div::inList('browser,version,system,useragent', strtolower($key))) {
+			$browserInfo = $this->browserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
+		}
+		switch ($key) {
+			case 'browser':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					if (strpos($browserInfo['browser'] . $browserInfo['version'], $test) !== false) {
+						return true;
+					}
+				}
+			break;
+			case 'version':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					if (strcspn($test, '=<>') == 0) {
+						switch (substr($test, 0, 1)) {
+							case '=':
+								if (doubleval(substr($test, 1)) == $browserInfo['version']) {
+									return true;
+								}
+							break;
+							case '<':
+								if (doubleval(substr($test, 1)) > $browserInfo['version']) {
+									return true;
+								}
+							break;
+							case '>':
+								if (doubleval(substr($test, 1)) < $browserInfo['version']) {
+									return true;
+								}
+							break;
+						}
+					} else {
+						if (strpos(' ' . $browserInfo['version'], $test) == 1) {
+							return true;
+						}
+					}
+				}
+			break;
+			case 'system':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					if (strpos(' ' . $browserInfo['system'], $test) == 1) {
+						return true;
+					}
+				}
+			break;
+			case 'device':
+				if (!isset($this->deviceInfo)) {
+					$this->deviceInfo = $this->whichDevice(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
+				}
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					if ($this->deviceInfo == $test) {
+						return true;
+					}
+				}
+			break;
+			case 'useragent':
+				$test = trim($value);
+				if (strlen($test)) {
+					return $this->matchWild($browserInfo['useragent'], $test);
+				}
+			break;
+			case 'language':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					if (preg_match('/^\*.+\*$/', $test)) {
+						$allLanguages = preg_split('/[,;]/', t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
+						if (in_array(substr($test, 1, -1), $allLanguages)) {
+							return true;
+						}
+					} else if (t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE') == $test) {
+						return true;
+					}
+				}
+			break;
+			case 'IP':
+				if (t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $value)) {
+					return true;
+				}
+			break;
+			case 'hostname':
+				if (t3lib_div::cmpFQDN(t3lib_div::getIndpEnv('REMOTE_ADDR'), $value)) {
+					return true;
+				}
+			break;
+				// hour, minute, dayofweek, dayofmonth, month, year, julianday
+			case 'hour':
+			case 'minute':
+			case 'month':
+			case 'year':
+			case 'dayofweek':
+			case 'dayofmonth':
+			case 'dayofyear':
+				$theEvalTime = $GLOBALS['SIM_EXEC_TIME'];	// In order to simulate time properly in templates.
+				switch($key) {
+					case 'hour':		$theTestValue = date('H', $theEvalTime);	break;
+					case 'minute':		$theTestValue = date('i', $theEvalTime);	break;
+					case 'month':		$theTestValue = date('m', $theEvalTime);	break;
+					case 'year':		$theTestValue = date('Y', $theEvalTime);	break;
+					case 'dayofweek':	$theTestValue = date('w', $theEvalTime);	break;
+					case 'dayofmonth':	$theTestValue = date('d', $theEvalTime);	break;
+					case 'dayofyear':	$theTestValue = date('z', $theEvalTime);	break;
+				}
+				$theTestValue = intval($theTestValue);
+					// comp
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					if (t3lib_div::testInt($test)) {
+						$test = '=' . $test;
+					}
+					if ($this->testNumber($test, $theTestValue)) {
+						return true;
+					}
+				}
+			break;
+			case 'usergroup':
+				if ($GLOBALS['TSFE']->gr_list != '0,-1') {		// '0,-1' is the default usergroups when not logged in!
+					$values = t3lib_div::trimExplode(',', $value, true);
+					foreach ($values as $test) {
+						if ($test == '*' || t3lib_div::inList($GLOBALS['TSFE']->gr_list, $test)) {
+							return true;
+						}
+					}
+				}
+			break;
+			case 'loginUser':
+				if ($GLOBALS['TSFE']->loginUser) {
+					$values = t3lib_div::trimExplode(',', $value, true);
+					foreach ($values as $test) {
+						if ($test == '*' || !strcmp($GLOBALS['TSFE']->fe_user->user['uid'], $test)) {
+							return true;
+						}
+					}
+				}
+			break;
+			case 'globalVar':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					$point = strcspn($test, '!=<>');
+					$theVarName = substr($test, 0, $point);
+					$nv = $this->getArgument(trim($theVarName));
+					$testValue = substr($test, $point);
+
+					if ($this->testNumber($testValue, $nv)) {
+						return true;
+					}
+				}
+			break;
+			case 'globalString':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					$point = strcspn($test, '=');
+					$theVarName = substr($test, 0, $point);
+					$nv = $this->getArgument(trim($theVarName));
+					$testValue = substr($test, $point+1);
+
+					if ($this->matchWild($nv, trim($testValue))) {
+						return true;
+					}
+				}
+			break;
+			case 'treeLevel':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				$theRootLine = is_array($GLOBALS['TSFE']->tmpl->rootLine) ? $GLOBALS['TSFE']->tmpl->rootLine : $this->altRootLine;
+				$treeLevel = count($theRootLine)-1;
+				foreach ($values as $test) {
+					if ($test == $treeLevel) {
+						return true;
+					}
+				}
+			break;
+			case 'PIDupinRootline':
+			case 'PIDinRootline':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				if (($key=='PIDinRootline') || (!in_array($GLOBALS['TSFE']->id, $values))) {
+					$theRootLine = is_array($GLOBALS['TSFE']->tmpl->rootLine) ? $GLOBALS['TSFE']->tmpl->rootLine : $this->altRootLine;
+					foreach ($values as $test) {
+						foreach ($theRootLine as $rl_dat) {
+							if ($rl_dat['uid'] == $test) {
+								return true;
+							}
+						}
+					}
+				}
+			break;
+			case 'compatVersion':
+				return t3lib_div::compat_version($value);
+			break;
+			case 'userFunc':
+				$values = preg_split('/\(|\)/', $value);
+				$funcName = trim($values[0]);
+				$funcValue = t3lib_div::trimExplode(',', $values[1]);
+				$pre = $GLOBALS['TSFE']->TYPO3_CONF_VARS['FE']['userFuncClassPrefix'];
+				if ($pre &&
+					!t3lib_div::isFirstPartOfStr(trim($funcName),$pre) &&
+					!t3lib_div::isFirstPartOfStr(trim($funcName),'tx_')
+				)	{
+					if (is_object($GLOBALS['TT']))	$GLOBALS['TT']->setTSlogMessage('Match condition: Function "'.$funcName.'" was not prepended with "'.$pre.'"',3);
+					return false;
+				}
+				if (function_exists($funcName) && call_user_func($funcName, $funcValue[0]))	{
+					return true;
+				}
+			break;
+		}
+
+		return false;
+	}
+
+	/**
+	 * Returns GP / ENV / TSFE vars
+	 *
+	 * @param	string		Identifier
+	 * @return	mixed		The value of the variable pointed to.
+	 * @access private
+	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=311&cHash=487cbd5cdf
+	 */
+	protected function getArgument($var) {
+		$vars = explode(':',$var,2);
+		if (count($vars)==1)	{
+			$val = $this->getGlobal($var);
+		} else {
+			$splitAgain=explode('|',$vars[1],2);
+			$k=trim($splitAgain[0]);
+			if ($k)	{
+				switch((string)trim($vars[0]))	{
+					case 'GP':
+						$val = t3lib_div::_GP($k);
+					break;
+					case 'TSFE':
+						$val = $this->getGlobal('TSFE|'.$vars[1]);
+						$splitAgain=0;	// getGlobal resolves all parts of the key, so no further splitting is needed
+					break;
+					case 'ENV':
+						$val = getenv($k);
+					break;
+					case 'IENV':
+						$val = t3lib_div::getIndpEnv($k);
+					break;
+					case 'LIT':
+						{ return trim($vars[1]); }	// return litteral value...
+					break;
+				}
+					// If array:
+				if (count($splitAgain)>1)	{
+					if (is_array($val) && trim($splitAgain[1]))	{
+						$val=$this->getGlobal($splitAgain[1],$val);
+					} else {
+						$val='';
+					}
+				}
+			}
+		}
+		return $val;
+	}
+
+	/**
+	 * Get the usergroup list of the current user.
+	 *
+	 * @return	string		The usergroup list of the current user
+	 */
+	protected function getGroupList() {
+		$groupList = $GLOBALS['TSFE']->gr_list;
+		return $groupList;
+	}
+
+	/**
+	 * Get the id of the current page.
+	 *
+	 * @return	integer		The id of the current page
+	 */
+	protected function getPageId() {
+		$pageId = $GLOBALS['TSFE']->id;
+		return $pageId;
+	}
+
+	/**
+	 * Get the rootline for the current page.
+	 *
+	 * @return	array		The rootline for the current page.
+	 */
+	protected function getRootline() {
+		$rootline = $GLOBALS['TSFE']->tmpl->rootLine;
+		return $rootline;
+	}
+
+	/**
+	 * Get prefix for user functions (normally 'user_').
+	 *
+	 * @return	string		The prefix for user functions (normally 'user_').
+	 */
+	protected function getUserFuncClassPrefix() {
+		$userFuncClassPrefix = $GLOBALS['TSFE']->TYPO3_CONF_VARS['FE']['userFuncClassPrefix'];
+		return $userFuncClassPrefix;
+	}
+
+	/**
+	 * Get the id of the current user.
+	 *
+	 * @return	integer		The id of the current user
+	 */
+	protected function getUserId() {
+		$userId = $GLOBALS['TSFE']->fe_user->user['uid'];
+		return $userId;
+	}
+
+	/**
+	 * Determines if a user is logged in.
+	 *
+	 * @return	boolean		Determines if a user is logged in
+	 */
+	protected function isUserLoggedIn() {
+		$userLoggedIn = false;
+		if ($GLOBALS['TSFE']->loginUser) {
+			$userLoggedIn = true;
+		}
+		return $userLoggedIn;
+	}
+
+	/**
+	 * Set/write a log message.
+	 *
+	 * @param	string		$message: The log message to set/write
+	 * @return	void
+	 */
+	protected function log($message) {
+		if (is_object($GLOBALS['TT'])) {
+			$GLOBALS['TT']->setTSlogMessage($message,3);
+		}
+	}
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_matchcondition_frontend.php'])	{
+	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_matchcondition_frontend.php']);
+}
+
+?>
\ No newline at end of file
Index: t3lib/class.t3lib_matchcondition.php
===================================================================
--- t3lib/class.t3lib_matchcondition.php	(Revision 5730)
+++ t3lib/class.t3lib_matchcondition.php	(Arbeitskopie)
@@ -77,7 +77,7 @@
  * @subpackage t3lib
  * @see t3lib_TStemplate::matching(), t3lib_TStemplate::generateConfig()
  */
-class t3lib_matchCondition {
+abstract class t3lib_matchCondition {
 	var $matchAlternative=array();		// If this array has elements, the matching returns true if a whole "matchline" is found in the array!
 	var $matchAll=0;					// If set all is matched!
 
@@ -85,33 +85,6 @@
 	var $hookObjectsArr = array();
 
 	/**
-	 * Constructor for this class
-	 *
-	 * @return	void
-	 */
-	function __construct()	{
-		global $TYPO3_CONF_VARS;
-
-		// Usage (ext_localconf.php):
-		// $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass'][] =
-		// 'EXT:my_ext/class.browserinfo.php:MyBrowserInfoClass';
-		if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass'])) {
-			foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass'] as $classRef) {
-				$this->hookObjectsArr[] = &t3lib_div::getUserObj($classRef, '');
-			}
-		}
-	}
-
-	/**
-	 * Constructor for this class
-	 *
-	 * @return	void
-	 */
-	function t3lib_matchCondition() {
-		$this->__construct();
-	}
-
-	/**
 	 * Matching TS condition
 	 *
 	 * @param	string		Line to match
@@ -160,226 +133,10 @@
 	 * @param	string		The condition to match against its criterias.
 	 * @return	boolean		Returns true or false based on the evaluation.
 	 * @see t3lib_tsparser::parse()
-	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=292&cHash=c6c7d43d2f
+	 * @deprecated	since TYPO3 4.3 - use evaluateCondition() instead
 	 */
 	function evalConditionStr($string)	{
-		if (!is_array($this->altRootLine)) {
-			$this->altRootLine = array();
-		}
-		list($key, $value) = explode('=', $string, 2);
-		$key = trim($key);
-		$value = trim($value);
-		if (t3lib_div::inList('browser,version,system,useragent', strtolower($key))) {
-			$browserInfo = $this->browserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
-		}
-		switch ($key) {
-			case 'browser':
-				$values = t3lib_div::trimExplode(',', $value, true);
-				foreach ($values as $test) {
-					if (strpos($browserInfo['browser'] . $browserInfo['version'], $test) !== false) {
-						return true;
-					}
-				}
-			break;
-			case 'version':
-				$values = t3lib_div::trimExplode(',', $value, true);
-				foreach ($values as $test) {
-					if (strcspn($test, '=<>') == 0) {
-						switch (substr($test, 0, 1)) {
-							case '=':
-								if (doubleval(substr($test, 1)) == $browserInfo['version']) {
-									return true;
-								}
-							break;
-							case '<':
-								if (doubleval(substr($test, 1)) > $browserInfo['version']) {
-									return true;
-								}
-							break;
-							case '>':
-								if (doubleval(substr($test, 1)) < $browserInfo['version']) {
-									return true;
-								}
-							break;
-						}
-					} else {
-						if (strpos(' ' . $browserInfo['version'], $test) == 1) {
-							return true;
-						}
-					}
-				}
-			break;
-			case 'system':
-				$values = t3lib_div::trimExplode(',', $value, true);
-				foreach ($values as $test) {
-					if (strpos(' ' . $browserInfo['system'], $test) == 1) {
-						return true;
-					}
-				}
-			break;
-			case 'device':
-				if (!isset($this->deviceInfo)) {
-					$this->deviceInfo = $this->whichDevice(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
-				}
-				$values = t3lib_div::trimExplode(',', $value, true);
-				foreach ($values as $test) {
-					if ($this->deviceInfo == $test) {
-						return true;
-					}
-				}
-			break;
-			case 'useragent':
-				$test = trim($value);
-				if (strlen($test)) {
-					return $this->matchWild($browserInfo['useragent'], $test);
-				}
-			break;
-			case 'language':
-				$values = t3lib_div::trimExplode(',', $value, true);
-				foreach ($values as $test) {
-					if (preg_match('/^\*.+\*$/', $test)) {
-						$allLanguages = preg_split('/[,;]/', t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
-						if (in_array(substr($test, 1, -1), $allLanguages)) {
-							return true;
-						}
-					} else if (t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE') == $test) {
-						return true;
-					}
-				}
-			break;
-			case 'IP':
-				if (t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $value)) {
-					return true;
-				}
-			break;
-			case 'hostname':
-				if (t3lib_div::cmpFQDN(t3lib_div::getIndpEnv('REMOTE_ADDR'), $value)) {
-					return true;
-				}
-			break;
-				// hour, minute, dayofweek, dayofmonth, month, year, julianday
-			case 'hour':
-			case 'minute':
-			case 'month':
-			case 'year':
-			case 'dayofweek':
-			case 'dayofmonth':
-			case 'dayofyear':
-				$theEvalTime = $GLOBALS['SIM_EXEC_TIME'];	// In order to simulate time properly in templates.
-				switch($key) {
-					case 'hour':		$theTestValue = date('H', $theEvalTime);	break;
-					case 'minute':		$theTestValue = date('i', $theEvalTime);	break;
-					case 'month':		$theTestValue = date('m', $theEvalTime);	break;
-					case 'year':		$theTestValue = date('Y', $theEvalTime);	break;
-					case 'dayofweek':	$theTestValue = date('w', $theEvalTime);	break;
-					case 'dayofmonth':	$theTestValue = date('d', $theEvalTime);	break;
-					case 'dayofyear':	$theTestValue = date('z', $theEvalTime);	break;
-				}
-				$theTestValue = intval($theTestValue);
-					// comp
-				$values = t3lib_div::trimExplode(',', $value, true);
-				foreach ($values as $test) {
-					if (t3lib_div::testInt($test)) {
-						$test = '=' . $test;
-					}
-					if ($this->testNumber($test, $theTestValue)) {
-						return true;
-					}
-				}
-			break;
-			case 'usergroup':
-				if ($GLOBALS['TSFE']->gr_list != '0,-1') {		// '0,-1' is the default usergroups when not logged in!
-					$values = t3lib_div::trimExplode(',', $value, true);
-					foreach ($values as $test) {
-						if ($test == '*' || t3lib_div::inList($GLOBALS['TSFE']->gr_list, $test)) {
-							return true;
-						}
-					}
-				}
-			break;
-			case 'loginUser':
-				if ($GLOBALS['TSFE']->loginUser) {
-					$values = t3lib_div::trimExplode(',', $value, true);
-					foreach ($values as $test) {
-						if ($test == '*' || !strcmp($GLOBALS['TSFE']->fe_user->user['uid'], $test)) {
-							return true;
-						}
-					}
-				}
-			break;
-			case 'globalVar':
-				$values = t3lib_div::trimExplode(',', $value, true);
-				foreach ($values as $test) {
-					$point = strcspn($test, '!=<>');
-					$theVarName = substr($test, 0, $point);
-					$nv = $this->getGP_ENV_TSFE(trim($theVarName));
-					$testValue = substr($test, $point);
-
-					if ($this->testNumber($testValue, $nv)) {
-						return true;
-					}
-				}
-			break;
-			case 'globalString':
-				$values = t3lib_div::trimExplode(',', $value, true);
-				foreach ($values as $test) {
-					$point = strcspn($test, '=');
-					$theVarName = substr($test, 0, $point);
-					$nv = $this->getGP_ENV_TSFE(trim($theVarName));
-					$testValue = substr($test, $point+1);
-
-					if ($this->matchWild($nv, trim($testValue))) {
-						return true;
-					}
-				}
-			break;
-			case 'treeLevel':
-				$values = t3lib_div::trimExplode(',', $value, true);
-				$theRootLine = is_array($GLOBALS['TSFE']->tmpl->rootLine) ? $GLOBALS['TSFE']->tmpl->rootLine : $this->altRootLine;
-				$treeLevel = count($theRootLine)-1;
-				foreach ($values as $test) {
-					if ($test == $treeLevel) {
-						return true;
-					}
-				}
-			break;
-			case 'PIDupinRootline':
-			case 'PIDinRootline':
-				$values = t3lib_div::trimExplode(',', $value, true);
-				if (($key=='PIDinRootline') || (!in_array($GLOBALS['TSFE']->id, $values))) {
-					$theRootLine = is_array($GLOBALS['TSFE']->tmpl->rootLine) ? $GLOBALS['TSFE']->tmpl->rootLine : $this->altRootLine;
-					foreach ($values as $test) {
-						foreach ($theRootLine as $rl_dat) {
-							if ($rl_dat['uid'] == $test) {
-								return true;
-							}
-						}
-					}
-				}
-			break;
-			case 'compatVersion':
-				return t3lib_div::compat_version($value);
-			break;
-			case 'userFunc':
-				$values = preg_split('/\(|\)/', $value);
-				$funcName = trim($values[0]);
-				$funcValue = t3lib_div::trimExplode(',', $values[1]);
-				$pre = $GLOBALS['TSFE']->TYPO3_CONF_VARS['FE']['userFuncClassPrefix'];
-				if ($pre &&
-					!t3lib_div::isFirstPartOfStr(trim($funcName),$pre) &&
-					!t3lib_div::isFirstPartOfStr(trim($funcName),'tx_')
-				)	{
-					if (is_object($GLOBALS['TT']))	$GLOBALS['TT']->setTSlogMessage('Match condition: Function "'.$funcName.'" was not prepended with "'.$pre.'"',3);
-					return false;
-				}
-				if (function_exists($funcName) && call_user_func($funcName, $funcValue[0]))	{
-					return true;
-				}
-			break;
-		}
-
-
-		return false;
+		$this->evaluateCondition($sting);
 	}
 
 	/**
@@ -682,46 +439,65 @@
 	 * @param	string		Identifier
 	 * @return	mixed		The value of the variable pointed to.
 	 * @access private
-	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=311&cHash=487cbd5cdf
+	 * @deprecated	since TYPO3 4.3 - use getArgument() instead
 	 */
 	function getGP_ENV_TSFE($var) {
-		$vars = explode(':',$var,2);
-		if (count($vars)==1)	{
-			$val = $this->getGlobal($var);
-		} else {
-			$splitAgain=explode('|',$vars[1],2);
-			$k=trim($splitAgain[0]);
-			if ($k)	{
-				switch((string)trim($vars[0]))	{
-					case 'GP':
-						$val = t3lib_div::_GP($k);
-					break;
-					case 'TSFE':
-						$val = $this->getGlobal('TSFE|'.$vars[1]);
-						$splitAgain=0;	// getGlobal resolves all parts of the key, so no further splitting is needed
-					break;
-					case 'ENV':
-						$val = getenv($k);
-					break;
-					case 'IENV':
-						$val = t3lib_div::getIndpEnv($k);
-					break;
-					case 'LIT':
-						{ return trim($vars[1]); }	// return litteral value...
-					break;
-				}
-					// If array:
-				if (count($splitAgain)>1)	{
-					if (is_array($val) && trim($splitAgain[1]))	{
-						$val=$this->getGlobal($splitAgain[1],$val);
-					} else {
-						$val='';
-					}
-				}
-			}
-		}
-		return $val;
+		$this->getArgument($var);
 	}
+
+	abstract protected function evaluateCondition($string);
+
+	abstract protected function getArgument($var);
+
+	/**
+	 * Gets the usergroup list of the current user.
+	 *
+	 * @return	string		The usergroup list of the current user
+	 */
+	abstract protected function getGroupList();
+
+	/**
+	 * Gets the id of the current page.
+	 *
+	 * @return	integer		The id of the current page
+	 */
+	abstract protected function getPageId();
+
+	/**
+	 * Gets the rootline for the current page.
+	 *
+	 * @return	array		The rootline for the current page.
+	 */
+	abstract protected function getRootline();
+
+	/**
+	 * Gets prefix for user functions (normally 'user_').
+	 *
+	 * @return	string		The prefix for user functions (normally 'user_').
+	 */
+	abstract protected function getUserFuncClassPrefix();
+
+	/**
+	 * Hybrid FE/BE: Get the id of the current user.
+	 *
+	 * @return	integer		The id of the current user
+	 */
+	abstract protected function getUserId();
+
+	/**
+	 * Determines if a user is logged in.
+	 *
+	 * @return	boolean		Determines if a user is logged in
+	 */
+	abstract protected function isUserLoggedIn();
+
+	/**
+	 * Sets a log message.
+	 *
+	 * @param	string		$message: The log message to set/write
+	 * @return	void
+	 */
+	abstract protected function log($message);
 }
 
 
Index: t3lib/class.t3lib_matchcondition_backend.php
===================================================================
--- t3lib/class.t3lib_matchcondition_backend.php	(Revision 0)
+++ t3lib/class.t3lib_matchcondition_backend.php	(Revision 0)
@@ -0,0 +1,529 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Oliver Hader <oliver@typo3.org>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project 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.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script 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.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+/**
+ * Contains class for Matching TypoScript conditions
+ *
+ * $Id: class.t3lib_matchcondition.php 5574 2009-06-08 15:20:28Z ohader $
+ * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
+ *
+ * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
+ */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+/**
+ * Matching TypoScript conditions for backend disposal.
+ *
+ * Used with the TypoScript parser.
+ * Matches browserinfo, IPnumbers for use with templates
+ *
+ * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @package TYPO3
+ * @subpackage t3lib
+ * @see t3lib_TStemplate::matching(), t3lib_TStemplate::generateConfig()
+ */
+class t3lib_matchCondition_backend extends t3lib_matchCondition {
+	protected $backendPage;
+	protected $backendRootline;
+
+	/**
+	 * Constructor for this class
+	 *
+	 * @param	t3lib_TSparser_TSconfig	$parent
+	 * @return	void
+	 */
+	function __construct(t3lib_TSparser_TSconfig $parent) {
+		global $TYPO3_CONF_VARS;
+
+		$this->backendPage = $parent->id;
+		$this->backendRootline = $parent->rootLine;
+
+		// Usage (ext_localconf.php):
+		// $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_matchcondition_backend.php']['matchConditionClass'][] =
+		// 'EXT:my_ext/class.browserinfo.php:MyBrowserInfoClass';
+		if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_matchcondition_backend.php']['matchConditionClass'])) {
+			foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_matchcondition_backend.php']['matchConditionClass'] as $classRef) {
+				$this->hookObjectsArr[] = &t3lib_div::getUserObj($classRef, '');
+			}
+		}
+	}
+
+	/**
+	 * Evaluates a TypoScript condition given as input, eg. "[browser=net][...(other conditions)...]"
+	 *
+	 * @param	string		The condition to match against its criterias.
+	 * @return	boolean		Returns true or false based on the evaluation.
+	 * @see t3lib_tsparser::parse()
+	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=292&cHash=c6c7d43d2f
+	 */
+	protected function evaluateCondition($string) {
+		if (!is_array($this->altRootLine)) {
+			$this->altRootLine = array();
+		}
+		list($key, $value) = explode('=', $string, 2);
+		$key = trim($key);
+		$value = trim($value);
+		if (t3lib_div::inList('browser,version,system,useragent', strtolower($key))) {
+			$browserInfo = $this->browserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
+		}
+		switch ($key) {
+			case 'browser':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					if (strpos($browserInfo['browser'] . $browserInfo['version'], $test) !== false) {
+						return true;
+					}
+				}
+			break;
+			case 'version':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					if (strcspn($test, '=<>') == 0) {
+						switch (substr($test, 0, 1)) {
+							case '=':
+								if (doubleval(substr($test, 1)) == $browserInfo['version']) {
+									return true;
+								}
+							break;
+							case '<':
+								if (doubleval(substr($test, 1)) > $browserInfo['version']) {
+									return true;
+								}
+							break;
+							case '>':
+								if (doubleval(substr($test, 1)) < $browserInfo['version']) {
+									return true;
+								}
+							break;
+						}
+					} else {
+						if (strpos(' ' . $browserInfo['version'], $test) == 1) {
+							return true;
+						}
+					}
+				}
+			break;
+			case 'system':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					if (strpos(' ' . $browserInfo['system'], $test) == 1) {
+						return true;
+					}
+				}
+			break;
+			case 'device':
+				if (!isset($this->deviceInfo)) {
+					$this->deviceInfo = $this->whichDevice(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
+				}
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					if ($this->deviceInfo == $test) {
+						return true;
+					}
+				}
+			break;
+			case 'useragent':
+				$test = trim($value);
+				if (strlen($test)) {
+					return $this->matchWild($browserInfo['useragent'], $test);
+				}
+			break;
+			case 'language':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					if (preg_match('/^\*.+\*$/', $test)) {
+						$allLanguages = preg_split('/[,;]/', t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
+						if (in_array(substr($test, 1, -1), $allLanguages)) {
+							return true;
+						}
+					} else if (t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE') == $test) {
+						return true;
+					}
+				}
+			break;
+			case 'IP':
+				if (t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $value)) {
+					return true;
+				}
+			break;
+			case 'hostname':
+				if (t3lib_div::cmpFQDN(t3lib_div::getIndpEnv('REMOTE_ADDR'), $value)) {
+					return true;
+				}
+			break;
+				// hour, minute, dayofweek, dayofmonth, month, year, julianday
+			case 'hour':
+			case 'minute':
+			case 'month':
+			case 'year':
+			case 'dayofweek':
+			case 'dayofmonth':
+			case 'dayofyear':
+				$theEvalTime = $GLOBALS['SIM_EXEC_TIME'];	// In order to simulate time properly in templates.
+				switch($key) {
+					case 'hour':		$theTestValue = date('H', $theEvalTime);	break;
+					case 'minute':		$theTestValue = date('i', $theEvalTime);	break;
+					case 'month':		$theTestValue = date('m', $theEvalTime);	break;
+					case 'year':		$theTestValue = date('Y', $theEvalTime);	break;
+					case 'dayofweek':	$theTestValue = date('w', $theEvalTime);	break;
+					case 'dayofmonth':	$theTestValue = date('d', $theEvalTime);	break;
+					case 'dayofyear':	$theTestValue = date('z', $theEvalTime);	break;
+				}
+				$theTestValue = intval($theTestValue);
+					// comp
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					if (t3lib_div::testInt($test)) {
+						$test = '=' . $test;
+					}
+					if ($this->testNumber($test, $theTestValue)) {
+						return true;
+					}
+				}
+			break;
+			case 'usergroup':
+				if ($GLOBALS['TSFE']->gr_list != '0,-1') {		// '0,-1' is the default usergroups when not logged in!
+					$values = t3lib_div::trimExplode(',', $value, true);
+					foreach ($values as $test) {
+						if ($test == '*' || t3lib_div::inList($GLOBALS['TSFE']->gr_list, $test)) {
+							return true;
+						}
+					}
+				}
+			break;
+			case 'loginUser':
+				if ($GLOBALS['TSFE']->loginUser) {
+					$values = t3lib_div::trimExplode(',', $value, true);
+					foreach ($values as $test) {
+						if ($test == '*' || !strcmp($GLOBALS['TSFE']->fe_user->user['uid'], $test)) {
+							return true;
+						}
+					}
+				}
+			break;
+			case 'globalVar':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					$point = strcspn($test, '!=<>');
+					$theVarName = substr($test, 0, $point);
+					$nv = $this->getArgument(trim($theVarName));
+					$testValue = substr($test, $point);
+
+					if ($this->testNumber($testValue, $nv)) {
+						return true;
+					}
+				}
+			break;
+			case 'globalString':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				foreach ($values as $test) {
+					$point = strcspn($test, '=');
+					$theVarName = substr($test, 0, $point);
+					$nv = $this->getArgument(trim($theVarName));
+					$testValue = substr($test, $point+1);
+
+					if ($this->matchWild($nv, trim($testValue))) {
+						return true;
+					}
+				}
+			break;
+			case 'treeLevel':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				$theRootLine = is_array($GLOBALS['TSFE']->tmpl->rootLine) ? $GLOBALS['TSFE']->tmpl->rootLine : $this->altRootLine;
+				$treeLevel = count($theRootLine)-1;
+				foreach ($values as $test) {
+					if ($test == $treeLevel) {
+						return true;
+					}
+				}
+			break;
+			case 'PIDupinRootline':
+			case 'PIDinRootline':
+				$values = t3lib_div::trimExplode(',', $value, true);
+				if (($key=='PIDinRootline') || (!in_array($GLOBALS['TSFE']->id, $values))) {
+					$theRootLine = is_array($GLOBALS['TSFE']->tmpl->rootLine) ? $GLOBALS['TSFE']->tmpl->rootLine : $this->altRootLine;
+					foreach ($values as $test) {
+						foreach ($theRootLine as $rl_dat) {
+							if ($rl_dat['uid'] == $test) {
+								return true;
+							}
+						}
+					}
+				}
+			break;
+			case 'compatVersion':
+				return t3lib_div::compat_version($value);
+			break;
+			case 'userFunc':
+				$values = preg_split('/\(|\)/', $value);
+				$funcName = trim($values[0]);
+				$funcValue = t3lib_div::trimExplode(',', $values[1]);
+				$pre = $GLOBALS['TSFE']->TYPO3_CONF_VARS['FE']['userFuncClassPrefix'];
+				if ($pre &&
+					!t3lib_div::isFirstPartOfStr(trim($funcName),$pre) &&
+					!t3lib_div::isFirstPartOfStr(trim($funcName),'tx_')
+				)	{
+					if (is_object($GLOBALS['TT']))	$GLOBALS['TT']->setTSlogMessage('Match condition: Function "'.$funcName.'" was not prepended with "'.$pre.'"',3);
+					return false;
+				}
+				if (function_exists($funcName) && call_user_func($funcName, $funcValue[0]))	{
+					return true;
+				}
+			break;
+		}
+
+		return false;
+	}
+
+	/**
+	 * Returns GP / ENV vars
+	 *
+	 * @param	string		Identifier
+	 * @return	mixed		The value of the variable pointed to.
+	 * @access private
+	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=311&cHash=487cbd5cdf
+	 */
+	protected function getArgument($var) {
+		$vars = explode(':',$var,2);
+		if (count($vars)==1)	{
+			$val = $this->getGlobal($var);
+		} else {
+			$splitAgain=explode('|',$vars[1],2);
+			$k=trim($splitAgain[0]);
+			if ($k)	{
+				switch((string)trim($vars[0]))	{
+					case 'GP':
+						$val = t3lib_div::_GP($k);
+					break;
+					case 'ENV':
+						$val = getenv($k);
+					break;
+					case 'IENV':
+						$val = t3lib_div::getIndpEnv($k);
+					break;
+					case 'LIT':
+						{ return trim($vars[1]); }	// return litteral value...
+					break;
+				}
+					// If array:
+				if (count($splitAgain)>1)	{
+					if (is_array($val) && trim($splitAgain[1]))	{
+						$val=$this->getGlobal($splitAgain[1],$val);
+					} else {
+						$val='';
+					}
+				}
+			}
+		}
+		return $val;
+	}
+
+	/**
+	 * Get the usergroup list of the current user.
+	 *
+	 * @return	string		The usergroup list of the current user
+	 */
+	protected function getGroupList() {
+		$groupList = $GLOBALS['BE_USER']->groupList;
+		return $groupList;
+	}
+
+	/**
+	 * Get the id of the current page.
+	 *
+	 * @return	integer		The id of the current page
+	 */
+	protected function getPageId() {
+		if ($this->backendPage !== false) {
+			$pageId = $this->backendPage;
+		} else {
+			$pageId = $this->backendPage = $this->evalPageId();
+		}
+		return $pageId;
+	}
+
+
+	/**
+	 * Tries to determine the ID of the page currently processed. User/Group TS-Config is also parsed when no specific
+	 * page is handled (i.e. in the Extension Manager, etc.)
+	 *
+	 * @return	integer		evaluated ID or 0 if none
+	 * @access private
+	 */
+	protected function evalPageId() {
+		$ret = 0;
+		if ($id = intval(t3lib_div::_GP('id'))) {
+			$ret = $id;
+		} elseif ($edit = t3lib_div::_GP('edit')) {
+			list($table, $val) = each($edit);
+			list($uid, $action) = each($val);
+			if ($action=='edit') {
+				if ($table=='pages') {
+					$ret = intval($uid);
+				} else {
+					$rec = t3lib_BEfunc::getRecord($table, $uid);
+					$ret = $rec['pid'];
+				}
+			} elseif ($action=='new') {
+				$ret = intval($uid);
+			}
+		} elseif ($cmd = t3lib_div::_GP('cmd')) {
+			list($table, $val) = each($cmd);
+			list($uid, $val2) = each($val);
+			list($action, $param) = each($val2);
+			if ($action=='delete') {
+				if ($table=='pages') {
+					$ret = intval($uid);
+				} else {
+					$rec = t3lib_BEfunc::getRecord($table, $uid);
+					$ret = $rec['pid'];
+				}
+			} elseif (($action=='copy') || ($action=='move')) {
+				$param = intval($param);
+				if ($param>=0) {
+					$ret = $param;
+				} else {
+					$rec = t3lib_BEfunc::getRecord($table, $uid);
+					$ret = $rec['pid'];
+				}
+			}
+		}
+		return $ret;
+	}
+
+	/**
+	 * Determine if record of table 'pages' with the given $pid is currently created in TCEforms.
+	 * This information is required for conditions in BE for PIDupinRootline.
+	 * 
+	 * @param	integer		$pid: The pid the check for as parent page
+	 * @return	boolean		true if the is currently a new page record being edited with $pid as uid of the parent page
+	 */
+	protected function isNewPageWithPid($pid) {
+		if (isset($GLOBALS['SOBE']) && is_object($GLOBALS['SOBE']) && is_a($GLOBALS['SOBE'], 'SC_alt_doc')) {
+			$pid = intval($pid);
+			$elementsData = $GLOBALS['SOBE']->elementsData;
+			$data = $GLOBALS['SOBE']->data;
+				// If editing a new page record:
+			if (is_array($elementsData)) {
+				foreach ($elementsData as $element) {
+					if ($element['cmd'] == 'new' && $element['table'] == 'pages') {
+						if ($element['pid'] < 0) {
+							$pageRecord = t3lib_BEfunc::getRecord('pages', abs($element['pid']), 'pid');
+							$element['pid'] = $pageRecord['pid'];
+						}
+						if ($element['pid'] == $pid) {
+							return true;
+						}
+					}
+				}
+				// If saving a new page record:
+			} elseif (is_array($data) && isset($data['pages']) && is_array($data['pages'])) {
+				foreach ($data['pages'] as $uid => $fields) {
+					if (substr($uid, 0, 3) == 'NEW' && $fields['pid'] == $pid) {
+						return true;
+					}
+				}
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * Get the rootline for the current page.
+	 *
+	 * @return	array		The rootline for the current page.
+	 */
+	protected function getRootline() {
+		$pageId = $this->getPageId();
+		$rootline = t3lib_BEfunc::BEgetRootLine($pageId, '', true);
+		return $rootline;
+	}
+
+	/**
+	 * Get prefix for user functions (normally 'user_').
+	 *
+	 * @return	string		The prefix for user functions (normally 'user_').
+	 */
+	protected function getUserFuncClassPrefix() {
+		$userFuncClassPrefix = 'user_';
+		return $userFuncClassPrefix;
+	}
+
+	/**
+	 * Get the id of the current user.
+	 *
+	 * @return	integer		The id of the current user
+	 */
+	protected function getUserId() {
+		$userId = $GLOBALS['BE_USER']->user['uid'];
+		return $userId;
+	}
+
+	/**
+	 * Determines if a user is logged in.
+	 *
+	 * @return	boolean		Determines if a user is logged in
+	 */
+	protected function isUserLoggedIn() {
+		$userLoggedIn = false;
+		if ($GLOBALS['BE_USER']->user['uid']) {
+			$userLoggedIn = true;
+		}
+		return $userLoggedIn;
+	}
+
+	/**
+	 * Set/write a log message.
+	 *
+	 * @param	string		$message: The log message to set/write
+	 * @return	void
+	 */
+	protected function log($message) {
+		if (is_object($GLOBALS['BE_USER'])) {
+			$GLOBALS['BE_USER']->writelog(3, 0, 1, 0, $message, array());
+		}
+	}
+}
+
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_matchcondition_frontend.php'])	{
+	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_matchcondition_frontend.php']);
+}
+
+?>
\ No newline at end of file
Index: t3lib/core_autoload.php
===================================================================
--- t3lib/core_autoload.php	(Revision 5730)
+++ t3lib/core_autoload.php	(Arbeitskopie)
@@ -37,6 +37,8 @@
 	't3lib_loadmodules' => PATH_t3lib . 'class.t3lib_loadmodules.php',
 	't3lib_lock' => PATH_t3lib . 'class.t3lib_lock.php',
 	't3lib_matchcondition' => PATH_t3lib . 'class.t3lib_matchcondition.php',
+	't3lib_matchcondition_backend' => PATH_t3lib . 'class.t3lib_matchcondition_backend.php',
+	't3lib_matchcondition_frontend' => PATH_t3lib . 'class.t3lib_matchcondition_frontend.php',
 	't3lib_modsettings' => PATH_t3lib . 'class.t3lib_modsettings.php',
 	't3lib_pageselect' => PATH_t3lib . 'class.t3lib_page.php',
 	't3lib_pagetree' => PATH_t3lib . 'class.t3lib_pagetree.php',
@@ -68,6 +70,7 @@
 	't3lib_tsfebeuserauth' => PATH_t3lib . 'class.t3lib_tsfebeuserauth.php',
 	't3lib_tsparser' => PATH_t3lib . 'class.t3lib_tsparser.php',
 	't3lib_tsparser_ext' => PATH_t3lib . 'class.t3lib_tsparser_ext.php',
+	't3lib_tsparser_tsconfig' => PATH_t3lib . 'class.t3lib_tsparser_tsconfig.php',
 	't3lib_tsstyleconfig' => PATH_t3lib . 'class.t3lib_tsstyleconfig.php',
 	't3lib_tstemplate' => PATH_t3lib . 'class.t3lib_tstemplate.php',
 	't3lib_userauth' => PATH_t3lib . 'class.t3lib_userauth.php',
Index: t3lib/class.t3lib_userauthgroup.php
===================================================================
--- t3lib/class.t3lib_userauthgroup.php	(Revision 5730)
+++ t3lib/class.t3lib_userauthgroup.php	(Arbeitskopie)
@@ -1143,19 +1143,30 @@
 				// Check include lines.
 			$this->TSdataArray = t3lib_TSparser::checkIncludeLines_array($this->TSdataArray);
 
-				// Parsing the user TSconfig (or getting from cache)
 			$this->userTS_text = implode(chr(10).'[GLOBAL]'.chr(10),$this->TSdataArray);	// Imploding with "[global]" will make sure that non-ended confinements with braces are ignored.
-			$hash = md5('userTS:'.$this->userTS_text);
-			$cachedContent = t3lib_BEfunc::getHash($hash);
-			if (isset($cachedContent) && !$this->userTS_dontGetCached)	{
-				$this->userTS = unserialize($cachedContent);
+
+			if ($GLOBALS['TYPO3_CONF_VARS']['BE']['TSconfigConditions'] && !$this->userTS_dontGetCached) {
+					// Perform TS-Config parsing with condition matching
+				$parseObj = t3lib_div::makeInstance('t3lib_TSparser_TSconfig');
+				$res = $parseObj->parseTSconfig($this->userTS_text, false, false, 'userTS');
+				if ($res) {
+					$this->userTS = $res['TSconfig'];
+					$this->userTSUpdated = ($res['cached'] ? 0 : 1);
+				}
 			} else {
-				$parseObj = t3lib_div::makeInstance('t3lib_TSparser');
-				$parseObj->parse($this->userTS_text);
-				$this->userTS = $parseObj->setup;
-				t3lib_BEfunc::storeHash($hash,serialize($this->userTS),'BE_USER_TSconfig');
-					// Update UC:
-				$this->userTSUpdated=1;
+					// Parsing the user TSconfig (or getting from cache)
+				$hash = md5('userTS:' . $this->userTS_text);
+				$cachedContent = t3lib_BEfunc::getHash($hash);
+				if (isset($cachedContent) && !$this->userTS_dontGetCached) {
+					$this->userTS = unserialize($cachedContent);
+				} else {
+					$parseObj = t3lib_div::makeInstance('t3lib_TSparser');
+					$parseObj->parse($this->userTS_text);
+					$this->userTS = $parseObj->setup;
+					t3lib_BEfunc::storeHash($hash, serialize($this->userTS), 'BE_USER_TSconfig');
+						// Update UC:
+					$this->userTSUpdated=1;
+				}
 			}
 
 				// Processing webmounts
Index: t3lib/class.t3lib_tsparser_ext.php
===================================================================
--- t3lib/class.t3lib_tsparser_ext.php	(Revision 5730)
+++ t3lib/class.t3lib_tsparser_ext.php	(Arbeitskopie)
@@ -291,7 +291,7 @@
 		$constants->setup = $this->const;
 		$constants->setup = $this->mergeConstantsFromPageTSconfig($constants->setup);
 
-		$matchObj = t3lib_div::makeInstance('t3lib_matchCondition');
+		$matchObj = t3lib_div::makeInstance('t3lib_matchCondition_frontend');
 		$matchObj->matchAll=1;		// Matches ALL conditions in TypoScript
 
 		$c=0;
Index: typo3/template.php
===================================================================
--- typo3/template.php	(Revision 5730)
+++ typo3/template.php	(Arbeitskopie)
@@ -674,7 +674,8 @@
 		}
 
 			// Get the browser info
-		$matchObject = t3lib_div::makeInstance('t3lib_matchCondition');
+		// @todo: Move browserInfo away from matchCondition - this is a misuse of functionality -- olly/20090721
+		$matchObject = t3lib_div::makeInstance('t3lib_matchCondition_frontend');
 		$browserInfo = $matchObject->browserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
 
 			// Set the XML prologue
