/** * Main method which is called by EXT:scheduler. * * Needs to return TRUE or FALSE in order to tell EXT:scheduler whether the task * went through smoothly. * * @return bool */ public function execute() { $this->init(); $migrationQueue = array(); $res = $this->database->exec_SELECTquery('tt_content.uid AS tt_content_uid, sys_file_reference.uid AS sys_file_reference_uid, tt_content.imagecaption AS imagecaption', 'tt_content INNER JOIN sys_file_reference ON tt_content.uid = sys_file_reference.uid_foreign', 'tt_content.imagecaption != "" AND sys_file_reference.fieldname = "image" AND sys_file_reference.tablenames = "tt_content"'); while ($row = $this->database->sql_fetch_assoc($res)) { // remove trailing linebreaks (and spaces) in imagecaption $row['imagecaption'] = preg_replace('/(\\r\\n|\\r|\\n| )+$/', '', $row['imagecaption']); $imagecaptionLines = preg_split("/\r\n|\r|\n/", $row['imagecaption']); $numberOfImagecaptionLines = count($imagecaptionLines); if ($numberOfImagecaptionLines > $this->getNumberOfFalRecordsOfTtContentRecord($row['tt_content_uid'])) { // ...it is very likely that tt_content.imagecaption is not used as it // is generally supposed to be used. Most probably tt_content.imagecaption // is not used as a one-line-per-image field but as a all-lines-for-one-image // field. This records must be migrated manually. GeneralUtility::devLog('tt_content record ' . $row['tt_content_uid'] . ": The number of lines in tt_content.imagecaption exceeds the record's number of FAL records! Therefore tt_content.imagecaption was neither migrated nor deleted for this tt_content record.", 'dam_falmigration', 2); } else { if (!array_key_exists($row['tt_content_uid'], $migrationQueue)) { $migrationQueue[$row['tt_content_uid']] = $imagecaptionLines; } } } $this->migrate($migrationQueue); // mark task as successfully executed return TRUE; }
/** * Helper function to find the parents class recordType * @param \EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject * @return string */ public function render(\EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject) { $classSettings = $this->configurationManager->getExtbaseClassConfiguration($domainObject->getParentClass()); if (isset($classSettings['recordType'])) { $parentRecordType = \EBT\ExtensionBuilder\Utility\Tools::convertClassNameToRecordType($classSettings['recordType']); } else { $parentRecordType = \EBT\ExtensionBuilder\Utility\Tools::convertClassNameToRecordType($domainObject->getParentClass()); $existingTypes = $GLOBALS['TCA'][$domainObject->getDatabaseTableName()]['types']; \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Parent Record type: ' . $parentRecordType, 'extension_builder', 2, $existingTypes); if (is_array($existingTypes) && !isset($existingTypes[$parentRecordType])) { // no types field for parent record type configured, use the default type 1 if (isset($existingTypes['1'])) { $parentRecordType = 1; } else { //if it not exists get first existing key $parentRecordType = reset(array_keys($existingTypes)); } } } $this->templateVariableContainer->add('parentModelName', end(explode('\\', $domainObject->getParentClass()))); $this->templateVariableContainer->add('parentRecordType', $parentRecordType); $content = $this->renderChildren(); $this->templateVariableContainer->remove('parentRecordType'); $this->templateVariableContainer->remove('parentModelName'); return $content; }
/** * The main method of the PlugIn * * @access public * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return string The content that is displayed on the website */ public function main($content, $conf) { $this->init($conf); // Turn cache on. $this->setCache(TRUE); // Quit without doing anything if required configuration variables are not set. if (empty($this->conf['pages'])) { if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_collection->main(' . $content . ', [data])] Incomplete plugin configuration', $this->extKey, SYSLOG_SEVERITY_WARNING, $conf); } return $content; } // Load template file. if (!empty($this->conf['templateFile'])) { $this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###'); } else { $this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/collection/template.tmpl'), '###TEMPLATE###'); } // Get hook objects. $this->hookObjects = tx_dlf_helper::getHookObjects($this->scriptRelPath); if (!empty($this->piVars['collection'])) { $this->showSingleCollection(intval($this->piVars['collection'])); } else { $content .= $this->showCollectionList(); } return $this->pi_wrapInBaseClass($content); }
/** * The main method of the PlugIn * * @access public * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return string The content that is displayed on the website */ public function main($content, $conf) { $this->init($conf); // Turn cache on. $this->setCache(TRUE); // Quit without doing anything if required configuration variables are not set. if (empty($this->conf['pages'])) { if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_statistics->main(' . $content . ', [data])] Incomplete plugin configuration', $this->extKey, SYSLOG_SEVERITY_WARNING, $conf); } return $content; } // Get description. $content .= $this->pi_RTEcssText($this->conf['description']); // Check for selected collections. if ($this->conf['collections']) { // Include only selected collections. $resultTitles = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_documents.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_collections.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_documents.partof=0 AND tx_dlf_collections.uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']) . ') AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_collections'), 'tx_dlf_documents.uid', '', ''); $resultVolumes = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_documents.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_collections.pid=' . intval($this->conf['pages']) . ' AND NOT tx_dlf_documents.uid IN (SELECT DISTINCT tx_dlf_documents.partof FROM tx_dlf_documents WHERE NOT tx_dlf_documents.partof=0' . tx_dlf_helper::whereClause('tx_dlf_documents') . ') AND tx_dlf_collections.uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']) . ') AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_collections'), 'tx_dlf_documents.uid', '', ''); } else { // Include all collections. $resultTitles = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_documents.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_documents.partof=0' . tx_dlf_helper::whereClause('tx_dlf_documents'), '', '', ''); $resultVolumes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_documents.pid=' . intval($this->conf['pages']) . ' AND NOT tx_dlf_documents.uid IN (SELECT DISTINCT tx_dlf_documents.partof FROM tx_dlf_documents WHERE NOT tx_dlf_documents.partof=0' . tx_dlf_helper::whereClause('tx_dlf_documents') . ')' . tx_dlf_helper::whereClause('tx_dlf_documents'), '', '', ''); } $countTitles = $GLOBALS['TYPO3_DB']->sql_num_rows($resultTitles); $countVolumes = $GLOBALS['TYPO3_DB']->sql_num_rows($resultVolumes); // Set replacements. $replace = array('key' => array('###TITLES###', '###VOLUMES###'), 'value' => array($countTitles . ($countTitles > 1 ? $this->pi_getLL('titles', '', TRUE) : $this->pi_getLL('title', '', TRUE)), $countVolumes . ($countVolumes > 1 ? $this->pi_getLL('volumes', '', TRUE) : $this->pi_getLL('volume', '', TRUE)))); // Apply replacements. $content = str_replace($replace['key'], $replace['value'], $content); return $this->pi_wrapInBaseClass($content); }
/** * Writes exception to different logs * * @param \Exception|\Throwable $exception The exception(PHP 5.x) or throwable(PHP >= 7.0) object. * @param string $context The context where the exception was thrown, WEB or CLI * @return void * @see \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog(), \TYPO3\CMS\Core\Utility\GeneralUtility::devLog() * @TODO #72293 This will change to \Throwable only if we are >= PHP7.0 only */ protected function writeLogEntries($exception, $context) { // Do not write any logs for this message to avoid filling up tables or files with illegal requests if ($exception->getCode() === 1396795884) { return; } $filePathAndName = $exception->getFile(); $exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : ''; $logTitle = 'Core: Exception handler (' . $context . ')'; $logMessage = 'Uncaught TYPO3 Exception: ' . $exceptionCodeNumber . $exception->getMessage() . ' | ' . get_class($exception) . ' thrown in file ' . $filePathAndName . ' in line ' . $exception->getLine(); if ($context === 'WEB') { $logMessage .= '. Requested URL: ' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'); } $backtrace = $exception->getTrace(); // Write error message to the configured syslogs GeneralUtility::sysLog($logMessage, $logTitle, GeneralUtility::SYSLOG_SEVERITY_FATAL); // When database credentials are wrong, the exception is probably // caused by this. Therefor we cannot do any database operation, // otherwise this will lead into recurring exceptions. try { // Write error message to devlog // see: $TYPO3_CONF_VARS['SYS']['enable_exceptionDLOG'] if (TYPO3_EXCEPTION_DLOG) { GeneralUtility::devLog($logMessage, $logTitle, 3, array('TYPO3_MODE' => TYPO3_MODE, 'backtrace' => $backtrace)); } // Write error message to sys_log table $this->writeLog($logTitle . ': ' . $logMessage); } catch (\Exception $exception) { } }
/** * Writes exception to different logs * * @param Exception $exception The exception * @param string $context The context where the exception was thrown, WEB or CLI * @return void * @see t3lib_div::sysLog(), t3lib_div::devLog() */ protected function writeLogEntries(\Exception $exception, $context) { $filePathAndName = $exception->getFile(); $exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : ''; $logTitle = 'Core: Exception handler (' . $context . ')'; $logMessage = 'Uncaught TYPO3 Exception: ' . $exceptionCodeNumber . $exception->getMessage() . ' | ' . get_class($exception) . ' thrown in file ' . $filePathAndName . ' in line ' . $exception->getLine(); if ($context === 'WEB') { $logMessage .= '. Requested URL: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'); } $backtrace = $exception->getTrace(); // Write error message to the configured syslogs \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($logMessage, $logTitle, \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_FATAL); // When database credentials are wrong, the exception is probably // caused by this. Therefor we cannot do any database operation, // otherwise this will lead into recurring exceptions. try { // In case an error occurs before a database connection exists, try // to connect to the DB to be able to write the devlog/sys_log entry if (isset($GLOBALS['TYPO3_DB']) && is_object($GLOBALS['TYPO3_DB']) && empty($GLOBALS['TYPO3_DB']->link)) { $GLOBALS['TYPO3_DB']->connectDB(); } // Write error message to devlog // see: $TYPO3_CONF_VARS['SYS']['enable_exceptionDLOG'] if (TYPO3_EXCEPTION_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($logMessage, $logTitle, 3, array('TYPO3_MODE' => TYPO3_MODE, 'backtrace' => $backtrace)); } // Write error message to sys_log table $this->writeLog($logTitle . ': ' . $logMessage); } catch (\Exception $exception) { } }
/** * Devlog if enabled * * @param string $functionName Functionname * @param string $additionalData The log data * * @return void */ public static function devLog($functionName, $additionalData = '') { self::loadExtConf(); if (self::$extConf['enableDevLog']) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($functionName, 'varnish', 0, $additionalData); } }
/** * Process the submitted credentials. * In this case decrypt the password if it is RSA encrypted. * * @param array $loginData Credentials that are submitted and potentially modified by other services * @param string $passwordTransmissionStrategy Keyword of how the password has been hashed or encrypted before submission * @return boolean */ public function processLoginData(array &$loginData, $passwordTransmissionStrategy) { $isProcessed = FALSE; if ($passwordTransmissionStrategy === 'rsa') { $storage = \TYPO3\CMS\Rsaauth\Storage\StorageFactory::getStorage(); /** @var $storage \TYPO3\CMS\Rsaauth\Storage\AbstractStorage */ // Decrypt the password $password = $loginData['uident']; $key = $storage->get(); if ($key != NULL && substr($password, 0, 4) === 'rsa:') { // Decode password and store it in loginData $decryptedPassword = $this->backend->decrypt($key, substr($password, 4)); if ($decryptedPassword != NULL) { $loginData['uident_text'] = $decryptedPassword; $isProcessed = TRUE; } else { if ($this->pObj->writeDevLog) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Process login data: Failed to RSA decrypt password', 'TYPO3\\CMS\\Rsaauth\\RsaAuthService'); } } // Remove the key $storage->put(NULL); } else { if ($this->pObj->writeDevLog) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Process login data: passwordTransmissionStrategy has been set to "rsa" but no rsa encrypted password has been found.', 'TYPO3\\CMS\\Rsaauth\\RsaAuthService'); } } } return $isProcessed; }
/** * Download a file * * @param string $file Path to the file * @param array $configuration configuration used to render the filelink cObject * @param boolean $hideError define if an error should be displayed if file not found * @param string $class optional class * @param string $target target * @param string $alt alt text * @param string $title title text * @param integer $secure news uid * @return string * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException */ public function render($file, $configuration = array(), $hideError = FALSE, $class = '', $target = '', $alt = '', $title = '', $secure = 0) { if (!is_file($file)) { $errorMessage = sprintf('Given file "%s" for %s is not valid', htmlspecialchars($file), get_class()); \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($errorMessage, 'moox_news', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_WARNING); if (!$hideError) { throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException('Given file is not a valid file: ' . htmlspecialchars($file)); } } $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_cObj'); $fileInformation = pathinfo($file); $fileInformation['file'] = $file; $fileInformation['size'] = filesize($file); $cObj->data = $fileInformation; // set a basic configuration for cObj->filelink $tsConfiguration = array('path' => $fileInformation['dirname'] . '/', 'ATagParams' => 'class="download-link basic-class ' . strtolower($fileInformation['extension']) . (!empty($class) ? ' ' . $class : '') . '"', 'labelStdWrap.' => array('cObject.' => array('value' => $this->renderChildren()))); // Fallback if no configuration given if (!is_array($configuration)) { $configuration = array('labelStdWrap.' => array('cObject' => 'TEXT')); } else { /** @var $typoscriptService \TYPO3\CMS\Extbase\Service\TypoScriptService */ $typoscriptService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService'); $configuration = $typoscriptService->convertPlainArrayToTypoScriptArray($configuration); } // merge default configuration with optional configuration \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($tsConfiguration, $configuration); if (!empty($target)) { $tsConfiguration['target'] = $target; } if (!empty($alt)) { $tsConfiguration['altText'] = $alt; } if (!empty($title)) { $tsConfiguration['titleText'] = $title; } $link = $cObj->filelink($fileInformation['basename'], $tsConfiguration); $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['moox_news']); $securityExcludedFileTypes = array(); if ($extConf['securityExcludedFileTypes'] != "") { $securityExcludedFileTypes = explode(",", $extConf['securityExcludedFileTypes']); } $securityFileLocators = array(); if ($extConf['securityFileLocators'] != "") { $securityFileLocators = explode(",", $extConf['securityFileLocators']); } if ($extConf['securityUrlIndicator'] != "") { $securityUrlIndicator = $extConf['securityUrlIndicator']; } else { $securityUrlIndicator = "mxsecured"; } if ($secure > 0 && !in_array($fileInformation['extension'], $securityExcludedFileTypes)) { foreach ($securityFileLocators as $securityFileLocator) { $dividerPos = strpos($link, $securityFileLocator); if ($dividerPos !== FALSE) { $link = str_replace($securityFileLocator, $securityFileLocator . $securityUrlIndicator . '/' . base_convert($secure + 999999, 10, 21) . '/' . $GLOBALS["TSFE"]->id . '/', $link); } } } return $link; }
/** * Clear Cach Post Processing Hook * * @param $params * @param $pObj */ public function clearCachePostProc(&$params, &$pObj) { $now = time(); //cached files older than x minutes. $minutes = (int) $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['webkitpdf']['cacheThreshold']; $threshold = $now - $minutes * 60; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,crdate,filename', 'tx_webkitpdf_cache', 'crdate<' . $threshold); if ($res && $GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $filenames = array(); while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) { $filenames[] = $row['filename']; } $GLOBALS['TYPO3_DB']->sql_free_result($res); $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_webkitpdf_cache', 'crdate<' . $threshold); foreach ($filenames as $file) { if (file_exists($file)) { unlink($file); } } // Write a message to devlog if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['webkitpdf']['debug'] === 1) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Clearing cached files older than ' . $minutes . ' minutes.', 'webkitpdf', -1); } } }
/** * Initializes the Records * All Products are read, no matter what the rights - only editing is restricted! * * @param int $index Leaf index * @param array $parentIndices Parent Indices * @param \CommerceTeam\Commerce\Tree\Leaf\Data $parentLeafData Parent leafData * * @return void */ public function initRecords($index, array $parentIndices, \CommerceTeam\Commerce\Tree\Leaf\Data &$parentLeafData) { if (!is_numeric($index) || !is_array($parentIndices) || is_null($parentLeafData)) { if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('initRecords (CommerceTeam\\Commerce\\Tree\\Leaf\\SlaveData) gets passed invalid parameters.', COMMERCE_EXTKEY, 3); } return; } // Check if User's Group may view the records $backendUser = $this->getBackendUser(); if (!$backendUser->check('tables_select', $this->table)) { $this->records = null; if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('initRecords User is not allowed to view table: ' . $this->table, COMMERCE_EXTKEY, 3); } return; } // Store the position Uids $this->getPositionsByIndices($index, $parentIndices); // Get the uids of the open parent - returns uids which are currently open $recordUids = $parentLeafData->getRecordsUids(); if ($recordUids == null) { return; } // Read all items if ($this->useMMTable) { $this->where['uid_foreign'] = implode(',', $recordUids); $this->where['uid_local'] = 0; } else { $this->where[$this->itemParentField] = implode(',', $recordUids); $this->where['uid'] = 0; } $this->records = $this->loadRecords(); }
/** * Starts the execution of a frontend helper. * * @param Tx_Solr_IndexQueue_PageIndexerRequest $request Page indexer request * @param Tx_Solr_IndexQueue_PageIndexerResponse $response Page indexer response */ public function processRequest(Tx_Solr_IndexQueue_PageIndexerRequest $request, Tx_Solr_IndexQueue_PageIndexerResponse $response) { $this->request = $request; $this->response = $response; if ($request->getParameter('loggingEnabled')) { GeneralUtility::devLog('Page indexer request received', 'solr', 0, array('request' => (array) $request)); } }
/** * Show the content of the update script (if any). * * @param string $extensionKey Extension key * @return void * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException */ public function showAction($extensionKey) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Request for update script', 'extensionmanager', 0, $extensionKey); /** @var $updateScriptUtility \TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility */ $updateScriptUtility = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\UpdateScriptUtility::class); $updateScriptResult = $updateScriptUtility->executeUpdateIfNeeded($extensionKey); $this->view->assign('updateScriptResult', $updateScriptResult)->assign('extensionKey', $extensionKey); }
/** * Logs a message and optionally data to devlog * * @param string $message Log message * @param array $data Optional data * @return void */ protected function log($message, array $data = array()) { // TODO refactor to have logger injected if (!$this->configuration['logging']) { return; } GeneralUtility::devLog($message, 'tika', 0, $data); }
/** * Extracts the markup wrapped with TYPO3SEARCH_begin and TYPO3SEARCH_end * markers. * * @param string $html HTML markup with TYPO3SEARCH markers for content that should be indexed * @return string HTML markup found between TYPO3SEARCH markers */ protected function extractContentMarkedForIndexing($html) { preg_match_all('/<!--\\s*?TYPO3SEARCH_begin\\s*?-->.*?<!--\\s*?TYPO3SEARCH_end\\s*?-->/mis', $html, $indexableContents); $indexableContent = implode($indexableContents[0], ''); if (empty($indexableContent) && $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['logging.']['indexing.']['missingTypo3SearchMarkers']) { GeneralUtility::devLog('No TYPO3SEARCH markers found.', 'solr', 2); } return $indexableContent; }
/** * Spam-Validation of given Params * see powermail/doc/SpamDetection for formula * * @param \In2code\Powermail\Domain\Model\Mail $mail * @return bool */ public function isValid($mail) { if (!$this->settings['spamshield.']['_enable']) { return $this->getIsValid(); } $spamFactor = $this->settings['spamshield.']['factor'] / 100; // Different checks to increase spam indicator $this->honeypodCheck($this->settings['spamshield.']['indicator.']['honeypod']); $this->linkCheck($mail, $this->settings['spamshield.']['indicator.']['link'], $this->settings['spamshield.']['indicator.']['linkLimit']); $this->nameCheck($mail, $this->settings['spamshield.']['indicator.']['name']); $this->sessionCheck($mail, $this->settings['spamshield.']['indicator.']['session']); $this->uniqueCheck($mail, $this->settings['spamshield.']['indicator.']['unique']); $this->blacklistStringCheck($mail, $this->settings['spamshield.']['indicator.']['blacklistString']); $this->blacklistIpCheck($this->settings['spamshield.']['indicator.']['blacklistIp']); // spam formula with asymptote 1 (100%) if ($this->spamIndicator > 0) { $thisSpamFactor = -1 / $this->spamIndicator + 1; } else { $thisSpamFactor = 0; } // Save Spam Factor in session for db storage $GLOBALS['TSFE']->fe_user->setKey('ses', 'powermail_spamfactor', $this->formatSpamFactor($thisSpamFactor)); $GLOBALS['TSFE']->storeSessionData(); // Spam debugging if ($this->settings['debug.']['spamshield']) { GeneralUtility::devLog('Spamshield (Spamfactor ' . $this->formatSpamFactor($thisSpamFactor) . ')', 'powermail', 0, $this->getMessages()); } // if spam if ($thisSpamFactor >= $spamFactor) { $this->addError('spam_details', $this->formatSpamFactor($thisSpamFactor)); $this->setIsValid(FALSE); // Send notification email to admin if (GeneralUtility::validEmail($this->settings['spamshield.']['email'])) { $subject = 'Spam in powermail form recognized'; $message = 'Possible spam in powermail form on page with PID ' . $GLOBALS['TSFE']->id; $message .= "\n\n"; $message .= 'Spamfactor of this mail: ' . $this->formatSpamFactor($thisSpamFactor) . "\n"; $message .= "\n\n"; $message .= 'Failed Spamchecks:' . "\n"; $message .= Div::viewPlainArray($this->getMessages()); $message .= "\n\n"; $message .= 'Given Form variables:' . "\n"; foreach ($mail->getAnswers() as $answer) { $message .= $answer->getField()->getTitle(); $message .= ': '; $message .= $answer->getValue(); $message .= "\n"; } $header = 'MIME-Version: 1.0' . "\r\n"; $header .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $header .= 'From: powermail@' . GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY') . "\r\n"; GeneralUtility::plainMailEncoded($this->settings['spamshield.']['email'], $subject, $message, $header); } } return $this->getIsValid(); }
/** * Extracts the markup wrapped with TYPO3SEARCH_begin and TYPO3SEARCH_end * markers. * * @param string $html HTML markup with TYPO3SEARCH markers for content that should be indexed * @return string HTML markup found between TYPO3SEARCH markers */ protected function extractContentMarkedForIndexing($html) { preg_match_all('/<!--\\s*?TYPO3SEARCH_begin\\s*?-->.*?<!--\\s*?TYPO3SEARCH_end\\s*?-->/mis', $html, $indexableContents); $indexableContent = implode($indexableContents[0], ''); $indexableContent = $this->excludeContentByClass($indexableContent); if (empty($indexableContent) && $this->getConfiguration()->getLoggingIndexingMissingTypo3SearchMarkers()) { GeneralUtility::devLog('No TYPO3SEARCH markers found.', 'solr', 2); } return $indexableContent; }
/** * @param $message, The Message to log * @param int $severity type and severity of log entry * @param array|null $additionalData optional Array of additional data for the log entry which will be logged too * @param string|null $packageKey optional string with a free key for the application so the log entries are easier * to find * @return void */ public function log($message, $severity = self::SEVERITY_NOTICE, $additionalData = null, $packageKey = null) { if (!isset($packageKey)) { $packageKey = ''; } if (!isset($additionalData)) { $additionalData = false; } GeneralUtility::devLog($message, $packageKey, $severity, $additionalData); }
/** * Modify a TYPO3 insert array (key -> value) , and adds the uid that should be forced during INSERT * * @param string $tableName * @param array $fields_values */ public function modifyInsertFields($tableName, array $fields_values) { if ($this->needsSequenzer($tableName)) { if (isset($fields_values['uid'])) { $e = new Exception(); GeneralUtility::devLog('UID ' . $fields_values['uid'] . ' is already set for table "' . $tableName . '"', 'aoe_dbsequenzer', 2, $e->getTraceAsString()); } else { $fields_values['uid'] = $this->sequenzer->getNextIdForTable($tableName); } } return $fields_values; }
/** * Authenticates the request, runs the frontend helpers defined by the * request, and registers its own shutdown() method for execution at * hook_eofe in tslib/class.tslib_fe.php. * * @return void */ public function run() { if (!$this->request->isAuthenticated()) { GeneralUtility::devLog('Invalid Index Queue Frontend Request detected!', 'solr', 3, array('page indexer request' => (array) $this->request, 'index queue header' => $_SERVER['HTTP_X_TX_SOLR_IQ'])); http_response_code(403); die('Invalid Index Queue Request!'); } $this->dispatcher->dispatch($this->request, $this->response); // register shutdown method here instead of in ext_localconf.php to // allow frontend helpers to execute at hook_eofe in // tslib/class.tslib_fe.php before shuting down $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_eofe'][__CLASS__] = '&Tx_Solr_IndexQueue_PageIndexerRequestHandler->shutdown'; }
/** * Inserts the messages to the devlog * * @return void */ public function outputDebugLog() { foreach ($this->debugLog as $section => $logData) { foreach ($logData as $messageData) { $message = $section . ': ' . $messageData['message']; $data = FALSE; if (is_array($messageData['data'])) { $data = $messageData['data']; } \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($message, 'formhandler', $severity, $data); } } }
/** * run( ) : Function executed from the Scheduler. * Sends an email * * @access public * @return boolean */ public function run($taskUid, $deal_adminemail) { $success = FALSE; $this->deal_adminemail = $deal_adminemail; $this->taskUid = $taskUid; if (empty($this->deal_adminemail)) { // No email defined, just log the task $this->promptErrorNoEmail(); \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[TYPO3\\CMS\\Scheduler\\Example\\TestTask]: No email address given', 'deal', 2); return $success; } // If an email address is defined, send a message to it // NOTE: the TYPO3_DLOG constant is not used in this case, as this is a test task // and debugging is its main purpose anyway \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[TYPO3\\CMS\\Scheduler\\Example\\TestTask]: Test email sent to "' . $this->deal_adminemail . '"', 'deal', 0); // Get execution information $exec = $this->getExecution(); // Get call method if (basename(PATH_thisScript) == 'cli_dispatch.phpsh') { $calledBy = 'CLI module dispatcher'; $site = '-'; } else { $calledBy = 'TYPO3 backend'; $site = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); } $start = $exec->getStart(); $end = $exec->getEnd(); $interval = $exec->getInterval(); $multiple = $exec->getMultiple(); $cronCmd = $exec->getCronCmd(); $mailBody = 'DEAL! TEST-TASK' . LF . '- - - - - - - - - - - - - - - -' . LF . 'UID: ' . $this->taskUid . LF . 'Sitename: ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . LF . 'Site: ' . $site . LF . 'Called by: ' . $calledBy . LF . 'tstamp: ' . date('Y-m-d H:i:s') . ' [' . time() . ']' . LF . 'maxLifetime: ' . $this->scheduler->extConf['maxLifetime'] . LF . 'start: ' . date('Y-m-d H:i:s', $start) . ' [' . $start . ']' . LF . 'end: ' . (empty($end) ? '-' : date('Y-m-d H:i:s', $end) . ' [' . $end . ']') . LF . 'interval: ' . $interval . LF . 'multiple: ' . ($multiple ? 'yes' : 'no') . LF . 'cronCmd: ' . ($cronCmd ? $cronCmd : 'not used'); // Prepare mailer and send the mail try { /** @var $mailer \TYPO3\CMS\Core\Mail\MailMessage */ $mailer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage'); $mailer->setFrom(array($this->deal_adminemail => 'DEAL! TEST-TASK')); $mailer->setReplyTo(array($this->deal_adminemail => 'DEAL! TEST-TASK')); $mailer->setSubject('DEAL! TEST-TASK'); $mailer->setBody($mailBody); $mailer->setTo($this->deal_adminemail); $mailsSend = $mailer->send(); $this->promptHelpInCaseOfNoEmail($mailsSend); $this->promptSuccess($mailsSend); $success = $mailsSend > 0; } catch (\Exception $e) { throw new \TYPO3\CMS\Core\Exception($e->getMessage()); } return $success; }
/** * Wrapping title in a-tags. * * @param string $title Title * @param string $row Record * @param int $bank Pointer (which mount point number) * * @return string */ public function wrapTitle($title, $row, $bank = 0) { if (!is_array($row) || !is_numeric($bank)) { if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('wrapTitle (Tx_Commerce_Tree_Leaf_View) gets passed invalid parameters.', COMMERCE_EXTKEY, 3); } return ''; } // Max. size for Title of 30 $title = '' != $title ? \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($title, 30) : $this->getLL('leaf.noTitle'); $aOnClick = 'return link_commerce(\'' . $this->getJumpToParam($row) . '\');'; $style = $row['uid'] == $this->openCat && 0 != $this->openCat ? 'style="color: red; font-weight: bold"' : ''; $res = $this->noRootOnclick && 0 == $row['uid'] || $this->noOnclick ? $title : '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '" ' . $style . '>' . $title . '</a>'; return $res; }
/** * Returns the link from the tree used to jump to a destination. * * @param array $row Array with the ID Information * * @return string */ public function getJumpToParam(array &$row) { if (!is_array($row)) { if (TYPO3_DLOG) { GeneralUtility::devLog('getJumpToParam gets passed invalid parameters.', COMMERCE_EXTKEY, 3); } return ''; } $value = 'edit'; if ($this->realValues) { $value = $this->table . '_' . $row['uid']; } $res = 'edit[' . $this->table . '][' . $row['uid'] . ']=' . $value; return $res; }
/** * Renders the size of a file using \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize * * @param string $file Path to the file * @param string $format Labels for bytes, kilo, mega and giga separated by vertical bar (|) and possibly encapsulated in "". Eg: " | K| M| G" (which is the default value) * @param boolean $hideError Define if an error should be displayed if file not found * @param integer $fileSize File size * @return string * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException */ public function render($file = NULL, $format = '', $hideError = FALSE, $fileSize = NULL) { if (!is_file($file)) { $errorMessage = sprintf('Given file "%s" for %s is not valid', htmlspecialchars($file), get_class()); \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($errorMessage, 'news', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_WARNING); if (!$hideError) { throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException('Given file is not a valid file: ' . htmlspecialchars($file)); } } if ($fileSize === NULL) { $result = \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize(filesize($file), $format); } else { $result = \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($fileSize, $format); } return $result; }
/** * Returns the link from the tree used to jump to a destination * * @param array $row Array with the ID Information * * @return string */ public function getJumpToParam(array $row) { if (!is_array($row)) { if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('getJumpToParam (Tx_Commerce_Tree_Leaf_View) gets passed invalid parameters.', COMMERCE_EXTKEY, 3); } return ''; } // get the UID of the Products SysFolder $productPid = Tx_Commerce_Utility_BackendUtility::getProductFolderUid(); $res = '&id=' . $productPid . '&control[' . $this->table . '][uid]=' . $row['uid']; if ($this->realValues) { $res = $this->table . '_' . $row['uid']; } return $res; }
/** * Indexes items from the Index Queue. * * @return void */ protected function indexItems() { $limit = $this->documentsToIndexLimit; $indexQueue = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\IndexQueue\\Queue'); // get items to index $itemsToIndex = $indexQueue->getItemsToIndex($this->site, $limit); foreach ($itemsToIndex as $itemToIndex) { try { // try indexing $itemIndexed = $this->indexItem($itemToIndex); } catch (\Exception $e) { $indexQueue->markItemAsFailed($itemToIndex, $e->getCode() . ': ' . $e->__toString()); GeneralUtility::devLog('Failed indexing Index Queue item ' . $itemToIndex->getIndexQueueUid(), 'solr', 3, array('code' => $e->getCode(), 'message' => $e->getMessage(), 'trace' => $e->getTrace(), 'item' => (array) $itemToIndex)); } } }
/** * Set properties of an object/array in cobj->LOAD_REGISTER which can then * be used to be loaded via TS with register:name * * @param string $properties comma separated list of properties * @param mixed $object object or array to get the properties * @param string $prefix optional prefix * @return void */ public static function setRegisterProperties($properties, $object, $prefix = 'news') { if (!empty($properties) && !is_null($object)) { $cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $items = GeneralUtility::trimExplode(',', $properties, TRUE); $register = array(); foreach ($items as $item) { $key = $prefix . ucfirst($item); try { $register[$key] = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getProperty($object, $item); } catch (\Exception $e) { GeneralUtility::devLog($e->getMessage(), 'news', GeneralUtility::SYSLOG_SEVERITY_WARNING); } } $cObj->LOAD_REGISTER($register, ''); } }
/** * Set properties of an object/array in cobj->LOAD_REGISTER which can then * be used to be loaded via TS with register:name * * @param string $properties comma separated list of properties * @param mixed $object object or array to get the properties * @param string $prefix optional prefix * @return void */ public static function setRegisterProperties($properties, $object, $prefix = 'news') { if (!empty($properties) && !is_null($object)) { /** @var ContentObjectRenderer $cObj */ $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class); $items = GeneralUtility::trimExplode(',', $properties, true); $register = []; foreach ($items as $item) { $key = $prefix . ucfirst($item); try { $register[$key] = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getProperty($object, $item); } catch (\Exception $e) { GeneralUtility::devLog($e->getMessage(), 'news', GeneralUtility::SYSLOG_SEVERITY_WARNING); } } $cObj->cObjGetSingle('LOAD_REGISTER', $register); } }
/** * Returns TRUE, if the given property ($value) matches the session captcha Value. * * If at least one error occurred, the result is FALSE. * * @param mixed $value The value that should be validated * @return boolean TRUE if the value is valid, FALSE if an error occured */ public function isValid($value) { // Overwrite $word if options contains a value if ($this->options['value']) { $value = $this->options['value']; } $captcha = GeneralUtility::makeInstance('Tx_CaptchaViewhelper_Captcha'); try { if ($value !== $captcha->getTextInSession()) { $this->addError(LocalizationUtility::translate('tx_pwcomments.validation_error.captcha', 'PwComments'), 170320111501.0); return FALSE; } } catch (\Exception $e) { GeneralUtility::devLog('captcha error: ' . $e->getMessage(), 'captcha_viewhelper', 2); return FALSE; } return TRUE; }