* Fixed SSL problem and many other minor things
authorKasper Skårhøj <kasper@typo3.org>
Thu, 1 Apr 2004 07:35:31 +0000 (07:35 +0000)
committerKasper Skårhøj <kasper@typo3.org>
Thu, 1 Apr 2004 07:35:31 +0000 (07:35 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@176 709f56b5-9817-0410-a4d7-c38de5d9e867

12 files changed:
ChangeLog
t3lib/class.t3lib_div.php
t3lib/class.t3lib_install.php
t3lib/class.t3lib_loaddbgroup.php
t3lib/class.t3lib_tsfebeuserauth.php
typo3/init.php
typo3/mod/tools/em/class.kickstarter.php
typo3/mod/tools/em/index.php
typo3/sysext/cms/tslib/class.tslib_content.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/cms/tslib/class.tslib_menu.php
typo3/sysext/cms/tslib/class.tslib_search.php

index bd08992..b404728 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2004-04-01  Kasper Skårhøj,,,  <kasper@typo3.com>
+
+       * Fixed SSL problem and many other minor things
+
 2004-03-31  Kasper Skårhøj,,,  <kasper@typo3.com>
 
        * Fixed spam-protection of email adresses inserted by "mailto:..." in text.
index 486d8d9..21353c4 100755 (executable)
@@ -2529,7 +2529,7 @@ class t3lib_div {
                                return $p[1];
                        break;
                        case 'TYPO3_REQUEST_HOST':
-                               return 'http'.($HTTP_SERVER_VARS['SSL_SESSION_ID']?'s':'').'://'.       // I hope this: ($HTTP_SERVER_VARS['SSL_SESSION_ID']?'s':'') - is sufficient to detect https...
+                               return (t3lib_div::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://').
                                        $HTTP_SERVER_VARS['HTTP_HOST'];
                        break;
                        case 'TYPO3_REQUEST_URL':
@@ -2553,6 +2553,9 @@ class t3lib_div {
                        case 'TYPO3_SITE_SCRIPT':
                                return substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'),strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL')));
                        break;
+                       case 'TYPO3_SSL':
+                               return ($HTTP_SERVER_VARS['SSL_SESSION_ID'] || $HTTP_SERVER_VARS['HTTPS']) ? TRUE : FALSE;
+                       break;
                        case '_ARRAY':
                                $out = array();
                                        // Here, list ALL possible keys to this function for debug display.
@@ -2570,6 +2573,7 @@ class t3lib_div {
                                        TYPO3_REQUEST_DIR,
                                        TYPO3_SITE_URL,
                                        TYPO3_SITE_SCRIPT,
+                                       TYPO3_SSL,
                                        SCRIPT_NAME,
                                        TYPO3_DOCUMENT_ROOT,
                                        SCRIPT_FILENAME,
index aa4dc5e..214d1eb 100755 (executable)
@@ -288,23 +288,25 @@ class t3lib_install {
                        SetCookie($this->cookie_name."_key", $uKey, 0, "/");            // Cookie is set
 
                        $this->JSmessage='SECURITY:
-Make sure to protect the Install Tool with another password than "joh316". 
+Make sure to protect the Install Tool with another password than "joh316".
 Better yet you can add a die() function call to typo3/install/index.php after usage.
 
 IF THE INSTALL TOOL CRASHES...
 The Install Tool is checking PHPs support for image formats. However certain versions of PHP (fx. 4.3.0 with bundled GD) will crash when trying to read the PNG test file. If this happens you will see a blank screen or error message.
-Workaround: Open the file typo3/t3lib/class.t3lib_install.php, go to line 2042, make the function isPNG() return "0" hardcoded. PNG is not checked anymore and the rest of the Install Tool will work as expected. The same has been known with the other image formats as well. You can use a similar method to bypass the testing if that is also a problem.
+Workaround: Open the file typo3/t3lib/class.t3lib_install.php, go to the line where the function "isPNG()" is defined and make it return "0" hardcoded. PNG is not checked anymore and the rest of the Install Tool will work as expected. The same has been known with the other image formats as well. You can use a similar method to bypass the testing if that is also a problem.
 On behalf of PHP we regret this inconvenience.
+
+BTW: This Install Tool will only work if cookies are accepted by your web browser. If this dialog pops up over and over again you didn\'t enable cookies.
 ';
-                       
+
                }
                        // Check if the password from TYPO3_CONF_VARS combined with uKey matches the sKey cookie. If not, ask for password.
                $sKey = $GLOBALS["HTTP_COOKIE_VARS"][$this->cookie_name];
-               
+
                if (md5($GLOBALS["TYPO3_CONF_VARS"]["BE"]["installToolPassword"]."|".$uKey) == $sKey || $this->checkPassword($uKey))    {
                        $this->passwordOK=1;
                }
-               
+
                if ($GLOBALS["CLIENT"]["SYSTEM"]=="unix" && $GLOBALS["CLIENT"]["BROWSER"]=="konqu")     {
                        $this->fontTag2='<font face="verdana,sans-serif" size=4 color=black>';
                        $this->fontTag1='<font face="verdana,sans-serif" size=3 color=black>';
@@ -1377,11 +1379,11 @@ Number of files at a time:
                        // Memory and functions
                        // *****************
                $memory_limit_value = $this->convertByteSize(get_cfg_var("memory_limit"));
-               if ($memory_limit_value<8*1024*1024)    {
-                       $this->message($ext, "Memory Limit below default 8 MB","
+               if ($memory_limit_value<16*1024*1024)   {
+                       $this->message($ext, "Memory Limit below 16 MB","
                                <i>memory_limit=".get_cfg_var("memory_limit")."</i>
-                               May impose problems if too low.
-                       ",1);
+                               Your system is configured to enforce a memory limit of PHP scripts lower than 16 MB. The Extension Manager needs to include more PHP-classes than will fit into this memory space. There is nothing else to do than raise the limit. To be safe, ask the system administrator of the webserver to raise the limit to over 25 MB.
+                       ",3);
                } else $this->message($ext, "Memory Limit","<i>memory_limit=".get_cfg_var("memory_limit")."</i>",-1);
                if (ini_get("max_execution_time")<30)   {
                        $this->message($ext, "Max Execution Time below default 30 seconds","
@@ -1601,8 +1603,8 @@ Number of files at a time:
                                        $this->message($ext, $relpath." directory does not exist","
                                        <em>Full path: ".PATH_site.$relpath."</em>
                                        ".$general_message."
-                                       
-                                       This error should not occur as ".$relpath." must always be accessible in the root of a TYPO3 website. 
+
+                                       This error should not occur as ".$relpath." must always be accessible in the root of a TYPO3 website.
                                        ",3);
                                } else {
                                        $this->message($ext, $relpath." directory does not exist","
@@ -1623,7 +1625,7 @@ Number of files at a time:
                                        $this->message($ext, $relpath." directory not writeable","
                                        <em>Full path: ".$file."</em>
                                        ".$general_message."
-                                       
+
                                        Tried to write this file (with touch()) but didn't succeed.
                                        The directory ".$relpath." must be writable!
                                        ",3);
@@ -1652,7 +1654,7 @@ Number of files at a time:
                reset($paths);
                while(list($k,$v)=each($paths)) {
                        reset($programs);
-                       if (!ereg('\/$',$v)) $v.='/';
+                       if (!ereg('[\\\/]$',$v)) $v.='/';
                        while(list(,$filename)=each($programs)) {
 #                              if (@file_exists($v) && @is_file($v.$filename.$isExt))    {       // file_exists was necessary on windows, because is_file issued a warning if the path was not correct.
                                if($this->_checkImageMagick_getVersion($v.$filename.$isExt) > 0 ) {
@@ -1660,7 +1662,7 @@ Number of files at a time:
                                }
                        }
                        if (count($index[$v])>=3)       {$this->config_array["im"]=1;}
-                       
+
                        if ($index[$v]["composite"] && !$index[$v]["combine"])  {
                                $this->config_array["im_combine_filename"]="composite";
                        } elseif (!$index[$v]["composite"] && $index[$v]["combine"]) {
@@ -4834,7 +4836,7 @@ A:hover {color: #000066}
        <head>
                <title>TYPO3 Install Tool</title>
                '.($this->JSmessage?'
-<script language="javascript" type="text/javascript">alert(unescape(\''.rawurlencode($this->JSmessage).'\'));</script>         
+<script language="javascript" type="text/javascript">alert(unescape(\''.rawurlencode($this->JSmessage).'\'));</script>
                
                ':'').'
        </head>
index 5dbe944..2c00bd5 100755 (executable)
@@ -38,8 +38,8 @@
  *
  *
  *   72: class t3lib_loadDBGroup       
- *   99:     function start ($itemlist,$tablelist, $MMtable='',$MMuid=0)       
- *  140:     function readList($itemlist)      
+ *   99:     function start ($itemlist,$tablelist, $MMtable='',$MMuid=0)
+ *  140:     function readList($itemlist)
  *  186:     function readMM($tableName,$uid)  
  *  215:     function writeMM($tableName,$uid,$prependTableName=0)     
  *  251:     function getValueArray($prependTableName='')      
@@ -96,7 +96,7 @@ class t3lib_loadDBGroup       {
         * @param       integer         Local UID for MM lookup
         * @return      void
         */
-       function start ($itemlist,$tablelist, $MMtable='',$MMuid=0)     {
+       function start($itemlist,$tablelist, $MMtable='',$MMuid=0)      {
                        // If the table list is "*" then all tables are used in the list:
                if (!strcmp(trim($tablelist),'*'))      {
                        $tablelist = implode(',',array_keys($GLOBALS['TCA']));
@@ -139,8 +139,8 @@ class t3lib_loadDBGroup     {
         */
        function readList($itemlist)    {
                if ((string)trim($itemlist)!='')        {
-                       $tempItemArray = explode(',',$itemlist);
-                       while(list($key,$val)=each($tempItemArray))     {
+                       $tempItemArray = t3lib_div::trimExplode(',', $itemlist);        // Changed to trimExplode 31/3 04; HMENU special type "list" didn't work if there were spaces in the list... I suppose this is better overall...
+                       foreach($tempItemArray as $key => $val) {
                                $isSet = 0;     // Will be set to "1" if the entry was a real table/id:
 
                                        // Extract table name and id. This is un the formular [tablename]_[id] where table name MIGHT contain "_", hence the reversion of the string!                                   
@@ -159,7 +159,7 @@ class t3lib_loadDBGroup     {
                                                        // Register ID/table name in internal arrays:
                                                $this->itemArray[$key]['id'] = $theID;
                                                $this->itemArray[$key]['table'] = $theTable;
-                                               $this->tableArray[$theTable][]=$theID;
+                                               $this->tableArray[$theTable][] = $theID;
                                                        // Set update-flag:
                                                $isSet=1;
                                        }
@@ -355,4 +355,4 @@ class t3lib_loadDBGroup     {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_loaddbgroup.php'])      {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_loaddbgroup.php']);
 }
-?>
\ No newline at end of file
+?>
index 6b33139..c05cf24 100755 (executable)
@@ -612,23 +612,23 @@ class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth {
         *
         ****************************************************/
 
-        /**
- * Implementing the access checks that the typo3/init.php script does before a user is ever logged in.
- * Used in the frontend.
- *
* @return     boolean         Returns true if access is OK
- * @see typo3/init.php, t3lib_beuserauth::backendCheckLogin()
- */
+       /**
       * Implementing the access checks that the typo3/init.php script does before a user is ever logged in.
       * Used in the frontend.
       *
       * @return      boolean         Returns true if access is OK
       * @see typo3/init.php, t3lib_beuserauth::backendCheckLogin()
       */
        function checkBackendAccessSettingsFromInitPhp()        {
                global $TYPO3_CONF_VARS;
-       
+
                // **********************
                // Check Hardcoded lock on BE:
                // **********************
                if ($TYPO3_CONF_VARS['BE']['adminOnly'] < 0)    {
                        return FALSE;
                }
-               
+
                // **********************
                // Check IP
                // **********************
@@ -637,24 +637,24 @@ class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth {
                                return FALSE;
                        }
                }
-               
-               
+
+
                // **********************
                // Check SSL (https)
                // **********************
                if (intval($TYPO3_CONF_VARS['BE']['lockSSL']))  {
-                       if (!$HTTP_SERVER_VARS['SSL_SESSION_ID'])       {
+                       if (!t3lib_div::getIndpEnv('TYPO3_SSL'))        {
                                return FALSE;
                        }
                }
-               
+
                        // Finally a check from t3lib_beuserauth::backendCheckLogin()
                if (!$TYPO3_CONF_VARS['BE']['adminOnly'] || $this->isAdmin())   {
                        return TRUE;
                } else return FALSE;
         }
-        
-        
+
+
        /**
         * Evaluates if the Backend User has read access to the input page record.
         * The evaluation is based on both read-permission and whether the page is found in one of the users webmounts. Only if both conditions are true will the function return true.
@@ -1037,4 +1037,4 @@ class t3lib_tsfeBeUserAuth extends t3lib_beUserAuth {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsfebeuserauth.php'])   {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsfebeuserauth.php']);
 }
-?>
\ No newline at end of file
+?>
index d55f4d2..14e4bdd 100755 (executable)
@@ -180,7 +180,7 @@ if (trim($TYPO3_CONF_VARS['BE']['IPmaskList']))     {
 // Check SSL (https)
 // **********************
 if (intval($TYPO3_CONF_VARS['BE']['lockSSL'])) {
-       if (!$HTTP_SERVER_VARS['SSL_SESSION_ID'])       {
+       if (!t3lib_div::getIndpEnv('TYPO3_SSL'))        {
                if ($TYPO3_CONF_VARS['BE']['lockSSL']==2)       {
                        list(,$url) = explode('://',t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir,2);
                        header('Location: https://'.$url);      // Just point us away from here...
index 3f9a223..b440bdd 100755 (executable)
@@ -111,4 +111,4 @@ class em_kickstarter extends tx_extrepwizard {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/tools/em/class.kickstarter.php'])       {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/mod/tools/em/class.kickstarter.php']);
 }
-?>
\ No newline at end of file
+?>
index 2350ffd..ecb93fa 100755 (executable)
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
+
+
 unset($MCONF);
 require ('conf.php');
 require ($BACK_PATH.'init.php');
index 0c866af..01a47fd 100755 (executable)
@@ -69,7 +69,7 @@
  * 1247:     function CTABLE ($conf)   
  * 1285:     function OTABLE ($conf)   
  * 1300:     function COLUMNS ($conf)  
- * 1379:     function HRULER ($conf)   
+ * 1379:     function HRULER ($conf)
  * 1403:     function CASEFUNC ($conf)
  * 1428:     function LOAD_REGISTER($conf,$name)       
  * 1468:     function FORM($conf,$formData='')    
@@ -1379,9 +1379,10 @@ class tslib_cObj {
                $lineColor = $conf['lineColor'] ? $conf['lineColor'] : 'black';
                $spaceBefore = intval($conf['spaceLeft']);
                $spaceAfter = intval($conf['spaceRight']);
+               $tableWidth = $conf['tableWidth'] ? $conf['tableWidth'] : '99%';
                $content='';
-               
-               $content.='<table border="0" cellspacing="0" cellpadding="0" width="99%"><tr>';
+
+               $content.='<table border="0" cellspacing="0" cellpadding="0" width="'.htmlspecialchars($tableWidth).'"><tr>';
                if ($spaceBefore)       {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceBefore.'" height="1" alt="" title="" /></td>'; }
                $content.='<td bgcolor="'.$lineColor.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$lineThickness.'" alt="" title="" /></td>';
                if ($spaceAfter)        {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceAfter.'" height="1" alt="" title="" /></td>'; }
@@ -1893,12 +1894,18 @@ class tslib_cObj {
                                // generate page-tree
                        $search->pageIdList.=$this->getTreeList($theStartId,$depth);
                        
-                       $endClause = 'pages.uid IN ('.$search->pageIdList.$theStartId.') AND pages.doktype in ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].($conf['addExtUrlsAndShortCuts']?',3,4':'').') AND pages.no_search=0';
-                       $endClause.=$this->enableFields($search->fTable).$this->enableFields('pages');
+                       $endClause = 'pages.uid IN ('.$search->pageIdList.$theStartId.')
+                               AND pages.doktype in ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].($conf['addExtUrlsAndShortCuts']?',3,4':'').')
+                               AND pages.no_search=0'.
+                               $this->enableFields($search->fTable).
+                               $this->enableFields('pages');
+
+                       if ($conf['languageField.'][$search->fTable])   {
+                               $endClause.= ' AND '.$search->fTable.'.'.       $conf['languageField.'][$search->fTable].' = '.intval($GLOBALS['TSFE']->sys_language_uid);
+                       }
 
                                // build query
                        $search->build_search_query($endClause);
-#debug($search->queryParts);
 
                                // count...
                        if (t3lib_div::testInt(t3lib_div::_GP('scount')))       {
@@ -5917,7 +5924,7 @@ class tslib_cObj {
                if ($conf['languageField'])     {
                        $query.=' AND '.$conf['languageField'].'='.intval($GLOBALS['TSFE']->sys_language_uid);
                }
-               
+
                $andWhere = trim($this->stdWrap($conf['andWhere'],$conf['andWhere.']));
                if ($andWhere)  {
                        $query.=' AND '.$andWhere;
index f6d66fe..96a1dc7 100755 (executable)
@@ -63,7 +63,7 @@
  *  957:     function findDomainRecord($recursive=0)   
  *  978:     function pageNotFoundHandler($code,$header='')    
  * 1000:     function checkAndSetAlias()       
- * 1015:     function idPartsAnalyze($str)     
+ * 1015:     function idPartsAnalyze($str)
  * 1040:     function mergingWithGetVars($GET_VARS)    
  *
  *              SECTION: Template and caching related functions.
         * @see index_ts.php
         */
        function tslib_fe($TYPO3_CONF_VARS, $id, $type, $no_cache='', $cHash='', $jumpurl='',$MP='',$RDCT='')   {
+
                        // Setting some variables:
+               $this->TYPO3_CONF_VARS = $TYPO3_CONF_VARS;
                $this->id = $id;
                $this->type = $type;
                $this->no_cache = $no_cache ? 1 : 0;
                $this->cHash = $cHash;
                $this->jumpurl = $jumpurl;
-               $this->MP = $TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? $MP : '';
+               $this->MP = $this->TYPO3_CONF_VARS['FE']['enable_mount_pids'] ? $MP : '';
                $this->RDCT = $RDCT;
-               $this->TYPO3_CONF_VARS = $TYPO3_CONF_VARS;
                $this->clientInfo = t3lib_div::clientInfo();
                $this->uniqueString=md5(microtime());
                
                $this->csConvObj = t3lib_div::makeInstance('t3lib_cs');
                
                        // Call post processing function for constructor:
-               if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc']))  {
+               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc']))    {
                        $_params = array('pObj' => &$this);
-                       foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'] as $_funcRef)   {
+                       foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'] as $_funcRef)     {
                                t3lib_div::callUserFunction($_funcRef,$_params,$this);
                        }
                }               
         * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&cHash=4ad9d7acb4
         */
        function checkAlternativeIdMethods()    {
-               global $TYPO3_CONF_VARS;
-               
-#              IF (TYPO3_OS=='WIN')    return;         # Commenting out this line will make it work for windows Apache mod_rewrite as well.
+
                $this->siteScript = t3lib_div::getIndpEnv('TYPO3_SITE_SCRIPT');
 
                        // Resolving of "simulateStaticDocuments" URLs:
                }
 
                        // Call post processing function for custom URL methods.
-               if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'])) {
+               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc']))   {
                        $_params = array('pObj' => &$this);
-                       foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'] as $_funcRef)  {
+                       foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'] as $_funcRef)    {
                                t3lib_div::callUserFunction($_funcRef,$_params,$this);
                        }
                }
        function clear_preview()        {
                $this->showHiddenPage = 0;
                $this->showHiddenRecords = 0;
-               $GLOBALS['SIM_EXEC_TIME'] = $GLOBALS['EXEC_TIME'];      
+               $GLOBALS['SIM_EXEC_TIME'] = $GLOBALS['EXEC_TIME'];
                $this->fePreview = 0;
        }
 
         * @return      void
         */
        function determineId()  {
-               global $TYPO3_CONF_VARS;
-               
+
                        // Getting ARG-v values if some
                $this->setIDfromArgV(); 
                        
 
                
                        // Call post processing function for id determination:
-               if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc']))       {
+               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'])) {
                        $_params = array('pObj' => &$this);
-                       foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'] as $_funcRef)        {
+                       foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'] as $_funcRef)  {
                                t3lib_div::callUserFunction($_funcRef,$_params,$this);
                        }
-               }                       
+               }
        }
 
        /**
                }
 
                        // ADD group-numbers if the IPmask matches.
-               if (is_array($GLOBALS['TYPO3_CONF_VARS']['FE']['IPmaskMountGroups']))   {
-                       reset($GLOBALS['TYPO3_CONF_VARS']['FE']['IPmaskMountGroups']);
-                       while(list(,$IPel)=each($GLOBALS['TYPO3_CONF_VARS']['FE']['IPmaskMountGroups']))        {
+               if (is_array($this->TYPO3_CONF_VARS['FE']['IPmaskMountGroups']))        {
+                       foreach($this->TYPO3_CONF_VARS['FE']['IPmaskMountGroups'] as $IPel)     {
                                if (t3lib_div::getIndpEnv('REMOTE_ADDR') && $IPel[0] && t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'),$IPel[0]))        {$gr_array[]=intval($IPel[1]);}
                        }
                }
 
                        // We find the first page belonging to the current domain
                $GLOBALS['TT']->push('fetch_the_id domain/','');
-               $this->domainStartPage = $this->findDomainRecord($GLOBALS['TYPO3_CONF_VARS']['SYS']['recursiveDomainSearch']);  // the page_id of the current domain 
+               $this->domainStartPage = $this->findDomainRecord($this->TYPO3_CONF_VARS['SYS']['recursiveDomainSearch']);       // the page_id of the current domain
                if (!$this->id) {
                        if ($this->domainStartPage)     {
                                $this->id = $this->domainStartPage;     // If the id was not previously set, set it to the id of the domain.
         * @see checkDataSubmission()
         */
        function sendFormmail() {
-               global $TYPO3_CONF_VARS;
-
                $formmail = t3lib_div::makeInstance('t3lib_formmail');
 
                $EMAIL_VARS = t3lib_div::_POST();
                unset($EMAIL_VARS['formtype_mail']);
 
                        // Hook for preprocessing of the content for formmails:
-               if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sendFormmail-PreProcClass']))  {
-                       foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sendFormmail-PreProcClass'] as $_classRef)  {
+               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sendFormmail-PreProcClass']))    {
+                       foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['sendFormmail-PreProcClass'] as $_classRef)    {
                                $_procObj = &t3lib_div::getUserObj($_classRef);
                                $EMAIL_VARS = $_procObj->sendFormmail_preProcessVariables($EMAIL_VARS,$this);
                        }
         */
        function generatePage_postProcessing()  {
                        // This is to ensure, that the page is NOT cached if the no_cache parameter was set before the page was generated. This is a safety precaution, as it could have been unset by some script.
-               if ($this->no_cacheBeforePageGen) $this->set_no_cache();        
-       
+               if ($this->no_cacheBeforePageGen) $this->set_no_cache();
+
                        // Tidy up the code, if flag...
                if ($this->TYPO3_CONF_VARS['FE']['tidy_option'] == 'all')               {
                        $GLOBALS['TT']->push('Tidy, all','');
                        $GLOBALS['TT']->pull();
                }
 
+                       // Hook for post-processing of page content cached/non-cached:
+               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all']))  {
+                       $_params = array('pObj' => &$this);
+                       foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'] as $_funcRef)   {
+                               t3lib_div::callUserFunction($_funcRef,$_params,$this);
+                       }
+               }
+
                        // Storing page
                if (!$this->no_cache)   {
                                        // Tidy up the code, if flag...
                                $GLOBALS['TT']->pull();
                        }
 
+                               // Hook for post-processing of page content before being cached:
+                       if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached']))       {
+                               $_params = array('pObj' => &$this);
+                               foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached'] as $_funcRef)        {
+                                       t3lib_div::callUserFunction($_funcRef,$_params,$this);
+                               }
+                       }
+
                        $this->realPageCacheContent();
                } elseif ($this->tempContent)   {               // If there happens to be temporary content in the cache and the cache was not cleared due to new content put in it... ($this->no_cache=0)
                        $this->clearPageCacheContent();
@@ -2167,6 +2178,14 @@ if (version == "n3") {
                        $GLOBALS['TT']->pull();
                }
 
+                       // Hook for post-processing of page content before output:
+               if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output']))       {
+                       $_params = array('pObj' => &$this);
+                       foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'] as $_funcRef)        {
+                               t3lib_div::callUserFunction($_funcRef,$_params,$this);
+                       }
+               }
+
 /*             if ($this->beUserLogin && t3lib_div::_GP('ADMCMD_view'))        {               // This is a try to change target=_top to target=_self if pages are shown in the Web>View module...
                        $this->content = str_replace('target="_top"','target="_self"',$this->content);
                        $this->content = str_replace('target=_top','target="_self"',$this->content);
@@ -2274,7 +2293,7 @@ if (version == "n3") {
                                                        $LogLine.= ' "'.t3lib_div::getIndpEnv('HTTP_REFERER').'" "'.t3lib_div::getIndpEnv('HTTP_USER_AGENT').'"';
                                                }
 
-                                               switch($GLOBALS['TYPO3_CONF_VARS']['FE']['logfile_write'])      {
+                                               switch($this->TYPO3_CONF_VARS['FE']['logfile_write'])   {
                                                        case 'fputs':
                                                                $GLOBALS['TT']->push('Write to log file (fputs)');
                                                                        $logfilehandle = fopen(PATH_site.$this->config['stat_vars']['logFile'], 'a');
@@ -2486,13 +2505,13 @@ if (version == "n3") {
         * @see tslib_cObj::PHP_SCRIPT(), tslib_feTCE::includeScripts(), tslib_menu::includeMakeMenu()
         */
        function checkFileInclude($incFile)     {
-               return !$GLOBALS['TYPO3_CONF_VARS']['FE']['noPHPscriptInclude']
+               return !$this->TYPO3_CONF_VARS['FE']['noPHPscriptInclude']
                        || substr($incFile,0,14)=='media/scripts/'
                        || substr($incFile,0,4+strlen(TYPO3_mainDir))==TYPO3_mainDir.'ext/'
                        || substr($incFile,0,7+strlen(TYPO3_mainDir))==TYPO3_mainDir.'sysext/'
                        || substr($incFile,0,14)=='typo3conf/ext/';
        }
-       
+
        /**
         * Creates an instance of tslib_cObj in $this->cObj
         * This instance is used to start the rendering of the TypoScript template structure
@@ -2640,7 +2659,7 @@ if (version == "n3") {
                if (!is_array($this->pagesTSconfig))    {
                        reset($this->rootLine);
                        $TSdataArray = array();
-                       $TSdataArray[]=$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];        // Setting default configuration:
+                       $TSdataArray[] = $this->TYPO3_CONF_VARS['BE']['defaultPageTSconfig'];   // Setting default configuration:
                        while(list($k,$v)=each($this->rootLine))        {
                                $TSdataArray[]=$v['TSconfig'];
                        }
index ebaaf97..15ef05d 100755 (executable)
@@ -259,17 +259,17 @@ class tslib_menu {
                                        break;
                                        case 'directory':
                                                if ($value=='') {
-                                                       $value=$GLOBALS['TSFE']->page['uid'];
+                                                       $value = $GLOBALS['TSFE']->page['uid'];
                                                }
-                                               $items=t3lib_div::intExplode(',',$value);
-                                               reset($items);
-                                               while(list(,$id)=each($items))  {
+                                               $items = t3lib_div::intExplode(',',$value);
+
+                                               foreach($items as $id)  {
                                                        $idPage = $GLOBALS['TSFE']->sys_page->getRawRecord('pages',$id);
                                                        if (is_array($idPage) && $GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'] && $idPage['mount_pid']>0)      {
                                                                $MP=$idPage['mount_pid'].'-'.$idPage['uid'];
                                                                $id=$idPage['mount_pid'];
                                                        } else $MP=0;
-                                                       
+
                                                        $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages',Array('pidInList'=>$id,'orderBy'=>$altSortField));
                                                        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
                                                                $temp[$row['uid']]=$GLOBALS['TSFE']->sys_page->getPageOverlay($row);
@@ -279,28 +279,28 @@ class tslib_menu {
                                        break;
                                        case 'list':
                                                if ($value=='') {
-                                                       $value=$this->id;
+                                                       $value = $this->id;
                                                }
                                                $loadDB = t3lib_div::makeInstance('FE_loadDBGroup');
                                                $loadDB->start($value, 'pages');
-                                               $loadDB->additionalWhere['pages']=tslib_cObj::enableFields('pages');
+                                               $loadDB->additionalWhere['pages'] = tslib_cObj::enableFields('pages');
                                                $loadDB->getFromDB();
-       
+
                                                reset($loadDB->itemArray);
                                                $data = $loadDB->results;
-       
-                                               while(list(,$val)=each($loadDB->itemArray))     {
+
+                                               foreach($loadDB->itemArray as $val)     {
                                                        $row = $data[$val['table']][$val['id']];
                                                        if ($row)       {
-                                                               $temp[]=$GLOBALS['TSFE']->sys_page->getPageOverlay($row);
+                                                               $temp[] = $GLOBALS['TSFE']->sys_page->getPageOverlay($row);
                                                        }
                                                }
                                        break;
                                        case 'updated':
                                                if ($value=='') {
-                                                       $value=$GLOBALS['TSFE']->page['uid'];
+                                                       $value = $GLOBALS['TSFE']->page['uid'];
                                                }
-                                               $items=t3lib_div::intExplode(',',$value);
+                                               $items = t3lib_div::intExplode(',',$value);
                                                if (t3lib_div::testInt($this->conf['special.']['depth']))       {
                                                        $depth = t3lib_div::intInRange($this->conf['special.']['depth'],1,20);          // Tree depth
                                                } else {
index f5aee55..bb5b8ff 100755 (executable)
@@ -24,7 +24,7 @@
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
-/** 
+/**
  * Searching in database tables, typ. "pages" and "tt_content"
  * Used to generate search queries for TypoScript.
  * The class is included from "class.tslib_pagegen.php" based on whether there has been detected content in the GPvar "sword"
@@ -219,16 +219,17 @@ class tslib_search {
 
        /**
         * Used to split a search-word line up into elements to search for. This function will detect boolean words like AND and OR, + and -, and even find sentences encapsulated in ""
-        * This function also has the charm of still containing some of the original comments - in danish!
         * This function could be re-written to be more clean and effective - yet it's not that important.
         *
         * @param       string          The raw sword string from outside
         * @param       string          Special chars which are used as operators (+- is default)
+        * @param       string          Special chars which are deleted if the append the searchword (+-., is default)
         * @return      mixed           Returns an ARRAY if there were search words, othervise the return value may be unset.
         */
-       function split($origSword, $specchars='+-')     {
+       function split($origSword, $specchars='+-', $delchars='+-.,')   {
                $sword = $origSword;
                $specs = '['.$this->quotemeta($specchars).']';
+               $delchars = '['.$this->quotemeta($delchars).']';
 
                        // As long as $sword is true (that means $sword MUST be reduced little by little until its empty inside the loop!)
                while ($sword)  {
@@ -241,24 +242,37 @@ class tslib_search {
                        } elseif (ereg('^'.$specs,$sword,$reg)) {
                                $value[] = $reg[0];
                                $sword = trim(ereg_replace('^'.$specs,'',$sword));              // Removes = sign
+                       } elseif (ereg('[\+\-]',$sword)) {      // Check if $sword contains + or -
+                                       // + and - shall only be interpreted as $specchars when there's whitespace before it
+                                       // otherwise it's included in the searchword (e.g. "know-how")
+                               $a_sword = explode(' ',$sword); // explode $sword to single words
+                               $word = array_shift($a_sword);  // get first word
+                               $word = ereg_replace($delchars.'$','',$word);           // Delete $delchars at end of string
+                               $value[] = $word;       // add searchword to values
+                               $sword = implode(' ',$a_sword); // re-build $sword
                        } else {
-                                       // There are no double-quotes around the value. Looking for next (space) ' ' or '>'
+                                       // There are no double-quotes around the value. Looking for next (space) or special char.
                                ereg('^[^ '.$this->quotemeta($specchars).']*',$sword,$reg);
-                               $value[] = trim($reg[0]);
+                               $word = ereg_replace($delchars.'$','',trim($reg[0]));           // Delete $delchars at end of string
+                               $value[] = $word;
                                $sword = trim(ereg_replace('^'.$this->quotemeta($reg[0]),'',$sword));
                        }
                }
+
                return $value;
        }
 
        /**
-        * Local version of quotemeta. This is the same as the PHP function but the vertical line, |, is also escaped with a slash.
+        * Local version of quotemeta. This is the same as the PHP function
+        * but the vertical line, |, and minus, -, is also escaped with a slash.
         *
         * @param       string          String to pass through quotemeta()
         * @return      string          Return value
         */
        function quotemeta($str)        {
-               return str_replace('|','\|',quotemeta($str));
+               $str = str_replace('|','\|',quotemeta($str));
+               #$str = str_replace('-','\-',$str);             // Breaks "-" which should NOT have a slash before it inside of [ ] in a regex.
+               return $str;
        }
 
        /**
@@ -313,11 +327,11 @@ class tslib_search {
                                $whereArray = array();
                                
                                $primary_table_and_key = $primary_table.'.'.$tables[$primary_table]['primary_key'];
-                               $primKeys=Array();
+                               $primKeys = Array();
                                foreach($tables as $key => $val)        {
                                        $fkey = $tables[$key]['fkey'];
                                        if ($fkey)      {
-                                                $primKeys[]=$key.'.'.$fkey.'='.$primary_table_and_key;
+                                                $primKeys[] = $key.'.'.$fkey.'='.$primary_table_and_key;
                                        }
                                }
                                if (count($primKeys))   {
@@ -332,10 +346,10 @@ class tslib_search {
                                        // Add search word where clause:
                                $query_part = $this->build_search_query_for_searchwords();
                                if (!$query_part)       {
-                                       $query_part='(0!=0)';
+                                       $query_part = '(0!=0)';
                                }
                                $whereArray[] = '('.$query_part.')';
-                               
+
                                        // Implode where clauses:
                                $this->queryParts['WHERE'] = implode(' AND ',$whereArray);
                                
@@ -480,4 +494,4 @@ if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_search.php']);
 }
 
-?>
\ No newline at end of file
+?>