/**
  * Rendering the "clickenlarge" custom attribute, called from TypoScript
  *
  * @param	string		Content input. Not used, ignore.
  * @param	array		TypoScript configuration
  * @return	string		HTML output.
  * @access private
  */
 function render_clickenlarge($content, $conf)
 {
     $clickenlarge = isset($this->cObj->parameters['clickenlarge']) ? $this->cObj->parameters['clickenlarge'] : 0;
     $path = $this->cObj->parameters['src'];
     $pathPre = $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'] . 'RTEmagicC_';
     if (t3lib_div::isFirstPartOfStr($path, $pathPre)) {
         // Find original file:
         $pI = pathinfo(substr($path, strlen($pathPre)));
         $filename = substr($pI['basename'], 0, -strlen('.' . $pI['extension']));
         $file = $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'] . 'RTEmagicP_' . $filename;
     } else {
         $file = $this->cObj->parameters['src'];
     }
     unset($this->cObj->parameters['clickenlarge']);
     unset($this->cObj->parameters['allParams']);
     $content = '<img ' . t3lib_div::implodeAttributes($this->cObj->parameters, TRUE, TRUE) . ' />';
     if ($clickenlarge && is_array($conf['imageLinkWrap.'])) {
         $theImage = $file ? $GLOBALS['TSFE']->tmpl->getFileName($file) : '';
         if ($theImage) {
             $this->cObj->parameters['origFile'] = $theImage;
             if ($this->cObj->parameters['title']) {
                 $conf['imageLinkWrap.']['title'] = $this->cObj->parameters['title'];
             }
             if ($this->cObj->parameters['alt']) {
                 $conf['imageLinkWrap.']['alt'] = $this->cObj->parameters['alt'];
             }
             $content = $this->cObj->imageLinkWrap($content, $theImage, $conf['imageLinkWrap.']);
             $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
         }
     }
     return $content;
 }
예제 #2
0
 /**
  * Prepend current url if url is relative
  *
  * @param string $url given url
  * @return string
  */
 public static function prependDomain($url)
 {
     if (!t3lib_div::isFirstPartOfStr($url, t3lib_div::getIndpEnv('TYPO3_SITE_URL'))) {
         $url = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $url;
     }
     return $url;
 }
예제 #3
0
 function validate(&$oRdt)
 {
     $sAbsName = $oRdt->getAbsName();
     $sValue = $oRdt->getValue();
     if ($sValue === "") {
         // never evaluate if value is empty
         // as this is left to STANDARD:required
         return;
     }
     $aKeys = array_keys($this->_navConf("/"));
     reset($aKeys);
     while (!$oRdt->hasError() && (list(, $sKey) = each($aKeys))) {
         /***********************************************************************
          *
          *	/pattern
          *
          ***********************************************************************/
         if ($sKey[0] === "p" && t3lib_div::isFirstPartOfStr($sKey, "pattern")) {
             $sPattern = $this->_navConf("/" . $sKey . "/value");
             if (!$this->_isValid($sPattern)) {
                 $this->oForm->mayday("<b>validator:PREG</b> on renderlet " . $sAbsName . ": the given regular expression pattern seems to be not valid");
             }
             if (!$this->_isMatch($sPattern, $sValue)) {
                 $this->oForm->_declareValidationError($sAbsName, "PREG:pattern", $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message")), $sValue);
                 break;
             }
         }
     }
 }
예제 #4
0
 /**
  * Returns the localized label of the LOCAL_LANG key, $key.
  *
  * @param string $key The key from the LOCAL_LANG array for which to return the value.
  * @param string $extensionName The name of the extension
  * @param array $arguments the arguments of the extension, being passed over to vsprintf
  * @return string The value from LOCAL_LANG or NULL if no translation was found.
  * @author Christopher Hlubek <*****@*****.**>
  * @author Bastian Waidelich <*****@*****.**>
  * @author Sebastian Kurfuerst <*****@*****.**>
  * @api
  * @todo: If vsprintf gets a malformed string, it returns FALSE! Should we throw an exception there?
  */
 public static function translate($key, $extensionName, $arguments = NULL)
 {
     if (t3lib_div::isFirstPartOfStr($key, 'LLL:')) {
         $value = self::translateFileReference($key);
     } else {
         self::initializeLocalization($extensionName);
         // The "from" charset of csConv() is only set for strings from TypoScript via _LOCAL_LANG
         if (isset(self::$LOCAL_LANG[$extensionName][self::$languageKey][$key])) {
             $value = self::$LOCAL_LANG[$extensionName][self::$languageKey][$key];
             if (isset(self::$LOCAL_LANG_charset[$extensionName][self::$languageKey][$key])) {
                 $value = self::convertCharset($value, self::$LOCAL_LANG_charset[$extensionName][self::$languageKey][$key]);
             }
         } elseif (self::$alternativeLanguageKey !== '' && isset(self::$LOCAL_LANG[$extensionName][self::$alternativeLanguageKey][$key])) {
             $value = self::$LOCAL_LANG[$extensionName][self::$alternativeLanguageKey][$key];
             if (isset(self::$LOCAL_LANG_charset[$extensionName][self::$alternativeLanguageKey][$key])) {
                 $value = self::convertCharset($value, self::$LOCAL_LANG_charset[$extensionName][self::$alternativeLanguageKey][$key]);
             }
         } elseif (isset(self::$LOCAL_LANG[$extensionName]['default'][$key])) {
             $value = self::$LOCAL_LANG[$extensionName]['default'][$key];
             // No charset conversion because default is english and thereby ASCII
         }
     }
     if (is_array($arguments)) {
         return vsprintf($value, $arguments);
     } else {
         return $value;
     }
 }
 function loadAggregates()
 {
     reset($this->aElement);
     while (list($sElementName, ) = each($this->aElement)) {
         if ($sElementName[0] === "a" && t3lib_div::isFirstPartOfStr($sElementName, "aggregate")) {
             if (($sClassFile = $this->_navConf("/" . $sElementName . "/classfile")) === FALSE) {
                 $this->oForm->mayday("datasource:CONTENTREPOSITORY[name='" . $this->getName() . "'] You have to provide <b>/aggregate/classFile</b>.");
             } else {
                 $sClassFile = $this->oForm->toServerPath($sClassFile);
                 if (!file_exists($sClassFile)) {
                     $this->oForm->mayday("datasource:CONTENTREPOSITORY[name='" . $this->getName() . "'] The given <b>/aggregate/classFile</b> given (" . $sClassFile . ") does not exist.");
                 }
                 if (!is_readable($sClassFile)) {
                     $this->oForm->mayday("datasource:CONTENTREPOSITORY[name='" . $this->getName() . "'] The given <b>/aggregate/classFile</b> given (" . $sClassFile . ") exists, but is not readable.");
                 }
                 require_once $sClassFile;
             }
             if (($sClassName = $this->_navConf("/" . $sElementName . "/classname")) === FALSE) {
                 $this->oForm->mayday("datasource:CONTENTREPOSITORY[name='" . $this->getName() . "'] You have to provide <b>/aggregate/className</b>.");
             } else {
                 if (!class_exists($sClassName)) {
                     $this->oForm->mayday("datasource:CONTENTREPOSITORY[name='" . $this->getName() . "'] The given <b>/aggregate/className</b> (" . $sClassName . ") does not exist.");
                 }
             }
         }
     }
 }
예제 #6
0
 /**
  * @return string
  */
 public function render()
 {
     $url = t3lib_div::getIndpEnv('TYPO3_REQUEST_URL');
     if (!t3lib_div::isFirstPartOfStr($url, t3lib_div::getIndpEnv('TYPO3_SITE_URL'))) {
         $url = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $url;
     }
     return $url;
 }
 /**
  * returns a label for the given key
  *
  * @param array $arguments
  * @return	string
  */
 public function execute(array $arguments = array())
 {
     $label = '';
     if (t3lib_div::isFirstPartOfStr($arguments[0], 'EXT')) {
         // a full path reference...
         $label = $this->resolveFullPathLabel($arguments[0]);
     } else {
         $label = $this->getLabel($this->languageFile, $arguments[0]);
     }
     return $label;
 }
예제 #8
0
 function _getPathReload()
 {
     if (($sPath = $this->_navConf("/reloadpic/")) !== FALSE) {
         if (tx_ameosformidable::isRunneable($sPath)) {
             $sPath = $this->callRunneable($sPath);
         }
         if (t3lib_div::isFirstPartOfStr($sPath, "EXT:")) {
             $sPath = t3lib_div::getIndpEnv("TYPO3_SITE_URL") . str_replace(t3lib_div::getIndpEnv("TYPO3_DOCUMENT_ROOT"), "", t3lib_div::getFileAbsFileName($sPath));
         }
     }
     return $sPath;
 }
 public function handleError($params, tslib_fe $pObj)
 {
     if (isset($params['pageAccessFailureReasons']['fe_group']) && !isset($params['pageAccessFailureReasons']['hidden']) && current($params['pageAccessFailureReasons']['fe_group']) !== 0) {
         // make sure realurl does't issue this 401
         $code = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ajaxlogin']['unauthorized_handling'];
         $header = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ajaxlogin']['unauthorized_handling_statheader'];
         if (t3lib_div::isFirstPartOfStr($code, 'REDIRECT:')) {
             $appendQueryString = 'redirect_url=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'));
             if (strpos($code, '?') === false) {
                 $code .= '?' . $appendQueryString;
             } else {
                 $code .= '&' . $appendQueryString;
             }
         }
     } else {
         $code = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ajaxlogin']['pageNotFound_handling'];
         $header = $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling_statheader'];
     }
     $pObj->pageErrorHandler($code, $header, $params['reasonText']);
 }
 /**
  * Recursively builds a sub menu structure for the current menu.
  *
  * @param array $facetOptions Array of facet options
  * @param string $menuName Name of the top level menu to build the sub menu structure for
  * @param integer $level The sub level depth
  * @return array Returns an array sub menu structure if a sub menu exists, an empty array otherwise
  */
 protected function getSubMenu(array $facetOptions, $menuName, $level)
 {
     $menu = array();
     $subMenuEntryPrefix = $level . '-' . $menuName;
     foreach ($facetOptions as $facetOptionKey => $facetOption) {
         // find the sub menu items for the current menu
         if (t3lib_div::isFirstPartOfStr($facetOptionKey, $subMenuEntryPrefix)) {
             $currentMenu = array('title' => $this->getFacetOptionLabel($facetOptionKey, $facetOption['numberOfResults']), 'facetKey' => Tx_Solr_Facet_HierarchicalFacetRenderer::getLastPathSegmentFromHierarchicalFacetOption($facetOptionKey), 'numberOfResults' => $facetOption['numberOfResults'], '_OVERRIDE_HREF' => $facetOption['url'], 'ITEM_STATE' => $facetOption['selected'] ? 'ACT' : 'NO');
             $lastPathSegment = Tx_Solr_Facet_HierarchicalFacetRenderer::getLastPathSegmentFromHierarchicalFacetOption($facetOptionKey);
             // move one level down (recursion)
             $subMenu = $this->getSubMenu($facetOptions, $menuName . '/' . $lastPathSegment, $level + 1);
             if (!empty($subMenu)) {
                 $currentMenu['_SUB_MENU'] = $subMenu;
             }
             $menu[] = $currentMenu;
         }
     }
     // return one level up
     return $menu;
 }
 /**
  * This method executes the requested commands and applies the changes to
  * the template.
  *
  * TODO This method should be located somewhere in a base view
  */
 protected function render($actionResult)
 {
     $commandList = $this->getCommandList();
     $commandResolver = $this->getCommandResolver();
     foreach ($commandList as $commandName) {
         $command = $commandResolver->getCommand($commandName, $this);
         $commandVariables = $command->execute();
         $subpartTemplate = clone $this->template;
         $subpartTemplate->setWorkingTemplateContent($this->template->getSubpart('solr_search_' . $commandName));
         if (!is_null($commandVariables)) {
             foreach ($commandVariables as $variableName => $commandVariable) {
                 if (t3lib_div::isFirstPartOfStr($variableName, 'loop_')) {
                     $dividerPosition = strpos($variableName, '|');
                     $loopName = substr($variableName, 5, $dividerPosition - 5);
                     $loopedMarkerName = substr($variableName, $dividerPosition + 1);
                     $subpartTemplate->addLoop($loopName, $loopedMarkerName, $commandVariable);
                 } else {
                     if (t3lib_div::isFirstPartOfStr($variableName, 'subpart_')) {
                         $subpartName = substr($variableName, 8);
                         $subpartTemplate->addSubpart($subpartName, $commandVariable);
                     } else {
                         $subpartTemplate->addVariable($commandName, $commandVariables);
                     }
                 }
             }
             $this->template->addSubpart('solr_search_' . $commandName, $subpartTemplate->render());
         }
         unset($subpartTemplate);
     }
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr'][$this->getPluginKey()]['renderTemplate'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr'][$this->getPluginKey()]['renderTemplate'] as $classReference) {
             $templateModifier =& t3lib_div::getUserObj($classReference);
             if ($templateModifier instanceof tx_solr_TemplateModifier) {
                 $templateModifier->modifyTemplate($this->template);
             } else {
                 // TODO throw exceptions
             }
         }
     }
     return $this->template->render(tx_solr_Template::CLEAN_TEMPLATE_YES);
 }
 /**
  * Renders a meta tag
  *
  * @param boolean $useCurrentDomain If set, current domain is used
  * @param boolean $forceAbsoluteUrl If set, absolute url is forced
  * @param boolean $useNameAttribute If set, the meta tag is built by using the attribute name="" instead of property
  * @return void
  */
 public function render($useCurrentDomain = FALSE, $forceAbsoluteUrl = FALSE, $useNameAttribute = FALSE)
 {
     // set current domain
     if ($useCurrentDomain) {
         $this->tag->addAttribute('content', t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'));
     }
     // prepend current domain
     if ($forceAbsoluteUrl) {
         $path = $this->arguments['content'];
         if (!t3lib_div::isFirstPartOfStr($path, t3lib_div::getIndpEnv('TYPO3_SITE_URL'))) {
             $this->tag->addAttribute('content', t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $this->arguments['content']);
         }
     }
     if ($useCurrentDomain || isset($this->arguments['content']) && !empty($this->arguments['content'])) {
         if ($useNameAttribute && $this->arguments['property'] !== '') {
             $attributesContent = $this->arguments['property'];
             $this->tag->removeAttribute('property');
             $this->tag->addAttribute('name', $attributesContent);
         }
         $GLOBALS['TSFE']->getPageRenderer()->addMetaTag($this->tag->render());
     }
 }
예제 #13
0
 function validate(&$oRdt)
 {
     $sAbsName = $oRdt->getAbsName();
     $mValue = $oRdt->getValue();
     $aKeys = array_keys($this->_navConf("/"));
     reset($aKeys);
     while (!$oRdt->hasError() && (list(, $sKey) = each($aKeys))) {
         /***********************************************************************
          *
          *	/unique
          *
          ***********************************************************************/
         if ($sKey[0] === "u" && t3lib_div::isFirstPartOfStr($sKey, "unique")) {
             // field value has to be unique in the database
             // checking this
             if (!$this->_isUnique($oRdt, $mValue)) {
                 $this->oForm->_declareValidationError($sAbsName, "DB:unique", $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message/")), $mValue);
                 break;
             }
         }
     }
 }
 /**
  * Create a tag
  *
  * @param array $params
  * @param TYPO3AJAX $ajaxObj
  * @return void
  * @throws Exception
  */
 public function createTag(array $params, TYPO3AJAX $ajaxObj)
 {
     $request = t3lib_div::_POST();
     try {
         // Check if a tag is submitted
         if (!isset($request['item']) || empty($request['item'])) {
             throw new Exception('error_no-tag');
         }
         $newsUid = $request['newsid'];
         if ((int) $newsUid === 0 && (strlen($newsUid) == 16 && !t3lib_div::isFirstPartOfStr($newsUid, 'NEW'))) {
             throw new Exception('error_no-newsid');
         }
         // Get tag uid
         $newTagId = $this->getTagUid($request);
         $ajaxObj->setContentFormat('javascript');
         $ajaxObj->setContent('');
         $response = array($newTagId, $request['item'], self::TAG, self::NEWS, 'tags', 'data[tx_news_domain_model_news][' . $newsUid . '][tags]', $newsUid);
         $ajaxObj->setJavascriptCallbackWrap(implode('-', $response));
     } catch (Exception $e) {
         $errorMsg = $GLOBALS['LANG']->sL(self::LLPATH . $e->getMessage());
         $ajaxObj->setError($errorMsg);
     }
 }
예제 #15
0
 function _doTheMagic($aRendered, $sForm)
 {
     $sUrl = "";
     if ($this->oForm->oDataHandler->_allIsValid()) {
         if (($mPage = $this->_navConf("/pageid")) !== FALSE) {
             if (tx_ameosformidable::isRunneable($mPage)) {
                 $mPage = $this->callRunneable($mPage);
             }
             $sUrl = $this->oForm->cObj->typolink_URL(array("parameter" => $mPage));
             if (!t3lib_div::isFirstPartOfStr($sUrl, "http://") && trim($GLOBALS["TSFE"]->baseUrl) !== "") {
                 $sUrl = $this->oForm->_removeEndingSlash($GLOBALS["TSFE"]->baseUrl) . "/" . $sUrl;
             }
         } else {
             $sUrl = $this->_navConf("/url");
             if (tx_ameosformidable::isRunneable($sUrl)) {
                 $sUrl = $this->callRunneable($sUrl);
             }
         }
         if (is_string($sUrl) && trim($sUrl) !== "") {
             header("Location: " . $sUrl);
             exit;
         }
     }
 }
예제 #16
0
 /**
  * Determines wether the URL is relative to the
  * current TYPO3 installation.
  *
  * @param string $url URL which needs to be checked
  * @return boolean Whether the URL is considered to be relative
  */
 protected function isRelativeUrl($url)
 {
     $parsedUrl = @parse_url($url);
     if ($parsedUrl !== FALSE && !isset($parsedUrl['scheme']) && !isset($parsedUrl['host'])) {
         // If the relative URL starts with a slash, we need to check if it's within the current site path
         return !t3lib_div::isFirstPartOfStr($parsedUrl['path'], '/') || t3lib_div::isFirstPartOfStr($parsedUrl['path'], t3lib_div::getIndpEnv('TYPO3_SITE_PATH'));
     }
     return FALSE;
 }
 /**
  * Returns the reference to a 'resource' in TypoScript.
  * This could be from the filesystem if '/' is found in the value $fileFromSetup, else from the resource-list
  *
  * @param	string		TypoScript "resource" data type value.
  * @return	string		Resulting filename, if any.
  */
 function getFileName($fileFromSetup)
 {
     $file = trim($fileFromSetup);
     if (!$file) {
         return;
     } elseif (strstr($file, '../')) {
         if ($this->tt_track) {
             $GLOBALS['TT']->setTSlogMessage('File path "' . $file . '" contained illegal string "../"!', 3);
         }
         return;
     }
     // cache
     $hash = md5($file);
     if (isset($this->fileCache[$hash])) {
         return $this->fileCache[$hash];
     }
     if (!strcmp(substr($file, 0, 4), 'EXT:')) {
         $newFile = '';
         list($extKey, $script) = explode('/', substr($file, 4), 2);
         if ($extKey && t3lib_extMgm::isLoaded($extKey)) {
             $extPath = t3lib_extMgm::extPath($extKey);
             $newFile = substr($extPath, strlen(PATH_site)) . $script;
         }
         if (!@is_file(PATH_site . $newFile)) {
             if ($this->tt_track) {
                 $GLOBALS['TT']->setTSlogMessage('Extension media file "' . $newFile . '" was not found!', 3);
             }
             return;
         } else {
             $file = $newFile;
         }
     }
     // find
     if (strpos($file, '/') !== false) {
         // if the file is in the media/ folder but it doesn't exist,
         // it is assumed that it's in the tslib folder
         if (t3lib_div::isFirstPartOfStr($file, 'media/') && !is_file($this->getFileName_backPath . $file)) {
             $file = t3lib_extMgm::siteRelPath('cms') . 'tslib/' . $file;
         }
         if (is_file($this->getFileName_backPath . $file)) {
             $outFile = $file;
             $fileInfo = t3lib_div::split_fileref($outFile);
             $OK = 0;
             foreach ($this->allowedPaths as $val) {
                 if (substr($fileInfo['path'], 0, strlen($val)) == $val) {
                     $OK = 1;
                     break;
                 }
             }
             if ($OK) {
                 $this->fileCache[$hash] = $outFile;
                 return $outFile;
             } elseif ($this->tt_track) {
                 $GLOBALS['TT']->setTSlogMessage('"' . $file . '" was not located in the allowed paths: (' . implode(',', $this->allowedPaths) . ')', 3);
             }
         } elseif ($this->tt_track) {
             $GLOBALS['TT']->setTSlogMessage('"' . $this->getFileName_backPath . $file . '" is not a file (non-uploads/.. resource, did not exist).', 3);
         }
     } else {
         // Here it is uploaded media:
         $outFile = $this->extractFromResources($this->setup['resources'], $file);
         if ($outFile) {
             if (@is_file($this->uplPath . $outFile)) {
                 $this->fileCache[$hash] = $this->uplPath . $outFile;
                 return $this->uplPath . $outFile;
             } elseif ($this->tt_track) {
                 $GLOBALS['TT']->setTSlogMessage('"' . $this->uplPath . $outFile . '" is not a file (did not exist).', 3);
             }
         } elseif ($this->tt_track) {
             $GLOBALS['TT']->setTSlogMessage('"' . $file . '" is not a file (uploads/.. resource).', 3);
         }
     }
 }
 /**
  * Calling a user function/class-method
  * Notice: For classes the instantiated object will have the internal variable, $cObj, set to be a *reference* to $this (the parent/calling object).
  *
  * @param	string		The functionname, eg "user_myfunction" or "user_myclass->main". Notice that there are rules for the names of functions/classes you can instantiate. If a function cannot be called for some reason it will be seen in the TypoScript log in the AdminPanel.
  * @param	array		The TypoScript configuration to pass the function
  * @param	string		The content string to pass the function
  * @return	string		The return content from the function call. Should probably be a string.
  * @see USER(), stdWrap(), typoLink(), _parseFunc()
  */
 function callUserFunction($funcName, $conf, $content)
 {
     $pre = $GLOBALS['TSFE']->TYPO3_CONF_VARS['FE']['userFuncClassPrefix'];
     if ($pre && !t3lib_div::isFirstPartOfStr(trim($funcName), $pre) && !t3lib_div::isFirstPartOfStr(trim($funcName), 'tx_')) {
         $GLOBALS['TT']->setTSlogMessage('Function "' . $funcName . '" was not prepended with "' . $pre . '"', 3);
         return $content;
     }
     // Split parts
     $parts = explode('->', $funcName);
     if (count($parts) == 2) {
         // Class
         // Check whether class is available and try to reload includeLibs if possible:
         if ($this->isClassAvailable($parts[0], $conf)) {
             $classObj = t3lib_div::makeInstance($parts[0]);
             if (is_object($classObj) && method_exists($classObj, $parts[1])) {
                 $classObj->cObj = $this;
                 $content = call_user_func_array(array($classObj, $parts[1]), array($content, $conf));
             } else {
                 $GLOBALS['TT']->setTSlogMessage('Method "' . $parts[1] . '" did not exist in class "' . $parts[0] . '"', 3);
             }
         } else {
             $GLOBALS['TT']->setTSlogMessage('Class "' . $parts[0] . '" did not exist', 3);
         }
     } else {
         // Function
         if (function_exists($funcName)) {
             $content = call_user_func($funcName, $content, $conf);
         } else {
             $GLOBALS['TT']->setTSlogMessage('Function "' . $funcName . '" did not exist', 3);
         }
     }
     return $content;
 }
예제 #19
0
 /**
  * @test
  * @depends settingGroupingTrueActivatesGrouping
  */
 public function settingGroupingFalseDeactivatesGrouping(Tx_Solr_Query $query)
 {
     $query->setGrouping(FALSE);
     $queryParameters = $query->getQueryParameters();
     foreach ($queryParameters as $queryParameter => $value) {
         $this->assertTrue(!t3lib_div::isFirstPartOfStr($queryParameter, 'group'), 'Query contains grouping parameter "' . $queryParameter . '"');
     }
 }
 /**
  * Moving files and folders (action=3)
  *
  * @param	array		$cmds['data'] is the file/folder to move. $cmds['target'] is the path where to move to. $cmds['altName'] (boolean): If set, another filename is found in case the target already exists
  * @return	string		Returns the new filename upon success
  */
 function func_move($cmds, $id)
 {
     if (!$this->isInit) {
         return FALSE;
     }
     // Initialize and check basic conditions:
     $theFile = $cmds['data'];
     $theDest = $this->is_directory($cmds['target']);
     // Clean up destination directory
     $altName = $cmds['altName'];
     // main log entry
     $this->log['cmd']['move'][$id] = array('errors' => array(), 'orig_filename' => $theFile, 'target_file' => '', 'target_folder' => '', 'target_path' => $theDest);
     if (!$theDest) {
         $this->writelog(3, 2, 100, 'Destination "%s" was not a directory', array($cmds['target']), 'move', $id);
         return FALSE;
     }
     if (!$this->isPathValid($theFile) || !$this->isPathValid($theDest)) {
         $this->writelog(3, 2, 101, 'Target or destination had invalid path (".." and "//" is not allowed in path). T="%s", D="%s"', array($theFile, $theDest), 'move', $id);
         return FALSE;
     }
     // Processing of file or directory:
     if (@is_file($theFile)) {
         // If we are moving a file...
         if ($this->actionPerms['moveFile']) {
             if (filesize($theFile) < $this->maxMoveFileSize * 1024) {
                 $fI = t3lib_div::split_fileref($theFile);
                 if ($altName) {
                     // If altName is set, we're allowed to create a new filename if the file already existed
                     $theDestFile = $this->getUniqueName($fI['file'], $theDest);
                     $fI = t3lib_div::split_fileref($theDestFile);
                 } else {
                     $theDestFile = $theDest . '/' . $fI['file'];
                 }
                 if ($theDestFile && !@file_exists($theDestFile)) {
                     if ($this->checkIfAllowed($fI['fileext'], $theDest, $fI['file'])) {
                         if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile)) {
                             if ($this->PHPFileFunctions) {
                                 rename($theFile, $theDestFile);
                             } else {
                                 $cmd = 'mv ' . escapeshellarg($theFile) . ' ' . escapeshellarg($theDestFile);
                                 exec($cmd);
                             }
                             clearstatcache();
                             if (@is_file($theDestFile)) {
                                 $this->log['cmd']['move'][$id]['target_file'] = $theDestFile;
                                 // update meta data
                                 if ($this->processMetaUpdate) {
                                     tx_dam::notify_fileMoved($theFile, $theDestFile);
                                 }
                                 $this->writelog(3, 0, 1, 'File "%s" moved to "%s"', array($theFile, $theDestFile), 'move', $id);
                                 return $theDestFile;
                             } else {
                                 $this->writelog(3, 2, 109, 'File "%s" WAS NOT moved to "%s"! Write-permission problem?', array($theFile, $theDestFile), 'move', $id);
                             }
                         } else {
                             $this->writelog(3, 1, 110, 'Target or destination was not within your mountpoints! T="%s", D="%s"', array($theFile, $theDestFile), 'move', $id);
                         }
                     } else {
                         $this->writelog(3, 1, 111, 'Fileextension "%s" is not allowed in "%s"!', array($fI['fileext'], $theDest . '/'), 'move', $id);
                     }
                 } else {
                     $this->writelog(3, 1, 112, 'File "%s" already exists!', array($theDestFile), 'move', $id);
                 }
             } else {
                 $this->writelog(3, 1, 113, 'File "%s" exceeds the size-limit of %s bytes', array($theFile, $this->maxMoveFileSize * 1024), 'move', $id);
             }
         } else {
             $this->writelog(3, 1, 114, 'You are not allowed to move files', '', 'move', $id);
         }
         // FINISHED moving file
     } elseif (@is_dir($theFile)) {
         // if we're moving a folder
         if ($this->actionPerms['moveFolder']) {
             $theFile = $this->is_directory($theFile);
             if ($theFile) {
                 $fI = t3lib_div::split_fileref($theFile);
                 if ($altName) {
                     // If altName is set, we're allowed to create a new filename if the file already existed
                     $theDestFile = $this->getUniqueName($fI['file'], $theDest);
                     $fI = t3lib_div::split_fileref($theDestFile);
                 } else {
                     $theDestFile = $theDest . '/' . $fI['file'];
                 }
                 if ($theDestFile && !@file_exists($theDestFile)) {
                     if (!t3lib_div::isFirstPartOfStr($theDestFile . '/', $theFile . '/')) {
                         // Check if the one folder is inside the other or on the same level... to target/dest is the same?
                         if ($this->checkIfFullAccess($theDest) || $this->is_webPath($theDestFile) == $this->is_webPath($theFile)) {
                             // // no moving of folders between spaces
                             if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile)) {
                                 if ($this->PHPFileFunctions) {
                                     rename($theFile, $theDestFile);
                                 } else {
                                     $cmd = 'mv ' . escapeshellarg($theFile) . ' ' . escapeshellarg($theDestFile);
                                     $errArr = array();
                                     $retVar = 0;
                                     exec($cmd, $errArr, $retVar);
                                 }
                                 clearstatcache();
                                 if (@is_dir($theDestFile)) {
                                     $this->log['cmd']['move'][$id]['target_folder'] = $theDestFile;
                                     // update meta data
                                     if ($this->processMetaUpdate) {
                                         tx_dam::notify_fileMoved($theFile, $theDestFile);
                                     }
                                     $this->writelog(3, 0, 2, 'Directory "%s" moved to "%s"', array($theFile, $theDestFile), 'move', $id);
                                     return $theDestFile;
                                 } else {
                                     $this->writelog(3, 2, 119, 'Directory "%s" WAS NOT moved to "%s"! Write-permission problem?', array($theFile, $theDestFile), 'move', $id);
                                 }
                             } else {
                                 $this->writelog(3, 1, 120, 'Target or destination was not within your mountpoints! T="%s", D="%s"', array($theFile, $theDestFile), 'move', $id);
                             }
                         } else {
                             $this->writelog(3, 1, 121, 'You don\'t have full access to the destination directory "%s"!', array($theDest . '/'), 'move', $id);
                         }
                     } else {
                         $this->writelog(3, 1, 122, 'Destination cannot be inside the target! D="%s", T="%s"', array($theDestFile . '/', $theFile . '/'), 'move', $id);
                     }
                 } else {
                     $this->writelog(3, 1, 123, 'Target "%s" already exists!', array($theDestFile), 'move', $id);
                 }
             } else {
                 $this->writelog(3, 2, 124, 'Target seemed not to be a directory! (Shouldn\'t happen here!)', '', 'move', $id);
             }
         } else {
             $this->writelog(3, 1, 125, 'You are not allowed to move directories', '', 'move', $id);
         }
         // FINISHED moving directory
     } else {
         $this->writelog(3, 2, 130, 'The item "%s" was not a file or directory!', array($theFile), 'move', $id);
     }
 }
 /**
  * Creates a valid email address for the sender of mail messages.
  *
  * Uses a fallback chain:
  *     $TYPO3_CONF_VARS['MAIL']['defaultMailFromAddress'] ->
  *     no-reply@FirstDomainRecordFound ->
  *     no-reply@php_uname('n') ->
  *     no-reply@example.com
  *
  * Ready to be passed to $mail->setFrom() (t3lib_mail)
  *
  * @return	string	An email address
  */
 public static function getSystemFromAddress()
 {
     // default, first check the localconf setting
     $address = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
     if (!t3lib_div::validEmail($address)) {
         // just get us a domain record we can use as the host
         $host = '';
         $domainRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('domainName', 'sys_domain', 'hidden = 0', '', 'pid ASC, sorting ASC');
         if (!empty($domainRecord['domainName'])) {
             $tempUrl = $domainRecord['domainName'];
             if (!t3lib_div::isFirstPartOfStr($tempUrl, 'http')) {
                 // shouldn't be the case anyways, but you never know
                 // ... there're crazy people out there
                 $tempUrl = 'http://' . $tempUrl;
             }
             $host = parse_url($tempUrl, PHP_URL_HOST);
         }
         $address = 'no-reply@' . $host;
         if (!t3lib_div::validEmail($address)) {
             // still nothing, get host name from server
             $address = 'no-reply@' . php_uname('n');
             if (!t3lib_div::validEmail($address)) {
                 // if everything fails use a dummy address
                 $address = '*****@*****.**';
             }
         }
     }
     return $address;
 }
	/**
	 * Rendering the information
	 *
	 * @param	array		The Page tree data
	 * @return	string		HTML for the information table.
	 */
	function renderModule(t3lib_pageTree $tree)	{

			// Initialize:
		$searchPath = trim(t3lib_div::_GP('pathPrefixSearch'));
		$cmd = t3lib_div::_GET('cmd');
		$entry = t3lib_div::_GET('entry');
		$searchForm_replace = t3lib_div::_POST('_replace');
		$searchForm_delete = t3lib_div::_POST('_delete');

		$trackSameUrl = array();
		$this->searchResultCounter = 0;

			// Traverse tree:
		$output = '';
		$cc=0;
		foreach($tree->tree as $row)	{

				// Get all pagepath entries for page:
			$pathCacheInfo = $this->getPathCache($row['row']['uid']);

				// Row title:
			$rowTitle = $row['HTML'].t3lib_BEfunc::getRecordTitle('pages',$row['row'],TRUE);
			$cellAttrib = ($row['row']['_CSSCLASS'] ? ' class="'.$row['row']['_CSSCLASS'].'"' : '');

				// Add at least one empty element:
			if (!count($pathCacheInfo))	{

						// Add title:
					$tCells = array();
					$tCells[]='<td nowrap="nowrap"'.$cellAttrib.'>'.$rowTitle.'</td>';

						// Empty row:
					$tCells[]='<td colspan="10" align="center">&nbsp;</td>';

						// Compile Row:
					$output.= '
						<tr class="bgColor'.($cc%2 ? '-20':'-10').'">
							'.implode('
							',$tCells).'
						</tr>';
					$cc++;
			} else {
				foreach($pathCacheInfo as $c => $inf)	{

						// Init:
					$deletedEntry = FALSE;
					$hash = $inf['pagepath'].'|'.$inf['rootpage_id'].'|'.$inf['language_id'];	// MP is not a part of this because the path itself should be different simply because the MP makes a different path! (see tx_realurl_advanced::pagePathtoID())

						// Add icon/title and ID:
					$tCells = array();
					if (!$c)	{
						$tCells[]='<td nowrap="nowrap" rowspan="'.count($pathCacheInfo).'"'.$cellAttrib.'>'.$rowTitle.'</td>';
						$tCells[]='<td rowspan="'.count($pathCacheInfo).'">'.$inf['page_id'].'</td>';
					}

						// Add values from alternative field used to generate URL:
					$baseRow = $row['row'];	// page row as base.
					$onClick = t3lib_BEfunc::editOnClick('&edit[pages]['.$row['row']['uid'].']=edit&columnsOnly=title,nav_title,alias,tx_realurl_pathsegment',$this->pObj->doc->backPath);
					$editIcon = '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
								'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' title="" alt="" />'.
								'</a>';
					$onClick = t3lib_BEfunc::viewOnClick($row['row']['uid'],$this->pObj->doc->backPath,'','','','');
					$editIcon.= '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
								'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/zoom.gif','width="12" height="12"').' title="" alt="" />'.
								'</a>';

					if ($inf['language_id']>0)	{	// For alternative languages, show another list of fields, form page overlay record:
						$editIcon = '';
						list($olRec) = t3lib_BEfunc::getRecordsByField('pages_language_overlay','pid',$row['row']['uid'],' AND sys_language_uid='.intval($inf['language_id']));
						if (is_array($olRec))	{
							$baseRow = array_merge($baseRow,$olRec);
							$onClick = t3lib_BEfunc::editOnClick('&edit[pages_language_overlay]['.$olRec['uid'].']=edit&columnsOnly=title,nav_title',$this->pObj->doc->backPath);
							$editIcon = '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
										'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' title="" alt="" />'.
										'</a>';
							$onClick = t3lib_BEfunc::viewOnClick($row['row']['uid'],$this->pObj->doc->backPath,'','','','&L='.$olRec['sys_language_uid']);
							$editIcon.= '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
										'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/zoom.gif','width="12" height="12"').' title="" alt="" />'.
										'</a>';
						} else {
							$baseRow = array();
						}
					}
					$tCells[]='<td>'.$editIcon.'</td>';

						// 	Sources for segment:
					$sources = count($baseRow) ? implode(' | ',array($baseRow['tx_realurl_pathsegment'], $baseRow['alias'], $baseRow['nav_title'], $baseRow['title'])) : '';
					$tCells[]='<td nowrap="nowrap">'.htmlspecialchars($sources).'</td>';

						// Show page path:
					if (strcmp($searchPath,'') && t3lib_div::isFirstPartOfStr($inf['pagepath'],$searchPath) && !$inf['expire'])	{

							// Delete entry:
						if ($searchForm_delete)	{
							$this->deletePathCacheEntry($inf['cache_id']);
							$deletedEntry = TRUE;
							$pagePath = '[DELETED]';
						} elseif ($searchForm_replace) {
							$replacePart = trim(t3lib_div::_POST('pathPrefixReplace'));
							$this->editPathCacheEntry($inf['cache_id'],
								$replacePart.substr($inf['pagepath'],strlen($searchPath)));

							$pagePath =
									'<span class="typo3-red">'.
									htmlspecialchars($replacePart).
									'</span>'.
									htmlspecialchars(substr($inf['pagepath'],strlen($searchPath)));
						} else {
							$pagePath =
									'<span class="typo3-red">'.
									htmlspecialchars(substr($inf['pagepath'],0,strlen($searchPath))).
									'</span>'.
									htmlspecialchars(substr($inf['pagepath'],strlen($searchPath)));
							$this->searchResultCounter++;
						}
					} else {
							// Delete entries:
						if ($cmd==='edit' && (!strcmp($entry,$inf['cache_id']) || !strcmp($entry,'ALL')))	{
							$pagePath = '<input type="text" name="edit['.$inf['cache_id'].']" value="'.htmlspecialchars($inf['pagepath']).'" size="40" />';
							if ($cmd==='edit' && $entry!='ALL')	{
								$pagePath.= $this->saveCancelButtons();
							}

						} else {
							$pagePath = htmlspecialchars($inf['pagepath']);
						}
					}

					$tCells[]='<td'.($inf['expire'] ? ' style="font-style: italic; color:#999999;"' : '').'>'.$pagePath.'</td>';

					if ($deletedEntry)	{
						$tCells[]='<td>&nbsp;</td>';
					} else {
						$tCells[]='<td>'.
								'<a href="'.$this->linkSelf('&cmd=delete&entry='.$inf['cache_id']).'">'.
								'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/garbage.gif','width="11" height="12"').' title="Delete" alt="" />'.
								'</a>'.
								'<a href="'.$this->linkSelf('&cmd=edit&entry='.$inf['cache_id']).'">'.
								'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' title="Edit" alt="" />'.
								'</a>'.
								'<a href="'.$this->linkSelf('&pathPrefixSearch='.rawurlencode($inf['pagepath'])).'">'.
								'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/napshot.gif','width="12" height="12"').' title="Use for search" alt="" />'.
								'</a>'.
								'<a href="'.$this->linkSelf('&cmd=copy&entry='.$inf['cache_id']).'">'.
								'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/clip_copy.gif','width="12" height="12"').' title="Copy entry" alt="" />'.
								'</a>'.
								'</td>';
					}
					$tCells[]='<td'.($inf['expire'] && $inf['expire']<time() ? ' style="color: red;"':'').'>'.
								($inf['expire'] ? htmlspecialchars(t3lib_BEfunc::dateTimeAge($inf['expire'],-1)) : '').
								($inf['expire'] ?
									'<a href="'.$this->linkSelf('&cmd=raiseExpire&entry='.$inf['cache_id']).'">'.
									'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/up.gif','width="14" height="14"').' title="Set expire time to 30 days" alt="" />'.
									'</a>' : '').
								'</td>';

						// Set error msg:
					$error = '';
					if (!strcmp($inf['pagepath'],''))	{
						if ($row['row']['uid']!=$this->pObj->id)	{	// Show error of "Empty" only for levels under the root. Yes, we cannot know that the pObj->id is the true root of the site, but at least any SUB page should probably have a path string!
							$error = $this->pObj->doc->icons(2).'Empty';
						}
					} elseif (isset($trackSameUrl[$hash]))	{
						$error = $this->pObj->doc->icons(2).'Already used on page ID '.$trackSameUrl[$hash];
					} else {
						$error = '&nbsp;';
					}
					$tCells[]='<td>'.$error.'</td>';

					$tCells[]='<td>'.htmlspecialchars($inf['language_id']).'</td>';
					$tCells[]='<td>'.htmlspecialchars($inf['mpvar']).'</td>';
					$tCells[]='<td>'.htmlspecialchars($inf['rootpage_id']).'</td>';


					#$tCells[]='<td nowrap="nowrap">'.htmlspecialchars(t3lib_BEfunc::datetime($inf['expire'])).' / '.htmlspecialchars(t3lib_BEfunc::calcAge($inf['expire']-time())).'</td>';

					$trackSameUrl[$hash] = $inf['page_id'];

						// Compile Row:
					$rowClass = 'bgColor'.($cc%2 ? '-20':'-10');
					$output.= '
						<tr class="'.$rowClass.'">
							'.implode('
							',$tCells).'
						</tr>';
					$cc++;
				}
			}
		}

			// Create header:
		$tCells = array();
		$tCells[]='<td>Title:</td>';
		$tCells[]='<td>ID:</td>';
		$tCells[]='<td>&nbsp;</td>';
		$tCells[]='<td>PathSegment | Alias | NavTitle | Title:</td>';
		$tCells[]='<td>Pagepath:</td>';
		$tCells[]='<td>'.
					'<a href="'.$this->linkSelf('&cmd=delete&entry=ALL').'" onclick="return confirm(\'Are you sure you want to flush all cached page paths?\');">'.
					'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/garbage.gif','width="11" height="12"').' alt="" />'.
					'</a>'.
					'<a href="'.$this->linkSelf('&cmd=edit&entry=ALL').'">'.
					'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' title="" alt="" />'.
					'</a>'.
					'</td>';
		$tCells[]='<td>Expires:'.
						'<a href="'.$this->linkSelf('&cmd=flushExpired').'">'.
						'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/garbage.gif','width="11" height="12"').' title="Flush all expired" alt="" />'.
						'</a>'.
					'</td>';
		$tCells[]='<td>Errors:</td>';
		$tCells[]='<td>Lang:</td>';
		$tCells[]='<td>&MP:</td>';
		$tCells[]='<td>RootPage ID:</td>';
		#$tCells[]='<td>Expire:</td>';
		$output = '
			<tr class="bgColor5 tableheader">
				'.implode('
				',$tCells).'
			</tr>'.$output;

			// Compile final table and return:
		$output = '
		<table border="0" cellspacing="1" cellpadding="0" id="tx-realurl-pathcacheTable" class="lrPadding c-list">'.$output.'
		</table>';

		if ($cmd==='edit' && $entry=='ALL')	{
			$output.= $this->saveCancelButtons();
		}

		return $output;
	}
예제 #23
0
 /**
  * Mandatory autofix function
  * Will run auto-fix on the result array. Echos status during processing.
  *
  * @param	array		Result array from main() function
  * @return	void
  */
 function main_autoFix($resultArray)
 {
     $limitTo = $this->cli_args['--AUTOFIX'][0];
     if (is_array($resultArray['doubleFiles'])) {
         if (!$limitTo || $limitTo === 'doubleFiles') {
             echo 'FIXING double-usages of RTE files in uploads/: ' . LF;
             foreach ($resultArray['RTEmagicFilePairs'] as $fileName => $fileInfo) {
                 // Only fix something if there is a usage count of more than 1 plus if both original and copy exists:
                 if ($fileInfo['count'] > 1 && $fileInfo['exists'] && $fileInfo['original_exists']) {
                     // Traverse all records using the file:
                     $c = 0;
                     foreach ($fileInfo['usedIn'] as $hash => $recordID) {
                         if ($c == 0) {
                             echo '	Keeping file ' . $fileName . ' for record ' . $recordID . LF;
                         } else {
                             // CODE below is adapted from "class.tx_impexp.php" where there is support for duplication of RTE images:
                             echo '	Copying file ' . basename($fileName) . ' for record ' . $recordID . ' ';
                             // Initialize; Get directory prefix for file and set the original name:
                             $dirPrefix = dirname($fileName) . '/';
                             $rteOrigName = basename($fileInfo['original']);
                             // If filename looks like an RTE file, and the directory is in "uploads/", then process as a RTE file!
                             if ($rteOrigName && t3lib_div::isFirstPartOfStr($dirPrefix, 'uploads/') && @is_dir(PATH_site . $dirPrefix)) {
                                 // RTE:
                                 // From the "original" RTE filename, produce a new "original" destination filename which is unused.
                                 $fileProcObj = $this->getFileProcObj();
                                 $origDestName = $fileProcObj->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
                                 // Create copy file name:
                                 $pI = pathinfo($fileName);
                                 $copyDestName = dirname($origDestName) . '/RTEmagicC_' . substr(basename($origDestName), 10) . '.' . $pI['extension'];
                                 if (!@is_file($copyDestName) && !@is_file($origDestName) && $origDestName === t3lib_div::getFileAbsFileName($origDestName) && $copyDestName === t3lib_div::getFileAbsFileName($copyDestName)) {
                                     echo ' to ' . basename($copyDestName);
                                     if ($bypass = $this->cli_noExecutionCheck($fileName)) {
                                         echo $bypass;
                                     } else {
                                         // Making copies:
                                         t3lib_div::upload_copy_move(PATH_site . $fileInfo['original'], $origDestName);
                                         t3lib_div::upload_copy_move(PATH_site . $fileName, $copyDestName);
                                         clearstatcache();
                                         if (@is_file($copyDestName)) {
                                             $sysRefObj = t3lib_div::makeInstance('t3lib_refindex');
                                             $error = $sysRefObj->setReferenceValue($hash, substr($copyDestName, strlen(PATH_site)));
                                             if ($error) {
                                                 echo '	- ERROR:	t3lib_refindex::setReferenceValue(): ' . $error . LF;
                                                 exit;
                                             } else {
                                                 echo " - DONE";
                                             }
                                         } else {
                                             echo '	- ERROR: File "' . $copyDestName . '" was not created!';
                                         }
                                     }
                                 } else {
                                     echo '	- ERROR: Could not construct new unique names for file!';
                                 }
                             } else {
                                 echo '	- ERROR: Maybe directory of file was not within "uploads/"?';
                             }
                             echo LF;
                         }
                         $c++;
                     }
                 }
             }
         } else {
             echo 'Bypassing fixing of double-usages since --AUTOFIX was not "doubleFiles"' . LF;
         }
     }
     if (is_array($resultArray['lostFiles'])) {
         if ($limitTo === 'lostFiles') {
             echo 'Removing lost RTEmagic files from folders inside uploads/: ' . LF;
             foreach ($resultArray['lostFiles'] as $key => $value) {
                 $absFileName = t3lib_div::getFileAbsFileName($value);
                 echo 'Deleting file: "' . $absFileName . '": ';
                 if ($bypass = $this->cli_noExecutionCheck($absFileName)) {
                     echo $bypass;
                 } else {
                     if ($absFileName && @is_file($absFileName)) {
                         unlink($absFileName);
                         echo 'DONE';
                     } else {
                         echo '	ERROR: File "' . $absFileName . '" was not found!';
                     }
                 }
                 echo LF;
             }
         }
     } else {
         echo 'Bypassing fixing of double-usages since --AUTOFIX was not "lostFiles"' . LF;
     }
 }
 /**
  * Transformation handler: 'ts_images' / direction: "db"
  * Processing images inserted in the RTE.
  * This is used when content goes from the RTE to the database.
  * Images inserted in the RTE has an absolute URL applied to the src attribute. This URL is converted to a relative URL
  * If it turns out that the URL is from another website than the current the image is read from that external URL and moved to the local server.
  * Also "magic" images are processed here.
  *
  * @param	string		The content from RTE going to Database
  * @return	string		Processed content
  */
 function TS_images_db($value)
 {
     // Split content by <img> tags and traverse the resulting array for processing:
     $imgSplit = $this->splitTags('img', $value);
     foreach ($imgSplit as $k => $v) {
         if ($k % 2) {
             // image found, do processing:
             // Init
             $attribArray = $this->get_tag_attributes_classic($v, 1);
             $siteUrl = $this->siteUrl();
             $sitePath = str_replace(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST'), '', $siteUrl);
             $absRef = trim($attribArray['src']);
             // It's always a absolute URL coming from the RTE into the Database.
             // make path absolute if it is relative and we have a site path wich is not '/'
             $pI = pathinfo($absRef);
             if ($sitePath and !$pI['scheme'] && t3lib_div::isFirstPartOfStr($absRef, $sitePath)) {
                 // if site is in a subpath (eg. /~user_jim/) this path needs to be removed because it will be added with $siteUrl
                 $absRef = substr($absRef, strlen($sitePath));
                 $absRef = $siteUrl . $absRef;
             }
             // External image from another URL? In that case, fetch image (unless disabled feature).
             if (!t3lib_div::isFirstPartOfStr($absRef, $siteUrl) && !$this->procOptions['dontFetchExtPictures']) {
                 $externalFile = $this->getUrl($absRef);
                 // Get it
                 if ($externalFile) {
                     $pU = parse_url($absRef);
                     $pI = pathinfo($pU['path']);
                     if (t3lib_div::inList('gif,png,jpeg,jpg', strtolower($pI['extension']))) {
                         $filename = t3lib_div::shortMD5($absRef) . '.' . $pI['extension'];
                         $origFilePath = PATH_site . $this->rteImageStorageDir() . 'RTEmagicP_' . $filename;
                         $C_origFilePath = PATH_site . $this->rteImageStorageDir() . 'RTEmagicC_' . $filename . '.' . $pI['extension'];
                         if (!@is_file($origFilePath)) {
                             t3lib_div::writeFile($origFilePath, $externalFile);
                             t3lib_div::writeFile($C_origFilePath, $externalFile);
                         }
                         $absRef = $siteUrl . $this->rteImageStorageDir() . 'RTEmagicC_' . $filename . '.' . $pI['extension'];
                         $attribArray['src'] = $absRef;
                         $params = t3lib_div::implodeAttributes($attribArray, 1);
                         $imgSplit[$k] = '<img ' . $params . ' />';
                     }
                 }
             }
             // Check image as local file (siteURL equals the one of the image)
             if (strpos($absRef, 'http://') === FALSE and strpos($absRef, 'https://') === FALSE and strpos($absRef, 'ftp://') === FALSE) {
                 //XCLASS changed from: if (t3lib_div::isFirstPartOfStr($absRef,$siteUrl))	{
                 $path = rawurldecode(substr($absRef, strlen($siteUrl)));
                 // Rel-path, rawurldecoded for special characters.
                 $path = $absRef;
                 //XCLASS added
                 $filepath = t3lib_div::getFileAbsFileName($path);
                 // Abs filepath, locked to relative path of this project.
                 // Check file existence (in relative dir to this installation!)
                 if ($filepath && @is_file($filepath)) {
                     // If "magic image":
                     $pathPre = $this->rteImageStorageDir() . 'RTEmagicC_';
                     if (t3lib_div::isFirstPartOfStr($path, $pathPre)) {
                         // Find original file:
                         $pI = pathinfo(substr($path, strlen($pathPre)));
                         $filename = substr($pI['basename'], 0, -strlen('.' . $pI['extension']));
                         $origFilePath = PATH_site . $this->rteImageStorageDir() . 'RTEmagicP_' . $filename;
                         if (@is_file($origFilePath)) {
                             $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
                             $imgObj->init();
                             $imgObj->mayScaleUp = 0;
                             $imgObj->tempPath = PATH_site . $imgObj->tempPath;
                             $curInfo = $imgObj->getImageDimensions($filepath);
                             // Image dimensions of the current image
                             $curWH = $this->getWHFromAttribs($attribArray);
                             // Image dimensions as set in the image tag
                             // Compare dimensions:
                             if ($curWH[0] != $curInfo[0] || $curWH[1] != $curInfo[1]) {
                                 $origImgInfo = $imgObj->getImageDimensions($origFilePath);
                                 // Image dimensions of the current image
                                 $cW = $curWH[0];
                                 $cH = $curWH[1];
                                 $cH = 1000;
                                 // Make the image based on the width solely...
                                 $imgI = $imgObj->imageMagickConvert($origFilePath, $pI['extension'], $cW . 'm', $cH . 'm');
                                 if ($imgI[3]) {
                                     $fI = pathinfo($imgI[3]);
                                     @copy($imgI[3], $filepath);
                                     // Override the child file
                                     // Removing width and heigth form style attribute
                                     $attribArray['style'] = preg_replace('/((?:^|)\\s*(?:width|height)\\s*:[^;]*(?:$|;))/si', '', $attribArray['style']);
                                     $attribArray['width'] = $imgI[0];
                                     $attribArray['height'] = $imgI[1];
                                     $params = t3lib_div::implodeAttributes($attribArray, 1);
                                     $imgSplit[$k] = '<img ' . $params . ' />';
                                 }
                             }
                         }
                     } elseif ($this->procOptions['plainImageMode']) {
                         // If "plain image" has been configured:
                         // Image dimensions as set in the image tag, if any
                         $curWH = $this->getWHFromAttribs($attribArray);
                         if ($curWH[0]) {
                             $attribArray['width'] = $curWH[0];
                         }
                         if ($curWH[1]) {
                             $attribArray['height'] = $curWH[1];
                         }
                         // Removing width and heigth form style attribute
                         $attribArray['style'] = preg_replace('/((?:^|)\\s*(?:width|height)\\s*:[^;]*(?:$|;))/si', '', $attribArray['style']);
                         // Finding dimensions of image file:
                         $fI = @getimagesize($filepath);
                         // Perform corrections to aspect ratio based on configuration:
                         switch ((string) $this->procOptions['plainImageMode']) {
                             case 'lockDimensions':
                                 $attribArray['width'] = $fI[0];
                                 $attribArray['height'] = $fI[1];
                                 break;
                             case 'lockRatioWhenSmaller':
                                 // If the ratio has to be smaller, then first set the width...:
                                 if ($attribArray['width'] > $fI[0]) {
                                     $attribArray['width'] = $fI[0];
                                 }
                             case 'lockRatio':
                                 if ($fI[0] > 0) {
                                     $attribArray['height'] = round($attribArray['width'] * ($fI[1] / $fI[0]));
                                 }
                                 break;
                         }
                         // Compile the image tag again:
                         $params = t3lib_div::implodeAttributes($attribArray, 1);
                         $imgSplit[$k] = '<img ' . $params . ' />';
                     }
                 } else {
                     // Remove image if it was not found in a proper position on the server!
                     // Commented out; removing the image tag might not be that logical...
                     #$imgSplit[$k]='';
                 }
             }
             // Convert abs to rel url
             if ($imgSplit[$k]) {
                 $attribArray = $this->get_tag_attributes_classic($imgSplit[$k], 1);
                 $absRef = trim($attribArray['src']);
                 if (t3lib_div::isFirstPartOfStr($absRef, $siteUrl)) {
                     $attribArray['src'] = $this->relBackPath . substr($absRef, strlen($siteUrl));
                     if (!isset($attribArray['alt'])) {
                         $attribArray['alt'] = '';
                     }
                     // Must have alt-attribute for XHTML compliance.
                     $imgSplit[$k] = '<img ' . t3lib_div::implodeAttributes($attribArray, 1, 1) . ' />';
                 }
             }
         }
     }
     return implode('', $imgSplit);
 }
 /**
  * Passwords prefixed with M or C might be salted passwords:
  *	M means: originally a md5 hash before it was salted (eg. default be_users).
  *	C means: originally a cleartext password with lower hash looping count generated by t3sec_saltedpw.
  * Both M and C will be updated to usual salted hashes on first login of user.
  *
  * If a password does not start with M or C determine if a password is already a usual salted hash.
  *
  * @param string Password
  * @return boolean True if password is a salted hash
  */
 protected function isSaltedHash($password)
 {
     $isSaltedHash = FALSE;
     if (strlen($password) > 2 && (t3lib_div::isFirstPartOfStr($password, 'C$') || t3lib_div::isFirstPartOfStr($password, 'M$'))) {
         // Cut off M or C and test if we have a salted hash
         $isSaltedHash = tx_saltedpasswords_salts_factory::determineSaltingHashingMethod(substr($password, 1));
     }
     // Test if given password is a already a usual salted hash
     if (!$isSaltedHash) {
         $isSaltedHash = tx_saltedpasswords_salts_factory::determineSaltingHashingMethod($password);
     }
     return $isSaltedHash;
 }
예제 #26
0
 /**
  * Main function, adding items to the click menu array.
  *
  * @param	object		Reference to the parent object of the clickmenu class which calls this function
  * @param	array		The current array of menu items - you have to add or remove items to this array in this function. Thats the point...
  * @param	string		The database table OR filename
  * @param	integer		For database tables, the UID
  * @return	array		The modified menu array.
  */
 function main(&$backRef, $menuItems, $table, $uid)
 {
     global $BE_USER, $LANG, $TYPO3_DB;
     $localItems = array();
     if (!$backRef->cmLevel) {
         $LL = $LANG->includeLLFile(t3lib_extMgm::extPath('templavoila') . 'locallang.xml', 0);
         // Adding link for Mapping tool:
         if (@is_file($table)) {
             if ($BE_USER->isAdmin()) {
                 if (function_exists('finfo_open')) {
                     $finfoMode = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
                     $fi = finfo_open($finfoMode);
                     $mimeInformation = @finfo_file($fi, $table);
                     $enabled = FALSE;
                     if (t3lib_div::isFirstPartOfStr($mimeInformation, 'text/html') || t3lib_div::isFirstPartOfStr($mimeInformation, 'application/xml')) {
                         $enabled = TRUE;
                     }
                     finfo_close($fi);
                 } else {
                     $pi = @pathinfo($table);
                     $enabled = preg_match('/(html?|tmpl|xml)/', $pi['extension']);
                 }
                 if ($enabled) {
                     $url = t3lib_extMgm::extRelPath('templavoila') . 'cm1/index.php?file=' . rawurlencode($table);
                     $localItems[] = $backRef->linkItem($LANG->getLLL('cm1_title', $LL, 1), $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
                 }
             }
         } elseif (t3lib_div::inList('tx_templavoila_tmplobj,tx_templavoila_datastructure,tx_templavoila_content', $table)) {
             $url = t3lib_extMgm::extRelPath('templavoila') . 'cm1/index.php?table=' . rawurlencode($table) . '&uid=' . $uid . '&_reload_from=1';
             $localItems[] = $backRef->linkItem($LANG->getLLL('cm1_title', $LL, 1), $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
         }
         $isTVelement = ('tt_content' == $table && $backRef->rec['CType'] == 'templavoila_pi1' || 'pages' == $table) && $backRef->rec['tx_templavoila_flex'];
         // Adding link for "View: Sub elements":
         if ($table == 'tt_content' && $isTVelement) {
             $localItems = array();
             $url = t3lib_extMgm::extRelPath('templavoila') . 'mod1/index.php?id=' . intval($backRef->rec['pid']) . '&altRoot[table]=' . rawurlencode($table) . '&altRoot[uid]=' . $uid . '&altRoot[field_flex]=tx_templavoila_flex';
             $localItems[] = $backRef->linkItem($LANG->getLLL('cm1_viewsubelements', $LL, 1), $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
         }
         // Adding link for "View: Flexform XML" (admin only):
         if ($BE_USER->isAdmin() && $isTVelement) {
             $url = t3lib_extMgm::extRelPath('templavoila') . 'cm2/index.php?' . '&viewRec[table]=' . rawurlencode($table) . '&viewRec[uid]=' . $uid . '&viewRec[field_flex]=tx_templavoila_flex';
             $localItems[] = $backRef->linkItem($LANG->getLLL('cm1_viewflexformxml', $LL, 1), $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm2/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
         }
         // Adding link for "View: DS/TO" (admin only):
         if ($BE_USER->isAdmin() && $isTVelement) {
             if (tx_templavoila_div::canBeInterpretedAsInteger($backRef->rec['tx_templavoila_ds'])) {
                 $url = t3lib_extMgm::extRelPath('templavoila') . 'cm1/index.php?' . 'table=tx_templavoila_datastructure&uid=' . $backRef->rec['tx_templavoila_ds'];
                 $localItems[] = $backRef->linkItem($LANG->getLLL('cm_viewdsto', $LL, 1) . ' [' . $backRef->rec['tx_templavoila_ds'] . '/' . $backRef->rec['tx_templavoila_to'] . ']', $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm2/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
             }
         }
         #			if ($table=='tt_content') {
         #					// Adding link for "Pages using this element":
         #				$localItems[] = $backRef->linkItem(
         #					$LANG->getLLL('cm1_pagesusingthiselement',$LL),
         #					$backRef->excludeIcon('<img src="'.t3lib_extMgm::extRelPath('templavoila').'cm1/cm_icon_activate.gif" width="15" height="12" border=0 align=top>'),
         #					"top.loadTopMenu('".t3lib_div::linkThisScript()."&cmLevel=1&subname=tx_templavoila_cm1_pagesusingthiselement');return false;",
         #					0,
         #					1
         #				);
         #			}
     } else {
         if (t3lib_div::_GP('subname') == 'tx_templavoila_cm1_pagesusingthiselement') {
             $menuItems = array();
             $url = t3lib_extMgm::extRelPath('templavoila') . 'mod1/index.php?id=';
             // Generate a list of pages where this element is also being used:
             $res = $TYPO3_DB->exec_SELECTquery('*', 'tx_templavoila_elementreferences', 'uid=' . $backRef->rec['uid']);
             if ($res) {
                 while (false != ($referenceRecord = $TYPO3_DB->sql_fetch_assoc($res))) {
                     $pageRecord = t3lib_beFunc::getRecord('pages', $referenceRecord['pid']);
                     $icon = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageRecord);
                     // To do: Display language flag icon and jump to correct language
                     #						if ($referenceRecord['lkey'] != 'lDEF') {
                     #							$icon .= ' lKey:'.$referenceRecord['lkey'];
                     #						} elseif ($referenceRecord['vkey'] != 'vDEF') {
                     #							$icon .= ' vKey:'.$referenceRecord['vkey'];
                     #						}
                     if (is_array($pageRecord)) {
                         $menuItems[] = $backRef->linkItem($icon, t3lib_beFunc::getRecordTitle('pages', $pageRecord, 1), $backRef->urlRefForCM($url . $pageRecord['uid'], 'returnUrl'), 1);
                     }
                 }
             }
         }
     }
     // Simply merges the two arrays together and returns ...
     if (count($localItems)) {
         $menuItems = array_merge($menuItems, $localItems);
     }
     return $menuItems;
 }
예제 #27
0
    function _render()
    {
        //$this->oForm->oJs->loadScriptaculous();
        $aConf = array();
        if (($sSpeed = $this->_navConf("/speed")) !== FALSE) {
            $aConf["resizeSpeed"] = intval($sSpeed);
        }
        if (($sClassToggle = $this->_navConf("/classtoggle")) !== FALSE) {
            $aConf["classNames"]["toggle"] = $sClassToggle;
        } else {
            $aConf["classNames"]["toggle"] = "accordion_toggle";
        }
        if (($sClassToggleActive = $this->_navConf("/classtoggleactive")) !== FALSE) {
            $aConf["classNames"]["toggleActive"] = $sClassToggleActive;
        } else {
            $aConf["classNames"]["toggle"] = "accordion_toggle_active";
        }
        if (($sWidth = $this->_navConf("/width")) !== FALSE) {
            $aConf["defaultSize"]["width"] = $sWidth;
        }
        if (($sHeight = $this->_navConf("/height")) !== FALSE) {
            $aConf["defaultSize"]["height"] = $sHeight;
        }
        if (($sDirection = $this->_navConf("/direction")) !== FALSE) {
            $aConf["direction"] = $sDirection;
        }
        if (($sEvent = $this->_navConf("/event")) !== FALSE) {
            $sEvent = strtolower(trim($sEvent));
            if (t3lib_div::isFirstPartOfStr($sEvent, "on")) {
                $sEvent = substr($sEvent, 2);
            }
            $aConf["onEvent"] = $sEvent;
        }
        reset($this->aChilds);
        $aKeys = array_keys($this->aChilds);
        reset($aKeys);
        while (list(, $sChild) = each($aKeys)) {
            // even is toggle
            $aConf["accordions"][] = $this->aChilds[$sChild]->_getElementHtmlId();
            if ($aConf["direction"] === "horizontal") {
                $this->aChilds[$sChild]->addCssClass("rdtaccordion_toggle_horizontal");
            } else {
                $this->aChilds[$sChild]->addCssClass("rdtaccordion_toggle");
            }
            $this->aChilds[$sChild]->addCssClass($aConf["classNames"]["toggle"]);
            // odd is content
            list(, $sChild) = each($aKeys);
            $this->aChilds[$sChild]->addCssClass("rdtaccordion_content");
            if ($aConf["direction"] === "horizontal") {
                $this->aChilds[$sChild]->addCssClass("rdtaccordion_content_horizontal");
            } else {
                $this->aChilds[$sChild]->addCssClass("rdtaccordion_content");
            }
        }
        if ($aConf["direction"] === "horizontal") {
            $sStyle = <<<STYLE
.rdtaccordion_toggle_horizontal {
\t/* REQUIRED */
\tfloat: left;\t/* This make sure it stays horizontal */
\t/* REQUIRED */
}
.rdtaccordion_content_horizontal {
\toverflow: hidden;
\t/* REQUIRED */
\tfloat: left;\t/* This make sure it stays horizontal */
\t/* REQUIRED */
}
STYLE;
        } else {
            $sStyle = <<<STYLE
.rdtaccordion_toggle {}
.rdtaccordion_content { overflow: hidden;}
STYLE;
        }
        $this->oForm->additionalHeaderData($this->oForm->inline2TempFile($sStyle, 'css', "CSS required by rdt_accordion"), "rdt_accordion_" . $aConf["direction"] . " required_css");
        $this->oForm->oJs->loadScriptaculous();
        $this->includeScripts(array("libconf" => $aConf));
        $sAddInputParams = $this->_getAddInputParams();
        $aChilds = $this->renderChildsBag();
        $sCompiledChilds = $this->renderChildsCompiled($aChilds);
        return array("__compiled" => "<div id='" . $this->_getElementHtmlId() . "'>" . $sCompiledChilds . "</div>", "childs" => $aChilds);
    }
예제 #28
0
 function validateByPath($sPath)
 {
     if (!$this->hasError()) {
         $aConf = $this->_navConf($sPath);
         if (is_array($aConf) && !empty($aConf)) {
             $sAbsName = $this->getAbsName();
             while (!$this->hasError() && (list($sKey, $aValidator) = each($aConf))) {
                 if ($sKey[0] === "v" && $sKey[1] === "a" && t3lib_div::isFirstPartOfStr($sKey, "validator") && !t3lib_div::isFirstPartOfStr($sKey, "validators")) {
                     // the conf section exists
                     // call validator
                     $oValidator = $this->oForm->_makeValidator($aValidator);
                     if ($oValidator->_matchConditions()) {
                         $bHasToValidate = TRUE;
                         $aValidMap = $this->oForm->_navConf($this->oForm->sXpathToControl . "factorize/switchvalidation");
                         if (tx_ameosformidable::isRunneable($aValidMap)) {
                             $aValidMap = $this->callRunneable($aValidMap);
                         }
                         if (is_array($aValidMap) && array_key_exists($sAbsName, $aValidMap)) {
                             $bHasToValidate = $aValidMap[$sAbsName];
                         }
                         if ($bHasToValidate === TRUE) {
                             $oValidator->validate($this);
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Unlink (delete) cache files - ALL, including those not current, made by another sitepath.
  *
  * @return	string		Status Message
  */
 function removeALLtempCachedFiles()
 {
     $path = PATH_typo3conf;
     if (is_dir($path)) {
         $filesInDir = t3lib_div::getFilesInDir($path, 'php', 1);
         reset($filesInDir);
         while (list($kk, $vv) = each($filesInDir)) {
             if (t3lib_div::isFirstPartOfStr(basename($vv), 'temp_CACHED_')) {
                 if (strstr(basename($vv), 'ext_localconf.php') || strstr(basename($vv), 'ext_tables.php')) {
                     $content .= 'REMOVED: ' . $vv . '<br />';
                     unlink($vv);
                     if (file_exists($vv)) {
                         $content .= '<strong><font color="red">ERROR: File still exists, so could not be removed anyways!</font></strong><br />';
                     }
                 }
             }
         }
     }
     return $content;
 }
예제 #30
0
 /**
  * Find lost files in uploads/ folder
  * FIX METHOD: Simply delete the file...
  *
  * TODO: Add parameter to exclude filepath
  * TODO: Add parameter to list more file names/patterns to ignore
  * TODO: Add parameter to include RTEmagic images
  *
  * @return	array
  */
 function main()
 {
     global $TYPO3_DB;
     // Initialize result array:
     $resultArray = array('message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'], 'headers' => array('managedFiles' => array('Files related to TYPO3 records and managed by TCEmain', 'These files you definitely want to keep.', 0), 'ignoredFiles' => array('Ignored files (index.html, .htaccess etc.)', 'These files are allowed in uploads/ folder', 0), 'RTEmagicFiles' => array('RTE magic images - those found (and ignored)', 'These files are also allowed in some uploads/ folders as RTEmagic images.', 0), 'lostFiles' => array('Lost files - those you can delete', 'You can delete these files!', 3), 'warnings' => array('Warnings picked up', '', 2)), 'managedFiles' => array(), 'ignoredFiles' => array(), 'RTEmagicFiles' => array(), 'lostFiles' => array(), 'warnings' => array());
     // Get all files:
     $fileArr = array();
     $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr, PATH_site . 'uploads/');
     $fileArr = t3lib_div::removePrefixPathFromList($fileArr, PATH_site);
     $excludePaths = t3lib_div::trimExplode(',', $this->cli_argValue('--excludePath', 0), 1);
     // Traverse files and for each, look up if its found in the reference index.
     foreach ($fileArr as $key => $value) {
         $include = TRUE;
         foreach ($excludePaths as $exclPath) {
             if (t3lib_div::isFirstPartOfStr($value, $exclPath)) {
                 $include = FALSE;
             }
         }
         $shortKey = t3lib_div::shortmd5($value);
         if ($include) {
             // First, allow "index.html", ".htaccess" files since they are often used for good reasons
             if (substr($value, -11) == '/index.html' || substr($value, -10) == '/.htaccess') {
                 unset($fileArr[$key]);
                 $resultArray['ignoredFiles'][$shortKey] = $value;
             } else {
                 // Looking for a reference from a field which is NOT a soft reference (thus, only fields with a proper TCA/Flexform configuration)
                 $recs = $TYPO3_DB->exec_SELECTgetRows('*', 'sys_refindex', 'ref_table=' . $TYPO3_DB->fullQuoteStr('_FILE', 'sys_refindex') . ' AND ref_string=' . $TYPO3_DB->fullQuoteStr($value, 'sys_refindex') . ' AND softref_key=' . $TYPO3_DB->fullQuoteStr('', 'sys_refindex'), '', 'sorting DESC');
                 // If found, unset entry:
                 if (count($recs)) {
                     unset($fileArr[$key]);
                     $resultArray['managedFiles'][$shortKey] = $value;
                     if (count($recs) > 1) {
                         $resultArray['warnings'][$shortKey] = 'Warning: File "' . $value . '" had ' . count($recs) . ' references from group-fields, should have only one!';
                     }
                 } else {
                     // When here it means the file was not found. So we test if it has a RTEmagic-image name and if so, we allow it:
                     if (preg_match('/^RTEmagic[P|C]_/', basename($value))) {
                         unset($fileArr[$key]);
                         $resultArray['RTEmagicFiles'][$shortKey] = $value;
                     } else {
                         // We conclude that the file is lost...:
                         unset($fileArr[$key]);
                         $resultArray['lostFiles'][$shortKey] = $value;
                     }
                 }
             }
         }
     }
     asort($resultArray['ignoredFiles']);
     asort($resultArray['managedFiles']);
     asort($resultArray['RTEmagicFiles']);
     asort($resultArray['lostFiles']);
     asort($resultArray['warnings']);
     // $fileArr variable should now be empty with all contents transferred to the result array keys.
     return $resultArray;
 }