本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::hmac方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::hmac方法的具体用法?PHP GeneralUtility::hmac怎么用?PHP GeneralUtility::hmac使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::hmac方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Render method
*
* @param string $action Target action
* @param array $arguments Arguments
* @param string $controller Target controller. If NULL current controllerName is used
* @param string $extensionName Target Extension Name (without "tx_" prefix and no underscores). If NULL the current
* extension name is used
* @param string $pluginName Target plugin. If empty, the current plugin name is used
* @param integer $pageUid target page. See TypoLink destination
* @param integer $pageType type of the target page. See typolink.parameter
* @param boolean $noCache set this to disable caching for the target page. You should not need this.
* @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink.
* @param string $section the anchor to be added to the URI
* @param string $format The requested format, e.g. ".html
* @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages
* will still link to the page even though the page cannot be accessed.
* @param array $additionalParams additional query parameters that won't be prefixed like
* $arguments (overrule $arguments)
* @param boolean $absolute If set, the URI of the rendered link is absolute
* @param boolean $addQueryString If set, the current query parameters will be kept in the URI
* @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI.
* Only active if $addQueryString = TRUE
* @param string $addQueryStringMethod Set which parameters will be kept. Only active if $addQueryString = TRUE
*
* @return string Rendered link
*/
public function render($action = null, array $arguments = [], $controller = null, $extensionName = null, $pluginName = null, $pageUid = null, $pageType = 0, $noCache = false, $noCacheHash = false, $section = '', $format = '', $linkAccessRestrictedPages = false, array $additionalParams = [], $absolute = false, $addQueryString = false, array $argumentsToBeExcludedFromQueryString = [], $addQueryStringMethod = null)
{
if ($action !== null && $arguments !== null && isset($arguments['user'])) {
$arguments['hash'] = GeneralUtility::hmac($action . '::' . $arguments['user']);
}
return parent::render($action, $arguments, $controller, $extensionName, $pluginName, $pageUid, $pageType, $noCache, $noCacheHash, $section, $format, $linkAccessRestrictedPages, $additionalParams, $absolute, $addQueryString, $argumentsToBeExcludedFromQueryString, $addQueryStringMethod);
}
示例2: findById
/**
* @param string $listenerId
* @return object
*/
public function findById($listenerId)
{
if ($listenerId) {
$object = parent::findById($listenerId);
if (!$object) {
list($table, $uid, $rawListenerId) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('-', $listenerId, false, 3);
// try to generate the listener cache
if ($table == 'tt_content' && $uid) {
$object = $this->serviceContent->generateListenerCacheForContentElement($table, $uid);
} elseif ($table == 'h' || $table == 'hInt') {
$settingsHash = $uid;
$encodedSettings = $rawListenerId;
if (\TYPO3\CMS\Core\Utility\GeneralUtility::hmac($encodedSettings) == $settingsHash) {
$loadContentFromTypoScript = str_replace('---', '.', $encodedSettings);
$eventsToListen = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('e');
$object = $this->serviceContent->generateListenerCacheForHijaxPi1($loadContentFromTypoScript, $eventsToListen[$listenerId], $table == 'h');
}
}
if ($table == 'f') {
$settingsHash = $uid;
$encodedSettings = $rawListenerId;
if (\TYPO3\CMS\Core\Utility\GeneralUtility::hmac($encodedSettings) == $settingsHash) {
$fallbackTypoScriptConfiguration = str_replace('---', '.', $encodedSettings);
$object = $this->serviceContent->generateListenerCacheForTypoScriptFallback($fallbackTypoScriptConfiguration);
}
}
}
return $object;
} else {
return null;
}
}
示例3: render
/**
* Create a link to a file that forces a download
*
* @param \TYPO3\CMS\Core\Resource\FileInterface $file
* @param bool $uriOnly
* @return string
*/
public function render(\TYPO3\CMS\Core\Resource\FileInterface $file, $uriOnly = FALSE)
{
$queryParameterArray = array('eID' => 'dumpFile', 't' => '');
if ($file instanceof \TYPO3\CMS\Core\Resource\File) {
$queryParameterArray['f'] = $file->getUid();
$queryParameterArray['t'] = 'f';
} elseif ($file instanceof \TYPO3\CMS\Core\Resource\ProcessedFile) {
$queryParameterArray['p'] = $file->getUid();
$queryParameterArray['t'] = 'p';
}
$queryParameterArray['token'] = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac(implode('|', $queryParameterArray), 'resourceStorageDumpFile');
$queryParameterArray['download'] = '';
$uri = 'index.php?' . str_replace('+', '%20', http_build_query($queryParameterArray));
// Add absRefPrefix
if (!empty($GLOBALS['TSFE'])) {
$uri = $GLOBALS['TSFE']->absRefPrefix . $uri;
}
if ($uriOnly) {
return $uri;
}
$this->tag->addAttribute('href', $uri);
$this->tag->setContent($this->renderChildren());
$this->tag->forceClosingTag(TRUE);
return $this->tag->render();
}
示例4: render
/**
* Handler for unknown types.
*
* @return array As defined in initializeResultArray() of AbstractNode
*/
public function render()
{
$resultArray = $this->initializeResultArray();
$languageService = $this->getLanguageService();
$row = $this->data['databaseRow'];
$parameterArray = $this->data['parameterArray'];
// If ratios are set do not add default options
if (isset($parameterArray['fieldConf']['config']['ratios'])) {
unset($this->defaultConfig['ratios']);
}
$config = ArrayUtility::arrayMergeRecursiveOverrule($this->defaultConfig, $parameterArray['fieldConf']['config']);
// By default we allow all image extensions that can be handled by the GFX functionality
if ($config['allowedExtensions'] === null) {
$config['allowedExtensions'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
}
if ($config['readOnly']) {
$options = array();
$options['parameterArray'] = array('fieldConf' => array('config' => $config), 'itemFormElValue' => $parameterArray['itemFormElValue']);
$options['renderType'] = 'none';
return $this->nodeFactory->create($options)->render();
}
$file = $this->getFile($row, $config['file_field']);
if (!$file) {
return $resultArray;
}
$content = '';
$preview = '';
if (GeneralUtility::inList(mb_strtolower($config['allowedExtensions']), mb_strtolower($file->getExtension()))) {
// Get preview
$preview = $this->getPreview($file, $parameterArray['itemFormElValue']);
// Check if ratio labels hold translation strings
foreach ((array) $config['ratios'] as $ratio => $label) {
$config['ratios'][$ratio] = $languageService->sL($label, true);
}
$formFieldId = StringUtility::getUniqueId('formengine-image-manipulation-');
$wizardData = array('zoom' => $config['enableZoom'] ? '1' : '0', 'ratios' => json_encode($config['ratios']), 'file' => $file->getUid());
$wizardData['token'] = GeneralUtility::hmac(implode('|', $wizardData), 'ImageManipulationWizard');
$buttonAttributes = array('data-url' => BackendUtility::getAjaxUrl('wizard_image_manipulation', $wizardData), 'data-severity' => 'notice', 'data-image-name' => $file->getNameWithoutExtension(), 'data-image-uid' => $file->getUid(), 'data-file-field' => $config['file_field'], 'data-field' => $formFieldId);
$button = '<button class="btn btn-default t3js-image-manipulation-trigger"';
foreach ($buttonAttributes as $key => $value) {
$button .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
}
$button .= '><span class="t3-icon fa fa-crop"></span>';
$button .= $languageService->sL('LLL:EXT:lang/locallang_wizards.xlf:imwizard.open-editor', true);
$button .= '</button>';
$inputField = '<input type="hidden" ' . 'id="' . $formFieldId . '" ' . 'name="' . $parameterArray['itemFormElName'] . '" ' . 'value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
$content .= $inputField . $button;
$content .= $this->getImageManipulationInfoTable($parameterArray['itemFormElValue']);
$resultArray['requireJsModules'][] = array('TYPO3/CMS/Backend/ImageManipulation' => 'function(ImageManipulation){ImageManipulation.initializeTrigger()}');
}
$content .= '<p class="text-muted"><em>' . $languageService->sL('LLL:EXT:lang/locallang_wizards.xlf:imwizard.supported-types-message', true) . '<br />';
$content .= mb_strtoupper(implode(', ', GeneralUtility::trimExplode(',', $config['allowedExtensions'])));
$content .= '</em></p>';
$item = '<div class="media">';
$item .= $preview;
$item .= '<div class="media-body">' . $content . '</div>';
$item .= '</div>';
$resultArray['html'] = $item;
return $resultArray;
}
示例5: init
/**
* Initialiation of the script class
*
* @return void
*/
protected function init()
{
// Setting backPath
$this->backPath = $GLOBALS['BACK_PATH'];
// Setting GPvars:
$this->currentSubScript = GeneralUtility::_GP('currentSubScript');
$this->cMR = GeneralUtility::_GP('cMR');
$scopeData = (string) GeneralUtility::_GP('scopeData');
$scopeHash = (string) GeneralUtility::_GP('scopeHash');
if (!empty($scopeData) && GeneralUtility::hmac($scopeData) === $scopeHash) {
$this->scopeData = unserialize($scopeData);
}
// Create folder tree object:
if (!empty($this->scopeData)) {
$this->foldertree = GeneralUtility::makeInstance($this->scopeData['class']);
$this->foldertree->thisScript = $this->scopeData['script'];
$this->foldertree->ext_noTempRecyclerDirs = $this->scopeData['ext_noTempRecyclerDirs'];
$GLOBALS['SOBE']->browser = new \stdClass();
$GLOBALS['SOBE']->browser->mode = $this->scopeData['browser']['mode'];
$GLOBALS['SOBE']->browser->act = $this->scopeData['browser']['act'];
} else {
$this->foldertree = GeneralUtility::makeInstance('TYPO3\\CMS\\Filelist\\FileListFolderTree');
$this->foldertree->thisScript = 'alt_file_navframe.php';
}
$this->foldertree->ext_IconMode = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu');
}
示例6: tokenFromSessionDataIsAvailableForValidateToken
/**
* @test
*/
public function tokenFromSessionDataIsAvailableForValidateToken()
{
$sessionToken = '881ffea2159ac72182557b79dc0c723f5a8d20136f9fab56cdd4f8b3a1dbcfcd';
$formName = 'foo';
$action = 'edit';
$formInstanceName = '42';
$tokenId = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac($formName . $action . $formInstanceName . $sessionToken);
$this->backendUserMock->expects($this->atLeastOnce())->method('getSessionData')->with('formProtectionSessionToken')->will($this->returnValue($sessionToken));
$this->assertTrue($this->subject->validateToken($tokenId, $formName, $action, $formInstanceName));
}
示例7: tokenFromSessionDataIsAvailableForValidateToken
/**
* @test
*/
public function tokenFromSessionDataIsAvailableForValidateToken()
{
$sessionToken = '881ffea2159ac72182557b79dc0c723f5a8d20136f9fab56cdd4f8b3a1dbcfcd';
$formName = 'foo';
$action = 'edit';
$formInstanceName = '42';
$tokenId = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac($formName . $action . $formInstanceName . $sessionToken);
$_SESSION['installToolFormToken'] = $sessionToken;
$this->fixture->_call('retrieveSessionToken');
$this->assertTrue($this->fixture->validateToken($tokenId, $formName, $action, $formInstanceName));
}
示例8: PMiconATagWrap
/**
* Wrap the plus/minus icon in a link
*
* @param string $icon HTML string to wrap, probably an image tag.
* @param string $cmd Command for 'PM' get var
* @param boolean $isExpand If expanded
* @return string Link-wrapped input string
* @access private
*/
public function PMiconATagWrap($icon, $cmd, $isExpand = TRUE)
{
if (empty($this->scope)) {
$this->scope = array('class' => get_class($this), 'script' => $this->thisScript, 'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs, 'browser' => array('mode' => $GLOBALS['SOBE']->browser->mode, 'act' => $GLOBALS['SOBE']->browser->act, 'editorNo' => $GLOBALS['SOBE']->browser->editorNo));
}
if ($this->thisScript) {
// Activates dynamic AJAX based tree
$scopeData = serialize($this->scope);
$scopeHash = GeneralUtility::hmac($scopeData);
$js = htmlspecialchars('Tree.load(' . GeneralUtility::quoteJSvalue($cmd) . ', ' . (int) $isExpand . ', this, ' . GeneralUtility::quoteJSvalue($scopeData) . ', ' . GeneralUtility::quoteJSvalue($scopeHash) . ');');
return '<a class="pm" onclick="' . $js . '">' . $icon . '</a>';
} else {
return $icon;
}
}
示例9: dumpAction
/**
* Main method to dump a file
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return NULL|ResponseInterface
*
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException
* @throws \UnexpectedValueException
*/
public function dumpAction(ServerRequestInterface $request, ResponseInterface $response)
{
$parameters = array('eID' => 'dumpFile');
$t = $this->getGetOrPost($request, 't');
if ($t) {
$parameters['t'] = $t;
}
$f = $this->getGetOrPost($request, 'f');
if ($f) {
$parameters['f'] = $f;
}
$p = $this->getGetOrPost($request, 'p');
if ($p) {
$parameters['p'] = $p;
}
if (GeneralUtility::hmac(implode('|', $parameters), 'resourceStorageDumpFile') === $this->getGetOrPost($request, 'token')) {
if (isset($parameters['f'])) {
$file = ResourceFactory::getInstance()->getFileObject($parameters['f']);
if ($file->isDeleted() || $file->isMissing()) {
$file = null;
}
} else {
$file = GeneralUtility::makeInstance(ProcessedFileRepository::class)->findByUid($parameters['p']);
if ($file->isDeleted()) {
$file = null;
}
}
if ($file === null) {
HttpUtility::setResponseCodeAndExit(HttpUtility::HTTP_STATUS_404);
}
// Hook: allow some other process to do some security/access checks. Hook should issue 403 if access is rejected
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['FileDumpEID.php']['checkFileAccess'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['FileDumpEID.php']['checkFileAccess'] as $classRef) {
$hookObject = GeneralUtility::getUserObj($classRef);
if (!$hookObject instanceof FileDumpEIDHookInterface) {
throw new \UnexpectedValueException('FileDump hook object must implement interface ' . FileDumpEIDHookInterface::class, 1394442417);
}
$hookObject->checkFileAccess($file);
}
}
$file->getStorage()->dumpFileContents($file);
// @todo Refactor FAL to not echo directly, but to implement a stream for output here and use response
return null;
} else {
return $response->withStatus(403);
}
}
示例10: generatePublicUrl
/**
* Generate public url for file
*
* @param Resource\ResourceStorage $storage
* @param Resource\Driver\DriverInterface $driver
* @param Resource\FileInterface $file
* @param $relativeToCurrentScript
* @param array $urlData
* @return void
*/
public function generatePublicUrl(Resource\ResourceStorage $storage, Resource\Driver\DriverInterface $driver, Resource\FileInterface $file, $relativeToCurrentScript, array $urlData)
{
// We only render special links for non-public files
if ($this->enabled && !$storage->isPublic()) {
$queryParameterArray = array('eID' => 'dumpFile', 't' => '');
if ($file instanceof Resource\File) {
$queryParameterArray['f'] = $file->getUid();
$queryParameterArray['t'] = 'f';
} elseif ($file instanceof Resource\ProcessedFile) {
$queryParameterArray['p'] = $file->getUid();
$queryParameterArray['t'] = 'p';
}
$queryParameterArray['token'] = GeneralUtility::hmac(implode('|', $queryParameterArray), 'BeResourceStorageDumpFile');
// $urlData['publicUrl'] is passed by reference, so we can change that here and the value will be taken into account
$urlData['publicUrl'] = BackendUtility::getAjaxUrl('FalSecuredownload::publicUrl', $queryParameterArray);
}
}
示例11: call
/**
* Runs a remote function call.
*
* @param int $storageUid The UID of the drivers storage.
* @param string $function The name of the function that should be called.
* @param array $parameters The parameters passed to the remote function.
* @return mixed The return value of the remote function.
*/
public function call($storageUid, $function, $parameters = array())
{
$parameters = base64_encode(serialize($parameters));
$hash = GeneralUtility::hmac($storageUid . $function . $parameters, 'fal_remote');
$report = array();
$url = $this->extensionConfiguration->getRemoteTypo3Url() . sprintf('?eID=fal_remote&hash=%s&storageUid=%d&function=%s¶meters=%s', $hash, (int) $storageUid, rawurlencode($function), $parameters);
$result = GeneralUtility::getUrl($url, 0, FALSE, $report);
if (!$result) {
throw new \RuntimeException('Error fetching file information for ' . $function . ': ' . $report['message']);
}
$result = json_decode($result, TRUE);
if (empty($result['success'])) {
$error = !empty($result['error']) ? ': ' . $result['error'] : '';
throw new \RuntimeException('Error fetching file information for ' . $function . $error);
}
return $result['returnValue'];
}
示例12: main
/**
* Processes eID request.
*
* @return void
*/
public function main()
{
// Due to the nature of OpenID (redrections, etc) we need to force user
// session fetching if there is no session around. This ensures that
// our service is called even if there is no login data in the request.
// Inside the service we will process OpenID response and authenticate
// the user.
$GLOBALS['TYPO3_CONF_VARS']['SVCONF']['auth']['FE_fetchUserIfNoSession'] = true;
// Initialize Frontend user
EidUtility::initFeUser();
// Redirect to the original location in any case (authenticated or not)
@ob_end_clean();
$location = GeneralUtility::_GP('tx_openid_location');
$signature = GeneralUtility::hmac($location, 'openid');
if ($signature === GeneralUtility::_GP('tx_openid_location_signature')) {
HttpUtility::redirect($location, HttpUtility::HTTP_STATUS_303);
}
}
示例13: processCall
/**
* Processed the requested call based on the current GET parameters.
*/
public function processCall()
{
$storageUid = (string) GeneralUtility::_GET('storageUid');
if ($storageUid === '') {
$this->result['error'] = 'No storageUid submitted.';
return;
}
$storageUid = (int) $storageUid;
$function = (string) GeneralUtility::_GET('function');
if ($function === '') {
$this->result['error'] = 'No function submitted.';
return;
}
$parameters = (string) GeneralUtility::_GET('parameters');
if ($parameters === '') {
$this->result['error'] = 'No parameters submnitted.';
return;
}
$hash = (string) GeneralUtility::_GET('hash');
if ($hash === '') {
$this->result['error'] = 'No hash was submitted.';
return;
}
if ($hash !== GeneralUtility::hmac($storageUid . $function . $parameters, 'fal_remote')) {
$this->result['error'] = 'An invalid hash was submitted.';
return;
}
$parameters = unserialize(base64_decode($parameters));
if ($parameters === FALSE || !is_array($parameters)) {
$this->result['error'] = 'The parameters array could not be deserialized.';
return;
}
try {
$result = call_user_func_array(array($this->getDriver($storageUid), $function), $parameters);
if ($function === 'getFileContents') {
$result = base64_encode($result);
}
$this->result = array('success' => TRUE, 'returnValue' => $result);
} catch (\Exception $e) {
$this->result = array('success' => FALSE, 'error' => $e->getMessage());
}
}
示例14: dumpFile
/**
* Dump file content
* Copy from /sysext/core/Resources/PHP/FileDumpEID.php
*
* @param array $params
* @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj
*/
public function dumpFile($params = array(), \TYPO3\CMS\Core\Http\AjaxRequestHandler &$ajaxObj = null)
{
$parameters = array('eID' => 'dumpFile');
if (GeneralUtility::_GP('t')) {
$parameters['t'] = GeneralUtility::_GP('t');
}
if (GeneralUtility::_GP('f')) {
$parameters['f'] = (int) GeneralUtility::_GP('f');
}
if (GeneralUtility::_GP('p')) {
$parameters['p'] = (int) GeneralUtility::_GP('p');
}
if (GeneralUtility::hmac(implode('|', $parameters), 'BeResourceStorageDumpFile') === GeneralUtility::_GP('token')) {
if (isset($parameters['f'])) {
$file = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($parameters['f']);
if ($file->isDeleted() || $file->isMissing()) {
$file = null;
}
$orgFile = $file;
} else {
/** @var \TYPO3\CMS\Core\Resource\ProcessedFile $file */
$file = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ProcessedFileRepository')->findByUid($parameters['p']);
if ($file->isDeleted()) {
$file = null;
}
$orgFile = $file->getOriginalFile();
}
// Check file read permissions
if (!$orgFile->getStorage()->checkFileActionPermission('read', $orgFile)) {
HttpUtility::setResponseCodeAndExit(HttpUtility::HTTP_STATUS_403);
}
if ($file === null) {
HttpUtility::setResponseCodeAndExit(HttpUtility::HTTP_STATUS_404);
}
ob_start();
$file->getStorage()->dumpFileContents($file);
exit;
} else {
HttpUtility::setResponseCodeAndExit(HttpUtility::HTTP_STATUS_403);
}
}
示例15: getBrowsableTree
/**
* Will create and return the HTML code for a browsable tree of folders.
* Is based on the mounts found in the internal array ->MOUNTS (set in the constructor)
*
* @return string HTML code for the browsable tree
*/
public function getBrowsableTree()
{
// TYPO3\CMS\Backend\Controller\FileSystemNavigationFrameController does not set custom parameters on an Ajax expand/collapse request
if (!$GLOBALS['SOBE']->browser->editorNo) {
$scopeData = (string) GeneralUtility::_GP('scopeData');
$scopeHash = (string) GeneralUtility::_GP('scopeHash');
if (!empty($scopeData) && GeneralUtility::hmac($scopeData) === $scopeHash) {
$scopeData = unserialize($scopeData);
if ($scopeData['browser']['editorNo']) {
$GLOBALS['SOBE']->browser->editorNo = $scopeData['browser']['editorNo'];
}
if ($scopeData['browser']['sys_language_content']) {
$GLOBALS['SOBE']->browser->sys_language_content = $scopeData['browser']['sys_language_content'];
}
if ($scopeData['browser']['contentTypo3Language']) {
$GLOBALS['SOBE']->browser->contentTypo3Language = $scopeData['browser']['contentTypo3Language'];
}
}
}
return parent::getBrowsableTree();
}