/**
  * @test
  */
 public function getCurrentPageIdReturnsPageIdFromPost()
 {
     \TYPO3\CMS\Core\Utility\GeneralUtility::_GETset(array('id' => 123));
     $_POST['id'] = 321;
     $expectedResult = 321;
     $actualResult = $this->backendConfigurationManager->_call('getCurrentPageId');
     $this->assertEquals($expectedResult, $actualResult);
 }
 /**
  * @test
  * @return void
  */
 public function viewReturnsCurrentFieldValueIfValueInGPAvailable()
 {
     \TYPO3\CMS\Core\Utility\GeneralUtility::_GETset(['tx_sfeventmgt_pievent' => ['registration' => ['fieldname' => 'Existing Value']]]);
     $GLOBALS['TSFE'] = new \stdClass();
     $viewHelper = new PrefillViewHelper();
     $actual = $viewHelper->render('fieldname', []);
     $this->assertSame('Existing Value', $actual);
 }
 /**
  * Initializes the TSFE for a given page ID and language.
  *
  * @param integer The page id to initialize the TSFE for
  * @param integer System language uid, optional, defaults to 0
  * @param boolean Use cache to reuse TSFE
  * @return void
  */
 public static function initializeTsfe($pageId, $language = 0, $useCache = TRUE)
 {
     static $tsfeCache = array();
     // resetting, a TSFE instance with data from a different page Id could be set already
     unset($GLOBALS['TSFE']);
     $cacheId = $pageId . '|' . $language;
     if (!is_object($GLOBALS['TT'])) {
         $GLOBALS['TT'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_TimeTrackNull');
     }
     if (!isset($tsfeCache[$cacheId]) || !$useCache) {
         \TYPO3\CMS\Core\Utility\GeneralUtility::_GETset($language, 'L');
         $GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_fe', $GLOBALS['TYPO3_CONF_VARS'], $pageId, 0);
         // for certain situations we need to trick TSFE into granting us
         // access to the page in any case to make getPageAndRootline() work
         // see http://forge.typo3.org/issues/42122
         $pageRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord('pages', $pageId);
         $groupListBackup = $GLOBALS['TSFE']->gr_list;
         $GLOBALS['TSFE']->gr_list = $pageRecord['fe_group'];
         $GLOBALS['TSFE']->sys_page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_pageSelect');
         $GLOBALS['TSFE']->getPageAndRootline();
         // restore gr_list
         $GLOBALS['TSFE']->gr_list = $groupListBackup;
         $GLOBALS['TSFE']->initTemplate();
         $GLOBALS['TSFE']->forceTemplateParsing = TRUE;
         $GLOBALS['TSFE']->initFEuser();
         $GLOBALS['TSFE']->initUserGroups();
         // $GLOBALS['TSFE']->getCompressedTCarray(); // seems to cause conflicts sometimes
         $GLOBALS['TSFE']->no_cache = TRUE;
         $GLOBALS['TSFE']->tmpl->start($GLOBALS['TSFE']->rootLine);
         $GLOBALS['TSFE']->no_cache = FALSE;
         $GLOBALS['TSFE']->getConfigArray();
         $GLOBALS['TSFE']->settingLanguage();
         $GLOBALS['TSFE']->newCObj();
         $GLOBALS['TSFE']->absRefPrefix = $GLOBALS['TSFE']->config['config']['absRefPrefix'] ? trim($GLOBALS['TSFE']->config['config']['absRefPrefix']) : '';
         if ($useCache) {
             $tsfeCache[$cacheId] = $GLOBALS['TSFE'];
         }
     }
     if ($useCache) {
         $GLOBALS['TSFE'] = $tsfeCache[$cacheId];
     }
 }
 public function guardLanguageRequestParameterForTtContent()
 {
     if (!is_array(GeneralUtility::_GET('data'))) {
         return;
     }
     $data = GeneralUtility::_GET('data');
     if (count($data) !== 1) {
         return;
     }
     if (!array_key_exists('tt_content', $data) || !is_array($data['tt_content'])) {
         return;
     }
     if (count($data['tt_content']) !== 1) {
         return;
     }
     $recordId = key($data['tt_content']);
     $keys = array_intersect_key($data['tt_content'][$recordId], array_flip($this->requiredUpdateFields));
     if (count($keys) !== count($this->requiredUpdateFields)) {
         return;
     }
     unset($data['tt_content'][$recordId]['sys_language_uid']);
     GeneralUtility::_GETset($data, 'data');
 }
 /**
  * Gets the configured Solr connection for a specific root page and language ID.
  *
  * @param array $rootPage A root page record with at least title and uid
  * @param integer $languageId ID of a system language
  * @return array A solr connection configuration.
  */
 protected function getConfiguredSolrConnectionByRootPage(array $rootPage, $languageId)
 {
     $connection = array();
     $languageId = intval($languageId);
     GeneralUtility::_GETset($languageId, 'L');
     $connectionKey = $rootPage['uid'] . '|' . $languageId;
     $pageSelect = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
     $rootLine = $pageSelect->getRootLine($rootPage['uid']);
     $tmpl = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\ExtendedTemplateService');
     $tmpl->tt_track = false;
     // Do not log time-performance information
     $tmpl->init();
     $tmpl->runThroughTemplates($rootLine);
     // This generates the constants/config + hierarchy info for the template.
     // fake micro TSFE to get correct condition parsing
     $GLOBALS['TSFE'] = new \stdClass();
     $GLOBALS['TSFE']->tmpl = new \stdClass();
     $GLOBALS['TSFE']->tmpl->rootLine = $rootLine;
     $GLOBALS['TSFE']->sys_page = $pageSelect;
     $GLOBALS['TSFE']->id = $rootPage['uid'];
     $GLOBALS['TSFE']->page = $rootPage;
     $tmpl->generateConfig();
     list($solrSetup) = $tmpl->ext_getSetup($tmpl->setup, 'plugin.tx_solr.solr');
     list(, $solrEnabled) = $tmpl->ext_getSetup($tmpl->setup, 'plugin.tx_solr.enabled');
     $solrEnabled = !empty($solrEnabled) ? true : false;
     if (!empty($solrSetup) && $solrEnabled) {
         $solrPath = trim($solrSetup['path'], '/');
         $solrPath = '/' . $solrPath . '/';
         $connection = array('connectionKey' => $connectionKey, 'rootPageTitle' => $rootPage['title'], 'rootPageUid' => $rootPage['uid'], 'solrScheme' => $solrSetup['scheme'], 'solrHost' => $solrSetup['host'], 'solrPort' => $solrSetup['port'], 'solrPath' => $solrPath, 'language' => $languageId);
         $connection['label'] = $this->buildConnectionLabel($connection);
     }
     return $connection;
 }
 /**
  * Initializes all actions.
  *
  * @return void
  */
 protected function initializeAction()
 {
     $this->id = (int) GeneralUtility::_GET('id');
     $this->databaseConnection = $GLOBALS['TYPO3_DB'];
     // Fix pagers
     $arguments = GeneralUtility::_GPmerged($this->argumentsKey);
     if ($arguments && is_array($arguments)) {
         foreach ($arguments as $argumentKey => $argumentValue) {
             if ($argumentValue) {
                 if (!in_array($argumentKey, $this->excludedArguments)) {
                     GeneralUtility::_GETset($argumentValue, $this->argumentsKey . '|' . $argumentKey);
                 } else {
                     GeneralUtility::_GETset('', $this->argumentsKey . '|' . $argumentKey);
                 }
             }
         }
     } else {
         $this->forwardToLastModule();
     }
     parent::initializeAction();
 }
Example #7
0
 /**
  * Tests the sort url creation
  *
  * @dataProvider sortUrlCreationDataProvider
  * @test
  *
  * @param string $currentSorting the current sort parameters
  * @param string $sorting the requested sorting
  * @param string $expectedResult
  * @return void
  */
 public function canCreateSortUrls($currentSorting, $sorting, $expectedResult)
 {
     GeneralUtility::_GETset(array('sort' => $currentSorting), 'tx_solr');
     $sortUrl = $this->viewHelper->execute(array($sorting));
     $this->assertEquals($expectedResult, $sortUrl['sort'], 'Sort url parameter "' . $sortUrl['sort'] . '"  doesn\'t match the expected parameters: ' . $expectedResult);
 }
Example #8
0
 /**
  * @test
  */
 public function buildBackendUriCreatesAbsoluteUrisIfSpecified()
 {
     GeneralUtility::flushInternalRuntimeCaches();
     GeneralUtility::_GETset(array('M' => 'moduleKey'));
     $_SERVER['HTTP_HOST'] = 'baseuri';
     $_SERVER['SCRIPT_NAME'] = '/typo3/index.php';
     $this->mockRequest->expects($this->any())->method('getBaseUri')->will($this->returnValue('http://baseuri'));
     $this->uriBuilder->setCreateAbsoluteUri(true);
     $expectedResult = 'http://baseuri/' . TYPO3_mainDir . 'index.php?M=moduleKey&moduleToken=dummyToken';
     $actualResult = $this->uriBuilder->buildBackendUri();
     $this->assertSame($expectedResult, $actualResult);
 }
Example #9
0
 /**
  * Generates a workspace splitted preview link.
  *
  * @param int $uid The ID of the record to be linked
  * @param bool $addDomain Parameter to decide if domain should be added to the generated link, FALSE per default
  * @return string the preview link without the trailing '/'
  */
 public function generateWorkspaceSplittedPreviewLink($uid, $addDomain = false)
 {
     // In case a $pageUid is submitted we need to make sure it points to a live-page
     if ($uid > 0) {
         $uid = $this->getLivePageUid($uid);
     }
     /** @var $uriBuilder \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder */
     $uriBuilder = $this->getObjectManager()->get(\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class);
     $redirect = 'index.php?redirect_url=';
     // @todo this should maybe be changed so that the extbase URI Builder can deal with module names directly
     $originalM = GeneralUtility::_GET('M');
     GeneralUtility::_GETset('web_WorkspacesWorkspaces', 'M');
     $viewScript = $uriBuilder->uriFor('index', array(), 'Preview', 'workspaces', 'web_workspacesworkspaces') . '&id=';
     GeneralUtility::_GETset($originalM, 'M');
     if ($addDomain === true) {
         return BackendUtility::getViewDomain($uid) . $redirect . urlencode($viewScript) . $uid;
     } else {
         return $viewScript;
     }
 }
Example #10
0
 /**
  * Set storage pid in BE
  *
  * Only needed when the class is called or injected in a BE context, e.g. a hook.
  * Without the generation of the TS is based upon the next root page (default
  * extbase behaviour) and repositories won't work as expected.
  *
  * @param $pageUid
  *
  * @return void
  */
 public function setPageUid($pageUid)
 {
     if (TYPO3_MODE === 'BE') {
         $currentPid['persistence']['storagePid'] = (int) $pageUid;
         $this->configurationManager->setConfiguration(array_merge($this->getFrameworkSettings(), $currentPid));
         GeneralUtility::_GETset((int) $pageUid, 'id');
     }
 }
Example #11
0
 /**
  * @test
  */
 public function buildBackendUriCreatesAbsoluteUrisIfSpecified()
 {
     \TYPO3\CMS\Core\Utility\GeneralUtility::_GETset(array('M' => 'moduleKey'));
     $this->mockRequest->expects($this->any())->method('getBaseUri')->will($this->returnValue('http://baseuri/' . TYPO3_mainDir));
     $this->uriBuilder->setCreateAbsoluteUri(TRUE);
     $expectedResult = 'http://baseuri/' . TYPO3_mainDir . 'mod.php?M=moduleKey&moduleToken=dummyToken';
     $actualResult = $this->uriBuilder->buildBackendUri();
     $this->assertSame($expectedResult, $actualResult);
 }
 /**
  * Sets the jumpurl for page type "External URL"
  *
  * @return void
  */
 public function setExternalJumpUrl()
 {
     if ($extUrl = $this->sys_page->getExtURL($this->page, $this->config['config']['disablePageExternalUrl'])) {
         $this->jumpurl = $extUrl;
         GeneralUtility::_GETset(GeneralUtility::hmac($this->jumpurl, 'jumpurl'), 'juHash');
     }
 }
Example #13
0
 /**
  * Looking for a ADMCMD_prev code, looks it up if found and returns configuration data.
  * Background: From the backend a request to the frontend to show a page, possibly with
  * workspace preview can be "recorded" and associated with a keyword.
  * When the frontend is requested with this keyword the associated request parameters are
  * restored from the database AND the backend user is loaded - only for that request.
  * The main point is that a special URL valid for a limited time,
  * eg. http://localhost/typo3site/index.php?ADMCMD_prev=035d9bf938bd23cb657735f68a8cedbf will
  * open up for a preview that doesn't require login. Thus it's useful for sending in an email
  * to someone without backend account.
  * This can also be used to generate previews of hidden pages, start/endtimes, usergroups and
  * those other settings from the Admin Panel - just not implemented yet.
  *
  * @throws \Exception
  * @return array Preview configuration array from sys_preview record.
  */
 public function getPreviewConfiguration()
 {
     $inputCode = $this->getPreviewInputCode();
     // If inputcode is available, look up the settings
     if ($inputCode) {
         // "log out"
         if ($inputCode == 'LOGOUT') {
             setcookie($this->previewKey, '', 0, GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'));
             if ($this->tsfeObj->TYPO3_CONF_VARS['FE']['workspacePreviewLogoutTemplate']) {
                 $templateFile = PATH_site . $this->tsfeObj->TYPO3_CONF_VARS['FE']['workspacePreviewLogoutTemplate'];
                 if (@is_file($templateFile)) {
                     $message = GeneralUtility::getUrl(PATH_site . $this->tsfeObj->TYPO3_CONF_VARS['FE']['workspacePreviewLogoutTemplate']);
                 } else {
                     $message = '<strong>ERROR!</strong><br>Template File "' . $this->tsfeObj->TYPO3_CONF_VARS['FE']['workspacePreviewLogoutTemplate'] . '" configured with $TYPO3_CONF_VARS["FE"]["workspacePreviewLogoutTemplate"] not found. Please contact webmaster about this problem.';
                 }
             } else {
                 $message = 'You logged out from Workspace preview mode. Click this link to <a href="%1$s">go back to the website</a>';
             }
             $returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GET('returnUrl'));
             die(sprintf($message, htmlspecialchars(preg_replace('/\\&?' . $this->previewKey . '=[[:alnum:]]+/', '', $returnUrl))));
         }
         // Look for keyword configuration record:
         $where = 'keyword=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($inputCode, 'sys_preview') . ' AND endtime>' . $GLOBALS['EXEC_TIME'];
         $previewData = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_preview', $where);
         // Get: Backend login status, Frontend login status
         // - Make sure to remove fe/be cookies (temporarily);
         // BE already done in ADMCMD_preview_postInit()
         if (is_array($previewData)) {
             if (!count(GeneralUtility::_POST())) {
                 // Unserialize configuration:
                 $previewConfig = unserialize($previewData['config']);
                 // For full workspace preview we only ADD a get variable
                 // to set the preview of the workspace - so all other Get
                 // vars are accepted. Hope this is not a security problem.
                 // Still posting is not allowed and even if a backend user
                 // get initialized it shouldn't lead to situations where
                 // users can use those credentials.
                 if ($previewConfig['fullWorkspace']) {
                     // Set the workspace preview value:
                     GeneralUtility::_GETset($previewConfig['fullWorkspace'], 'ADMCMD_previewWS');
                     // If ADMCMD_prev is set the $inputCode value cannot come
                     // from a cookie and we set that cookie here. Next time it will
                     // be found from the cookie if ADMCMD_prev is not set again...
                     if (GeneralUtility::_GP($this->previewKey)) {
                         // Lifetime is 1 hour, does it matter much?
                         // Requires the user to click the link from their email again if it expires.
                         SetCookie($this->previewKey, GeneralUtility::_GP($this->previewKey), 0, GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'));
                     }
                     return $previewConfig;
                 } elseif (GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'index.php?' . $this->previewKey . '=' . $inputCode === GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')) {
                     // Set GET variables
                     $GET_VARS = '';
                     parse_str($previewConfig['getVars'], $GET_VARS);
                     GeneralUtility::_GETset($GET_VARS);
                     // Return preview keyword configuration
                     return $previewConfig;
                 } else {
                     // This check is to prevent people from setting additional
                     // GET vars via realurl or other URL path based ways of passing parameters.
                     throw new \Exception(htmlspecialchars('Request URL did not match "' . GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'index.php?' . $this->previewKey . '=' . $inputCode . '"', 1294585190));
                 }
             } else {
                 throw new \Exception('POST requests are incompatible with keyword preview.', 1294585191);
             }
         } else {
             throw new \Exception('ADMCMD command could not be executed! (No keyword configuration found)', 1294585192);
         }
     }
     return FALSE;
 }
Example #14
0
 /**
  * Generates a workspace splitted preview link.
  *
  * @param integer $uid The ID of the record to be linked
  * @param boolean $addDomain Parameter to decide if domain should be added to the generated link, FALSE per default
  * @return string the preview link without the trailing '/'
  */
 public function generateWorkspaceSplittedPreviewLink($uid, $addDomain = FALSE)
 {
     // In case a $pageUid is submitted we need to make sure it points to a live-page
     if ($uid > 0) {
         $uid = $this->getLivePageUid($uid);
     }
     /** @var $uriBuilder \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder */
     $uriBuilder = $this->getObjectManager()->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
     // This seems to be very harsh to set this directly to "/typo3 but the viewOnClick also
     // has /index.php as fixed value here and dealing with the backPath is very error-prone
     // @todo make sure this would work in local extension installation too
     $backPath = '/' . TYPO3_mainDir;
     $redirect = $backPath . 'index.php?redirect_url=';
     // @todo this should maybe be changed so that the extbase URI Builder can deal with module names directly
     $originalM = GeneralUtility::_GET('M');
     GeneralUtility::_GETset('web_WorkspacesWorkspaces', 'M');
     $viewScript = $backPath . $uriBuilder->uriFor('index', array(), 'Preview', 'workspaces', 'web_workspacesworkspaces') . '&id=';
     GeneralUtility::_GETset($originalM, 'M');
     if ($addDomain === TRUE) {
         return BackendUtility::getViewDomain($uid) . $redirect . urlencode($viewScript) . $uid;
     } else {
         return $viewScript;
     }
 }
 /**
  * Adds an array to the PHP global $_GET var.
  *
  * @param	array	$arguments	The arguments you want to add.
  */
 private function addRequestArgumentsToGlobal($arguments)
 {
     GeneralUtility::_GETset($arguments);
 }
Example #16
0
 /**
  * Get the url to jump to as set by Direct Mail
  *
  * @return	void
  * @throws \Exception
  */
 public function preprocessRequest($parameter, $parentObject)
 {
     $db = $this->getDatabaseConnection();
     $jumpUrlVariables = GeneralUtility::_GET();
     $mid = $jumpUrlVariables['mid'];
     $rid = $jumpUrlVariables['rid'];
     $aC = $jumpUrlVariables['aC'];
     $responseType = 0;
     if ($mid) {
         // overwrite the jumpUrl with the one from the &jumpurl= get parameter
         $jumpurl = $jumpUrlVariables['jumpurl'];
         // this will split up the "rid=f_13667", where the first part
         // is the DB table name and the second part the UID of the record in the DB table
         $recipientTable = '';
         $recipientUid = '';
         if (!empty($rid)) {
             list($recipientTable, $recipientUid) = explode('_', $rid);
         }
         $urlId = 0;
         if (MathUtility::canBeInterpretedAsInteger($jumpurl)) {
             // fetch the direct mail record where the mailing was sent (for this message)
             $resMailing = $db->exec_SELECTquery('mailContent, page, authcode_fieldList', 'sys_dmail', 'uid = ' . intval($mid));
             if ($row = $db->sql_fetch_assoc($resMailing)) {
                 $mailContent = unserialize(base64_decode($row['mailContent']));
                 $urlId = $jumpurl;
                 if ($jumpurl >= 0) {
                     // Link (number)
                     $responseType = 1;
                     $jumpurl = $mailContent['html']['hrefs'][$urlId]['absRef'];
                 } else {
                     // Link (number, plaintext)
                     $responseType = 2;
                     $jumpurl = $mailContent['plain']['link_ids'][abs($urlId)];
                 }
                 $jumpurl = htmlspecialchars_decode(urldecode($jumpurl));
                 switch ($recipientTable) {
                     case 't':
                         $theTable = 'tt_address';
                         break;
                     case 'f':
                         $theTable = 'fe_users';
                         break;
                     default:
                         $theTable = '';
                 }
                 if ($theTable) {
                     $recipRow = $this->getRawRecord($theTable, $recipientUid);
                     if (is_array($recipRow)) {
                         $authCode = GeneralUtility::stdAuthCode($recipRow, $row['authcode_fieldList'] ? $row['authcode_fieldList'] : 'uid');
                         // check if supplied aC identical with counted authCode
                         if ($aC != '' && $aC == $authCode) {
                             $rowFieldsArray = explode(',', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail']['defaultRecipFields']);
                             if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail']['addRecipFields']) {
                                 $rowFieldsArray = array_merge($rowFieldsArray, explode(',', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail']['addRecipFields']));
                             }
                             reset($rowFieldsArray);
                             foreach ($rowFieldsArray as $substField) {
                                 $jumpurl = str_replace('###USER_' . $substField . '###', $recipRow[$substField], $jumpurl);
                             }
                             // Put in the tablename of the userinformation
                             $jumpurl = str_replace('###SYS_TABLE_NAME###', substr($theTable, 0, 1), $jumpurl);
                             // Put in the uid of the mail-record
                             $jumpurl = str_replace('###SYS_MAIL_ID###', $mid, $jumpurl);
                             // If authCode is provided, keep it.
                             $jumpurl = str_replace('###SYS_AUTHCODE###', $aC, $jumpurl);
                             // Auto Login an FE User, only possible if we're allowed to set the $_POST variables and
                             // in the authcode_fieldlist the field "password" is computed in as well
                             // TODO: add a switch in Direct Mail configuration to decide if this option should be enabled by default
                             if ($theTable == 'fe_users' && $aC != '' && $aC == $authCode && GeneralUtility::inList($row['authcode_fieldList'], 'password')) {
                                 $_POST['user'] = $recipRow['username'];
                                 $_POST['pass'] = $recipRow['password'];
                                 $_POST['pid'] = $recipRow['pid'];
                                 $_POST['logintype'] = 'login';
                             }
                         } else {
                             throw new \Exception('authCode: Calculated authCode did not match the submitted authCode.', 1376899631);
                         }
                     }
                 }
             }
             $db->sql_free_result($resMailing);
             if (!$jumpurl) {
                 die('Error: No further link. Please report error to the mail sender.');
             } else {
                 // jumpurl has been validated by lookup of id in direct_mail tables
                 // for this reason it is save to set the juHash
                 // set juHash as done for external_url in core: http://forge.typo3.org/issues/46071
                 GeneralUtility::_GETset(GeneralUtility::hmac($jumpurl, 'jumpurl'), 'juHash');
             }
         } else {
             // jumpUrl is not an integer -- then this is a URL, that means that the "dmailerping"
             // functionality was used to count the number of "opened mails" received (url, dmailerping)
             // Check if jumpurl is a valid link to a "dmailerping.gif"
             // Make $checkPath an absolute path pointing to dmailerping.gif so it can get checked via ::isAllowedAbsPath()
             // and remove an eventual "/" at beginning of $jumpurl (because PATH_site already contains "/" at the end)
             $checkPath = PATH_site . preg_replace('#^/#', '', $jumpurl);
             // Now check if $checkPath is a valid path and points to a "/dmailerping.gif"
             if (preg_match('#/dmailerping\\.(gif|png)$#', $checkPath) && GeneralUtility::isAllowedAbsPath($checkPath)) {
                 // set juHash as done for external_url in core: http://forge.typo3.org/issues/46071
                 GeneralUtility::_GETset(GeneralUtility::hmac($jumpurl, 'jumpurl'), 'juHash');
                 $responseType = -1;
             } elseif (GeneralUtility::isValidUrl($jumpurl) && preg_match('#^(http://|https://)#', $jumpurl)) {
                 // Also allow jumpurl to be a valid URL
                 GeneralUtility::_GETset(GeneralUtility::hmac($jumpurl, 'jumpurl'), 'juHash');
                 $responseType = -1;
             }
             // to count the dmailerping correctly, we need something unique
             $recipientUid = $aC;
         }
         if ($responseType != 0) {
             $insertFields = array('mid' => intval($mid), 'tstamp' => time(), 'url' => $jumpurl, 'response_type' => intval($responseType), 'url_id' => intval($urlId), 'rtbl' => $recipientTable, 'rid' => $recipientUid);
             $db->exec_INSERTquery('sys_dmail_maillog', $insertFields);
         }
     }
     // finally set the jumpURL to the TSFE object
     if (!empty($jumpurl)) {
         GeneralUtility::_GETset($jumpurl, 'jumpurl');
     }
 }
Example #17
0
 * script which receives ajax calls from tt_news
 *
 * @author Rupert Germann <*****@*****.**>
 * Copyright (c) 2009
 *
 * @version $Id$
 */
// Exit, if script is called directly (must be included via eID in index_ts.php)
if (!defined('PATH_typo3conf')) {
    die('Could not access this script directly!');
}
$TYPO3_AJAX = true;
//print_r(array(TYPO3_REQUESTTYPE_AJAX,TYPO3_REQUESTTYPE,TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX));
$L = intval(GeneralUtility::_GP('L'));
if ($L > 0) {
    GeneralUtility::_GETset(array('L' => $L));
}
$idAndTarget = rawurldecode(GeneralUtility::_GP('id'));
$idParts = GeneralUtility::trimExplode(' ', $idAndTarget, 1);
$id = intval($idParts[0]);
// Make new instance of TSFE
//$temp_TSFEclassName = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceClassName('tslib_fe');
//$GLOBALS['TSFE'] = new \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController (
//	$GLOBALS['TYPO3_CONF_VARS'],
//	$id,
//	\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('type'),
//	\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('no_cache'),
//	\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cHash'),
//	\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('jumpurl'),
//	\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('MP'),
//	\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('RDCT')
Example #18
0
 /**
  * Merges $_GET from domains configuration.
  *
  * @return void
  */
 protected function mergeGetVarsFromDomainsConfiguration()
 {
     // Convert the configuration into an $_GET-"friendly" format
     $getVarsToSet = $this->makeRealPhpArrayFromRequestVars($this->configuration->getGetVarsToSet());
     if (count($getVarsToSet) > 0) {
         // Overwrite with $_GET-params that $_GET-parmas have a "higher" priority
         $getVars = GeneralUtility::_GET();
         if (!is_array($getVars)) {
             $getVars = array();
         }
         ArrayUtility::mergeRecursiveWithOverrule($getVars, $getVarsToSet, true, true, false);
         // Store the "new" $_GET-params back
         GeneralUtility::_GETset($getVars);
     }
 }
Example #19
0
 /**
  * Initializes the TSFE for a given page ID and language.
  *
  * @param integer $pageId The page id to initialize the TSFE for
  * @param integer $language System language uid, optional, defaults to 0
  * @param boolean $useCache Use cache to reuse TSFE
  * @return void
  */
 public static function initializeTsfe($pageId, $language = 0, $useCache = true)
 {
     static $tsfeCache = array();
     // resetting, a TSFE instance with data from a different page Id could be set already
     unset($GLOBALS['TSFE']);
     $cacheId = $pageId . '|' . $language;
     if (!is_object($GLOBALS['TT'])) {
         $GLOBALS['TT'] = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TimeTracker\\NullTimeTracker');
     }
     if (!isset($tsfeCache[$cacheId]) || !$useCache) {
         GeneralUtility::_GETset($language, 'L');
         $GLOBALS['TSFE'] = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $pageId, 0);
         // for certain situations we need to trick TSFE into granting us
         // access to the page in any case to make getPageAndRootline() work
         // see http://forge.typo3.org/issues/42122
         $pageRecord = BackendUtility::getRecord('pages', $pageId);
         $groupListBackup = $GLOBALS['TSFE']->gr_list;
         $GLOBALS['TSFE']->gr_list = $pageRecord['fe_group'];
         $GLOBALS['TSFE']->sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
         $GLOBALS['TSFE']->getPageAndRootline();
         // restore gr_list
         $GLOBALS['TSFE']->gr_list = $groupListBackup;
         $GLOBALS['TSFE']->initTemplate();
         $GLOBALS['TSFE']->forceTemplateParsing = true;
         $GLOBALS['TSFE']->initFEuser();
         $GLOBALS['TSFE']->initUserGroups();
         // $GLOBALS['TSFE']->getCompressedTCarray(); // seems to cause conflicts sometimes
         $GLOBALS['TSFE']->no_cache = true;
         $GLOBALS['TSFE']->tmpl->start($GLOBALS['TSFE']->rootLine);
         $GLOBALS['TSFE']->no_cache = false;
         $GLOBALS['TSFE']->getConfigArray();
         $GLOBALS['TSFE']->settingLanguage();
         if (!$useCache) {
             $GLOBALS['TSFE']->settingLocale();
         }
         $GLOBALS['TSFE']->newCObj();
         $GLOBALS['TSFE']->absRefPrefix = self::getAbsRefPrefixFromTSFE($GLOBALS['TSFE']);
         $GLOBALS['TSFE']->calculateLinkVars();
         if ($useCache) {
             $tsfeCache[$cacheId] = $GLOBALS['TSFE'];
         }
     }
     if ($useCache) {
         $GLOBALS['TSFE'] = $tsfeCache[$cacheId];
         $GLOBALS['TSFE']->settingLocale();
     }
 }
 /**
  * Checks if config-array exists already but if not, gets it
  *
  * @return void
  * @todo Define visibility
  */
 public function getConfigArray()
 {
     $setStatPageName = FALSE;
     // If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it
     if (!is_array($this->config) || is_array($this->config['INTincScript']) || $this->forceTemplateParsing) {
         $GLOBALS['TT']->push('Parse template', '');
         // Force parsing, if set?:
         $this->tmpl->forceTemplateParsing = $this->forceTemplateParsing;
         // Start parsing the TS template. Might return cached version.
         $this->tmpl->start($this->rootLine);
         $GLOBALS['TT']->pull();
         if ($this->tmpl->loaded) {
             $GLOBALS['TT']->push('Setting the config-array', '');
             // toplevel - objArrayName
             $this->sPre = $this->tmpl->setup['types.'][$this->type];
             $this->pSetup = $this->tmpl->setup[$this->sPre . '.'];
             if (!is_array($this->pSetup)) {
                 $message = 'The page is not configured! [type=' . $this->type . '][' . $this->sPre . '].';
                 if ($this->checkPageUnavailableHandler()) {
                     $this->pageUnavailableAndExit($message);
                 } else {
                     $explanation = 'This means that there is no TypoScript object of type PAGE with typeNum=' . $this->type . ' configured.';
                     \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($message, 'cms', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR);
                     throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message . ' ' . $explanation, 1294587217);
                 }
             } else {
                 $this->config['config'] = array();
                 // Filling the config-array, first with the main "config." part
                 if (is_array($this->tmpl->setup['config.'])) {
                     $this->config['config'] = $this->tmpl->setup['config.'];
                 }
                 // override it with the page/type-specific "config."
                 if (is_array($this->pSetup['config.'])) {
                     $this->config['config'] = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($this->config['config'], $this->pSetup['config.']);
                 }
                 if ($this->config['config']['typolinkEnableLinksAcrossDomains']) {
                     $this->config['config']['typolinkCheckRootline'] = TRUE;
                 }
                 // Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0
                 if (\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('4.0')) {
                     if (!isset($this->config['config']['removeDefaultJS'])) {
                         $this->config['config']['removeDefaultJS'] = 'external';
                     }
                     if (!isset($this->config['config']['inlineStyle2TempFile'])) {
                         $this->config['config']['inlineStyle2TempFile'] = 1;
                     }
                 }
                 if (!isset($this->config['config']['compressJs'])) {
                     $this->config['config']['compressJs'] = 0;
                 }
                 // Processing for the config_array:
                 $this->config['rootLine'] = $this->tmpl->rootLine;
                 $this->config['mainScript'] = trim($this->config['config']['mainScript']) ? trim($this->config['config']['mainScript']) : 'index.php';
                 // Class for render Header and Footer parts
                 $template = '';
                 if ($this->pSetup['pageHeaderFooterTemplateFile']) {
                     $file = $this->tmpl->getFileName($this->pSetup['pageHeaderFooterTemplateFile']);
                     if ($file) {
                         $this->setTemplateFile($file);
                     }
                 }
             }
             $GLOBALS['TT']->pull();
         } else {
             if ($this->checkPageUnavailableHandler()) {
                 $this->pageUnavailableAndExit('No TypoScript template found!');
             } else {
                 $message = 'No TypoScript template found!';
                 \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($message, 'cms', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR);
                 throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message, 1294587218);
             }
         }
     }
     // Initialize charset settings etc.
     $this->initLLvars();
     // No cache
     // Set $this->no_cache TRUE if the config.no_cache value is set!
     if ($this->config['config']['no_cache']) {
         $this->set_no_cache();
     }
     // Merge GET with defaultGetVars
     if (!empty($this->config['config']['defaultGetVars.'])) {
         $modifiedGetVars = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule(\TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($this->config['config']['defaultGetVars.']), \TYPO3\CMS\Core\Utility\GeneralUtility::_GET());
         \TYPO3\CMS\Core\Utility\GeneralUtility::_GETset($modifiedGetVars);
     }
     // Hook for postProcessing the configuration array
     if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'])) {
         $params = array('config' => &$this->config['config']);
         foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'] as $funcRef) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
         }
     }
 }
 /**
  * Initializes all actions.
  *
  * @return void
  */
 protected function initializeAction()
 {
     Utility::checkAndPerformRequiredUpdates();
     $this->currentPageId = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('id');
     $this->databaseConnection = $GLOBALS['TYPO3_DB'];
     // Fix pagers
     $arguments = GeneralUtility::_GPmerged('tx_realurl_web_realurlrealurl');
     if ($arguments && is_array($arguments)) {
         foreach ($arguments as $argumentKey => $argumentValue) {
             if ($argumentValue) {
                 if (!in_array($argumentKey, $this->excludedArgments)) {
                     GeneralUtility::_GETset($argumentValue, 'tx_realurl_web_realurlrealurl|' . $argumentKey);
                 } else {
                     GeneralUtility::_GETset('', 'tx_realurl_web_realurlrealurl|' . $argumentKey);
                 }
             }
         }
     } else {
         $this->forwardToLastModule();
     }
     parent::initializeAction();
 }
 /**
  * @test
  */
 public function getSetCanAssignAnArrayToASpecificArrayChildElement()
 {
     $_GET = array();
     $GLOBALS['HTTP_GET_VARS'] = array();
     Utility\GeneralUtility::_GETset(array('key1' => 'value1', 'key2' => 'value2'), 'parentKey|childKey');
     $this->assertEquals(array('parentKey' => array('childKey' => array('key1' => 'value1', 'key2' => 'value2'))), $GLOBALS['HTTP_GET_VARS']);
 }
Example #23
0
 /**
  * Checks if config-array exists already but if not, gets it
  *
  * @throws ServiceUnavailableException
  * @return void
  */
 public function getConfigArray()
 {
     // If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it
     if (!is_array($this->config) || is_array($this->config['INTincScript']) || $this->forceTemplateParsing) {
         $timeTracker = $this->getTimeTracker();
         $timeTracker->push('Parse template', '');
         // Force parsing, if set?:
         $this->tmpl->forceTemplateParsing = $this->forceTemplateParsing;
         // Start parsing the TS template. Might return cached version.
         $this->tmpl->start($this->rootLine);
         $timeTracker->pull();
         if ($this->tmpl->loaded) {
             $timeTracker->push('Setting the config-array', '');
             // toplevel - objArrayName
             $this->sPre = $this->tmpl->setup['types.'][$this->type];
             $this->pSetup = $this->tmpl->setup[$this->sPre . '.'];
             if (!is_array($this->pSetup)) {
                 $message = 'The page is not configured! [type=' . $this->type . '][' . $this->sPre . '].';
                 if ($this->checkPageUnavailableHandler()) {
                     $this->pageUnavailableAndExit($message);
                 } else {
                     $explanation = 'This means that there is no TypoScript object of type PAGE with typeNum=' . $this->type . ' configured.';
                     GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
                     throw new ServiceUnavailableException($message . ' ' . $explanation, 1294587217);
                 }
             } else {
                 if (!isset($this->config['config'])) {
                     $this->config['config'] = [];
                 }
                 // Filling the config-array, first with the main "config." part
                 if (is_array($this->tmpl->setup['config.'])) {
                     ArrayUtility::mergeRecursiveWithOverrule($this->tmpl->setup['config.'], $this->config['config']);
                     $this->config['config'] = $this->tmpl->setup['config.'];
                 }
                 // override it with the page/type-specific "config."
                 if (is_array($this->pSetup['config.'])) {
                     ArrayUtility::mergeRecursiveWithOverrule($this->config['config'], $this->pSetup['config.']);
                 }
                 if ($this->config['config']['typolinkEnableLinksAcrossDomains']) {
                     $this->config['config']['typolinkCheckRootline'] = true;
                 }
                 // Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0
                 if (!isset($this->config['config']['removeDefaultJS'])) {
                     $this->config['config']['removeDefaultJS'] = 'external';
                 }
                 if (!isset($this->config['config']['inlineStyle2TempFile'])) {
                     $this->config['config']['inlineStyle2TempFile'] = 1;
                 }
                 if (!isset($this->config['config']['compressJs'])) {
                     $this->config['config']['compressJs'] = 0;
                 }
                 // Processing for the config_array:
                 $this->config['rootLine'] = $this->tmpl->rootLine;
                 $this->config['mainScript'] = trim($this->config['config']['mainScript']) ?: 'index.php';
                 if (isset($this->config['config']['mainScript']) || $this->config['mainScript'] !== 'index.php') {
                     $this->logDeprecatedTyposcript('config.mainScript', 'Setting the frontend script to something else than index.php is deprecated as of TYPO3 v8, and will not be possible in TYPO3 v9 without a custom extension');
                 }
                 // Class for render Header and Footer parts
                 if ($this->pSetup['pageHeaderFooterTemplateFile']) {
                     $file = $this->tmpl->getFileName($this->pSetup['pageHeaderFooterTemplateFile']);
                     if ($file) {
                         $this->pageRenderer->setTemplateFile($file);
                     }
                 }
             }
             $timeTracker->pull();
         } else {
             if ($this->checkPageUnavailableHandler()) {
                 $this->pageUnavailableAndExit('No TypoScript template found!');
             } else {
                 $message = 'No TypoScript template found!';
                 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
                 throw new ServiceUnavailableException($message, 1294587218);
             }
         }
     }
     // No cache
     // Set $this->no_cache TRUE if the config.no_cache value is set!
     if ($this->config['config']['no_cache']) {
         $this->set_no_cache('config.no_cache is set');
     }
     // Merge GET with defaultGetVars
     if (!empty($this->config['config']['defaultGetVars.'])) {
         $modifiedGetVars = GeneralUtility::removeDotsFromTS($this->config['config']['defaultGetVars.']);
         ArrayUtility::mergeRecursiveWithOverrule($modifiedGetVars, GeneralUtility::_GET());
         GeneralUtility::_GETset($modifiedGetVars);
     }
     // Hook for postProcessing the configuration array
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'])) {
         $params = ['config' => &$this->config['config']];
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'] as $funcRef) {
             GeneralUtility::callUserFunction($funcRef, $params, $this);
         }
     }
 }