/** * Returns HTML-code, which is a visual representation of a multidimensional array * use t3lib_div::print_array() in order to print an array * Returns false if $array_in is not an array * * @param mixed Array to view * @return string HTML output */ public static function viewArray($array_in) { if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { return \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($array_in); } else { return t3lib_utility_Debug::viewArray($array_in); } }
/** * Returns the internal debug messages as a string. * * @return string */ public function toString() { $messagesAsString = ''; if (!empty($this->debugMessages)) { $messagesAsString = \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($this->debugMessages); } return $messagesAsString; }
public function getParams($PA, $fobj) { $params = unserialize($PA['itemFormElValue']); $output = '<input readonly="readonly" style="display:none" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" onchange="' . htmlspecialchars(implode('', $PA['fieldChangeFunc'])) . '" ' . $PA['onFocus'] . '/> '; $output .= \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($params); return $output; }
/** * Prints the messages to the screen * * @return void */ public function outputDebugLog() { $out = ''; foreach ($this->debugLog as $section => $logData) { $out .= $this->globals->getCObj()->wrap($section, $this->utilityFuncs->getSingle($this->settings, 'sectionHeaderWrap')); $sectionContent = ''; foreach ($logData as $messageData) { $message = str_replace("\n", '<br />', $messageData['message']); $message = $this->globals->getCObj()->wrap($message, $this->utilityFuncs->getSingle($this->settings['severityWrap.'], $messageData['severity'])); $sectionContent .= $this->globals->getCObj()->wrap($message, $this->settings['messageWrap']); if ($messageData['data']) { $sectionContent .= \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($messageData['data']); $sectionContent .= '<br />'; } } $out .= $this->globals->getCObj()->wrap($sectionContent, $this->utilityFuncs->getSingle($this->settings, 'sectionWrap')); } print $out; }
/** * Returns a table with the error-messages. * * @return string HTML print of error log * @todo Define visibility */ public function printErrorLog() { return count($this->errorLog) ? \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($this->errorLog) : ''; }
/** * Find the best service and check if it works. * Returns object of the service class. * * @param string $serviceType Type of service (service key). * @param string $serviceSubType Sub type like file extensions or similar. Defined by the service. * @param mixed $excludeServiceKeys List of service keys which should be excluded in the search for a service. Array or comma list. * @return object|string[] The service object or an array with error infos. */ public static function makeInstanceService($serviceType, $serviceSubType = '', $excludeServiceKeys = []) { $error = false; if (!is_array($excludeServiceKeys)) { $excludeServiceKeys = self::trimExplode(',', $excludeServiceKeys, true); } $requestInfo = ['requestedServiceType' => $serviceType, 'requestedServiceSubType' => $serviceSubType, 'requestedExcludeServiceKeys' => $excludeServiceKeys]; while ($info = ExtensionManagementUtility::findService($serviceType, $serviceSubType, $excludeServiceKeys)) { // provide information about requested service to service object $info = array_merge($info, $requestInfo); // Check persistent object and if found, call directly and exit. if (is_object($GLOBALS['T3_VAR']['makeInstanceService'][$info['className']])) { // update request info in persistent object $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]->info = $info; // reset service and return object $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]->reset(); return $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]; } else { $obj = self::makeInstance($info['className']); if (is_object($obj)) { if (!@is_callable([$obj, 'init'])) { // use silent logging??? I don't think so. die('Broken service:' . DebugUtility::viewArray($info)); } $obj->info = $info; // service available? if ($obj->init()) { // create persistent object $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']] = $obj; return $obj; } $error = $obj->getLastErrorArray(); unset($obj); } } // deactivate the service ExtensionManagementUtility::deactivateService($info['serviceType'], $info['serviceKey']); } return $error; }
/** * Find the best service and check if it works. * Returns object of the service class. * * @param string $serviceType Type of service (service key). * @param string $serviceSubType Sub type like file extensions or similar. Defined by the service. * @param mixed $excludeServiceKeys List of service keys which should be excluded in the search for a service. Array or comma list. * @return object The service object or an array with error info's. */ public static function makeInstanceService($serviceType, $serviceSubType = '', $excludeServiceKeys = array()) { $error = FALSE; if (!is_array($excludeServiceKeys)) { $excludeServiceKeys = self::trimExplode(',', $excludeServiceKeys, 1); } $requestInfo = array('requestedServiceType' => $serviceType, 'requestedServiceSubType' => $serviceSubType, 'requestedExcludeServiceKeys' => $excludeServiceKeys); while ($info = \TYPO3\CMS\Core\Extension\ExtensionManager::findService($serviceType, $serviceSubType, $excludeServiceKeys)) { // provide information about requested service to service object $info = array_merge($info, $requestInfo); // Check persistent object and if found, call directly and exit. if (is_object($GLOBALS['T3_VAR']['makeInstanceService'][$info['className']])) { // update request info in persistent object $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]->info = $info; // reset service and return object $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]->reset(); return $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]; } else { $requireFile = self::getFileAbsFileName($info['classFile']); if (@is_file($requireFile)) { self::requireOnce($requireFile); $obj = self::makeInstance($info['className']); if (is_object($obj)) { if (!@is_callable(array($obj, 'init'))) { // use silent logging??? I don't think so. die('Broken service:' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($info)); } $obj->info = $info; // service available? if ($obj->init()) { // create persistent object $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']] = $obj; // needed to delete temp files register_shutdown_function(array(&$obj, '__destruct')); return $obj; } $error = $obj->getLastErrorArray(); unset($obj); } } } // deactivate the service \TYPO3\CMS\Core\Extension\ExtensionManager::deactivateService($info['serviceType'], $info['serviceKey']); } return $error; }
/** * Save mail on submit * * @param \In2code\Powermail\Domain\Model\Mail $mail * @return void */ protected function saveMail(Mail &$mail = NULL) { $marketingInfos = Div::getMarketingInfos(); $mail->setPid(Div::getStoragePage($this->settings['main']['pid'])); $mail->setSenderMail($this->div->getSenderMailFromArguments($mail)); $mail->setSenderName($this->div->getSenderNameFromArguments($mail)); $mail->setSubject($this->settings['receiver']['subject']); $mail->setReceiverMail($this->settings['receiver']['email']); $mail->setBody(\TYPO3\CMS\Core\Utility\DebugUtility::viewArray($this->div->getVariablesWithLabels($mail))); $mail->setSpamFactor($GLOBALS['TSFE']->fe_user->getKey('ses', 'powermail_spamfactor')); $mail->setTime(time() - Div::getFormStartFromSession($mail->getForm()->getUid())); $mail->setUserAgent(GeneralUtility::getIndpEnv('HTTP_USER_AGENT')); $mail->setMarketingRefererDomain($marketingInfos['refererDomain']); $mail->setMarketingReferer($marketingInfos['referer']); $mail->setMarketingCountry($marketingInfos['country']); $mail->setMarketingMobileDevice($marketingInfos['mobileDevice']); $mail->setMarketingFrontendLanguage($marketingInfos['frontendLanguage']); $mail->setMarketingBrowserLanguage($marketingInfos['browserLanguage']); $mail->setMarketingPageFunnel($marketingInfos['pageFunnel']); if (intval($GLOBALS['TSFE']->fe_user->user['uid']) > 0) { $mail->setFeuser($this->userRepository->findByUid(Div::getPropertyFromLoggedInFeUser('uid'))); } if (empty($this->settings['global']['disableIpLog'])) { $mail->setSenderIp(GeneralUtility::getIndpEnv('REMOTE_ADDR')); } if ($this->settings['main']['optin'] || $this->settings['db']['hidden']) { $mail->setHidden(TRUE); } foreach ($mail->getAnswers() as $answer) { $answer->setPid(Div::getStoragePage($this->settings['main']['pid'])); } $this->mailRepository->add($mail); $this->persistenceManager->persistAll(); }
/** * Get query result code * * @param string $mQ * @param bool|\mysqli_result|object $res MySQLi result object / DBAL object * @param string $table * @return string */ public function getQueryResultCode($mQ, $res, $table) { $out = ''; $cPR = array(); switch ($mQ) { case 'count': $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); $cPR['header'] = 'Count'; $cPR['content'] = '<BR><strong>' . $row[0] . '</strong> records selected.'; break; case 'all': $rowArr = array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $rowArr[] = $this->resultRowDisplay($row, $GLOBALS['TCA'][$table], $table); $lrow = $row; } if (is_array($this->hookArray['beforeResultTable'])) { foreach ($this->hookArray['beforeResultTable'] as $_funcRef) { $out .= GeneralUtility::callUserFunction($_funcRef, $GLOBALS['SOBE']->MOD_SETTINGS, $this); } } if (!empty($rowArr)) { $out .= '<table class="table table-striped table-hover">' . $this->resultRowTitles($lrow, $GLOBALS['TCA'][$table], $table) . implode(LF, $rowArr) . '</table>'; } if (!$out) { $out = '<div class="alert-info">No rows selected!</div>'; } $cPR['header'] = 'Result'; $cPR['content'] = $out; break; case 'csv': $rowArr = array(); $first = 1; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { if ($first) { $rowArr[] = $this->csvValues(array_keys($row), ',', ''); $first = 0; } $rowArr[] = $this->csvValues($row, ',', '"', $GLOBALS['TCA'][$table], $table); } if (!empty($rowArr)) { $out .= '<textarea name="whatever" rows="20" wrap="off"' . $GLOBALS['SOBE']->getModuleTemplate()->formWidth($this->formW) . ' class="text-monospace">' . htmlspecialchars(implode(LF, $rowArr)) . '</textarea>'; if (!$this->noDownloadB) { $out .= '<br><input class="btn btn-default" type="submit" name="download_file" value="Click to download file" onClick="window.location.href=\'' . $this->downloadScript . '\';">'; } // Downloads file: if (GeneralUtility::_GP('download_file')) { $filename = 'TYPO3_' . $table . '_export_' . date('dmy-Hi') . '.csv'; $mimeType = 'application/octet-stream'; header('Content-Type: ' . $mimeType); header('Content-Disposition: attachment; filename=' . $filename); echo implode(CRLF, $rowArr); die; } } if (!$out) { $out = '<em>No rows selected!</em>'; } $cPR['header'] = 'Result'; $cPR['content'] = $out; break; case 'explain': default: while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $out .= '<br />' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($row); } $cPR['header'] = 'Explain SQL query'; $cPR['content'] = $out; } return $cPR; }
/** * Implements the TypoScript data type "getText". This takes a string with parameters and based on those a value from somewhere in the system is returned. * * @param string $string The parameter string, eg. "field : title" or "field : navtitle // field : title" (in the latter case and example of how the value is FIRST splitted by "//" is shown) * @param mixed $fieldArray Alternative field array; If you set this to an array this variable will be used to look up values for the "field" key. Otherwise the current page record in $GLOBALS['TSFE']->page is used. * @return string The value fetched * @see getFieldVal() * @todo Define visibility */ public function getData($string, $fieldArray) { global $TYPO3_CONF_VARS; if (!is_array($fieldArray)) { $fieldArray = $GLOBALS['TSFE']->page; } $retVal = ''; $sections = explode('//', $string); while (!$retVal and list($secKey, $secVal) = each($sections)) { $parts = explode(':', $secVal, 2); $key = trim($parts[1]); if ((string) $key != '') { $type = strtolower(trim($parts[0])); switch ($type) { case 'gp': // Merge GET and POST and get $key out of the merged array $retVal = $this->getGlobal($key, \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET(), \TYPO3\CMS\Core\Utility\GeneralUtility::_POST())); break; case 'tsfe': $retVal = $this->getGlobal('TSFE|' . $key); break; case 'getenv': $retVal = getenv($key); break; case 'getindpenv': $retVal = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv($key); break; case 'field': $retVal = $fieldArray[$key]; break; case 'file': $retVal = $this->getFileDataKey($key); break; case 'parameters': $retVal = $this->parameters[$key]; break; case 'register': $retVal = $GLOBALS['TSFE']->register[$key]; break; case 'global': $retVal = $this->getGlobal($key); break; case 'leveltitle': $nkey = $this->getKey($key, $GLOBALS['TSFE']->tmpl->rootLine); $retVal = $this->rootLineValue($nkey, 'title', stristr($key, 'slide')); break; case 'levelmedia': $nkey = $this->getKey($key, $GLOBALS['TSFE']->tmpl->rootLine); $retVal = $this->rootLineValue($nkey, 'media', stristr($key, 'slide')); break; case 'leveluid': $nkey = $this->getKey($key, $GLOBALS['TSFE']->tmpl->rootLine); $retVal = $this->rootLineValue($nkey, 'uid', stristr($key, 'slide')); break; case 'levelfield': $keyP = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $key); $nkey = $this->getKey($keyP[0], $GLOBALS['TSFE']->tmpl->rootLine); $retVal = $this->rootLineValue($nkey, $keyP[1], strtolower($keyP[2]) == 'slide'); break; case 'fullrootline': $keyP = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $key); $fullKey = intval($keyP[0]) - count($GLOBALS['TSFE']->tmpl->rootLine) + count($GLOBALS['TSFE']->rootLine); if ($fullKey >= 0) { $retVal = $this->rootLineValue($fullKey, $keyP[1], stristr($keyP[2], 'slide'), $GLOBALS['TSFE']->rootLine); } break; case 'date': if (!$key) { $key = 'd/m Y'; } $retVal = date($key, $GLOBALS['EXEC_TIME']); break; case 'page': $retVal = $GLOBALS['TSFE']->page[$key]; break; case 'current': $retVal = $this->data[$this->currentValKey]; break; case 'level': $retVal = count($GLOBALS['TSFE']->tmpl->rootLine) - 1; break; case 'db': $selectParts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(':', $key); $db_rec = $GLOBALS['TSFE']->sys_page->getRawRecord($selectParts[0], $selectParts[1]); if (is_array($db_rec) && $selectParts[2]) { $retVal = $db_rec[$selectParts[2]]; } break; case 'lll': $retVal = $GLOBALS['TSFE']->sL('LLL:' . $key); break; case 'path': $retVal = $GLOBALS['TSFE']->tmpl->getFileName($key); break; case 'cobj': switch ((string) $key) { case 'parentRecordNumber': $retVal = $this->parentRecordNumber; break; } break; case 'debug': switch ((string) $key) { case 'rootLine': $retVal = \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($GLOBALS['TSFE']->tmpl->rootLine); break; case 'fullRootLine': $retVal = \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($GLOBALS['TSFE']->rootLine); break; case 'data': $retVal = \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($this->data); break; } break; } } if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['getData'])) { foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['getData'] as $classData) { $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classData); if (!$hookObject instanceof \TYPO3\CMS\Frontend\ContentObject\ContentObjectGetDataHookInterface) { throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectGetDataHookInterface', 1195044480); } $retVal = $hookObject->getDataExtension($string, $fieldArray, $secVal, $retVal, $this); } } } return $retVal; }
/** * Find the best service and check if it works. * Returns object of the service class. * * @param string $serviceType Type of service (service key). * @param string $serviceSubType Sub type like file extensions or similar. Defined by the service. * @param mixed $excludeServiceKeys List of service keys which should be excluded in the search for a service. Array or comma list. * @return object The service object or an array with error info's. */ public static function makeInstanceService($serviceType, $serviceSubType = '', $excludeServiceKeys = array()) { $error = FALSE; if (!is_array($excludeServiceKeys)) { $excludeServiceKeys = self::trimExplode(',', $excludeServiceKeys, TRUE); } $requestInfo = array('requestedServiceType' => $serviceType, 'requestedServiceSubType' => $serviceSubType, 'requestedExcludeServiceKeys' => $excludeServiceKeys); while ($info = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::findService($serviceType, $serviceSubType, $excludeServiceKeys)) { // provide information about requested service to service object $info = array_merge($info, $requestInfo); // Check persistent object and if found, call directly and exit. if (is_object($GLOBALS['T3_VAR']['makeInstanceService'][$info['className']])) { // update request info in persistent object $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]->info = $info; // reset service and return object $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]->reset(); return $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]; } else { if (isset($info['classFile'])) { // @deprecated since 6.1, will be removed in TYPO3 CMS 6.3 // Option is deprecated, since we now have the autoloader function self::deprecationLog('The option "classFile" of "' . $info['className'] . '" in T3_SERVICES has been deprecated, as this should now be done by the respective ' . 'ext_autoload.php of each extension. This option will be removed in TYPO3 CMS v6.3.'); $requireFile = self::getFileAbsFileName($info['classFile']); if (@is_file($requireFile)) { self::requireOnce($requireFile); } } $obj = self::makeInstance($info['className']); if (is_object($obj)) { if (!@is_callable(array($obj, 'init'))) { // use silent logging??? I don't think so. die('Broken service:' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($info)); } $obj->info = $info; // service available? if ($obj->init()) { // create persistent object $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']] = $obj; return $obj; } $error = $obj->getLastErrorArray(); unset($obj); } } // deactivate the service \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::deactivateService($info['serviceType'], $info['serviceKey']); } return $error; }
/** * Printing the debug-log from the DBAL extension * * To enabled debugging, you will have to enabled it in the configuration! * * @return string HTML content */ protected function printLogMgm() { // Disable debugging in any case... $GLOBALS['TYPO3_DB']->debug = false; // Get cmd: $cmd = (string) GeneralUtility::_GP('cmd'); switch ($cmd) { case 'flush': $res = $GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('tx_dbal_debuglog'); $res = $GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('tx_dbal_debuglog_where'); $outStr = 'Log FLUSHED!'; break; case 'joins': $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('table_join,exec_time,query,script', 'tx_dbal_debuglog', 'table_join!=\'\'', 'table_join,script,exec_time,query'); // Init vars in which to pick up the query result: $tableIndex = array(); $tRows = array(); $tRows[] = ' <tr> <td>Execution time</td> <td>Table joins</td> <td>Script</td> <td>Query</td> </tr>'; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $tableArray = $GLOBALS['TYPO3_DB']->SQLparser->parseFromTables($row['table_join']); // Create table name index: foreach ($tableArray as $a) { foreach ($tableArray as $b) { if ($b['table'] != $a['table']) { $tableIndex[$a['table']][$b['table']] = 1; } } } // Create output row $tRows[] = ' <tr> <td>' . htmlspecialchars($row['exec_time']) . '</td> <td>' . htmlspecialchars($row['table_join']) . '</td> <td>' . htmlspecialchars($row['script']) . '</td> <td>' . htmlspecialchars($row['query']) . '</td> </tr>'; } // Printing direct joins: $outStr .= '<h4>Direct joins:</h4>' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($tableIndex); // Printing total dependencies: foreach ($tableIndex as $priTable => $a) { foreach ($tableIndex as $tableN => $v) { foreach ($v as $tableP => $vv) { if ($tableP == $priTable) { $tableIndex[$priTable] = array_merge($v, $a); } } } } $outStr .= '<h4>Total dependencies:</h4>' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($tableIndex); // Printing data rows: $outStr .= ' <table border="1" cellspacing="0">' . implode('', $tRows) . ' </table>'; break; case 'errors': $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('serdata,exec_time,query,script', 'tx_dbal_debuglog', 'errorFlag>0', '', 'tstamp DESC'); // Init vars in which to pick up the query result: $tRows = array(); $tRows[] = ' <tr> <td>Execution time</td> <td>Error data</td> <td>Script</td> <td>Query</td> </tr>'; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { // Create output row $tRows[] = ' <tr> <td>' . htmlspecialchars($row['exec_time']) . '</td> <td>' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray(unserialize($row['serdata'])) . '</td> <td>' . htmlspecialchars($row['script']) . '</td> <td>' . htmlspecialchars($row['query']) . '</td> </tr>'; } // Printing data rows: $outStr .= ' <table border="1" cellspacing="0">' . implode('', $tRows) . ' </table>'; break; case 'parsing': $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('query,serdata', 'tx_dbal_debuglog', 'errorFlag&2=2'); $tRows = array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { // Create output row $tRows[] = ' <tr> <td>' . htmlspecialchars($row['query']) . '</td> </tr>'; } // Printing data rows: $outStr .= ' <table border="1" cellspacing="0">' . implode('', $tRows) . ' </table>'; break; case 'where': $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp,script,tablename,whereclause', 'tx_dbal_debuglog_where', '', '', 'tstamp DESC'); $tRows = array(); $tRows[] = ' <tr> <td>Time</td> <td>Script</td> <td>Table</td> <td>WHERE clause</td> </tr>'; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $tRows[] = ' <tr> <td>' . BackendUtility::datetime($row['tstamp']) . '</td> <td>' . htmlspecialchars($row['script']) . '</td> <td>' . htmlspecialchars($row['tablename']) . '</td> <td>' . str_replace(array('\'\'', '""', 'IS NULL', 'IS NOT NULL'), array('<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">\'\'</span>', '<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">""</span>', '<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NULL</span>', '<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NOT NULL</span>'), htmlspecialchars($row['whereclause'])) . '</td> </tr>'; } $outStr = ' <table border="1" cellspacing="0">' . implode('', $tRows) . ' </table>'; break; default: // Look for request to view specific script exec: $specTime = GeneralUtility::_GP('specTime'); if ($specTime) { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('exec_time,errorFlag,table_join,serdata,query', 'tx_dbal_debuglog', 'tstamp=' . (int) $specTime); $tRows = array(); $tRows[] = ' <tr> <td>Execution time</td> <td>Error</td> <td>Table joins</td> <td>Data</td> <td>Query</td> </tr>'; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $tRows[] = ' <tr> <td>' . htmlspecialchars($row['exec_time']) . '</td> <td>' . ($row['errorFlag'] ? 1 : 0) . '</td> <td>' . htmlspecialchars($row['table_join']) . '</td> <td>' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray(unserialize($row['serdata'])) . '</td> <td>' . str_replace(array('\'\'', '""', 'IS NULL', 'IS NOT NULL'), array('<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">\'\'</span>', '<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">""</span>', '<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NULL</span>', '<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NOT NULL</span>'), htmlspecialchars($row['query'])) . '</td> </tr>'; } } else { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp,script, SUM(exec_time) as calc_sum, count(*) AS qrycount, MAX(errorFlag) as error', 'tx_dbal_debuglog', '', 'tstamp,script', 'tstamp DESC'); $tRows = array(); $tRows[] = ' <tr> <td>Time</td> <td># of queries</td> <td>Error</td> <td>Time (ms)</td> <td>Script</td> </tr>'; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $tRows[] = ' <tr> <td>' . BackendUtility::datetime($row['tstamp']) . '</td> <td>' . htmlspecialchars($row['qrycount']) . '</td> <td>' . ($row['error'] ? '<strong style="color:#f00">ERR</strong>' : '') . '</td> <td>' . htmlspecialchars($row['calc_sum']) . '</td> <td><a href="' . $this->thisScript . '&specTime=' . (int) $row['tstamp'] . '">' . htmlspecialchars($row['script']) . '</a></td> </tr>'; } } $outStr = ' <table border="1" cellspacing="0">' . implode('', $tRows) . ' </table>'; } $menu = ' <a href="' . $this->thisScript . '&cmd=flush">FLUSH LOG</a> - <a href="' . $this->thisScript . '&cmd=joins">JOINS</a> - <a href="' . $this->thisScript . '&cmd=errors">ERRORS</a> - <a href="' . $this->thisScript . '&cmd=parsing">PARSING</a> - <a href="' . $this->thisScript . '">LOG</a> - <a href="' . $this->thisScript . '&cmd=where">WHERE</a> - <a href="' . htmlspecialchars(GeneralUtility::linkThisScript()) . '" target="tx_debuglog">[New window]</a> <hr /> '; return $menu . $outStr; }
/** * Implements the TypoScript data type "getText". This takes a string with parameters and based on those a value from somewhere in the system is returned. * * @param string $string The parameter string, eg. "field : title" or "field : navtitle // field : title" (in the latter case and example of how the value is FIRST splitted by "//" is shown) * @param NULL|array $fieldArray Alternative field array; If you set this to an array this variable will be used to look up values for the "field" key. Otherwise the current page record in $GLOBALS['TSFE']->page is used. * @return string The value fetched * @see getFieldVal() */ public function getData($string, $fieldArray = null) { $tsfe = $this->getTypoScriptFrontendController(); if (!is_array($fieldArray)) { $fieldArray = $tsfe->page; } $retVal = ''; $sections = explode('//', $string); foreach ($sections as $secKey => $secVal) { if ($retVal) { break; } $parts = explode(':', $secVal, 2); $type = strtolower(trim($parts[0])); $typesWithOutParameters = array('level', 'date', 'current', 'pagelayout'); $key = trim($parts[1]); if ($key != '' || in_array($type, $typesWithOutParameters)) { switch ($type) { case 'gp': // Merge GET and POST and get $key out of the merged array $getPostArray = GeneralUtility::_GET(); ArrayUtility::mergeRecursiveWithOverrule($getPostArray, GeneralUtility::_POST()); $retVal = $this->getGlobal($key, $getPostArray); break; case 'tsfe': $retVal = $this->getGlobal('TSFE|' . $key); break; case 'getenv': $retVal = getenv($key); break; case 'getindpenv': $retVal = $this->getEnvironmentVariable($key); break; case 'field': $retVal = $this->getGlobal($key, $fieldArray); break; case 'file': $retVal = $this->getFileDataKey($key); break; case 'parameters': $retVal = $this->parameters[$key]; break; case 'register': $retVal = $tsfe->register[$key]; break; case 'global': $retVal = $this->getGlobal($key); break; case 'level': $retVal = count($tsfe->tmpl->rootLine) - 1; break; case 'leveltitle': $keyParts = GeneralUtility::trimExplode(',', $key); $numericKey = $this->getKey($keyParts[0], $tsfe->tmpl->rootLine); $retVal = $this->rootLineValue($numericKey, 'title', strtolower($keyParts[1]) === 'slide'); break; case 'levelmedia': $keyParts = GeneralUtility::trimExplode(',', $key); $numericKey = $this->getKey($keyParts[0], $tsfe->tmpl->rootLine); $retVal = $this->rootLineValue($numericKey, 'media', strtolower($keyParts[1]) === 'slide'); break; case 'leveluid': $numericKey = $this->getKey($key, $tsfe->tmpl->rootLine); $retVal = $this->rootLineValue($numericKey, 'uid'); break; case 'levelfield': $keyParts = GeneralUtility::trimExplode(',', $key); $numericKey = $this->getKey($keyParts[0], $tsfe->tmpl->rootLine); $retVal = $this->rootLineValue($numericKey, $keyParts[1], strtolower($keyParts[2]) === 'slide'); break; case 'fullrootline': $keyParts = GeneralUtility::trimExplode(',', $key); $fullKey = (int) $keyParts[0] - count($tsfe->tmpl->rootLine) + count($tsfe->rootLine); if ($fullKey >= 0) { $retVal = $this->rootLineValue($fullKey, $keyParts[1], stristr($keyParts[2], 'slide'), $tsfe->rootLine); } break; case 'date': if (!$key) { $key = 'd/m Y'; } $retVal = date($key, $GLOBALS['EXEC_TIME']); break; case 'page': $retVal = $tsfe->page[$key]; break; case 'pagelayout': // Check if the current page has a value in the DB field "backend_layout" // if empty, check the root line for "backend_layout_next_level" // same as // field = backend_layout // ifEmpty.data = levelfield:-2, backend_layout_next_level, slide // ifEmpty.ifEmpty = default $retVal = $GLOBALS['TSFE']->page['backend_layout']; // If it is set to "none" - don't use any if ($retVal === '-1') { $retVal = 'none'; } elseif ($retVal === '' || $retVal === '0') { // If it not set check the root-line for a layout on next level and use this // Remove first element, which is the current page // See also \TYPO3\CMS\Backend\View\BackendLayoutView::getSelectedCombinedIdentifier() $rootLine = $tsfe->rootLine; array_shift($rootLine); foreach ($rootLine as $rootLinePage) { $retVal = (string) $rootLinePage['backend_layout_next_level']; // If layout for "next level" is set to "none" - don't use any and stop searching if ($retVal === '-1') { $retVal = 'none'; break; } elseif ($retVal !== '' && $retVal !== '0') { // Stop searching if a layout for "next level" is set break; } } } if ($retVal === '0' || $retVal === '') { $retVal = 'default'; } break; case 'current': $retVal = $this->data[$this->currentValKey]; break; case 'db': $selectParts = GeneralUtility::trimExplode(':', $key); $db_rec = $tsfe->sys_page->getRawRecord($selectParts[0], $selectParts[1]); if (is_array($db_rec) && $selectParts[2]) { $retVal = $db_rec[$selectParts[2]]; } break; case 'lll': $retVal = $tsfe->sL('LLL:' . $key); break; case 'path': $retVal = $tsfe->tmpl->getFileName($key); break; case 'cobj': switch ($key) { case 'parentRecordNumber': $retVal = $this->parentRecordNumber; break; } break; case 'debug': switch ($key) { case 'rootLine': $retVal = DebugUtility::viewArray($tsfe->tmpl->rootLine); break; case 'fullRootLine': $retVal = DebugUtility::viewArray($tsfe->rootLine); break; case 'data': $retVal = DebugUtility::viewArray($this->data); break; case 'register': $retVal = DebugUtility::viewArray($tsfe->register); break; case 'page': $retVal = DebugUtility::viewArray($tsfe->page); break; } break; } } if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getData'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getData'] as $classData) { $hookObject = GeneralUtility::getUserObj($classData); if (!$hookObject instanceof ContentObjectGetDataHookInterface) { throw new \UnexpectedValueException('$hookObject must implement interface ' . ContentObjectGetDataHookInterface::class, 1195044480); } $retVal = $hookObject->getDataExtension($string, $fieldArray, $secVal, $retVal, $this); } } } return $retVal; }
/** * Save mail on submit * * @param Mail $mail * @return void */ protected function saveMail(Mail &$mail = null) { $marketingInfos = SessionUtility::getMarketingInfos(); $mail->setPid(FrontendUtility::getStoragePage($this->settings['main']['pid']))->setSenderMail($this->mailRepository->getSenderMailFromArguments($mail))->setSenderName($this->mailRepository->getSenderNameFromArguments($mail))->setSubject($this->settings['receiver']['subject'])->setReceiverMail($this->settings['receiver']['email'])->setBody(DebugUtility::viewArray($this->mailRepository->getVariablesWithMarkersFromMail($mail)))->setSpamFactor(SessionUtility::getSpamFactorFromSession())->setTime(time() - SessionUtility::getFormStartFromSession($mail->getForm()->getUid(), $this->settings))->setUserAgent(GeneralUtility::getIndpEnv('HTTP_USER_AGENT'))->setMarketingRefererDomain($marketingInfos['refererDomain'])->setMarketingReferer($marketingInfos['referer'])->setMarketingCountry($marketingInfos['country'])->setMarketingMobileDevice($marketingInfos['mobileDevice'])->setMarketingFrontendLanguage($marketingInfos['frontendLanguage'])->setMarketingBrowserLanguage($marketingInfos['browserLanguage'])->setMarketingPageFunnel($marketingInfos['pageFunnel']); if (FrontendUtility::isLoggedInFrontendUser()) { $mail->setFeuser($this->userRepository->findByUid(FrontendUtility::getPropertyFromLoggedInFrontendUser('uid'))); } if (!ConfigurationUtility::isDisableIpLogActive()) { $mail->setSenderIp(GeneralUtility::getIndpEnv('REMOTE_ADDR')); } if ($this->settings['main']['optin'] || $this->settings['db']['hidden']) { $mail->setHidden(true); } foreach ($mail->getAnswers() as $answer) { $answer->setPid(FrontendUtility::getStoragePage($this->settings['main']['pid'])); } $this->mailRepository->add($mail); $this->persistenceManager->persistAll(); }
/** * Create the rows for display of the page tree * For each page a number of rows are shown displaying GET variable configuration * * @param array Page row * @param string Page icon and title for row * @return string HTML <tr> content (one or more) */ public function drawURLs_addRowsForPage(array $pageRow, $pageTitleAndIcon) { $skipMessage = ''; // Get list of configurations $configurations = $this->getUrlsForPageRow($pageRow, $skipMessage); if (count($this->incomingConfigurationSelection) > 0) { // remove configuration that does not match the current selection foreach ($configurations as $confKey => $confArray) { if (!in_array($confKey, $this->incomingConfigurationSelection)) { unset($configurations[$confKey]); } } } // Traverse parameter combinations: $c = 0; $cc = 0; $content = ''; if (count($configurations)) { foreach ($configurations as $confKey => $confArray) { // Title column: if (!$c) { $titleClm = '<td rowspan="' . count($configurations) . '">' . $pageTitleAndIcon . '</td>'; } else { $titleClm = ''; } if (!in_array($pageRow['uid'], $this->expandExcludeString($confArray['subCfg']['exclude']))) { // URL list: $urlList = $this->urlListFromUrlArray($confArray, $pageRow, $this->scheduledTime, $this->reqMinute, $this->submitCrawlUrls, $this->downloadCrawlUrls, $this->duplicateTrack, $this->downloadUrls, $this->incomingProcInstructions); // Expanded parameters: $paramExpanded = ''; $calcAccu = array(); $calcRes = 1; foreach ($confArray['paramExpanded'] as $gVar => $gVal) { $paramExpanded .= ' <tr> <td class="bgColor4-20">' . htmlspecialchars('&' . $gVar . '=') . '<br/>' . '(' . count($gVal) . ')' . '</td> <td class="bgColor4" nowrap="nowrap">' . nl2br(htmlspecialchars(implode(chr(10), $gVal))) . '</td> </tr> '; $calcRes *= count($gVal); $calcAccu[] = count($gVal); } $paramExpanded = '<table class="lrPadding c-list param-expanded">' . $paramExpanded . '</table>'; $paramExpanded .= 'Comb: ' . implode('*', $calcAccu) . '=' . $calcRes; // Options $optionValues = ''; if ($confArray['subCfg']['userGroups']) { $optionValues .= 'User Groups: ' . $confArray['subCfg']['userGroups'] . '<br/>'; } if ($confArray['subCfg']['baseUrl']) { $optionValues .= 'Base Url: ' . $confArray['subCfg']['baseUrl'] . '<br/>'; } if ($confArray['subCfg']['procInstrFilter']) { $optionValues .= 'ProcInstr: ' . $confArray['subCfg']['procInstrFilter'] . '<br/>'; } // Compile row: $content .= ' <tr class="bgColor' . ($c % 2 ? '-20' : '-10') . '"> ' . $titleClm . ' <td>' . htmlspecialchars($confKey) . '</td> <td>' . nl2br(htmlspecialchars(rawurldecode(trim(str_replace('&', chr(10) . '&', \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', $confArray['paramParsed'])))))) . '</td> <td>' . $paramExpanded . '</td> <td nowrap="nowrap">' . $urlList . '</td> <td nowrap="nowrap">' . $optionValues . '</td> <td nowrap="nowrap">' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($confArray['subCfg']['procInstrParams.']) . '</td> </tr>'; } else { $content .= '<tr class="bgColor' . ($c % 2 ? '-20' : '-10') . '"> ' . $titleClm . ' <td>' . htmlspecialchars($confKey) . '</td> <td colspan="5"><em>No entries</em> (Page is excluded in this configuration)</td> </tr>'; } $c++; } } else { $message = !empty($skipMessage) ? ' (' . $skipMessage . ')' : ''; // Compile row: $content .= ' <tr class="bgColor-20" style="border-bottom: 1px solid black;"> <td>' . $pageTitleAndIcon . '</td> <td colspan="6"><em>No entries</em>' . $message . '</td> </tr>'; } return $content; }
/** * Re-indexing files/records attached to a page. * * @param integer Phash value * @param integer The page uid for the section record (file/url could appear more than one place you know...) * @return string HTML content * @todo Define visibility */ public function reindexPhash($phash, $pageId) { // Query: $resultRow = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('ISEC.*, IP.*', 'index_phash IP, index_section ISEC', 'IP.phash = ISEC.phash AND IP.phash = ' . (int) $phash . ' AND ISEC.page_id = ' . (int) $pageId); $content = ''; if (is_array($resultRow)) { if ($resultRow['item_type'] && $resultRow['item_type'] !== '0') { // (Re)-Indexing file on page. $indexerObj = GeneralUtility::makeInstance('TYPO3\\CMS\\IndexedSearch\\Indexer'); $indexerObj->backend_initIndexer($pageId, 0, 0, '', $this->getUidRootLineForClosestTemplate($pageId)); // URL or local file: if ($resultRow['externalUrl']) { $indexerObj->indexExternalUrl($resultRow['data_filename']); } else { $indexerObj->indexRegularDocument($resultRow['data_filename'], TRUE); } if ($indexerObj->file_phash_arr['phash'] != $resultRow['phash']) { $content .= 'ERROR: phash (' . $indexerObj->file_phash_arr['phash'] . ') did NOT match ' . $resultRow['phash'] . ' for strange reasons!'; } $content .= '<h4>Log for re-indexing of "' . htmlspecialchars($resultRow['data_filename']) . '":</h4>'; $content .= \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($indexerObj->internal_log); $content .= '<h4>Hash-array, page:</h4>'; $content .= \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($indexerObj->hash); $content .= '<h4>Hash-array, file:</h4>'; $content .= \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($indexerObj->file_phash_arr); } } // Link back to list. $content .= $this->linkList(); return $content; }
/** * Shows the log of indexed URLs * * @return string HTML output */ function drawLog() { global $BACK_PATH; $output = ''; // Init: $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); $this->crawlerObj->setAccessMode('gui'); $this->crawlerObj->setID = \TYPO3\CMS\Core\Utility\GeneralUtility::md5int(microtime()); $this->CSVExport = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_csv'); // Read URL: if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_read')) { $this->crawlerObj->readUrl(intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_read')), TRUE); } // Look for set ID sent - if it is, we will display contents of that set: $showSetId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); // Show details: if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details')) { // Get entry record: list($q_entry) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tx_crawler_queue', 'qid=' . intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details'))); // Explode values: $resStatus = $this->getResStatus($q_entry); $q_entry['parameters'] = unserialize($q_entry['parameters']); $q_entry['result_data'] = unserialize($q_entry['result_data']); if (is_array($q_entry['result_data'])) { $q_entry['result_data']['content'] = unserialize($q_entry['result_data']['content']); } if (!$this->pObj->MOD_SETTINGS['log_resultLog']) { unset($q_entry['result_data']['content']['log']); } // Print rudimentary details: $output .= ' <br /><br /> <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.back') . '" name="_back" /> <input type="hidden" value="' . $this->pObj->id . '" name="id" /> <input type="hidden" value="' . $showSetId . '" name="setID" /> <br /> Current server time: ' . date('H:i:s', time()) . '<br />' . 'Status: ' . $resStatus . '<br />' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($q_entry); } else { // Show list: // If either id or set id, show list: if ($this->pObj->id || $showSetId) { if ($this->pObj->id) { // Drawing tree: $tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView'); $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); $tree->init('AND ' . $perms_clause); // Set root row: $HTML = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $this->pObj->pageinfo); $HTML = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $this->pObj->pageinfo); $tree->tree[] = array('row' => $this->pObj->pageinfo, 'HTML' => $HTML); // Get branch beneath: if ($this->pObj->MOD_SETTINGS['depth']) { $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS['depth'], ''); } // Traverse page tree: $code = ''; $count = 0; foreach ($tree->tree as $data) { $code .= $this->drawLog_addRows($data['row'], $data['HTML'] . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages', $data['row'], TRUE), intval($this->pObj->MOD_SETTINGS['itemsPerPage'])); if (++$count == 1000) { break; } } } else { $code = ''; $code .= $this->drawLog_addRows($showSetId, 'Set ID: ' . $showSetId); } if ($code) { $output .= ' <br /><br /> <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.reloadlist') . '" name="_reload" /> <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.downloadcsv') . '" name="_csv" /> <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.flushvisiblequeue') . '" name="_flush" onclick="return confirm(\'' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.confirmyouresure') . '\');" /> <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.flushfullqueue') . '" name="_flush_all" onclick="return confirm(\'' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.confirmyouresure') . '\');" /> <input type="hidden" value="' . $this->pObj->id . '" name="id" /> <input type="hidden" value="' . $showSetId . '" name="setID" /> <br /> ' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.curtime') . ': ' . date('H:i:s', time()) . ' <br /><br /> <table class="lrPadding c-list crawlerlog">' . $this->drawLog_printTableHeader() . $code . '</table>'; } } else { // Otherwise show available sets: $setList = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('set_id, count(*) as count_value, scheduled', 'tx_crawler_queue', '', 'set_id, scheduled', 'scheduled DESC'); $code = ' <tr class="bgColor5 tableheader"> <td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.setid') . ':</td> <td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.count') . 't:</td> <td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time') . ':</td> </tr> '; $cc = 0; foreach ($setList as $set) { $code .= ' <tr class="bgColor' . ($cc % 2 ? '-20' : '-10') . '"> <td><a href="' . htmlspecialchars('index.php?setID=' . $set['set_id']) . '">' . $set['set_id'] . '</a></td> <td>' . $set['count_value'] . '</td> <td>' . \TYPO3\CMS\Backend\Utility\BackendUtility::dateTimeAge($set['scheduled']) . '</td> </tr> '; $cc++; } $output .= ' <br /><br /> <table class="lrPadding c-list">' . $code . '</table>'; } } if ($this->CSVExport) { $this->outputCsvFile(); } // Return output return $output; }
/** * Print TypoScript parsing log * * @return string HTML table with the information about parsing times. */ public function printTSlog() { if (!$this->isEnabled) { return ''; } // Calculate times and keys for the tsStackLog foreach ($this->tsStackLog as $uniqueId => &$data) { $data['endtime'] = $this->getDifferenceToStarttime($data['endtime']); $data['starttime'] = $this->getDifferenceToStarttime($data['starttime']); $data['deltatime'] = $data['endtime'] - $data['starttime']; if (is_array($data['tsStack'])) { $data['key'] = implode($data['stackPointer'] ? '.' : '/', end($data['tsStack'])); } } unset($data); // Create hierarchical array of keys pointing to the stack $arr = array(); foreach ($this->tsStackLog as $uniqueId => $data) { $this->createHierarchyArray($arr, $data['level'], $uniqueId); } // Parsing the registeret content and create icon-html for the tree $this->tsStackLog[$arr['0.'][0]]['content'] = $this->fixContent($arr['0.'], $this->tsStackLog[$arr['0.'][0]]['content'], '', 0, $arr['0.'][0]); // Displaying the tree: $outputArr = array(); $outputArr[] = $this->fw('TypoScript Key'); $outputArr[] = $this->fw('Value'); if ($this->printConf['allTime']) { $outputArr[] = $this->fw('Time'); $outputArr[] = $this->fw('Own'); $outputArr[] = $this->fw('Sub'); $outputArr[] = $this->fw('Total'); } else { $outputArr[] = $this->fw('Own'); } $outputArr[] = $this->fw('Details'); $out = ''; foreach ($outputArr as $row) { $out .= ' <th><strong>' . $row . '</strong></th>'; } $out = '<tr class="typo3-adminPanel-itemRow">' . $out . '</tr>'; $flag_tree = $this->printConf['flag_tree']; $flag_messages = $this->printConf['flag_messages']; $flag_content = $this->printConf['flag_content']; $flag_queries = $this->printConf['flag_queries']; $keyLgd = $this->printConf['keyLgd']; $c = 0; foreach ($this->tsStackLog as $uniqueId => $data) { if ($this->highlightLongerThan && (int) $data['owntime'] > (int) $this->highlightLongerThan) { $logRowClass = 'typo3-adminPanel-logRow-highlight'; } else { $logRowClass = $c % 2 ? 'line-odd' : 'line-even'; } $logRowClass .= ' typo3-adminPanel-section-content-title'; $item = ''; // If first... if (!$c) { $data['icons'] = ''; $data['key'] = 'Script Start'; $data['value'] = ''; } // Key label: $keyLabel = ''; if (!$flag_tree && $data['stackPointer']) { $temp = array(); foreach ($data['tsStack'] as $k => $v) { $temp[] = GeneralUtility::fixed_lgd_cs(implode($v, $k ? '.' : '/'), -$keyLgd); } array_pop($temp); $temp = array_reverse($temp); array_pop($temp); if (!empty($temp)) { $keyLabel = '<br /><span style="color:#999999;">' . implode($temp, '<br />') . '</span>'; } } if ($flag_tree) { $tmp = GeneralUtility::trimExplode('.', $data['key'], true); $theLabel = end($tmp); } else { $theLabel = $data['key']; } $theLabel = GeneralUtility::fixed_lgd_cs($theLabel, -$keyLgd); $theLabel = $data['stackPointer'] ? '<span class="stackPointer">' . $theLabel . '</span>' : $theLabel; $keyLabel = $theLabel . $keyLabel; $item .= '<td class="' . $logRowClass . '">' . ($flag_tree ? $data['icons'] : '') . $this->fw($keyLabel) . '</td>'; // Key value: $keyValue = $data['value']; $item .= '<td class="' . $logRowClass . ' typo3-adminPanel-tsLogTime">' . $this->fw(htmlspecialchars($keyValue)) . '</td>'; if ($this->printConf['allTime']) { $item .= '<td class="' . $logRowClass . ' typo3-adminPanel-tsLogTime"> ' . $this->fw($data['starttime']) . '</td>'; $item .= '<td class="' . $logRowClass . ' typo3-adminPanel-tsLogTime"> ' . $this->fw($data['owntime']) . '</td>'; $item .= '<td class="' . $logRowClass . ' typo3-adminPanel-tsLogTime"> ' . $this->fw($data['subtime'] ? '+' . $data['subtime'] : '') . '</td>'; $item .= '<td class="' . $logRowClass . ' typo3-adminPanel-tsLogTime"> ' . $this->fw($data['subtime'] ? '=' . $data['deltatime'] : '') . '</td>'; } else { $item .= '<td class="' . $logRowClass . ' typo3-adminPanel-tsLogTime"> ' . $this->fw($data['owntime']) . '</td>'; } // Messages: $msgArr = array(); $msg = ''; if ($flag_messages && is_array($data['message'])) { foreach ($data['message'] as $v) { $msgArr[] = nl2br($v); } } if ($flag_queries && is_array($data['selectQuery'])) { $msgArr[] = \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($data['selectQuery']); } if ($flag_content && (string) $data['content'] !== '') { $maxlen = 120; // Break lines which are too longer than $maxlen chars (can happen if content contains long paths...) if (preg_match_all('/(\\S{' . $maxlen . ',})/', $data['content'], $reg)) { foreach ($reg[1] as $key => $match) { $match = preg_replace('/(.{' . $maxlen . '})/', '$1 ', $match); $data['content'] = str_replace($reg[0][$key], $match, $data['content']); } } $msgArr[] = '<span style="color:#000066;">' . nl2br($data['content']) . '</span>'; } if (!empty($msgArr)) { $msg = implode($msgArr, '<hr />'); } $item .= '<td valign="top" class="' . $logRowClass . '" style="text-align:left;">' . $this->fw($msg) . '</td>'; $out .= '<tr class="typo3-adminPanel-itemRow">' . $item . '</tr>'; $c++; } $out = '<table class="typo3-adminPanel-table typo3-adminPanel-tsLog">' . $out . '</table>'; return $out; }
/** * Implements the TypoScript data type "getText". This takes a string with parameters and based on those a value from somewhere in the system is returned. * * @param string $string The parameter string, eg. "field : title" or "field : navtitle // field : title" (in the latter case and example of how the value is FIRST splitted by "//" is shown) * @param NULL|array $fieldArray Alternative field array; If you set this to an array this variable will be used to look up values for the "field" key. Otherwise the current page record in $GLOBALS['TSFE']->page is used. * @return string The value fetched * @see getFieldVal() */ public function getData($string, $fieldArray = NULL) { if (!is_array($fieldArray)) { $fieldArray = $GLOBALS['TSFE']->page; } $retVal = ''; $sections = explode('//', $string); foreach ($sections as $secKey => $secVal) { if ($retVal) { break; } $parts = explode(':', $secVal, 2); $type = strtolower(trim($parts[0])); $typesWithOutParameters = array('level', 'date', 'current'); $key = trim($parts[1]); if ($key != '' || in_array($type, $typesWithOutParameters)) { switch ($type) { case 'gp': // Merge GET and POST and get $key out of the merged array $getPostArray = GeneralUtility::_GET(); ArrayUtility::mergeRecursiveWithOverrule($getPostArray, GeneralUtility::_POST()); $retVal = $this->getGlobal($key, $getPostArray); break; case 'tsfe': $retVal = $this->getGlobal('TSFE|' . $key); break; case 'getenv': $retVal = getenv($key); break; case 'getindpenv': $retVal = $this->getEnvironmentVariable($key); break; case 'field': $retVal = $this->getGlobal($key, $fieldArray); break; case 'file': $retVal = $this->getFileDataKey($key); break; case 'parameters': $retVal = $this->parameters[$key]; break; case 'register': $retVal = $GLOBALS['TSFE']->register[$key]; break; case 'global': $retVal = $this->getGlobal($key); break; case 'level': $retVal = count($GLOBALS['TSFE']->tmpl->rootLine) - 1; break; case 'leveltitle': $keyParts = GeneralUtility::trimExplode(',', $key); $numericKey = $this->getKey($keyParts[0], $GLOBALS['TSFE']->tmpl->rootLine); $retVal = $this->rootLineValue($numericKey, 'title', strtolower($keyParts[1]) === 'slide'); break; case 'levelmedia': $keyParts = GeneralUtility::trimExplode(',', $key); $numericKey = $this->getKey($keyParts[0], $GLOBALS['TSFE']->tmpl->rootLine); $retVal = $this->rootLineValue($numericKey, 'media', strtolower($keyParts[1]) === 'slide'); break; case 'leveluid': $numericKey = $this->getKey($key, $GLOBALS['TSFE']->tmpl->rootLine); $retVal = $this->rootLineValue($numericKey, 'uid'); break; case 'levelfield': $keyParts = GeneralUtility::trimExplode(',', $key); $numericKey = $this->getKey($keyParts[0], $GLOBALS['TSFE']->tmpl->rootLine); $retVal = $this->rootLineValue($numericKey, $keyParts[1], strtolower($keyParts[2]) === 'slide'); break; case 'fullrootline': $keyParts = GeneralUtility::trimExplode(',', $key); $fullKey = (int) $keyParts[0] - count($GLOBALS['TSFE']->tmpl->rootLine) + count($GLOBALS['TSFE']->rootLine); if ($fullKey >= 0) { $retVal = $this->rootLineValue($fullKey, $keyParts[1], stristr($keyParts[2], 'slide'), $GLOBALS['TSFE']->rootLine); } break; case 'date': if (!$key) { $key = 'd/m Y'; } $retVal = date($key, $GLOBALS['EXEC_TIME']); break; case 'page': $retVal = $GLOBALS['TSFE']->page[$key]; break; case 'current': $retVal = $this->data[$this->currentValKey]; break; case 'db': $selectParts = GeneralUtility::trimExplode(':', $key); $db_rec = $GLOBALS['TSFE']->sys_page->getRawRecord($selectParts[0], $selectParts[1]); if (is_array($db_rec) && $selectParts[2]) { $retVal = $db_rec[$selectParts[2]]; } break; case 'lll': $retVal = $GLOBALS['TSFE']->sL('LLL:' . $key); break; case 'path': $retVal = $GLOBALS['TSFE']->tmpl->getFileName($key); break; case 'cobj': switch ($key) { case 'parentRecordNumber': $retVal = $this->parentRecordNumber; break; } break; case 'debug': switch ($key) { case 'rootLine': $retVal = DebugUtility::viewArray($GLOBALS['TSFE']->tmpl->rootLine); break; case 'fullRootLine': $retVal = DebugUtility::viewArray($GLOBALS['TSFE']->rootLine); break; case 'data': $retVal = DebugUtility::viewArray($this->data); break; case 'register': $retVal = DebugUtility::viewArray($GLOBALS['TSFE']->register); break; case 'page': $retVal = DebugUtility::viewArray($GLOBALS['TSFE']->page); break; } break; } } if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getData'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getData'] as $classData) { $hookObject = GeneralUtility::getUserObj($classData); if (!$hookObject instanceof ContentObjectGetDataHookInterface) { throw new \UnexpectedValueException('$hookObject must implement interface ' . ContentObjectGetDataHookInterface::class, 1195044480); } $retVal = $hookObject->getDataExtension($string, $fieldArray, $secVal, $retVal, $this); } } } return $retVal; }
/** * Returns a table with the error-messages. * * @return string HTML print of error log */ public function printErrorLog() { return !empty($this->errorLog) ? DebugUtility::viewArray($this->errorLog) : ''; }
/** * Get query result code * * @param string $type * @param array $dataRows Rows to display * @param string $table * @return string */ public function getQueryResultCode($type, array $dataRows, $table) { $out = ''; $cPR = []; switch ($type) { case 'count': $cPR['header'] = 'Count'; $cPR['content'] = '<BR><strong>' . $dataRows[0] . '</strong> records selected.'; break; case 'all': $rowArr = []; $dataRow = null; foreach ($dataRows as $dataRow) { $rowArr[] = $this->resultRowDisplay($dataRow, $GLOBALS['TCA'][$table], $table); } if (is_array($this->hookArray['beforeResultTable'])) { foreach ($this->hookArray['beforeResultTable'] as $_funcRef) { $out .= GeneralUtility::callUserFunction($_funcRef, $GLOBALS['SOBE']->MOD_SETTINGS, $this); } } if (!empty($rowArr)) { $out .= '<table class="table table-striped table-hover">' . $this->resultRowTitles($dataRow, $GLOBALS['TCA'][$table], $table) . implode(LF, $rowArr) . '</table>'; } if (!$out) { $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, 'No rows selected!', '', FlashMessage::INFO); $out = $flashMessage->getMessageAsMarkup(); } $cPR['header'] = 'Result'; $cPR['content'] = $out; break; case 'csv': $rowArr = []; $first = 1; foreach ($dataRows as $dataRow) { if ($first) { $rowArr[] = $this->csvValues(array_keys($dataRow), ',', ''); $first = 0; } $rowArr[] = $this->csvValues($dataRow, ',', '"', $GLOBALS['TCA'][$table], $table); } if (!empty($rowArr)) { $out .= '<textarea name="whatever" rows="20" class="text-monospace" style="width:100%">' . htmlspecialchars(implode(LF, $rowArr)) . '</textarea>'; if (!$this->noDownloadB) { $out .= '<br><input class="btn btn-default" type="submit" name="download_file" ' . 'value="Click to download file" onClick="window.location.href=\'' . $this->downloadScript . '\';">'; } // Downloads file: // @todo: args. routing anyone? if (GeneralUtility::_GP('download_file')) { $filename = 'TYPO3_' . $table . '_export_' . date('dmy-Hi') . '.csv'; $mimeType = 'application/octet-stream'; header('Content-Type: ' . $mimeType); header('Content-Disposition: attachment; filename=' . $filename); echo implode(CRLF, $rowArr); die; } } if (!$out) { $out = '<em>No rows selected!</em>'; } $cPR['header'] = 'Result'; $cPR['content'] = $out; break; case 'explain': default: foreach ($dataRows as $dataRow) { $out .= '<br />' . DebugUtility::viewArray($dataRow); } $cPR['header'] = 'Explain SQL query'; $cPR['content'] = $out; } return $cPR; }