Пример #1
0
 /**
  * Checks peak memory usage and stores data in cache for use in the report module
  *
  * @return void
  */
 public static function peakMemoryUsage()
 {
     $peakUsage = memory_get_peak_usage(true);
     $memoryLimit = GeneralUtility::getBytesFromSizeMeasurement(ini_get('memory_limit'));
     if (is_double($memoryLimit) && $memoryLimit != 0) {
         if ($peakUsage / $memoryLimit >= 0.9) {
             /** @var $registry \TYPO3\CMS\Core\Registry */
             $registry = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Registry::class);
             $data = array('used' => $peakUsage, 'tstamp' => $GLOBALS['EXEC_TIME'], 'url' => GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
             $registry->set('core', 'reports-peakMemoryUsage', $data);
         }
     }
 }
Пример #2
0
 /**
  * Creates an absolute URL out of really any input path, removes '../' parts for the targetPath
  *
  * @param string $targetPath can be "../../typo3/contrib/myfile.js" or "/myfile.js"
  * @return string something like "/mysite/typo3/sysext/backend.js"
  */
 public static function getAbsoluteWebPath($targetPath)
 {
     if (self::isAbsolutePath($targetPath)) {
         if (StringUtility::beginsWith($targetPath, PATH_site)) {
             $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . self::stripPathSitePrefix($targetPath);
         }
     } elseif (strpos($targetPath, '://') !== FALSE) {
         return $targetPath;
     } else {
         // Make an absolute path out of it
         $targetPath = GeneralUtility::resolveBackPath(dirname(PATH_thisScript) . '/' . $targetPath);
         $targetPath = self::stripPathSitePrefix($targetPath);
         $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . $targetPath;
     }
     return $targetPath;
 }
Пример #3
0
 /**
  * Creates an absolute URL out of really any input path, removes '../' parts for the targetPath
  *
  * @param string $targetPath can be "../typo3conf/ext/myext/myfile.js" or "/myfile.js"
  * @return string something like "/mysite/typo3conf/ext/myext/myfile.js"
  */
 public static function getAbsoluteWebPath($targetPath)
 {
     if (self::isAbsolutePath($targetPath)) {
         if (strpos($targetPath, PATH_site) === 0) {
             $targetPath = self::stripPathSitePrefix($targetPath);
             if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI)) {
                 $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . $targetPath;
             }
         }
     } elseif (strpos($targetPath, '://') !== false) {
         return $targetPath;
     } else {
         // Make an absolute path out of it
         $targetPath = GeneralUtility::resolveBackPath(dirname(PATH_thisScript) . '/' . $targetPath);
         $targetPath = self::stripPathSitePrefix($targetPath);
         if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI)) {
             $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . $targetPath;
         }
     }
     return $targetPath;
 }