/** * Returns some statistics and a social link to Twitter. * * @return void */ protected function addStatisticsAndSocialLink() { $fileName = PATH_site . 'typo3conf/.tx_imageautoresize'; if (!is_file($fileName)) { return; } $data = json_decode(file_get_contents($fileName), true); if (!is_array($data) || !(isset($data['images']) && isset($data['bytes']))) { return; } $resourcesPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($this->extKey) . 'Resources/Public/'; $pageRenderer = version_compare(TYPO3_version, '7.5.99', '>') ? $this->moduleTemplate->getPageRenderer() : $this->doc->getPageRenderer(); $pageRenderer->addCssFile($resourcesPath . 'Css/twitter.css'); $pageRenderer->addJsFile($resourcesPath . 'JavaScript/popup.js'); $totalSpaceClaimed = GeneralUtility::formatSize((int) $data['bytes']); $messagePattern = $this->languageService->getLL('storage.claimed'); $message = sprintf($messagePattern, $totalSpaceClaimed, (int) $data['images']); $flashMessage = htmlspecialchars($message); $twitterMessagePattern = $this->languageService->getLL('social.twitter'); $message = sprintf($twitterMessagePattern, $totalSpaceClaimed); $url = 'https://typo3.org/extensions/repository/view/image_autoresize'; $twitterLink = 'https://twitter.com/intent/tweet?text=' . urlencode($message) . '&url=' . urlencode($url); $twitterLink = GeneralUtility::quoteJSvalue($twitterLink); $flashMessage .= ' <div class="custom-tweet-button"> <a href="#" onclick="popitup(' . $twitterLink . ',\'twitter\')" title="' . $this->languageService->getLL('social.share', true) . '"> <i class="btn-icon"></i> <span class="btn-text">Tweet</span> </a> </div>'; if (version_compare(TYPO3_version, '7.0.0', '>=')) { $this->content .= ' <div class="alert alert-info"> <div class="media"> <div class="media-left"> <span class="fa-stack fa-lg"> <i class="fa fa-circle fa-stack-2x"></i> <i class="fa fa-info fa-stack-1x"></i> </span> </div> <div class="media-body"> ' . $flashMessage . ' </div> </div> </div> '; } else { $this->content .= ' <div id="typo3-messages"> <div class="typo3-message message-information"> <div class="message-body"> ' . $flashMessage . ' </div> </div> </div> '; } }
/** * Remove specified directory * * @param string $extDirPath * @throws ExtensionManagerException * @return void */ public function removeDirectory($extDirPath) { $extensionPathWithoutTrailingSlash = rtrim($extDirPath, DIRECTORY_SEPARATOR); if (is_link($extensionPathWithoutTrailingSlash)) { $result = unlink($extensionPathWithoutTrailingSlash); } else { $result = GeneralUtility::rmdir($extDirPath, TRUE); } if ($result === FALSE) { throw new ExtensionManagerException(sprintf($this->languageService->getLL('fileHandling.couldNotRemoveDirectory'), $this->getRelativePath($extDirPath)), 1337280415); } }
/** * Remove specified directory * * @param string $extDirPath * @throws ExtensionManagerException * @return void */ public function removeDirectory($extDirPath) { $extDirPath = GeneralUtility::fixWindowsFilePath($extDirPath); $extensionPathWithoutTrailingSlash = rtrim($extDirPath, '/'); if (is_link($extensionPathWithoutTrailingSlash) && TYPO3_OS !== 'WIN') { $result = unlink($extensionPathWithoutTrailingSlash); } else { $result = GeneralUtility::rmdir($extDirPath, true); } if ($result === false) { throw new ExtensionManagerException(sprintf($this->languageService->getLL('fileHandling.couldNotRemoveDirectory'), $this->getRelativePath($extDirPath)), 1337280415); } }
/** * Returns option array to be used in Fluid * * @param string $excludeList Table names (and the string "_ALL") to exclude. Comma list * @return array */ public function getTableSelectOptions($excludeList = '') { $optValues = array(); if (!GeneralUtility::inList($excludeList, '_ALL')) { $optValues['_ALL'] = '[' . $this->lang->getLL('ALL_tables') . ']'; } foreach ($GLOBALS['TCA'] as $table => $_) { if ($this->getBackendUser()->check('tables_select', $table) && !GeneralUtility::inList($excludeList, $table)) { $optValues[$table] = $table; } } return $optValues; }
/** * Initializes the controller before invoking an action method. * * @return void */ protected function initializeAction() { $this->pageId = (int) GeneralUtility::_GP('id'); $this->pageRenderer->addInlineLanguageLabelArray(array('title' => $this->languageService->getLL('title'), 'path' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.path'), 'table' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.table'), 'depth' => $this->languageService->sL('LLL:EXT:lang/locallang_mod_web_perm.xml:Depth'), 'depth_0' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_0'), 'depth_1' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_1'), 'depth_2' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_2'), 'depth_3' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_3'), 'depth_4' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_4'), 'depth_infi' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xml:labels.depth_infi'))); $this->pageRenderer->addInlineLanguageLabelFile('EXT:typo3_forum/Resources/Private/Language/locallang_mod.xml'); $this->pageRenderer->loadExtJS(); $this->pageRenderer->enableExtJSQuickTips(); $this->pageRenderer->addJsFile(ExtensionManagementUtility::extRelPath('lang') . 'res/js/be/typo3lang.js'); $this->pageRenderer->addJsFile($this->backPath . 'js/extjs/ux/Ext.ux.FitToParent.js'); $this->includeJavascriptFromPath('Resources/Public/Javascript/Backend/ExtJS/'); $this->includeJavascriptFromPath('Resources/Public/Javascript/Backend/ForumIndex/'); $this->includeCssFromPath('Resources/Public/Javascript/Backend/ExtJS/'); $this->pageRenderer->addCssFile(ExtensionManagementUtility::extRelPath('typo3_forum') . 'Resources/Public/Stylesheets/typo3_forum-backend.css'); }
/** * Sets column positions based on a selected gridelement layout * * @param array $parserRows : The parsed rows of the gridelement layout * @param array $colPosValues : The column positions that have been found for that layout * * @return void */ public function setMultipleColPosValues($parserRows, &$colPosValues) { if (is_array($parserRows)) { foreach ($parserRows as $parserRow) { if (is_array($parserRow['columns.']) && count($parserRow['columns.']) > 0) { foreach ($parserRow['columns.'] as $parserColumns) { $name = $this->lang->sL($parserColumns['name'], TRUE); if ($parserColumns['colPos'] !== '') { $colPosValues[(int) $parserColumns['colPos']] = array('name' => $name, 'allowed' => $parserColumns['allowed']); } else { $colPosValues[32768] = array('name' => $this->lang->getLL('notAssigned'), 'allowed' => ''); } } } } } }
/** * Initialize module header etc and call extObjContent function * * @return void */ public function main() { // Access check... // The page will show only if there is a valid page and if this page // may be viewed by the user $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause); $access = is_array($this->pageinfo); if ($this->id && $access || $this->backendUser->user['admin'] && !$this->id) { if ($this->backendUser->user['admin'] && !$this->id) { $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0); } $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class); $this->doc->backPath = $GLOBALS['BACK_PATH']; $this->doc->setModuleTemplate('EXT:info/Resources/Private/Templates/info.html'); $this->doc->tableLayout = array('0' => array('0' => array('<td valign="top"><strong>', '</strong></td>'), 'defCol' => array('<td><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td><td valign="top"><strong>', '</strong></td>')), 'defRow' => array('0' => array('<td valign="top">', '</td>'), 'defCol' => array('<td><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td><td valign="top">', '</td>'))); // JavaScript $this->doc->postCode = $this->doc->wrapScriptTags('if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int) $this->id . ';'); // Setting up the context sensitive menu: $this->doc->getContextMenuCode(); $this->doc->form = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl($this->moduleName)) . '" method="post" name="webinfoForm">'; $vContent = $this->doc->getVersionSelector($this->id, 1); if ($vContent) { $this->content .= $this->doc->section('', $vContent); } $this->extObjContent(); // Setting up the buttons and markers for docheader $docHeaderButtons = $this->getButtons(); $markers = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']), 'CONTENT' => $this->content); // Build the <body> for the module $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); } else { // If no access or if ID == zero $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class); $this->doc->backPath = $GLOBALS['BACK_PATH']; $this->content = $this->doc->header($this->languageService->getLL('title')); $this->content .= $this->doc->spacer(5); $this->content .= $this->doc->spacer(10); } // Renders the module page $this->content = $this->doc->render($this->languageService->getLL('title'), $this->content); }
/** * Result row display * * @param array $row * @param array $conf * @param string $table * @return string */ public function resultRowDisplay($row, $conf, $table) { $SET = $GLOBALS['SOBE']->MOD_SETTINGS; $out = '<tr>'; foreach ($row as $fieldName => $fieldValue) { if (GeneralUtility::inList($SET['queryFields'], $fieldName) || !$SET['queryFields'] && $fieldName != 'pid' && $fieldName != 'deleted') { if ($SET['search_result_labels']) { $fVnew = $this->getProcessedValueExtra($table, $fieldName, $fieldValue, $conf, '<br />'); } else { $fVnew = htmlspecialchars($fieldValue); } $out .= '<td>' . $fVnew . '</td>'; } } $out .= '<td>'; if (!$row['deleted']) { $out .= '<div class="btn-group" role="group">'; $url = BackendUtility::getModuleUrl('record_edit', ['edit' => [$table => [$row['uid'] => 'edit']], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . GeneralUtility::implodeArrayForUrl('SET', (array) GeneralUtility::_POST('SET'))]); $out .= '<a class="btn btn-default" href="' . htmlspecialchars($url) . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>'; $out .= '</div><div class="btn-group" role="group">'; $out .= '<a class="btn btn-default" href="#" onClick="top.launchView(\'' . $table . '\',' . $row['uid'] . ');return false;">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '</a>'; $out .= '</div>'; } else { $out .= '<div class="btn-group" role="group">'; $out .= '<a class="btn btn-default" href="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_db', ['cmd' => [$table => [$row['uid'] => ['undelete' => 1]]], 'redirect' => GeneralUtility::linkThisScript()])) . '" title="' . htmlspecialchars($this->languageService->getLL('undelete_only')) . '">'; $out .= $this->iconFactory->getIcon('actions-edit-restore', Icon::SIZE_SMALL)->render() . '</a>'; $formEngineParameters = ['edit' => [$table => [$row['uid'] => 'edit']], 'returnUrl' => GeneralUtility::linkThisScript()]; $redirectUrl = BackendUtility::getModuleUrl('record_edit', $formEngineParameters); $out .= '<a class="btn btn-default" href="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_db', ['cmd' => [$table => [$row['uid'] => ['undelete' => 1]]], 'redirect' => $redirectUrl])) . '" title="' . htmlspecialchars($this->languageService->getLL('undelete_and_edit')) . '">'; $out .= $this->iconFactory->getIcon('actions-edit-restore-edit', Icon::SIZE_SMALL)->render() . '</a>'; $out .= '</div>'; } $_params = [$table => $row]; if (is_array($this->hookArray['additionalButtons'])) { foreach ($this->hookArray['additionalButtons'] as $_funcRef) { $out .= GeneralUtility::callUserFunction($_funcRef, $_params, $this); } } $out .= '</td></tr>'; return $out; }
/** * Initialize module header etc and call extObjContent function * * @return void */ public function main() { // We leave this here because of dependencies to submodules $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class); // The page will show only if there is a valid page and if this page // may be viewed by the user $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause); if ($this->pageinfo) { $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo); } $access = is_array($this->pageinfo); if ($this->id && $access || $this->backendUser->user['admin'] && !$this->id) { if ($this->backendUser->user['admin'] && !$this->id) { $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0); } // JavaScript $this->moduleTemplate->addJavaScriptCode('WebFuncInLineJS', 'if (top.fsMod) top.fsMod.recentIds["web"] = ' . (int) $this->id . '; function jumpToUrl(URL) { window.location.href = URL; return false; } '); // Setting up the context sensitive menu: $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu'); $this->content .= '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl($this->moduleName)) . '" method="post" id="InfoModuleController" name="webinfoForm" class="form-inline form-inline-spaced">'; $vContent = $this->moduleTemplate->getVersionSelector($this->id, 1); if ($vContent) { $this->content .= $this->moduleTemplate->section('', $vContent); } $this->extObjContent(); // Setting up the buttons and markers for docheader $this->getButtons(); $this->generateMenu(); $this->content .= '</form>'; } else { // If no access or if ID == zero $this->content = $this->doc->header($this->languageService->getLL('title')); } }
/** * Inject alt attribute for image that don't have it yet */ private function infoImageAlt() { if (!$this->content) { return; } $document = new \DOMDocument(); $prefix = '<?xml encoding="UTF-8">'; @$document->loadHTML($prefix . $this->content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $imgs = $document->getElementsByTagName('img'); $count = 0; foreach ($imgs as $img) { if (!$img->hasAttribute('alt')) { $img->setAttribute('alt', ''); ++$count; } } if ($count) { $this->infos[] = sprintf($this->lang->getLL('validation_mail_injected_alt_attribute'), $count); } $newContent = trim(preg_replace('/^' . preg_quote($prefix) . '/', '', $document->saveHTML())); $this->content = $newContent; }
/** * Returns a selector-box with TCA tables * * @param string $prefix Form element name prefix * @param array $value The current values selected * @param string $excludeList Table names (and the string "_ALL") to exclude. Comma list * @return string HTML select element */ public function tableSelector($prefix, $value, $excludeList = '') { $optValues = array(); if (!GeneralUtility::inList($excludeList, '_ALL')) { $optValues['_ALL'] = '[' . $this->lang->getLL('ALL_tables') . ']'; } foreach ($GLOBALS['TCA'] as $table => $_) { if ($this->getBackendUser()->check('tables_select', $table) && !GeneralUtility::inList($excludeList, $table)) { $optValues[$table] = $table; } } // make box: $opt = array(); $opt[] = '<option value=""></option>'; $sel = ''; foreach ($optValues as $k => $v) { if (is_array($value)) { $sel = in_array($k, $value) ? ' selected="selected"' : ''; } $opt[] = '<option value="' . htmlspecialchars($k) . '"' . $sel . '>' . htmlspecialchars($v) . '</option>'; } return '<select name="' . $prefix . '[]" multiple="multiple" size="' . MathUtility::forceIntegerInRange(count($opt), 5, 10) . '">' . implode('', $opt) . '</select>'; }
/** * Ensures credit card information is keyed in correctly. * <p>Checks that the length is correct, the first four digits are * within accepted ranges, the number passes the Mod 10 / Luhn * checksum algorithm and that you accept the given type of card. It * also determines the card's type via the number's first four digits.</p> * <p>The procedure has the option to check the card's expiration date.</p> * <p>Error messages are internationalized through use of variables * defined by files in the <kbd>./language</kbd> subdirectory. These * files are named after their ISO 639-1 two letter language code. * The language used depends on the code put in the * <var>$Language</var> parameter.</p> * <p>Just to be clear, this process does not check with banks or * credit card companies to see if the card number given is actually * associated with a good account. It just checks to see if the * number matches the expected format.</p> * <p>Warning: this function uses exact number ranges as part of * the validation process. These ranges are current as of * 30 July 2002. If presently undefined ranges come into use * in the future, this program will improperly deject card numbers * in such ranges, rendering an error saying "First four digits * indicate unknown card type." If this happens while entering a * card and type you KNOW are valid, please contact us so we can * update the ranges.</p> * <p>This function requires PHP to be at version 4.0 or above.</p> * <p>Please make a donation to support our open source development. * Update notifications are sent to people who make donations that exceed * the small registration threshold. See the link below.</p> * <p>Credit Card Validation Solution is a trademark of The Analysis and * Solutions Company.</p> * <p>Several people deserve praise for the Credit Card Validation * Solution. I learned of the Mod 10 Algorithm in some Perl code, * entitled "The Validator," available on Matt's Script Archive, * http://www.scriptarchive.com/ccver.html. That code was written by * David Paris, who based it on material Melvyn Myers reposted from an * unknown author. Paris credits Aries Solis for tracking down the data * underlying the algorithm. I pruned down the algorithm to it's core * components, making things smaller, cleaner and more flexible. Plus, * I added the expiration date checking routine. My first attemts at * this were in Visual Basic, on which Allen Browne and Rico Zschau * assisted. Neil Fraser helped a bit on the Perl version. Steve * Horsley, Roedy Green and Jon Skeet provided tips on the Java Edition.</p>. * * @param string $Number the number of the credit card to * validate. * @param string $CheckNumber the ISO 639-1 two letter code of * the language for error messages. * @param array|string $Accepted credit card types you accept. If * not used in function call, all * known cards are accepted. Set * it before calling the function: <br /><kbd> * $A = array('Visa', 'JCB'); * </kbd><br /> * Known types: <ul> * <li> American Express </li> * <li> Australian BankCard </li> * <li> Carte Blanche </li> * <li> Diners Club </li> * <li> Discover/Novus </li> * <li> JCB </li> * <li> MasterCard </li> * <li> Visa </li></ul> * @param string $RequireExp should the expiration date be * checked? Y or N. * @param int|string $Month the card's expiration month * in M, 0M or MM foramt. * @param int|string $Year the card's expiration year in YYYY format. * * @return bool TRUE if everything is fine. FALSE if problems. * * @version $Name: rel-5-14 $ * * @author Daniel Convissor <*****@*****.**> * @copyright The Analysis and Solutions Company, 2002-2006 * * @link http://www.analysisandsolutions.com/software/ccvs/ccvs.htm * @link http://www.loc.gov/standards/iso639-2/langcodes.html * @link http://www.analysisandsolutions.com/donate/ * * @license http://www.analysisandsolutions.com/software/license.htm Simple Public License */ public function validateCreditCard($Number, $CheckNumber, $Accepted = '', $RequireExp = 'N', $Month = '', $Year = '') { $this->CCVSNumber = ''; $this->CCVSNumberLeft = ''; $this->CCVSNumberRight = ''; $this->CCVSType = ''; $this->CCVSExpiration = ''; $this->CCVSError = ''; // Catch malformed input. if (empty($Number) || !is_string($Number)) { $this->CCVSError = $this->language->getLL('ErrNumberString'); return false; } // Ensure number doesn't overrun. $Number = substr($Number, 0, 30); // Remove non-numeric characters. $this->CCVSNumber = preg_replace('/[^0-9]/', '', $Number); // Set up variables. $this->CCVSCheckNumber = trim($CheckNumber); $this->CCVSNumberLeft = substr($this->CCVSNumber, 0, 4); $this->CCVSNumberRight = substr($this->CCVSNumber, -4); $NumberLength = strlen($this->CCVSNumber); $DoChecksum = 'Y'; // Determine the card type and appropriate length. if ($this->CCVSNumberLeft >= 3000 && $this->CCVSNumberLeft <= 3059) { $this->CCVSType = 'Diners Club'; $ShouldLength = 14; } elseif ($this->CCVSNumberLeft >= 3600 && $this->CCVSNumberLeft <= 3699) { $this->CCVSType = 'Diners Club'; $ShouldLength = 14; } elseif ($this->CCVSNumberLeft >= 3800 && $this->CCVSNumberLeft <= 3889) { $this->CCVSType = 'Diners Club'; $ShouldLength = 14; } elseif ($this->CCVSNumberLeft >= 3400 && $this->CCVSNumberLeft <= 3499) { $this->CCVSType = 'American Express'; $ShouldLength = 15; } elseif ($this->CCVSNumberLeft >= 3700 && $this->CCVSNumberLeft <= 3799) { $this->CCVSType = 'American Express'; $ShouldLength = 15; } elseif ($this->CCVSNumberLeft >= 3088 && $this->CCVSNumberLeft <= 3094) { $this->CCVSType = 'JCB'; $ShouldLength = 16; } elseif ($this->CCVSNumberLeft >= 3096 && $this->CCVSNumberLeft <= 3102) { $this->CCVSType = 'JCB'; $ShouldLength = 16; } elseif ($this->CCVSNumberLeft >= 3112 && $this->CCVSNumberLeft <= 3120) { $this->CCVSType = 'JCB'; $ShouldLength = 16; } elseif ($this->CCVSNumberLeft >= 3158 && $this->CCVSNumberLeft <= 3159) { $this->CCVSType = 'JCB'; $ShouldLength = 16; } elseif ($this->CCVSNumberLeft >= 3337 && $this->CCVSNumberLeft <= 3349) { $this->CCVSType = 'JCB'; $ShouldLength = 16; } elseif ($this->CCVSNumberLeft >= 3528 && $this->CCVSNumberLeft <= 3589) { $this->CCVSType = 'JCB'; $ShouldLength = 16; } elseif ($this->CCVSNumberLeft >= 3890 && $this->CCVSNumberLeft <= 3899) { $this->CCVSType = 'Carte Blanche'; $ShouldLength = 14; } elseif ($this->CCVSNumberLeft >= 4000 && $this->CCVSNumberLeft <= 4999) { $this->CCVSType = 'Visa'; if ($NumberLength > 14) { $ShouldLength = 16; } elseif ($NumberLength < 14) { $ShouldLength = 13; } else { $this->CCVSError = $this->language->getLL('ErrVisa14'); return false; } } elseif ($this->CCVSNumberLeft >= 5100 && $this->CCVSNumberLeft <= 5599) { $this->CCVSType = 'MasterCard'; $ShouldLength = 16; } elseif ($this->CCVSNumberLeft == 5610) { $this->CCVSType = 'Australian BankCard'; $ShouldLength = 16; } elseif ($this->CCVSNumberLeft == 6011) { $this->CCVSType = 'Discover/Novus'; $ShouldLength = 16; } else { $this->CCVSError = sprintf($this->language->getLL('ErrUnknown'), $this->CCVSNumberLeft); return false; } // Check acceptance. if (!empty($Accepted)) { if (!is_array($Accepted)) { $this->CCVSError = $this->language->getLL('ErrAccepted'); return false; } if (!in_array($this->CCVSType, $Accepted)) { $this->CCVSError = sprintf($this->language->getLL('ErrNoAccept'), $this->CCVSType); return false; } } /* Check CheckNumber. */ if (!empty($this->CCVSType)) { switch ($this->CCVSType) { case 'American Express': if (strlen($this->CCVSCheckNumber) != 4) { $this->CCVSError = sprintf($this->language->getLL('ErrCheckNumber'), $this->CCVSCheckNumber); return false; } break; case 'MasterCard': if (strlen($this->CCVSCheckNumber) != 3) { $this->CCVSError = sprintf($this->language->getLL('ErrCheckNumber'), $this->CCVSCheckNumber); return false; } break; case 'Visa': if (strlen($this->CCVSCheckNumber) != 3) { $this->CCVSError = sprintf($this->language->getLL('ErrCheckNumber'), $this->CCVSCheckNumber); return false; } break; } } // Check length. if ($NumberLength != $ShouldLength) { $Missing = $NumberLength - $ShouldLength; if ($Missing < 0) { $this->CCVSError = sprintf($this->language->getLL('ErrShort'), abs($Missing)); } else { $this->CCVSError = sprintf($this->language->getLL('ErrLong'), $Missing); } return false; } // Mod10 checksum process... if ($DoChecksum == 'Y') { $Checksum = 0; /* * Add even digits in even length strings * or odd digits in odd length strings. */ for ($Location = 1 - $NumberLength % 2; $Location < $NumberLength; $Location += 2) { $Checksum += (int) substr($this->CCVSNumber, $Location, 1); } /* * Analyze odd digits in even length strings * or even digits in odd length strings. */ for ($Location = $NumberLength % 2; $Location < $NumberLength; $Location += 2) { $Digit = (int) substr($this->CCVSNumber, $Location, 1) * 2; if ($Digit < 10) { $Checksum += $Digit; } else { $Checksum += $Digit - 9; } } // Checksums not divisible by 10 are bad. if ($Checksum % 10 != 0) { $this->CCVSError = $this->language->getLL('ErrChecksum'); return false; } } // Expiration date process... if ($RequireExp == 'Y') { if (empty($Month) || !is_string($Month)) { $this->CCVSError = $this->language->getLL('ErrMonthString'); return false; } if (!preg_match('/^(0?[1-9]|1[0-2])$/', $Month)) { $this->CCVSError = $this->language->getLL('ErrMonthFormat'); return false; } if (empty($Year) || !is_string($Year)) { $this->CCVSError = $this->language->getLL('ErrYearString'); return false; } if (!preg_match('/^[0-9]{4}$/', $Year)) { $this->CCVSError = $this->language->getLL('ErrYearFormat'); return false; } if ($Year < date('Y')) { $this->CCVSError = $this->language->getLL('ErrExpired'); return false; } elseif ($Year == date('Y')) { if ($Month < date('m')) { $this->CCVSError = $this->language->getLL('ErrExpired'); return false; } } $this->CCVSExpiration = sprintf('%02d', $Month) . substr($Year, -2); } return true; }
/** * Adding CM element for edit page properties * * @param int $uid page uid to edit (PID) * @return array Item array, element in $menuItems * @internal */ public function DB_editPageProperties($uid) { $url = BackendUtility::getModuleUrl('record_edit', array('edit[pages][' . $uid . ']' => 'edit')); return $this->linkItem($this->languageService->makeEntities($this->languageService->getLL('CM_editPageProperties')), IconUtility::getSpriteIcon('actions-page-open'), $this->urlRefForCM($url, 'returnUrl'), 1); }
/** * Returns the content of the newsletter with validation messages. The content * is also "fixed" automatically when possible. * @param Newsletter $newsletter * @param string $language language of the content of the newsletter (the 'L' parameter in TYPO3 URL) * @return array ('content' => $content, 'errors' => $errors, 'warnings' => $warnings, 'infos' => $infos); */ public function validate(Newsletter $newsletter, $language = null) { $this->initializeLang(); // We need to catch the exception if domain was not found/configured properly try { $url = $newsletter->getContentUrl($language); } catch (Exception $e) { return array('content' => '', 'errors' => array($e->getMessage()), 'warnings' => array(), 'infos' => array()); } $content = $this->getURL($url); $errors = array(); $warnings = array(); $infos = array(sprintf($this->lang->getLL('validation_content_url'), '<a target="_blank" href="' . $url . '">' . $url . '</a>')); // Content should be more that just a few characters. Apache error propably occured if (strlen($content) < 200) { $errors[] = $this->lang->getLL('validation_mail_too_short'); } // Content should not contain PHP-Warnings if (substr($content, 0, 22) == "<br />\n<b>Warning</b>:") { $errors[] = $this->lang->getLL('validation_mail_contains_php_warnings'); } // Content should not contain PHP-Warnings if (substr($content, 0, 26) == "<br />\n<b>Fatal error</b>:") { $errors[] = $this->lang->getLL('validation_mail_contains_php_errors'); } // If the page contains a "Pages is being generared" text... this is bad too if (strpos($content, 'Page is being generated.') && strpos($content, 'If this message does not disappear within')) { $errors[] = $this->lang->getLL('validation_mail_being_generated'); } // Find out the absolute domain. If specified in HTML source, use it as is. if (preg_match('|<base[^>]*href="([^"]*)"[^>]*/>|i', $content, $match)) { $absoluteDomain = $match[1]; } else { $absoluteDomain = $newsletter->getBaseUrl() . '/'; } // Fix relative URL to absolute URL $urlPatterns = array('hyperlinks' => '/<a [^>]*href="(.*)"/Ui', 'stylesheets' => '/<link [^>]*href="(.*)"/Ui', 'images' => '/ src="(.*)"/Ui', 'background images' => '/ background="(.*)"/Ui'); foreach ($urlPatterns as $type => $urlPattern) { preg_match_all($urlPattern, $content, $urls); $replacementCount = 0; foreach ($urls[1] as $i => $url) { // If this is already an absolute link, dont replace it $decodedUrl = html_entity_decode($url); if (!Uri::isAbsolute($decodedUrl)) { $replace_url = str_replace($decodedUrl, $absoluteDomain . ltrim($decodedUrl, '/'), $urls[0][$i]); $content = str_replace($urls[0][$i], $replace_url, $content); ++$replacementCount; } } if ($replacementCount) { $infos[] = sprintf($this->lang->getLL('validation_mail_converted_relative_url'), $type); } } // Find linked css and convert into a style-tag preg_match_all('|<link rel="stylesheet" type="text/css" href="([^"]+)"[^>]+>|Ui', $content, $urls); foreach ($urls[1] as $i => $url) { $content = str_replace($urls[0][$i], "<!-- fetched URL: {$url} -->\n<style type=\"text/css\">\n<!--\n" . $this->getURL($url) . "\n-->\n</style>", $content); } if (count($urls[1])) { $infos[] = $this->lang->getLL('validation_mail_contains_linked_styles'); } // We cant very well have attached javascript in a newsmail ... removing $content = preg_replace('|<script[^>]*type="text/javascript"[^>]*>[^<]*</script>|i', '', $content, -1, $count); if ($count) { $warnings[] = $this->lang->getLL('validation_mail_contains_javascript'); } // Images in CSS if (preg_match('|background-image: url\\([^\\)]+\\)|', $content) || preg_match('|list-style-image: url\\([^\\)]+\\)|', $content)) { $errors[] = $this->lang->getLL('validation_mail_contains_css_images'); } // CSS-classes if (preg_match('|<[a-z]+ [^>]*class="[^"]+"[^>]*>|', $content)) { $warnings[] = $this->lang->getLL('validation_mail_contains_css_classes'); } // Positioning & element sizes in CSS $forbiddenCssProperties = array('width' => '((min|max)+-)?width', 'height' => '((min|max)+-)?height', 'margin' => 'margin(-(bottom|left|right|top)+)?', 'padding' => 'padding(-(bottom|left|right|top)+)?', 'position' => 'position'); $forbiddenCssPropertiesWarnings = array(); if (preg_match_all('|<[a-z]+[^>]+style="([^"]*)"|', $content, $matches)) { foreach ($matches[1] as $stylepart) { foreach ($forbiddenCssProperties as $property => $regex) { if (preg_match('/(^|[^\\w-])' . $regex . '[^\\w-]/', $stylepart)) { $forbiddenCssPropertiesWarnings[$property] = $property; } } } foreach ($forbiddenCssPropertiesWarnings as $property) { $warnings[] = sprintf($this->lang->getLL('validation_mail_contains_css_some_property'), $property); } } return array('content' => $content, 'errors' => $errors, 'warnings' => $warnings, 'infos' => $infos); }
/** * Adding CM element for edit page properties * * @param int $uid page uid to edit (PID) * @return array Item array, element in $menuItems * @internal */ public function DB_editPageProperties($uid) { $url = BackendUtility::getModuleUrl('record_edit', array('edit[pages][' . $uid . ']' => 'edit')); return $this->linkItem(htmlspecialchars($this->languageService->getLL('CM_editPageProperties')), $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render(), $this->urlRefForCM($url, 'returnUrl'), 1); }
/** * Get security status of loaded and installed extensions * * @return \stdClass with properties 'loaded' and 'existing' containing a TYPO3\CMS\Reports\Report\Status\Status object */ protected function getSecurityStatusOfExtensions() { $extensionInformation = $this->listUtility->getAvailableAndInstalledExtensionsWithAdditionalInformation(); $loadedInsecure = array(); $existingInsecure = array(); $loadedOutdated = array(); $existingOutdated = array(); foreach ($extensionInformation as $extensionKey => $information) { if (array_key_exists('terObject', $information) && $information['terObject'] instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension) { /** @var $terObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension */ $terObject = $information['terObject']; $insecureStatus = $terObject->getReviewState(); if ($insecureStatus === -1) { if (array_key_exists('installed', $information) && $information['installed'] === TRUE) { $loadedInsecure[] = array('extensionKey' => $extensionKey, 'version' => $terObject->getVersion()); } else { $existingInsecure[] = array('extensionKey' => $extensionKey, 'version' => $terObject->getVersion()); } } elseif ($insecureStatus === -2) { if (array_key_exists('installed', $information) && $information['installed'] === TRUE) { $loadedOutdated[] = array('extensionKey' => $extensionKey, 'version' => $terObject->getVersion()); } else { $existingOutdated[] = array('extensionKey' => $extensionKey, 'version' => $terObject->getVersion()); } } } } $result = new \stdClass(); if (empty($loadedInsecure)) { $value = $this->languageService->getLL('report.status.loadedExtensions.noInsecureExtensionLoaded.value'); $message = ''; $severity = \TYPO3\CMS\Reports\Status::OK; } else { $value = sprintf($this->languageService->getLL('report.status.loadedExtensions.insecureExtensionLoaded.value'), count($loadedInsecure)); $extensionList = array(); foreach ($loadedInsecure as $insecureExtension) { $extensionList[] = sprintf($this->languageService->getLL('report.status.loadedExtensions.insecureExtensionLoaded.message.extension'), $insecureExtension['extensionKey'], $insecureExtension['version']); } $message = sprintf($this->languageService->getLL('report.status.loadedExtensions.insecureExtensionLoaded.message'), implode('', $extensionList)); $severity = \TYPO3\CMS\Reports\Status::ERROR; } $result->loaded = $this->objectManager->get(\TYPO3\CMS\Reports\Status::class, $this->languageService->getLL('report.status.loadedExtensions.title'), $value, $message, $severity); if (empty($existingInsecure)) { $value = $this->languageService->getLL('report.status.existingExtensions.noInsecureExtensionExists.value'); $message = ''; $severity = \TYPO3\CMS\Reports\Status::OK; } else { $value = sprintf($this->languageService->getLL('report.status.existingExtensions.insecureExtensionExists.value'), count($existingInsecure)); $extensionList = array(); foreach ($existingInsecure as $insecureExtension) { $extensionList[] = sprintf($this->languageService->getLL('report.status.existingExtensions.insecureExtensionExists.message.extension'), $insecureExtension['extensionKey'], $insecureExtension['version']); } $message = sprintf($this->languageService->getLL('report.status.existingExtensions.insecureExtensionExists.message'), implode('', $extensionList)); $severity = \TYPO3\CMS\Reports\Status::WARNING; } $result->existing = $this->objectManager->get(\TYPO3\CMS\Reports\Status::class, $this->languageService->getLL('report.status.existingExtensions.title'), $value, $message, $severity); if (empty($loadedOutdated)) { $value = $this->languageService->getLL('report.status.loadedOutdatedExtensions.noOutdatedExtensionLoaded.value'); $message = ''; $severity = \TYPO3\CMS\Reports\Status::OK; } else { $value = sprintf($this->languageService->getLL('report.status.loadedOutdatedExtensions.outdatedExtensionLoaded.value'), count($loadedOutdated)); $extensionList = array(); foreach ($loadedOutdated as $outdatedExtension) { $extensionList[] = sprintf($this->languageService->getLL('report.status.loadedOutdatedExtensions.outdatedExtensionLoaded.message.extension'), $outdatedExtension['extensionKey'], $outdatedExtension['version']); } $message = sprintf($this->languageService->getLL('report.status.loadedOutdatedExtensions.outdatedExtensionLoaded.message'), implode('', $extensionList)); $severity = \TYPO3\CMS\Reports\Status::WARNING; } $result->loadedoutdated = $this->objectManager->get(\TYPO3\CMS\Reports\Status::class, $this->languageService->getLL('report.status.loadedOutdatedExtensions.title'), $value, $message, $severity); if (empty($existingOutdated)) { $value = $this->languageService->getLL('report.status.existingOutdatedExtensions.noOutdatedExtensionExists.value'); $message = ''; $severity = \TYPO3\CMS\Reports\Status::OK; } else { $value = sprintf($this->languageService->getLL('report.status.existingOutdatedExtensions.outdatedExtensionExists.value'), count($existingOutdated)); $extensionList = array(); foreach ($existingOutdated as $outdatedExtension) { $extensionList[] = sprintf($this->languageService->getLL('report.status.existingOutdatedExtensions.outdatedExtensionExists.message.extension'), $outdatedExtension['extensionKey'], $outdatedExtension['version']); } $message = sprintf($this->languageService->getLL('report.status.existingOutdatedExtensions.outdatedExtensionExists.message'), implode('', $extensionList)); $severity = \TYPO3\CMS\Reports\Status::WARNING; } $result->existingoutdated = $this->objectManager->get(\TYPO3\CMS\Reports\Status::class, $this->languageService->getLL('report.status.existingOutdatedExtensions.title'), $value, $message, $severity); return $result; }
/** * renders a single column of a grid layout and sets the edit uid list * * @param PageLayoutView $parentObject : The parent object that triggered this hook * @param array $items : The content data of the column to be rendered * @param int $colPos : The column position we want to get the content for * @param array $values : The layout configuration values for the grid column * @param array $gridContent : The rendered content data of the grid column * @param $row * @param array $editUidList : determines if we will get edit icons or not */ protected function renderSingleGridColumn(PageLayoutView $parentObject, &$items, &$colPos, $values, &$gridContent, $row, &$editUidList) { $specificIds = $this->helper->getSpecificIds($row); $url = ''; $pageinfo = BackendUtility::readPageAccess($parentObject->id, ''); if ($colPos < 32768) { if ($this->getPageLayoutController()->pageIsNotLockedForEditors() && $this->getBackendUser()->doesUserHaveAccess($pageinfo, Permission::CONTENT_EDIT) && !$this->checkIfTranslationsExistInLanguage($items, $row['sys_language_uid'], $parentObject)) { if ($parentObject->option_newWizard) { $urlParameters = ['id' => $parentObject->id, 'colPos' => -1, 'tx_gridelements_allowed' => $values['allowed'], 'tx_gridelements_allowed_grid_types' => $values['allowedGridTypes'], 'tx_gridelements_container' => $specificIds['uid'], 'tx_gridelements_columns' => $colPos, 'uid_pid' => $parentObject->id, 'sys_language_uid' => $row['sys_language_uid'], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]; $url = BackendUtility::getModuleUrl('new_content_element', $urlParameters); } else { $urlParameters = ['edit' => ['tt_content' => [$parentObject->id => 'new']], 'defVals' => ['tt_content' => ['colPos' => -1, 'tx_gridelements_allowed' => $values['allowed'], 'tx_gridelements_allowed_grid_types' => $values['allowedGridTypes'], 'tx_gridelements_container' => $specificIds['uid'], 'tx_gridelements_columns' => $colPos, 'sys_language_uid' => $row['sys_language_uid']]], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]; $url = BackendUtility::getModuleUrl('record_edit', $urlParameters); } } } $iconsArray = array(); if ($colPos !== '' && $colPos !== null && $colPos < 32768 && $url) { $iconsArray = array('new' => '<a href="' . htmlspecialchars($url) . '" title="' . $this->languageService->getLL('newContentElement', true) . '" class="btn btn-default btn-sm">' . $this->iconFactory->getIcon('actions-document-new', 'small') . ' ' . $this->languageService->getLL('content', true) . '</a>'); } $gridContent[$colPos] .= '<div class="t3-page-ce gridelements-collapsed-column-marker">' . $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_contentcollapsed') . '</div>'; $gridContent[$colPos] .= ' <div data-colpos="' . $colPos . '" data-language-uid="' . $row['sys_language_uid'] . '" class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $row['sys_language_uid'] . ' t3-page-ce-wrapper ui-sortable"> <div class="t3-page-ce t3js-page-ce" data-container="' . $row['uid'] . '" id="' . str_replace('.', '', uniqid('', true)) . '"> <div class="t3js-page-new-ce t3js-page-new-ce-allowed t3-page-ce-wrapper-new-ce btn-group btn-group-sm" id="colpos-' . $colPos . '-' . str_replace('.', '', uniqid('', true)) . '">' . implode('', $iconsArray) . ' </div> <div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div> </div>'; if (!empty($items)) { foreach ($items as $itemRow) { if ((int) $itemRow['t3ver_state'] === VersionState::DELETE_PLACEHOLDER) { continue; } if (is_array($itemRow)) { $statusHidden = $parentObject->isDisabled('tt_content', $itemRow) ? ' t3-page-ce-hidden' : ''; $gridContent[$colPos] .= ' <div class="t3-page-ce t3js-page-ce t3js-page-ce-sortable' . $statusHidden . '" data-table="tt_content" data-uid="' . $itemRow['uid'] . '" data-container="' . $itemRow['tx_gridelements_container'] . '" data-ctype="' . $itemRow['CType'] . '"><div class="t3-page-ce-dragitem" id="' . str_replace('.', '', uniqid('', true)) . '">' . $this->renderSingleElementHTML($parentObject, $itemRow) . '</div></div>'; $url = ''; if ($this->getPageLayoutController()->pageIsNotLockedForEditors() && $this->getBackendUser()->doesUserHaveAccess($pageinfo, Permission::CONTENT_EDIT) && !$this->checkIfTranslationsExistInLanguage($items, $row['sys_language_uid'], $parentObject)) { // New content element: if ($parentObject->option_newWizard) { $urlParameters = ['id' => $itemRow['pid'], 'sys_language_uid' => $itemRow['sys_language_uid'], 'tx_gridelements_allowed' => $values['allowed'], 'tx_gridelements_allowed_grid_types' => $values['allowedGridTypes'], 'colPos' => -1, 'uid_pid' => -$itemRow['uid'], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]; $url = BackendUtility::getModuleUrl('new_content_element', $urlParameters); } else { $urlParameters = ['edit' => ['tt_content' => [-$itemRow['uid'] => 'new']], 'defVals' => ['tt_content' => ['sys_language_uid' => $itemRow['sys_language_uid'], 'colPos' => -1, 'tx_gridelements_allowed' => $values['allowed'], 'tx_gridelements_allowed_grid_types' => $values['allowedGridTypes']]], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]; $url = BackendUtility::getModuleUrl('record_edit', $urlParameters); } $iconsArray = array('new' => '<a href="' . htmlspecialchars($url) . '" title="' . $this->languageService->getLL('newContentElement', true) . '" class="btn btn-default btn-sm">' . $this->iconFactory->getIcon('actions-document-new', 'small') . ' ' . $this->languageService->getLL('content', true) . '</a>'); } $gridContent[$colPos] .= ' <div class="t3js-page-new-ce t3js-page-new-ce-allowed t3-page-ce-wrapper-new-ce btn-group btn-group-sm" id="colpos-' . $itemRow['tx_gridelements_columns'] . '-page-' . $itemRow['pid'] . '-gridcontainer-' . $itemRow['tx_gridelements_container'] . '-' . str_replace('.', '', uniqid('', true)) . '">' . implode('', $iconsArray) . ' </div> <div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div> </div> '; $editUidList[$colPos] .= $editUidList[$colPos] ? ',' . $itemRow['uid'] : $itemRow['uid']; } } } $gridContent[$colPos] .= '</div>'; }