Tiny bug with date function in t3lib_befunc. Casted timestamp to integer.
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_matchcondition.php
index ec1d6a9..cd55830 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -97,7 +97,7 @@ class t3lib_matchCondition {
                // '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, '');
+                               $this->hookObjectsArr[] = t3lib_div::getUserObj($classRef, '');
                        }
                }
        }
@@ -188,23 +188,23 @@ class t3lib_matchCondition {
                                                switch (substr($test, 0, 1)) {
                                                        case '=':
                                                                if (doubleval(substr($test, 1)) == $browserInfo['version']) {
-                                                                   return true;
+                                                                       return true;
                                                                }
                                                        break;
                                                        case '<':
                                                                if (doubleval(substr($test, 1)) > $browserInfo['version']) {
-                                                                   return true;
+                                                                       return true;
                                                                }
                                                        break;
                                                        case '>':
                                                                if (doubleval(substr($test, 1)) < $browserInfo['version']) {
-                                                                   return true;
+                                                                       return true;
                                                                }
                                                        break;
                                                }
                                        } else {
                                                if (strpos(' ' . $browserInfo['version'], $test) == 1) {
-                                                   return true;
+                                                       return true;
                                                }
                                        }
                                }
@@ -213,7 +213,7 @@ class t3lib_matchCondition {
                                $values = t3lib_div::trimExplode(',', $value, true);
                                foreach ($values as $test) {
                                        if (strpos(' ' . $browserInfo['system'], $test) == 1) {
-                                           return true;
+                                               return true;
                                        }
                                }
                        break;
@@ -224,7 +224,7 @@ class t3lib_matchCondition {
                                $values = t3lib_div::trimExplode(',', $value, true);
                                foreach ($values as $test) {
                                        if ($this->deviceInfo == $test) {
-                                           return true;
+                                               return true;
                                        }
                                }
                        break;
@@ -240,21 +240,21 @@ class t3lib_matchCondition {
                                        if (preg_match('/^\*.+\*$/', $test)) {
                                                $allLanguages = preg_split('/[,;]/', t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
                                                if (in_array(substr($test, 1, -1), $allLanguages)) {
-                                                   return true;
+                                                       return true;
                                                }
                                        } else if (t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE') == $test) {
-                                           return true;
+                                               return true;
                                        }
                                }
                        break;
                        case 'IP':
                                if (t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $value)) {
-                                   return true;
+                                       return true;
                                }
                        break;
                        case 'hostname':
                                if (t3lib_div::cmpFQDN(t3lib_div::getIndpEnv('REMOTE_ADDR'), $value)) {
-                                   return true;
+                                       return true;
                                }
                        break;
                                // hour, minute, dayofweek, dayofmonth, month, year, julianday
@@ -280,29 +280,29 @@ class t3lib_matchCondition {
                                $values = t3lib_div::trimExplode(',', $value, true);
                                foreach ($values as $test) {
                                        if (t3lib_div::testInt($test)) {
-                                           $test = '=' . $test;
+                                               $test = '=' . $test;
                                        }
                                        if ($this->testNumber($test, $theTestValue)) {
-                                           return true;
+                                               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) {
+                                       $values = t3lib_div::trimExplode(',', $value, true);
+                                       foreach ($values as $test) {
                                                if ($test == '*' || t3lib_div::inList($GLOBALS['TSFE']->gr_list, $test)) {
-                                                   return true;
+                                                       return true;
                                                }
                                        }
                                }
                        break;
                        case 'loginUser':
                                if ($GLOBALS['TSFE']->loginUser) {
-                                   $values = t3lib_div::trimExplode(',', $value, true);
-                                   foreach ($values as $test) {
+                                       $values = t3lib_div::trimExplode(',', $value, true);
+                                       foreach ($values as $test) {
                                                if ($test == '*' || !strcmp($GLOBALS['TSFE']->fe_user->user['uid'], $test)) {
-                                                   return true;
+                                                       return true;
                                                }
                                        }
                                }
@@ -316,7 +316,7 @@ class t3lib_matchCondition {
                                        $testValue = substr($test, $point);
 
                                        if ($this->testNumber($testValue, $nv)) {
-                                           return true;
+                                               return true;
                                        }
                                }
                        break;
@@ -329,7 +329,7 @@ class t3lib_matchCondition {
                                        $testValue = substr($test, $point+1);
 
                                        if ($this->matchWild($nv, trim($testValue))) {
-                                           return true;
+                                               return true;
                                        }
                                }
                        break;
@@ -339,7 +339,7 @@ class t3lib_matchCondition {
                                $treeLevel = count($theRootLine)-1;
                                foreach ($values as $test) {
                                        if ($test == $treeLevel) {
-                                           return true;
+                                               return true;
                                        }
                                }
                        break;
@@ -348,10 +348,10 @@ class t3lib_matchCondition {
                                $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) {
+                                       foreach ($values as $test) {
+                                               foreach ($theRootLine as $rl_dat) {
                                                        if ($rl_dat['uid'] == $test) {
-                                                           return true;
+                                                               return true;
                                                        }
                                                }
                                        }
@@ -361,7 +361,7 @@ class t3lib_matchCondition {
                                return t3lib_div::compat_version($value);
                        break;
                        case 'userFunc':
-                               $values = preg_split('/[\(\)]/', $value);
+                               $values = preg_split('/\(|\)/', $value);
                                $funcName = trim($values[0]);
                                $funcValue = t3lib_div::trimExplode(',', $values[1]);
                                $pre = $GLOBALS['TSFE']->TYPO3_CONF_VARS['FE']['userFuncClassPrefix'];
@@ -468,7 +468,7 @@ class t3lib_matchCondition {
                // deprecated, see above
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['devices_class']))       {
                        foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['devices_class'] as $_classRef)       {
-                               $_procObj = &t3lib_div::getUserObj($_classRef);
+                               $_procObj = t3lib_div::getUserObj($_classRef);
                                return $_procObj->whichDevice_ext($useragent);
                        }
                }
@@ -534,99 +534,7 @@ class t3lib_matchCondition {
                        }
                }
 
-               $useragent = trim($useragent);
-               $browserInfo=Array();
-               $browserInfo['useragent']=$useragent;
-               if ($useragent) {
-                       // browser
-                       if (strstr($useragent,'MSIE'))  {
-                               $browserInfo['browser']='msie';
-                       } elseif(strstr($useragent,'Konqueror'))        {
-                               $browserInfo['browser']='konqueror';
-                       } elseif(strstr($useragent,'Opera'))    {
-                               $browserInfo['browser']='opera';
-                       } elseif(strstr($useragent,'Lynx'))     {
-                               $browserInfo['browser']='lynx';
-                       } elseif(strstr($useragent,'PHP'))      {
-                               $browserInfo['browser']='php';
-                       } elseif(strstr($useragent,'AvantGo'))  {
-                               $browserInfo['browser']='avantgo';
-                       } elseif(strstr($useragent,'WebCapture'))       {
-                               $browserInfo['browser']='acrobat';
-                       } elseif(strstr($useragent,'IBrowse'))  {
-                               $browserInfo['browser']='ibrowse';
-                       } elseif(strstr($useragent,'Teleport')) {
-                               $browserInfo['browser']='teleport';
-                       } elseif(strstr($useragent,'Mozilla'))  {
-                               $browserInfo['browser']='netscape';
-                       } else {
-                               $browserInfo['browser']='unknown';
-                       }
-                       // version
-                       switch($browserInfo['browser']) {
-                               case 'netscape':
-                                       $browserInfo['version'] = $this->browserInfo_version(substr($useragent,8));
-                                       if (strstr($useragent,'Netscape6')) {$browserInfo['version']=6;}
-                               break;
-                               case 'msie':
-                                       $tmp = strstr($useragent,'MSIE');
-                                       $browserInfo['version'] = $this->browserInfo_version(substr($tmp,4));
-                               break;
-                               case 'opera':
-                                       $tmp = strstr($useragent,'Opera');
-                                       $browserInfo['version'] = $this->browserInfo_version(substr($tmp,5));
-                               break;
-                               case 'lynx':
-                                       $tmp = strstr($useragent,'Lynx/');
-                                       $browserInfo['version'] = $this->browserInfo_version(substr($tmp,5));
-                               break;
-                               case 'php':
-                                       $tmp = strstr($useragent,'PHP/');
-                                       $browserInfo['version'] = $this->browserInfo_version(substr($tmp,4));
-                               break;
-                               case 'avantgo':
-                                       $tmp = strstr($useragent,'AvantGo');
-                                       $browserInfo['version'] = $this->browserInfo_version(substr($tmp,7));
-                               break;
-                               case 'acrobat':
-                                       $tmp = strstr($useragent,'WebCapture');
-                                       $browserInfo['version'] = $this->browserInfo_version(substr($tmp,10));
-                               break;
-                               case 'ibrowse':
-                                       $tmp = strstr($useragent,'IBrowse/');
-                                       $browserInfo['version'] = $this->browserInfo_version(substr($tmp,8));
-                               break;
-                               case 'konqueror':
-                                       $tmp = strstr($useragent,'Konqueror/');
-                                       $browserInfo['version'] = $this->browserInfo_version(substr($tmp,10));
-                               break;
-                       }
-                       // system
-                       $browserInfo['system']='';
-                       if (strstr($useragent,'Win'))   {
-                               // windows
-                               if (strstr($useragent,'Win98') || strstr($useragent,'Windows 98'))      {
-                                       $browserInfo['system']='win98';
-                               } elseif (strstr($useragent,'Win95') || strstr($useragent,'Windows 95'))        {
-                                       $browserInfo['system']='win95';
-                               } elseif (strstr($useragent,'WinNT') || strstr($useragent,'Windows NT'))        {
-                                       $browserInfo['system']='winNT';
-                               } elseif (strstr($useragent,'Win16') || strstr($useragent,'Windows 311'))       {
-                                       $browserInfo['system']='win311';
-                               }
-                       } elseif (strstr($useragent,'Mac'))     {
-                               $browserInfo['system']='mac';
-                               // unixes
-                       } elseif (strstr($useragent,'Linux'))   {
-                               $browserInfo['system']='linux';
-                       } elseif (strstr($useragent,'SGI') && strstr($useragent,' IRIX '))      {
-                               $browserInfo['system']='unix_sgi';
-                       } elseif (strstr($useragent,' SunOS ')) {
-                               $browserInfo['system']='unix_sun';
-                       } elseif (strstr($useragent,' HP-UX ')) {
-                               $browserInfo['system']='unix_hp';
-                       }
-               }
+               $browserInfo = t3lib_utility_Client::getBrowserInfo($useragent);
 
                return $browserInfo;
        }
@@ -636,9 +544,11 @@ class t3lib_matchCondition {
         *
         * @param       string          A string with version number, eg. "/7.32 blablabla"
         * @return      double          Returns double value, eg. "7.32"
+        * @deprecated  since TYPO3 4.3 - use t3lib_utility_Client::getVersion() instead
         */
        function browserInfo_version($tmp)      {
-               return doubleval(preg_replace('/^[^0-9]*/','',$tmp));
+               t3lib_div::logDeprecatedFunction();
+               return t3lib_utility_Client::getVersion($tmp);
        }
 
        /**