Example #1
0
 /**
  * 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;
 }
 /**
  * @return string
  */
 public static function getDebugTrail()
 {
     tx_rnbase::load('tx_rnbase_util_TYPO3');
     if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) {
         return \TYPO3\CMS\Core\Utility\DebugUtility::debugTrail();
     } else {
         return t3lib_utility_Debug::debugTrail();
     }
 }
Example #3
0
 /**
  * @param $parameters
  */
 protected function writeDebugMessage($parameters)
 {
     $message = isset($parameters['msg']) ? $parameters['msg'] : '';
     if (TYPO3_MODE == 'BE') {
         DebugUtility::debug($parameters, $parameters['extKey'], 'DevLog ext:solr: ' . $message);
     } else {
         echo $message . ':<br/>';
         DebuggerUtility::var_dump($parameters);
     }
 }
    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;
    }
Example #5
0
function debug($variable = '', $name = '*variable*', $line = '*line*', $file = '*file*', $recursiveDepth = 3, $debugLevel = E_DEBUG)
{
    // If you wish to use the debug()-function, and it does not output something,
    // please edit the IP mask in TYPO3_CONF_VARS
    if (!\TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
        return;
    }
    if (is_object($GLOBALS['error']) && @is_callable([$GLOBALS['error'], 'debug'])) {
        $GLOBALS['error']->debug($variable, $name, $line, $file, $recursiveDepth, $debugLevel);
    } else {
        $title = $name === '*variable*' ? '' : $name;
        $group = $line === '*line*' ? null : $line;
        \TYPO3\CMS\Core\Utility\DebugUtility::debug($variable, $title, $group);
    }
}
 /**
  * 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;
 }
Example #7
0
 /**
  * Logs a call to a deprecated function.
  * The log message will be taken from the annotation.
  *
  * @return void
  */
 public static function logDeprecatedFunction()
 {
     if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
         return;
     }
     $trail = debug_backtrace();
     if ($trail[1]['type']) {
         $function = new \ReflectionMethod($trail[1]['class'], $trail[1]['function']);
     } else {
         $function = new \ReflectionFunction($trail[1]['function']);
     }
     $msg = '';
     if (preg_match('/@deprecated\\s+(.*)/', $function->getDocComment(), $match)) {
         $msg = $match[1];
     }
     // Trigger PHP error with a short message: <function> is deprecated (called from <source>, defined in <source>)
     $errorMsg = 'Function ' . $trail[1]['function'];
     if ($trail[1]['class']) {
         $errorMsg .= ' of class ' . $trail[1]['class'];
     }
     $errorMsg .= ' is deprecated (called from ' . $trail[1]['file'] . '#' . $trail[1]['line'] . ', defined in ' . $function->getFileName() . '#' . $function->getStartLine() . ')';
     // Write a longer message to the deprecation log: <function> <annotion> - <trace> (<source>)
     $logMsg = $trail[1]['class'] . $trail[1]['type'] . $trail[1]['function'];
     $logMsg .= '() - ' . $msg . ' - ' . \TYPO3\CMS\Core\Utility\DebugUtility::debugTrail();
     $logMsg .= ' (' . substr($function->getFileName(), strlen(PATH_site)) . '#' . $function->getStartLine() . ')';
     self::deprecationLog($logMsg);
 }
Example #8
0
    /**
     * 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 . '&amp;specTime=' . (int) $row['tstamp'] . '">' . htmlspecialchars($row['script']) . '</a></td>
								</tr>';
                    }
                }
                $outStr = '
						<table border="1" cellspacing="0">' . implode('', $tRows) . '
						</table>';
        }
        $menu = '
					<a href="' . $this->thisScript . '&amp;cmd=flush">FLUSH LOG</a> -
					<a href="' . $this->thisScript . '&amp;cmd=joins">JOINS</a> -
					<a href="' . $this->thisScript . '&amp;cmd=errors">ERRORS</a> -
					<a href="' . $this->thisScript . '&amp;cmd=parsing">PARSING</a> -
					<a href="' . $this->thisScript . '">LOG</a> -
					<a href="' . $this->thisScript . '&amp;cmd=where">WHERE</a> -

					<a href="' . htmlspecialchars(GeneralUtility::linkThisScript()) . '" target="tx_debuglog">[New window]</a>
					<hr />
		';
        return $menu . $outStr;
    }
Example #9
0
 /**
  * Replaces a file with file in local file system.
  *
  * @param string $fileIdentifier
  * @param string $localFilePath
  * @return bool TRUE if the operation succeeded
  */
 public function replaceFile($fileIdentifier, $localFilePath)
 {
     DebugUtility::debug(__FUNCTION__, 'Method');
     $this->cache->flush();
 }
Example #10
0
 /**
  * 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) : '';
 }
Example #11
0
 /**
  * Debugging var with header and group.
  *
  * @param mixed $var Var
  * @param string $header Header
  * @param string $group Group
  *
  * @return void
  */
 protected function debug($var, $header, $group)
 {
     if ($this->debug) {
         \TYPO3\CMS\Core\Utility\DebugUtility::debug($var, $header, $group);
     }
 }
 /**
  * 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;
 }
 /**
  * Explain select queries
  * If $this->explainOutput is set, SELECT queries will be explained here. Only queries with more than one possible result row will be displayed.
  * The output is either printed as raw HTML output or embedded into the TS admin panel (checkbox must be enabled!)
  *
  * @todo Feature is not DBAL-compliant
  *
  * @param string $query SQL query
  * @param string $from_table Table(s) from which to select. This is what comes right after "FROM ...". Required value.
  * @param int $row_count Number of resulting rows
  * @return bool TRUE if explain was run, FALSE otherwise
  */
 protected function explain($query, $from_table, $row_count)
 {
     $debugAllowedForIp = GeneralUtility::cmpIP(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
     if ((int) $this->explainOutput == 1 || (int) $this->explainOutput == 2 && $debugAllowedForIp) {
         // Raw HTML output
         $explainMode = 1;
     } elseif ((int) $this->explainOutput == 3 && is_object($GLOBALS['TT'])) {
         // Embed the output into the TS admin panel
         $explainMode = 2;
     } else {
         return false;
     }
     $error = $this->sql_error();
     $trail = \TYPO3\CMS\Core\Utility\DebugUtility::debugTrail();
     $explain_tables = array();
     $explain_output = array();
     $res = $this->sql_query('EXPLAIN ' . $query, $this->link);
     if (is_a($res, '\\mysqli_result')) {
         while ($tempRow = $this->sql_fetch_assoc($res)) {
             $explain_output[] = $tempRow;
             $explain_tables[] = $tempRow['table'];
         }
         $this->sql_free_result($res);
     }
     $indices_output = array();
     // Notice: Rows are skipped if there is only one result, or if no conditions are set
     if ($explain_output[0]['rows'] > 1 || GeneralUtility::inList('ALL', $explain_output[0]['type'])) {
         // Only enable output if it's really useful
         $debug = true;
         foreach ($explain_tables as $table) {
             $tableRes = $this->sql_query('SHOW TABLE STATUS LIKE \'' . $table . '\'');
             $isTable = $this->sql_num_rows($tableRes);
             if ($isTable) {
                 $res = $this->sql_query('SHOW INDEX FROM ' . $table, $this->link);
                 if (is_a($res, '\\mysqli_result')) {
                     while ($tempRow = $this->sql_fetch_assoc($res)) {
                         $indices_output[] = $tempRow;
                     }
                     $this->sql_free_result($res);
                 }
             }
             $this->sql_free_result($tableRes);
         }
     } else {
         $debug = false;
     }
     if ($debug) {
         if ($explainMode) {
             $data = array();
             $data['query'] = $query;
             $data['trail'] = $trail;
             $data['row_count'] = $row_count;
             if ($error) {
                 $data['error'] = $error;
             }
             if (!empty($explain_output)) {
                 $data['explain'] = $explain_output;
             }
             if (!empty($indices_output)) {
                 $data['indices'] = $indices_output;
             }
             if ($explainMode == 1) {
                 \TYPO3\CMS\Core\Utility\DebugUtility::debug($data, 'Tables: ' . $from_table, 'DB SQL EXPLAIN');
             } elseif ($explainMode == 2) {
                 $GLOBALS['TT']->setTSselectQuery($data);
             }
         }
         return true;
     }
     return false;
 }
Example #14
0
 /**
  * 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();
 }
 /**
  * store collected data of defined indexers to db
  * @param integer $storagePid
  * @param string $title
  * @param string $type
  * @param integer $targetPid
  * @param string $content
  * @param string $tags
  * @param string $params
  * @param string $abstract
  * @param integer $language
  * @param integer $starttime
  * @param integer $endtime
  * @param string $fe_group
  * @param boolean $debugOnly
  * @param array $additionalFields
  * @return boolean|integer
  */
 public function storeInIndex($storagePid, $title, $type, $targetPid, $content, $tags = '', $params = '', $abstract = '', $language = 0, $starttime = 0, $endtime = 0, $fe_group = '', $debugOnly = false, $additionalFields = array())
 {
     // if there are errors found in current record return false and break processing
     if (!$this->checkIfRecordHasErrorsBeforeIndexing($storagePid, $title, $type, $targetPid)) {
         return false;
     }
     // optionally add tag set in the indexer configuration
     if (!empty($this->indexerConfig['filteroption']) && (substr($type, 0, 4) != 'file' || substr($type, 0, 4) == 'file' && $this->indexerConfig['index_use_page_tags_for_files'] || $this->indexerConfig['type'] == 'file')) {
         $indexerTag = $this->getTag($this->indexerConfig['filteroption']);
         $tagChar = $this->extConf['prePostTagChar'];
         if ($tags) {
             $tags .= ',' . $tagChar . $indexerTag . $tagChar;
         } else {
             $tags = $tagChar . $indexerTag . $tagChar;
         }
         $tags = TYPO3\CMS\Core\Utility\GeneralUtility::uniqueList($tags);
     }
     $table = 'tx_kesearch_index';
     $fieldValues = $this->createFieldValuesForIndexing($storagePid, $title, $type, $targetPid, $content, $tags, $params, $abstract, $language, $starttime, $endtime, $fe_group, $additionalFields);
     // check if record already exists
     if (substr($type, 0, 4) == 'file') {
         $recordExists = $this->checkIfFileWasIndexed($fieldValues['type'], $fieldValues['hash']);
     } else {
         $recordExists = $this->checkIfRecordWasIndexed($fieldValues['orig_uid'], $fieldValues['pid'], $fieldValues['type'], $fieldValues['language']);
     }
     if ($recordExists) {
         // update existing record
         $where = 'uid=' . intval($this->currentRow['uid']);
         unset($fieldValues['crdate']);
         if ($debugOnly) {
             // do not process - just debug query
             \TYPO3\CMS\Core\Utility\DebugUtility::debug($GLOBALS['TYPO3_DB']->UPDATEquery($table, $where, $fieldValues), 1);
         } else {
             // process storing of index record and return uid
             $this->updateRecordInIndex($fieldValues);
             return true;
         }
     } else {
         // insert new record
         if ($debugOnly) {
             // do not process - just debug query
             \TYPO3\CMS\Core\Utility\DebugUtility::debug($GLOBALS['TYPO3_DB']->INSERTquery($table, $fieldValues, false));
         } else {
             // process storing of index record and return uid
             $this->insertRecordIntoIndex($fieldValues);
             return $GLOBALS['TYPO3_DB']->sql_insert_id();
         }
     }
 }
Example #16
0
 /**
  * Template rendering for subdatas and principal datas
  *
  * @param array   $templateMarkers
  * @param string  $templateSection
  * @param boolean $debug
  * @return string HTML code
  */
 public function renderAllTemplate($templateMarkers, $templateSection, $debug = false)
 {
     // Check if the template is loaded
     if (!$this->templateContent) {
         return false;
     }
     // Check argument
     if (!is_array($templateMarkers)) {
         return false;
     }
     if ($debug === true) {
         \TYPO3\CMS\Core\Utility\DebugUtility::debug($templateMarkers, 'Markers for ' . $templateSection);
     }
     $content = '';
     if (is_array($templateMarkers[0])) {
         foreach ($templateMarkers as $markers) {
             $content .= $this->renderAllTemplate($markers, $templateSection, $debug);
         }
     } else {
         $content = $this->renderSingle($templateMarkers, $templateSection);
     }
     return $this->cleanTemplate($content);
 }
Example #17
0
 /**
  * Init Method for initialising the navigation.
  *
  * @param string $content Content passed to method
  * @param array $conf Typoscript Array
  *
  * @return array array for the menurendering of TYPO3
  */
 public function init($content, array $conf)
 {
     $this->mConf = $this->processConf($conf);
     if ($this->mConf['useRootlineInformationToUrl']) {
         $this->useRootlineInformationToUrl = $this->mConf['useRootlineInformationToUrl'];
     }
     $this->choosenCat = $this->mConf['category'];
     $this->nodeArrayAdditionalFields = GeneralUtility::trimExplode(',', $this->mConf['additionalFields'], 0);
     $this->pid = $this->mConf['overridePid'] ? $this->mConf['overridePid'] : $this->getFrontendController()->id;
     $this->gpVars = GeneralUtility::_GPmerged($this->prefixId);
     \CommerceTeam\Commerce\Utility\GeneralUtility::initializeFeUserBasket();
     $this->gpVars['basketHashValue'] = $this->getBasket()->getBasketHashValue();
     $this->pageRootline = $this->getFrontendController()->rootLine;
     $this->menuType = $this->mConf['1'];
     $this->entryLevel = (int) $this->mConf['entryLevel'];
     if ((int) $this->mConf['noAct'] > 0) {
         $this->noAct = true;
     }
     if ((int) $this->mConf['maxLevel'] > 0) {
         $this->maxLevel = (int) $this->mConf['maxLevel'];
     }
     /*
      * Detect if a user is logged in and if he or she has usergroups
      * as we have to take in accout, that different usergroups may have different
      * rights on the commerce tree, so consider this whe calculation the cache hash.
      */
     $usergroups = '';
     if (is_array($this->getFrontendUser()->user)) {
         $usergroups = $this->getFrontendUser()->user['usergroup'];
     }
     $this->cat = $this->getRootCategory();
     // Define a default
     $this->choosenCat = $this->mConf['category'];
     $this->showUid = $this->gpVars['showUid'] ? $this->gpVars['showUid'] : 0;
     $this->mDepth = $this->gpVars['mDepth'] ? $this->gpVars['mDepth'] : 0;
     $this->path = $this->gpVars['path'] ? $this->gpVars['path'] : 0;
     $this->expandAll = $this->mConf['expandAll'] ? $this->mConf['expandAll'] : 0;
     $menuErrorName = array();
     if (!($this->cat > 0)) {
         $menuErrorName[] = 'No category defined in TypoScript: lib.tx_commerce.navigation.special.category';
     }
     if (!($this->pid > 0)) {
         $menuErrorName[] = 'No OveridePID defined in TypoScript: lib.tx_commerce.navigation.special.overridePid';
     }
     if (!empty($menuErrorName)) {
         foreach ($menuErrorName as $oneError) {
             \TYPO3\CMS\Core\Utility\DebugUtility::debug($this->mConf, $oneError);
         }
         return $this->makeErrorMenu(5);
     }
     /*
      * Unique Hash for this usergroup and page to display the navigation
      */
     $hash = md5('tx_commerce_navigation:' . implode('-', $this->mConf) . ':' . $usergroups . ':' . $this->getFrontendController()->linkVars . ':' . GeneralUtility::getIndpEnv('HTTP_HOST'));
     /*
      * Render Menue Array and store in cache, if possible
      */
     if ($this->getFrontendController()->no_cache) {
         // Build directly and don't sore, if no_cache=1'
         $this->mTree = $this->makeArrayPostRender($this->pid, 'tx_commerce_categories', 'tx_commerce_categories_parent_category_mm', 'tx_commerce_products', 'tx_commerce_products_categories_mm', $this->cat, 1, 0, $this->maxLevel);
         /*
          * Sorting Options, there is only one type 'alphabetiDesc' :)
          * the others must to program
          *
          * @todo: implement sortType: alphabetiAsc, byUid, bySorting
          */
         if ($this->mConf['sortAllitems.']['type'] == 'alphabetiDesc') {
             $this->sortAllMenuArray($this->mTree, 'alphabetiDesc');
         }
     } else {
         $cachedMatrix = $this->getHash($hash);
         if (!empty($cachedMatrix)) {
             // User the cached version
             $this->mTree = $cachedMatrix;
         } else {
             // no cache present buld data and stor it in cache
             $this->mTree = $this->makeArrayPostRender($this->pid, 'tx_commerce_categories', 'tx_commerce_categories_parent_category_mm', 'tx_commerce_products', 'tx_commerce_products_categories_mm', $this->cat, 1, 0, $this->maxLevel);
             /*
              * Sorting Options, there is only one type 'alphabetiDesc' :)
              * the others must to program
              *
              * @todo: implement sortType: alphabetiAsc, byUid, bySorting
              */
             if ($this->mConf['sortAllitems.']['type'] == 'alphabetiDesc') {
                 $this->sortAllMenuArray($this->mTree, 'alphabetiDesc');
             }
             $this->storeHash($hash, $this->mTree);
         }
     }
     /*
      * Finish menue array rendering, now postprocessing
      * with current status of menue
      */
     $keys = array_keys($this->mTree);
     /*
      * Detect rootline, necessary
      */
     if ($this->noAct === true) {
         $this->pathParents = array();
         $this->mDepth = 0;
     } elseif ($this->gpVars['catUid']) {
         $this->choosenCat = $this->gpVars['catUid'];
     } elseif ($this->gpVars['showUid']) {
         /*
          * If a product is shown, we have to detect the parent category as well
          * even if wo haven't walked thrue the categories
          */
         /**
          * Product.
          *
          * @var \CommerceTeam\Commerce\Domain\Model\Product $product
          */
         $product = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Product', $this->gpVars['showUid']);
         $product->loadData();
         $this->choosenCat = $product->getMasterparentCategory();
     }
     if ($this->gpVars['path']) {
         $this->path = $this->gpVars['path'];
         $this->pathParents = explode(',', $this->path);
     } elseif (is_numeric($this->choosenCat) && $this->choosenCat > 0) {
         /**
          * Build the path by or own.
          *
          * @var \CommerceTeam\Commerce\Domain\Model\Category $category
          */
         $category = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Category', $this->choosenCat);
         $category->loadData();
         // Get the right path with custom method
         $aPath = $this->getRootLine($this->mTree, $this->choosenCat, $this->expandAll);
         if (!$aPath) {
             /*
              * If the methode getRootLine fail, we take the path direct from the DB.
              */
             $tmpArray = $category->getParentCategoriesUidlist();
             $this->fixPathParents($tmpArray, $this->cat);
         } else {
             $tmpArray = $aPath;
         }
         /*
          * Strip the Staring point and the value 0
          */
         if (!is_array($tmpArray)) {
             $tmpArray = array();
         }
         foreach ((array) $tmpArray as $value) {
             if ($value != $this->cat && $value > 0) {
                 $this->pathParents[] = $value;
             }
         }
         if ($this->mConf['groupOptions.']['onOptions'] == 1 && $this->getFrontendUser()->user['usergroup'] != '') {
             $this->fixPathParents($this->pathParents, $keys[0]);
         }
         $this->pathParents = array_reverse($this->pathParents);
         if (!$this->gpVars['mDepth']) {
             $this->mDepth = count($this->pathParents);
             if ($this->gpVars['manufacturer']) {
                 ++$this->mDepth;
             }
         }
     } else {
         /*
          * If no Category is choosen by the user, so you just render the default menue
          * no rootline for the categories is needed and the depth is 0
          */
         $this->pathParents = array();
         $this->mDepth = 0;
     }
     /*
      * If we do have an entry level,
      * we strip away the number of array levels of the entry level value
      */
     if ($this->entryLevel > 0) {
         $newParentes = array_reverse($this->pathParents);
         /**
          * Foreach entry level detect the array for this level and remove
          * it from $this->mTree.
          */
         for ($i = 0; $i < $this->entryLevel; ++$i) {
             $this->mTree = $this->mTree[$newParentes[$i]]['--subLevel--'];
             /*
              * Reduce elementes in pathParents and decrese menue depth
              */
             array_pop($this->pathParents);
             --$this->mDepth;
         }
     }
     if ($this->pathParents) {
         $this->processArrayPostRender($this->mTree, $this->pathParents, $this->mDepth);
     }
     // never ever tough this piece of crap its needed to return an array
     return $this->mTree;
 }
Example #18
0
    /**
     * 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;
    }
Example #19
0
 function hasPeriodChanged($old, $new, $reverse = false, $debug = false)
 {
     if ($debug) {
         \TYPO3\CMS\Core\Utility\DebugUtility::debug(array($old, $new, $reverse));
     }
     if ($reverse) {
         return intval($new) < intval($old);
     } else {
         return intval($new) > intval($old);
     }
 }
Example #20
0
 /**
  * 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();
 }
Example #21
0
 /**
  * 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) : '';
 }
    /**
     * 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;
    }
Example #23
0
 /**
  * Logs a call to a deprecated function.
  * The log message will be taken from the annotation.
  *
  * @return void
  */
 public static function logDeprecatedFunction()
 {
     if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
         return;
     }
     $trail = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
     if ($trail[1]['type']) {
         $function = new \ReflectionMethod($trail[1]['class'], $trail[1]['function']);
     } else {
         $function = new \ReflectionFunction($trail[1]['function']);
     }
     $msg = '';
     if (preg_match('/@deprecated\\s+(.*)/', $function->getDocComment(), $match)) {
         $msg = $match[1];
     }
     // Write a longer message to the deprecation log: <function> <annotion> - <trace> (<source>)
     $logMsg = $trail[1]['class'] . $trail[1]['type'] . $trail[1]['function'];
     $logMsg .= '() - ' . $msg . ' - ' . DebugUtility::debugTrail();
     $logMsg .= ' (' . PathUtility::stripPathSitePrefix($function->getFileName()) . '#' . $function->getStartLine() . ')';
     self::deprecationLog($logMsg);
 }
 /**
  * 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;
 }
Example #25
0
    /**
     * 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;
    }
Example #26
0
 /**
  * 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;
 }
 /**
  * Logs a call to a deprecated function.
  * The log message will be taken from the annotation.
  *
  * @return void
  */
 public static function logDeprecatedFunction()
 {
     if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
         return;
     }
     // This require_once is needed for deprecation calls
     // thrown early during bootstrap, if the autoloader is
     // not instantiated yet. This can happen for example if
     // ext_localconf triggers a deprecation.
     require_once 'DebugUtility.php';
     $trail = debug_backtrace();
     if ($trail[1]['type']) {
         $function = new \ReflectionMethod($trail[1]['class'], $trail[1]['function']);
     } else {
         $function = new \ReflectionFunction($trail[1]['function']);
     }
     $msg = '';
     if (preg_match('/@deprecated\\s+(.*)/', $function->getDocComment(), $match)) {
         $msg = $match[1];
     }
     // Write a longer message to the deprecation log: <function> <annotion> - <trace> (<source>)
     $logMsg = $trail[1]['class'] . $trail[1]['type'] . $trail[1]['function'];
     $logMsg .= '() - ' . $msg . ' - ' . \TYPO3\CMS\Core\Utility\DebugUtility::debugTrail();
     $logMsg .= ' (' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($function->getFileName()) . '#' . $function->getStartLine() . ')';
     self::deprecationLog($logMsg);
 }
Example #28
0
 /**
  * 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;
 }
Example #29
0
    /**
     * Calling function that checks system, IM, GD, dirs, database
     * and lets you alter localconf.php
     *
     * This method is called from init.php to start the Install Tool.
     *
     * @return void
     * @todo Define visibility
     */
    public function init()
    {
        // Must be called after inclusion of init.php (or from init.php)
        if (!defined('PATH_typo3')) {
            die;
        }
        if (!$this->passwordOK) {
            die;
        }
        // Setting stuff...
        $this->check_mail();
        $this->setupGeneral();
        $this->generateConfigForm();
        if (count($this->messages)) {
            \TYPO3\CMS\Core\Utility\DebugUtility::debug($this->messages);
        }
        if ($this->step) {
            $this->output($this->outputWrapper($this->stepOutput()));
        } else {
            // Menu...
            switch ($this->INSTALL['type']) {
                case 'images':
                    $this->checkIM = 1;
                    $this->checkTheConfig();
                    $this->silent = 0;
                    $this->checkTheImageProcessing();
                    break;
                case 'database':
                    $this->checkTheConfig();
                    $this->silent = 0;
                    $this->checkTheDatabase();
                    break;
                case 'update':
                    $this->checkDatabase();
                    $this->silent = 0;
                    $this->updateWizard();
                    break;
                case 'config':
                    $this->silent = 0;
                    $this->checkIM = 1;
                    $this->message('About configuration', 'How to configure TYPO3', $this->generallyAboutConfiguration());
                    $isPhpCgi = PHP_SAPI == 'fpm-fcgi' || PHP_SAPI == 'cgi' || PHP_SAPI == 'isapi' || PHP_SAPI == 'cgi-fcgi';
                    $this->message('System Information', 'Your system has the following configuration', '
							<dl id="systemInformation">
								<dt>OS detected:</dt>
								<dd>' . (TYPO3_OS == 'WIN' ? 'WIN' : 'UNIX') . '</dd>
								<dt>CGI detected:</dt>
								<dd>' . ($isPhpCgi ? 'YES' : 'NO') . '</dd>
								<dt>PATH_thisScript:</dt>
								<dd>' . PATH_thisScript . '</dd>
							</dl>
						');
                    $this->checkTheConfig();
                    $ext = 'Write configuration';
                    if ($this->fatalError) {
                        if ($this->config_array['no_database'] || !$this->config_array['mysqlConnect']) {
                            $this->message($ext, 'Database not configured yet!', '
								<p>
									You need to specify database username,
									password and host as one of the first things.
									<br />
									Next you\'ll have to select a database to
									use with TYPO3.
								</p>
								<p>
									Use the form below.
								</p>
							', 2);
                        } else {
                            $this->message($ext, 'Fatal error encountered!', '
								<p>
									Somewhere above a fatal configuration
									problem is encountered.
									Please make sure that you\'ve fixed this
									error before you submit the configuration.
									TYPO3 will not run if this problem is not
									fixed!
									<br />
									You should also check all warnings that may
									appear.
								</p>
							', 2);
                        }
                    } elseif ($this->mode == '123') {
                        if (!$this->fatalError) {
                            $this->message($ext, 'Basic configuration completed', '
								<p>
									You have no fatal errors in your basic
									configuration.
									You may have warnings though. Please pay
									attention to them!
									However you may continue and install the
									database.
								</p>
								<p>
									<strong>
										<span style="color:#f00;">Step 2: </span>
									</strong>
									<a href="' . $this->scriptSelf . '?TYPO3_INSTALL[type]=database' . ($this->mode ? '&mode=' . rawurlencode($this->mode) : '') . '">Click here to install the database.</a>
								</p>
							', -1, 1);
                        }
                    }
                    $this->message($ext, 'Very Important: Changing Image Processing settings', '
						<p>
							When you change the settings for Image Processing
							you <em>must</em> take into account
							that <em>old images</em> may still be in typo3temp/
							folder and prevent new files from being generated!
							<br />
							This is especially important to know, if you\'re
							trying to set up image processing for the very first
							time.
							<br />
							The problem is solved by <a href="' . htmlspecialchars($this->setScriptName('cleanup')) . '">clearing the typo3temp/ folder</a>.
							Also make sure to clear the cache_pages table.
						</p>
					', 1, 1);
                    $this->message($ext, 'Very Important: Changing Encryption Key setting', '
						<p>
							When you change the setting for the Encryption Key
							you <em>must</em> take into account that a change to
							this value might invalidate temporary information,
							URLs etc.
							<br />
							The problem is solved by <a href="' . htmlspecialchars($this->setScriptName('cleanup')) . '">clearing the typo3temp/ folder</a>.
							Also make sure to clear the cache_pages table.
						</p>
					', 1, 1);
                    $this->message($ext, 'Update configuration', '
						<p>
							This form updates the configuration with the
							suggested values you see below. The values are based
							on the analysis above.
							<br />
							You can change the values in case you have
							alternatives to the suggested defaults.
							<br />
							By this final step you will configure TYPO3 for
							immediate use provided that you have no fatal errors
							left above.
						</p>' . $this->setupGeneral('get_form') . '
					', 0, 1);
                    $this->output($this->outputWrapper($this->printAll()));
                    break;
                case 'extConfig':
                    $this->silent = 0;
                    $this->generateConfigForm('get_form');
                    // Get the template file
                    $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'InitExtConfig.html');
                    // Get the template part from the file
                    $template = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($templateFile, '###TEMPLATE###');
                    // Define the markers content
                    $markers = array('action' => $this->action, 'content' => $this->printAll(), 'write' => 'Write configuration', 'notice' => 'NOTICE:', 'explanation' => '
							By clicking this button, the configuration is updated
							with new values for the parameters listed above!
						');
                    // Fill the markers in the template
                    $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($template, $markers, '###|###', TRUE, FALSE);
                    // Send content to the page wrapper function
                    $this->output($this->outputWrapper($content));
                    break;
                case 'cleanup':
                    $this->checkTheConfig();
                    $this->silent = 0;
                    $this->cleanupManager();
                    break;
                case 'phpinfo':
                    $this->silent = 0;
                    $this->phpinformation();
                    break;
                case 'typo3conf_edit':
                    $this->silent = 0;
                    $this->typo3conf_edit();
                    break;
                case 'logout':
                    $enableInstallToolFile = PATH_site . 'typo3conf/ENABLE_INSTALL_TOOL';
                    if (is_file($enableInstallToolFile) && trim(file_get_contents($enableInstallToolFile)) !== 'KEEP_FILE') {
                        unlink(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
                    }
                    $this->formProtection->clean();
                    $this->session->destroySession();
                    \TYPO3\CMS\Core\Utility\HttpUtility::redirect($this->scriptSelf);
                    break;
                case 'about':
                default:
                    $this->silent = 0;
                    $this->message('About', 'Warning - very important!', $this->securityRisk() . $this->alterPasswordForm(), 2);
                    $this->message('About', 'Using this script', '
						<p>
							Installing TYPO3 has always been a hot topic on the
							mailing list and forums. Therefore we\'ve developed
							this tool which will help you through configuration
							and testing.
							<br />
							There are three primary steps for you to take:
						</p>
						<p>
							<strong>1: Basic Configuration</strong>
							<br />
							In this step your PHP-configuration is checked. If
							there are any settings that will prevent TYPO3 from
							running correctly you\'ll get warnings and errors
							with a description of the problem.
							<br />
							You\'ll have to enter a database username, password
							and hostname. Then you can choose to create a new
							database or select an existing one.
							<br />
							Finally the image processing settings are entered
							and verified and you can choose to let the script
							update the configuration with the suggested settings.
						</p>
						<p>
							<strong>2: Database Analyser</strong>
							<br />
							In this step you can either install a new database
							or update the database from any previous TYPO3
							version.
							<br />
							You can also get an overview of extra/missing
							fields/tables in the database compared to a raw
							sql-file.
							<br />
							The database is also verified against your
							\'tables.php\' configuration ($TCA) and you can
							even see suggestions to entries in $TCA or new
							fields in the database.
						</p>
						<p>
							<strong>3: Upgrade Wizard</strong>
							<br />
							Here you will find update methods taking care of
							changes to the TYPO3 core which are not backwards
							compatible.
							<br />
							It is recommended to run this wizard after every
							update to make sure everything will still work
							flawlessly.
						</p>
						<p>
							<strong>4: Image Processing</strong>
							<br />
							This step is a visual guide to verify your
							configuration of the image processing software.
							<br />
							You\'ll be presented to a list of images that should
							all match in pairs. If some irregularity appears,
							you\'ll get a warning. Thus you\'re able to track an
							error before you\'ll discover it on your website.
						</p>
						<p>
							<strong>5: All Configuration</strong>
							<br />
							This gives you access to any of the configuration
							options in the TYPO3_CONF_VARS array. Every option
							is also presented with a comment explaining what it
							does.
						</p>
						<p>
							<strong>6: Cleanup</strong>
							<br />
							Here you can clean up the temporary files in typo3temp/
							folder and the tables used for caching of data in
							your database.
						</p>
					');
                    $this->message('About', 'Why is this script stand-alone?', '
						<p>
							You would think that this script should rather be a
							module in the backend and access-controlled to only
							admin-users from the database. But that\'s not how
							it works.
							<br />
							The reason is, that this script must not be
							depending on the success of the configuration of
							TYPO3 and whether or not there is a working database
							behind. Therefore the script is invoked from the
							backend init.php file, which allows access if the
							constant \'TYPO3_enterInstallScript\' has been
							defined and is not FALSE. That is and should be the
							case <em>only</em> when calling the script
							\'typo3/install/index.php\' - this script!
						</p>
					');
                    $headCode = 'Header legend';
                    $this->message($headCode, 'Notice!', '
						<p>
							Indicates that something is important to be aware
							of.
							<br />
							This does <em>not</em> indicate an error.
						</p>
					', 1);
                    $this->message($headCode, 'Just information', '
						<p>
							This is a simple message with some information about
							something.
						</p>
					');
                    $this->message($headCode, 'Check was successful', '
						<p>
							Indicates that something was checked and returned an
							expected result.
						</p>
					', -1);
                    $this->message($headCode, 'Warning!', '
						<p>
							Indicates that something may very well cause trouble
							and you should definitely look into it before
							proceeding.
							<br />
							This indicates a <em>potential</em> error.
						</p>
					', 2);
                    $this->message($headCode, 'Error!', '
						<p>
							Indicates that something is definitely wrong and
							that TYPO3 will most likely not perform as expected
							if this problem is not solved.
							<br />
							This indicates an actual error.
						</p>
					', 3);
                    $this->output($this->outputWrapper($this->printAll()));
                    break;
            }
        }
    }
    /**
     * 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;
    }