/** * Obtains site URL. * * @static * @param int $pageId * @return string */ protected static function getSiteUrl($pageId) { $domain = t3lib_BEfunc::firstDomainRecord(t3lib_BEfunc::BEgetRootLine($pageId)); $pageRecord = t3lib_BEfunc::getRecord('pages', $pageId); $scheme = is_array($pageRecord) && isset($pageRecord['url_scheme']) && $pageRecord['url_scheme'] == t3lib_utility_Http::SCHEME_HTTPS ? 'https' : 'http'; return $domain ? $scheme . '://' . $domain . '/' : t3lib_div::getIndpEnv('TYPO3_SITE_URL'); }
/** * Generates a site specific key using the site url, encryption key, and * the extension key sent through md5. * * @param integer Optional page ID, if a page ID is provided it is used to determine the site hash, otherwise we try to use TSFE * @return string A site specific hash */ public static function getSiteHash($pageId = 0) { static $siteHashes; $rootLine = array(); // TODO caching might be more efficient if using root pid if (empty($siteHashes[$pageId])) { if ($pageId == 0 && empty($GLOBALS['TSFE']->rootLine)) { throw new RuntimeException('Unable to retrieve a rootline while calculating the site hash.', 1268673589); } // frontend if (!empty($GLOBALS['TSFE']->rootLine)) { $rootLine = $GLOBALS['TSFE']->rootLine; } // fallback, backend if (empty($rootLine) && $pageId != 0) { $pageSelect = t3lib_div::makeInstance('t3lib_pageSelect'); $rootLine = $pageSelect->getRootLine($pageId); } $domain = t3lib_BEfunc::firstDomainRecord($rootLine); $siteHashes[$pageId] = md5($domain . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . 'tx_solr'); } return $siteHashes[$pageId]; }
/** * Main function * * @return void */ function main() { global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS; // Access check... // The page will show only if there is a valid page and if this page may be viewed by the user $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id, $this->perms_clause); $access = is_array($this->pageinfo) ? 1 : 0; $addCmd = ''; if ($this->id && $access) { $addCmd = '&ADMCMD_view=1&ADMCMD_editIcons=1' . t3lib_BEfunc::ADMCMD_previewCmds($this->pageinfo); } $parts = parse_url(t3lib_div::getIndpEnv('TYPO3_SITE_URL')); $dName = t3lib_BEfunc::getDomainStartPage($parts['host'], $parts['path']) ? t3lib_BEfunc::firstDomainRecord(t3lib_BEfunc::BEgetRootLine($this->id)) : ''; // preview of mount pages $sys_page = t3lib_div::makeInstance('t3lib_pageSelect'); $sys_page->init(FALSE); $mountPointInfo = $sys_page->getMountPointInfo($this->id); if ($mountPointInfo && $mountPointInfo['overlay']) { $this->id = $mountPointInfo['mount_pid']; $addCmd .= '&MP=' . $mountPointInfo['MPvar']; } $this->url .= ($dName ? (t3lib_div::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://') . $dName : $BACK_PATH . '..') . '/index.php?id=' . $this->id . ($this->type ? '&type=' . $this->type : '') . $addCmd; }
/** * Url parsing * * @param array $row: broken link record * @return string parsed broken url */ public function getBrokenUrl($row) { $domain = rtrim(t3lib_div::getIndpEnv('TYPO3_SITE_URL'), '/'); $rootLine = t3lib_BEfunc::BEgetRootLine($row['record_pid']); // checks alternate domains if (count($rootLine) > 0) { $protocol = t3lib_div::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://'; $domainRecord = t3lib_BEfunc::firstDomainRecord($rootLine); if (!empty($domainRecord)) { $domain = $protocol . $domainRecord; } } return $domain . '/index.php?id=' . $row['url']; }
/** * Gets the site's main domain. More specifically the first domain record in * the site tree. * * @return string The site's main domain. */ public function getDomain() { $pageSelect = t3lib_div::makeInstance('t3lib_pageSelect'); $rootLine = $pageSelect->getRootLine($this->rootPage['uid']); return t3lib_BEfunc::firstDomainRecord($rootLine); }
/** * Initializes the $_SERVER['HTTP_HOST'] environment variable in CLI * environments dependent on the Index Queue item's root page. * * When the Index Queue Worker task is executed by a cron job there is no * HTTP_HOST since we are in a CLI environment. RealURL needs the host * information to generate a proper URL though. Using the Index Queue item's * root page information we can determine the correct host although being * in a CLI environment. * * @param Tx_Solr_IndexQueue_Item $item Index Queue item to use to determine the host. */ protected function initializeHttpHost(Tx_Solr_IndexQueue_Item $item) { static $hosts = array(); // relevant for realURL environments, only if (t3lib_extMgm::isLoaded('realurl')) { $rootpageId = $item->getRootPageUid(); $hostFound = !empty($hosts[$rootpageId]); if (!$hostFound) { $rootline = t3lib_BEfunc::BEgetRootLine($rootpageId); $host = t3lib_BEfunc::firstDomainRecord($rootline); $hosts[$rootpageId] = $host; } $_SERVER['HTTP_HOST'] = $hosts[$rootpageId]; } }
/** * Gets the site's main domain. More specifically the first domain record in * the site tree. * * @return string The site's main domain. */ public function getDomain() { $pageSelect = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_pageSelect'); $rootLine = $pageSelect->getRootLine($this->rootPage['uid']); return t3lib_BEfunc::firstDomainRecord($rootLine); }
/** * Retrieves RealURL configuration for given pid * * @param int $pid Page uid * @return mixed Configuration array or false */ function getConfigForPage($pid) { $rootline = t3lib_BEfunc::BEgetRootLine($pid); if (($domain = t3lib_BEfunc::firstDomainRecord($rootline))) { if ($this->enableDevLog) { t3lib_div::devLog('Found domain record', 'realurl', 0, $domain); } if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$domain])) { $config = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$domain]; while (is_string($config)) { $domain = $config; $config = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'][$config]; } return array($domain, $config); } } if ($this->enableDevLog) { t3lib_div::devLog('Checking default', 'realurl', 0, intval(isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']))); } return (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']) ? array('_DEFAULT', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']) : false); }