本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::shortMD5方法的具体用法?PHP GeneralUtility::shortMD5怎么用?PHP GeneralUtility::shortMD5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::shortMD5方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: createHash
/**
* Create Hash from String and TYPO3 Encryption Key
*
* @param string $string Any String
* @return string Hashed String
*/
protected static function createHash($string)
{
if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
$string .= $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
}
return GeneralUtility::shortMD5($string);
}
示例3: importCommand
/**
* Import command
*
* @param string $icsCalendarUri
* @param int $pid
*/
public function importCommand($icsCalendarUri = NULL, $pid = NULL)
{
if ($icsCalendarUri === NULL || !filter_var($icsCalendarUri, FILTER_VALIDATE_URL)) {
$this->enqueueMessage('You have to enter a valid URL to the iCalendar ICS', 'Error', FlashMessage::ERROR);
}
if (!MathUtility::canBeInterpretedAsInteger($pid)) {
$this->enqueueMessage('You have to enter a valid PID for the new created elements', 'Error', FlashMessage::ERROR);
}
// fetch external URI and write to file
$this->enqueueMessage('Start to checkout the calendar: ' . $icsCalendarUri, 'Calendar', FlashMessage::INFO);
$relativeIcalFile = 'typo3temp/ical.' . GeneralUtility::shortMD5($icsCalendarUri) . '.ical';
$absoluteIcalFile = GeneralUtility::getFileAbsFileName($relativeIcalFile);
$content = GeneralUtility::getUrl($icsCalendarUri);
GeneralUtility::writeFile($absoluteIcalFile, $content);
// get Events from file
$icalEvents = $this->getIcalEvents($absoluteIcalFile);
$this->enqueueMessage('Found ' . sizeof($icalEvents) . ' events in the given calendar', 'Items', FlashMessage::INFO);
$events = $this->prepareEvents($icalEvents);
$this->enqueueMessage('This is just a first draft. There are same missing fields. Will be part of the next release', 'Items', FlashMessage::ERROR);
return;
foreach ($events as $event) {
$eventObject = $this->eventRepository->findOneByImportId($event['uid']);
if ($eventObject instanceof Event) {
// update
$eventObject->setTitle($event['title']);
$eventObject->setDescription($this->nl2br($event['description']));
$this->eventRepository->update($eventObject);
$this->enqueueMessage('Update Event Meta data: ' . $eventObject->getTitle(), 'Update');
} else {
// create
$eventObject = new Event();
$eventObject->setPid($pid);
$eventObject->setImportId($event['uid']);
$eventObject->setTitle($event['title']);
$eventObject->setDescription($this->nl2br($event['description']));
$configuration = new Configuration();
$configuration->setType(Configuration::TYPE_TIME);
$configuration->setFrequency(Configuration::FREQUENCY_NONE);
/** @var \DateTime $startDate */
$startDate = clone $event['start'];
$startDate->setTime(0, 0, 0);
$configuration->setStartDate($startDate);
/** @var \DateTime $endDate */
$endDate = clone $event['end'];
$endDate->setTime(0, 0, 0);
$configuration->setEndDate($endDate);
$startTime = $this->dateTimeToDaySeconds($event['start']);
if ($startTime > 0) {
$configuration->setStartTime($startTime);
$configuration->setEndTime($this->dateTimeToDaySeconds($event['end']));
$configuration->setAllDay(FALSE);
} else {
$configuration->setAllDay(TRUE);
}
$eventObject->addCalendarize($configuration);
$this->eventRepository->add($eventObject);
$this->enqueueMessage('Add Event: ' . $eventObject->getTitle(), 'Add');
}
}
}
示例4: main_parseTreeCallBack
/**
* Call back function for page tree traversal!
*
* @param string $tableName Table name
* @param int $uid UID of record in processing
* @param int $echoLevel Echo level (see calling function
* @param string $versionSwapmode Version swap mode on that level (see calling function
* @param int $rootIsVersion Is root version (see calling function
* @return void
*/
public function main_parseTreeCallBack($tableName, $uid, $echoLevel, $versionSwapmode, $rootIsVersion)
{
foreach ($GLOBALS['TCA'][$tableName]['columns'] as $colName => $config) {
if ($config['config']['type'] == 'flex') {
if ($echoLevel > 2) {
echo LF . ' [cleanflexform:] Field "' . $colName . '" in ' . $tableName . ':' . $uid . ' was a flexform and...';
}
$recRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw($tableName, 'uid=' . (int) $uid);
$flexObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class);
if ($recRow[$colName]) {
// Clean XML:
$newXML = $flexObj->cleanFlexFormXML($tableName, $colName, $recRow);
if (md5($recRow[$colName]) != md5($newXML)) {
if ($echoLevel > 2) {
echo ' was DIRTY, needs cleanup!';
}
$this->cleanFlexForm_dirtyFields[\TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($tableName . ':' . $uid . ':' . $colName)] = $tableName . ':' . $uid . ':' . $colName;
} else {
if ($echoLevel > 2) {
echo ' was CLEAN';
}
}
} elseif ($echoLevel > 2) {
echo ' was EMPTY';
}
}
}
}
示例5: createRealTestdir
/**
* Creates a "real" directory for doing tests. This is neccessary because some file system properties (e.g. permissions)
* cannot be reflected by vfsStream, and some methods (like touch()) don't work there either.
*
* Created directories are automatically destroyed by the tearDownAfterClass() method.
*
* @return string
*/
protected function createRealTestdir()
{
$basedir = PATH_site . 'typo3temp/fal-test-' . \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5(microtime(TRUE));
mkdir($basedir);
self::$testDirs[] = $basedir;
return $basedir;
}
示例6: importCommand
/**
* Import command
*
* @param string $icsCalendarUri
* @param int $pid
*/
public function importCommand($icsCalendarUri = null, $pid = null)
{
if ($icsCalendarUri === null || !filter_var($icsCalendarUri, FILTER_VALIDATE_URL)) {
$this->enqueueMessage('You have to enter a valid URL to the iCalendar ICS', 'Error', FlashMessage::ERROR);
return;
}
if (!MathUtility::canBeInterpretedAsInteger($pid)) {
$this->enqueueMessage('You have to enter a valid PID for the new created elements', 'Error', FlashMessage::ERROR);
return;
}
// fetch external URI and write to file
$this->enqueueMessage('Start to checkout the calendar: ' . $icsCalendarUri, 'Calendar', FlashMessage::INFO);
$relativeIcalFile = 'typo3temp/ical.' . GeneralUtility::shortMD5($icsCalendarUri) . '.ical';
$absoluteIcalFile = GeneralUtility::getFileAbsFileName($relativeIcalFile);
$content = GeneralUtility::getUrl($icsCalendarUri);
GeneralUtility::writeFile($absoluteIcalFile, $content);
// get Events from file
$icalEvents = $this->getIcalEvents($absoluteIcalFile);
$this->enqueueMessage('Found ' . sizeof($icalEvents) . ' events in the given calendar', 'Items', FlashMessage::INFO);
$events = $this->prepareEvents($icalEvents);
$this->enqueueMessage('Found ' . sizeof($events) . ' events in ' . $icsCalendarUri, 'Items', FlashMessage::INFO);
/** @var Dispatcher $signalSlotDispatcher */
$signalSlotDispatcher = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
$this->enqueueMessage('Send the ' . __CLASS__ . '::importCommand signal for each event.', 'Signal', FlashMessage::INFO);
foreach ($events as $event) {
$arguments = ['event' => $event, 'commandController' => $this, 'pid' => $pid, 'handled' => false];
$signalSlotDispatcher->dispatch(__CLASS__, 'importCommand', $arguments);
}
}
示例7: writeFontFile
/**
* 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;
}
示例8: extractHyperLinksReturnsCorrectFileUsingT3Vars
/**
* @test
*/
public function extractHyperLinksReturnsCorrectFileUsingT3Vars()
{
$this->temporaryFileName = tempnam(sys_get_temp_dir(), 't3unit-');
$html = 'test <a href="testfile">test</a> test';
$GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = array(\TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5('testfile') => $this->temporaryFileName);
$result = $this->fixture->extractHyperLinks($html);
$this->assertEquals(1, count($result));
$this->assertEquals($this->temporaryFileName, $result[0]['localPath']);
}
示例9: wrapClickMenuOnIcon
/**
* @param $str
* @param $table
* @param string $uid
* @return string
*/
private function wrapClickMenuOnIcon($str, $table, $uid = '')
{
$listFr = 1;
$addParams = '';
$enDisItems = '';
$returnOnClick = FALSE;
$backPath = rawurlencode($GLOBALS['BACK_PATH']) . '|' . \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($GLOBALS['BACK_PATH'] . '|' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
$onClick = 'showClickmenu("' . $table . '","' . $uid . '","' . $listFr . '","' . str_replace('+', '%2B', $enDisItems) . '","' . str_replace('&', '&', addcslashes($backPath, '"')) . '","' . str_replace('&', '&', addcslashes($addParams, '"')) . '");return false;';
return $returnOnClick ? $onClick : '<a href="#" onclick="' . htmlspecialchars($onClick) . '" oncontextmenu="' . htmlspecialchars($onClick) . '">' . $str . '</a>';
}
示例10: extractHyperLinksReturnsCorrectFileUsingT3Vars
/**
* @test
*/
public function extractHyperLinksReturnsCorrectFileUsingT3Vars()
{
$temporaryFileName = tempnam(PATH_site . 'typo3temp/var/tests/', 't3unit-');
$this->testFilesToDelete[] = $temporaryFileName;
$html = 'test <a href="testfile">test</a> test';
$GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = array(\TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5('testfile') => $temporaryFileName);
$result = $this->subject->extractHyperLinks($html);
$this->assertEquals(1, count($result));
$this->assertEquals($temporaryFileName, $result[0]['localPath']);
}
示例11: main
/**
* Find lost files in uploads/ folder
* FIX METHOD: Simply delete the file...
*
* @todo Add parameter to exclude filepath
* @todo Add parameter to list more file names/patterns to ignore
* @todo Add parameter to include RTEmagic images
*
* @return array
*/
public function main()
{
// Initialize result array:
$resultArray = array('message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'], 'headers' => array('managedFiles' => array('Files related to TYPO3 records and managed by TCEmain', 'These files you definitely want to keep.', 0), 'ignoredFiles' => array('Ignored files (index.html, .htaccess etc.)', 'These files are allowed in uploads/ folder', 0), 'RTEmagicFiles' => array('RTE magic images - those found (and ignored)', 'These files are also allowed in some uploads/ folders as RTEmagic images.', 0), 'lostFiles' => array('Lost files - those you can delete', 'You can delete these files!', 3), 'warnings' => array('Warnings picked up', '', 2)), 'managedFiles' => array(), 'ignoredFiles' => array(), 'RTEmagicFiles' => array(), 'lostFiles' => array(), 'warnings' => array());
// Get all files:
$fileArr = array();
$fileArr = \TYPO3\CMS\Core\Utility\GeneralUtility::getAllFilesAndFoldersInPath($fileArr, PATH_site . 'uploads/');
$fileArr = \TYPO3\CMS\Core\Utility\GeneralUtility::removePrefixPathFromList($fileArr, PATH_site);
$excludePaths = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->cli_argValue('--excludePath', 0), true);
// Traverse files and for each, look up if its found in the reference index.
foreach ($fileArr as $key => $value) {
$include = true;
foreach ($excludePaths as $exclPath) {
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($value, $exclPath)) {
$include = false;
}
}
$shortKey = \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($value);
if ($include) {
// First, allow "index.html", ".htaccess" files since they are often used for good reasons
if (substr($value, -11) == '/index.html' || substr($value, -10) == '/.htaccess') {
unset($fileArr[$key]);
$resultArray['ignoredFiles'][$shortKey] = $value;
} else {
// Looking for a reference from a field which is NOT a soft reference (thus, only fields with a proper TCA/Flexform configuration)
$recs = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('_FILE', 'sys_refindex') . ' AND ref_string=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, 'sys_refindex') . ' AND softref_key=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('', 'sys_refindex'), '', 'sorting DESC');
// If found, unset entry:
if (count($recs)) {
unset($fileArr[$key]);
$resultArray['managedFiles'][$shortKey] = $value;
if (count($recs) > 1) {
$resultArray['warnings'][$shortKey] = 'Warning: File "' . $value . '" had ' . count($recs) . ' references from group-fields, should have only one!';
}
} else {
// When here it means the file was not found. So we test if it has a RTEmagic-image name and if so, we allow it:
if (preg_match('/^RTEmagic[P|C]_/', basename($value))) {
unset($fileArr[$key]);
$resultArray['RTEmagicFiles'][$shortKey] = $value;
} else {
// We conclude that the file is lost...:
unset($fileArr[$key]);
$resultArray['lostFiles'][$shortKey] = $value;
}
}
}
}
}
asort($resultArray['ignoredFiles']);
asort($resultArray['managedFiles']);
asort($resultArray['RTEmagicFiles']);
asort($resultArray['lostFiles']);
asort($resultArray['warnings']);
// $fileArr variable should now be empty with all contents transferred to the result array keys.
return $resultArray;
}
示例12: testLocalPathWithT3Vars
/**
* Checks that using t3vars returns correct file
*
* @return void
*/
public function testLocalPathWithT3Vars()
{
$this->temporaryFileName = tempnam(sys_get_temp_dir(), 't3unit-');
$html = 'test <a href="testfile">test</a> test';
$savedValue = $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'];
$GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = array(\TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5('testfile') => $this->temporaryFileName);
$result = $this->indexer->extractHyperLinks($html);
$GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = $savedValue;
$this->assertEquals(1, count($result), 'Wrong number of parsed links');
$this->assertEquals($result[0]['localPath'], $this->temporaryFileName, 'Local path is incorrect');
}
示例13: toArray
/**
* Get the ICS events in an array
*
* @param string $paramUrl
*
* @return array
*/
function toArray($paramUrl)
{
$tempFileName = GeneralUtility::getFileAbsFileName('typo3temp/calendarize_temp_' . GeneralUtility::shortMD5($paramUrl));
if (filemtime($tempFileName) < time() - 60 * 60) {
$icsFile = GeneralUtility::getUrl($paramUrl);
GeneralUtility::writeFile($tempFileName, $icsFile);
}
$backend = new ICalParser();
if ($backend->parseFromFile($tempFileName)) {
return $backend->getEvents();
}
return array();
}
示例14: toArray
/**
* Get the ICS events in an array
*
* @param string $paramUrl
*
* @return array
*/
function toArray($paramUrl)
{
$tempFileName = $this->getCheckedCacheFolder() . GeneralUtility::shortMD5($paramUrl);
if (!is_file($tempFileName) || filemtime($tempFileName) < time() - DateTimeUtility::SECONDS_HOUR) {
$icsFile = GeneralUtility::getUrl($paramUrl);
GeneralUtility::writeFile($tempFileName, $icsFile);
}
$backend = new ICalParser();
if ($backend->parseFromFile($tempFileName)) {
return $backend->getEvents();
}
return [];
}
示例15: render
/**
* Entry method
*
* @return array As defined in initializeResultArray() of AbstractNode
*/
public function render()
{
$languageService = $this->getLanguageService();
$table = $this->data['tableName'];
$row = $this->data['databaseRow'];
$fieldName = $this->data['fieldName'];
// field name of the flex form field in DB
$parameterArray = $this->data['parameterArray'];
$flexFormDataStructureArray = $this->data['flexFormDataStructureArray'];
$flexFormCurrentLanguage = $this->data['flexFormCurrentLanguage'];
$flexFormRowData = $this->data['flexFormRowData'];
$resultArray = $this->initializeResultArray();
$resultArray['requireJsModules'][] = 'TYPO3/CMS/Backend/Tabs';
$domIdPrefix = 'DTM-' . GeneralUtility::shortMD5($this->data['parameterArray']['itemFormElName'] . $flexFormCurrentLanguage);
$tabCounter = 0;
$tabElements = array();
foreach ($flexFormDataStructureArray['sheets'] as $sheetName => $sheetDataStructure) {
$flexFormRowSheetDataSubPart = $flexFormRowData['data'][$sheetName][$flexFormCurrentLanguage];
if (!is_array($sheetDataStructure['ROOT']['el'])) {
$resultArray['html'] .= LF . 'No Data Structure ERROR: No [\'ROOT\'][\'el\'] found for sheet "' . $sheetName . '".';
continue;
}
$tabCounter++;
// Assemble key for loading the correct CSH file
// @todo: what is that good for? That is for the title of single elements ... see FlexFormElementContainer!
$dsPointerFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['ds_pointerField'], true);
$parameterArray['_cshKey'] = $table . '.' . $fieldName;
foreach ($dsPointerFields as $key) {
if ((string) $row[$key] !== '') {
$parameterArray['_cshKey'] .= '.' . $row[$key];
}
}
$options = $this->data;
$options['flexFormDataStructureArray'] = $sheetDataStructure['ROOT']['el'];
$options['flexFormRowData'] = $flexFormRowSheetDataSubPart;
$options['flexFormFormPrefix'] = '[data][' . $sheetName . '][' . $flexFormCurrentLanguage . ']';
$options['parameterArray'] = $parameterArray;
// Merge elements of this tab into a single list again and hand over to
// palette and single field container to render this group
$options['tabAndInlineStack'][] = array('tab', $domIdPrefix . '-' . $tabCounter);
$options['renderType'] = 'flexFormElementContainer';
$childReturn = $this->nodeFactory->create($options)->render();
$tabElements[] = array('label' => !empty($sheetDataStructure['ROOT']['sheetTitle']) ? $languageService->sL($sheetDataStructure['ROOT']['sheetTitle']) : $sheetName, 'content' => $childReturn['html'], 'description' => $sheetDataStructure['ROOT']['sheetDescription'] ? $languageService->sL($sheetDataStructure['ROOT']['sheetDescription']) : '', 'linkTitle' => $sheetDataStructure['ROOT']['sheetShortDescr'] ? $languageService->sL($sheetDataStructure['ROOT']['sheetShortDescr']) : '');
$childReturn['html'] = '';
$resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $childReturn);
}
// Feed everything to document template for tab rendering
$resultArray['html'] = $this->renderTabMenu($tabElements, $domIdPrefix);
return $resultArray;
}