public function setModeByFile($file)
 {
     $fileInfo = t3lib_div::split_fileref($file);
     switch ($fileInfo['fileext']) {
         case 'html':
         case 'htm':
         case 'tmpl':
             $mode = self::MODE_HTML;
             break;
         case 'js':
             $mode = self::MODE_JAVASCRIPT;
             break;
         case 'xml':
         case 'svg':
             $mode = self::MODE_XML;
             break;
         case 'css':
             $mode = self::MODE_CSS;
             break;
         case 'ts':
             $mode = self::MODE_TYPOSCRIPT;
             break;
         case 'php':
         case 'phpsh':
         case 'inc':
             $mode = self::MODE_PHP;
             break;
         default:
             $mode = self::MODE_MIXED;
     }
     $this->setMode($mode);
 }
 /**
  * collect all fileinformations of given file and
  * save them to the global fileinformation array
  *
  * @param string $file
  * @return boolean is valid file?
  */
 protected function setFileInformations($file)
 {
     $this->fileInfo = array();
     // reset previously information to have a cleaned object
     $this->file = $file instanceof \TYPO3\CMS\Core\Resource\File ? $file : NULL;
     if (is_string($file) && !empty($file)) {
         if (TYPO3_VERSION_INTEGER >= 7000000) {
             $this->fileInfo = TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($file);
         } else {
             $this->fileInfo = t3lib_div::split_fileref($file);
         }
         $this->fileInfo['mtime'] = filemtime($file);
         $this->fileInfo['atime'] = fileatime($file);
         $this->fileInfo['owner'] = fileowner($file);
         $this->fileInfo['group'] = filegroup($file);
         $this->fileInfo['size'] = filesize($file);
         $this->fileInfo['type'] = filetype($file);
         $this->fileInfo['perms'] = fileperms($file);
         $this->fileInfo['is_dir'] = is_dir($file);
         $this->fileInfo['is_file'] = is_file($file);
         $this->fileInfo['is_link'] = is_link($file);
         $this->fileInfo['is_readable'] = is_readable($file);
         $this->fileInfo['is_uploaded'] = is_uploaded_file($file);
         $this->fileInfo['is_writeable'] = is_writeable($file);
     }
     if ($file instanceof \TYPO3\CMS\Core\Resource\File) {
         $pathInfo = \TYPO3\CMS\Core\Utility\PathUtility::pathinfo($file->getName());
         $this->fileInfo = array('file' => $file->getName(), 'filebody' => $file->getNameWithoutExtension(), 'fileext' => $file->getExtension(), 'realFileext' => $pathInfo['extension'], 'atime' => $file->getCreationTime(), 'mtime' => $file->getModificationTime(), 'owner' => '', 'group' => '', 'size' => $file->getSize(), 'type' => 'file', 'perms' => '', 'is_dir' => FALSE, 'is_file' => $file->getStorage()->getDriverType() === 'Local' ? is_file($file->getForLocalProcessing(FALSE)) : TRUE, 'is_link' => $file->getStorage()->getDriverType() === 'Local' ? is_link($file->getForLocalProcessing(FALSE)) : FALSE, 'is_readable' => TRUE, 'is_uploaded' => FALSE, 'is_writeable' => FALSE);
     }
     return $this->fileInfo !== array();
 }
 /**
  * Manipulating the input array, $params, adding new selectorbox items.
  * 
  * @param	array	array of select field options (reference)
  * @param	object	parent object (reference)
  * @return	void
  */
 function main(&$params, &$pObj)
 {
     // get the current page ID
     $thePageId = $params['row']['pid'];
     $template = t3lib_div::makeInstance('t3lib_tsparser_ext');
     // do not log time-performance information
     $template->tt_track = 0;
     $template->init();
     $sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
     $rootLine = $sys_page->getRootLine($thePageId);
     // generate the constants/config + hierarchy info for the template.
     $template->runThroughTemplates($rootLine);
     $template->generateConfig();
     // get value for the path containing the template files
     $readPath = t3lib_div::getFileAbsFileName($template->setup['plugin.']['tx_ttaddress_pi1.']['templatePath']);
     // if that direcotry is valid and is a directory then select files in it
     if (@is_dir($readPath)) {
         $template_files = t3lib_div::getFilesInDir($readPath, 'tmpl,html,htm', 1, 1);
         $parseHTML = t3lib_div::makeInstance('t3lib_parseHTML');
         foreach ($template_files as $htmlFilePath) {
             // reset vars
             $selectorBoxItem_title = '';
             $selectorBoxItem_icon = '';
             // read template content
             $content = t3lib_div::getUrl($htmlFilePath);
             // ... and extract content of the title-tags
             $parts = $parseHTML->splitIntoBlock('title', $content);
             $titleTagContent = $parseHTML->removeFirstAndLastTag($parts[1]);
             // set the item label
             $selectorBoxItem_title = trim($titleTagContent . ' (' . basename($htmlFilePath) . ')');
             // try to look up an image icon for the template
             $fI = t3lib_div::split_fileref($htmlFilePath);
             $testImageFilename = $readPath . $fI['filebody'] . '.gif';
             if (@is_file($testImageFilename)) {
                 $selectorBoxItem_icon = '../' . substr($testImageFilename, strlen(PATH_site));
             }
             // finally add the new item
             $params['items'][] = array($selectorBoxItem_title, basename($htmlFilePath), $selectorBoxItem_icon);
         }
     }
 }
 /**
  * @param $fileref
  * @return array
  * @see t3lib_div::split_fileref
  */
 public function split_fileref($fileref)
 {
     /** @noinspection PhpDeprecationInspection PhpUndefinedClassInspection */
     return t3lib_div::split_fileref($fileref);
 }
 /**
  * get the mime type of a file with full path
  *
  * @param	string		$pathname absolute path to file
  * @return	array		file information
  */
 function getFileMimeType($pathname)
 {
     // this will be called from tx_dam therefore $pathname can be a fileInfo array
     $pathname = tx_dam::file_absolutePath($pathname);
     $TX_DAM = $GLOBALS['T3_VAR']['ext']['dam'];
     $mimeType = array();
     $mimeType['fulltype'] = '';
     $mimeType['file_mime_type'] = '';
     $mimeType['file_mime_subtype'] = '';
     $mimeType['file_type'] = '';
     $path_parts = t3lib_div::split_fileref($pathname);
     $mimeType['file_type'] = strtolower($path_parts['realFileext']);
     // cleanup bakup files extension
     $mimeType['file_type'] = preg_replace('#\\~$#', '', $mimeType['file_type']);
     $this->setup['useInternalMimeList'] = tx_dam::config_checkValueEnabled('setup.indexing.useInternalMimeList', true);
     $this->setup['useMimeContentType'] = tx_dam::config_checkValueEnabled('setup.indexing.useMimeContentType', true);
     $this->setup['useFileCommand'] = tx_dam::config_checkValueEnabled('setup.indexing.useFileCommand', true);
     // Get the mimetype info from the DB
     $file_type = tx_dam_db::getMediaExtension($mimeType['file_type']);
     // try first to get the mime type by extension with own array
     // I made the experience that it is a bit safer than with 'file'
     if ($this->setup['useInternalMimeList'] and $mimeType['file_type'] and isset($file_type['mime'])) {
         $mt = $file_type['mime'];
         if ($this->writeDevLog) {
             t3lib_div::devLog('getFileMimeType(): used builtin conversion table', 'tx_dam_indexing');
         }
         // next try
     } elseif ($this->setup['useMimeContentType'] and function_exists('mime_content_type')) {
         // available in PHP 4.3.0
         $mt = mime_content_type($pathname);
         if ($this->writeDevLog) {
             t3lib_div::devLog('getFileMimeType(): used mime_content_type()', 'tx_dam_indexing');
         }
     }
     // last chance
     if ($this->setup['useFileCommand'] and (!$mt or $mt === 'application/octet-stream')) {
         $osType = TYPO3_OS;
         if (!($osType === 'WIN')) {
             if ($cmd = t3lib_exec::getCommand('file')) {
                 $dummy = array();
                 $ret = false;
                 $mimeTypeTxt = trim(exec($cmd . ' --mime ' . escapeshellarg($pathname), $dummy, $ret));
                 if (!$ret and strstr($mimeTypeTxt, tx_dam::file_basename($pathname) . ':')) {
                     $a = explode(':', $mimeTypeTxt);
                     $a = explode(';', trim($a[1]));
                     //a[1]: text/plain, English; charset=iso-8859-1
                     $a = explode(',', trim($a[0]));
                     $a = explode(' ', trim($a[0]));
                     $mt = trim($a[0]);
                 }
             }
         }
         if ($this->writeDevLog) {
             t3lib_div::devLog('getFileMimeType(): used t3lib_exec::getCommand(\'file\')', 'tx_dam_indexing');
         }
     }
     $mtarr = explode('/', $mt);
     if (is_array($mtarr) && count($mtarr) == 2) {
         $mimeType['fulltype'] = $mt;
         $mimeType['file_mime_type'] = $mtarr[0];
         $mimeType['file_mime_subtype'] = $mtarr[1];
     }
     if ($mimeType['file_type'] == '') {
         $file_type = tx_dam_db::getMediaExtension('', $mimeType['fulltype']);
         $mimeType['file_type'] = $file_type['mime'];
     }
     if ($this->writeDevLog) {
         t3lib_div::devLog('getFileMimeType()', 'tx_dam_indexing', 0, $mimeType);
     }
     unset($mimeType['fulltype']);
     return $mimeType;
 }
 /**
  * Creates and returns a TypoScript "imgResource".
  * The value ($file) can either be a file reference (TypoScript resource) or the string "GIFBUILDER".
  * In the first case a current image is returned, possibly scaled down or otherwise processed.
  * In the latter case a GIFBUILDER image is returned; This means an image is made by TYPO3 from layers of elements as GIFBUILDER defines.
  * In the function IMG_RESOURCE() this function is called like $this->getImgResource($conf['file'],$conf['file.']);
  *
  * @param	string		A "imgResource" TypoScript data type. Either a TypoScript file resource or the string GIFBUILDER. See description above.
  * @param	array		TypoScript properties for the imgResource type
  * @return	array		Returns info-array. info[origFile] = original file.
  * @see IMG_RESOURCE(), cImage(), tslib_gifBuilder
  */
 function getImgResource($file, $fileArray)
 {
     if (is_array($fileArray)) {
         switch ($file) {
             case 'GIFBUILDER':
                 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
                 $gifCreator->init();
                 $theImage = '';
                 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
                     $gifCreator->start($fileArray, $this->data);
                     $theImage = $gifCreator->gifBuild();
                 }
                 $imageResource = $gifCreator->getImageDimensions($theImage);
                 break;
             default:
                 if ($fileArray['import.']) {
                     $ifile = $this->stdWrap('', $fileArray['import.']);
                     if ($ifile) {
                         $file = $fileArray['import'] . $ifile;
                     }
                 }
                 $theImage = $GLOBALS['TSFE']->tmpl->getFileName($file);
                 if ($theImage) {
                     $fileArray['width'] = isset($fileArray['width.']) ? $this->stdWrap($fileArray['width'], $fileArray['width.']) : $fileArray['width'];
                     $fileArray['height'] = isset($fileArray['height.']) ? $this->stdWrap($fileArray['height'], $fileArray['height.']) : $fileArray['height'];
                     $fileArray['ext'] = isset($fileArray['ext.']) ? $this->stdWrap($fileArray['ext'], $fileArray['ext.']) : $fileArray['ext'];
                     $fileArray['maxW'] = isset($fileArray['maxW.']) ? intval($this->stdWrap($fileArray['maxW'], $fileArray['maxW.'])) : intval($fileArray['maxW']);
                     $fileArray['maxH'] = isset($fileArray['maxH.']) ? intval($this->stdWrap($fileArray['maxH'], $fileArray['maxH.'])) : intval($fileArray['maxH']);
                     $fileArray['minW'] = isset($fileArray['minW.']) ? intval($this->stdWrap($fileArray['minW'], $fileArray['minW.'])) : intval($fileArray['minW']);
                     $fileArray['minH'] = isset($fileArray['minH.']) ? intval($this->stdWrap($fileArray['minH'], $fileArray['minH.'])) : intval($fileArray['minH']);
                     $fileArray['noScale'] = isset($fileArray['noScale.']) ? $this->stdWrap($fileArray['noScale'], $fileArray['noScale.']) : $fileArray['noScale'];
                     $maskArray = $fileArray['m.'];
                     $maskImages = array();
                     if (is_array($fileArray['m.'])) {
                         // Must render mask images and include in hash-calculating - else we cannot be sure the filename is unique for the setup!
                         $maskImages['m_mask'] = $this->getImgResource($maskArray['mask'], $maskArray['mask.']);
                         $maskImages['m_bgImg'] = $this->getImgResource($maskArray['bgImg'], $maskArray['bgImg.']);
                         $maskImages['m_bottomImg'] = $this->getImgResource($maskArray['bottomImg'], $maskArray['bottomImg.']);
                         $maskImages['m_bottomImg_mask'] = $this->getImgResource($maskArray['bottomImg_mask'], $maskArray['bottomImg_mask.']);
                     }
                     $hash = t3lib_div::shortMD5($theImage . serialize($fileArray) . serialize($maskImages));
                     if (!isset($GLOBALS['TSFE']->tmpl->fileCache[$hash])) {
                         $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
                         $gifCreator->init();
                         if ($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix']) {
                             $filename = basename($theImage);
                             // remove extension
                             $filename = substr($filename, 0, strrpos($filename, '.'));
                             // strip everything non-ascii
                             $filename = preg_replace('/[^A-Za-z0-9_-]/', '', trim($filename));
                             $gifCreator->filenamePrefix = substr($filename, 0, intval($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix'])) . '_';
                             unset($filename);
                         }
                         if ($fileArray['sample']) {
                             $gifCreator->scalecmd = '-sample';
                             $GLOBALS['TT']->setTSlogMessage('Sample option: Images are scaled with -sample.');
                         }
                         if ($fileArray['alternativeTempPath'] && t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['FE']['allowedTempPaths'], $fileArray['alternativeTempPath'])) {
                             $gifCreator->tempPath = $fileArray['alternativeTempPath'];
                             $GLOBALS['TT']->setTSlogMessage('Set alternativeTempPath: ' . $fileArray['alternativeTempPath']);
                         }
                         if (!trim($fileArray['ext'])) {
                             $fileArray['ext'] = 'web';
                         }
                         $options = array();
                         if ($fileArray['maxW']) {
                             $options['maxW'] = $fileArray['maxW'];
                         }
                         if ($fileArray['maxH']) {
                             $options['maxH'] = $fileArray['maxH'];
                         }
                         if ($fileArray['minW']) {
                             $options['minW'] = $fileArray['minW'];
                         }
                         if ($fileArray['minH']) {
                             $options['minH'] = $fileArray['minH'];
                         }
                         if ($fileArray['noScale']) {
                             $options['noScale'] = $fileArray['noScale'];
                         }
                         // checks to see if m (the mask array) is defined
                         if (is_array($maskArray) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
                             // Filename:
                             $fI = t3lib_div::split_fileref($theImage);
                             $imgExt = strtolower($fI['fileext']) == $gifCreator->gifExtension ? $gifCreator->gifExtension : 'jpg';
                             $dest = $gifCreator->tempPath . $hash . '.' . $imgExt;
                             if (!file_exists($dest)) {
                                 // Generate!
                                 $m_mask = $maskImages['m_mask'];
                                 $m_bgImg = $maskImages['m_bgImg'];
                                 if ($m_mask && $m_bgImg) {
                                     $negate = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ? ' -negate' : '';
                                     $temp_ext = 'png';
                                     if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif']) {
                                         // If ImageMagick version 5+
                                         $temp_ext = $gifCreator->gifExtension;
                                     }
                                     $tempFileInfo = $gifCreator->imageMagickConvert($theImage, $temp_ext, $fileArray['width'], $fileArray['height'], $fileArray['params'], $fileArray['frame'], $options);
                                     if (is_array($tempFileInfo)) {
                                         $m_bottomImg = $maskImages['m_bottomImg'];
                                         if ($m_bottomImg) {
                                             $m_bottomImg_mask = $maskImages['m_bottomImg_mask'];
                                         }
                                         //	Scaling:	****
                                         $tempScale = array();
                                         $command = '-geometry ' . $tempFileInfo[0] . 'x' . $tempFileInfo[1] . '!';
                                         $command = $this->modifyImageMagickStripProfileParameters($command, $fileArray);
                                         $tmpStr = $gifCreator->randomName();
                                         //	m_mask
                                         $tempScale['m_mask'] = $tmpStr . '_mask.' . $temp_ext;
                                         $gifCreator->imageMagickExec($m_mask[3], $tempScale['m_mask'], $command . $negate);
                                         //	m_bgImg
                                         $tempScale['m_bgImg'] = $tmpStr . '_bgImg.' . trim($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_noloss']);
                                         $gifCreator->imageMagickExec($m_bgImg[3], $tempScale['m_bgImg'], $command);
                                         //	m_bottomImg / m_bottomImg_mask
                                         if ($m_bottomImg && $m_bottomImg_mask) {
                                             $tempScale['m_bottomImg'] = $tmpStr . '_bottomImg.' . $temp_ext;
                                             $gifCreator->imageMagickExec($m_bottomImg[3], $tempScale['m_bottomImg'], $command);
                                             $tempScale['m_bottomImg_mask'] = $tmpStr . '_bottomImg_mask.' . $temp_ext;
                                             $gifCreator->imageMagickExec($m_bottomImg_mask[3], $tempScale['m_bottomImg_mask'], $command . $negate);
                                             // BEGIN combining:
                                             // The image onto the background
                                             $gifCreator->combineExec($tempScale['m_bgImg'], $tempScale['m_bottomImg'], $tempScale['m_bottomImg_mask'], $tempScale['m_bgImg']);
                                         }
                                         // The image onto the background
                                         $gifCreator->combineExec($tempScale['m_bgImg'], $tempFileInfo[3], $tempScale['m_mask'], $dest);
                                         // Unlink the temp-images...
                                         foreach ($tempScale as $file) {
                                             if (@is_file($file)) {
                                                 unlink($file);
                                             }
                                         }
                                     }
                                 }
                             }
                             // Finish off
                             if (($fileArray['reduceColors'] || $imgExt == 'png' && !$gifCreator->png_truecolor) && is_file($dest)) {
                                 $reduced = $gifCreator->IMreduceColors($dest, t3lib_div::intInRange($fileArray['reduceColors'], 256, $gifCreator->truecolorColors, 256));
                                 if (is_file($reduced)) {
                                     unlink($dest);
                                     rename($reduced, $dest);
                                 }
                             }
                             $GLOBALS['TSFE']->tmpl->fileCache[$hash] = $gifCreator->getImageDimensions($dest);
                         } else {
                             // Normal situation:
                             $fileArray['params'] = $this->modifyImageMagickStripProfileParameters($fileArray['params'], $fileArray);
                             $GLOBALS['TSFE']->tmpl->fileCache[$hash] = $gifCreator->imageMagickConvert($theImage, $fileArray['ext'], $fileArray['width'], $fileArray['height'], $fileArray['params'], $fileArray['frame'], $options);
                             if (($fileArray['reduceColors'] || $imgExt == 'png' && !$gifCreator->png_truecolor) && is_file($GLOBALS['TSFE']->tmpl->fileCache[$hash][3])) {
                                 $reduced = $gifCreator->IMreduceColors($GLOBALS['TSFE']->tmpl->fileCache[$hash][3], t3lib_div::intInRange($fileArray['reduceColors'], 256, $gifCreator->truecolorColors, 256));
                                 if (is_file($reduced)) {
                                     unlink($GLOBALS['TSFE']->tmpl->fileCache[$hash][3]);
                                     rename($reduced, $GLOBALS['TSFE']->tmpl->fileCache[$hash][3]);
                                 }
                             }
                         }
                         $GLOBALS['TSFE']->tmpl->fileCache[$hash]['origFile'] = $theImage;
                         $GLOBALS['TSFE']->tmpl->fileCache[$hash]['origFile_mtime'] = @filemtime($theImage);
                         // This is needed by tslib_gifbuilder, ln 100ff in order for the setup-array to create a unique filename hash.
                         $GLOBALS['TSFE']->tmpl->fileCache[$hash]['fileCacheHash'] = $hash;
                     }
                     $imageResource = $GLOBALS['TSFE']->tmpl->fileCache[$hash];
                 }
                 break;
         }
     }
     $theImage = $GLOBALS['TSFE']->tmpl->getFileName($file);
     // If image was processed by GIFBUILDER:
     // ($imageResource indicates that it was processed the regular way)
     if (!isset($imageResource) && $theImage) {
         $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
         /* @var $gifCreator tslib_gifbuilder */
         $gifCreator->init();
         $info = $gifCreator->imageMagickConvert($theImage, 'WEB', '', '', '', '', '');
         $info['origFile'] = $theImage;
         $info['origFile_mtime'] = @filemtime($theImage);
         // This is needed by tslib_gifbuilder, ln 100ff in order for the setup-array to create a unique filename hash.
         $imageResource = $info;
     }
     // Hook 'getImgResource': Post-processing of image resources
     if (isset($imageResource)) {
         foreach ($this->getGetImgResourceHookObjects() as $hookObject) {
             $imageResource = $hookObject->getImgResourcePostProcess($file, (array) $fileArray, $imageResource, $this);
         }
     }
     return $imageResource;
 }
    /**
     * Render list of files.
     *
     * @param	array		List of folder. See $this->getFolderInDir()
     * @param	string		If set a header with a folder icon and folder name are shown
     * @param	boolean		Whether to show thumbnails or not. If set, no thumbnails are shown.
     * @return	string		HTML output
     */
    function folderList($folder, $folderName = '', $noThumbs = 0)
    {
        global $LANG, $BACK_PATH;
        $out = '';
        // Listing the files:
        if (is_array($folder)) {
            // Create headline (showing number of files):
            $out .= $this->barheader(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:file_newfolder.php.folders') . ' (%s):', count($folder)));
            $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
            $folderIcon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"');
            // todo: use modes?
            #			 $fileadminDir = PATH_site.$GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'];
            $fcount = count($folder);
            $folder = array_merge(array(md5($folderName) => $folderName), $folder);
            // Traverse the file list:
            $lines = array();
            foreach ($folder as $filepath) {
                $path_parts = t3lib_div::split_fileref($filepath);
                # $shortFilepath = preg_replace('#^'.preg_quote($fileadminDir).'#','', $filepath);
                $shortFilepath = preg_replace('#^' . preg_quote(PATH_site) . '#', '', $filepath);
                if (count($lines) == 0) {
                    $treeLine = '';
                } elseif (count($lines) < $fcount) {
                    $LN = 'join';
                    $treeLine = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/ol/' . $LN . '.gif', 'width="18" height="16"') . ' alt="" />';
                } else {
                    $LN = 'joinbottom';
                    $treeLine = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/ol/' . $LN . '.gif', 'width="18" height="16"') . ' alt="" />';
                }
                // Create folder icon:
                $icon = $folderIcon . ' title="' . htmlspecialchars($path_parts['file']) . '" class="absmiddle" alt="" />';
                // Create links for adding the file:
                if (strstr($filepath, ',') || strstr($filepath, '|')) {
                    // In case an invalid character is in the filepath, display error message:
                    $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'), ', |'));
                    $ATag = $ATag_alt = "<a href=\"#\" onclick=\"alert(" . $eMsg . ");return false;\">";
                } else {
                    // If filename is OK, just add it:
                    $ATag = "<a href=\"#\" onclick=\"return insertElement('','" . t3lib_div::shortMD5($filepath) . "', 'file', '" . rawurlencode($shortFilepath) . "', unescape('" . rawurlencode($shortFilepath) . "'), '" . '' . "', '" . '' . "');\">";
                    $ATag_alt = substr($ATag, 0, -4) . ",'',1);\">";
                }
                $ATag_e = '</a>';
                // Combine the stuff:
                $filenameAndIcon = $ATag_alt . $icon . htmlspecialchars(t3lib_div::fixed_lgd_cs($path_parts['file'], $titleLen)) . $ATag_e;
                $lines[] = '
					<tr class="bgColor4">
						<td nowrap="nowrap">' . $treeLine . $filenameAndIcon . '&nbsp;</td>
						<td>' . $ATag . '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $LANG->getLL('addToList', 1) . '" alt="" />' . $ATag_e . '</td>
					</tr>';
            }
            // Wrap all the rows in table tags:
            $out .= '



		<!--
			File listing
		-->
				<table border="0" cellpadding="0" cellspacing="1" id="typo3-fileList">
					' . implode('', $lines) . '
				</table>';
        }
        // Return accumulated content for filelisting:
        return $out;
    }
	/**
	 * Parse speaking URL and translate it to parameters understood by TYPO3
	 * Function is called from tslib_fe
	 * The overall format of a speaking URL is these five parts [TYPO3_SITE_URL] / [pre-var] / [page-identification] / [post-vars] / [file.ext]
	 * - "TYPO3_SITE_URL" is fixed value from the environment,
	 * - "pre-var" is any number of segments separated by "/" mapping to GETvars AND with a known lenght,
	 * - "page-identification" identifies the page id in TYPO3 possibly with multiple segments separated by "/" BUT with an UNKNOWN length,
	 * - "post-vars" is sets of segments offering the same features as "pre-var"
	 * - "file.ext" is any filename that might apply
	 *
	 * @param	array		Params for hook
	 * @return	void		Setting internal variables.
	 */
	public function decodeSpURL($params) {

		$this->devLog('Entering decodeSpURL');

		// Setting parent object reference (which is $GLOBALS['TSFE'])
		$this->pObj = &$params['pObj'];

		// Initializing config / request URL:
		$this->setConfig();
		$this->adjustConfigurationByHost('decode');
		$this->adjustRootPageId();

		// If there has been a redirect (basically; we arrived here otherwise than via "index.php" in the URL) this can happend either due to a CGI-script or because of reWrite rule. Earlier we used $GLOBALS['HTTP_SERVER_VARS']['REDIRECT_URL'] to check but...
		if ($this->pObj->siteScript && substr($this->pObj->siteScript, 0, 9) != 'index.php' && substr($this->pObj->siteScript, 0, 1) != '?') {

			// Getting the path which is above the current site url:
			// For instance "first/second/third/index.html?&param1=value1&param2=value2"
			// should be the result of the URL
			// "http://localhost/typo3/dev/dummy_1/first/second/third/index.html?&param1=value1&param2=value2"
			// Note: sometimes in fcgi installations it is absolute, so we have to make it
			// relative to work properly.
			$speakingURIpath = $this->pObj->siteScript{0} == '/' ? substr($this->pObj->siteScript, 1) : $this->pObj->siteScript;

			// Call hooks
			if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['decodeSpURL_preProc'])) {
				foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['decodeSpURL_preProc'] as $userFunc) {
					$hookParams = array(
						'pObj' => &$this,
						'params' => $params,
						'URL' => &$speakingURIpath,
					);
					t3lib_div::callUserFunction($userFunc, $hookParams, $this);
				}
			}

			// Append missing slash if configured for:
			if ($this->extConf['init']['appendMissingSlash']) {
				$regexp = '~^([^\?]*[^/])(\?.*)?$~';
				if (substr($speakingURIpath, -1, 1) == '?') {
					$speakingURIpath = substr($speakingURIpath, 0, -1);
				}
				if (preg_match($regexp, $speakingURIpath)) { // Only process if a slash is missing:
					$options = t3lib_div::trimExplode(',', $this->extConf['init']['appendMissingSlash'], true);
					if (in_array('ifNotFile', $options)) {
						if (!preg_match('/\/[^\/\?]+\.[^\/]+(\?.*)?$/', '/' . $speakingURIpath)) {
							$speakingURIpath = preg_replace($regexp, '\1/\2', $speakingURIpath);
							$this->appendedSlash = true;
						}
					}
					else {
						$speakingURIpath = preg_replace($regexp, '\1/\2', $speakingURIpath);
						$this->appendedSlash = true;
					}
					if ($this->appendedSlash && count($options) > 0) {
						foreach ($options as $option) {
							$matches = array();
							if (preg_match('/^redirect(\[(30[1237])\])?$/', $option, $matches)) {
								$code = count($matches) > 1 ? $matches[2] : 301;
								$status = 'HTTP/1.0 ' . $code . ' TYPO3 RealURL redirect';

								// Check path segment to be relative for the current site.
								// parse_url() does not work with relative URLs, so we use it to test
								if (!@parse_url($speakingURIpath, PHP_URL_HOST)) {
									@ob_end_clean();
									header($status);
									header('Location: ' . t3lib_div::locationHeaderUrl($speakingURIpath));
									exit;
								}
							}
						}
					}
				}
			}

			// If the URL is a single script like "123.1.html" it might be an "old" simulateStaticDocument request. If this is the case and support for this is configured, do NOT try and resolve it as a Speaking URL
			$fI = t3lib_div::split_fileref($speakingURIpath);
			if (!self::testInt($this->pObj->id) && $fI['path'] == '' && $this->extConf['fileName']['defaultToHTMLsuffixOnPrev'] && $this->extConf['init']['respectSimulateStaticURLs']) {
				// If page ID does not exist yet and page is on the root level and both
				// respectSimulateStaticURLs and defaultToHTMLsuffixOnPrev are set, than
				// ignore respectSimulateStaticURLs and attempt to resolve page id.
				// See http://bugs.typo3.org/view.php?id=1530
				$GLOBALS['TT']->setTSlogMessage('decodeSpURL: ignoring respectSimulateStaticURLs due defaultToHTMLsuffixOnPrev for the root level page!)', 2);
				$this->extConf['init']['respectSimulateStaticURLs'] = false;
			}
			if (!$this->extConf['init']['respectSimulateStaticURLs'] || $fI['path']) {
				$this->devLog('RealURL powered decoding (TM) starting!');

				// Parse path:
				$uParts = @parse_url($speakingURIpath);
				if (!is_array($uParts)) {
					$this->decodeSpURL_throw404('Current URL is invalid');
				}
				$speakingURIpath = $this->speakingURIpath_procValue = $uParts['path'];

				// Redirecting if needed (exits if so).
				$this->decodeSpURL_checkRedirects($speakingURIpath);

				// Looking for cached information:
				$cachedInfo = $this->decodeSpURL_decodeCache($speakingURIpath);

				// If no cached info was found, create it:
				if (!is_array($cachedInfo)) {
					// Decode URL:
					$cachedInfo = $this->decodeSpURL_doDecode($speakingURIpath, $this->extConf['init']['enableCHashCache']);

					// Storing cached information:
					$this->decodeSpURL_decodeCache($speakingURIpath, $cachedInfo);
				}

				// Re-create QUERY_STRING from Get vars for use with typoLink()
				$_SERVER['QUERY_STRING'] = $this->decodeSpURL_createQueryString($cachedInfo['GET_VARS']);

				// Jump-admin if configured:
				$this->decodeSpURL_jumpAdmin_goBackend($cachedInfo['id']);

				// Setting info in TSFE:
				$this->pObj->mergingWithGetVars($cachedInfo['GET_VARS']);
				$this->pObj->id = $cachedInfo['id'];

				if ($this->mimeType) {
					header('Content-type: ' . $this->mimeType);
					$this->mimeType = null;
				}
			}
		}
	}
示例#9
0
 function _renderReadOnly()
 {
     $sPath = $this->_getPath();
     if ($sPath !== FALSE || is_array($this->_navConf("/imageconf/")) && $this->defaultFalse("/imageconf/forcegeneration")) {
         $sTag = FALSE;
         $aSize = FALSE;
         $bExternal = FALSE;
         $bReprocess = FALSE;
         if (is_array($mConf = $this->_navConf("/imageconf/")) && tx_ameosformidable::isRunneable($mConf)) {
             $bReprocess = TRUE;
         }
         if ($this->oForm->isAbsServerPath($sPath)) {
             $sAbsServerPath = $sPath;
             $sRelWebPath = $this->oForm->_removeStartingSlash($this->oForm->toRelPath($sAbsServerPath));
             $sAbsWebPath = $this->oForm->toWebPath($sRelWebPath);
             $sFileName = basename($sRelWebPath);
             $aSize = @getImageSize($sAbsServerPath);
         } else {
             if (!$this->oForm->isAbsWebPath($sPath)) {
                 // relative web path given
                 // turn it into absolute web path
                 $sPath = $this->oForm->toWebPath($sPath);
                 $aSize = @getImageSize($this->oForm->toServerPath($sPath));
             }
             // absolute web path
             $sAbsWebPath = $sPath;
             $aInfosPath = parse_url($sAbsWebPath);
             $aInfosFile = t3lib_div::split_fileref($sAbsWebPath);
             #debug($aInfosPath);
             #debug($aInfosFile);
             if (strtolower($aInfosPath["host"]) !== strtolower(t3lib_div::getIndpEnv("TYPO3_HOST_ONLY"))) {
                 // it's an external image
                 $bExternal = TRUE;
                 $sAbsServerPath = "";
                 if ($bReprocess === TRUE) {
                     // we have to make a local copy of the image to enable TS processing
                     $aHeaders = $this->oForm->div_getHeadersForUrl($sAbsWebPath);
                     if (array_key_exists("ETag", $aHeaders)) {
                         $sSignature = str_replace(array('"', ",", ":", "-", ".", "/", "\\", " "), "", $aHeaders["ETag"]);
                     } elseif (array_key_exists("Last-Modified", $aHeaders)) {
                         $sSignature = str_replace(array('"', ",", ":", "-", ".", "/", "\\", " "), "", $aHeaders["Last-Modified"]);
                     } elseif (array_key_exists("Content-Length", $aHeaders)) {
                         $sSignature = $aHeaders["Content-Length"];
                     }
                 }
                 $sTempFileName = $aInfosFile["filebody"] . $aInfosFile["fileext"] . "-" . $sSignature . "." . $aInfosFile["fileext"];
                 $sTempFilePath = PATH_site . "typo3temp/" . $sTempFileName;
                 if (!file_exists($sTempFilePath)) {
                     t3lib_div::writeFileToTypo3tempDir($sTempFilePath, t3lib_div::getUrl($sAbsWebPath));
                 }
                 $sAbsServerPath = $sTempFilePath;
                 $sAbsWebPath = $this->oForm->toWebPath($sAbsServerPath);
                 $sRelWebPath = $this->oForm->toRelPath($sAbsServerPath);
             } else {
                 // it's an local image given as an absolute web url
                 // trying to convert pathes to handle the image as a local one
                 $sAbsServerPath = PATH_site . $this->oForm->_removeStartingSlash($aInfosPath["path"]);
                 $sRelWebPath = $this->oForm->_removeStartingSlash($aInfosPath["path"]);
             }
             $sFileName = $aInfosFile["file"];
         }
         $sRelWebPath = $this->oForm->_removeStartingslash($sRelWebPath);
         $sContentAlt = '';
         if (($mAlt = $this->_navConf("/alt")) !== FALSE) {
             if (tx_ameosformidable::isRunneable($mAlt)) {
                 $mAlt = $this->callRunneable($mAlt);
             }
             $sContentAlt = $mAlt;
         }
         $sAlt = trim($sContentAlt) == '' ? '' : 'alt="' . $sContentAlt . '"';
         $aHtmlBag = array("filepath" => $sAbsWebPath, "filepath." => array("rel" => $sRelWebPath, "web" => $this->oForm->toWebPath($this->oForm->toServerPath($sRelWebPath)), "original" => $sAbsWebPath, "original." => array("rel" => $sRelWebPath, "web" => $this->oForm->toWebPath($sAbsServerPath), "server" => $sAbsServerPath)), "filename" => $sFileName, "filename." => array("original" => $sFileName), "alt" => $sContentAlt);
         if ($aSize !== FALSE) {
             $aHtmlBag["filesize."]["width"] = $aSize[0];
             $aHtmlBag["filesize."]["width."]["px"] = $aSize[0] . "px";
             $aHtmlBag["filesize."]["height"] = $aSize[1];
             $aHtmlBag["filesize."]["height."]["px"] = $aSize[1] . "px";
         }
         if ($bReprocess === TRUE) {
             //			require_once(PATH_t3lib . "class.t3lib_stdgraphic.php");
             //			require_once(PATH_tslib . "class.tslib_gifbuilder.php");
             // expecting typoscript
             $aParams = array("filename" => $sFileName, "abswebpath" => $sAbsWebPath, "relwebpath" => $sRelWebPath);
             if ($this->oForm->oDataHandler->aObjectType["TYPE"] == "LISTER") {
                 $aParams["row"] = $this->oForm->oDataHandler->__aListData;
             } elseif ($this->oForm->oDataHandler->aObjectType["TYPE"] == "DB") {
                 $aParams["row"] = $this->oForm->oDataHandler->_getStoredData();
             }
             $this->callRunneable($mConf, $aParams);
             $aImage = array_pop($this->oForm->aLastTs);
             if ($this->defaultFalse("/imageconf/generatetag") === TRUE) {
                 $sTag = $GLOBALS["TSFE"]->cObj->IMAGE($aImage);
             } else {
                 $sTag = FALSE;
             }
             $sNewPath = $GLOBALS["TSFE"]->cObj->IMG_RESOURCE($aImage);
             // IMG_RESOURCE always returns relative path
             $aHtmlBag["filepath"] = $this->oForm->toWebPath($sNewPath);
             $aHtmlBag["filepath."]["rel"] = $sNewPath;
             $aHtmlBag["filepath."]["web"] = $this->oForm->toWebPath($this->oForm->toServerPath($sNewPath));
             $aHtmlBag["filename"] = basename($sNewPath);
             $aNewSize = @getImageSize($this->oForm->toServerPath($sNewPath));
             $aHtmlBag["filesize."]["width"] = $aNewSize[0];
             $aHtmlBag["filesize."]["width."]["px"] = $aNewSize[0] . "px";
             $aHtmlBag["filesize."]["height"] = $aNewSize[1];
             $aHtmlBag["filesize."]["height."]["px"] = $aNewSize[1] . "px";
         }
         $sLabel = $this->getLabel();
         if ($sTag === FALSE) {
             if (isset($aHtmlBag["filesize."]["width"])) {
                 $sWidth = " width='" . $aHtmlBag["filesize."]["width"] . "' ";
             }
             if (isset($aHtmlBag["filesize."]["height"])) {
                 $sHeight = " height='" . $aHtmlBag["filesize."]["height"] . "' ";
             }
             $aHtmlBag["imagetag"] = "<img src=\"" . $aHtmlBag["filepath"] . "\" id=\"" . $this->_getElementHtmlId() . "\" " . $this->_getAddInputParams() . " " . $sWidth . $sHeight . $sAlt . "/>";
             #print_r($aHtmlBag["imagetag"]);
         } else {
             $aHtmlBag["imagetag"] = $sTag;
         }
         $aHtmlBag["__compiled"] = $this->_displayLabel($sLabel) . $aHtmlBag["imagetag"];
         return $aHtmlBag;
     }
     return "";
 }
 /**
  * Handling files for group/select function
  *
  * @param	array		Array of incoming file references. Keys are numeric, values are files (basically, this is the exploded list of incoming files)
  * @param	array		Configuration array from TCA of the field
  * @param	string		Current value of the field
  * @param	array		Array of uploaded files, if any
  * @param	string		Status ("update" or ?)
  * @param	string		tablename of record
  * @param	integer		UID of record
  * @param	string		Field identifier ([table:uid:field:....more for flexforms?]
  * @return	array		Modified value array
  * @see checkValue_group_select()
  */
 function checkValue_group_select_file($valueArray, $tcaFieldConf, $curValue, $uploadedFileArray, $status, $table, $id, $recFID)
 {
     if (!$this->bypassFileHandling) {
         // If filehandling should NOT be bypassed, do processing:
         // If any files are uploaded, add them to value array
         if (is_array($uploadedFileArray) && $uploadedFileArray['name'] && strcmp($uploadedFileArray['tmp_name'], 'none')) {
             $valueArray[] = $uploadedFileArray['tmp_name'];
             $this->alternativeFileName[$uploadedFileArray['tmp_name']] = $uploadedFileArray['name'];
         }
         // Creating fileFunc object.
         if (!$this->fileFunc) {
             $this->fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
             $this->include_filefunctions = 1;
         }
         // Setting permitted extensions.
         $all_files = array();
         $all_files['webspace']['allow'] = $tcaFieldConf['allowed'];
         $all_files['webspace']['deny'] = $tcaFieldConf['disallowed'] ? $tcaFieldConf['disallowed'] : '*';
         $all_files['ftpspace'] = $all_files['webspace'];
         $this->fileFunc->init('', $all_files);
     }
     // If there is an upload folder defined:
     if ($tcaFieldConf['uploadfolder'] && $tcaFieldConf['internal_type'] == 'file') {
         if (!$this->bypassFileHandling) {
             // If filehandling should NOT be bypassed, do processing:
             // For logging..
             $propArr = $this->getRecordProperties($table, $id);
             // Get destrination path:
             $dest = $this->destPathFromUploadFolder($tcaFieldConf['uploadfolder']);
             // If we are updating:
             if ($status == 'update') {
                 // Traverse the input values and convert to absolute filenames in case the update happens to an autoVersionized record.
                 // Background: This is a horrible workaround! The problem is that when a record is auto-versionized the files of the record get copied and therefore get new names which is overridden with the names from the original record in the incoming data meaning both lost files and double-references!
                 // The only solution I could come up with (except removing support for managing files when autoversioning) was to convert all relative files to absolute names so they are copied again (and existing files deleted). This should keep references intact but means that some files are copied, then deleted after being copied _again_.
                 // Actually, the same problem applies to database references in case auto-versioning would include sub-records since in such a case references are remapped - and they would be overridden due to the same principle then.
                 // Illustration of the problem comes here:
                 // We have a record 123 with a file logo.gif. We open and edit the files header in a workspace. So a new version is automatically made.
                 // The versions uid is 456 and the file is copied to "logo_01.gif". But the form data that we sent was based on uid 123 and hence contains the filename "logo.gif" from the original.
                 // The file management code below will do two things: First it will blindly accept "logo.gif" as a file attached to the record (thus creating a double reference) and secondly it will find that "logo_01.gif" was not in the incoming filelist and therefore should be deleted.
                 // If we prefix the incoming file "logo.gif" with its absolute path it will be seen as a new file added. Thus it will be copied to "logo_02.gif". "logo_01.gif" will still be deleted but since the files are the same the difference is zero - only more processing and file copying for no reason. But it will work.
                 if ($this->autoVersioningUpdate === TRUE) {
                     foreach ($valueArray as $key => $theFile) {
                         if ($theFile === basename($theFile)) {
                             // If it is an already attached file...
                             $valueArray[$key] = PATH_site . $tcaFieldConf['uploadfolder'] . '/' . $theFile;
                         }
                     }
                 }
                 // Finding the CURRENT files listed, either from MM or from the current record.
                 $theFileValues = array();
                 if ($tcaFieldConf['MM']) {
                     // If MM relations for the files also!
                     $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
                     /* @var $dbAnalysis t3lib_loadDBGroup */
                     $dbAnalysis->start('', 'files', $tcaFieldConf['MM'], $id);
                     foreach ($dbAnalysis->itemArray as $item) {
                         if ($item['id']) {
                             $theFileValues[] = $item['id'];
                         }
                     }
                 } else {
                     $theFileValues = t3lib_div::trimExplode(',', $curValue, 1);
                 }
                 $currentFilesForHistory = implode(',', $theFileValues);
                 // DELETE files: If existing files were found, traverse those and register files for deletion which has been removed:
                 if (count($theFileValues)) {
                     // Traverse the input values and for all input values which match an EXISTING value, remove the existing from $theFileValues array (this will result in an array of all the existing files which should be deleted!)
                     foreach ($valueArray as $key => $theFile) {
                         if ($theFile && !strstr(t3lib_div::fixWindowsFilePath($theFile), '/')) {
                             $theFileValues = t3lib_div::removeArrayEntryByValue($theFileValues, $theFile);
                         }
                     }
                     // This array contains the filenames in the uploadfolder that should be deleted:
                     foreach ($theFileValues as $key => $theFile) {
                         $theFile = trim($theFile);
                         if (@is_file($dest . '/' . $theFile)) {
                             $this->removeFilesStore[] = $dest . '/' . $theFile;
                         } elseif ($theFile) {
                             $this->log($table, $id, 5, 0, 1, "Could not delete file '%s' (does not exist). (%s)", 10, array($dest . '/' . $theFile, $recFID), $propArr['event_pid']);
                         }
                     }
                 }
             }
             // Traverse the submitted values:
             foreach ($valueArray as $key => $theFile) {
                 // NEW FILES? If the value contains '/' it indicates, that the file is new and should be added to the uploadsdir (whether its absolute or relative does not matter here)
                 if (strstr(t3lib_div::fixWindowsFilePath($theFile), '/')) {
                     // Init:
                     $maxSize = intval($tcaFieldConf['max_size']);
                     $cmd = '';
                     $theDestFile = '';
                     // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
                     // Check various things before copying file:
                     if (@is_dir($dest) && (@is_file($theFile) || @is_uploaded_file($theFile))) {
                         // File and destination must exist
                         // Finding size. For safe_mode we have to rely on the size in the upload array if the file is uploaded.
                         if (is_uploaded_file($theFile) && $theFile == $uploadedFileArray['tmp_name']) {
                             $fileSize = $uploadedFileArray['size'];
                         } else {
                             $fileSize = filesize($theFile);
                         }
                         if (!$maxSize || $fileSize <= $maxSize * 1024) {
                             // Check file size:
                             // Prepare filename:
                             $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
                             $fI = t3lib_div::split_fileref($theEndFileName);
                             // Check for allowed extension:
                             if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
                                 $theDestFile = $this->fileFunc->getUniqueName($this->fileFunc->cleanFileName($fI['file']), $dest);
                                 // If we have a unique destination filename, then write the file:
                                 if ($theDestFile) {
                                     t3lib_div::upload_copy_move($theFile, $theDestFile);
                                     // Hook for post-processing the upload action
                                     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processUpload'])) {
                                         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processUpload'] as $classRef) {
                                             $hookObject = t3lib_div::getUserObj($classRef);
                                             if (!$hookObject instanceof t3lib_TCEmain_processUploadHook) {
                                                 throw new UnexpectedValueException('$hookObject must implement interface t3lib_TCEmain_processUploadHook', 1279962349);
                                             }
                                             $hookObject->processUpload_postProcessAction($theDestFile, $this);
                                         }
                                     }
                                     $this->copiedFileMap[$theFile] = $theDestFile;
                                     clearstatcache();
                                     if (!@is_file($theDestFile)) {
                                         $this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)", 16, array($theFile, dirname($theDestFile), $recFID), $propArr['event_pid']);
                                     }
                                 } else {
                                     $this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: No destination file (%s) possible!. (%s)", 11, array($theFile, $theDestFile, $recFID), $propArr['event_pid']);
                                 }
                             } else {
                                 $this->log($table, $id, 5, 0, 1, "File extension '%s' not allowed. (%s)", 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
                             }
                         } else {
                             $this->log($table, $id, 5, 0, 1, "Filesize (%s) of file '%s' exceeds limit (%s). (%s)", 13, array(t3lib_div::formatSize($fileSize), $theFile, t3lib_div::formatSize($maxSize * 1024), $recFID), $propArr['event_pid']);
                         }
                     } else {
                         $this->log($table, $id, 5, 0, 1, 'The destination (%s) or the source file (%s) does not exist. (%s)', 14, array($dest, $theFile, $recFID), $propArr['event_pid']);
                     }
                     // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
                     if (@is_file($theDestFile)) {
                         $info = t3lib_div::split_fileref($theDestFile);
                         $valueArray[$key] = $info['file'];
                         // The value is set to the new filename
                     } else {
                         unset($valueArray[$key]);
                         // The value is set to the new filename
                     }
                 }
             }
         }
         // If MM relations for the files, we will set the relations as MM records and change the valuearray to contain a single entry with a count of the number of files!
         if ($tcaFieldConf['MM']) {
             $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
             /* @var $dbAnalysis t3lib_loadDBGroup */
             $dbAnalysis->tableArray['files'] = array();
             // dummy
             foreach ($valueArray as $key => $theFile) {
                 // explode files
                 $dbAnalysis->itemArray[]['id'] = $theFile;
             }
             if ($status == 'update') {
                 $dbAnalysis->writeMM($tcaFieldConf['MM'], $id, 0);
                 $newFiles = implode(',', $dbAnalysis->getValueArray());
                 list(, , $recFieldName) = explode(':', $recFID);
                 if ($currentFilesForHistory != $newFiles) {
                     $this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$recFieldName] = $currentFilesForHistory;
                     $this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$recFieldName] = $newFiles;
                 } else {
                     $this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$recFieldName] = '';
                     $this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$recFieldName] = '';
                 }
             } else {
                 $this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf['MM'], $id, 0);
                 // This will be traversed later to execute the actions
             }
             $valueArray = $dbAnalysis->countItems();
         }
         //store path relative to site root (if uploadfolder is not set or internal_type is file_reference)
     } else {
         if (count($valueArray)) {
             if (!$this->bypassFileHandling) {
                 // If filehandling should NOT be bypassed, do processing:
                 $propArr = $this->getRecordProperties($table, $id);
                 // For logging..
                 foreach ($valueArray as &$theFile) {
                     // if alernative File Path is set for the file, then it was an import
                     if ($this->alternativeFilePath[$theFile]) {
                         // don't import the file if it already exists
                         if (@is_file(PATH_site . $this->alternativeFilePath[$theFile])) {
                             $theFile = PATH_site . $this->alternativeFilePath[$theFile];
                             // import the file
                         } elseif (@is_file($theFile)) {
                             $dest = dirname(PATH_site . $this->alternativeFilePath[$theFile]);
                             if (!@is_dir($dest)) {
                                 t3lib_div::mkdir_deep(PATH_site, dirname($this->alternativeFilePath[$theFile]) . '/');
                             }
                             // Init:
                             $maxSize = intval($tcaFieldConf['max_size']);
                             $cmd = '';
                             $theDestFile = '';
                             // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
                             $fileSize = filesize($theFile);
                             if (!$maxSize || $fileSize <= $maxSize * 1024) {
                                 // Check file size:
                                 // Prepare filename:
                                 $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
                                 $fI = t3lib_div::split_fileref($theEndFileName);
                                 // Check for allowed extension:
                                 if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
                                     $theDestFile = PATH_site . $this->alternativeFilePath[$theFile];
                                     // Write the file:
                                     if ($theDestFile) {
                                         t3lib_div::upload_copy_move($theFile, $theDestFile);
                                         $this->copiedFileMap[$theFile] = $theDestFile;
                                         clearstatcache();
                                         if (!@is_file($theDestFile)) {
                                             $this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)", 16, array($theFile, dirname($theDestFile), $recFID), $propArr['event_pid']);
                                         }
                                     } else {
                                         $this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: No destination file (%s) possible!. (%s)", 11, array($theFile, $theDestFile, $recFID), $propArr['event_pid']);
                                     }
                                 } else {
                                     $this->log($table, $id, 5, 0, 1, "File extension '%s' not allowed. (%s)", 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
                                 }
                             } else {
                                 $this->log($table, $id, 5, 0, 1, "Filesize (%s) of file '%s' exceeds limit (%s). (%s)", 13, array(t3lib_div::formatSize($fileSize), $theFile, t3lib_div::formatSize($maxSize * 1024), $recFID), $propArr['event_pid']);
                             }
                             // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
                             if (@is_file($theDestFile)) {
                                 $theFile = $theDestFile;
                                 // The value is set to the new filename
                             } else {
                                 unset($theFile);
                                 // The value is set to the new filename
                             }
                         }
                     }
                     $theFile = t3lib_div::fixWindowsFilePath($theFile);
                     if (t3lib_div::isFirstPartOfStr($theFile, PATH_site)) {
                         $theFile = substr($theFile, strlen(PATH_site));
                     }
                 }
             }
         }
     }
     return $valueArray;
 }
示例#11
0
    /**
     * Main function. Will generate the information to display for the item set internally.
     *
     * @param	string		<a> tag closing/returning.
     * @return	void
     */
    function renderFileInfo($returnLinkTag)
    {
        // Initialize object to work on the image:
        $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
        $imgObj->init();
        $imgObj->mayScaleUp = 0;
        $imgObj->absPrefix = PATH_site;
        // Read Image Dimensions (returns false if file was not an image type, otherwise dimensions in an array)
        $imgInfo = '';
        $imgInfo = $imgObj->getImageDimensions($this->file);
        // File information
        $fI = t3lib_div::split_fileref($this->file);
        $ext = $fI['fileext'];
        $code = '';
        // Setting header:
        $fileName = t3lib_iconWorks::getSpriteIconForFile($ext) . '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.file', TRUE) . ':</strong> ' . $fI['file'];
        if (t3lib_div::isFirstPartOfStr($this->file, PATH_site)) {
            $code .= '<a href="../' . substr($this->file, strlen(PATH_site)) . '" target="_blank">' . $fileName . '</a>';
        } else {
            $code .= $fileName;
        }
        $code .= ' &nbsp;&nbsp;<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.filesize') . ':</strong> ' . t3lib_div::formatSize(@filesize($this->file)) . '<br />
			';
        if (is_array($imgInfo)) {
            $code .= '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.dimensions') . ':</strong> ' . $imgInfo[0] . 'x' . $imgInfo[1] . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.pixels');
        }
        $this->content .= $this->doc->section('', $code);
        $this->content .= $this->doc->divider(2);
        // If the file was an image...:
        if (is_array($imgInfo)) {
            $imgInfo = $imgObj->imageMagickConvert($this->file, 'web', '346', '200m', '', '', '', 1);
            $imgInfo[3] = '../' . substr($imgInfo[3], strlen(PATH_site));
            $code = '<br />
				<div align="center">' . $returnLinkTag . $imgObj->imgTag($imgInfo) . '</a></div>';
            $this->content .= $this->doc->section('', $code);
        } else {
            $this->content .= $this->doc->spacer(10);
            $lowerFilename = strtolower($this->file);
            // Archive files:
            if (TYPO3_OS != 'WIN' && !$GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']) {
                if ($ext == 'zip') {
                    $code = '';
                    $t = array();
                    t3lib_utility_Command::exec('unzip -l ' . $this->file, $t);
                    if (is_array($t)) {
                        reset($t);
                        next($t);
                        next($t);
                        next($t);
                        while (list(, $val) = each($t)) {
                            $parts = explode(' ', trim($val), 7);
                            $code .= '
								' . $parts[6] . '<br />';
                        }
                        $code = '
							<span class="nobr">' . $code . '
							</span>
							<br /><br />';
                    }
                    $this->content .= $this->doc->section('', $code);
                } elseif ($ext == 'tar' || $ext == 'tgz' || substr($lowerFilename, -6) == 'tar.gz' || substr($lowerFilename, -5) == 'tar.z') {
                    $code = '';
                    if ($ext == 'tar') {
                        $compr = '';
                    } else {
                        $compr = 'z';
                    }
                    $t = array();
                    t3lib_utility_Command::exec('tar t' . $compr . 'f ' . $this->file, $t);
                    if (is_array($t)) {
                        foreach ($t as $val) {
                            $code .= '
								' . $val . '<br />';
                        }
                        $code .= '
								 -------<br/>
								 ' . count($t) . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.files');
                        $code = '
							<span class="nobr">' . $code . '
							</span>
							<br /><br />';
                    }
                    $this->content .= $this->doc->section('', $code);
                }
            } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']) {
                $this->content .= $this->doc->section('', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.cannotDisplayArchive'));
            }
            // Font files:
            if ($ext == 'ttf') {
                $thumbScript = 'thumbs.php';
                $check = basename($this->file) . ':' . filemtime($this->file) . ':' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
                $params = '&file=' . rawurlencode($this->file);
                $params .= '&md5sum=' . t3lib_div::shortMD5($check);
                $url = $thumbScript . '?&dummy=' . $GLOBALS['EXEC_TIME'] . $params;
                $thumb = '<br />
					<div align="center">' . $returnLinkTag . '<img src="' . htmlspecialchars($url) . '" border="0" title="' . htmlspecialchars(trim($this->file)) . '" alt="" /></a></div>';
                $this->content .= $this->doc->section('', $thumb);
            }
        }
        // References:
        $this->content .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:show_item.php.referencesToThisItem'), $this->makeRef('_FILE', $this->file));
    }
 /**
  * Hook for checking to see if the URL is a speaking URL
  *
  * Here a .htaccess file maps all .html-files to index.php and
  *  then we extract the id and type from the name of that HTML-file. (AKA "simulateStaticDocuments")
  * Support for RewriteRule to generate   (simulateStaticDocuments)
  * With the mod_rewrite compiled into apache, put these lines into a .htaccess in this directory:
  * RewriteEngine On
  * RewriteRule   ^[^/]*\.html$  index.php
  * The url must end with '.html' and the format must comply with either of these:
  * 1:      '[title].[id].[type].html'  - title is just for easy recognition in the
  *                                       logfile!; no practical use of the title for TYPO3.
  * 2:      '[id].[type].html'          - above, but title is omitted; no practical use of
  *                                       the title for TYPO3.
  * 3:      '[id].html'                 - only id, type is set to the default, zero!
  * NOTE: In all case 'id' may be the uid-number OR the page alias (if any)
  *
  * @param	array		includes a reference to the parent Object (which is the global TSFE)
  * @param	tslib_fe	is a reference to the global TSFE
  * @return	void
  */
 public function hookCheckAlternativeIDMethods(array &$parameters, tslib_fe &$parentObject)
 {
     // If there has been a redirect (basically; we arrived here otherwise
     // than via "index.php" in the URL)
     // this can happend either due to a CGI-script or because of reWrite rule.
     // Earlier we used $_SERVER['REDIRECT_URL'] to check
     if ($parentObject->siteScript && substr($parentObject->siteScript, 0, 9) != 'index.php') {
         $uParts = parse_url($parentObject->siteScript);
         $fI = t3lib_div::split_fileref($uParts['path']);
         if (!$fI['path'] && $fI['file'] && substr($fI['file'], -5) == '.html') {
             $parts = explode('.', $fI['file']);
             $pCount = count($parts);
             if ($pCount > 2) {
                 $parentObject->type = intval($parts[$pCount - 2]);
                 $parentObject->id = $parts[$pCount - 3];
             } else {
                 $parentObject->type = 0;
                 $parentObject->id = $parts[0];
             }
         }
     }
     // If PATH_INFO is defined as simulateStaticDocuments mode and has information:
     if (t3lib_div::getIndpEnv('PATH_INFO') && strpos(t3lib_div::getIndpEnv('TYPO3_SITE_SCRIPT'), 'index.php/') === 0) {
         $parts = t3lib_div::trimExplode('/', t3lib_div::getIndpEnv('PATH_INFO'), true);
         $pCount = count($parts);
         if ($pCount > 1) {
             $parentObject->type = intval($parts[$pCount - 1]);
             $parentObject->id = $parts[$pCount - 2];
         } else {
             $parentObject->type = 0;
             $parentObject->id = $parts[0];
         }
         $parentObject->absRefPrefix_force = 1;
     }
 }
 /**
  * @test
  * @see t3lib_div::split_fileref()
  */
 public function checkIfSplitFileRefReturnsFileTypeForFilesWithoutPathSite()
 {
     $testFile = 'fileadmin/media/someFile.png';
     $fileInfo = t3lib_div::split_fileref($testFile);
     $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $fileInfo);
     $this->assertEquals('fileadmin/media/', $fileInfo['path']);
     $this->assertEquals('someFile.png', $fileInfo['file']);
     $this->assertEquals('someFile', $fileInfo['filebody']);
     $this->assertEquals('png', $fileInfo['fileext']);
 }
示例#14
0
 /**
  * Sets the alternative files
  *
  * @return void
  */
 public function setAltfiles()
 {
     $fileInfo = t3lib_div::split_fileref($this->getFile());
     /* get mime and duration from provided file */
     $this->setMime($this->getFileMime($this->getFile()));
     $this->setDuration($this->getFileDuration($this->getFile()));
     $altfiles = array();
     $altfiles[0] = $this->getFile() . ',' . $this->getMime();
     $basepath = $fileInfo['path'] . $fileInfo['filebody'] . '.*';
     $files = glob($basepath);
     /* search for other files */
     for ($i = 0; $i < count($files); $i++) {
         if ($files[$i] != $this->getFile()) {
             $altfiles[$i + 1] = $files[$i] . ',' . $this->getFileMime($files[$i]);
         }
     }
     $this->altfiles = implode('|', $altfiles);
 }
 /**
  * Returns the destination path/filename of a unique filename/foldername in that path.
  * If $theFile exists in $theDest (directory) the file have numbers appended up to $this->maxNumber. Hereafter a unique string will be appended.
  * This function is used by fx. TCEmain when files are attached to records and needs to be uniquely named in the uploads/* folders
  *
  * @param	string		The input filename to check
  * @param	string		The directory for which to return a unique filename for $theFile. $theDest MUST be a valid directory. Should be absolute.
  * @param	boolean		If set the filename is returned with the path prepended without checking whether it already existed!
  * @return	string		The destination absolute filepath (not just the name!) of a unique filename/foldername in that path.
  * @see t3lib_TCEmain::checkValue()
  */
 function getUniqueName($theFile, $theDest, $dontCheckForUnique = 0)
 {
     $theDest = $this->is_directory($theDest);
     // $theDest is cleaned up
     $origFileInfo = t3lib_div::split_fileref($theFile);
     // Fetches info about path, name, extention of $theFile
     if ($theDest) {
         if ($this->getUniqueNamePrefix) {
             // Adds prefix
             $origFileInfo['file'] = $this->getUniqueNamePrefix . $origFileInfo['file'];
             $origFileInfo['filebody'] = $this->getUniqueNamePrefix . $origFileInfo['filebody'];
         }
         // Check if the file exists and if not - return the filename...
         $fileInfo = $origFileInfo;
         $theDestFile = $theDest . '/' . $fileInfo['file'];
         // The destinations file
         if (!file_exists($theDestFile) || $dontCheckForUnique) {
             // If the file does NOT exist we return this filename
             return $theDestFile;
         }
         // Well the filename in its pure form existed. Now we try to append numbers / unique-strings and see if we can find an available filename...
         $theTempFileBody = preg_replace('/_[0-9][0-9]$/', '', $origFileInfo['filebody']);
         // This removes _xx if appended to the file
         $theOrigExt = $origFileInfo['realFileext'] ? '.' . $origFileInfo['realFileext'] : '';
         for ($a = 1; $a <= $this->maxNumber + 1; $a++) {
             if ($a <= $this->maxNumber) {
                 // First we try to append numbers
                 $insert = '_' . sprintf('%02d', $a);
             } else {
                 // .. then we try unique-strings...
                 $insert = '_' . substr(md5(uniqId('')), 0, $this->uniquePrecision);
             }
             $theTestFile = $theTempFileBody . $insert . $theOrigExt;
             $theDestFile = $theDest . '/' . $theTestFile;
             // The destinations file
             if (!file_exists($theDestFile)) {
                 // If the file does NOT exist we return this filename
                 return $theDestFile;
             }
         }
     }
 }
示例#16
0
    /**
     * Returns file-listing of an extension
     *
     * @param	string		Extension key
     * @param	array		Extension information array
     * @return	string		HTML table.
     */
    function getFileListOfExtension($extKey, $conf)
    {
        $content = '';
        $extPath = tx_em_Tools::getExtPath($extKey, $conf['type']);
        if ($extPath) {
            // Read files:
            $fileArr = array();
            $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr, $extPath, '', 0, 99, $this->excludeForPackaging);
            // Start table:
            $lines = array();
            $totalSize = 0;
            // Header:
            $lines[] = '
				<tr class="t3-row-header">
					<td>' . $GLOBALS['LANG']->getLL('extFileList_file') . '</td>
					<td>' . $GLOBALS['LANG']->getLL('extFileList_size') . '</td>
					<td>' . $GLOBALS['LANG']->getLL('extFileList_edit') . '</td>
				</tr>';
            foreach ($fileArr as $file) {
                $fI = t3lib_div::split_fileref($file);
                $lines[] = '
				<tr class="bgColor4">
					<td><a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[downloadFile]' => rawurlencode($file)))) . '" title="' . $GLOBALS['LANG']->getLL('extFileList_download') . '">' . substr($file, strlen($extPath)) . '</a></td>
					<td>' . t3lib_div::formatSize(filesize($file)) . '</td>
					<td>' . (!in_array($extKey, $this->requiredExt) && t3lib_div::inList($this->editTextExtensions, $fI['fileext'] ? $fI['fileext'] : $fI['filebody']) ? '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[editFile]' => rawurlencode($file)))) . '">' . $GLOBALS['LANG']->getLL('extFileList_edit_file') . '</a>' : '') . '</td>
				</tr>';
                $totalSize += filesize($file);
            }
            $lines[] = '
				<tr class="bgColor6">
					<td><strong>' . $GLOBALS['LANG']->getLL('extFileList_total') . '</strong></td>
					<td><strong>' . t3lib_div::formatSize($totalSize) . '</strong></td>
					<td>&nbsp;</td>
				</tr>';
            $content = '
			Path: ' . $extPath . '<br /><br />
			<table border="0" cellpadding="1" cellspacing="2">' . implode('', $lines) . '</table>';
        }
        return $content;
    }
示例#17
0
 /**
  * Add file relation entries for a record's rels-array
  *
  * @param	array		Array of file IDs
  * @param	array		Output lines array (is passed by reference and modified)
  * @param	string		Pre-HTML code
  * @param	string		Alternative HTML color class to use.
  * @param	string		Token ID if this is a softreference (in which case it only makes sense with a single element in the $rels array!)
  * @return	void
  * @access private
  * @see singleRecordLines()
  */
 function addFiles($rels, &$lines, $preCode, $htmlColorClass = '', $tokenID = '')
 {
     foreach ($rels as $ID) {
         // Process file:
         $pInfo = array();
         $fI = $this->dat['header']['files'][$ID];
         if (!is_array($fI)) {
             if (!$tokenID || $this->includeSoftref($tokenID)) {
                 $pInfo['msg'] = 'MISSING FILE: ' . $ID;
                 $this->error('MISSING FILE: ' . $ID, 1);
             } else {
                 return;
             }
         }
         $pInfo['preCode'] = $preCode . '&nbsp;&nbsp;&nbsp;&nbsp;' . t3lib_iconWorks::getSpriteIcon('status-status-reference-hard');
         $pInfo['title'] = htmlspecialchars($fI['filename']);
         $pInfo['ref'] = 'FILE';
         $pInfo['size'] = $fI['filesize'];
         $pInfo['class'] = $htmlColorClass ? $htmlColorClass : 'bgColor3';
         $pInfo['type'] = 'file';
         // If import mode and there is a non-RTE softreference, check the destination directory:
         if ($this->mode === 'import' && $tokenID && !$fI['RTE_ORIG_ID']) {
             if (isset($fI['parentRelFileName'])) {
                 $pInfo['msg'] = 'Seems like this file is already referenced from within an HTML/CSS file. That takes precedence. ';
             } else {
                 $testDirPrefix = dirname($fI['relFileName']) . '/';
                 $testDirPrefix2 = $this->verifyFolderAccess($testDirPrefix);
                 if (!$testDirPrefix2) {
                     $pInfo['msg'] = 'ERROR: There are no available filemounts to write file in! ';
                 } elseif (strcmp($testDirPrefix, $testDirPrefix2)) {
                     $pInfo['msg'] = 'File will be attempted written to "' . $testDirPrefix2 . '". ';
                 }
             }
             // Check if file exists:
             if (file_exists(PATH_site . $fI['relFileName'])) {
                 if ($this->update) {
                     $pInfo['updatePath'] .= 'File exists.';
                 } else {
                     $pInfo['msg'] .= 'File already exists! ';
                 }
             }
             // Check extension:
             $fileProcObj = $this->getFileProcObj();
             if ($fileProcObj->actionPerms['newFile']) {
                 $testFI = t3lib_div::split_fileref(PATH_site . $fI['relFileName']);
                 if (!$this->allowPHPScripts && !$fileProcObj->checkIfAllowed($testFI['fileext'], $testFI['path'], $testFI['file'])) {
                     $pInfo['msg'] .= 'File extension was not allowed!';
                 }
             } else {
                 $pInfo['msg'] = 'You user profile does not allow you to create files on the server!';
             }
         }
         $pInfo['showDiffContent'] = substr($this->fileIDMap[$ID], strlen(PATH_site));
         $lines[] = $pInfo;
         unset($this->remainHeader['files'][$ID]);
         // RTE originals:
         if ($fI['RTE_ORIG_ID']) {
             $ID = $fI['RTE_ORIG_ID'];
             $pInfo = array();
             $fI = $this->dat['header']['files'][$ID];
             if (!is_array($fI)) {
                 $pInfo['msg'] = 'MISSING RTE original FILE: ' . $ID;
                 $this->error('MISSING RTE original FILE: ' . $ID, 1);
             }
             $pInfo['showDiffContent'] = substr($this->fileIDMap[$ID], strlen(PATH_site));
             $pInfo['preCode'] = $preCode . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . t3lib_iconWorks::getSpriteIcon('actions-reference-file');
             $pInfo['title'] = htmlspecialchars($fI['filename']) . ' <em>(Original)</em>';
             $pInfo['ref'] = 'FILE';
             $pInfo['size'] = $fI['filesize'];
             $pInfo['class'] = $htmlColorClass ? $htmlColorClass : 'bgColor3';
             $pInfo['type'] = 'file';
             $lines[] = $pInfo;
             unset($this->remainHeader['files'][$ID]);
         }
         // External resources:
         if (is_array($fI['EXT_RES_ID'])) {
             foreach ($fI['EXT_RES_ID'] as $ID) {
                 $pInfo = array();
                 $fI = $this->dat['header']['files'][$ID];
                 if (!is_array($fI)) {
                     $pInfo['msg'] = 'MISSING External Resource FILE: ' . $ID;
                     $this->error('MISSING External Resource FILE: ' . $ID, 1);
                 } else {
                     $pInfo['updatePath'] = $fI['parentRelFileName'];
                 }
                 $pInfo['showDiffContent'] = substr($this->fileIDMap[$ID], strlen(PATH_site));
                 $pInfo['preCode'] = $preCode . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . t3lib_iconWorks::getSpriteIcon('actions-insert-reference');
                 $pInfo['title'] = htmlspecialchars($fI['filename']) . ' <em>(Resource)</em>';
                 $pInfo['ref'] = 'FILE';
                 $pInfo['size'] = $fI['filesize'];
                 $pInfo['class'] = $htmlColorClass ? $htmlColorClass : 'bgColor3';
                 $pInfo['type'] = 'file';
                 $lines[] = $pInfo;
                 unset($this->remainHeader['files'][$ID]);
             }
         }
     }
 }
 /**
  * Returns a linked image-tag for thumbnail(s)/fileicons/truetype-font-previews from a database row with a list of image files in a field
  * All $TYPO3_CONF_VARS['GFX']['imagefile_ext'] extension are made to thumbnails + ttf file (renders font-example)
  * Thumbsnails are linked to the show_item.php script which will display further details.
  * Usage: 7
  *
  * @param	array		$row is the database row from the table, $table.
  * @param	string		Table name for $row (present in TCA)
  * @param	string		$field is pointing to the field with the list of image files
  * @param	string		Back path prefix for image tag src="" field
  * @param	string		Optional: $thumbScript os by default 'thumbs.php' if you don't set it otherwise
  * @param	string		Optional: $uploaddir is the directory relative to PATH_site where the image files from the $field value is found (Is by default set to the entry in $TCA for that field! so you don't have to!)
  * @param	boolean		If set, uploaddir is NOT prepended with "../"
  * @param	string		Optional: $tparams is additional attributes for the image tags
  * @param	integer		Optional: $size is [w]x[h] of the thumbnail. 56 is default.
  * @return	string		Thumbnail image tag.
  */
 public static function thumbCode($row, $table, $field, $backPath, $thumbScript = '', $uploaddir = NULL, $abs = 0, $tparams = '', $size = '')
 {
     global $TCA;
     // Load table.
     t3lib_div::loadTCA($table);
     // Find uploaddir automatically
     $uploaddir = is_null($uploaddir) ? $TCA[$table]['columns'][$field]['config']['uploadfolder'] : $uploaddir;
     $uploaddir = preg_replace('#/$#', '', $uploaddir);
     // Set thumbs-script:
     if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails']) {
         $thumbScript = 'gfx/notfound_thumb.gif';
     } elseif (!$thumbScript) {
         $thumbScript = 'thumbs.php';
     }
     // Check and parse the size parameter
     $sizeParts = array();
     if ($size = trim($size)) {
         $sizeParts = explode('x', $size . 'x' . $size);
         if (!intval($sizeParts[0])) {
             $size = '';
         }
     }
     // Traverse files:
     $thumbs = explode(',', $row[$field]);
     $thumbData = '';
     foreach ($thumbs as $theFile) {
         if (trim($theFile)) {
             $fI = t3lib_div::split_fileref($theFile);
             $ext = $fI['fileext'];
             // New 190201 start
             $max = 0;
             if (t3lib_div::inList('gif,jpg,png', $ext)) {
                 $imgInfo = @getimagesize(PATH_site . $uploaddir . '/' . $theFile);
                 if (is_array($imgInfo)) {
                     $max = max($imgInfo[0], $imgInfo[1]);
                 }
             }
             // use the original image if it's size fits to the thumbnail size
             if ($max && $max <= (count($sizeParts) && max($sizeParts) ? max($sizeParts) : 56)) {
                 $theFile = $url = ($abs ? '' : '../') . ($uploaddir ? $uploaddir . '/' : '') . trim($theFile);
                 $onClick = 'top.launchView(\'' . $theFile . '\',\'\',\'' . $backPath . '\');return false;';
                 $thumbData .= '<a href="#" onclick="' . htmlspecialchars($onClick) . '"><img src="' . $backPath . $url . '" ' . $imgInfo[3] . ' hspace="2" border="0" title="' . trim($url) . '"' . $tparams . ' alt="" /></a> ';
                 // New 190201 stop
             } elseif ($ext == 'ttf' || t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $ext)) {
                 $theFile_abs = PATH_site . ($uploaddir ? $uploaddir . '/' : '') . trim($theFile);
                 $theFile = ($abs ? '' : '../') . ($uploaddir ? $uploaddir . '/' : '') . trim($theFile);
                 if (!is_readable($theFile_abs)) {
                     $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:warning.file_missing_text') . ' <abbr title="' . $theFile_abs . '">' . $theFile . '</abbr>', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:warning.file_missing'), t3lib_FlashMessage::ERROR);
                     $thumbData .= $flashMessage->render();
                     continue;
                 }
                 $check = basename($theFile_abs) . ':' . filemtime($theFile_abs) . ':' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
                 $params = '&file=' . rawurlencode($theFile);
                 $params .= $size ? '&size=' . $size : '';
                 $params .= '&md5sum=' . t3lib_div::shortMD5($check);
                 $url = $thumbScript . '?&dummy=' . $GLOBALS['EXEC_TIME'] . $params;
                 $onClick = 'top.launchView(\'' . $theFile . '\',\'\',\'' . $backPath . '\');return false;';
                 $thumbData .= '<a href="#" onclick="' . htmlspecialchars($onClick) . '"><img src="' . htmlspecialchars($backPath . $url) . '" hspace="2" border="0" title="' . trim($theFile) . '"' . $tparams . ' alt="" /></a> ';
             } else {
                 // Icon
                 $theFile_abs = PATH_site . ($uploaddir ? $uploaddir . '/' : '') . trim($theFile);
                 $theFile = ($abs ? '' : '../') . ($uploaddir ? $uploaddir . '/' : '') . trim($theFile);
                 $fileIcon = t3lib_iconWorks::getSpriteIconForFile(strtolower($ext), array('title' => htmlspecialchars(trim($theFile))));
                 $check = basename($theFile_abs) . ':' . filemtime($theFile_abs) . ':' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
                 $params = '&file=' . rawurlencode($theFile);
                 $params .= $size ? '&size=' . $size : '';
                 $params .= '&md5sum=' . t3lib_div::shortMD5($check);
                 $url = $thumbScript . '?&dummy=' . $GLOBALS['EXEC_TIME'] . $params;
                 $onClick = 'top.launchView(\'' . $theFile . '\',\'\',\'' . $backPath . '\');return false;';
                 $thumbData .= '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $fileIcon . '</a> ';
             }
         }
     }
     return $thumbData;
 }
    /**
     * The main processing method if this class
     *
     * @return	string		Information of the template status or the taken actions as HTML string
     */
    function main()
    {
        global $SOBE, $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
        global $tmpl, $tplRow, $theConstants;
        $edit = $this->pObj->edit;
        $e = $this->pObj->e;
        t3lib_div::loadTCA('sys_template');
        // **************************
        // Checking for more than one template an if, set a menu...
        // **************************
        $manyTemplatesMenu = $this->pObj->templateMenu();
        $template_uid = 0;
        if ($manyTemplatesMenu) {
            $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
        }
        // **************************
        // Initialize
        // **************************
        $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
        // initialize
        if ($existTemplate) {
            $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
        }
        // **************************
        // Create extension template
        // **************************
        $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
        if ($newId) {
            // switch to new template
            t3lib_utility_Http::redirect('index.php?id=' . $this->pObj->id . '&SET[templatesOnPage]=' . $newId);
        }
        if ($existTemplate) {
            // Update template ?
            $POST = t3lib_div::_POST();
            if ($POST['submit'] || t3lib_div::testInt($POST['submit_x']) && t3lib_div::testInt($POST['submit_y']) || $POST['saveclose'] || t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y'])) {
                // Set the data to be saved
                $recData = array();
                $alternativeFileName = array();
                $resList = $tplRow['resources'];
                $tmp_upload_name = '';
                $tmp_newresource_name = '';
                // Set this to blank
                if (is_array($POST['data'])) {
                    foreach ($POST['data'] as $field => $val) {
                        switch ($field) {
                            case 'constants':
                            case 'config':
                            case 'title':
                            case 'sitetitle':
                            case 'description':
                                $recData['sys_template'][$saveId][$field] = $val;
                                break;
                            case 'resources':
                                $tmp_upload_name = t3lib_div::upload_to_tempfile($_FILES['resources']['tmp_name']);
                                // If there is an uploaded file, move it for the sake of safe_mode.
                                if ($tmp_upload_name) {
                                    if ($tmp_upload_name != 'none' && $_FILES['resources']['name']) {
                                        $alternativeFileName[$tmp_upload_name] = trim($_FILES['resources']['name']);
                                        $resList = $tmp_upload_name . ',' . $resList;
                                    }
                                }
                                break;
                            case 'new_resource':
                                $newName = trim(t3lib_div::_GP('new_resource'));
                                if ($newName) {
                                    $newName .= '.' . t3lib_div::_GP('new_resource_ext');
                                    $tmp_newresource_name = t3lib_div::tempnam('new_resource_');
                                    $alternativeFileName[$tmp_newresource_name] = $newName;
                                    $resList = $tmp_newresource_name . ',' . $resList;
                                }
                                break;
                            case 'makecopy_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $tmp_name = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $file;
                                        $resList = $tmp_name . ',' . $resList;
                                    }
                                }
                                break;
                            case 'remove_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $resList = str_replace(',' . $file . ',', ',', $resList);
                                    }
                                }
                                break;
                            case 'totop_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $resList = str_replace(',' . $file . ',', ',', $resList);
                                        $resList = ',' . $file . $resList;
                                    }
                                }
                                break;
                        }
                    }
                }
                $resList = implode(',', t3lib_div::trimExplode(',', $resList, 1));
                if (strcmp($resList, $tplRow['resources'])) {
                    $recData['sys_template'][$saveId]['resources'] = $resList;
                }
                if (count($recData)) {
                    // Create new  tce-object
                    $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                    $tce->stripslashes_values = 0;
                    $tce->alternativeFileName = $alternativeFileName;
                    // Initialize
                    $tce->start($recData, array());
                    // Saved the stuff
                    $tce->process_datamap();
                    // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
                    $tce->clear_cacheCmd('all');
                    // tce were processed successfully
                    $this->tce_processed = true;
                    // re-read the template ...
                    $this->initialize_editor($this->pObj->id, $template_uid);
                }
                // Unlink any uploaded/new temp files there was:
                t3lib_div::unlink_tempfile($tmp_upload_name);
                t3lib_div::unlink_tempfile($tmp_newresource_name);
                // If files has been edited:
                if (is_array($edit)) {
                    if ($edit['filename'] && $tplRow['resources'] && t3lib_div::inList($tplRow['resources'], $edit['filename'])) {
                        // Check if there are resources, and that the file is in the resourcelist.
                        $path = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $edit['filename'];
                        $fI = t3lib_div::split_fileref($edit['filename']);
                        if (@is_file($path) && t3lib_div::getFileAbsFileName($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) {
                            // checks that have already been done.. Just to make sure
                            // @TODO: Check if the hardcorded value already has a config member, otherwise create one
                            if (filesize($path) < 30720) {
                                // checks that have already been done.. Just to make sure
                                t3lib_div::writeFile($path, $edit['file']);
                                $theOutput .= $this->pObj->doc->spacer(10);
                                $theOutput .= $this->pObj->doc->section('<font color=red>' . $GLOBALS['LANG']->getLL('fileChanged') . '</font>', sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']), 0, 0, 0, 1);
                                // Clear cache - the file has probably affected the template setup
                                // @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible!
                                $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                                $tce->stripslashes_values = 0;
                                $tce->start(array(), array());
                                $tce->clear_cacheCmd('all');
                            }
                        }
                    }
                }
            }
            // hook	Post updating template/TCE processing
            if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) {
                $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'];
                if (is_array($postTCEProcessingHook)) {
                    $hookParameters = array('POST' => $POST, 'tce' => $tce);
                    foreach ($postTCEProcessingHook as $hookFunction) {
                        t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                    }
                }
            }
            $theOutput .= $this->pObj->doc->spacer(5);
            $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateInformation'), t3lib_iconWorks::getSpriteIconForRecord('sys_template', $tplRow) . '<strong>' . htmlspecialchars($tplRow['title']) . '</strong>' . htmlspecialchars(trim($tplRow['sitetitle']) ? ' - (' . $tplRow['sitetitle'] . ')' : ''), 0, 1);
            if ($manyTemplatesMenu) {
                $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
                $theOutput .= $this->pObj->doc->divider(5);
            }
            #$numberOfRows= t3lib_div::intInRange($this->pObj->MOD_SETTINGS["ts_template_editor_TArows"],0,150);
            #if (!$numberOfRows)
            $numberOfRows = 35;
            // If abort pressed, nothing should be edited:
            if ($POST['abort'] || t3lib_div::testInt($POST['abort_x']) && t3lib_div::testInt($POST['abort_y']) || $POST['saveclose'] || t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y'])) {
                unset($e);
            }
            if ($e['title']) {
                $outCode = '<input type="Text" name="data[title]" value="' . htmlspecialchars($tplRow['title']) . '"' . $this->pObj->doc->formWidth() . '>';
                $outCode .= '<input type="Hidden" name="e[title]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('title'), $outCode);
            }
            if ($e['sitetitle']) {
                $outCode = '<input type="Text" name="data[sitetitle]" value="' . htmlspecialchars($tplRow['sitetitle']) . '"' . $this->pObj->doc->formWidth() . '>';
                $outCode .= '<input type="Hidden" name="e[sitetitle]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('sitetitle'), $outCode);
            }
            if ($e['description']) {
                $outCode = '<textarea name="data[description]" rows="5" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, '', '') . '>' . t3lib_div::formatForTextarea($tplRow['description']) . '</textarea>';
                $outCode .= '<input type="Hidden" name="e[description]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('description'), $outCode);
            }
            if ($e['resources']) {
                // Upload
                $outCode = '<input type="File" name="resources"' . $this->pObj->doc->formWidth() . ' size="50">';
                $outCode .= '<input type="Hidden" name="data[resources]" value="1">';
                $outCode .= '<input type="Hidden" name="e[resources]" value="1">';
                $outCode .= '<BR>' . $GLOBALS['LANG']->getLL('allowedExtensions') . ' <strong>' . $TCA['sys_template']['columns']['resources']['config']['allowed'] . '</strong>';
                $outCode .= '<BR>' . $GLOBALS['LANG']->getLL('maxFilesize') . ' <strong>' . t3lib_div::formatSize($TCA['sys_template']['columns']['resources']['config']['max_size'] * 1024) . '</strong>';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('uploadResource'), $outCode);
                // New
                $opt = explode(',', $this->pObj->textExtensions);
                $optTags = '';
                foreach ($opt as $extVal) {
                    $optTags .= '<option value="' . $extVal . '">.' . $extVal . '</option>';
                }
                $outCode = '<input type="text" name="new_resource"' . $this->pObj->doc->formWidth(20) . '>
					<select name="new_resource_ext">' . $optTags . '</select>';
                $outCode .= '<input type="Hidden" name="data[new_resource]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('newTextResource'), $outCode);
                // Make copy
                $rL = $this->resourceListForCopy($this->pObj->id, $template_uid);
                if ($rL) {
                    $theOutput .= $this->pObj->doc->spacer(20);
                    $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('copyResource'), $rL);
                }
                // Update resource list
                $rL = $this->procesResources($tplRow['resources'], 1);
                if ($rL) {
                    $theOutput .= $this->pObj->doc->spacer(20);
                    $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('updateResourceList'), $rL);
                }
            }
            if ($e['constants']) {
                $outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($tplRow['constants']) . '</textarea>';
                $outCode .= '<input type="Hidden" name="e[constants]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants'), '');
                $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
            }
            if ($e['file']) {
                $path = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $e[file];
                $fI = t3lib_div::split_fileref($e[file]);
                if (@is_file($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) {
                    if (filesize($path) < $TCA['sys_template']['columns']['resources']['config']['max_size'] * 1024) {
                        $fileContent = t3lib_div::getUrl($path);
                        $outCode = $GLOBALS['LANG']->getLL('file') . ' <strong>' . $e[file] . '</strong><BR>';
                        $outCode .= '<textarea name="edit[file]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($fileContent) . '</textarea>';
                        $outCode .= '<input type="Hidden" name="edit[filename]" value="' . $e[file] . '">';
                        $outCode .= '<input type="Hidden" name="e[file]" value="' . htmlspecialchars($e[file]) . '">';
                        $theOutput .= $this->pObj->doc->spacer(15);
                        $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editResource'), '');
                        $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
                    } else {
                        $theOutput .= $this->pObj->doc->spacer(15);
                        $fileToBig = sprintf($GLOBALS['LANG']->getLL('filesizeExceeded'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
                        $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
                        $theOutput .= $this->pObj->doc->section('<font color=red>' . $fileToBig . '</font>', $filesizeNotAllowed, 0, 0, 0, 1);
                    }
                }
            }
            if ($e['config']) {
                $outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, "width:98%;height:70%", "off") . ' class="fixed-font">' . t3lib_div::formatForTextarea($tplRow["config"]) . '</textarea>';
                if (t3lib_extMgm::isLoaded('tsconfig_help')) {
                    $url = $BACK_PATH . 'wizard_tsconfig.php?mode=tsref';
                    $params = array('formName' => 'editForm', 'itemName' => 'data[config]');
                    $outCode .= '<a href="#" onClick="vHWin=window.open(\'' . $url . t3lib_div::implodeArrayForUrl('', array('P' => $params)) . '\',\'popUp' . $md5ID . '\',\'height=500,width=780,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;">' . t3lib_iconWorks::getSpriteIcon('actions-system-typoscript-documentation-open', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:tsRef', true))) . '</a>';
                }
                $outCode .= '<input type="Hidden" name="e[config]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup'), '');
                $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
            }
            // Processing:
            $outCode = '';
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('title'), htmlspecialchars($tplRow['title']), 'title');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('sitetitle'), htmlspecialchars($tplRow['sitetitle']), 'sitetitle');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('description'), nl2br(htmlspecialchars($tplRow['description'])), 'description');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('resources'), $this->procesResources($tplRow['resources']), 'resources');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('constants'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[constants]) ? count(explode(LF, $tplRow[constants])) : 0), 'constants');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('setup'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[config]) ? count(explode(LF, $tplRow[config])) : 0), 'config');
            $outCode = '<br /><br /><table class="t3-table-info">' . $outCode . '</table>';
            // Edit all icon:
            $outCode .= '<br /><a href="#" onClick="' . t3lib_BEfunc::editOnClick(rawurlencode('&createExtension=0') . '&amp;edit[sys_template][' . $tplRow['uid'] . ']=edit', $BACK_PATH, '') . '"><strong>' . t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title' => $GLOBALS['LANG']->getLL('editTemplateRecord'))) . $GLOBALS['LANG']->getLL('editTemplateRecord') . '</strong></a>';
            $theOutput .= $this->pObj->doc->section('', $outCode);
            // hook	after compiling the output
            if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) {
                $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'];
                if (is_array($postOutputProcessingHook)) {
                    $hookParameters = array('theOutput' => &$theOutput, 'POST' => $POST, 'e' => $e, 'tplRow' => $tplRow, 'numberOfRows' => $numberOfRows);
                    foreach ($postOutputProcessingHook as $hookFunction) {
                        t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                    }
                }
            }
        } else {
            $theOutput .= $this->pObj->noTemplate(1);
        }
        return $theOutput;
    }
 /**
  * [Describe function...]
  *
  * @param	[type]		$typeDat: ...
  * @param	[type]		$tplRow: ...
  * @param	[type]		$theRealFileName: ...
  * @param	[type]		$tmp_name: ...
  * @return	[type]		...
  */
 function upload_copy_file($typeDat, &$tplRow, $theRealFileName, $tmp_name)
 {
     // extensions
     $extList = $typeDat['paramstr'];
     if ($extList == 'IMAGE_EXT') {
         $extList = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
     }
     $fI = t3lib_div::split_fileref($theRealFileName);
     if ($theRealFileName && (!$extList || t3lib_div::inList($extList, $fI['fileext']))) {
         $tmp_upload_name = t3lib_div::upload_to_tempfile($tmp_name);
         // If there is an uploaded file, move it for the sake of safe_mode.
         // Saving resource
         $alternativeFileName = array();
         $alternativeFileName[$tmp_upload_name] = $theRealFileName;
         // Making list of resources
         $resList = $tplRow['resources'];
         $resList = $tmp_upload_name . ',' . $resList;
         $resList = implode(t3lib_div::trimExplode(',', $resList, 1), ',');
         // Making data-array
         $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
         $recData = array();
         $recData['sys_template'][$saveId]['resources'] = $resList;
         // Saving
         $tce = t3lib_div::makeInstance('t3lib_TCEmain');
         $tce->stripslashes_values = 0;
         $tce->alternativeFileName = $alternativeFileName;
         $tce->start($recData, array());
         $tce->process_datamap();
         t3lib_div::unlink_tempfile($tmp_upload_name);
         $tmpRow = t3lib_BEfunc::getRecordWSOL('sys_template', $saveId, 'resources');
         $tplRow['resources'] = $tmpRow['resources'];
         // Setting the value
         $var = $this->ext_setStar($theRealFileName);
     }
     return $var;
 }
 /**
  * Returns the fileicon
  */
 function getFileIconHTML($file, $altText)
 {
     //ancienne synatxe: $iconDir = "t3lib/gfx/fileicons"; //
     // ces valeurs sont maintenant renseignées dans le fichier ext_typoscript_setup.txt
     $altIconDir = $this->conf["altIconDir"];
     $defaultIcon = $this->conf["defaultIcon"];
     $iconDir = $this->conf["iconDir"];
     $fI = t3lib_div::split_fileref($this->params["path"] . "/" . $file);
     if (file_exists($iconDir . "/" . $fI["fileext"] . ".gif")) {
         $img = $iconDir . "/" . $fI["fileext"] . ".gif";
     } else {
         $img = file_exists($altIconDir . "/" . $fI["fileext"] . ".gif") ? $altIconDir . "/" . $fI["fileext"] . ".gif" : $defaultIcon;
     }
     return '<IMG src="' . $img . '" border="0" title="' . $altText . '">';
 }
 /**
  * Reduce colors in image using IM and create a palette based image if possible (<=256 colors)
  *
  * @param	string		Image file to reduce
  * @param	integer		Number of colors to reduce the image to.
  * @return	string		Reduced file
  */
 function IMreduceColors($file, $cols)
 {
     $fI = t3lib_div::split_fileref($file);
     $ext = strtolower($fI['fileext']);
     $result = $this->randomName() . '.' . $ext;
     if (($reduce = t3lib_div::intInRange($cols, 0, $ext == 'gif' ? 256 : $this->truecolorColors, 0)) > 0) {
         $params = ' -colors ' . $reduce;
         if (!$this->im_version_4) {
             // IM4 doesn't have this options but forces them automatically if applicaple (<256 colors in image)
             if ($reduce <= 256) {
                 $params .= ' -type Palette';
             }
             if ($ext == 'png' && $reduce <= 256) {
                 $prefix = 'png8:';
             }
         }
         $this->imageMagickExec($file, $prefix . $result, $params);
         if ($result) {
             return $result;
         }
     }
     return '';
 }
示例#23
0
 /**
  * Like ->getHeader() but for files in the File>* main module/submodules
  * Returns the file-icon with the path of the file set in the alt/title attribute. Shows the file-name after the icon.
  *
  * @param	string		Title string, expected to be the filepath
  * @param	string		Alt text
  * @param	string		The icon file (relative to TYPO3 dir)
  * @return	string		HTML content
  */
 function getFileheader($title, $path, $iconfile)
 {
     $fileInfo = t3lib_div::split_fileref($title);
     $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($fileInfo['path'], -35)) . '<strong>' . htmlspecialchars($fileInfo['file']) . '</strong>';
     return '<span class="typo3-moduleHeader"><img' . t3lib_iconWorks::skinImg($this->backPath, $iconfile, 'width="18" height="16"') . ' title="' . htmlspecialchars($path) . '" alt="" />' . $title . '</span>';
 }
 function putFile2($absdir, $filename){
    $file=$absdir.$filename;
    
       //Clean all output buffers.
   while (@ob_end_clean());
        // including mimetypes.php here means it is only included when required, thereby saving parsing time for all other requests
     include("mimetypes.php");
        // extract the file extesion and attempt to determine the Mime type from the file's extension
     $fileinfo = t3lib_div::split_fileref($filename);
     $mimetype = $mimetypes[$fileinfo["fileext"]];
     if ($mimetype == "") {
        $mimetype = "application/octet-stream";
     }
    
     $fp = @fopen($file, 'rb');
     if(!$fp) return "File not found";
     
     header("Cache-control: must-revalidate, post-check=0, pre-check=0");
     header("Content-Transfer-Encoding: binary");
     header("Content-Type: $mimetype");
     header("Content-Length: ".filesize($file));
     header("Content-Disposition: attachment; filename=".$filename);
     header("Cache-control: private");
     while (!feof($fp)) {
        $buffer = fgets($fp, 4096);
        echo $buffer;
     }
     fclose($fp);
     exit;
 }
 /**
  * Unzipping file (action=7)
  * This is permitted only if the user has fullAccess or if the file resides
  *
  * @param	array		$cmds['data'] is the zip-file. $cmds['target'] is the target directory. If not set we'll default to the same directory as the file is in.
  * @return	boolean		Returns true on success
  */
 function func_unzip($cmds)
 {
     if (!$this->isInit || $this->dont_use_exec_commands) {
         return FALSE;
     }
     $theFile = $cmds['data'];
     if (@is_file($theFile)) {
         $fI = t3lib_div::split_fileref($theFile);
         if (!isset($cmds['target'])) {
             $cmds['target'] = $fI['path'];
         }
         $theDest = $this->is_directory($cmds['target']);
         // Clean up destination directory
         if ($theDest) {
             if ($this->actionPerms['unzipFile']) {
                 if ($fI['fileext'] == 'zip') {
                     if ($this->checkIfFullAccess($theDest)) {
                         if ($this->checkPathAgainstMounts($theFile) && $this->checkPathAgainstMounts($theDest . '/')) {
                             // No way to do this under windows.
                             $cmd = $this->unzipPath . 'unzip -qq "' . $theFile . '" -d "' . $theDest . '"';
                             exec($cmd);
                             $this->writelog(7, 0, 1, 'Unzipping file "%s" in "%s"', array($theFile, $theDest));
                             return TRUE;
                         } else {
                             $this->writelog(7, 1, 100, 'File "%s" or destination "%s" was not within your mountpoints!', array($theFile, $theDest));
                         }
                     } else {
                         $this->writelog(7, 1, 101, 'You don\'t have full access to the destination directory "%s"!', array($theDest));
                     }
                 } else {
                     $this->writelog(7, 1, 102, 'File extension is not "zip"', '');
                 }
             } else {
                 $this->writelog(7, 1, 103, 'You are not allowed to unzip files', '');
             }
         } else {
             $this->writelog(7, 2, 104, 'Destination "%s" was not a directory', array($cmds['target']));
         }
     } else {
         $this->writelog(7, 2, 105, 'The file "%s" did not exist!', array($theFile));
     }
 }
示例#26
0
/**
* Returns the requested file
!! à modifier !!
*/
function getDownloadFile($uid)
{
    $basePath = t3lib_extMgm::siteRelPath($this->extKey) . dirname($this->scriptRelPath) . "/mimetypes.php";
    if (@is_file($basePath)) {
        include "./" . $basePath;
    }
    $res = $this->getFilesResult("", $uid);
    $file = mysql_fetch_assoc($res);
    if (mysql_num_rows($res) != 1 || !is_file($this->params["path"] . "/" . $file["file"])) {
        echo "<B>" . $this->pi_getLL("file_not_found") . "</B>";
        exit;
    }
    $fI = t3lib_div::split_fileref($file["document"]);
    $sendmime = $mimetypes[$fI["fileext"]];
    if ($sendmime == "") {
        $sendmime = "application/stream";
    }
    header("HTTP/1.1 200 OK");
    header("Content-type: " . $sendmime);
    header("content-length: " . filesize($this->params["path"] . "/" . $file["file"]));
    header("Content-Disposition: attachment; filename=\"" . $file["file"] . "\"");
    $fp = fopen($this->params["path"] . "/" . $file["file"], "r");
    fpassthru($fp);
    flush();
    exit;
}
 /**
  * Renaming files or foldes (action=5)
  *
  * @param	array		$cmds['data'] is the new name. $cmds['target'] is the target (file or dir).
  * @param	string		$id: ID of the item
  * @return	string		Returns the new filename upon success
  */
 function func_rename($cmds, $id)
 {
     if (!$this->isInit) {
         return FALSE;
     }
     $theNewName = tx_dam::file_makeCleanName($cmds['data'], true);
     #		$theNewName = $this->cleanFileName($cmds['data']);
     if (empty($theNewName)) {
         return;
     }
     // main log entry
     $this->log['cmd']['rename'][$id] = array('errors' => array(), 'orig_filename' => $cmds['target'], 'target_file' => $theNewName);
     if (!$this->checkFileNameLen($theNewName)) {
         $this->writelog(5, 1, 124, 'New name "%s" was too long (max %s characters)', array($theNewName, $this->maxInputNameLen), 'rename', $id);
         return;
     }
     $theTarget = $cmds['target'];
     $type = filetype($theTarget);
     // $type MUST BE file or dir
     if (!($type == 'file' || $type == 'dir')) {
         $this->writelog(5, 2, 123, 'Target "%s" was neither a directory nor a file!', array($theTarget), 'rename', $id);
         return;
     }
     // Fetches info about path, name, extention of $theTarget
     $fileInfo = t3lib_div::split_fileref($theTarget);
     // The name should be different from the current. And the filetype must be allowed
     if ($fileInfo['file'] == $theNewName) {
         $this->writelog(5, 1, 122, 'Old and new name is the same (%s)', array($theNewName), 'rename', $id);
         return;
     }
     $theRenameName = $fileInfo['path'] . $theNewName;
     // check mountpoints
     if (!$this->checkPathAgainstMounts($fileInfo['path'])) {
         $this->writelog(5, 1, 121, 'Destination path "%s" was not within your mountpoints!', array($fileInfo['path']), 'rename', $id);
         return;
     }
     // check if dest exists
     if (@file_exists($theRenameName)) {
         $this->writelog(5, 1, 120, 'Destination "%s" existed already!', array($theRenameName), 'rename', $id);
         return;
     }
     if ($type == 'file') {
         // user have permissions for action
         if (!$this->actionPerms['renameFile']) {
             $this->writelog(5, 1, 102, 'You are not allowed to rename files!', '', 'rename', $id);
             return;
         }
         $fI = t3lib_div::split_fileref($theRenameName);
         if (!$this->checkIfAllowed($fI['fileext'], $fileInfo['path'], $fI['file'])) {
             $this->writelog(5, 1, 101, 'Fileextension "%s" was not allowed!', array($fI['fileext']), 'rename', $id);
             return;
         }
         if (!@rename($theTarget, $theRenameName)) {
             $this->writelog(5, 1, 100, 'File "%s" was not renamed! Write-permission problem in "%s"?', array($theTarget, $fileInfo['path']), 'rename', $id);
             return;
         }
         $this->writelog(5, 0, 1, 'File renamed from "%s" to "%s"', array($fileInfo['file'], $theNewName), 'rename', $id);
         // update meta data
         if ($this->processMetaUpdate) {
             tx_dam::notify_fileMoved($theTarget, $theRenameName);
         }
     } elseif ($type == 'dir') {
         // user have permissions for action
         if (!$this->actionPerms['renameFolder']) {
             $this->writelog(5, 1, 111, 'You are not allowed to rename directories!', '', 'rename', $id);
             return;
         }
         if (!@rename($theTarget, $theRenameName)) {
             $this->writelog(5, 1, 110, 'Directory "%s" was not renamed! Write-permission problem in "%s"?', array($theTarget, $fileInfo['path']), 'rename', $id);
             return;
         }
         $this->writelog(5, 0, 2, 'Directory renamed from "%s" to "%s"', array($fileInfo['file'], $theNewName), 'rename', $id);
         // update meta data
         if ($this->processMetaUpdate) {
             tx_dam::notify_fileMoved($theTarget, $theRenameName);
         }
     } else {
         return;
     }
     // add file to log entry
     $this->log['cmd']['rename'][$id]['target_' . $type] = $theRenameName;
     return $theRenameName;
 }
示例#28
0
 /**
  * Notifies the DAM about a deleted file or folder.
  * This will remove the file(s) from the index.
  *
  * @param	string		$filename Filename with path or a folder which have to have a trailing slash.
  * @param	string		$recyclerPath New path when item is moved to recycler.
  * @return	void
  */
 function notify_fileDeleted($filename, $recyclerPath = '')
 {
     if (is_array($row = tx_dam::meta_getDataForFile($filename, 'uid', true))) {
         $uid = $row['uid'];
     }
     if ($uid) {
         $fields_values = array();
         $fields_values['uid'] = $uid;
         $fields_values['deleted'] = '1';
         // file was moved to recycler
         if ($recyclerPath) {
             $org_filename = tx_dam::file_basename($filename);
             $path_parts = t3lib_div::split_fileref($recyclerPath);
             $new_filename = $path_parts['file'];
             $new_path = $path_parts['path'];
             if ($org_filename != $new_filename) {
                 $fields_values['file_name'] = $new_filename;
             }
             if ($new_path) {
                 $fields_values['file_path'] = tx_dam::path_makeRelative($new_path);
             }
         } else {
             // delete MM relations
             $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam_mm_ref', 'tx_dam_mm_ref.uid_local=' . $uid);
         }
         tx_dam_db::insertUpdateData($fields_values);
         // set language overlays deleted
         $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_dam', 'l18n_parent=' . $uid, array('deleted' => 1));
         # $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam', 'l18n_parent='.$uid);
         // todo: replace with full supported group concept --------------------
         // todo: delete child elements and their MM-relation
         // files stay at their physical storage position (usually uploads/tx_dam/storage/_uid_/)
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tx_dam', 'parent_id=' . intval($uid));
         while ($childRow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
             $childUid = $childRow[0];
             $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_dam', 'uid=' . $childUid, array('deleted' => 1));
             $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam_mm_ref', 'tx_dam_mm_ref.uid_local=' . $childUid);
         }
         // ------------------------------------
     } elseif (preg_match('#/$#', $filename)) {
         tx_dam_db::updateFilePathSetDeleted($filename);
     }
 }
 /**
  * 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);
         }
     }
 }
 /**
  * Rendering the cObject, MULTIMEDIA
  *
  * @param	array		Array of TypoScript properties
  * @return	string		Output
  */
 public function render($conf = array())
 {
     $content = '';
     $filename = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file'];
     $incFile = $GLOBALS['TSFE']->tmpl->getFileName($filename);
     if ($incFile) {
         $fileinfo = t3lib_div::split_fileref($incFile);
         if (t3lib_div::inList('txt,html,htm', $fileinfo['fileext'])) {
             $content = $GLOBALS['TSFE']->tmpl->fileContent($incFile);
         } else {
             // default params...
             $parArray = array();
             // src is added
             $width = isset($conf['width.']) ? $this->cObj->stdWrap($conf['width'], $conf['width.']) : $conf['width'];
             if (!$width) {
                 $width = 200;
             }
             $height = isset($conf['height.']) ? $this->cObj->stdWrap($conf['height'], $conf['height.']) : $conf['height'];
             if (!$height) {
                 $height = 200;
             }
             $parArray['src'] = 'src="' . $GLOBALS['TSFE']->absRefPrefix . $incFile . '"';
             if (t3lib_div::inList('au,wav,mp3', $fileinfo['fileext'])) {
             }
             if (t3lib_div::inList('avi,mov,mpg,asf,wmv', $fileinfo['fileext'])) {
                 $parArray['width'] = 'width="' . $width . '"';
                 $parArray['height'] = 'height="' . $height . '"';
             }
             if (t3lib_div::inList('swf,swa,dcr', $fileinfo['fileext'])) {
                 $parArray['quality'] = 'quality="high"';
                 $parArray['width'] = 'width="' . $width . '"';
                 $parArray['height'] = 'height="' . $height . '"';
             }
             if (t3lib_div::inList('class', $fileinfo['fileext'])) {
                 $parArray['width'] = 'width="' . $width . '"';
                 $parArray['height'] = 'height="' . $height . '"';
             }
             // fetching params
             $params = isset($conf['params.']) ? $this->cObj->stdWrap($conf['params'], $conf['params.']) : $conf['params'];
             $lines = explode(LF, $params);
             foreach ($lines as $l) {
                 $parts = explode('=', $l);
                 $parameter = strtolower(trim($parts[0]));
                 $value = trim($parts[1]);
                 if ((string) $value != '') {
                     $parArray[$parameter] = $parameter . '="' . htmlspecialchars($value) . '"';
                 } else {
                     unset($parArray[$parameter]);
                 }
             }
             if ($fileinfo['fileext'] == 'class') {
                 unset($parArray['src']);
                 $parArray['code'] = 'code="' . htmlspecialchars($fileinfo['file']) . '"';
                 $parArray['codebase'] = 'codebase="' . htmlspecialchars($fileinfo['path']) . '"';
                 $content = '<applet ' . implode(' ', $parArray) . '></applet>';
             } else {
                 $content = '<embed ' . implode(' ', $parArray) . '></embed>';
             }
         }
     }
     if (isset($conf['stdWrap.'])) {
         $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
     }
     return $content;
 }