/**
     * Return JS configuration of the htmlArea plugins registered by the extension
     *
     * @param	integer		Relative id of the RTE editing area in the form
     *
     * @return string		JS configuration for registered plugins
     *
     * The returned string will be a set of JS instructions defining the configuration that will be provided to the plugin(s)
     * Each of the instructions should be of the form:
     * 	RTEarea['.$RTEcounter.']["buttons"]["button-id"]["property"] = "value";
     */
    public function buildJavascriptConfiguration($RTEcounter)
    {
        $button = 'spellcheck';
        // Set the SpellChecker mode
        $spellCheckerMode = isset($GLOBALS['BE_USER']->userTS['options.']['HTMLAreaPspellMode']) ? trim($GLOBALS['BE_USER']->userTS['options.']['HTMLAreaPspellMode']) : 'normal';
        if (!in_array($spellCheckerMode, $this->spellCheckerModes)) {
            $spellCheckerMode = 'normal';
        }
        // Set the use of personal dictionary
        // $this->thisConfig['enablePersonalDicts'] is DEPRECATED as of 4.3.0
        $enablePersonalDicts = $this->thisConfig['buttons.'][$button . '.']['enablePersonalDictionaries'] || $this->thisConfig['enablePersonalDicts'] ? isset($GLOBALS['BE_USER']->userTS['options.']['enablePersonalDicts']) && $GLOBALS['BE_USER']->userTS['options.']['enablePersonalDicts'] ? true : false : false;
        if (t3lib_utility_PhpOptions::isSafeModeEnabled() || $this->htmlAreaRTE->is_FE()) {
            $enablePersonalDicts = false;
        }
        $registerRTEinJavascriptString = '';
        if (in_array($button, $this->toolbar)) {
            if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][$button . '.'])) {
                $registerRTEinJavascriptString .= '
			RTEarea[' . $RTEcounter . '].buttons.' . $button . ' = new Object();';
            }
            $registerRTEinJavascriptString .= '
			RTEarea[' . $RTEcounter . '].buttons.' . $button . '.contentTypo3Language = "' . $this->htmlAreaRTE->contentTypo3Language . '";
			RTEarea[' . $RTEcounter . '].buttons.' . $button . '.contentISOLanguage = "' . $this->htmlAreaRTE->contentISOLanguage . '";
			RTEarea[' . $RTEcounter . '].buttons.' . $button . '.contentCharset = "' . $this->htmlAreaRTE->contentCharset . '";
			RTEarea[' . $RTEcounter . '].buttons.' . $button . '.spellCheckerMode = "' . $spellCheckerMode . '";
			RTEarea[' . $RTEcounter . '].buttons.' . $button . '.enablePersonalDicts = ' . ($enablePersonalDicts ? 'true' : 'false') . ';';
            $registerRTEinJavascriptString .= '
			RTEarea[' . $RTEcounter . '].buttons.' . $button . '.path = "' . ($this->htmlAreaRTE->is_FE() || $this->htmlAreaRTE->isFrontendEditActive() ? ($GLOBALS['TSFE']->absRefPrefix ? $GLOBALS['TSFE']->absRefPrefix : '') . 'index.php?eID=rtehtmlarea_spellchecker' : $this->htmlAreaRTE->backPath . 'ajax.php?ajaxID=rtehtmlarea::spellchecker') . '";';
        }
        return $registerRTEinJavascriptString;
    }
    /**
     * Proxy for the PHP mail() function. Adds possibility to hook in and send the mails in a different way.
     * The hook can be used by adding function to the configuration array:
     * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery']
     *
     * @param	string		Email address to send to.
     * @param	string		Subject line, non-encoded. (see PHP function mail())
     * @param	string		Message content, non-encoded. (see PHP function mail())
     * @param	string		 Additional headers for the mail (see PHP function mail())
     * @param	string		Additional flags for the sending mail tool (see PHP function mail())
     * @return	boolean		Indicates whether the mail has been sent or not
     * @see		PHP function mail() []
     * @link	http://www.php.net/manual/en/function.mail.php
     */
    public static function mail($to, $subject, $messageBody, $additionalHeaders = NULL, $additionalParameters = NULL)
    {
        $success = TRUE;
        // If the mail does not have a From: header, fall back to the default in TYPO3_CONF_VARS.
        if (!preg_match('/^From:/im', $additionalHeaders) && $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']) {
            if (!is_null($additionalHeaders) && substr($additionalHeaders, -1) != LF) {
                $additionalHeaders .= LF;
            }
            if ($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']) {
                $additionalHeaders .= 'From: "' . $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'] . '" <' . $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'] . '>';
            } else {
                $additionalHeaders .= 'From: ' . $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
            }
        }
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'])) {
            $parameters = array('to' => $to, 'subject' => $subject, 'messageBody' => $messageBody, 'additionalHeaders' => $additionalHeaders, 'additionalParameters' => $additionalParameters);
            $fakeThis = FALSE;
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'] as $hookSubscriber) {
                $hookSubscriberContainsArrow = strpos($hookSubscriber, '->');
                if ($hookSubscriberContainsArrow !== FALSE) {
                    // deprecated, remove in TYPO3 4.7
                    t3lib_div::deprecationLog('The usage of user function notation for the substituteMailDelivery hook is deprecated,
						use the t3lib_mail_MailerAdapter interface instead.');
                    $success = $success && t3lib_div::callUserFunction($hookSubscriber, $parameters, $fakeThis);
                } else {
                    $mailerAdapter = t3lib_div::makeInstance($hookSubscriber);
                    if ($mailerAdapter instanceof t3lib_mail_MailerAdapter) {
                        $success = $success && $mailerAdapter->mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters, $fakeThis);
                    } else {
                        throw new RuntimeException($hookSubscriber . ' is not an implementation of t3lib_mail_MailerAdapter,
							but must implement that interface to be used in the substituteMailDelivery hook.', 1294062286);
                    }
                }
            }
        } else {
            if (t3lib_utility_PhpOptions::isSafeModeEnabled() && !is_null($additionalParameters)) {
                $additionalParameters = null;
            }
            if (is_null($additionalParameters)) {
                $success = @mail($to, $subject, $messageBody, $additionalHeaders);
            } else {
                $success = @mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters);
            }
        }
        if (!$success) {
            t3lib_div::sysLog('Mail to "' . $to . '" could not be sent (Subject: "' . $subject . '").', 'Core', 3);
        }
        return $success;
    }
    /**
     * Main class of Spell Checker plugin for Typo3 CMS
     *
     * @return	string		content produced by the plugin
     */
    function main()
    {
        $this->csConvObj = t3lib_div::makeInstance('t3lib_cs');
        // Setting start time
        $time_start = microtime(true);
        $this->pspell_is_available = in_array('pspell', get_loaded_extensions());
        $this->AspellDirectory = trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['AspellDirectory']) ? trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['AspellDirectory']) : '/usr/bin/aspell';
        $this->forceCommandMode = trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['forceCommandMode']) ? trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['forceCommandMode']) : 0;
        $safe_mode_is_enabled = t3lib_utility_PhpOptions::isSafeModeEnabled();
        if ($safe_mode_is_enabled && !$this->pspell_is_available) {
            echo 'Configuration problem: Spell checking cannot be performed';
        }
        if ($safe_mode_is_enabled && $this->forceCommandMode) {
            echo 'Configuration problem: Spell checking cannot be performed in command mode';
        }
        if (!$safe_mode_is_enabled && (!$this->pspell_is_available || $this->forceCommandMode)) {
            $AspellVersionString = explode('Aspell', shell_exec($this->AspellDirectory . ' -v'));
            $AspellVersion = substr($AspellVersionString[1], 0, 4);
            if (doubleval($AspellVersion) < doubleval('0.5') && (!$this->pspell_is_available || $this->forceCommandMode)) {
                echo 'Configuration problem: Aspell version ' . $AspellVersion . ' too old. Spell checking cannot be performed in command mode';
            }
            $this->defaultAspellEncoding = trim(shell_exec($this->AspellDirectory . ' config encoding'));
        }
        // Setting the list of dictionaries
        if (!$safe_mode_is_enabled && (!$this->pspell_is_available || $this->forceCommandMode)) {
            $dictionaryList = shell_exec($this->AspellDirectory . ' dump dicts');
            $dictionaryList = implode(',', t3lib_div::trimExplode(LF, $dictionaryList, 1));
        }
        if (empty($dictionaryList)) {
            $dictionaryList = t3lib_div::_POST('showDictionaries');
            // Applying EM variable DEPRECATED as of TYPO3 4.3.0
            $dictionaryList = $dictionaryList ? $dictionaryList : trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['dictionaryList']);
        }
        $dictionaryArray = t3lib_div::trimExplode(',', $dictionaryList, 1);
        $restrictToDictionaries = t3lib_div::_POST('restrictToDictionaries');
        if ($restrictToDictionaries) {
            $dictionaryArray = array_intersect($dictionaryArray, t3lib_div::trimExplode(',', $restrictToDictionaries, 1));
        }
        if (!count($dictionaryArray)) {
            $dictionaryArray[] = 'en';
        }
        $this->dictionary = t3lib_div::_POST('dictionary');
        // Applying EM variable DEPRECATED as of TYPO3 4.3.0
        $defaultDictionary = $this->dictionary ? $this->dictionary : trim($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['defaultDictionary']);
        if (!$defaultDictionary || !in_array($defaultDictionary, $dictionaryArray)) {
            $defaultDictionary = 'en';
        }
        uasort($dictionaryArray, 'strcoll');
        $dictionaryList = implode(',', $dictionaryArray);
        // Setting the dictionary
        if (empty($this->dictionary) || !in_array($this->dictionary, $dictionaryArray)) {
            $this->dictionary = 'en';
        }
        // Setting the pspell suggestion mode
        $this->pspellMode = t3lib_div::_POST('pspell_mode') ? t3lib_div::_POST('pspell_mode') : $this->pspellMode;
        // Now sanitize $this->pspellMode
        $this->pspellMode = t3lib_div::inList('ultra,fast,normal,bad-spellers', $this->pspellMode) ? $this->pspellMode : 'normal';
        switch ($this->pspellMode) {
            case 'ultra':
            case 'fast':
                $pspellModeFlag = PSPELL_FAST;
                break;
            case 'bad-spellers':
                $pspellModeFlag = PSPELL_BAD_SPELLERS;
                break;
            case 'normal':
            default:
                $pspellModeFlag = PSPELL_NORMAL;
                break;
        }
        // Setting the charset
        if (t3lib_div::_POST('pspell_charset')) {
            $this->charset = trim(t3lib_div::_POST('pspell_charset'));
        }
        if (strtolower($this->charset) == 'iso-8859-1') {
            $this->parserCharset = strtolower($this->charset);
        }
        // In some configurations, Aspell uses 'iso8859-1' instead of 'iso-8859-1'
        $this->aspellEncoding = $this->parserCharset;
        if ($this->parserCharset == 'iso-8859-1' && strstr($this->defaultAspellEncoding, '8859-1')) {
            $this->aspellEncoding = $this->defaultAspellEncoding;
        }
        // However, we are going to work only in the parser charset
        if ($this->pspell_is_available && !$this->forceCommandMode) {
            $this->pspell_link = pspell_new($this->dictionary, '', '', $this->parserCharset, $pspellModeFlag);
        }
        // Setting the path to user personal dicts, if any
        if (t3lib_div::_POST('enablePersonalDicts') == 'true' && TYPO3_MODE == 'BE' && is_object($GLOBALS['BE_USER'])) {
            $this->userUid = 'BE_' . $GLOBALS['BE_USER']->user['uid'];
            if ($this->userUid) {
                $this->personalDictPath = t3lib_div::getFileAbsFileName($this->uploadFolder . $this->userUid);
                if (!is_dir($this->personalDictPath)) {
                    t3lib_div::mkdir($this->personalDictPath);
                }
                // escape here for later use
                $this->personalDictsArg = ' --home-dir=' . escapeshellarg($this->personalDictPath);
            }
        }
        $cmd = t3lib_div::_POST('cmd');
        if ($cmd == 'learn' && !$safe_mode_is_enabled) {
            // Only availble for BE_USERS, die silently if someone has gotten here by accident
            if (TYPO3_MODE != 'BE' || !is_object($GLOBALS['BE_USER'])) {
                die('');
            }
            // Updating the personal word list
            $to_p_dict = t3lib_div::_POST('to_p_dict');
            $to_p_dict = $to_p_dict ? $to_p_dict : array();
            $to_r_list = t3lib_div::_POST('to_r_list');
            $to_r_list = $to_r_list ? $to_r_list : array();
            header('Content-Type: text/plain; charset=' . strtoupper($this->parserCharset));
            header('Pragma: no-cache');
            if ($to_p_dict || $to_r_list) {
                $tmpFileName = t3lib_div::tempnam($this->filePrefix);
                if ($filehandle = fopen($tmpFileName, 'wb')) {
                    foreach ($to_p_dict as $personal_word) {
                        $cmd = '&' . $personal_word . LF;
                        echo $cmd;
                        fwrite($filehandle, $cmd, strlen($cmd));
                    }
                    foreach ($to_r_list as $replace_pair) {
                        $cmd = '$$ra ' . $replace_pair[0] . ' , ' . $replace_pair[1] . LF;
                        echo $cmd;
                        fwrite($filehandle, $cmd, strlen($cmd));
                    }
                    $cmd = "#\n";
                    echo $cmd;
                    fwrite($filehandle, $cmd, strlen($cmd));
                    fclose($filehandle);
                    // $this->personalDictsArg has already been escapeshellarg()'ed above, it is an optional paramter and might be empty here
                    $AspellCommand = 'cat ' . escapeshellarg($tmpFileName) . ' | ' . $this->AspellDirectory . ' -a --mode=none' . $this->personalDictsArg . ' --lang=' . escapeshellarg($this->dictionary) . ' --encoding=' . escapeshellarg($this->aspellEncoding) . ' 2>&1';
                    print $AspellCommand . LF;
                    print shell_exec($AspellCommand);
                    t3lib_div::unlink_tempfile($tmpFileName);
                    echo 'Personal word list was updated.';
                } else {
                    echo 'SpellChecker tempfile open error.';
                }
            } else {
                echo 'Nothing to add to the personal word list.';
            }
            flush();
            exit;
        } else {
            // Check spelling content
            // Initialize output
            $this->result = '<?xml version="1.0" encoding="' . $this->parserCharset . '"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . substr($this->dictionary, 0, 2) . '" lang="' . substr($this->dictionary, 0, 2) . '">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=' . $this->parserCharset . '" />
<link rel="stylesheet" type="text/css" media="all" href="' . (TYPO3_MODE == 'BE' ? '../' : '') . t3lib_extMgm::siteRelPath($this->extKey) . '/htmlarea/plugins/SpellChecker/spell-check-style.css" />
<script type="text/javascript">
/*<![CDATA[*/
<!--
';
            // Getting the input content
            $content = t3lib_div::_POST('content');
            // Parsing the input HTML
            $parser = xml_parser_create(strtoupper($this->parserCharset));
            xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
            xml_set_object($parser, $this);
            if (!xml_set_element_handler($parser, 'startHandler', 'endHandler')) {
                echo 'Bad xml handler setting';
            }
            if (!xml_set_character_data_handler($parser, 'collectDataHandler')) {
                echo 'Bad xml handler setting';
            }
            if (!xml_set_default_handler($parser, 'defaultHandler')) {
                echo 'Bad xml handler setting';
            }
            if (!xml_parse($parser, '<?xml version="1.0" encoding="' . $this->parserCharset . '"?><spellchecker> ' . preg_replace('/&nbsp;/' . ($this->parserCharset == 'utf-8' ? 'u' : ''), ' ', $content) . ' </spellchecker>')) {
                echo 'Bad parsing';
            }
            if (xml_get_error_code($parser)) {
                die('Line ' . xml_get_current_line_number($parser) . ': ' . xml_error_string(xml_get_error_code($parser)));
            }
            xml_parser_free($parser);
            if ($this->pspell_is_available && !$this->forceCommandMode) {
                pspell_clear_session($this->pspell_link);
            }
            $this->result .= 'var suggestedWords = {' . $this->suggestedWords . '};
var dictionaries = "' . $dictionaryList . '";
var selectedDictionary = "' . $this->dictionary . '";
';
            // Calculating parsing and spell checkting time
            $time = number_format(microtime(true) - $time_start, 2, ',', ' ');
            // Insert spellcheck info
            $this->result .= 'var spellcheckInfo = { "Total words":"' . $this->wordCount . '","Misspelled words":"' . sizeof($this->misspelled) . '","Total suggestions":"' . $this->suggestionCount . '","Total words suggested":"' . $this->suggestedWordCount . '","Spelling checked in":"' . $time . '" };
// -->
/*]]>*/
</script>
</head>
';
            $this->result .= '<body onload="window.parent.RTEarea[\'' . t3lib_div::_POST('editorId') . '\'].editor.getPlugin(\'SpellChecker\').spellCheckComplete();">';
            $this->result .= preg_replace('/' . preg_quote('<?xml') . '.*' . preg_quote('?>') . '[' . preg_quote(LF . CR . chr(32)) . ']*/' . ($this->parserCharset == 'utf-8' ? 'u' : ''), '', $this->text);
            $this->result .= '<div style="display: none;">' . $dictionaries . '</div>';
            // Closing
            $this->result .= '
</body></html>';
            // Outputting
            header('Content-Type: text/html; charset=' . strtoupper($this->parserCharset));
            echo $this->result;
        }
    }
 /**
  * Sends the mail by calling the mail() function in php. On Linux systems this will invoke the MTA
  * defined in php.ini (sendmail -t -i by default), on Windows a SMTP must be specified in the sys.ini.
  * Most common MTA's on Linux has a Sendmail interface, including Postfix and Exim.
  * For setting the return-path correctly, the parameter -f has to be added to the system call to sendmail.
  * This obviously does not have any effect on Windows, but on Sendmail compliant systems this works. If safe mode
  * is enabled, then extra parameters is not allowed, so a safe mode check is made before the mail() command is
  * invoked. When using the -f parameter, some MTA's will put an X-AUTHENTICATION-WARNING saying that
  * the return path was modified manually with the -f flag. To disable this warning make sure that the user running
  * Apache is in the /etc/mail/trusted-users table.
  *
  * POSTFIX: With postfix version below 2.0 there is a problem that the -f parameter can not be used in conjunction
  * with -t. Postfix will give an error in the maillog:
  *
  *  cannot handle command-line recipients with -t
  *
  * The -f parameter is only enabled if the parameter forceReturnPath is enabled in the install tool.
  *
  * This whole problem of return-path turns out to be quite tricky. If you have a solution that works better, on all
  * standard MTA's then we are very open for suggestions.
  *
  * With time this function should be made such that several ways of sending the mail is possible (local MTA, smtp other).
  *
  * @return	boolean		Returns whether the mail was sent (successfully accepted for delivery)
  */
 public function sendTheMail()
 {
     $mailWasSent = FALSE;
     // Sending the mail requires the recipient and message to be set.
     if (!trim($this->recipient) || !trim($this->message)) {
         return FALSE;
     }
     // On windows the -f flag is not used (specific for Sendmail and Postfix),
     // but instead the php.ini parameter sendmail_from is used.
     $returnPath = $this->forceReturnPath && strlen($this->returnPath) > 0 ? '-f ' . escapeshellarg($this->returnPath) : '';
     if (TYPO3_OS == 'WIN' && $this->returnPath) {
         @ini_set('sendmail_from', t3lib_div::normalizeMailAddress($this->returnPath));
     }
     $recipient = t3lib_div::normalizeMailAddress($this->recipient);
     // If safe mode is on, the fifth parameter to mail is not allowed, so the fix wont work on unix with safe_mode=On
     $returnPathPossible = !t3lib_utility_PhpOptions::isSafeModeEnabled() && $this->forceReturnPath;
     if ($returnPathPossible) {
         $mailWasSent = t3lib_utility_Mail::mail($recipient, $this->subject, $this->message, $this->headers, $returnPath);
     } else {
         $mailWasSent = t3lib_utility_Mail::mail($recipient, $this->subject, $this->message, $this->headers);
     }
     // Auto response
     if ($this->auto_respond_msg) {
         $theParts = explode('/', $this->auto_respond_msg, 2);
         $theParts[0] = str_replace('###SUBJECT###', $this->subject, $theParts[0]);
         $theParts[1] = str_replace("/", LF, $theParts[1]);
         $theParts[1] = str_replace("###MESSAGE###", $this->getContent('plain'), $theParts[1]);
         if ($returnPathPossible) {
             $mailWasSent = t3lib_utility_Mail::mail($this->from_email, $theParts[0], $theParts[1], 'From: ' . $recipient . $this->linebreak . $this->plain_text_header, $returnPath);
         } else {
             $mailWasSent = t3lib_utility_Mail::mail($this->from_email, $theParts[0], $theParts[1], 'From: ' . $recipient . $this->linebreak . $this->plain_text_header);
         }
     }
     if ($this->returnPath) {
         ini_restore('sendmail_from');
     }
     return $mailWasSent;
 }
 /**
  * Checks if PHP safe_mode is enabled.
  *
  * @return	tx_reports_reports_status_Status	A tx_reports_reports_status_Status object representing whether the safe_mode is enabled or not
  */
 protected function getPhpSafeModeStatus()
 {
     $value = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:disabled');
     $message = '';
     $severity = tx_reports_reports_status_Status::OK;
     if (t3lib_utility_PhpOptions::isSafeModeEnabled()) {
         $value = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:enabled');
         $severity = tx_reports_reports_status_Status::WARNING;
         $message = $GLOBALS['LANG']->sL('status_configuration_PhpSafeModeEnabled');
     }
     return t3lib_div::makeInstance('tx_reports_reports_status_Status', $GLOBALS['LANG']->getLL('status_PhpSafeMode'), $value, $message, $severity);
 }
 /**
  * Initialize external parser for parsing content.
  *
  * @param	string		File extension
  * @return	boolean		Returns true if extension is supported/enabled, otherwise false.
  */
 function initParser($extension)
 {
     // Then read indexer-config and set if appropriate:
     $indexerConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['indexed_search']);
     // If windows, apply extension to tool name:
     $exe = TYPO3_OS == 'WIN' ? '.exe' : '';
     // lg
     $extOK = FALSE;
     $mainExtension = '';
     // Ignore extensions
     $ignoreExtensions = t3lib_div::trimExplode(',', strtolower($indexerConfig['ignoreExtensions']), 1);
     if (in_array($extension, $ignoreExtensions)) {
         $this->pObj->log_setTSlogMessage(sprintf($this->sL('LLL:EXT:indexed_search/locallang.xml:ignoreExtensions'), $extension), 1);
         return FALSE;
     }
     $safeModeEnabled = t3lib_utility_PhpOptions::isSafeModeEnabled();
     // Switch on file extension:
     switch ($extension) {
         case 'pdf':
             // PDF
             if ($indexerConfig['pdftools']) {
                 $pdfPath = rtrim($indexerConfig['pdftools'], '/') . '/';
                 if ($safeModeEnabled || @is_file($pdfPath . 'pdftotext' . $exe) && @is_file($pdfPath . 'pdfinfo' . $exe)) {
                     $this->app['pdfinfo'] = $pdfPath . 'pdfinfo' . $exe;
                     $this->app['pdftotext'] = $pdfPath . 'pdftotext' . $exe;
                     // PDF mode:
                     $this->pdf_mode = t3lib_div::intInRange($indexerConfig['pdf_mode'], -100, 100);
                     $extOK = TRUE;
                 } else {
                     $this->pObj->log_setTSlogMessage(sprintf($this->sL('LLL:EXT:indexed_search/locallang.xml:pdfToolsNotFound'), $pdfPath), 3);
                 }
             } else {
                 $this->pObj->log_setTSlogMessage($this->sL('LLL:EXT:indexed_search/locallang.xml:pdfToolsDisabled'), 1);
             }
             break;
         case 'doc':
             // Catdoc
             if ($indexerConfig['catdoc']) {
                 $catdocPath = rtrim($indexerConfig['catdoc'], '/') . '/';
                 if ($safeModeEnabled || @is_file($catdocPath . 'catdoc' . $exe)) {
                     $this->app['catdoc'] = $catdocPath . 'catdoc' . $exe;
                     $extOK = TRUE;
                 } else {
                     $this->pObj->log_setTSlogMessage(sprintf($this->sL('LLL:EXT:indexed_search/locallang.xml:catdocNotFound'), $catdocPath), 3);
                 }
             } else {
                 $this->pObj->log_setTSlogMessage($this->sL('LLL:EXT:indexed_search/locallang.xml:catdocDisabled'), 1);
             }
             break;
         case 'pps':
             // MS PowerPoint(?)
         // MS PowerPoint(?)
         case 'ppt':
             // MS PowerPoint
             // ppthtml
             if ($indexerConfig['ppthtml']) {
                 $ppthtmlPath = rtrim($indexerConfig['ppthtml'], '/') . '/';
                 if ($safeModeEnabled || @is_file($ppthtmlPath . 'ppthtml' . $exe)) {
                     $this->app['ppthtml'] = $ppthtmlPath . 'ppthtml' . $exe;
                     $extOK = TRUE;
                 } else {
                     $this->pObj->log_setTSlogMessage(sprintf($this->sL('LLL:EXT:indexed_search/locallang.xml:ppthtmlNotFound'), $ppthtmlPath), 3);
                 }
             } else {
                 $this->pObj->log_setTSlogMessage($this->sL('LLL:EXT:indexed_search/locallang.xml:ppthtmlDisabled'), 1);
             }
             break;
         case 'xls':
             // MS Excel
             // Xlhtml
             if ($indexerConfig['xlhtml']) {
                 $xlhtmlPath = rtrim($indexerConfig['xlhtml'], '/') . '/';
                 if ($safeModeEnabled || @is_file($xlhtmlPath . 'xlhtml' . $exe)) {
                     $this->app['xlhtml'] = $xlhtmlPath . 'xlhtml' . $exe;
                     $extOK = TRUE;
                 } else {
                     $this->pObj->log_setTSlogMessage(sprintf($this->sL('LLL:EXT:indexed_search/locallang.xml:xlhtmlNotFound'), $xlhtmlPath), 3);
                 }
             } else {
                 $this->pObj->log_setTSlogMessage($this->sL('LLL:EXT:indexed_search/locallang.xml:xlhtmlDisabled'), 1);
             }
             break;
         case 'sxc':
             // Open Office Calc.
         // Open Office Calc.
         case 'sxi':
             // Open Office Impress
         // Open Office Impress
         case 'sxw':
             // Open Office Writer
         // Open Office Writer
         case 'ods':
             // Oasis OpenDocument Spreadsheet
         // Oasis OpenDocument Spreadsheet
         case 'odp':
             // Oasis OpenDocument Presentation
         // Oasis OpenDocument Presentation
         case 'odt':
             // Oasis OpenDocument Text
             if ($indexerConfig['unzip']) {
                 $unzipPath = rtrim($indexerConfig['unzip'], '/') . '/';
                 if ($safeModeEnabled || @is_file($unzipPath . 'unzip' . $exe)) {
                     $this->app['unzip'] = $unzipPath . 'unzip' . $exe;
                     $extOK = TRUE;
                 } else {
                     $this->pObj->log_setTSlogMessage(sprintf($this->sL('LLL:EXT:indexed_search/locallang.xml:unzipNotFound'), $unzipPath), 3);
                 }
             } else {
                 $this->pObj->log_setTSlogMessage($this->sL('LLL:EXT:indexed_search/locallang.xml:unzipDisabled'), 1);
             }
             break;
         case 'rtf':
             // Catdoc
             if ($indexerConfig['unrtf']) {
                 $unrtfPath = rtrim($indexerConfig['unrtf'], '/') . '/';
                 if ($safeModeEnabled || @is_file($unrtfPath . 'unrtf' . $exe)) {
                     $this->app['unrtf'] = $unrtfPath . 'unrtf' . $exe;
                     $extOK = TRUE;
                 } else {
                     $this->pObj->log_setTSlogMessage(sprintf($this->sL('LLL:EXT:indexed_search/locallang.xml:unrtfNotFound'), $unrtfPath), 3);
                 }
             } else {
                 $this->pObj->log_setTSlogMessage($this->sL('LLL:EXT:indexed_search/locallang.xml:unrtfDisabled'), 1);
             }
             break;
         case 'txt':
             // Raw text
         // Raw text
         case 'csv':
             // Raw text
         // Raw text
         case 'xml':
             // PHP strip-tags()
         // PHP strip-tags()
         case 'tif':
             // PHP EXIF
             $extOK = TRUE;
             break;
         case 'html':
             // PHP strip-tags()
         // PHP strip-tags()
         case 'htm':
             // PHP strip-tags()
             $extOK = TRUE;
             $mainExtension = 'html';
             // making "html" the common "item_type"
             break;
         case 'jpg':
             // PHP EXIF
         // PHP EXIF
         case 'jpeg':
             // PHP EXIF
             $extOK = TRUE;
             $mainExtension = 'jpeg';
             // making "jpeg" the common item_type
             break;
     }
     // If extension was OK:
     if ($extOK) {
         $this->supportedExtensions[$extension] = TRUE;
         $this->ext2itemtype_map[$extension] = $mainExtension ? $mainExtension : $extension;
         return TRUE;
     }
 }