[BUGFIX] Allow different hosts as long as they are defined in BE
authorNicole Cordes <cordes@cps-it.de>
Wed, 26 Feb 2014 22:12:30 +0000 (23:12 +0100)
committerNicole Cordes <cordes@cps-it.de>
Wed, 26 Feb 2014 22:12:30 +0000 (23:12 +0100)
This is important as some installations may use SSL for the form.

Change-Id: Ie8216b17293d41fddb25f35cecbcf5f77d6f4302

pi1/class.tx_tipafriendplus_pi1.php

index 1c1ff7a..64abaa1 100644 (file)
@@ -303,9 +303,27 @@ class tx_tipafriendplus_pi1 extends tslib_pibase {
                if (strstr($url, '"')) {
                        $url = FALSE;
                }
-               // Check if the first part of the url is actually the server where tip-a-friend is installed. If not, unset $url.
-               if (!preg_match('#\A' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . '#', $url)) {
+               // Check if the host of the url is equal with current used one
+               $urlParts = parse_url($url);
+               if (empty($urlParts['host'])) {
                        $url = FALSE;
+               } elseif ($urlParts['host'] !== t3lib_div::getIndpEnv('TYPO3_HOST_ONLY')) {
+                       // Compare with registered domains
+                       $pidList = array(0);
+                       foreach ($GLOBALS['TSFE']->rootLine as $item) {
+                               $pidList[] = $item['uid'];
+                       }
+                       unset($item);
+
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                               '*',
+                               'sys_domain',
+                               'domainName=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($urlParts['host'], 'sys_domain') .
+                                       ' AND pid IN (' . implode(',', $pidList) . ') AND hidden=0'
+                       );
+                       if (!$count) {
+                               $url = FALSE;
+                       }
                }
 
                $ret = TRUE;