/**
  * Build the autoload registry for a given extension and place it ext_autoload.php.
  *
  * @param	string	$extensionName	Name of the extension
  * @param	string	$extensionPath	full path of the extension
  * @return	string	HTML string which should be outputted
  */
 public function createAutoloadRegistryForExtension($extensionName, $extensionPath)
 {
     $classNameToFileMapping = array();
     $globalPrefixes = array();
     $globalPrefixes[] = '$extensionPath = t3lib_extMgm::extPath(\'' . $extensionName . '\');';
     $this->buildAutoloadRegistryForSinglePath($classNameToFileMapping, $extensionPath, '.*tslib.*', '$extensionPath . \'|\'');
     // Processes special 'classes/' or 'Classes/' folder and use a shorter notation for that:
     // (files will be overridden in the class name to file mapping)
     $extensionClassesDirectory = $this->getExtensionClassesDirectory($extensionPath);
     if ($extensionClassesDirectory !== FALSE) {
         $globalPrefixes[] = '$extensionClassesPath = $extensionPath . \'' . $extensionClassesDirectory . '\';';
         $this->buildAutoloadRegistryForSinglePath($classNameToFileMapping, $extensionPath . $extensionClassesDirectory, '.*tslib.*', '$extensionClassesPath . \'|\'');
     }
     $extensionPrefix = $this->getExtensionPrefix($extensionName);
     $errors = array();
     foreach ($classNameToFileMapping as $className => $fileName) {
         if ($this->isValidClassNamePrefix($className, $extensionPrefix) === FALSE) {
             $errors[] = $className . ' does not start with Tx_' . $extensionPrefix . ', tx_' . $extensionPrefix . ' or user_' . $extensionPrefix . ' and is not added to the autoloader registry.';
             unset($classNameToFileMapping[$className]);
         }
     }
     $autoloadFileString = $this->generateAutoloadPHPFileDataForExtension($classNameToFileMapping, $globalPrefixes);
     if (@file_put_contents($extensionPath . 'ext_autoload.php', $autoloadFileString)) {
         t3lib_div::fixPermissions($extensionPath . 'ext_autoload.php');
         $errors[] = 'Wrote the following data: <pre>' . htmlspecialchars($autoloadFileString) . '</pre>';
     } else {
         $errors[] = '<b>' . $extensionPath . 'ext_autoload.php could not be written!</b>';
     }
     return implode('<br />', $errors);
 }
 /**
  * Moves uploaded files from temporary upload folder to a specified new folder.
  * This enables you to move the files from a successful submission to another folder and clean the files in temporary upload folder from time to time.
  *
  * TypoScript example:
  *
  * 1. Set the temporary upload folder
  * <code>
  * plugin.Tx_Formhandler.settings.files.tmpUploadFolder = uploads/formhandler/tmp
  * </code>
  *
  * 2. Set the folder to move the files to after submission
  * <code>
  * plugin.Tx_Formhandler.settings.finishers.1.class = Tx_Formhandler_Finisher_StoreUploadedFiles
  * plugin.Tx_Formhandler.settings.finishers.1.config.finishedUploadFolder = uploads/formhandler/finishedFiles/
  * plugin.Tx_Formhandler.settings.finishers.1.config.renameScheme = [filename]_[md5]_[time]
  * </code>
  *
  * @return void
  */
 protected function moveUploadedFiles()
 {
     $newFolder = $this->settings['finishedUploadFolder'];
     $newFolder = Tx_Formhandler_StaticFuncs::sanitizePath($newFolder);
     $uploadPath = Tx_Formhandler_StaticFuncs::getDocumentRoot() . $newFolder;
     $sessionFiles = Tx_Formhandler_Globals::$session->get('files');
     if (is_array($sessionFiles) && !empty($sessionFiles) && strlen($newFolder) > 0) {
         foreach ($sessionFiles as $field => $files) {
             $this->gp[$field] = array();
             foreach ($files as $key => $file) {
                 if ($file['uploaded_path'] != $uploadPath) {
                     $newFilename = $this->getNewFilename($file['uploaded_name']);
                     Tx_Formhandler_StaticFuncs::debugMessage('copy_file', array($file['uploaded_path'] . $file['uploaded_name'], $uploadPath . $newFilename));
                     copy($file['uploaded_path'] . $file['uploaded_name'], $uploadPath . $newFilename);
                     t3lib_div::fixPermissions($uploadPath . $newFilename);
                     unlink($file['uploaded_path'] . $file['uploaded_name']);
                     $sessionFiles[$field][$key]['uploaded_path'] = $uploadPath;
                     $sessionFiles[$field][$key]['uploaded_name'] = $newFilename;
                     $sessionFiles[$field][$key]['uploaded_folder'] = $newFolder;
                     $sessionFiles[$field][$key]['uploaded_url'] = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $newFolder . $newFilename;
                     if (!is_array($this->gp[$field])) {
                         $this->gp[$field] = array();
                     }
                     array_push($this->gp[$field], $newFilename);
                 }
             }
         }
         Tx_Formhandler_Globals::$session->set('files', $sessionFiles);
     }
 }
コード例 #3
0
 /**
  * Generates configuration. Locks configuration file for exclusive access to avoid collisions. Will not be stabe on Windows.
  *
  * @return	void
  */
 public function generateConfiguration()
 {
     $fileName = PATH_site . TX_REALURL_AUTOCONF_FILE;
     $lockObject = t3lib_div::makeInstance('t3lib_lock', $fileName, $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']);
     /** @var t3lib_lock $lockObject */
     $lockObject->setEnableLogging(FALSE);
     $lockObject->acquire();
     $fd = @fopen($fileName, 'a+');
     if ($fd) {
         // Check size
         fseek($fd, 0, SEEK_END);
         if (ftell($fd) == 0) {
             $this->doGenerateConfiguration($fd);
         }
         fclose($fd);
         t3lib_div::fixPermissions($fileName);
     }
     $lockObject->release();
 }
コード例 #4
0
ファイル: thumbs.php プロジェクト: NaveedWebdeveloper/Test
 /**
  * Create the thumbnail
  * Will exit before return if all is well.
  *
  * @return	void
  */
 function main()
 {
     global $TYPO3_CONF_VARS;
     // If file exists, we make a thumbsnail of the file.
     if ($this->input && file_exists($this->input)) {
         // Check file extension:
         $reg = array();
         if (preg_match('/(.*)\\.([^\\.]*$)/', $this->input, $reg)) {
             $ext = strtolower($reg[2]);
             $ext = $ext == 'jpeg' ? 'jpg' : $ext;
             if ($ext == 'ttf') {
                 $this->fontGif($this->input);
                 // Make font preview... (will not return)
             } elseif (!t3lib_div::inList($this->imageList, $ext)) {
                 $this->errorGif('Not imagefile!', $ext, basename($this->input));
             }
         } else {
             $this->errorGif('Not imagefile!', 'No ext!', basename($this->input));
         }
         // ... so we passed the extension test meaning that we are going to make a thumbnail here:
         if (!$this->size) {
             $this->size = $this->sizeDefault;
         }
         // default
         // I added extra check, so that the size input option could not be fooled to pass other values. That means the value is exploded, evaluated to an integer and the imploded to [value]x[value]. Furthermore you can specify: size=340 and it'll be translated to 340x340.
         $sizeParts = explode('x', $this->size . 'x' . $this->size);
         // explodes the input size (and if no "x" is found this will add size again so it is the same for both dimensions)
         $sizeParts = array(t3lib_div::intInRange($sizeParts[0], 1, 1000), t3lib_div::intInRange($sizeParts[1], 1, 1000));
         // Cleaning it up, only two parameters now.
         $this->size = implode('x', $sizeParts);
         // Imploding the cleaned size-value back to the internal variable
         $sizeMax = max($sizeParts);
         // Getting max value
         // Init
         $outpath = PATH_site . $this->outdir;
         // Should be - ? 'png' : 'gif' - , but doesn't work (ImageMagick prob.?)
         // René: png work for me
         $thmMode = t3lib_div::intInRange($TYPO3_CONF_VARS['GFX']['thumbnails_png'], 0);
         $outext = $ext != 'jpg' || $thmMode & 2 ? $thmMode & 1 ? 'png' : 'gif' : 'jpg';
         $outfile = 'tmb_' . substr(md5($this->input . $this->mtime . $this->size), 0, 10) . '.' . $outext;
         $this->output = $outpath . $outfile;
         if ($TYPO3_CONF_VARS['GFX']['im']) {
             // If thumbnail does not exist, we generate it
             if (!file_exists($this->output)) {
                 $parameters = '-sample ' . $this->size . ' ' . $this->wrapFileName($this->input) . '[0] ' . $this->wrapFileName($this->output);
                 $cmd = t3lib_div::imageMagickCommand('convert', $parameters);
                 t3lib_utility_Command::exec($cmd);
                 if (!file_exists($this->output)) {
                     $this->errorGif('No thumb', 'generated!', basename($this->input));
                 } else {
                     t3lib_div::fixPermissions($this->output);
                 }
             }
             // The thumbnail is read and output to the browser
             if ($fd = @fopen($this->output, 'rb')) {
                 header('Content-type: image/' . $outext);
                 fpassthru($fd);
                 fclose($fd);
             } else {
                 $this->errorGif('Read problem!', '', $this->output);
             }
         } else {
             exit;
         }
     } else {
         $this->errorGif('No valid', 'inputfile!', basename($this->input));
     }
 }
コード例 #5
0
 /**
  * Rendering the "txdam" custom attribute on img tag, called from TypoScript
  *
  * @param	string		Content input. Not used, ignore.
  * @param	array		TypoScript configuration
  * @return	string		Unmodified content input
  * @access private
  */
 function renderTxdamAttribute($content, $conf)
 {
     global $TYPO3_CONF_VARS;
     $mediaId = isset($this->cObj->parameters['txdam']) ? $this->cObj->parameters['txdam'] : 0;
     if ($mediaId) {
         if (!is_object($media = tx_dam::media_getByUid($mediaId))) {
             $GLOBALS['TT']->setTSlogMessage("tx_dam_tsfeimgtag->renderTxdamAttribute(): File id '" . $mediaId . "' was not found, so '" . $content . "' was not updated.", 1);
             return $content;
         }
         $metaInfo = $media->getMetaArray();
         $magicPathPrefix = $TYPO3_CONF_VARS['BE']['RTE_imageStorageDir'] . 'RTEmagicC_';
         if (t3lib_div::isFirstPartOfStr($this->cObj->parameters['src'], $magicPathPrefix)) {
             // Process magic image
             $pI = pathinfo(substr($this->cObj->parameters['src'], strlen($magicPathPrefix)));
             $fileName = preg_replace('/_[0-9][0-9]' . preg_quote('.') . '/', '.', substr($pI['basename'], 0, -strlen('.' . $pI['extension'])));
             if ($fileName != $metaInfo['file_name']) {
                 // Substitute magic image
                 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
                 $imgObj->init();
                 $imgObj->mayScaleUp = 0;
                 $imgObj->tempPath = PATH_site . $imgObj->tempPath;
                 $imgInfo = $imgObj->getImageDimensions(PATH_site . $metaInfo['file_path'] . $metaInfo['file_name']);
                 if (is_array($imgInfo) && count($imgInfo) == 4 && $TYPO3_CONF_VARS['BE']['RTE_imageStorageDir']) {
                     // Create or update the reference and magic images
                     $fileInfo = pathinfo($imgInfo[3]);
                     $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
                     // Construct a name based on the mediaId and on the width and height of the magic image
                     $basename = $fileFunc->cleanFileName('RTEmagicP_' . $fileInfo['filename'] . '_txdam' . $this->cObj->parameters['txdam'] . '_' . substr(md5($this->cObj->parameters['width'] . 'x' . $this->cObj->parameters['height']), 0, $fileFunc->uniquePrecision) . '.' . $fileInfo['extension']);
                     $destPath = PATH_site . $TYPO3_CONF_VARS['BE']['RTE_imageStorageDir'];
                     if (@is_dir($destPath)) {
                         // Do not check file uniqueness in order to avoid creating a new one on every rendering
                         $destName = $fileFunc->getUniqueName($basename, $destPath, 1);
                         if (!@is_file($destName)) {
                             @copy($imgInfo[3], $destName);
                             t3lib_div::fixPermissions($destName);
                         }
                         $magicImageInfo = $imgObj->imageMagickConvert($destName, 'WEB', $this->cObj->parameters['width'] . 'm', $this->cObj->parameters['height'] . 'm');
                         if ($magicImageInfo[3]) {
                             $fileInfo = pathinfo($magicImageInfo[3]);
                             $mainBase = 'RTEmagicC_' . substr(basename($destName), 10) . '.' . $fileInfo['extension'];
                             $destName = $fileFunc->getUniqueName($mainBase, $destPath, 1);
                             if (!@is_file($destName)) {
                                 @copy($magicImageInfo[3], $destName);
                                 t3lib_div::fixPermissions($destName);
                             }
                             $destName = dirname($destName) . '/' . rawurlencode(basename($destName));
                             $this->cObj->parameters['src'] = substr($destName, strlen(PATH_site));
                         }
                     }
                 }
             }
         } else {
             // Substitute plain image, if needed
             if ($this->cObj->parameters['src'] != $metaInfo['file_path'] . $metaInfo['file_name']) {
                 $this->cObj->parameters['src'] = $metaInfo['file_path'] . $metaInfo['file_name'];
             }
         }
     }
     $parametersForAttributes = $this->cObj->parameters;
     unset($parametersForAttributes['txdam']);
     unset($parametersForAttributes['allParams']);
     $content = '<img ' . t3lib_div::implodeAttributes($parametersForAttributes, TRUE, TRUE) . ' />';
     return $content;
 }
コード例 #6
0
ファイル: index.php プロジェクト: NaveedWebdeveloper/Test
    /**
     * Generate the main settings formular:
     *
     * @return	void
     */
    function main()
    {
        global $BE_USER, $LANG, $BACK_PATH, $TBE_MODULES;
        // file creation / delete
        if ($this->isAdmin) {
            if ($this->installToolFileKeep) {
                $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('enableInstallTool.fileHasKeep'), $LANG->getLL('enableInstallTool.file'), t3lib_FlashMessage::WARNING);
                $this->content .= $flashMessage->render();
            }
            if (t3lib_div::_POST('deleteInstallToolEnableFile')) {
                unlink(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
                $this->setInstallToolFileExists();
                if ($this->getInstallToolFileExists()) {
                    $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('enableInstallTool.fileDelete_failed'), $LANG->getLL('enableInstallTool.file'), t3lib_FlashMessage::ERROR);
                } else {
                    $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('enableInstallTool.fileDelete_ok'), $LANG->getLL('enableInstallTool.file'), t3lib_FlashMessage::OK);
                }
                $this->content .= $flashMessage->render();
            }
            if (t3lib_div::_POST('createInstallToolEnableFile')) {
                touch(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
                t3lib_div::fixPermissions(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
                $this->setInstallToolFileExists();
                if ($this->getInstallToolFileExists()) {
                    $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('enableInstallTool.fileCreate_ok'), $LANG->getLL('enableInstallTool.file'), t3lib_FlashMessage::OK);
                } else {
                    $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('enableInstallTool.fileCreate_failed'), $LANG->getLL('enableInstallTool.file'), t3lib_FlashMessage::ERROR);
                }
                $this->content .= $flashMessage->render();
            }
        }
        if ($this->languageUpdate) {
            $this->doc->JScodeArray['languageUpdate'] .= '
				if (top.refreshMenu) {
					top.refreshMenu();
				} else {
					top.TYPO3ModuleMenu.refreshMenu();
				}
			';
        }
        if ($this->pagetreeNeedsRefresh) {
            t3lib_BEfunc::setUpdateSignal('updatePageTree');
        }
        // Start page:
        $this->doc->loadJavascriptLib('md5.js');
        // use a wrapper div
        $this->content .= '<div id="user-setup-wrapper">';
        // Load available backend modules
        $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
        $this->loadModules->observeWorkspaces = true;
        $this->loadModules->load($TBE_MODULES);
        $this->content .= $this->doc->header($LANG->getLL('UserSettings') . ' - ' . $BE_USER->user['realName'] . ' [' . $BE_USER->user['username'] . ']');
        // show if setup was saved
        if ($this->setupIsUpdated && !$this->tempDataIsCleared && !$this->settingsAreResetToDefault) {
            $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('setupWasUpdated'), $LANG->getLL('UserSettings'));
            $this->content .= $flashMessage->render();
        }
        // Show if temporary data was cleared
        if ($this->tempDataIsCleared) {
            $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('tempDataClearedFlashMessage'), $LANG->getLL('tempDataCleared'));
            $this->content .= $flashMessage->render();
        }
        // Show if temporary data was cleared
        if ($this->settingsAreResetToDefault) {
            $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('settingsAreReset'), $LANG->getLL('resetConfiguration'));
            $this->content .= $flashMessage->render();
        }
        // If password is updated, output whether it failed or was OK.
        if ($this->passwordIsSubmitted) {
            if ($this->passwordIsUpdated) {
                $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('newPassword_ok'), $LANG->getLL('newPassword'));
            } else {
                $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('newPassword_failed'), $LANG->getLL('newPassword'), t3lib_FlashMessage::ERROR);
            }
            $this->content .= $flashMessage->render();
        }
        // render the menu items
        $menuItems = $this->renderUserSetup();
        $this->content .= $this->doc->spacer(20) . $this->doc->getDynTabMenu($menuItems, 'user-setup', FALSE, FALSE, 0, 1, FALSE, 1, $this->dividers2tabs);
        $formToken = $this->formProtection->generateToken('BE user setup', 'edit');
        // Submit and reset buttons
        $this->content .= $this->doc->spacer(20);
        $this->content .= $this->doc->section('', t3lib_BEfunc::cshItem('_MOD_user_setup', 'reset', $BACK_PATH) . '
			<input type="hidden" name="simUser" value="' . $this->simUser . '" />
			<input type="hidden" name="formToken" value="' . $formToken . '" />
			<input type="submit" name="data[save]" value="' . $LANG->getLL('save') . '" />
			<input type="button" value="' . $LANG->getLL('resetConfiguration') . '" onclick="if(confirm(\'' . $LANG->getLL('setToStandardQuestion') . '\')) {document.getElementById(\'setValuesToDefault\').value=1;this.form.submit();}" />
			<input type="button" value="' . $LANG->getLL('clearSessionVars') . '"  onclick="if(confirm(\'' . $LANG->getLL('clearSessionVarsQuestion') . '\')){document.getElementById(\'clearSessionVars\').value=1;this.form.submit();}" />
			<input type="hidden" name="data[setValuesToDefault]" value="0" id="setValuesToDefault" />
			<input type="hidden" name="data[clearSessionVars]" value="0" id="clearSessionVars" />');
        // Notice
        $this->content .= $this->doc->spacer(30);
        $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('activateChanges'), '', t3lib_FlashMessage::INFO);
        $this->content .= $flashMessage->render();
        // end of wrapper div
        $this->content .= '</div>';
        // Setting up the buttons and markers for docheader
        $docHeaderButtons = $this->getButtons();
        $markers['CSH'] = $docHeaderButtons['csh'];
        $markers['CONTENT'] = $this->content;
        // Build the <body> for the module
        $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
        // Renders the module page
        $this->content = $this->doc->render($LANG->getLL('UserSettings'), $this->content);
    }
コード例 #7
0
 /**
  * Outputs the mail to a text file according to RFC 4155.
  *
  * @param Swift_Mime_Message $message The message to send
  * @param string[] &$failedRecipients To collect failures by-reference, nothing will fail in our debugging case
  * @return int
  * @throws Exception
  */
 public function send(Swift_Mime_Message $message, &$failedRecipients = null)
 {
     $message->generateId();
     // Create a mbox-like header
     $mboxFrom = $this->getReversePath($message);
     $mboxDate = strftime('%c', $message->getDate());
     $messageStr = sprintf('From %s  %s', $mboxFrom, $mboxDate) . LF;
     // Add the complete mail inclusive headers
     $messageStr .= $message->toString();
     $messageStr .= LF . LF;
     // Write the mbox file
     $file = @fopen($this->debugFile, 'a');
     if (!$file) {
         throw new Exception(sprintf('Could not write to file "%s" when sending an email to debug transport', $this->debugFile), 1291064151);
     }
     flock($file, LOCK_EX);
     @fwrite($file, $messageStr);
     flock($file, LOCK_UN);
     @fclose($file);
     t3lib_div::fixPermissions($this->debugFile);
     // Return every receipient as "delivered"
     $count = count((array) $message->getTo()) + count((array) $message->getCc()) + count((array) $message->getBcc());
     return $count;
 }
コード例 #8
0
 /**
  * Acquire a lock and return when successful. If the lock is already open, the client will be
  *
  * It is important to know that the lock will be acquired in any case, even if the request was blocked first. Therefore, the lock needs to be released in every situation.
  *
  * @return	boolean		Returns true if lock could be acquired without waiting, false otherwise.
  */
 public function acquire()
 {
     $noWait = TRUE;
     // Default is TRUE, which means continue without caring for other clients. In the case of TYPO3s cache management, this has no negative effect except some resource overhead.
     $isAcquired = TRUE;
     switch ($this->method) {
         case 'simple':
             if (is_file($this->resource)) {
                 $this->sysLog('Waiting for a different process to release the lock');
                 $maxExecutionTime = ini_get('max_execution_time');
                 $maxAge = time() - ($maxExecutionTime ? $maxExecutionTime : 120);
                 if (@filectime($this->resource) < $maxAge) {
                     @unlink($this->resource);
                     $this->sysLog('Unlink stale lockfile');
                 }
             }
             $isAcquired = FALSE;
             for ($i = 0; $i < $this->loops; $i++) {
                 $filepointer = @fopen($this->resource, 'x');
                 if ($filepointer !== FALSE) {
                     fclose($filepointer);
                     $this->sysLog('Lock aquired');
                     $noWait = $i === 0;
                     $isAcquired = TRUE;
                     break;
                 }
                 usleep($this->step * 1000);
             }
             if (!$isAcquired) {
                 throw new Exception('Lock file could not be created');
             }
             t3lib_div::fixPermissions($this->resource);
             break;
         case 'flock':
             if (($this->filepointer = fopen($this->resource, 'w+')) == FALSE) {
                 throw new Exception('Lock file could not be opened');
             }
             if (flock($this->filepointer, LOCK_EX | LOCK_NB) == TRUE) {
                 // Lock without blocking
                 $noWait = TRUE;
             } elseif (flock($this->filepointer, LOCK_EX) == TRUE) {
                 // Lock with blocking (waiting for similar locks to become released)
                 $noWait = FALSE;
             } else {
                 throw new Exception('Could not lock file "' . $this->resource . '"');
             }
             break;
         case 'semaphore':
             if (sem_acquire($this->resource)) {
                 // Unfortunately it seems not possible to find out if the request was blocked, so we return FALSE in any case to make sure the operation is tried again.
                 $noWait = FALSE;
             }
             break;
         case 'disable':
             $noWait = FALSE;
             $isAcquired = FALSE;
             break;
     }
     $this->isAcquired = $isAcquired;
     return $noWait;
 }
コード例 #9
0
 /**
  * Sets the file system mode and group ownership of a file or a folder.
  *
  * @param string $path Path of file or folder, must not be escaped. Path can be absolute or relative
  * @param bool $recursive If set, also fixes permissions of files and folders in the folder (if $path is a folder)
  * @return mixed TRUE on success, FALSE on error, always TRUE on Windows OS
  */
 public function fixPermissions($path, $recursive = FALSE)
 {
     return t3lib_div::fixPermissions($path, $recursive);
 }
コード例 #10
0
 /**
  * Imports an extensions from the online repository
  * NOTICE: in version 4.0 this changed from "importExtFromRep_old($extRepUid,$loc,$uploadFlag=0,$directInput='',$recentTranslations=0,$incManual=0,$dontDelete=0)"
  *
  * @param	string		Extension key
  * @param	string		Version
  * @param	string		Install scope: "L" or "G" or "S"
  * @param	boolean		If true, extension is uploaded as file
  * @param	boolean		If true, extension directory+files will not be deleted before writing the new ones. That way custom files stored in the extension folder will be kept.
  * @param	array		Direct input array (like from kickstarter)
  * @return	string		Return false on success, returns error message if error.
  */
 function importExtFromRep($extKey, $version, $loc, $uploadFlag = 0, $dontDelete = 0, $directInput = '')
 {
     $uploadSucceed = false;
     $uploadedTempFile = '';
     if (is_array($directInput)) {
         $fetchData = array($directInput, '');
         $loc = $loc === 'G' || $loc === 'S' ? $loc : 'L';
     } elseif ($uploadFlag) {
         if (($uploadedTempFile = $this->CMD['alreadyUploaded']) || $_FILES['upload_ext_file']['tmp_name']) {
             // Read uploaded file:
             if (!$uploadedTempFile) {
                 if (!is_uploaded_file($_FILES['upload_ext_file']['tmp_name'])) {
                     t3lib_div::sysLog('Possible file upload attack: ' . $_FILES['upload_ext_file']['tmp_name'], 'Extension Manager', 3);
                     return $GLOBALS['LANG']->getLL('ext_import_file_not_uploaded');
                 }
                 $uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['upload_ext_file']['tmp_name']);
             }
             $fileContent = t3lib_div::getUrl($uploadedTempFile);
             if (!$fileContent) {
                 return $GLOBALS['LANG']->getLL('ext_import_file_empty');
             }
             // Decode file data:
             $fetchData = $this->terConnection->decodeExchangeData($fileContent);
             if (is_array($fetchData)) {
                 $extKey = $fetchData[0]['extKey'];
                 if ($extKey) {
                     if (!$this->CMD['uploadOverwrite']) {
                         $loc = $loc === 'G' || $loc === 'S' ? $loc : 'L';
                         $comingExtPath = PATH_site . $this->typePaths[$loc] . $extKey . '/';
                         if (@is_dir($comingExtPath)) {
                             $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_ext_present_no_overwrite'), $comingExtPath) . '<br />' . $GLOBALS['LANG']->getLL('ext_import_ext_present_nothing_done'), '', t3lib_FlashMessage::ERROR);
                             return $flashMessage->render();
                         }
                         // ... else go on, install...
                     }
                     // ... else go on, install...
                 } else {
                     return $GLOBALS['LANG']->getLL('ext_import_no_key');
                 }
             } else {
                 return sprintf($GLOBALS['LANG']->getLL('ext_import_wrong_file_format'), $fetchData);
             }
         } else {
             return $GLOBALS['LANG']->getLL('ext_import_no_file');
         }
     } else {
         $this->xmlhandler->searchExtensionsXMLExact($extKey, '', '', true, true);
         // Fetch extension from TER:
         if (!strlen($version)) {
             $versions = array_keys($this->xmlhandler->extensionsXML[$extKey]['versions']);
             $version = end($versions);
         }
         $fetchData = $this->terConnection->fetchExtension($extKey, $version, $this->xmlhandler->extensionsXML[$extKey]['versions'][$version]['t3xfilemd5'], $this->getMirrorURL());
     }
     // At this point the extension data should be present; so we want to write it to disc:
     if ($this->importAsType($loc)) {
         if (is_array($fetchData)) {
             // There was some data successfully transferred
             if ($fetchData[0]['extKey'] && is_array($fetchData[0]['FILES'])) {
                 $extKey = $fetchData[0]['extKey'];
                 if (!isset($fetchData[0]['EM_CONF']['constraints'])) {
                     $fetchData[0]['EM_CONF']['constraints'] = $this->xmlhandler->extensionsXML[$extKey]['versions'][$version]['dependencies'];
                 }
                 $EM_CONF = $this->fixEMCONF($fetchData[0]['EM_CONF']);
                 if (!$EM_CONF['lockType'] || !strcmp($EM_CONF['lockType'], $loc)) {
                     // check dependencies, act accordingly if ext is loaded
                     list($instExtInfo, ) = $this->getInstalledExtensions();
                     $depStatus = $this->checkDependencies($extKey, $EM_CONF, $instExtInfo);
                     if (t3lib_extMgm::isLoaded($extKey) && !$depStatus['returnCode']) {
                         $this->content .= $depStatus['html'];
                         if ($uploadedTempFile) {
                             $this->content .= '<input type="hidden" name="CMD[alreadyUploaded]" value="' . $uploadedTempFile . '" />';
                         }
                     } else {
                         $res = $this->clearAndMakeExtensionDir($fetchData[0], $loc, $dontDelete);
                         if (is_array($res)) {
                             $extDirPath = trim($res[0]);
                             if ($extDirPath && @is_dir($extDirPath) && substr($extDirPath, -1) == '/') {
                                 $emConfFile = $this->construct_ext_emconf_file($extKey, $EM_CONF);
                                 $dirs = $this->extractDirsFromFileList(array_keys($fetchData[0]['FILES']));
                                 $res = $this->createDirsInPath($dirs, $extDirPath);
                                 if (!$res) {
                                     $writeFiles = $fetchData[0]['FILES'];
                                     $writeFiles['ext_emconf.php']['content'] = $emConfFile;
                                     $writeFiles['ext_emconf.php']['content_md5'] = md5($emConfFile);
                                     // Write files:
                                     foreach ($writeFiles as $theFile => $fileData) {
                                         t3lib_div::writeFile($extDirPath . $theFile, $fileData['content']);
                                         if (!@is_file($extDirPath . $theFile)) {
                                             $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'), $extDirPath . $theFile) . '<br />';
                                         } elseif (md5(t3lib_div::getUrl($extDirPath . $theFile)) != $fileData['content_md5']) {
                                             $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_corrupted'), $extDirPath . $theFile) . '<br />';
                                         }
                                     }
                                     t3lib_div::fixPermissions($extDirPath, TRUE);
                                     // No content, no errors. Create success output here:
                                     if (!$content) {
                                         $messageContent = sprintf($GLOBALS['LANG']->getLL('ext_import_success_folder'), $extDirPath) . '<br />';
                                         $uploadSucceed = true;
                                         // Fix TYPO3_MOD_PATH for backend modules in extension:
                                         $modules = t3lib_div::trimExplode(',', $EM_CONF['module'], 1);
                                         if (count($modules)) {
                                             foreach ($modules as $mD) {
                                                 $confFileName = $extDirPath . $mD . '/conf.php';
                                                 if (@is_file($confFileName)) {
                                                     $messageContent .= $this->writeTYPO3_MOD_PATH($confFileName, $loc, $extKey . '/' . $mD . '/') . '<br />';
                                                 } else {
                                                     $messageContent .= sprintf($GLOBALS['LANG']->getLL('ext_import_no_conf_file'), $confFileName) . '<br />';
                                                 }
                                             }
                                         }
                                         // NOTICE: I used two hours trying to find out why a script, ext_emconf.php, written twice and in between included by PHP did not update correct the second time. Probably something with PHP-A cache and mtime-stamps.
                                         // But this order of the code works.... (using the empty Array with type, EMCONF and files hereunder).
                                         // Writing to ext_emconf.php:
                                         $sEMD5A = $this->serverExtensionMD5Array($extKey, array('type' => $loc, 'EM_CONF' => array(), 'files' => array()));
                                         $EM_CONF['_md5_values_when_last_written'] = serialize($sEMD5A);
                                         $emConfFile = $this->construct_ext_emconf_file($extKey, $EM_CONF);
                                         t3lib_div::writeFile($extDirPath . 'ext_emconf.php', $emConfFile);
                                         $messageContent .= 'ext_emconf.php: ' . $extDirPath . 'ext_emconf.php<br />';
                                         $messageContent .= $GLOBALS['LANG']->getLL('ext_import_ext_type') . ' ';
                                         $messageContent .= $this->typeLabels[$loc] . '<br />';
                                         $messageContent .= '<br />';
                                         // Remove cache files:
                                         $updateContent = '';
                                         if (t3lib_extMgm::isLoaded($extKey)) {
                                             if ($this->removeCacheFiles()) {
                                                 $messageContent .= $GLOBALS['LANG']->getLL('ext_import_cache_files_removed') . '<br />';
                                             }
                                             list($new_list) = $this->getInstalledExtensions();
                                             $updateContent = $this->updatesForm($extKey, $new_list[$extKey], 1, 'index.php?CMD[showExt]=' . $extKey . '&SET[singleDetails]=info');
                                         }
                                         $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $messageContent, $GLOBALS['LANG']->getLL('ext_import_success'));
                                         $content = $flashMessage->render() . $updateContent;
                                         // Install / Uninstall:
                                         if (!$this->CMD['standAlone']) {
                                             $content .= '<h3>' . $GLOBALS['LANG']->getLL('ext_import_install_uninstall') . '</h3>';
                                             $content .= $new_list[$extKey] ? '<a href="' . htmlspecialchars('index.php?CMD[showExt]=' . $extKey . '&CMD[remove]=1&CMD[clrCmd]=1&SET[singleDetails]=info') . '">' . $this->removeButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_uninstall') . '</a>' : '<a href="' . htmlspecialchars('index.php?CMD[showExt]=' . $extKey . '&CMD[load]=1&CMD[clrCmd]=1&SET[singleDetails]=info') . '">' . $this->installButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_install') . '</a>';
                                         } else {
                                             $content = $GLOBALS['LANG']->getLL('ext_import_imported') . '<br /><br /><a href="javascript:opener.top.content.document.forms[0].submit();window.close();">' . $GLOBALS['LANG']->getLL('ext_import_close_check') . '</a>';
                                         }
                                     }
                                 } else {
                                     $content = $res;
                                 }
                             } else {
                                 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_path_different'), $extDirPath);
                             }
                         } else {
                             $content = $res;
                         }
                     }
                 } else {
                     $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_only_here'), $this->typePaths[$EM_CONF['lockType']], $EM_CONF['lockType']);
                 }
             } else {
                 $content = $GLOBALS['LANG']->getLL('ext_import_no_ext_key_files');
             }
         } else {
             $content = sprintf($GLOBALS['LANG']->getLL('ext_import_data_transfer'), $fetchData);
         }
     } else {
         $content = sprintf($GLOBALS['LANG']->getLL('ext_import_no_install_here'), $this->typePaths[$loc]);
     }
     $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_results'), $content, 0, 1);
     if ($uploadSucceed && $uploadedTempFile) {
         t3lib_div::unlink_tempfile($uploadedTempFile);
     }
     return false;
 }
コード例 #11
0
 /**
  * Installs an extension.
  *
  * @param  $fetchData
  * @param  $loc
  * @param  $version
  * @param  $uploadedTempFile
  * @param  $dontDelete
  * @return mixed|string
  */
 public function installExtension($fetchData, $loc, $version, $uploadedTempFile, $dontDelete)
 {
     $xmlHandler =& $this->parentObject->xmlHandler;
     $extensionList =& $this->parentObject->extensionList;
     $extensionDetails =& $this->parentObject->extensionDetails;
     $content = '';
     if (tx_em_Tools::importAsType($loc)) {
         if (is_array($fetchData)) {
             // There was some data successfully transferred
             if ($fetchData[0]['extKey'] && is_array($fetchData[0]['FILES'])) {
                 $extKey = $fetchData[0]['extKey'];
                 if (!isset($fetchData[0]['EM_CONF']['constraints'])) {
                     $fetchData[0]['EM_CONF']['constraints'] = $xmlHandler->extensionsXML[$extKey]['versions'][$version]['dependencies'];
                 }
                 $EM_CONF = tx_em_Tools::fixEMCONF($fetchData[0]['EM_CONF']);
                 if (!$EM_CONF['lockType'] || !strcmp($EM_CONF['lockType'], $loc)) {
                     // check dependencies, act accordingly if ext is loaded
                     list($instExtInfo, ) = $extensionList->getInstalledExtensions();
                     $depStatus = $this->checkDependencies($extKey, $EM_CONF, $instExtInfo);
                     if (t3lib_extMgm::isLoaded($extKey) && !$depStatus['returnCode']) {
                         $content .= $depStatus['html'];
                         if ($uploadedTempFile) {
                             $content .= '<input type="hidden" name="CMD[alreadyUploaded]" value="' . $uploadedTempFile . '" />';
                         }
                     } else {
                         $res = $this->clearAndMakeExtensionDir($fetchData[0], $loc, $dontDelete);
                         if (is_array($res)) {
                             $extDirPath = trim($res[0]);
                             if ($extDirPath && @is_dir($extDirPath) && substr($extDirPath, -1) == '/') {
                                 $emConfFile = $extensionDetails->construct_ext_emconf_file($extKey, $EM_CONF);
                                 $dirs = tx_em_Tools::extractDirsFromFileList(array_keys($fetchData[0]['FILES']));
                                 $res = tx_em_Tools::createDirsInPath($dirs, $extDirPath);
                                 if (!$res) {
                                     $writeFiles = $fetchData[0]['FILES'];
                                     $writeFiles['ext_emconf.php']['content'] = $emConfFile;
                                     $writeFiles['ext_emconf.php']['content_md5'] = md5($emConfFile);
                                     // Write files:
                                     foreach ($writeFiles as $theFile => $fileData) {
                                         t3lib_div::writeFile($extDirPath . $theFile, $fileData['content']);
                                         if (!@is_file($extDirPath . $theFile)) {
                                             if (!$this->silentMode) {
                                                 $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'), $extDirPath . $theFile), '', t3lib_FlashMessage::ERROR);
                                                 $content .= $flashMessage->render();
                                             } else {
                                                 if (!$this->silentMode) {
                                                     $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'), $extDirPath . $theFile), '', t3lib_FlashMessage::ERROR);
                                                     $content .= $flashMessage->render();
                                                 } else {
                                                     $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'), $extDirPath . $theFile) . '<br />';
                                                 }
                                             }
                                         } elseif (md5(t3lib_div::getUrl($extDirPath . $theFile)) != $fileData['content_md5']) {
                                             $content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_corrupted'), $extDirPath . $theFile) . '<br />';
                                         }
                                     }
                                     t3lib_div::fixPermissions($extDirPath, TRUE);
                                     // No content, no errors. Create success output here:
                                     if (!$content) {
                                         $messageContent = sprintf($GLOBALS['LANG']->getLL('ext_import_success_folder'), $extDirPath) . '<br />';
                                         $uploadSucceed = true;
                                         // Fix TYPO3_MOD_PATH for backend modules in extension:
                                         $modules = t3lib_div::trimExplode(',', $EM_CONF['module'], 1);
                                         if (count($modules)) {
                                             foreach ($modules as $mD) {
                                                 $confFileName = $extDirPath . $mD . '/conf.php';
                                                 if (@is_file($confFileName)) {
                                                     $messageContent .= tx_em_Tools::writeTYPO3_MOD_PATH($confFileName, $loc, $extKey . '/' . $mD . '/') . '<br />';
                                                 } else {
                                                     $messageContent .= sprintf($GLOBALS['LANG']->getLL('ext_import_no_conf_file'), $confFileName) . '<br />';
                                                 }
                                             }
                                         }
                                         // NOTICE: I used two hours trying to find out why a script, ext_emconf.php, written twice and in between included by PHP did not update correct the second time. Probably something with PHP-A cache and mtime-stamps.
                                         // But this order of the code works.... (using the empty Array with type, EMCONF and files hereunder).
                                         // Writing to ext_emconf.php:
                                         $sEMD5A = $extensionDetails->serverExtensionMD5array($extKey, array('type' => $loc, 'EM_CONF' => array(), 'files' => array()));
                                         $EM_CONF['_md5_values_when_last_written'] = serialize($sEMD5A);
                                         $emConfFile = $extensionDetails->construct_ext_emconf_file($extKey, $EM_CONF);
                                         t3lib_div::writeFile($extDirPath . 'ext_emconf.php', $emConfFile);
                                         $messageContent .= 'ext_emconf.php: ' . $extDirPath . 'ext_emconf.php<br />';
                                         $messageContent .= $GLOBALS['LANG']->getLL('ext_import_ext_type') . ' ';
                                         $messageContent .= $this->api->typeLabels[$loc] . '<br />';
                                         $messageContent .= '<br />';
                                         // Remove cache files:
                                         $updateContent = '';
                                         if (t3lib_extMgm::isLoaded($extKey)) {
                                             if (t3lib_extMgm::removeCacheFiles()) {
                                                 $messageContent .= $GLOBALS['LANG']->getLL('ext_import_cache_files_removed') . '<br />';
                                             }
                                             list($new_list) = $this->parentObject->extensionList->getInstalledExtensions();
                                             $updateContent = $this->updatesForm($extKey, $new_list[$extKey], 1, t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'SET[singleDetails]' => 'info')));
                                         }
                                         if (!$this->silentMode) {
                                             $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $messageContent, $GLOBALS['LANG']->getLL('ext_import_success'));
                                             $content = $flashMessage->render();
                                         } else {
                                             $content = $updateContent;
                                         }
                                         // Install / Uninstall:
                                         if (!$this->parentObject->CMD['standAlone']) {
                                             $content .= '<h3>' . $GLOBALS['LANG']->getLL('ext_import_install_uninstall') . '</h3>';
                                             $content .= $new_list[$extKey] ? '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[remove]' => 1, 'CMD[clrCmd]' => 1, 'SET[singleDetails]' => 'info'))) . '">' . tx_em_Tools::removeButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_uninstall') . '</a>' : '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[load]' => 1, 'CMD[clrCmd]' => 1, 'SET[singleDetails]' => 'info'))) . '">' . tx_em_Tools::installButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_install') . '</a>';
                                         } else {
                                             $content = $GLOBALS['LANG']->getLL('ext_import_imported') . '<br /><br />';
                                             if ($this->silentMode || t3lib_div::_GP('nodoc')) {
                                                 $content .= '<a id="closewindow" href="javascript:parent.TYPO3.EM.Tools.closeImportWindow();">' . $GLOBALS['LANG']->getLL('ext_import_close') . '</a>';
                                             } else {
                                                 $content .= '<a href="javascript:opener.top.list.iframe.document.forms[0].submit();window.close();">' . $GLOBALS['LANG']->getLL('ext_import_close_check') . '</a>';
                                             }
                                         }
                                     }
                                 } else {
                                     if (!$this->silentMode) {
                                         $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $res, '', t3lib_FlashMessage::ERROR);
                                         $content = $flashMessage->render();
                                     } else {
                                         $content = $res;
                                     }
                                 }
                             } else {
                                 if (!$this->silentMode) {
                                     $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_ext_path_different'), $extDirPath), '', t3lib_FlashMessage::ERROR);
                                     $content = $flashMessage->render();
                                 } else {
                                     $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_path_different'), $extDirPath);
                                 }
                             }
                         } else {
                             if (!$this->silentMode) {
                                 $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $res, '', t3lib_FlashMessage::ERROR);
                                 $content = $flashMessage->render();
                             } else {
                                 $content = $res;
                             }
                         }
                     }
                 } else {
                     if (!$this->silentMode) {
                         $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_ext_only_here'), $this->typePaths[$EM_CONF['lockType']], $EM_CONF['lockType']), '', t3lib_FlashMessage::ERROR);
                         $content = $flashMessage->render();
                     } else {
                         $content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_only_here'), tx_em_Tools::typePath($EM_CONF['lockType']), $EM_CONF['lockType']);
                     }
                 }
             } else {
                 if (!$this->silentMode) {
                     $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_no_ext_key_files'), '', t3lib_FlashMessage::ERROR);
                     $content = $flashMessage->render();
                 } else {
                     $content = $GLOBALS['LANG']->getLL('ext_import_no_ext_key_files');
                 }
             }
         } else {
             if (!$this->silentMode) {
                 $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_data_transfer'), $fetchData), '', t3lib_FlashMessage::ERROR);
                 $content = $flashMessage->render();
             } else {
                 $content = sprintf($GLOBALS['LANG']->getLL('ext_import_data_transfer'), $fetchData);
             }
         }
     } else {
         if (!$this->silentMode) {
             $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_no_install_here'), $this->typePaths[$loc]), '', t3lib_FlashMessage::ERROR);
             $content = $flashMessage->render();
         } else {
             $content = sprintf($GLOBALS['LANG']->getLL('ext_import_no_install_here'), tx_em_Tools::typePath($loc));
         }
     }
     return $content;
 }
コード例 #12
0
    /**
     * Renders translation module
     *
     * @return string or direct output
     */
    public function translationHandling()
    {
        global $LANG, $TYPO3_LOADED_EXT;
        $LANG->includeLLFile('EXT:setup/mod/locallang.xml');
        //prepare docheader
        $docHeaderButtons = $this->parentObject->getButtons();
        $markers = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => $this->parentObject->getFuncMenu());
        $content = '';
        $incoming = t3lib_div::_POST('SET');
        if (isset($incoming['selectedLanguages']) && is_array($incoming['selectedLanguages'])) {
            t3lib_BEfunc::getModuleData($this->parentObject->MOD_MENU, array('selectedLanguages' => serialize($incoming['selectedLanguages'])), $this->parentObject->MCONF['name'], '', 'selectedLanguages');
            $this->parentObject->MOD_SETTINGS['selectedLanguages'] = serialize($incoming['selectedLanguages']);
        }
        $selectedLanguages = unserialize($this->parentObject->MOD_SETTINGS['selectedLanguages']);
        if (count($selectedLanguages) == 1 && empty($selectedLanguages[0])) {
            $selectedLanguages = array();
        }
        $theLanguages = t3lib_div::trimExplode('|', TYPO3_languages);
        foreach ($theLanguages as $val) {
            if ($val != 'default') {
                $localLabel = '  -  [' . htmlspecialchars($GLOBALS['LOCAL_LANG']['default']['lang_' . $val]) . ']';
                $selected = is_array($selectedLanguages) && in_array($val, $selectedLanguages) ? ' selected="selected"' : '';
                $opt[$GLOBALS['LANG']->getLL('lang_' . $val, 1) . '--' . $val] = '
			 <option value="' . $val . '"' . $selected . '>' . $LANG->getLL('lang_' . $val, 1) . $localLabel . '</option>';
            }
        }
        ksort($opt);
        $headline = $GLOBALS['LANG']->getLL('translation_settings');
        $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'translation', $headline);
        // Prepare the HTML output:
        $content .= '
			<form action="' . $this->parentObject->script . '" method="post" name="translationform">
			<fieldset><legend>' . $GLOBALS['LANG']->getLL('translation_settings') . '</legend>
			<table border="0" cellpadding="2" cellspacing="2">
				<tr class="bgColor4">
					<td>' . $GLOBALS['LANG']->getLL('languages_to_fetch') . '</td>
					<td>
					  <select name="SET[selectedLanguages][]" multiple="multiple" size="10">
					  <option>&nbsp;</option>' . implode('', $opt) . '
			</select>
		  </td>
				</tr>
			</table>
			<br />
			<p>' . $GLOBALS['LANG']->getLL('translation_info') . '<br />
			<br />' . $GLOBALS['LANG']->getLL('translation_loaded_exts') . '</p>
			</fieldset>
			<br />
			<input type="submit" value="' . $GLOBALS['LANG']->getLL('translation_save_selection') . '" />
			<br />
			</form>';
        $this->parentObject->content .= $this->parentObject->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE);
        if (count($selectedLanguages) > 0) {
            $mirrorURL = $this->parentObject->getMirrorURL();
            $content = '<input type="button" value="' . $GLOBALS['LANG']->getLL('translation_check_status_button') . '" onclick="document.location.href=\'' . htmlspecialchars(t3lib_div::linkThisScript(array('l10n' => 'check'))) . '\'" />&nbsp;<input type="button" value="' . $GLOBALS['LANG']->getLL('translation_update_button') . '" onclick="document.location.href=\'' . htmlspecialchars(t3lib_div::linkThisScript(array('l10n' => 'update'))) . '\'" />';
            // as this page loads dynamically, quit output buffering caused by ob_gzhandler
            t3lib_div::cleanOutputBuffers();
            if (t3lib_div::_GET('l10n') == 'check') {
                $loadedExtensions = array_keys($TYPO3_LOADED_EXT);
                $loadedExtensions = array_diff($loadedExtensions, array('_CACHEFILE'));
                // Override content output - we now do that ourselves:
                $this->parentObject->content .= $this->parentObject->doc->section($GLOBALS['LANG']->getLL('translation_status'), $content, 0, 1);
                // Setting up the buttons and markers for docheader
                $content = $this->parentObject->doc->startPage('Extension Manager');
                $content .= $this->parentObject->doc->moduleBody($this->parentObject->pageinfo, $docHeaderButtons, $markers);
                $contentParts = explode('###CONTENT###', $content);
                echo $contentParts[0] . $this->parentObject->content;
                $this->parentObject->doPrintContent = FALSE;
                flush();
                echo '
				<br />
				<br />
				<p id="progress-message">
					' . $GLOBALS['LANG']->getLL('translation_check_status') . '
				</p>
				<br />
				<div style="width:100%; height:20px; border: 1px solid black;">
					<div id="progress-bar" style="float: left; width: 0%; height: 20px; background-color:green;">&nbsp;</div>
					<div id="transparent-bar" style="float: left; width: 100%; height: 20px; background-color:' . $this->parentObject->doc->bgColor2 . ';">&nbsp;</div>
				</div>
				<br />
				<br /><p>' . $GLOBALS['LANG']->getLL('translation_table_check') . '</p><br />
				<table border="0" cellpadding="2" cellspacing="2">
					<tr class="t3-row-header"><td>' . $GLOBALS['LANG']->getLL('translation_extension_key') . '</td>
				';
                foreach ($selectedLanguages as $lang) {
                    echo '<td>' . $LANG->getLL('lang_' . $lang, 1) . '</td>';
                }
                echo '</tr>';
                $counter = 1;
                foreach ($loadedExtensions as $extKey) {
                    $percentDone = intval($counter / count($loadedExtensions) * 100);
                    echo '
					<script type="text/javascript">
						document.getElementById("progress-bar").style.width = "' . $percentDone . '%";
						document.getElementById("transparent-bar").style.width = "' . (100 - $percentDone) . '%";
						document.getElementById("progress-message").firstChild.data="' . sprintf($GLOBALS['LANG']->getLL('translation_checking_extension'), $extKey) . '";
					</script>
					';
                    flush();
                    $translationStatusArr = $this->parentObject->terConnection->fetchTranslationStatus($extKey, $mirrorURL);
                    echo '<tr class="bgColor4"><td>' . $extKey . '</td>';
                    foreach ($selectedLanguages as $lang) {
                        // remote unknown -> no l10n available
                        if (!isset($translationStatusArr[$lang])) {
                            echo '<td title="' . $GLOBALS['LANG']->getLL('translation_no_translation') . '">' . $GLOBALS['LANG']->getLL('translation_n_a') . '</td>';
                            continue;
                        }
                        // determine local md5 from zip
                        if (is_file(PATH_site . 'typo3temp/' . $extKey . '-l10n-' . $lang . '.zip')) {
                            $localmd5 = md5_file(PATH_site . 'typo3temp/' . $extKey . '-l10n-' . $lang . '.zip');
                        } else {
                            echo '<td title="' . $GLOBALS['LANG']->getLL('translation_not_installed') . '" style="background-color:#ff0">' . $GLOBALS['LANG']->getLL('translation_status_unknown') . '</td>';
                            continue;
                        }
                        // local!=remote -> needs update
                        if ($localmd5 != $translationStatusArr[$lang]['md5']) {
                            echo '<td title="' . $GLOBALS['LANG']->getLL('translation_needs_update') . '" style="background-color:#ff0">' . $GLOBALS['LANG']->getLL('translation_status_update') . '</td>';
                            continue;
                        }
                        echo '<td title="' . $GLOBALS['LANG']->getLL('translation_is_ok') . '" style="background-color:#69a550">' . $GLOBALS['LANG']->getLL('translation_status_ok') . '</td>';
                    }
                    echo '</tr>';
                    $counter++;
                }
                echo '</table>
					<script type="text/javascript">
						document.getElementById("progress-message").firstChild.data="' . $GLOBALS['LANG']->getLL('translation_check_done') . '";
					</script>
				';
                echo $contentParts[1] . $this->parentObject->doc->endPage();
                exit;
            } elseif (t3lib_div::_GET('l10n') == 'update') {
                $loadedExtensions = array_keys($TYPO3_LOADED_EXT);
                $loadedExtensions = array_diff($loadedExtensions, array('_CACHEFILE'));
                // Override content output - we now do that ourselves:
                $this->parentObject->content .= $this->parentObject->doc->section($GLOBALS['LANG']->getLL('translation_status'), $content, 0, 1);
                // Setting up the buttons and markers for docheader
                $content = $this->parentObject->doc->startPage('Extension Manager');
                $content .= $this->parentObject->doc->moduleBody($this->parentObject->pageinfo, $docHeaderButtons, $markers);
                $contentParts = explode('###CONTENT###', $content);
                echo $contentParts[0] . $this->parentObject->content;
                $this->parentObject->doPrintContent = FALSE;
                flush();
                echo '
				<br />
				<br />
				<p id="progress-message">
					' . $GLOBALS['LANG']->getLL('translation_update_status') . '
				</p>
				<br />
				<div style="width:100%; height:20px; border: 1px solid black;">
					<div id="progress-bar" style="float: left; width: 0%; height: 20px; background-color:green;">&nbsp;</div>
					<div id="transparent-bar" style="float: left; width: 100%; height: 20px; background-color:' . $this->parentObject->doc->bgColor2 . ';">&nbsp;</div>
				</div>
				<br />
				<br /><p>' . $GLOBALS['LANG']->getLL('translation_table_update') . '<br />
				<em>' . $GLOBALS['LANG']->getLL('translation_full_check_update') . '</em></p><br />
				<table border="0" cellpadding="2" cellspacing="2">
					<tr class="t3-row-header"><td>' . $GLOBALS['LANG']->getLL('translation_extension_key') . '</td>
				';
                foreach ($selectedLanguages as $lang) {
                    echo '<td>' . $LANG->getLL('lang_' . $lang, 1) . '</td>';
                }
                echo '</tr>';
                $counter = 1;
                foreach ($loadedExtensions as $extKey) {
                    $percentDone = intval($counter / count($loadedExtensions) * 100);
                    echo '
					<script type="text/javascript">
						document.getElementById("progress-bar").style.width = "' . $percentDone . '%";
						document.getElementById("transparent-bar").style.width = "' . (100 - $percentDone) . '%";
						document.getElementById("progress-message").firstChild.data="' . sprintf($GLOBALS['LANG']->getLL('translation_updating_extension'), $extKey) . '";
					</script>
					';
                    flush();
                    $translationStatusArr = $this->parentObject->terConnection->fetchTranslationStatus($extKey, $mirrorURL);
                    echo '<tr class="bgColor4"><td>' . $extKey . '</td>';
                    if (is_array($translationStatusArr)) {
                        foreach ($selectedLanguages as $lang) {
                            // remote unknown -> no l10n available
                            if (!isset($translationStatusArr[$lang])) {
                                echo '<td title="' . $GLOBALS['LANG']->getLL('translation_no_translation') . '">' . $GLOBALS['LANG']->getLL('translation_n_a') . '</td>';
                                continue;
                            }
                            // determine local md5 from zip
                            if (is_file(PATH_site . 'typo3temp/' . $extKey . '-l10n-' . $lang . '.zip')) {
                                $localmd5 = md5_file(PATH_site . 'typo3temp/' . $extKey . '-l10n-' . $lang . '.zip');
                            } else {
                                $localmd5 = 'zzz';
                            }
                            // local!=remote or not installed -> needs update
                            if ($localmd5 != $translationStatusArr[$lang]['md5']) {
                                $ret = $this->updateTranslation($extKey, $lang, $mirrorURL);
                                if ($ret === true) {
                                    echo '<td title="' . $GLOBALS['LANG']->getLL('translation_has_been_updated') . '" style="background-color:#69a550">' . $GLOBALS['LANG']->getLL('translation_status_update') . '</td>';
                                } else {
                                    echo '<td title="' . htmlspecialchars($ret) . '" style="background-color:#cb3352">' . $GLOBALS['LANG']->getLL('translation_status_error') . '</td>';
                                }
                                continue;
                            }
                            echo '<td title="' . $GLOBALS['LANG']->getLL('translation_is_ok') . '" style="background-color:#69a550">' . $GLOBALS['LANG']->getLL('translation_status_ok') . '</td>';
                        }
                    } else {
                        echo '<td colspan="' . count($selectedLanguages) . '" title="' . $GLOBALS['LANG']->getLL('translation_problems') . '">' . $GLOBALS['LANG']->getLL('translation_status_could_not_fetch') . '</td>';
                    }
                    echo '</tr>';
                    $counter++;
                }
                echo '</table>
					<script type="text/javascript">
						document.getElementById("progress-message").firstChild.data="' . $GLOBALS['LANG']->getLL('translation_update_done') . '";
					</script>
				';
                // Fix permissions on unzipped language xml files in the entire l10n folder and all subfolders
                t3lib_div::fixPermissions(PATH_typo3conf . 'l10n', TRUE);
                echo $contentParts[1] . $this->parentObject->doc->endPage();
                exit;
            }
            $this->parentObject->content .= $this->parentObject->doc->section($GLOBALS['LANG']->getLL('translation_status'), $content, 0, 1);
        }
    }
コード例 #13
0
 /**
  * Insert a magic image
  *
  * @param	string		$filepath: the path to the image file
  * @param	array		$imgInfo: a 4-elements information array about the file
  * @param	string		$altText: text for the alt attribute of the image
  * @param	string		$titleText: text for the title attribute of the image
  * @param	string		$additionalParams: text representing more HTML attributes to be added on the img tag
  * @return	void
  */
 public function insertMagicImage($filepath, $imgInfo, $altText = '', $titleText = '', $additionalParams = '')
 {
     if (is_array($imgInfo) && count($imgInfo) == 4) {
         if ($this->RTEImageStorageDir) {
             $fI = pathinfo($imgInfo[3]);
             $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
             $basename = $fileFunc->cleanFileName('RTEmagicP_' . $fI['basename']);
             $destPath = PATH_site . $this->RTEImageStorageDir;
             if (@is_dir($destPath)) {
                 $destName = $fileFunc->getUniqueName($basename, $destPath);
                 @copy($imgInfo[3], $destName);
                 t3lib_div::fixPermissions($destName);
                 $cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'), 0, $this->magicMaxWidth);
                 $cHeight = t3lib_div::intInRange(t3lib_div::_GP('cHeight'), 0, $this->magicMaxHeight);
                 if (!$cWidth) {
                     $cWidth = $this->magicMaxWidth;
                 }
                 if (!$cHeight) {
                     $cHeight = $this->magicMaxHeight;
                 }
                 $imgI = $this->imgObj->imageMagickConvert($filepath, 'WEB', $cWidth . 'm', $cHeight . 'm');
                 // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
                 if ($imgI[3]) {
                     $fI = pathinfo($imgI[3]);
                     $mainBase = 'RTEmagicC_' . substr(basename($destName), 10) . '.' . $fI['extension'];
                     $destName = $fileFunc->getUniqueName($mainBase, $destPath);
                     @copy($imgI[3], $destName);
                     t3lib_div::fixPermissions($destName);
                     $destName = dirname($destName) . '/' . rawurlencode(basename($destName));
                     $iurl = $this->siteURL . substr($destName, strlen(PATH_site));
                     $this->imageInsertJS($iurl, $imgI[0], $imgI[1], $altText, $titleText, $additionalParams);
                 } else {
                     t3lib_div::sysLog('Attempt at creating a magic image failed due to error converting image: "' . $filepath . '".', $this->extKey . '/tx_rtehtmlarea_select_image', t3lib_div::SYSLOG_SEVERITY_ERROR);
                 }
             } else {
                 t3lib_div::sysLog('Attempt at creating a magic image failed due to incorrect destination path: "' . $destPath . '".', $this->extKey . '/tx_rtehtmlarea_select_image', t3lib_div::SYSLOG_SEVERITY_ERROR);
             }
         } else {
             t3lib_div::sysLog('Attempt at creating a magic image failed due to absent RTE_imageStorageDir', $this->extKey . '/tx_rtehtmlarea_select_image', t3lib_div::SYSLOG_SEVERITY_ERROR);
         }
     } else {
         t3lib_div::sysLog('Attempt at creating a magic image failed due to missing image file info.', $this->extKey . '/tx_rtehtmlarea_select_image', t3lib_div::SYSLOG_SEVERITY_ERROR);
     }
 }
 /**
  * [Describe function...]
  *
  * @return	[type]		...
  */
 function imageInsert()
 {
     global $TCA, $TYPO3_CONF_VARS;
     if (t3lib_div::_GP('insertImage')) {
         $filepath = t3lib_div::_GP('insertImage');
         $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
         $imgObj->init();
         $imgObj->mayScaleUp = 0;
         $imgObj->tempPath = PATH_site . $imgObj->tempPath;
         $imgInfo = $imgObj->getImageDimensions($filepath);
         $imgMetaData = tx_dam::meta_getDataForFile($filepath, 'uid,pid,alt_text,hpixels,vpixels,' . $this->imgTitleDAMColumn . ',' . $TCA['tx_dam']['ctrl']['languageField']);
         $imgMetaData = $this->getRecordOverlay('tx_dam', $imgMetaData, $this->sys_language_content);
         switch ($this->act) {
             case 'magic':
                 if (is_array($imgInfo) && count($imgInfo) == 4 && $this->rteImageStorageDir() && is_array($imgMetaData)) {
                     $fI = pathinfo($imgInfo[3]);
                     $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
                     $basename = $fileFunc->cleanFileName('RTEmagicP_' . $fI['basename']);
                     $destPath = PATH_site . $this->rteImageStorageDir();
                     if (@is_dir($destPath)) {
                         $destName = $fileFunc->getUniqueName($basename, $destPath);
                         @copy($imgInfo[3], $destName);
                         t3lib_div::fixPermissions($destName);
                         $cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'), 0, $this->magicMaxWidth);
                         $cHeight = t3lib_div::intInRange(t3lib_div::_GP('cHeight'), 0, $this->magicMaxHeight);
                         if (!$cWidth) {
                             $cWidth = $this->magicMaxWidth;
                         }
                         if (!$cHeight) {
                             $cHeight = $this->magicMaxHeight;
                         }
                         $imgI = $imgObj->imageMagickConvert($filepath, 'WEB', $cWidth . 'm', $cHeight . 'm');
                         // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
                         if ($imgI[3]) {
                             $fI = pathinfo($imgI[3]);
                             $mainBase = 'RTEmagicC_' . substr(basename($destName), 10) . '.' . $fI['extension'];
                             $destName = $fileFunc->getUniqueName($mainBase, $destPath);
                             @copy($imgI[3], $destName);
                             t3lib_div::fixPermissions($destName);
                             $iurl = $this->siteUrl . substr($destName, strlen(PATH_site));
                             $this->imageInsertJS($iurl, $imgI[0], $imgI[1], $imgMetaData['alt_text'], $imgMetaData[$this->imgTitleDAMColumn], substr($imgInfo[3], strlen(PATH_site)));
                         }
                     }
                 }
                 exit;
                 break;
             case 'plain':
                 if (is_array($imgInfo) && count($imgInfo) == 4 && is_array($imgMetaData)) {
                     $iurl = $this->siteUrl . substr($imgInfo[3], strlen(PATH_site));
                     $this->imageInsertJS($iurl, $imgMetaData['hpixels'], $imgMetaData['vpixels'], $imgMetaData['alt_text'], $imgMetaData[$this->imgTitleDAMColumn], substr($imgInfo[3], strlen(PATH_site)));
                 }
                 exit;
                 break;
         }
     }
 }
コード例 #15
0
    /**
     * Generates the module content
     *
     * @return	string		HTML content
     */
    function moduleContent($header = '', $description = '', $lastStep = 4)
    {
        global $BE_USER, $LANG, $BACK_PATH, $FILEMOUNTS;
        $content = '';
        switch ($this->getCurrentFunc()) {
            case 'index':
            case 'index1':
                // TODO make it possible to read preset if present in current folder
                $content .= parent::moduleContent($LANG->getLL('tx_dam_tools_indexsetup.start_point'), '<p style="margin:0.8em 0 1.2em 0">' . $LANG->getLL('tx_dam_tools_indexsetup.desc', true) . '</p>');
                break;
                //
                // setup summary
                //
            //
            // setup summary
            //
            case 'index4':
                $step = 4;
                $content .= $this->pObj->getPathInfoHeaderBar($this->pObj->pathInfo, FALSE, $this->cmdIcons);
                $content .= $this->pObj->doc->spacer(10);
                $header = $LANG->getLL('tx_damindex_index.setup_summary');
                $stepsBar = $this->getStepsBar($step, $lastStep, '', '', '', $LANG->getLL('tx_dam_tools_indexsetup.finish'));
                $content .= $this->pObj->doc->section($header, $stepsBar, 0, 1);
                $content .= '<strong>Set Options:</strong><table border="0" cellspacing="0" cellpadding="4" width="100%">' . $this->index->getIndexingOptionsInfo() . '</table>';
                $content .= $this->pObj->doc->spacer(10);
                $rec = array_merge($this->index->dataPreset, $this->index->dataPostset);
                $fixedFields = array_keys($this->index->dataPostset);
                $content .= '<strong>Meta data preset:</strong><br /><table border="0" cellpadding="4" width="100%"><tr><td bgcolor="' . $this->pObj->doc->bgColor3dim . '">' . $this->showPresetData($rec, $fixedFields) . '</td></tr></table>';
                $content .= $this->pObj->doc->spacer(10);
                break;
            case 'indexStart':
                $content .= $this->pObj->doc->section('Indexing default setup', '', 0, 1);
                $filename = '.indexing.setup.xml';
                $path = tx_dam::path_makeAbsolute($this->pObj->path);
                $content .= '</form>';
                $content .= $this->pObj->getFormTag();
                if (is_file($path . $filename) and is_readable($path . $filename)) {
                    $content .= '<br /><strong>Overwrite existing default indexer setup to this folder:</strong><br />' . htmlspecialchars($this->pObj->path) . '<br />';
                    $content .= '<br /><input type="submit" name="indexSave" value="Overwrite" />';
                } else {
                    $content .= '<br /><strong>Save default indexer setup for this folder:</strong><br />' . htmlspecialchars($this->pObj->path) . '<br />';
                    $content .= '<br /><input type="submit" name="indexSave" value="Save" />';
                }
                $content .= '<input type="hidden" name="setuptype" value="folder">';
                $content .= $this->pObj->doc->spacer(10);
                if (t3lib_extMgm::isLoaded('dam_cron')) {
                    $content .= $this->pObj->doc->section('CRON', '', 0, 1);
                    $path = $this->cronUploadsFolder;
                    $filename = $this->makeSetupfilenameForPath($this->pObj->path);
                    $content .= '</form>';
                    $content .= $this->pObj->getFormTag();
                    $content .= '<input type="hidden" name="setuptype" value="cron">';
                    $content .= '<br /><strong>Save setup as cron indexer setup:</strong><br />' . htmlspecialchars($path) . '<br />
								<input type="text" size="25" maxlength="25" name="filename" value="' . htmlspecialchars($filename) . '"> .xml';
                    $content .= '<br /><input type="submit" name="indexSave" value="Save" />';
                    $files = t3lib_div::getFilesInDir($path, 'xml', 0, 1);
                    $out = '';
                    foreach ($files as $file) {
                        $out .= htmlspecialchars($file) . '<br />';
                    }
                    if ($out) {
                        $content .= '<br /><br /><strong>Existing cron setups:</strong><div style="border-top:1px solid grey;border-bottom:1px solid grey;">' . $out . '</div><br />';
                    }
                }
                $extraSetup = '';
                $this->index->setPath($this->pObj->path);
                $this->index->setOptionsFromRules();
                $this->index->setPID($this->pObj->defaultPid);
                $this->index->enableMetaCollect(TRUE);
                $setup = $this->index->serializeSetup($extraSetup, false);
                $content .= $this->pObj->doc->section('Set Options', t3lib_div::view_array($setup), 0, 1);
                $content .= '<br /><textarea style="width:100%" rows="15">' . htmlspecialchars(str_replace('{', "{\n", $this->index->serializeSetup($extraSetup))) . '</textarea>';
                break;
            case 'indexSave':
                $content .= $this->pObj->getPathInfoHeaderBar($this->pObj->pathInfo, FALSE, $this->cmdIcons);
                $content .= $this->pObj->doc->spacer(10);
                $content .= '<div style="width:100%;text-align:right;">' . $this->pObj->btn_back() . '</div>';
                if (t3lib_div::_GP('setuptype') === 'folder') {
                    $path = tx_dam::path_makeAbsolute($this->pObj->path);
                    $filename = $path . '.indexing.setup.xml';
                } else {
                    $path = $this->cronUploadsFolder;
                    $filename = t3lib_div::_GP('filename');
                    $filename = $filename ? $filename : $this->makeSetupfilenameForPath($this->pObj->path);
                    $filename = $path . $filename . '.xml';
                }
                $this->index->setPath($this->pObj->path);
                $this->index->setOptionsFromRules();
                $this->index->setPID($this->pObj->defaultPid);
                $this->index->enableMetaCollect(TRUE);
                $setup = $this->index->serializeSetup($extraSetup);
                if ($handle = fopen($filename, 'wb')) {
                    if (fwrite($handle, $setup)) {
                        $content .= 'Setup written to file<br />' . htmlspecialchars($filename);
                    } else {
                        $content .= 'Can\'t write to file ' . htmlspecialchars($filename);
                    }
                    fclose($handle);
                    t3lib_div::fixPermissions($filename);
                } else {
                    $content .= 'Can\'t open file ' . htmlspecialchars($filename);
                }
                break;
            case 'cron_info':
                $content .= $this->pObj->getHeaderBar('', implode('&nbsp;', $this->cmdIcons));
                $content .= $this->pObj->doc->spacer(10);
                $files = t3lib_div::getFilesInDir($this->cronUploadsFolder, 'xml', 1, 1);
                $out = '';
                foreach ($files as $file) {
                    if ($file == $filename) {
                        $out .= '<strong>' . htmlspecialchars($file) . '</strong><br />';
                    } else {
                        $out .= htmlspecialchars($file) . '<br />';
                    }
                }
                $filename = $filename ? $filename : $file;
                if ($out) {
                    $content .= '<br /><br /><strong>Existing setups:</strong><div style="border-top:1px solid grey;border-bottom:1px solid grey;">' . $out . '</div><br />';
                } else {
                    $content .= '<br /><br /><strong>No setups available.</strong><br />';
                }
                if ($out) {
                    $cronscript = t3lib_extMgm::extPath('dam_cron') . 'cron/dam_indexer.php';
                    $content .= '<br /><strong>Call indexer script example:</strong><br />';
                    $content .= '<span style="font-family: monaco,courier,monospace;">/usr/bin/php ' . htmlspecialchars($cronscript) . ' --setup=' . htmlspecialchars($filename) . '</span>';
                }
                break;
            case 'doIndexing':
                break;
            default:
                $content .= parent::moduleContent($header, $description, $lastStep);
        }
        return $content;
    }
コード例 #16
0
 /**
  * Writes the input GDlib image pointer to file
  *
  * @param	pointer		The GDlib image resource pointer
  * @param	string		The filename to write to
  * @param	integer		The image quality (for JPEGs)
  * @return	boolean		The output of either imageGif, imagePng or imageJpeg based on the filename to write
  * @see maskImageOntoImage(), scale(), output()
  */
 function ImageWrite($destImg, $theImage, $quality = 0)
 {
     imageinterlace($destImg, 0);
     $ext = strtolower(substr($theImage, strrpos($theImage, '.') + 1));
     $result = FALSE;
     switch ($ext) {
         case 'jpg':
         case 'jpeg':
             if (function_exists('imageJpeg')) {
                 if ($quality == 0) {
                     $quality = $this->jpegQuality;
                 }
                 $result = imageJpeg($destImg, $theImage, $quality);
             }
             break;
         case 'gif':
             if (function_exists('imageGif')) {
                 imagetruecolortopalette($destImg, TRUE, 256);
                 $result = imageGif($destImg, $theImage);
             }
             break;
         case 'png':
             if (function_exists('imagePng')) {
                 $result = ImagePng($destImg, $theImage);
             }
             break;
     }
     if ($result) {
         t3lib_div::fixPermissions($theImage);
     }
     return $result;
 }
コード例 #17
0
 /**
  * Moves $source file to $destination if uploaded, otherwise try to make a copy
  * Usage: 4
  *
  * @param	string		Source file, absolute path
  * @param	string		Destination file, absolute path
  * @return	boolean		Returns true if the file was moved.
  * @coauthor	Dennis Petersen <*****@*****.**>
  * @see upload_to_tempfile()
  */
 function upload_copy_move($source, $destination)
 {
     if (is_uploaded_file($source)) {
         $uploaded = TRUE;
         // Return the value of move_uploaded_file, and if false the temporary $source is still around so the user can use unlink to delete it:
         $uploadedResult = move_uploaded_file($source, $destination);
     } else {
         $uploaded = FALSE;
         @copy($source, $destination);
     }
     t3lib_div::fixPermissions($destination);
     // Change the permissions of the file
     // If here the file is copied and the temporary $source is still around, so when returning false the user can try unlink to delete the $source
     return $uploaded ? $uploadedResult : FALSE;
 }
コード例 #18
0
	/**
	 * lessc
	 *
	 * @return void
	 */
	public function lessc( $files )
	{

		// create outputfolder if it does not exist
		if( !is_dir( $this->outputfolder ) )
		{
			t3lib_div::mkdir_deep( '', $this->outputfolder );
		}

		// compile each less-file
		foreach( $files as $file )
		{
			//get only the name of less file
			$filename = array_pop( explode( '/', $file ) );

			$md5 = md5( $filename . md5_file( $file ) );

			$outputfile = $this->outputfolder . substr( $filename, 0, -5 ) . '_' . $md5 . '.css';

			if( $this->configuration['other']['forceMode'] && file_exists( $outputfile ) )
			{
				unlink( $outputfile );
			}

			if( !file_exists( $outputfile ) )
			{
				$compressed = $this->configuration['other']['compressed'] ? '--compress' : '';

				/* Define directories for @import scripts */
				$importDirs = '';
				if( isset( $this->configuration['other']['importDirs'] ) )
				{
					$importDirs = implode( ':', Tx_T3Less_Utility_Utilities::splitAndResolveDirNames( $this->configuration['other']['importDirs'] ) );
				}

				$lesscCommand = sprintf( 'lessc %s --line-numbers=\'comments\' --include-path=%s %s > %s 2>&1', $compressed, $importDirs, $file, $outputfile );
				$lesscOutput = array( );
				$lesscStatus = 0;
				exec( $lesscCommand, $lesscOutput, $lesscStatus );

				t3lib_div::fixPermissions( $outputfile, FALSE );
			}
		}

		// unlink compiled files which have no equal source less-file
		if( $this->configuration['other']['unlinkCssFilesWithNoSourceFile'] == 1 )
		{
			$this->unlinkGeneratedFilesWithNoSourceFile( $files );
		}

		$files = t3lib_div::getFilesInDir( $this->outputfolder, "css" );
		//respect given sort order defined in TS
		usort( $files, array( $this, 'getSortOrderPhp' ) );

		foreach( $files as $cssFile )
		{
			$excludeFromPageRender = isset( $this->configuration['phpcompiler']['filesettings'][substr( $cssFile, 0, -37 )]['excludeFromPageRenderer'] ) ? $this->configuration['phpcompiler']['filesettings'][substr( $cssFile, 0, -37 )]['excludeFromPageRenderer'] : 0;
			if( !$excludeFromPageRender || $excludeFromPageRender == 0 )
			{
				// array with filesettings from TS
				$tsOptions = $this->configuration['phpcompiler']['filesettings'][substr( $cssFile, 0, -37 )];

				$GLOBALS['TSFE']->getPageRenderer()->addCssFile(
					$this->outputfolder . $cssFile, $rel = 'stylesheet', $media = isset( $tsOptions['media'] ) ? $tsOptions['media'] : 'all', $title = isset( $tsOptions['title'] ) ? $tsOptions['title'] : '', $compress = isset( $tsOptions['compress'] ) && $tsOptions['compress'] >= '0' ? (boolean) $tsOptions['compress'] : TRUE, $forceOnTop = isset( $tsOptions['forceOnTop'] ) && $tsOptions['forceOnTop'] >= '0' ? (boolean) $tsOptions['forceOnTop'] : FALSE, $allWrap = isset( $tsOptions['allWrap'] ) ? $tsOptions['allWrap'] : '', $excludeFromConcatenation = isset( $tsOptions['excludeFromConcatenation'] ) && $tsOptions['excludeFromConcatenation'] >= '0' ? (boolean) $tsOptions['excludeFromConcatenation'] : FALSE
				);
			}
		}
	}
コード例 #19
0
 /**
  * Converts a png file to jpg.
  * This converts a png file to jpg.
  *
  * @param string $theFile the filename with path
  * @return string new filename
  */
 public static function png_to_jpg_by_imagemagick($theFile)
 {
     if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] && $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'] && strtolower(substr($theFile, -4, 4)) == '.png' && @is_file($theFile)) {
         // IM
         $newFile = substr($theFile, 0, -4) . '.jpg';
         $cmd = t3lib_div::imageMagickCommand('convert', '"' . $theFile . '" "' . $newFile . '"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']);
         t3lib_utility_Command::exec($cmd);
         $theFile = $newFile;
         if (@is_file($newFile)) {
             t3lib_div::fixPermissions($newFile);
         }
         // unlink old file?? May be bad idea because TYPO3 would then recreate the file every time as
         // TYPO3 thinks the file is not generated because it's missing!! So do not unlink $theFile here!!
     }
     return $theFile;
 }
コード例 #20
0
 /**
  * Checks if t3lib_div::fixPermissions() does not fix permissions on not allowed path
  * This test assumes directory 'PATH_site'/typo3temp exists
  * This test is not available on windows OS
  *
  * @test
  * @see t3lib_div::fixPermissions()
  */
 public function checkFixPermissionsDoesNotSetPermissionsToNotAllowedPath()
 {
     if (TYPO3_OS == 'WIN') {
         $this->markTestSkipped('fixPermissions() tests not available on Windows');
     }
     // Create and prepare test file
     $filename = PATH_site . 'typo3temp/../typo3temp/' . uniqid('test_');
     touch($filename);
     chmod($filename, 0742);
     // Set target permissions and run method
     $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
     $fixPermissionsResult = t3lib_div::fixPermissions($filename);
     // Get actual permissions and clean up
     clearstatcache();
     $resultFilePermissions = substr(decoct(fileperms($filename)), 2);
     unlink($filename);
     // Test if everything was ok
     $this->assertFalse($fixPermissionsResult);
     $this->assertEquals($resultFilePermissions, '0742');
 }
コード例 #21
0
 /**
  * Processes uploaded files, moves them to a temporary upload folder, renames them if they already exist and
  * stores the information in user session
  *
  *
  * @return void
  * @author	Reinhard Führicht <*****@*****.**>
  */
 protected function processFiles()
 {
     $sessionFiles = Tx_Formhandler_Globals::$session->get('files');
     $tempFiles = $sessionFiles;
     //if files were uploaded
     if (isset($_FILES) && is_array($_FILES) && !empty($_FILES)) {
         //get upload folder
         $uploadFolder = Tx_Formhandler_StaticFuncs::getTempUploadFolder();
         //build absolute path to upload folder
         $uploadPath = Tx_Formhandler_StaticFuncs::getTYPO3Root() . $uploadFolder;
         if (!file_exists($uploadPath)) {
             Tx_Formhandler_StaticFuncs::debugMessage('folder_doesnt_exist', array($uploadPath), 3);
             return;
         }
         //for all file properties
         foreach ($_FILES as $sthg => $files) {
             //if a file was uploaded
             if (isset($files['name']) && is_array($files['name'])) {
                 //for all file names
                 foreach ($files['name'] as $field => $name) {
                     if (!isset($this->errors[$field])) {
                         $exists = FALSE;
                         if (is_array($sessionFiles[$field])) {
                             foreach ($sessionFiles[$field] as $idx => $fileOptions) {
                                 if ($fileOptions['name'] === $name) {
                                     $exists = TRUE;
                                 }
                             }
                         }
                         if (!$exists) {
                             $filename = substr($name, 0, strpos($name, '.'));
                             if (strlen($filename) > 0) {
                                 $ext = substr($name, strpos($name, '.'));
                                 $suffix = 1;
                                 $filename = str_replace(' ', '_', $filename);
                                 //build file name
                                 $uploadedFileName = $filename . $ext;
                                 //rename if exists
                                 while (file_exists($uploadPath . $uploadedFileName)) {
                                     $uploadedFileName = $filename . '_' . $suffix . $ext;
                                     $suffix++;
                                 }
                                 $files['name'][$field] = $uploadedFileName;
                                 //move from temp folder to temp upload folder
                                 move_uploaded_file($files['tmp_name'][$field], $uploadPath . $uploadedFileName);
                                 t3lib_div::fixPermissions($uploadPath . $uploadedFileName);
                                 $files['uploaded_name'][$field] = $uploadedFileName;
                                 //set values for session
                                 $tmp['name'] = $name;
                                 $tmp['uploaded_name'] = $uploadedFileName;
                                 $tmp['uploaded_path'] = $uploadPath;
                                 $tmp['uploaded_folder'] = $uploadFolder;
                                 $uploadedUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $uploadFolder . $uploadedFileName;
                                 $uploadedUrl = str_replace('//', '/', $uploadedUrl);
                                 $tmp['uploaded_url'] = $uploadedUrl;
                                 $tmp['size'] = $files['size'][$field];
                                 $tmp['type'] = $files['type'][$field];
                                 if (!is_array($tempFiles[$field]) && strlen($field) > 0) {
                                     $tempFiles[$field] = array();
                                 }
                                 array_push($tempFiles[$field], $tmp);
                                 if (!is_array($this->gp[$field])) {
                                     $this->gp[$field] = array();
                                 }
                                 array_push($this->gp[$field], $uploadedFileName);
                             }
                         }
                     }
                 }
             }
         }
     }
     Tx_Formhandler_Globals::$session->set('files', $tempFiles);
     Tx_Formhandler_StaticFuncs::debugMessage('Files:', array(), 1, (array) $tempFiles);
 }
コード例 #22
0
 /**
  * Insert a magic image
  *
  * @param	string		$filepath: the path to the image file
  * @param	array		$imgInfo: a 4-elements information array about the file
  * @param	string		$altText: text for the alt attribute of the image
  * @param	string		$titleText: text for the title attribute of the image
  * @param	string		$additionalParams: text representing more HTML attributes to be added on the img tag
  * @return	void
  */
 public function insertMagicImage($filepath, $imgInfo, $altText = '', $titleText = '', $additionalParams = '')
 {
     if (is_array($imgInfo) && count($imgInfo) == 4 && $this->RTEImageStorageDir) {
         $fI = pathinfo($imgInfo[3]);
         $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
         $basename = $fileFunc->cleanFileName('RTEmagicP_' . $fI['basename']);
         $destPath = PATH_site . $this->RTEImageStorageDir;
         if (@is_dir($destPath)) {
             $destName = $fileFunc->getUniqueName($basename, $destPath);
             @copy($imgInfo[3], $destName);
             t3lib_div::fixPermissions($destName);
             $cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'), 0, $this->magicMaxWidth);
             $cHeight = t3lib_div::intInRange(t3lib_div::_GP('cHeight'), 0, $this->magicMaxHeight);
             if (!$cWidth) {
                 $cWidth = $this->magicMaxWidth;
             }
             if (!$cHeight) {
                 $cHeight = $this->magicMaxHeight;
             }
             $imgI = $this->imgObj->imageMagickConvert($filepath, 'WEB', $cWidth . 'm', $cHeight . 'm');
             // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
             if ($imgI[3]) {
                 $fI = pathinfo($imgI[3]);
                 $mainBase = 'RTEmagicC_' . substr(basename($destName), 10) . '.' . $fI['extension'];
                 $destName = $fileFunc->getUniqueName($mainBase, $destPath);
                 @copy($imgI[3], $destName);
                 t3lib_div::fixPermissions($destName);
                 $destName = dirname($destName) . '/' . rawurlencode(basename($destName));
                 $iurl = $this->siteURL . substr($destName, strlen(PATH_site));
                 $this->imageInsertJS($iurl, $imgI[0], $imgI[1], $altText, $titleText, $additionalParams);
             }
         }
     }
 }
コード例 #23
0
 /**
  * Copying files and folders (action=2)
  *
  * @param	array		$cmds['data'] is the file/folder to copy. $cmds['target'] is the path where to copy to. $cmds['altName'] (boolean): If set, another filename is found in case the target already exists
  * @return	string		Returns the new filename upon success
  */
 function func_copy($cmds, $id)
 {
     if (!$this->isInit) {
         return FALSE;
     }
     // Initialize and check basic conditions:
     $theFile = $cmds['data'];
     $theDest = $this->is_directory($cmds['target']);
     // Clean up destination directory
     $altName = $cmds['altName'];
     // main log entry
     $this->log['cmd']['move'][$id] = array('errors' => array(), 'orig_filename' => $theFile, 'target_file' => '', 'target_folder' => '', 'target_path' => $theDest);
     if (!$theDest) {
         $this->writelog(2, 2, 100, 'Destination "%s" was not a directory', array($cmds['target']), 'copy', $id);
         return FALSE;
     }
     if (!$this->isPathValid($theFile) || !$this->isPathValid($theDest)) {
         $this->writelog(2, 2, 101, 'Target or destination had invalid path (".." and "//" is not allowed in path). T="%s", D="%s"', array($theFile, $theDest), 'copy', $id);
         return FALSE;
     }
     // Processing of file or directory.
     if (@is_file($theFile)) {
         // If we are copying a file...
         if ($this->actionPerms['copyFile']) {
             if (filesize($theFile) < $this->maxCopyFileSize * 1024) {
                 $fI = t3lib_div::split_fileref($theFile);
                 if ($altName) {
                     // If altName is set, we're allowed to create a new filename if the file already existed
                     $theDestFile = $this->getUniqueName($fI['file'], $theDest);
                     $fI = t3lib_div::split_fileref($theDestFile);
                 } else {
                     $theDestFile = $theDest . '/' . $fI['file'];
                 }
                 if ($theDestFile && !@file_exists($theDestFile)) {
                     if ($this->checkIfAllowed($fI['fileext'], $theDest, $fI['file'])) {
                         if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile)) {
                             if ($this->PHPFileFunctions) {
                                 copy($theFile, $theDestFile);
                             } else {
                                 $cmd = 'cp "' . $theFile . '" "' . $theDestFile . '"';
                                 exec($cmd);
                             }
                             t3lib_div::fixPermissions($theDestFile);
                             clearstatcache();
                             if (@is_file($theDestFile)) {
                                 $this->writelog(2, 0, 1, 'File "%s" copied to "%s"', array($theFile, $theDestFile), 'copy', $id);
                                 $this->log['cmd']['move'][$id]['target_file'] = $theDestFile;
                                 // update meta data
                                 if ($this->processMetaUpdate) {
                                     tx_dam::notify_fileCopied($theFile, $theDestFile);
                                 }
                                 return $theDestFile;
                             } else {
                                 $this->writelog(2, 2, 109, 'File "%s" WAS NOT copied to "%s"! Write-permission problem?', array($theFile, $theDestFile), 'copy', $id);
                             }
                         } else {
                             $this->writelog(2, 1, 110, 'Target or destination was not within your mountpoints! T="%s", D="%s"', array($theFile, $theDestFile), 'copy', $id);
                         }
                     } else {
                         $this->writelog(2, 1, 111, 'Fileextension "%s" is not allowed in "%s"!', array($fI['fileext'], $theDest . '/'), 'copy', $id);
                     }
                 } else {
                     $this->writelog(2, 1, 112, 'File "%s" already exists!', array($theDestFile), 'copy', $id);
                 }
             } else {
                 $this->writelog(2, 1, 113, 'File "%s" exceeds the size-limit of %s bytes', array($theFile, $this->maxCopyFileSize * 1024), 'copy', $id);
             }
         } else {
             $this->writelog(2, 1, 114, 'You are not allowed to copy files', '', 'copy', $id);
         }
         // FINISHED copying file
     } elseif (@is_dir($theFile) && !$this->dont_use_exec_commands) {
         // if we're copying a folder
         if ($this->actionPerms['copyFolder']) {
             $theFile = $this->is_directory($theFile);
             if ($theFile) {
                 $fI = t3lib_div::split_fileref($theFile);
                 if ($altName) {
                     // If altName is set, we're allowed to create a new filename if the file already existed
                     $theDestFile = $this->getUniqueName($fI['file'], $theDest);
                     $fI = t3lib_div::split_fileref($theDestFile);
                 } else {
                     $theDestFile = $theDest . '/' . $fI['file'];
                 }
                 if ($theDestFile && !@file_exists($theDestFile)) {
                     if (!t3lib_div::isFirstPartOfStr($theDestFile . '/', $theFile . '/')) {
                         // Check if the one folder is inside the other or on the same level... to target/dest is the same?
                         if ($this->checkIfFullAccess($theDest) || $this->is_webPath($theDestFile) == $this->is_webPath($theFile)) {
                             // no copy of folders between spaces
                             if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile)) {
                                 // No way to do this under windows!
                                 $cmd = 'cp -R "' . $theFile . '" "' . $theDestFile . '"';
                                 exec($cmd);
                                 clearstatcache();
                                 if (@is_dir($theDestFile)) {
                                     $this->writelog(2, 0, 2, 'Directory "%s" copied to "%s"', array($theFile, $theDestFile), 'copy', $id);
                                     $this->log['cmd']['move'][$id]['target_folder'] = $theDestFile;
                                     // update meta data
                                     if ($this->processMetaUpdate) {
                                         tx_dam::notify_fileCopied($theFile, $theDestFile);
                                     }
                                     return $theDestFile;
                                 } else {
                                     $this->writelog(2, 2, 119, 'Directory "%s" WAS NOT copied to "%s"! Write-permission problem?', array($theFile, $theDestFile), 'copy', $id);
                                 }
                             } else {
                                 $this->writelog(2, 1, 120, 'Target or destination was not within your mountpoints! T="%s", D="%s"', array($theFile, $theDestFile), 'copy', $id);
                             }
                         } else {
                             $this->writelog(2, 1, 121, 'You don\'t have full access to the destination directory "%s"!', array($theDest . '/'), 'copy', $id);
                         }
                     } else {
                         $this->writelog(2, 1, 122, 'Destination cannot be inside the target! D="%s", T="%s"', array($theDestFile . '/', $theFile . '/'), 'copy', $id);
                     }
                 } else {
                     $this->writelog(2, 1, 123, 'Target "%s" already exists!', array($theDestFile), 'copy', $id);
                 }
             } else {
                 $this->writelog(2, 2, 124, 'Target seemed not to be a directory! (Shouldn\'t happen here!)', '', 'copy', $id);
             }
         } else {
             $this->writelog(2, 1, 125, 'You are not allowed to copy directories', '', 'copy', $id);
         }
         // FINISHED copying directory
     } else {
         $this->writelog(2, 2, 130, 'The item "%s" was not a file or directory!', array($theFile), 'copy', $id);
     }
 }
コード例 #24
0
 /**
  * Initialize file-based statistics handling: Check filename and permissions, and create the logfile if it does not exist yet.
  * This function should be called with care because it might overwrite existing settings otherwise.
  *
  * @return	boolean		True if statistics are enabled (will require some more processing after charset handling is initialized)
  * @access private
  */
 protected function statistics_init()
 {
     $setStatPageName = false;
     $theLogFile = $this->TYPO3_CONF_VARS['FE']['logfile_dir'] . strftime($this->config['config']['stat_apache_logfile']);
     // Add PATH_site left to $theLogFile if the path is not absolute yet
     if (!t3lib_div::isAbsPath($theLogFile)) {
         $theLogFile = PATH_site . $theLogFile;
     }
     if ($this->config['config']['stat_apache'] && $this->config['config']['stat_apache_logfile'] && !strstr($this->config['config']['stat_apache_logfile'], '/')) {
         if (t3lib_div::isAllowedAbsPath($theLogFile)) {
             if (!@is_file($theLogFile)) {
                 touch($theLogFile);
                 // Try to create the logfile
                 t3lib_div::fixPermissions($theLogFile);
             }
             if (@is_file($theLogFile) && @is_writable($theLogFile)) {
                 $this->config['stat_vars']['logFile'] = $theLogFile;
                 $setStatPageName = true;
                 // Set page name later on
             } else {
                 $GLOBALS['TT']->setTSlogMessage('Could not set logfile path. Check filepath and permissions.', 3);
             }
         }
     }
     return $setStatPageName;
 }
コード例 #25
0
	/**
	 * lessPhp
	 *
	 * @return void
	 */
	public function lessPhp( $files )
	{
		require_once (t3lib_extMgm::extPath( 't3_less' ) . 'Resources/Private/Lib/' . $this->configuration['other']['lessPhpScriptPath']);

		// create outputfolder if it does not exist
		if( !is_dir( $this->outputfolder ) )
		{
			t3lib_div::mkdir_deep( '', $this->outputfolder );
		}

		$less = t3lib_div::makeInstance( 'lessc' );
		$this->checkForAdditionalConfiguration( $less );


		// compile each less-file
		foreach( $files as $file )
		{
			//get only the name of less file
			$filename = array_pop( explode( '/', $file ) );

			$md5 = md5( $filename . md5_file( $file ) );

			$outputfile = $this->outputfolder . substr( $filename, 0, -5 ) . '_' . $md5 . '.css';

			if( $this->configuration['other']['forceMode'] )
			{
				unlink( $outputfile );
			}

			if( !file_exists( $outputfile ) )
			{
				if( $this->configuration['other']['compressed'] )
				{
					$less->setFormatter( "compressed" );
					lessc::ccompile( $file, $this->outputfolder . substr( $filename, 0, -5 ) . '_' . $md5 . '.css', $less );
				}
				else
				{
					lessc::ccompile( $file, $this->outputfolder . substr( $filename, 0, -5 ) . '_' . $md5 . '.css' );
				}
				t3lib_div::fixPermissions( $outputfile, FALSE );
			}
		}

		// unlink compiled files which have no equal source less-file
		if( $this->configuration['other']['unlinkCssFilesWithNoSourceFile'] == 1 )
		{
			$this->unlinkGeneratedFilesWithNoSourceFile( $files );
		}

		$files = t3lib_div::getFilesInDir( $this->outputfolder, "css" );
		//respect given sort order defined in TS
		usort( $files, array( $this, 'getSortOrderPhp' ) );

		foreach( $files as $cssFile )
		{
			$excludeFromPageRender = isset( $this->configuration['phpcompiler']['filesettings'][substr( $cssFile, 0, -37 )]['excludeFromPageRenderer'] ) ? $this->configuration['phpcompiler']['filesettings'][substr( $cssFile, 0, -37 )]['excludeFromPageRenderer'] : 0;
			if( !$excludeFromPageRender || $excludeFromPageRender == 0 )
			{
				// array with filesettings from TS
				$tsOptions = $this->configuration['phpcompiler']['filesettings'][substr( $cssFile, 0, -37 )];

				$GLOBALS['TSFE']->getPageRenderer()->addCssFile(
					$this->outputfolder . $cssFile, $rel = 'stylesheet', $media = isset( $tsOptions['media'] ) ? $tsOptions['media'] : 'all', $title = isset( $tsOptions['title'] ) ? $tsOptions['title'] : '', $compress = isset( $tsOptions['compress'] ) && $tsOptions['compress'] >= '0' ? (boolean) $tsOptions['compress'] : TRUE, $forceOnTop = isset( $tsOptions['forceOnTop'] ) && $tsOptions['forceOnTop'] >= '0' ? (boolean) $tsOptions['forceOnTop'] : FALSE, $allWrap = isset( $tsOptions['allWrap'] ) ? $tsOptions['allWrap'] : '', $excludeFromConcatenation = isset( $tsOptions['excludeFromConcatenation'] ) && $tsOptions['excludeFromConcatenation'] >= '0' ? (boolean) $tsOptions['excludeFromConcatenation'] : FALSE
				);
			}
		}
	}
コード例 #26
0
 /**
  * Write the icon in $im pointer to $path
  *
  * @param	pointer		Pointer to GDlib image resource
  * @param	string		Absolute path to the filename in which to write the icon.
  * @return	void
  * @access private
  */
 public static function imagemake($im, $path)
 {
     if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
         @ImagePng($im, $path);
     } else {
         @ImageGif($im, $path);
     }
     if (@is_file($path)) {
         t3lib_div::fixPermissions($path);
     }
 }