Exemplo n.º 1
0
 /**
  * Returns TRUE if $haystack ends with $needle.
  * The input string is not trimmed before and search
  * is done case sensitive.
  *
  * @param string $haystack Full string to check
  * @param string $needle Reference string which must be found as the "last part" of the full string
  * @throws \InvalidArgumentException
  * @return boolean TRUE if $needle was found to be equal to the last part of $str
  * @deprecated since 6.3 - will be removed two versions later, use beginsWith() instead
  */
 public static function isLastPartOfString($haystack, $needle)
 {
     GeneralUtility::logDeprecatedFunction();
     // Sanitize $haystack and $needle
     if (is_object($haystack) || (string) $haystack != $haystack || strlen($haystack) < 1) {
         throw new \InvalidArgumentException('$haystack can not be interpreted as string or has no length', 1347135544);
     }
     if (is_object($needle) || (string) $needle != $needle || strlen($needle) < 1) {
         throw new \InvalidArgumentException('$needle can not be interpreted as string or has no length', 1347135545);
     }
     $stringLength = strlen($haystack);
     $needleLength = strlen($needle);
     return strrpos((string) $haystack, (string) $needle, 0) === $stringLength - $needleLength;
 }
Exemplo n.º 2
0
    /**
     * 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 $to Email address to send to.
     * @param string $subject Subject line, non-encoded. (see PHP function mail())
     * @param string $messageBody Message content, non-encoded. (see PHP function mail())
     * @param string $additionalHeaders Additional headers for the mail (see PHP function mail())
     * @param string $additionalParameters 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
     * @deprecated since 6.1, will be removed two versions later - Use \TYPO3\CMS\Core\Mail\Mailer instead
     */
    public static function mail($to, $subject, $messageBody, $additionalHeaders = NULL, $additionalParameters = NULL)
    {
        GeneralUtility::logDeprecatedFunction();
        $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) {
                    throw new \RuntimeException($hookSubscriber . ' is an invalid hook implementation. Please consider using an implementation of TYPO3\\CMS\\Core\\Mail\\MailerAdapter.', 1322287600);
                } else {
                    $mailerAdapter = GeneralUtility::makeInstance($hookSubscriber);
                    if ($mailerAdapter instanceof \TYPO3\CMS\Core\Mail\MailerAdapterInterface) {
                        $success = $success && $mailerAdapter->mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters, $fakeThis);
                    } else {
                        throw new \RuntimeException($hookSubscriber . ' is not an implementation of TYPO3\\CMS\\Core\\Mail\\MailerAdapter,
							but must implement that interface to be used in the substituteMailDelivery hook.', 1294062286);
                    }
                }
            }
        } else {
            if (is_null($additionalParameters)) {
                $success = @mail($to, $subject, $messageBody, $additionalHeaders);
            } else {
                $success = @mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters);
            }
        }
        if (!$success) {
            GeneralUtility::sysLog('Mail to "' . $to . '" could not be sent (Subject: "' . $subject . '").', 'Core', GeneralUtility::SYSLOG_SEVERITY_ERROR);
        }
        return $success;
    }
 /**
  * Writes extension list and clear cache files.
  *
  * @TODO: This method should be protected, but with current em it is hard to do so,
  * @TODO: Find out if we may remove this already
  * @param array $newExtensionList Extension array to load, loader order is kept
  * @return void
  * @internal
  * @deprecated since 6.2, will be removed two versions later
  */
 public static function writeNewExtensionList(array $newExtensionList)
 {
     GeneralUtility::logDeprecatedFunction();
 }
Exemplo n.º 4
0
 /**
  * Check if php sql.safe_mode is enabled
  *
  * @return boolean TRUE if sql.safe_mode is enabled, FALSE if disabled
  * @deprecated since 6.2, will be removed two versions later
  */
 public static function isSqlSafeModeEnabled()
 {
     GeneralUtility::logDeprecatedFunction();
     return self::getIniValueBoolean('sql.safe_mode');
 }
Exemplo n.º 5
0
 /**
  * Sets the class
  *
  * @param string $class
  * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
  */
 public function setClass($class)
 {
     GeneralUtility::logDeprecatedFunction();
     $this->class = $class;
 }
Exemplo n.º 6
0
 /**
  * Replaces special characters for the usage inside javascript
  *
  * @param string $string
  * @param boolean $asObject
  * @return string
  * @deprecated since 6.0 will be removed with 6.2
  */
 public static function prepareVariableForJavascript($string, $asObject)
 {
     GeneralUtility::logDeprecatedFunction();
     return self::getJavaScriptEncoder()->encode($string);
 }