/** * Writes the GD font file * * @param \SJBR\SrFreecap\Domain\Model\Font the object to be stored * @return \SJBR\SrFreecap\Domain\Repository\FontRepository $this */ public function writeFontFile(\SJBR\SrFreecap\Domain\Model\Font $font) { $relativeFileName = 'uploads/' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($this->extensionKey) . '/' . $font->getGdFontFilePrefix() . '_' . \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($font->getGdFontData()) . '.gdf'; if (\TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_site . $relativeFileName, $font->getGdFontData())) { $font->setGdFontFileName($relativeFileName); } return $this; }
/** * @test * @param string $extensionName * @param string $expectedPrefix * @dataProvider extensionKeyDataProvider */ public function getClassNamePrefixForExtensionKey($extensionName, $expectedPrefix) { $this->assertSame($expectedPrefix, ExtensionManagementUtility::getCN($extensionName)); }
protected function loadViewHelper($helperKey) { if (isset($this->loadedHelperFiles[strtolower($helperKey)])) { return $this->loadedHelperFiles[strtolower($helperKey)]['class']; } foreach ($this->viewHelperIncludePath as $extensionKey => $viewHelperPath) { $viewHelperRealPath = $viewHelperPath; if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($viewHelperPath, 'Classes/')) { $viewHelperRealPath = substr($viewHelperPath, 8); } if (substr($viewHelperRealPath, -1) == '/') { $viewHelperRealPath = substr($viewHelperRealPath, 0, -1); } $classNamePrefix = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($extensionKey); $possibleFilename = Tx_Solr_Util::underscoredToUpperCamelCase($helperKey) . '.php'; $possibleClassName = $classNamePrefix . '_' . str_replace('/', '_', $viewHelperRealPath) . '_' . Tx_Solr_Util::underscoredToUpperCamelCase($helperKey); $viewHelperIncludePath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey) . $viewHelperPath . $possibleFilename; if (file_exists($viewHelperIncludePath)) { include_once $viewHelperIncludePath; $this->loadedHelperFiles[strtolower($helperKey)] = array('file' => $viewHelperIncludePath, 'class' => $possibleClassName); return $possibleClassName; } } // viewhelper could not be found return FALSE; }
/** * @param array $files * @return void */ protected function appendTypoScriptConfiguration(&$files) { $extensionKey = $this->getExtensionKeyFromSettings(); $templateVariables = array('extension' => $extensionKey, 'signature' => ExtensionManagementUtility::getCN($extensionKey)); $folder = $this->targetFolder . '/Configuration/TypoScript'; $files[$folder . '/constants.txt'] = $this->getPreparedCodeTemplate(self::TEMPLATE_TYPOSCRIPTCONSTANTS, $templateVariables)->render(); $files[$folder . '/setup.txt'] = $this->getPreparedCodeTemplate(self::TEMPLATE_TYPOSCRIPTSETUP, $templateVariables)->render(); }
<?php if (!defined('TYPO3_MODE')) { die('Access denied.'); } $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = "EXT:" . $_EXTKEY . "/hooks/class.tx_gorillary_collection_save_hook.php:&tx_gorillary_collection_save_hook"; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = "EXT:" . $_EXTKEY . "/hooks/class.tx_gorillary_feedimport_save_hook.php:&tx_gorillary_feedimport_save_hook"; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['tceformsInlineHook'][] = "EXT:" . $_EXTKEY . "/hooks/class.tx_gorillary_tceformsInlineHook.php:&tx_gorillary_tceformsInlineHook"; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'pi1/class.tx_gorillary_pi1.php', '_pi1', 'list_type', 1); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'pi2/class.tx_gorillary_pi2.php', '_pi2', 'list_type', 1); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript($_EXTKEY, 'setup', ' tt_content.shortcut.20.0.conf.tx_gorillary_images = < plugin.' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_pi1 tt_content.shortcut.20.0.conf.tx_gorillary_images.CMD = singleView ', 43);
/** * Reviews and adjusts plugin settings * * @return void * @api */ protected function processSettings() { // Image type: // possible values: "jpg", "png", "gif" // jpg doesn't support transparency (transparent bg option ends up white) // png isn't supported by old browsers (see http://www.libpng.org/pub/png/pngstatus.html) // gif may not be supported by your GD Lib. $this->settings['imageFormat'] = $this->settings['imageFormat'] ? $this->settings['imageFormat'] : 'png'; // true = generate pseudo-random string, false = use dictionary // dictionary is easier to recognise // - both for humans and computers, so use random string if you're paranoid. $this->settings['useWordsList'] = $this->settings['useWordsList'] ? TRUE : FALSE; // if your server is NOT set up to deny web access to files beginning ".ht" // then you should ensure the dictionary file is kept outside the web directory // eg: if www.foo.com/index.html points to c:\website\www\index.html // then the dictionary should be placed in c:\website\dict.txt // test your server's config by trying to access the dictionary through a web browser // you should NOT be able to view the contents. // can leave this blank if not using dictionary $this->settings['wordsListLocation'] = \SJBR\SrFreecap\Utility\LocalizationUtility::getWordsListLocation($this->settings['defaultWordsList']); // Used for non-dictionary word generation and to calculate image width $this->settings['maxWordLength'] = $this->settings['maxWordLength'] ? $this->settings['maxWordLength'] : 6; // Maximum times a user can refresh the image // on a 6500 word dictionary, I think 15-50 is enough to not annoy users and make BF unfeasble. // further notes re: BF attacks in "avoid brute force attacks" section, below // on the other hand, those attempting OCR will find the ability to request new images // very useful; if they can't crack one, just grab an easier target... // for the ultra-paranoid, setting it to <5 will still work for most users $this->settings['maxAttempts'] = $this->settings['maxAttempts'] ? $this->settings['maxAttempts'] : 50; // List of fonts to use // font size should be around 35 pixels wide for each character. // you can use my GD fontmaker script at www.puremango.co.uk to create your own fonts // There are other programs to can create GD fonts, but my script allows a greater // degree of control over exactly how wide each character is, and is therefore // recommended for 'special' uses. For normal use of GD fonts, // the GDFontGenerator @ http://www.philiplb.de is excellent for convering ttf to GD // the fonts included with freeCap *only* include lowercase alphabetic characters // so are not suitable for most other uses // to increase security, you really should add other fonts if ($this->settings['generateNumbers']) { $this->settings['fontLocations'] = array('EXT:' . $this->extensionKey . '/Resources/Private/Captcha/Fonts/anonymous.gdf'); } else { $this->settings['fontLocations'] = array('EXT:' . $this->extensionKey . '/Resources/Private/Captcha/Fonts/freecap_font1.gdf', 'EXT:' . $this->extensionKey . '/Resources/Private/Captcha/Fonts/freecap_font2.gdf', 'EXT:' . $this->extensionKey . '/Resources/Private/Captcha/Fonts/freecap_font3.gdf', 'EXT:' . $this->extensionKey . '/Resources/Private/Captcha/Fonts/freecap_font4.gdf', 'EXT:' . $this->extensionKey . '/Resources/Private/Captcha/Fonts/freecap_font5.gdf'); } if ($this->settings['fontFiles']) { $this->settings['fontLocations'] = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->settings['fontFiles'], 1); } for ($i = 0; $i < sizeof($this->settings['fontLocations']); $i++) { if (substr($this->settings['fontLocations'][$i], 0, 4) == 'EXT:') { $this->settings['fontLocations'][$i] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->settings['fontLocations'][$i]); } else { $this->settings['fontLocations'][$i] = PATH_site . 'uploads/' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($this->extensionKey) . '/' . $this->settings['fontLocations'][$i]; } } // Text color // 0 = one random color for all letters // 1 = different random color for each letter if ($this->settings['textColor']) { $this->settings['textColor'] = 1; } else { $this->settings['textColor'] = 0; } // Text position $this->settings['textPosition'] = array(); $this->settings['textPosition']['horizontal'] = $this->settings['textHorizontalPosition'] ? intval($this->settings['textHorizontalPosition']) : 32; $this->settings['textPosition']['vertical'] = $this->settings['textVerticalPosition'] ? intval($this->settings['textVerticalPosition']) : 15; // Text morphing factor $this->settings['morphFactor'] = $this->settings['morphFactor'] ? $this->settings['morphFactor'] : 0; // Limits for text color $this->settings['colorMaximum'] = array(); if (isset($this->settings['colorMaximumDarkness'])) { $this->settings['colorMaximum']['darkness'] = intval($this->settings['colorMaximumDarkness']); } if (isset($this->settings['colorMaximumLightness'])) { $this->settings['colorMaximum']['lightness'] = intval($this->settings['colorMaximumLightness']); } // Background // Many thanks to http://ocr-research.org.ua and http://sam.zoy.org/pwntcha/ for testing // for jpgs, 'transparent' is white if (!in_array($this->settings['backgroundType'], array('Transparent', 'White with grid', 'White with squiggles', 'Morphed image blocks'))) { $this->settings['backgroundType'] = 'White with grid'; } // Should we blur the background? (looks nicer, makes text easier to read, takes longer) $this->settings['backgroundBlur'] = $this->settings['backgroundBlur'] || !isset($this->settings['backgroundBlur']) ? TRUE : FALSE; // For background type 'Morphed image blocks', which images should we use? // If you add your own, make sure they're fairly 'busy' images (ie a lot of shapes in them) $this->settings['backgroundImages'] = array('EXT:' . $this->extensionKey . '/Resources/Private/Captcha/Images/freecap_im1.jpg', 'EXT:' . $this->extensionKey . '/Resources/Private/Captcha/Images/freecap_im2.jpg', 'EXT:' . $this->extensionKey . '/Resources/Private/Captcha/Images/freecap_im3.jpg', 'EXT:' . $this->extensionKey . '/Resources/Private/Captcha/Images/freecap_im4.jpg', 'EXT:' . $this->extensionKey . '/Resources/Private/Captcha/Images/freecap_im5.jpg'); // For non-transparent backgrounds only: // if 0, merges CAPTCHA with background // if 1, write CAPTCHA over background $this->settings['mergeWithBackground'] = $this->settings['mergeWithBackground'] ? 0 : 1; // Should we morph the background? (recommend yes, but takes a little longer to compute) $this->settings['backgroundMorph'] = $this->settings['backgroundMorph'] ? TRUE : FALSE; // Read each font and get font character widths $this->settings['fontWidths'] = array(); for ($i = 0; $i < sizeof($this->settings['fontLocations']); $i++) { $handle = fopen($this->settings['fontLocations'][$i], "r"); // Read header of GD font, up to char width $c_wid = fread($handle, 12); $this->settings['fontWidths'][$i] = ord($c_wid[8]) + ord($c_wid[9]) + ord($c_wid[10]) + ord($c_wid[11]); fclose($handle); } // Modify image width depending on maximum possible length of word // you shouldn't need to use words > 6 chars in length really. $this->settings['imageWidth'] = $this->settings['maxWordLength'] * (array_sum($this->settings['fontWidths']) / sizeof($this->settings['fontWidths'])) + (isset($this->settings['imageAdditionalWidth']) ? intval($this->settings['imageAdditionalWidth']) : 40); $this->settings['imageHeight'] = $this->settings['imageHeight'] ? $this->settings['imageHeight'] : 90; // Try to avoid the 'free p*rn' method of CAPTCHA circumvention // see www.wikipedia.com/captcha for more info // "To avoid spam, please do NOT enter the text if this site is not example.org"; // or more simply: // "for use only on example.org"; // reword or add lines as you please $this->settings['siteTag'] = $this->settings['siteTag'] ? explode('|', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('site_tag', $this->extensionName, isset($this->settings['siteTagDomain']) ? $this->settings['siteTagDomain'] : 'example.org')) : array(); // where to write the above: // 0=top // 1=bottom // 2=both $this->settings['siteTagPosition'] = isset($this->settings['siteTagPosition']) ? $this->settings['siteTagPosition'] : 1; }
protected function loadViewHelper($helperKey) { if (isset($this->loadedHelperFiles[strtolower($helperKey)])) { return $this->loadedHelperFiles[strtolower($helperKey)]['class']; } foreach ($this->viewHelperIncludePath as $extensionKey => $viewHelperPath) { $viewHelperRealPath = $viewHelperPath; if (GeneralUtility::isFirstPartOfStr($viewHelperPath, 'Classes/')) { $viewHelperRealPath = substr($viewHelperPath, 8); } if (substr($viewHelperRealPath, -1) == '/') { $viewHelperRealPath = substr($viewHelperRealPath, 0, -1); } $classNamePrefix = ExtensionManagementUtility::getCN($extensionKey); //FIXME for PHP 5.4.32, 5.5.16: $classNamePrefix = ucwords($classNamePrefix, '_'); $classNamePrefix = explode('_', $classNamePrefix); $classNamePrefix = array_map('ucfirst', $classNamePrefix); $classNamePrefix = implode('_', $classNamePrefix); $possibleFilename = Util::underscoredToUpperCamelCase($helperKey) . '.php'; $possibleClassName = $classNamePrefix . '_' . str_replace('/', '_', $viewHelperRealPath) . '_' . Util::underscoredToUpperCamelCase($helperKey); $viewHelperIncludePath = ExtensionManagementUtility::extPath($extensionKey) . $viewHelperPath . $possibleFilename; if (file_exists($viewHelperIncludePath)) { include_once $viewHelperIncludePath; $this->loadedHelperFiles[strtolower($helperKey)] = array('file' => $viewHelperIncludePath, 'class' => $possibleClassName); return $possibleClassName; } } // view helper could not be found return FALSE; }
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'plugins/navigation/class.tx_dlf_navigation.php', '_navigation', 'list_type', TRUE); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'plugins/oai/class.tx_dlf_oai.php', '_oai', 'list_type', FALSE); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'plugins/pagegrid/class.tx_dlf_pagegrid.php', '_pagegrid', 'list_type', TRUE); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'plugins/pageview/class.tx_dlf_pageview.php', '_pageview', 'list_type', TRUE); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'plugins/search/class.tx_dlf_search.php', '_search', 'list_type', TRUE); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'plugins/statistics/class.tx_dlf_statistics.php', '_statistics', 'list_type', TRUE); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'plugins/toc/class.tx_dlf_toc.php', '_toc', 'list_type', TRUE); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'plugins/toolbox/class.tx_dlf_toolbox.php', '_toolbox', 'list_type', TRUE); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'plugins/validator/class.tx_dlf_validator.php', '_validator', 'list_type', FALSE); // Register tools for toolbox plugin. \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'plugins/toolbox/tools/fulltext/class.tx_dlf_toolsFulltext.php', '_toolsFulltext', '', TRUE); $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/plugins/toolbox/tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_toolsFulltext'] = 'LLL:EXT:dlf/locallang.xml:tx_dlf_toolbox.toolsFulltext'; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'plugins/toolbox/tools/imagemanipulation/class.tx_dlf_toolsImagemanipulation.php', '_toolsImagemanipulation', '', TRUE); $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/plugins/toolbox/tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_toolsImagemanipulation'] = 'LLL:EXT:dlf/locallang.xml:tx_dlf_toolbox.toolsImagemanipulation'; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPItoST43($_EXTKEY, 'plugins/toolbox/tools/pdf/class.tx_dlf_toolsPdf.php', '_toolsPdf', '', TRUE); $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/plugins/toolbox/tools'][\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getCN($_EXTKEY) . '_toolsPdf'] = 'LLL:EXT:dlf/locallang.xml:tx_dlf_toolbox.toolsPdf'; // Register hooks. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:' . $_EXTKEY . '/hooks/class.tx_dlf_tcemain.php:tx_dlf_tcemain'; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = 'EXT:' . $_EXTKEY . '/hooks/class.tx_dlf_tcemain.php:tx_dlf_tcemain'; $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/common/class.tx_dlf_document.php']['hookClass'][] = 'EXT:' . $_EXTKEY . '/hooks/class.tx_dlf_hacks.php:tx_dlf_hacks'; // Register command line scripts. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys'][$_EXTKEY] = array('EXT:' . $_EXTKEY . '/cli/class.tx_dlf_cli.php', '_CLI_dlf'); // Register AJAX eID handlers. $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_dlf_search_suggest'] = 'EXT:' . $_EXTKEY . '/plugins/search/class.tx_dlf_search_suggest.php'; $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_dlf_fulltext_eid'] = 'EXT:' . $_EXTKEY . '/plugins/pageview/class.tx_dlf_fulltext_eid.php'; if (TYPO3_MODE === 'FE') { /* * docTypeCheck user function to use in Typoscript * * @access public *