/** * Returns information about this extension plugin * * @param array $params Parameters to the hook * * @return string Information about pi1 plugin * @hook TYPO3_CONF_VARS|SC_OPTIONS|cms/layout/class.tx_cms_layout.php|list_type_Info|calendarize_calendar */ public function getExtensionSummary(array $params) { $relIconPath = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . ExtensionManagementUtility::siteRelPath('calendarize') . 'ext_icon.png'; $this->flexFormService = GeneralUtility::makeInstance('HDNET\\Calendarize\\Service\\FlexFormService'); $this->layoutService = GeneralUtility::makeInstance('HDNET\\Calendarize\\Service\\ContentElementLayoutService'); $this->layoutService->setTitle('<img src="' . $relIconPath . '" /> Calendarize'); if ($params['row']['list_type'] != 'calendarize_calendar') { return ''; } $this->flexFormService->load($params['row']['pi_flexform']); if (!$this->flexFormService->isValid()) { return ''; } $actions = $this->flexFormService->get('switchableControllerActions', 'main'); $parts = GeneralUtility::trimExplode(';', $actions, true); $parts = array_map(function ($element) { $split = explode('->', $element); return ucfirst($split[1]); }, $parts); $actionKey = lcfirst(implode('', $parts)); $this->layoutService->addRow(LocalizationUtility::translate('mode', 'calendarize'), LocalizationUtility::translate('mode.' . $actionKey, 'calendarize')); $this->layoutService->addRow(LocalizationUtility::translate('configuration', 'calendarize'), $this->flexFormService->get('settings.configuration', 'main')); if ((bool) $this->flexFormService->get('settings.hidePagination', 'main')) { $this->layoutService->addRow(LocalizationUtility::translate('hide.pagination.teaser', 'calendarize'), '!!!'); } $this->addPageIdsToTable(); return $this->layoutService->render(); }
/** * Render the captcha image html * * @param string suffix to be appended to the extenstion key when forming css class names * @return string The html used to render the captcha image */ public function render($suffix = '') { $value = ''; // Include the required JavaScript $GLOBALS['TSFE']->additionalHeaderData[$this->extensionKey . '_freeCap'] = '<script type="text/javascript" src="' . GeneralUtility::createVersionNumberedFilename(ExtensionManagementUtility::siteRelPath($this->extensionKey) . 'Resources/Public/JavaScript/freeCap.js') . '"></script>'; // Disable caching $GLOBALS['TSFE']->no_cache = 1; // Get the plugin configuration $settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, $this->extensionName); // Get the translation view helper $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $translator = $objectManager->get('SJBR\\SrFreecap\\ViewHelpers\\TranslateViewHelper'); $translator->injectConfigurationManager($this->configurationManager); // Generate the image url $fakeId = GeneralUtility::shortMD5(uniqid(rand()), 5); $siteURL = GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); $L = GeneralUtility::_GP('L'); $urlParams = array('eID' => 'sr_freecap_EidDispatcher', 'id' => $GLOBALS['TSFE']->id, 'vendorName' => 'SJBR', 'extensionName' => 'SrFreecap', 'pluginName' => 'ImageGenerator', 'controllerName' => 'ImageGenerator', 'actionName' => 'show', 'formatName' => 'png', 'L' => $GLOBALS['TSFE']->sys_language_uid); if ($GLOBALS['TSFE']->MP) { $urlParams['MP'] = $GLOBALS['TSFE']->MP; } $urlParams['set'] = $fakeId; $imageUrl = $siteURL . 'index.php?' . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParams), '&'); // Generate the html text $value = '<img' . $this->getClassAttribute('image', $suffix) . ' id="tx_srfreecap_captcha_image_' . $fakeId . '"' . ' src="' . htmlspecialchars($imageUrl) . '"' . ' alt="' . $translator->render('altText') . ' "/>' . '<span' . $this->getClassAttribute('cant-read', $suffix) . '>' . $translator->render('cant_read1') . ' <a href="#" onclick="this.blur();' . $this->extensionName . '.newImage(\'' . $fakeId . '\', \'' . $translator->render('noImageMessage') . '\');return false;">' . $translator->render('click_here') . '</a>' . $translator->render('cant_read2') . '</span>'; return $value; }
/** * Initialize * * @return void */ protected function init() { // Initialize GPvars: $this->target = GeneralUtility::_GP('target'); $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl')); if (!$this->returnUrl) { $this->returnUrl = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . BackendUtility::getModuleUrl('file_list') . '&id=' . rawurlencode($this->target); } // Create the folder object if ($this->target) { $this->folderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->target); } if ($this->folderObject->getStorage()->getUid() === 0) { throw new \TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException('You are not allowed to access folders outside your storages', 1375889834); } // Cleaning and checking target directory if (!$this->folderObject) { $title = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:paramError', TRUE); $message = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:targetNoDir', TRUE); throw new \RuntimeException($title . ': ' . $message, 1294586843); } // Setting the title and the icon $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('apps-filetree-root'); $this->title = $icon . htmlspecialchars($this->folderObject->getStorage()->getName()) . ': ' . htmlspecialchars($this->folderObject->getIdentifier()); // Setting template object $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class); $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/file_upload.html'); $this->doc->backPath = $GLOBALS['BACK_PATH']; $this->doc->form = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_file')) . '" method="post" name="editform" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">'; }
/** * Analyses user groups * * @param array $reports * @return void */ protected function analyseUserGroups(&$reports) { /** @var \AOE\AoeIpauth\Domain\Service\FeEntityService $service */ $service = $this->objectManager->get('AOE\\AoeIpauth\\Domain\\Service\\FeEntityService'); $userGroups = $service->findAllGroupsWithIpAuthentication(); if (empty($userGroups)) { // Message that no user group has IP authentication $reports[] = $this->objectManager->get('TYPO3\\CMS\\Reports\\Status', 'IP Usergroup Authentication', 'No user groups with IP authentication found', 'No user groups were found anywhere that are active and have an automatic IP authentication enabled.' . 'Your current IP is: <strong>' . $this->myIp . '</strong>', \TYPO3\CMS\Reports\Status::INFO); } else { $thisUrl = urlencode(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')); $userGroupInfo = '<br /><br /><table cellpadding="4" cellspacing="0" border="0">'; $userGroupInfo .= '<thead><tr><th style="padding-bottom: 10px;">User Group</th><th>IP/Range</th></tr></thead>'; $userGroupInfo .= '<tbody>'; // Add user group strings foreach ($userGroups as $group) { $uid = $group['uid']; $ips = implode(', ', $group['tx_aoeipauth_ip']); $fullRecord = BackendUtility::getRecord('fe_groups', $uid); $title = $fullRecord['title']; $button = '<a title="Edit record" onclick="window.location.href=\'alt_doc.php?returnUrl=' . $thisUrl . '&edit[fe_groups][' . $uid . ']=edit\'; return false;" href="#">' . '<span class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-open"> </span>' . '</a>'; $userGroupInfo .= '<tr><td style="padding: 0 20px 0 0;">' . $button . $title . '</td><td>' . $ips . '</td></tr>'; } $userGroupInfo .= '</tbody>'; $userGroupInfo .= '</table>'; $userGroupInfo .= '<br /><br />Your current IP is: <strong>' . $this->myIp . '</strong>'; // Inform about the groups $reports[] = $this->objectManager->get('tx_reports_reports_status_Status', 'IP Usergroup Authentication', 'Some groups with automatic IP authentication were found.', $userGroupInfo, \TYPO3\CMS\Reports\Status::OK); } }
/** * Main function * Will issue a location-header, redirecting either BACK or to a new alt_doc.php instance... * * @return void * @todo Define visibility */ public function main() { // Get this record $origRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($this->P['table'], $this->P['uid']); // Get TSconfig for it. $TSconfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getTCEFORM_TSconfig($this->table, is_array($origRow) ? $origRow : array('pid' => $this->P['pid'])); // Set [params][pid] if (substr($this->P['params']['pid'], 0, 3) == '###' && substr($this->P['params']['pid'], -3) == '###') { $this->pid = intval($TSconfig['_' . substr($this->P['params']['pid'], 3, -3)]); } else { $this->pid = intval($this->P['params']['pid']); } // Make redirect: // If pid is blank OR if id is set, then return... if (!strcmp($this->pid, '') || strcmp($this->id, '')) { $redirectUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::sanitizeLocalUrl($this->P['returnUrl']); } else { // Otherwise, show the list: $urlParameters = array(); $urlParameters['id'] = $this->pid; $urlParameters['table'] = $this->P['params']['table']; $urlParameters['returnUrl'] = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'); $redirectUrl = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_list', $urlParameters); } \TYPO3\CMS\Core\Utility\HttpUtility::redirect($redirectUrl); }
/** * Load all necessary Javascript files * * @param bool $useRequireJsModule */ public function enableRsaEncryption($useRequireJsModule = false) { if ($this->moduleLoaded || !$this->isAvailable()) { return; } $this->moduleLoaded = true; $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); // Include necessary javascript files if ($useRequireJsModule) { $pageRenderer->loadRequireJsModule('TYPO3/CMS/Rsaauth/RsaEncryptionModule'); } else { // Register ajax handler url $code = 'var TYPO3RsaEncryptionPublicKeyUrl = ' . GeneralUtility::quoteJSvalue(GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'index.php?eID=RsaPublicKeyGenerationController') . ';'; $pageRenderer->addJsInlineCode('TYPO3RsaEncryptionPublicKeyUrl', $code); $javascriptPath = ExtensionManagementUtility::siteRelPath('rsaauth') . 'Resources/Public/JavaScript/'; if (!$GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['debug']) { $files = array('RsaEncryptionWithLib.min.js'); } else { $files = array('RsaLibrary.js', 'RsaEncryption.js'); } foreach ($files as $file) { $pageRenderer->addJsFile($javascriptPath . $file); } } }
/** * Initializes an anonymous template container. * The created container can be compared to "record_edit" module in backend-only disposal. * * @return void */ public function initializeTemplateContainer() { $GLOBALS['TBE_TEMPLATE'] = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\FrontendDocumentTemplate::class); $GLOBALS['TBE_TEMPLATE']->getPageRenderer()->addInlineSetting('', 'PATH_typo3', GeneralUtility::dirname(GeneralUtility::getIndpEnv('SCRIPT_NAME')) . '/' . TYPO3_mainDir); $GLOBALS['SOBE'] = new \stdClass(); $GLOBALS['SOBE']->doc = $GLOBALS['TBE_TEMPLATE']; }
/** * Render a share button * * @param boolean $loadJs * @return string */ public function render($loadJs = TRUE) { if (!empty($this->arguments['type'])) { $this->tag->addAttribute('data-type', $this->arguments['type']); $this->tag->removeAttribute('type'); } else { $this->tag->addAttribute('data-type', 'button_count'); } $shareUrl = empty($this->arguments['shareurl']) ? \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') : $this->arguments['shareurl']; $this->tag->addAttribute('data-href', $shareUrl); $this->tag->removeAttribute('shareurl'); $this->tag->addAttribute('class', 'fb-share-button'); $this->tag->setContent(' '); $code = $this->tag->render(); if ($loadJs) { $code .= '<div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/de_DE/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\'));</script>'; } // Social interaction Google Analytics if ($this->pluginSettingsService->getByPath('analytics.social.facebookShare') == 1) { $code .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS("\n\t\t\t\tFB.Event.subscribe('message.send', function(targetUrl) {\n\t\t\t\t _gaq.push(['_trackSocial', 'facebook', 'send', targetUrl]);\n\t\t\t\t});\n\t\t\t"); } return $code; }
/** * Default action. * * @return array * @throws \RuntimeException */ public function main() { $this->init(); $allowedIps = GeneralUtility::trimExplode(',', $this->config['allowedIps'], true); if ($this->config['debug']) { GeneralUtility::sysLog('Connection from ' . GeneralUtility::getIndpEnv('REMOTE_ADDR'), self::$extKey); } if ($this->config['mode'] !== 'M' || count($allowedIps) && !in_array(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $allowedIps)) { $this->denyAccess(); } // Initialize TCA (method handles if not already initialized) if (version_compare(TYPO3_version, '7.6', '>=')) { \TYPO3\CMS\Frontend\Utility\EidUtility::initTCA(); } $this->initTSFE(); if (!empty($this->config['synchronizeDeletedAccounts']) && $this->config['synchronizeDeletedAccounts']) { $additionalFields = ', deleted'; $additionalWhere = ''; } else { $additionalFields = ''; $additionalWhere = ' AND deleted=0'; } $administrators = $this->getDatabaseConnection()->exec_SELECTgetRows('username, admin, disable, realName, email, TSconfig, starttime, endtime, lang, tx_openid_openid' . $additionalFields, 'be_users', 'admin=1 AND tx_openid_openid<>\'\'' . $additionalWhere); if (count($administrators)) { $key = $this->config['preSharedKey']; $data = json_encode($administrators); $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $data, MCRYPT_MODE_CBC, md5(md5($key))); $encrypted = base64_encode($encrypted); return $encrypted; } else { throw new \RuntimeException('No administrators found', 1327586994); } }
/** * Executes the tool * * @return string Rendered content */ protected function executeAction() { if (isset($this->postValues['set']['changeEncryptionKey'])) { $this->setNewEncryptionKeyAndLogOut(); } $actionMessages = []; if (isset($this->postValues['set']['changeInstallToolPassword'])) { $actionMessages[] = $this->changeInstallToolPassword(); } if (isset($this->postValues['set']['changeSiteName'])) { $actionMessages[] = $this->changeSiteName(); } if (isset($this->postValues['set']['createAdministrator'])) { $actionMessages[] = $this->createAdministrator(); } if (isset($this->postValues['set']['clearAllCache'])) { $actionMessages[] = $this->clearAllCache(); $actionMessages[] = $this->clearOpcodeCache(); } if (isset($this->postValues['set']['dumpAutoload'])) { $actionMessages[] = $this->dumpAutoload(); } // Database analyzer handling if (isset($this->postValues['set']['databaseAnalyzerExecute']) || isset($this->postValues['set']['databaseAnalyzerAnalyze'])) { $this->loadExtLocalconfDatabaseAndExtTables(); } if (isset($this->postValues['set']['databaseAnalyzerExecute'])) { $actionMessages = array_merge($actionMessages, $this->databaseAnalyzerExecute()); } if (isset($this->postValues['set']['databaseAnalyzerAnalyze'])) { try { $actionMessages[] = $this->databaseAnalyzerAnalyze(); } catch (\TYPO3\CMS\Core\Database\Schema\Exception\StatementException $e) { $message = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Status\ErrorStatus::class); $message->setTitle('Database analysis failed'); $message->setMessage($e->getMessage()); $actionMessages[] = $message; } } $this->view->assign('actionMessages', $actionMessages); $operatingSystem = TYPO3_OS === 'WIN' ? 'Windows' : 'Unix'; $opcodeCacheService = GeneralUtility::makeInstance(OpcodeCacheService::class); /** @var \TYPO3\CMS\Install\Service\CoreUpdateService $coreUpdateService */ $coreUpdateService = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Service\CoreUpdateService::class); $this->view->assign('enableCoreUpdate', $coreUpdateService->isCoreUpdateEnabled())->assign('composerMode', Bootstrap::usesComposerClassLoading())->assign('operatingSystem', $operatingSystem)->assign('cgiDetected', GeneralUtility::isRunningOnCgiServerApi())->assign('extensionCompatibilityTesterProtocolFile', GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3temp/assets/ExtensionCompatibilityTester.txt')->assign('extensionCompatibilityTesterErrorProtocolFile', GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'typo3temp/assets/ExtensionCompatibilityTesterErrors.json')->assign('extensionCompatibilityTesterMessages', $this->getExtensionCompatibilityTesterMessages())->assign('listOfOpcodeCaches', $opcodeCacheService->getAllActive()); $connectionInfos = []; $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); foreach ($connectionPool->getConnectionNames() as $connectionName) { $connection = $connectionPool->getConnectionByName($connectionName); $connectionParameters = $connection->getParams(); $connectionInfo = ['connectionName' => $connectionName, 'version' => $connection->getServerVersion(), 'databaseName' => $connection->getDatabase(), 'username' => $connection->getUsername(), 'host' => $connection->getHost(), 'port' => $connection->getPort(), 'socket' => $connectionParameters['unix_socket'] ?? '', 'numberOfTables' => count($connection->getSchemaManager()->listTables()), 'numberOfMappedTables' => 0]; if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping']) && is_array($GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping'])) { // Count number of array keys having $connectionName as value $connectionInfo['numberOfMappedTables'] = count(array_intersect($GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping'], [$connectionName])); } $connectionInfos[] = $connectionInfo; } $this->view->assign('connections', $connectionInfos); return $this->view->render(); }
/** * Render a share button * * @param string $title Title for share * @param string $text Title for share * @param string $shareUrl Title for share * @return string */ public function render($title = NULL, $text = NULL, $shareUrl = NULL) { // check defaults if (empty($this->arguments['name'])) { $this->tag->addAttribute('name', 'fb_share'); } if (empty($this->arguments['type'])) { $this->tag->addAttribute('type', 'link'); } if (empty($this->arguments['target'])) { $this->tag->addAttribute('target', '_blank'); } $url = 'https://twitter.com/intent/tweet'; $url .= '?original_referer=' . urldecode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')); $url .= '&url='; if ($shareUrl) { $url .= urldecode($shareUrl); } else { $url .= urldecode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')); } if ($title) { $url .= '&p[title]=' . urldecode($title); } if ($text) { $url .= '&text=' . urldecode($text); } $this->tag->addAttribute('href', $url); $this->tag->setContent($this->renderChildren()); return $this->tag->render(); }
/** * Error handling if no news entry is found * * @param string $configuration configuration what will be done * @throws InvalidArgumentException * @return void */ protected function handleNoNewsFoundError($configuration) { if (empty($configuration)) { return; } $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $configuration, TRUE); switch ($configuration[0]) { case 'redirectToListView': $this->redirect('list'); break; case 'redirectToPage': if (count($configuration) === 1 || count($configuration) > 3) { $msg = sprintf('If error handling "%s" is used, either 2 or 3 arguments, split by "," must be used', $configuration[0]); throw new InvalidArgumentException($msg); } $this->uriBuilder->reset(); $this->uriBuilder->setTargetPageUid($configuration[1]); $this->uriBuilder->setCreateAbsoluteUri(TRUE); if (\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) { $this->uriBuilder->setAbsoluteUriScheme('https'); } $url = $this->uriBuilder->build(); if (isset($configuration[2])) { $this->redirectToUri($url, 0, (int) $configuration[2]); } else { $this->redirectToUri($url); } break; case 'pageNotFoundHandler': $GLOBALS['TSFE']->pageNotFoundAndExit('No news entry found.'); break; default: // Do nothing, it might be handled in the view. } }
/** * Main Function * * @param array $params * @param object $pObj * @return string */ public function getInfo($params = array(), $pObj) { // settings $confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['powermail']); if ($confArr['disablePluginInformation']) { return ''; } $this->params = $params; // $returnUrl = 'alt_doc.php?edit[tt_content][' . $pa['row']['uid'] . ']=edit&returnUrl=' . GeneralUtility::_GET('returnUrl'); // $returnUrl = rawurlencode($returnUrl); $returnUrl = rawurlencode(Div::getSubFolderOfCurrentUrl() . GeneralUtility::getIndpEnv('TYPO3_SITE_SCRIPT')); $editFormLink = Div::getSubFolderOfCurrentUrl() . 'typo3/alt_doc.php?edit[tx_powermail_domain_model_forms][' . $this->getFormProperty($this->getFieldFromFlexform('main', 'settings.flexform.main.form'), 'uid') . ']=edit'; $editFormLink .= '&returnUrl=' . $returnUrl; // let's go $array = array($GLOBALS['LANG']->sL($this->locallangPath . 'receiverEmail') => $this->getFieldFromFlexform('receiver', 'settings.flexform.receiver.email'), $GLOBALS['LANG']->sL($this->locallangPath . 'receiverName') => $this->getFieldFromFlexform('receiver', 'settings.flexform.receiver.name'), $GLOBALS['LANG']->sL($this->locallangPath . 'subject') => $this->getFieldFromFlexform('receiver', 'settings.flexform.receiver.subject'), $GLOBALS['LANG']->sL($this->locallangPath . 'form') => '<a href="' . $editFormLink . '" style="text-decoration:underline;">' . $this->getFormProperty($this->getFieldFromFlexform('main', 'settings.flexform.main.form')) . '</a>', $GLOBALS['LANG']->sL($this->locallangPath . 'confirmationPage') => '<img src="' . Div::getSubFolderOfCurrentUrl() . 'typo3conf/ext/powermail/Resources/Public/Image/icon-check.png" alt="1" />', $GLOBALS['LANG']->sL($this->locallangPath . 'optin') => '<img src="' . Div::getSubFolderOfCurrentUrl() . 'typo3conf/ext/powermail/Resources/Public/Image/icon-check.png" alt="1" />'); if (!$this->getFieldFromFlexform('main', 'settings.flexform.main.confirmation')) { $array[$GLOBALS['LANG']->sL($this->locallangPath . 'confirmationPage')] = '<img src="' . Div::getSubFolderOfCurrentUrl() . 'typo3conf/ext/powermail/Resources/Public/Image/icon-notchecked.png" alt="0" />'; } if (!$this->getFieldFromFlexform('main', 'settings.flexform.main.optin')) { $array[$GLOBALS['LANG']->sL($this->locallangPath . 'optin')] = '<img src="' . Div::getSubFolderOfCurrentUrl() . 'typo3conf/ext/powermail/Resources/Public/Image/icon-notchecked.png" alt="0" />'; } if ($this->showTable) { return $this->createOutput($array); } return ''; }
/** * getVideoData * * @param $settings * @return */ public function getVideoData($settings) { $this->fullURL = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); //$this->cObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_cObj'); $limit = ''; if (isset($settings['limit']) && $settings['limit'] > 0) { $limit = $settings['limit']; } $field = 'uid, upload_video, alttag, background_image'; $table = 'tx_video_domain_model_videos'; $orderBy = ' uid asc '; //$groupBy = " "; $where = ' '; if (isset($settings['storagePID']) && $settings['storagePID'] != '') { $where .= ' AND pid in (' . $settings['storagePID'] . ') '; } $where = ' deleted = 0 AND hidden = 0' . $where; $conf = $this->getDBHandle()->exec_SELECTgetRows($field, $table, $where, $groupBy, $orderBy, $limit); // echo $this->getDBHandle()->SELECTquery($field,$table,$where,$groupBy,$orderBy,$limit); die; $data = array(); foreach ($conf as $key => $value) { $data[$value['uid']] = $value; if ($value['background_image'] > 0) { $field1 = 'uid'; $table1 = 'sys_file_reference'; $where1 = ' tablenames = \'tx_video_domain_model_videos\' AND fieldname = \'backgroundImage\' AND uid_foreign = \'' . $value['uid'] . '\' AND deleted = 0 AND hidden = 0'; $res = $this->getDBHandle()->exec_SELECTgetRows($field1, $table1, $where1); $data[$value['uid']]['imageReference'] = $res[0]['uid']; } } return $data; }
/** * Constructor for initializing the class * * @return void * @todo Define visibility */ public function init() { // Initialize GPvars: $this->target = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('target'); $this->returnUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::sanitizeLocalUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('returnUrl')); if (!$this->returnUrl) { $this->returnUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('file_list') . '&id=' . rawurlencode($this->target); } // Create the folder object if ($this->target) { $this->folderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->target); } // Cleaning and checking target directory if (!$this->folderObject) { $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE); $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE); throw new \RuntimeException($title . ': ' . $message, 1294586843); } // Setting the title and the icon $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('apps-filetree-root'); $this->title = $icon . htmlspecialchars($this->folderObject->getStorage()->getName()) . ': ' . htmlspecialchars($this->folderObject->getIdentifier()); // Setting template object $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); $this->doc->setModuleTemplate('templates/file_upload.html'); $this->doc->backPath = $GLOBALS['BACK_PATH']; $this->doc->form = '<form action="tce_file.php" method="post" name="editform" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">'; }
/** * Hooks to the felogin extension to provide additional code for FE login * * @return array 0 => onSubmit function, 1 => extra fields and required files */ public function loginFormHook() { $result = array(0 => '', 1 => ''); if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['loginSecurityLevel']) === 'rsa') { $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend(); if ($backend) { $result[0] = 'tx_rsaauth_feencrypt(this);'; $javascriptPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('rsaauth') . 'resources/'; $files = array('jsbn/jsbn.js', 'jsbn/prng4.js', 'jsbn/rng.js', 'jsbn/rsa.js', 'jsbn/base64.js', 'rsaauth_min.js'); foreach ($files as $file) { $result[1] .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>'; } // Generate a new key pair $keyPair = $backend->createNewKeyPair(); // Save private key $storage = \TYPO3\CMS\Rsaauth\Storage\StorageFactory::getStorage(); /** @var $storage \TYPO3\CMS\Rsaauth\Storage\AbstractStorage */ $storage->put($keyPair->getPrivateKey()); // Add RSA hidden fields $result[1] .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />'; $result[1] .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />'; } } return $result; }
/** * @param int $pageId * @param array $additionalParams * @return string */ public function getFullUrl($pageId, array $additionalParams = NULL) { $domainName = $this->getDomainName($pageId); // Mount point overlay: Set new target page id and mp parameter /** @var PageRepository $sysPage */ $sysPage = GeneralUtility::makeInstance(PageRepository::class); $sysPage->init(FALSE); $mountPointMpParameter = ''; $finalPageIdToShow = $pageId; $mountPointInformation = $sysPage->getMountPointInfo($pageId); if ($mountPointInformation && $mountPointInformation['overlay']) { // New page id $finalPageIdToShow = $mountPointInformation['mount_pid']; $mountPointMpParameter = '&MP=' . $mountPointInformation['MPvar']; } // Modify relative path to protocol with host if domain record is given $protocolAndHost = '..'; if ($domainName) { $protocol = 'http'; $page = (array) $sysPage->getPage($finalPageIdToShow); if ($page['url_scheme'] == 2 || $page['url_scheme'] == 0 && GeneralUtility::getIndpEnv('TYPO3_SSL')) { $protocol = 'https'; } $protocolAndHost = $protocol . '://' . $domainName; } $mountPointMpParameter .= $this->addAdditionalParams($additionalParams); $url = $protocolAndHost . '/index.php?id=' . $finalPageIdToShow . $this->getTypeParameterIfSet($finalPageIdToShow) . $mountPointMpParameter; return $url; }
/** * Initialize * * @throws InsufficientFolderAccessPermissionsException */ protected function init() { // Initialize GPvars: $this->target = GeneralUtility::_GP('target'); $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl')); if (!$this->returnUrl) { $this->returnUrl = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . BackendUtility::getModuleUrl('file_list') . '&id=' . rawurlencode($this->target); } // Create the folder object if ($this->target) { $this->folderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->target); } if ($this->folderObject->getStorage()->getUid() === 0) { throw new InsufficientFolderAccessPermissionsException('You are not allowed to access folders outside your storages', 1375889834); } // Cleaning and checking target directory if (!$this->folderObject) { $title = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:paramError', true); $message = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:targetNoDir', true); throw new \RuntimeException($title . ': ' . $message, 1294586843); } // Setting up the context sensitive menu $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu'); // building pathInfo for metaInformation $pathInfo = ['combined_identifier' => $this->folderObject->getCombinedIdentifier()]; $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($pathInfo); }
/** * The main method called by the controller * * @return array The probably modified GET/POST parameters */ public function process() { if ($this->settings['type'] == 'city') { $queryStringCode = 'f'; } else { $queryStringCode = 'a'; } $maxmindAccountId = $this->settings['maxMindId']; $ip = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'); if ($this->settings['debugForceIp']) { $ip = $this->settings['debugForceIp']; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://geoip3.maxmind.com/' . $queryStringCode . '?l=' . $maxmindAccountId . '&i=' . $ip); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result = curl_exec($ch); switch ($queryStringCode) { case 'f': $array = explode(',', $result); foreach ($this->settings['resultArrayFieldMapping.'] as $index => $name) { $this->gp[$name] = $array[$index]; } break; case 'a': $this->gp[$this->settings['resultStringField']] = $result; break; } return $this->gp; }
/** * Render the facebook like viewhelper * * @return string */ public function render() { $code = ''; $url = !empty($this->arguments['href']) ? $this->arguments['href'] : \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'); // absolute urls are needed $this->tag->addAttribute('href', Tx_MooxNews_Utility_Url::prependDomain($url)); $this->tag->forceClosingTag(TRUE); // -1 means no JS if ($this->arguments['javaScript'] != '-1') { if (empty($this->arguments['javaScript'])) { $tsSettings = $this->pluginSettingsService->getSettings(); $locale = !empty($tsSettings['facebookLocale']) ? $tsSettings['facebookLocale'] : 'en_US'; $code = '<script src="https://connect.facebook.net/' . $locale . '/all.js#xfbml=1"></script>'; // Social interaction Google Analytics if ($this->pluginSettingsService->getByPath('analytics.social.facebookLike') == 1) { $code .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS("\n\t\t\t\t\t\tFB.Event.subscribe('edge.create', function(targetUrl) {\n\t\t\t\t\t\t \t_gaq.push(['_trackSocial', 'facebook', 'like', targetUrl]);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tFB.Event.subscribe('edge.remove', function(targetUrl) {\n\t\t\t\t\t\t _gaq.push(['_trackSocial', 'facebook', 'unlike', targetUrl]);\n\t\t\t\t\t\t});\n\t\t\t\t\t"); } } else { $code = '<script src="' . htmlspecialchars($this->arguments['javaScript']) . '"></script>'; } } // seems as if a div with id fb-root is needed this is just a dirty // workaround to make things work again Perhaps we should // use the iframe variation. $code .= '<div id="fb-root"></div>' . $this->tag->render(); return $code; }
/** * Constructor * * @param ContentObjectRenderer $contentObject The current cObject. If NULL a new instance will be created * @throws \InvalidArgumentException * @throws \UnexpectedValueException */ public function __construct(ContentObjectRenderer $contentObject = null) { $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); /** @var ConfigurationManagerInterface $configurationManager */ $configurationManager = $this->objectManager->get(ConfigurationManagerInterface::class); if ($contentObject === null) { /** @var ContentObjectRenderer $contentObject */ $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class); } $configurationManager->setContentObject($contentObject); /** @var WebRequest $request */ $request = $this->objectManager->get(WebRequest::class); $request->setRequestUri(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')); $request->setBaseUri(GeneralUtility::getIndpEnv('TYPO3_SITE_URL')); /** @var UriBuilder $uriBuilder */ $uriBuilder = $this->objectManager->get(UriBuilder::class); $uriBuilder->setRequest($request); /** @var ControllerContext $controllerContext */ $controllerContext = $this->objectManager->get(ControllerContext::class); $controllerContext->setRequest($request); $controllerContext->setUriBuilder($uriBuilder); $renderingContext = $this->objectManager->get(RenderingContext::class, $this); $renderingContext->setControllerContext($controllerContext); $this->setRenderingContext($renderingContext); }
/** * Handles any backend request * * @param ServerRequestInterface $request * @return NULL|ResponseInterface */ public function handleRequest(ServerRequestInterface $request) { // enable dispatching via Request/Response logic only for typo3/index.php // This fallback will be removed in TYPO3 CMS 8, as only index.php will be allowed $path = substr($request->getUri()->getPath(), strlen(GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'))); $routingEnabled = $path === TYPO3_mainDir . 'index.php' || $path === TYPO3_mainDir; $proceedIfNoUserIsLoggedIn = false; if ($routingEnabled) { $pathToRoute = (string) $request->getQueryParams()['route']; // Allow the login page to be displayed if routing is not used and on index.php if (empty($pathToRoute)) { $pathToRoute = '/login'; } $request = $request->withAttribute('routePath', $pathToRoute); // Evaluate the constant for skipping the BE user check for the bootstrap // should be handled differently in the future by checking the Bootstrap directly if ($pathToRoute === '/login') { $proceedIfNoUserIsLoggedIn = true; } } $this->boot($proceedIfNoUserIsLoggedIn); // Check if the router has the available route and dispatch. if ($routingEnabled) { return $this->dispatch($request); } // No route found, so the system proceeds in called entrypoint as fallback. return null; }
/** * Render a share button * * @param string $title * @param string $text * @param string $image * @param string $shareUrl * * @return string */ public function render($title = NULL, $text = NULL, $image = NULL, $shareUrl = NULL) { // check defaults if (empty($this->arguments['name'])) { $this->tag->addAttribute('name', 'fb_share'); } if (empty($this->arguments['type'])) { $this->tag->addAttribute('type', 'link'); } if (empty($this->arguments['target'])) { $this->tag->addAttribute('target', '_blank'); } $url = 'https://www.facebook.com/sharer/sharer.php?s=100&p[url]='; if ($shareUrl) { $url .= urldecode($shareUrl); } else { $url .= urldecode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')); } if ($title) { $url .= '&p[title]=' . urldecode($title); } if ($text) { $url .= '&p[summary]=' . urldecode($text); } if ($image) { $url .= '&p[images][0]=' . urldecode($image); } $this->tag->addAttribute('href', $url); $this->tag->setContent($this->renderChildren()); return $this->tag->render(); }
/** * Prepend current url if url is relative * * @param string $url given url * @return string */ public static function prependDomain($url) { if (!GeneralUtility::isFirstPartOfStr($url, GeneralUtility::getIndpEnv('TYPO3_SITE_URL'))) { $url = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $url; } return $url; }
/** * Provides form code and javascript for the user setup. * * @param array $parameters Parameters to the script * @param \TYPO3\CMS\Setup\Controller\SetupModuleController $userSetupObject Calling object: user setup module * @return string The code for the user setup */ public function getLoginScripts(array $parameters, \TYPO3\CMS\Setup\Controller\SetupModuleController $userSetupObject) { $content = ''; if ($this->isRsaAvailable()) { // If we can get the backend, we can proceed $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend(); $javascriptPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('rsaauth') . 'resources/'; $files = array('jsbn/jsbn.js', 'jsbn/prng4.js', 'jsbn/rng.js', 'jsbn/rsa.js', 'jsbn/base64.js', 'rsaauth_min.js'); $content = ''; foreach ($files as $file) { $content .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>'; } // Generate a new key pair $keyPair = $backend->createNewKeyPair(); // Save private key $storage = \TYPO3\CMS\Rsaauth\Storage\StorageFactory::getStorage(); /** @var $storage \TYPO3\CMS\Rsaauth\Storage\AbstractStorage */ $storage->put($keyPair->getPrivateKey()); // Add form tag $form = '<form action="' . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('user_setup') . '" method="post" name="usersetup" enctype="application/x-www-form-urlencoded" onsubmit="tx_rsaauth_encryptUserSetup();">'; // Add RSA hidden fields $form .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />'; $form .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />'; $userSetupObject->doc->form = $form; } return $content; }
/** * Constructor. Starts PHP session handling in our own private store * * Side-effect: might set a cookie, so must be called before any other output. */ public function __construct() { $this->typo3tempPath = PATH_site . 'typo3temp/'; // Start our PHP session early so that hasSession() works $sessionSavePath = $this->getSessionSavePath(); // Register our "save" session handler session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc')); session_save_path($sessionSavePath); session_name($this->cookieName); ini_set('session.cookie_path', GeneralUtility::getIndpEnv('TYPO3_SITE_PATH')); // Always call the garbage collector to clean up stale session files ini_set('session.gc_probability', 100); ini_set('session.gc_divisor', 100); ini_set('session.gc_maxlifetime', $this->expireTimeInMinutes * 2 * 60); if (\TYPO3\CMS\Core\Utility\PhpOptionsUtility::isSessionAutoStartEnabled()) { $sessionCreationError = 'Error: session.auto-start is enabled.<br />'; $sessionCreationError .= 'The PHP option session.auto-start is enabled. Disable this option in php.ini or .htaccess:<br />'; $sessionCreationError .= '<pre>php_value session.auto_start Off</pre>'; throw new \TYPO3\CMS\Install\Exception($sessionCreationError, 1294587485); } elseif (defined('SID')) { $sessionCreationError = 'Session already started by session_start().<br />'; $sessionCreationError .= 'Make sure no installed extension is starting a session in its ext_localconf.php or ext_tables.php.'; throw new \TYPO3\CMS\Install\Exception($sessionCreationError, 1294587486); } session_start(); }
/** * This method renders the report * * @return string The status report as HTML */ public function getReport() { $actionURL = tx_additionalreports_util::getBaseUrl() . '&cmd=deleteAll'; $content = '<a href="' . $actionURL . '"><img src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_DIR') . '../typo3conf/ext/additional_reports/Resources/Public/Icons/garbage.gif"/> ' . $GLOBALS['LANG']->getLL('flushalllog') . '</a>'; $content .= tx_additionalreports_main::displayRealUrlErrors(); return $content; }
/** * Render a share button * * @param boolean $loadJs * @return string */ public function render($loadJs = TRUE) { // check defaults if (empty($this->arguments['href'])) { $this->tag->addAttribute('href', 'https://www.facebook.com/sharer/sharer.php'); } if (empty($this->arguments['name'])) { $this->tag->addAttribute('name', 'fb_share'); } if (empty($this->arguments['type'])) { $this->tag->addAttribute('type', 'button_count'); } $shareUrl = empty($this->arguments['shareurl']) ? \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') : $this->arguments['shareurl']; $this->tag->addAttribute('share_url', $shareUrl); $this->tag->removeAttribute('shareurl'); $this->tag->setContent($this->renderChildren()); $code = $this->tag->render(); if ($loadJs) { $code .= '<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>'; } // Social interaction Google Analytics if ($this->pluginSettingsService->getByPath('analytics.social.facebookShare') == 1) { $code .= \TYPO3\CMS\Core\Utility\GeneralUtility::wrapJS("\n\t\t\t\tFB.Event.subscribe('message.send', function(targetUrl) {\n\t\t\t\t _gaq.push(['_trackSocial', 'facebook', 'send', targetUrl]);\n\t\t\t\t});\n\t\t\t"); } return $code; }
/** * Determine the url to view * * @return string */ protected function getTargetUrl() { $pageIdToShow = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'); $adminCommand = $this->getAdminCommand($pageIdToShow); $domainName = $this->getDomainName($pageIdToShow); // Mount point overlay: Set new target page id and mp parameter /** @var \TYPO3\CMS\Frontend\Page\PageRepository $sysPage */ $sysPage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $sysPage->init(FALSE); $mountPointMpParameter = ''; $finalPageIdToShow = $pageIdToShow; $mountPointInformation = $sysPage->getMountPointInfo($pageIdToShow); if ($mountPointInformation && $mountPointInformation['overlay']) { // New page id $finalPageIdToShow = $mountPointInformation['mount_pid']; $mountPointMpParameter = '&MP=' . $mountPointInformation['MPvar']; } // Modify relative path to protocol with host if domain record is given $protocolAndHost = '..'; if ($domainName) { $protocol = 'http'; $page = (array) $sysPage->getPage($finalPageIdToShow); if ($page['url_scheme'] == 2 || $page['url_scheme'] == 0 && \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) { $protocol = 'https'; } $protocolAndHost = $protocol . '://' . $domainName; } $url = $protocolAndHost . '/index.php?id=' . $finalPageIdToShow . $this->getTypeParameterIfSet($finalPageIdToShow) . $mountPointMpParameter . $adminCommand; return $url; }
/** * @test */ public function extractHyperLinksRecurnsCorrectPathWithBaseUrl() { $baseURL = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); $html = 'test <a href="' . $baseURL . 'index.php">test</a> test'; $result = $this->fixture->extractHyperLinks($html); $this->assertEquals(1, count($result)); $this->assertEquals(PATH_site . 'index.php', $result[0]['localPath']); }