Kompatibilität mit PHP 7 hergestellt

This commit is contained in:
Carsten Götzinger 2016-11-26 09:34:48 +01:00
parent ca6aabdf01
commit 974e8a4bad
3 changed files with 16 additions and 11 deletions

View File

@ -194,7 +194,7 @@ class AeoHybrid extends \Hybrid
/** /**
* Template variables * Template variables
*/ */
$this->import('String'); $this->import('StringUtil');
$this->Template->action = $this->getIndexFreeRequest(); $this->Template->action = $this->getIndexFreeRequest();
$this->Template->n = $this->Input->get('n'); $this->Template->n = $this->Input->get('n');
$this->Template->d = $this->Input->get('d'); $this->Template->d = $this->Input->get('d');
@ -220,11 +220,11 @@ class AeoHybrid extends \Hybrid
} }
if ($this->Input->post('p')) { if ($this->Input->post('p')) {
$email .= $this->String->decodeEntities(base64_decode($this->String->decodeEntities($this->Input->post('p')))); $email .= $this->StringUtil->decodeEntities(base64_decode($this->StringUtil->decodeEntities($this->Input->post('p'))));
} }
$this->Template->isHuman = true; $this->Template->isHuman = true;
$this->Template->success = sprintf($GLOBALS['TL_LANG']['aeo']['success'], $this->String->encodeEmail($email), $this->String->encodeEmail(preg_replace('/\?.*$/', '', $email))); $this->Template->success = sprintf($GLOBALS['TL_LANG']['aeo']['success'], $this->StringUtil->encodeEmail($email), $this->StringUtil->encodeEmail(preg_replace('/\?.*$/', '', $email)));
if (!headers_sent()) { if (!headers_sent()) {
header('HTTP/1.1 303 See Other'); header('HTTP/1.1 303 See Other');

View File

@ -28,6 +28,11 @@
* @filesource * @filesource
*/ */
// Backwards compatibility for Contao < 3.5.1
if (!class_exists('StringUtil') && class_exists('String')) {
class_alias('String', 'StringUtil');
}
/** /**
* Hooks * Hooks
*/ */

View File

@ -191,14 +191,14 @@ class AeoFrontendUtil extends \Frontend {
if (TL_MODE == 'FE' && $this->replace_standard_obfuscation && $objPage2->id != $redirectPageId) { if (TL_MODE == 'FE' && $this->replace_standard_obfuscation && $objPage2->id != $redirectPageId) {
$strContent = $this->aeoReplaceInsertTags($strContent); $strContent = $this->aeoReplaceInsertTags($strContent);
$this->import('String'); $this->import('StringUtil');
// erst alle Mailadresse decodieren (Verschleierung von Contao rückgänging machen) // erst alle Mailadresse decodieren (Verschleierung von Contao rückgänging machen)
$intOffset = 0; $intOffset = 0;
$arrNoAeoAreas = $this->aeo->getNoAeoAreas($strContent); $arrNoAeoAreas = $this->aeo->getNoAeoAreas($strContent);
while (preg_match('/(&#[x]?\w+;)+/i', $strContent, $arrEmail, PREG_OFFSET_CAPTURE, $intOffset)) { while (preg_match('/(&#[x]?\w+;)+/i', $strContent, $arrEmail, PREG_OFFSET_CAPTURE, $intOffset)) {
if ($this->aeo->isEnabled($arrEmail[0][1], $arrNoAeoAreas)) { if ($this->aeo->isEnabled($arrEmail[0][1], $arrNoAeoAreas)) {
$strDecodedMail = $this->String->decodeEntities($arrEmail[0][0]); $strDecodedMail = $this->StringUtil->decodeEntities($arrEmail[0][0]);
if (preg_match('/mailto:'.REGEXP_EMAIL.'/i', $strDecodedMail)) { if (preg_match('/mailto:'.REGEXP_EMAIL.'/i', $strDecodedMail)) {
// erst alle verlinkten eMail-Adressen entschleiern // erst alle verlinkten eMail-Adressen entschleiern
$strContent = $this->aeo->str_replace($arrEmail[0][0], $strDecodedMail, $strContent, $arrEmail[0][1]); $strContent = $this->aeo->str_replace($arrEmail[0][0], $strDecodedMail, $strContent, $arrEmail[0][1]);
@ -281,17 +281,17 @@ class AeoFrontendUtil extends \Frontend {
continue; continue;
} }
$this->import('String'); $this->import('StringUtil');
if ($GLOBALS['TL_CONFIG']['aeo_replace_standard_obfuscation'] === true && if ($GLOBALS['TL_CONFIG']['aeo_replace_standard_obfuscation'] === true &&
$this->aeo->isEnabled($position, $arrNoAeoAreas)) { $this->aeo->isEnabled($position, $arrNoAeoAreas)) {
// AEO aktiv und Bereich nicht auf deaktiviert gestellt // AEO aktiv und Bereich nicht auf deaktiviert gestellt
$strValue = $this->aeo->obfuscateSingle($this->String->decodeEntities($arrTag[1]), $objPage->id, $arrTag[2]); $strValue = $this->aeo->obfuscateSingle($this->StringUtil->decodeEntities($arrTag[1]), $objPage->id, $arrTag[2]);
$strContent = $this->aeo->str_replace($arrTags[0][0], $strValue, $strContent, $position); $strContent = $this->aeo->str_replace($arrTags[0][0], $strValue, $strContent, $position);
$intOffset += strlen($strValue); $intOffset += strlen($strValue);
} else { } else {
// AEO nicht aktiv oder Bereich auf deaktiviert gestellt // AEO nicht aktiv oder Bereich auf deaktiviert gestellt
$strEmail = $this->String->encodeEmail($this->String->decodeEntities($arrTag[1])); $strEmail = $this->StringUtil->encodeEmail($this->StringUtil->decodeEntities($arrTag[1]));
$strValue = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;' . $this->String->encodeEmail($strEmail) . '" class="email">' . $this->String->encodeEmail(preg_replace('/\?.*$/', '', $strEmail)) . '</a>'; $strValue = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;' . $this->StringUtil->encodeEmail($strEmail) . '" class="email">' . $this->StringUtil->encodeEmail(preg_replace('/\?.*$/', '', $strEmail)) . '</a>';
$strContent = $this->aeo->str_replace($arrTags[0][0], $strValue, $strContent, $position); $strContent = $this->aeo->str_replace($arrTags[0][0], $strValue, $strContent, $position);
$intOffset += strlen($strValue); $intOffset += strlen($strValue);
} }
@ -402,8 +402,8 @@ class Aeo extends \System {
// passendes CSS hinzufügen // passendes CSS hinzufügen
$strLink .= $this->obfuscateWithMethod($arrEmail[0], $method, true, 0, 0).'@'.$strDomain.'.'.$strTld; $strLink .= $this->obfuscateWithMethod($arrEmail[0], $method, true, 0, 0).'@'.$strDomain.'.'.$strTld;
} else { } else {
$this->import('String'); $this->import('StringUtil');
$strLink .= $this->String->encodeEmail($email); $strLink .= $this->StringUtil->encodeEmail($email);
} }
$strLink .= '</a>'; $strLink .= '</a>';
return $this->createSpecialEntities($strLink); return $this->createSpecialEntities($strLink);