/**
  * Constructor
  */
 public function __construct()
 {
     // we check for existance of our targetDirectory
     if (!is_dir(PATH_site . $this->targetDirectory)) {
         t3lib_div::mkdir(PATH_site . $this->targetDirectory);
     }
     // if enabled, we check whether we should auto-create the .htaccess file
     if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['generateApacheHtaccess']) {
         // check whether .htaccess exists
         $htaccessPath = PATH_site . $this->targetDirectory . '.htaccess';
         if (!file_exists($htaccessPath)) {
             t3lib_div::writeFile($htaccessPath, $this->htaccessTemplate);
         }
     }
     // decide whether we should create gzipped versions or not
     $compressionLevel = $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['compressionLevel'];
     // we need zlib for gzencode()
     if (extension_loaded('zlib') && $compressionLevel) {
         $this->createGzipped = TRUE;
         // $compressionLevel can also be TRUE
         if (t3lib_div::testInt($compressionLevel)) {
             $this->gzipCompressionLevel = intval($compressionLevel);
         }
     }
 }
 /**
  * Check if the icon cache has to be rebuild, instantiate and call the handler class if so.
  *
  * @param boolean Suppress regeneration if false (useful for feediting)
  * @return void
  */
 function __construct($allowRegeneration = TRUE)
 {
     // Create temp directory if missing
     if (!is_dir(PATH_site . self::$tempPath)) {
         t3lib_div::mkdir(PATH_site . self::$tempPath);
     }
     // Backwards compatibility handling for API calls <= 4.3, will be removed in 4.7
     $this->compatibilityCalls();
     // Create cache filename, the hash includes all icons, registered CSS styles registered and the extension list
     $this->tempFileName = PATH_site . self::$tempPath . md5(serialize($GLOBALS['TBE_STYLES']['spritemanager']) . md5(serialize($GLOBALS['TBE_STYLES']['spriteIconApi']['coreSpriteImageNames'])) . $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList']) . '.inc';
     // Regenerate cache file if not already existing
     if (!@file_exists($this->tempFileName)) {
         if ($allowRegeneration) {
             $handlerClass = $GLOBALS['TYPO3_CONF_VARS']['BE']['spriteIconGenerator_handler'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['spriteIconGenerator_handler'] : 't3lib_spritemanager_SimpleHandler';
             $this->handler = t3lib_div::makeInstance($handlerClass);
             // Throw exception if handler class does not implement required interface
             if (!$this->handler || !$this->handler instanceof t3lib_spritemanager_SpriteIconGenerator) {
                 throw new Exception("class in TYPO3_CONF_VARS[BE][spriteIconGenerator_handler] does not exist,\n\t\t\t\t\t\tor does not implement t3lib_spritemanager_SpriteIconGenerator");
             }
             $this->rebuildCache();
         } else {
             // Set tempFileName to existing file if regeneration is not allowed
             list($this->tempFileName) = t3lib_div::getFilesInDir(PATH_site . self::$tempPath, 'inc', TRUE);
         }
     }
 }
 /**
  * class constructor checks if cache has to be rebuild and initiates the rebuild
  * instantiates the handler class
  *
  * @param boolean $regenerate	with set to false, cache won't be regenerated if needed (useful for feediting)
  * @return void
  */
 function __construct($regenerate = TRUE)
 {
     // we check for existance of our targetDirectory
     if (!is_dir(PATH_site . self::$tempPath)) {
         t3lib_div::mkdir(PATH_site . self::$tempPath);
     }
     // create a fileName, the hash includes all icons and css-styles registered and the extlist
     $this->tempFileName = PATH_site . self::$tempPath . md5(serialize($GLOBALS['TBE_STYLES']['spritemanager']) . md5(serialize($GLOBALS['TBE_STYLES']['spriteIconApi']['coreSpriteImageNames'])) . $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList']) . '.inc';
     // if no cache-file for the current config ist present, regenerate it
     if (!@file_exists($this->tempFileName)) {
         // regenerate if allowed
         if ($regenerate) {
             $handlerClass = $GLOBALS['TYPO3_CONF_VARS']['BE']['spriteIconGenerator_handler'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['spriteIconGenerator_handler'] : 't3lib_spritemanager_SimpleHandler';
             $this->handler = t3lib_div::makeInstance($handlerClass);
             // check if the handler could be loaded and implements the needed interface
             if (!$this->handler || !$this->handler instanceof t3lib_spritemanager_SpriteIconGenerator) {
                 throw new Exception("class in TYPO3_CONF_VARS[BE][spriteIconGenerator_handler] does not exist,\n\t\t\t\t\t\tor does not implement t3lib_spritemanager_SpriteIconGenerator");
             }
             // all went good? to go for rebuild
             $this->rebuildCache();
         } else {
             // use old file if present
             list($this->tempFileName) = t3lib_div::getFilesInDir(PATH_site . self::$tempPath, 'inc', 1);
         }
     }
 }
Example #4
0
				/**
				 * Initializes the Module
				 * @return	void
				 */
				function init()	{
					global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;

					parent::init();
                    $this->extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['rzdummyimage']);
                    $store_path = $this->extConf['storePath']; 
                    if($store_path == '') $store_path = 'fileadmin/user_upload/rzdummyimage';

                    t3lib_div::mkdir(PATH_site . $store_path);
				}
 /**
  * Checks for several directories being writable.
  *
  * @return tx_reports_reports_status_Status	An tx_reports_reports_status_Status object indicating the status of the file system
  */
 protected function getFileSystemStatus()
 {
     $value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_writable');
     $message = '';
     $severity = tx_reports_reports_status_Status::OK;
     // Requirement level
     // -1 = not required, but if it exists may be writable or not
     //  0 = not required, if it exists the dir should be writable
     //  1 = required, don't has to be writable
     //  2 = required, has to be writable
     $checkWritable = array('typo3temp/' => 2, 'typo3temp/pics/' => 2, 'typo3temp/temp/' => 2, 'typo3temp/llxml/' => 2, 'typo3temp/cs/' => 2, 'typo3temp/GB/' => 2, 'typo3temp/locks/' => 2, 'typo3conf/' => 2, 'typo3conf/ext/' => 0, 'typo3conf/l10n/' => 0, TYPO3_mainDir . 'ext/' => -1, 'uploads/' => 2, 'uploads/pics/' => 0, 'uploads/media/' => 0, 'uploads/tf/' => 0, $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => -1, $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => 0);
     foreach ($checkWritable as $relPath => $requirementLevel) {
         if (!@is_dir(PATH_site . $relPath)) {
             // If the directory is missing, try to create it
             t3lib_div::mkdir(PATH_site . $relPath);
         }
         if (!@is_dir(PATH_site . $relPath)) {
             if ($requirementLevel > 0) {
                 // directory is required
                 $value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_missingDirectory');
                 $message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryDoesNotExistCouldNotCreate'), $relPath) . '<br />';
                 $severity = tx_reports_reports_status_Status::ERROR;
             } else {
                 $message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryDoesNotExist'), $relPath);
                 if ($requirementLevel == 0) {
                     $message .= ' ' . $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryShouldAlsoBeWritable');
                 }
                 $message .= '<br />';
                 if ($severity < tx_reports_reports_status_Status::WARNING) {
                     $value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_nonExistingDirectory');
                     $severity = tx_reports_reports_status_Status::WARNING;
                 }
             }
         } else {
             if (!is_writable(PATH_site . $relPath)) {
                 switch ($requirementLevel) {
                     case 0:
                         $message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryShouldBeWritable'), PATH_site . $relPath) . '<br />';
                         if ($severity < tx_reports_reports_status_Status::WARNING) {
                             $value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_recommendedWritableDirectory');
                             $severity = tx_reports_reports_status_Status::WARNING;
                         }
                         break;
                     case 2:
                         $value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_requiredWritableDirectory');
                         $message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryMustBeWritable'), PATH_site . $relPath) . '<br />';
                         $severity = tx_reports_reports_status_Status::ERROR;
                         break;
                 }
             }
         }
     }
     return t3lib_div::makeInstance('tx_reports_reports_status_Status', $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_fileSystem'), $value, $message, $severity);
 }
 /**
  * (non-PHPdoc)
  * @see tx_mklib_tests_DBTestCaseSkeleton::setUp()
  */
 public function setUp()
 {
     if (!t3lib_extMgm::isLoaded('dam')) {
         $this->markTestSkipped('DAM ist nicht installiert');
     }
     parent::setUp();
     $this->sTempFolder = t3lib_extMgm::extPath('mklib') . 'tests/typo3temp';
     t3lib_div::mkdir($this->sTempFolder);
     $sImageFile = 'test.jpg';
     $this->sAbsoluteImagePath = $this->sTempFolder . '/' . $sImageFile;
     touch($this->sAbsoluteImagePath);
     $this->sRelativeImagePath = 'typo3conf/ext/mklib/tests/typo3temp/' . $sImageFile;
 }
 private static function createTestfiles($testfolder)
 {
     t3lib_div::mkdir($testfolder);
     $files = array(array($testfolder . '/', 'test.zip'), array($testfolder . '/', 'test.xml'), array($testfolder . '/', 'test.tmp'), array($testfolder . '/', 'test.dat'), array($testfolder . '/sub/', 'test.zip'), array($testfolder . '/sub/', 'test.tmp'), array($testfolder . '/sub/sub/', 'test.xml'), array($testfolder . '/sub/sub/', 'test.dat'));
     foreach ($files as $file) {
         $path = $file[0];
         $file = $file[1];
         if (!is_dir($path)) {
             t3lib_div::mkdir($path);
         }
         $iH = fopen($path . $file, "w+");
         fwrite($iH, 'This is an automatic generated testfile and can be removed.');
         fclose($iH);
     }
 }
 function head()
 {
     global $TYPO3_CONF_VARS;
     global $TYPO3_CONF_VARS, $FILEMOUNTS;
     if (!is_object($GLOBALS['SOBE']->basicFF)) {
         $GLOBALS['SOBE']->basicFF = t3lib_div::makeInstance('t3lib_basicFileFunctions');
         $GLOBALS['SOBE']->basicFF->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
     }
     $this->pObj->guiCmdIconsDeny[] = 'popup';
     $this->cronUploadsFolder = PATH_site . $this->cronUploadsFolder;
     if (!is_dir($this->cronUploadsFolder)) {
         t3lib_div::mkdir($this->cronUploadsFolder);
     }
     return parent::head();
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     // we check for existance of our targetDirectory
     if (!is_dir(PATH_site . $this->targetDirectory)) {
         t3lib_div::mkdir(PATH_site . $this->targetDirectory);
     }
     // decide whether we should create gzipped versions or not
     $compressionLevel = $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['compressionLevel'];
     // we need zlib for gzencode()
     if (extension_loaded('zlib') && $compressionLevel) {
         $this->createGzipped = TRUE;
         // $compressionLevel can also be TRUE
         if (t3lib_div::testInt($compressionLevel)) {
             $this->gzipCompressionLevel = $compressionLevel;
         }
     }
 }
 /**
  * @test
  * @author Robert Lemke <*****@*****.**>
  */
 public function setCacheDirectoryThrowsExceptionOnNonWritableDirectory()
 {
     if (TYPO3_OS == 'WIN') {
         $this->markTestSkipped('test not reliable in Windows environment');
     }
     // Create test directory and remove write permissions
     $directoryName = PATH_site . 'typo3temp/' . uniqid('test_');
     t3lib_div::mkdir($directoryName);
     chmod($directoryName, 1551);
     try {
         $this->backend->setCacheDirectory($directoryName);
         $this->fail('setCacheDirectory did not throw an exception on a non writable directory');
     } catch (t3lib_cache_Exception $e) {
         // Remove created test directory
         t3lib_div::rmdir($directoryName);
     }
 }
 /**
  * Interface function. This will be called from the sprite manager to
  * refresh all caches.
  *
  * @return void
  */
 public function generate()
 {
     $this->generatorInstance = t3lib_div::makeInstance('t3lib_spritemanager_SpriteGenerator', 'GeneratorHandler');
     $this->generatorInstance->setOmmitSpriteNameInIconName(TRUE)->setIncludeTimestampInCSS(TRUE)->setSpriteFolder(t3lib_SpriteManager::$tempPath)->setCSSFolder(t3lib_SpriteManager::$tempPath);
     $iconsToProcess = array_merge((array) $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons'], $this->collectTcaSpriteIcons());
     foreach ($iconsToProcess as $iconName => $iconFile) {
         $iconsToProcess[$iconName] = t3lib_div::resolveBackPath('typo3/' . $iconFile);
     }
     $generatorResponse = $this->generatorInstance->generateSpriteFromArray($iconsToProcess);
     if (!is_dir(PATH_site . t3lib_SpriteManager::$tempPath . 'ie6')) {
         t3lib_div::mkdir(PATH_site . t3lib_SpriteManager::$tempPath . 'ie6');
     }
     t3lib_div::upload_copy_move($generatorResponse['spriteGifImage'], t3lib_div::dirname($generatorResponse['spriteGifImage']) . '/ie6/' . basename($generatorResponse['spriteGifImage']));
     unlink($generatorResponse['spriteGifImage']);
     t3lib_div::upload_copy_move($generatorResponse['cssGif'], t3lib_div::dirname($generatorResponse['cssGif']) . '/ie6/' . basename($generatorResponse['cssGif']));
     unlink($generatorResponse['cssGif']);
     $this->iconNames = array_merge($this->iconNames, $generatorResponse['iconNames']);
     parent::generate();
 }
 /**
  *
  * @param Tx_ExtensionBuilder_Domain_Model_Extension $extension
  * @param string $backupDir
  *
  * @return void
  */
 static function backupExtension($extension, $backupDir)
 {
     if (empty($backupDir)) {
         throw new Exception('Please define a backup directory in extension configuration!');
     } else {
         if (!t3lib_div::validPathStr($backupDir)) {
             throw new Exception('Backup directory is not a valid path: ' . $backupDir);
         } else {
             if (t3lib_div::isAbsPath($backupDir)) {
                 if (!t3lib_div::isAllowedAbsPath($backupDir)) {
                     throw new Exception('Backup directory is not an allowed absolute path: ' . $backupDir);
                 }
             } else {
                 $backupDir = PATH_site . $backupDir;
             }
         }
     }
     if (strrpos($backupDir, '/') < strlen($backupDir) - 1) {
         $backupDir .= '/';
     }
     if (!is_dir($backupDir)) {
         throw new Exception('Backup directory does not exist: ' . $backupDir);
     } else {
         if (!is_writable($backupDir)) {
             throw new Exception('Backup directory is not writable: ' . $backupDir);
         }
     }
     $backupDir .= $extension->getExtensionKey();
     // create a subdirectory for this extension
     if (!is_dir($backupDir)) {
         t3lib_div::mkdir($backupDir);
     }
     if (strrpos($backupDir, '/') < strlen($backupDir) - 1) {
         $backupDir .= '/';
     }
     $backupDir .= date('Y-m-d-') . time();
     if (!is_dir($backupDir)) {
         t3lib_div::mkdir($backupDir);
     }
     $extensionDir = substr($extension->getExtensionDir(), 0, strlen($extension->getExtensionDir()) - 1);
     try {
         self::recurse_copy($extensionDir, $backupDir);
     } catch (Exception $e) {
         throw new Exception('Code generation aborted:' . $e->getMessage());
     }
     t3lib_div::devlog('Backup created in ' . $backupDir, 'extension_builder', 0);
 }
 /**
  * Returns true if directory exists  and if it doesn't it will create directory and return true if that succeeded.
  *
  * @param	string		Directory to create. Having a trailing slash. Must be in fileadmin/. Relative to PATH_site
  * @return	boolean		True, if directory exists (was created)
  */
 function checkOrCreateDir($dirPrefix)
 {
     // Split dir path and remove first directory (which should be "fileadmin")
     $filePathParts = explode('/', $dirPrefix);
     $firstDir = array_shift($filePathParts);
     if ($firstDir === $this->fileadminFolderName && t3lib_div::getFileAbsFileName($dirPrefix)) {
         $pathAcc = '';
         foreach ($filePathParts as $dirname) {
             $pathAcc .= '/' . $dirname;
             if (strlen($dirname)) {
                 if (!@is_dir(PATH_site . $this->fileadminFolderName . $pathAcc)) {
                     if (!t3lib_div::mkdir(PATH_site . $this->fileadminFolderName . $pathAcc)) {
                         $this->error('ERROR: Directory could not be created....B');
                         return FALSE;
                     }
                 }
             } elseif ($dirPrefix === $this->fileadminFolderName . $pathAcc) {
                 return TRUE;
             } else {
                 $this->error('ERROR: Directory could not be created....A');
             }
         }
     }
 }
 /**
  * Writes $content to a filename in the typo3temp/ folder (and possibly a subfolder...)
  * Accepts an additional subdirectory in the file path!
  *
  * @param	string		Absolute filepath to write to inside "typo3temp/". First part of this string must match PATH_site."typo3temp/"
  * @param	string		Content string to write
  * @return	string		Returns false on success, otherwise an error string telling about the problem.
  */
 function writeFileToTypo3tempDir($filepath, $content)
 {
     // Parse filepath into directory and basename:
     $fI = pathinfo($filepath);
     $fI['dirname'] .= '/';
     // Check parts:
     if (t3lib_div::validPathStr($filepath) && $fI['basename'] && strlen($fI['basename']) < 60) {
         if (defined('PATH_site')) {
             $dirName = PATH_site . 'typo3temp/';
             // Setting main temporary directory name (standard)
             if (@is_dir($dirName)) {
                 if (t3lib_div::isFirstPartOfStr($fI['dirname'], $dirName)) {
                     // Checking if the "subdir" is found:
                     $subdir = substr($fI['dirname'], strlen($dirName));
                     if ($subdir) {
                         if (ereg('^[[:alnum:]_]+\\/$', $subdir)) {
                             $dirName .= $subdir;
                             if (!@is_dir($dirName)) {
                                 t3lib_div::mkdir($dirName);
                             }
                         } else {
                             return 'Subdir, "' . $subdir . '", was NOT on the form "[a-z]/"';
                         }
                     }
                     // Checking dir-name again (sub-dir might have been created):
                     if (@is_dir($dirName)) {
                         if ($filepath == $dirName . $fI['basename']) {
                             t3lib_div::writeFile($filepath, $content);
                             if (!@is_file($filepath)) {
                                 return 'File not written to disk! Write permission error in filesystem?';
                             }
                         } else {
                             return 'Calculated filelocation didn\'t match input $filepath!';
                         }
                     } else {
                         return '"' . $dirName . '" is not a directory!';
                     }
                 } else {
                     return '"' . $fI['dirname'] . '" was not within directory PATH_site + "typo3temp/"';
                 }
             } else {
                 return 'PATH_site + "typo3temp/" was not a directory!';
             }
         } else {
             return 'PATH_site constant was NOT defined!';
         }
     } else {
         return 'Input filepath "' . $filepath . '" was generally invalid!';
     }
 }
 /**
  * Creates subdirectory in typo3temp/ if not already found.
  *
  * @param	string		Name of sub directory
  * @return	boolean		Result of t3lib_div::mkdir(), true if it went well.
  */
 function createTempSubDir($dirName)
 {
     // Checking if the this->tempPath is already prefixed with PATH_site and if not, prefix it with that constant.
     if (t3lib_div::isFirstPartOfStr($this->tempPath, PATH_site)) {
         $tmpPath = $this->tempPath;
     } else {
         $tmpPath = PATH_site . $this->tempPath;
     }
     // Making the temporary filename:
     if (!@is_dir($tmpPath . $dirName)) {
         return t3lib_div::mkdir($tmpPath . $dirName);
     }
 }
 /**
  * Constructor. Starts PHP session handling in our own private store
  *
  * Side-effect: might set a cookie, so must be called before any other output.
  */
 public function __construct()
 {
     $this->typo3tempPath = PATH_site . 'typo3temp/';
     // Start our PHP session early so that hasSession() works
     $sessionSavePath = $this->getSessionSavePath();
     if (!is_dir($sessionSavePath)) {
         if (!t3lib_div::mkdir($sessionSavePath)) {
             die('Could not create session folder in typo3temp/. Make sure it is writeable!');
         }
         t3lib_div::writeFile($sessionSavePath . '/.htaccess', 'Order deny, allow' . "\n" . 'Deny from all' . "\n");
         $indexContent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
         $indexContent .= '<HTML><HEAD<TITLE></TITLE><META http-equiv=Refresh Content="0; Url=../../">';
         $indexContent .= '</HEAD></HTML>';
         t3lib_div::writeFile($sessionSavePath . '/index.html', $indexContent);
     }
     // Register our "save" session handler
     session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc'));
     session_save_path($sessionSavePath);
     session_name($this->cookieName);
     ini_set('session.cookie_path', t3lib_div::getIndpEnv('TYPO3_SITE_PATH'));
     // Always call the garbage collector to clean up stale session files
     ini_set('session.gc_probability', 100);
     ini_set('session.gc_divisor', 100);
     ini_set('session.gc_maxlifetime', $this->expireTimeInMinutes * 2 * 60);
     if (version_compare(phpversion(), '5.2', '<')) {
         ini_set('session.cookie_httponly', TRUE);
     }
     session_start();
 }
Example #17
0
 /**
  * Creates the upload folder if it does not exist yet.
  *
  * @return void
  *
  * @throws t3lib_exception
  */
 protected function createDummyUploadFolder()
 {
     if (is_dir($this->getUploadFolderPath())) {
         return;
     }
     if (t3lib_div::mkdir($this->getUploadFolderPath())) {
         // registers the upload folder as dummy folder
         $this->dummyFolders['uploadFolder'] = $this->getUploadFolderPath();
     } else {
         throw new t3lib_exception('The upload folder ' . $this->getUploadFolderPath() . ' could not be created.', 1334439408);
     }
 }
 function customAjaxPage(&$params, &$ref)
 {
     error_log("customAjaxPage hook");
     error_log("products path: " . $ref->ms['image_paths']['products']['original']);
     $ref->ms['image_paths']['variants']['original'] = 'uploads/tx_msvariants/images/original';
     error_log("variants path: " . $ref->ms['image_paths']['variants']['original']);
     if ($ref->ADMIN_USER) {
         if (isset($_SERVER["CONTENT_LENGTH"])) {
             //        switch ($ref->get['file_type']) {
             //          case 'variants_image':
             //          for ($x=0; $x<$ref->ms['MODULES']['NUMBER_OF_PRODUCT_IMAGES']; $x++) {
             //              // hidden filename that is retrieved from the ajax upload
             //            $i=$x;
             //            if ($i==0) {
             //              $i='';
             //            }
             //            $field='products_image'.$i;
             //            if ($ref->get['file_type']==$field) {
             $temp_file = $ref->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . uniqid();
             if (isset($_FILES['qqfile'])) {
                 move_uploaded_file($_FILES['qqfile']['tmp_name'], $temp_file);
             } else {
                 $input = fopen("php://input", "r");
                 $debug_file = fopen("/Applications/XAMPP/xamppfiles/htdocs/typo3/typo3temp/debug.txt", "w");
                 fwrite($debug_file, sys_get_temp_dir());
                 fclose($debug_file);
                 $temp = tmpfile();
                 $realSize = stream_copy_to_stream($input, $temp);
                 fclose($input);
                 $target = fopen($temp_file, "w");
                 fseek($temp, 0, SEEK_SET);
                 stream_copy_to_stream($temp, $target);
                 fclose($target);
             }
             error_log("temp file created");
             $size = getimagesize($temp_file);
             if ($size[0] > 5 and $size[1] > 5) {
                 error_log("size ok");
                 $imgtype = mslib_befe::exif_imagetype($temp_file);
                 if ($imgtype) {
                     error_log("type ok");
                     // valid image
                     $ext = image_type_to_extension($imgtype, false);
                     if ($ext) {
                         error_log("ext ok");
                         $i = 0;
                         $filename = mslib_fe::rewritenamein($ref->get['products_name']) . '.' . $ext;
                         $folder = mslib_befe::getImagePrefixFolder($filename);
                         $array = explode(".", $filename);
                         if (!is_dir($ref->DOCUMENT_ROOT . $ref->ms['image_paths']['variants']['original'] . '/' . $folder)) {
                             t3lib_div::mkdir($ref->DOCUMENT_ROOT . $ref->ms['image_paths']['variants']['original'] . '/' . $folder);
                         }
                         error_log("mkdir ok");
                         $folder .= '/';
                         $target = $ref->DOCUMENT_ROOT . $ref->ms['image_paths']['variants']['original'] . '/' . $folder . $filename;
                         if (file_exists($target)) {
                             error_log("file exists ok");
                             do {
                                 $filename = mslib_fe::rewritenamein($ref->get['products_name']) . ($i > 0 ? '-' . $i : '') . '.' . $ext;
                                 $folder_name = mslib_befe::getImagePrefixFolder($filename);
                                 $array = explode(".", $filename);
                                 $folder = $folder_name;
                                 if (!is_dir($ref->DOCUMENT_ROOT . $ref->ms['image_paths']['variants']['original'] . '/' . $folder)) {
                                     t3lib_div::mkdir($ref->DOCUMENT_ROOT . $ref->ms['image_paths']['variants']['original'] . '/' . $folder);
                                 }
                                 $folder .= '/';
                                 $target = $ref->DOCUMENT_ROOT . $ref->ms['image_paths']['variants']['original'] . '/' . $folder . $filename;
                                 $i++;
                             } while (file_exists($target));
                         }
                         error_log("before copy file ok");
                         if (copy($temp_file, $target)) {
                             $filename = mslib_befe::resizeProductImage($target, $filename, $ref->DOCUMENT_ROOT . t3lib_extMgm::siteRelPath($ref->extKey), 1);
                             $result = array();
                             $result['success'] = true;
                             $result['error'] = false;
                             $result['filename'] = $filename;
                             echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
                             exit;
                         }
                     }
                 }
             }
         }
         //          }
         //          break;
         //        }
         //      }
     }
     //    exit();
     //    break;
 }
 /**
  * Creates a new file
  *
  * Returns an array with
  * 0: boolean success
  * 1: string absolute path of written file/folder
  * 2: error code
  *
  * The error code returns
  * 0: no error
  * -1: not writable
  * -2: not allowed path
  * -3: already exists
  * -4: not able to create
  *
  * @static
  * @param  $folder
  * @param  $file
  * @param  $isFolder
  * @return array
  */
 public static function createNewFile($folder, $file, $isFolder)
 {
     $success = FALSE;
     $error = 0;
     if (substr($folder, -1) !== '/') {
         $folder .= '/';
     }
     $newFile = t3lib_div::resolveBackPath(PATH_site . $folder . $file);
     if (!is_writable(dirname($newFile))) {
         $error = -1;
     } elseif (!t3lib_div::isAllowedAbsPath($newFile)) {
         $error = -2;
     } elseif (file_exists($newFile)) {
         $error = -3;
     } else {
         if ($isFolder) {
             $success = t3lib_div::mkdir($newFile);
         } else {
             $success = t3lib_div::writeFile($newFile, '');
         }
         if (!$success) {
             $error = -4;
         }
     }
     return array($success, $newFile, $error);
 }
Example #20
0
	/**
	 * Creates all needed folders and files if not exist
	 * 
	 * @return	boolean
	 */
	function createFolder()
	{
		// create the config folder
		if (! is_dir($this->configDir)) {
			if (! t3lib_div::mkdir($this->configDir)) {
				$error = "Could not create config path '{$this->configDir}'!";
				$this->errors['createFolder'] = $error;
				t3lib_div::devLog($error, 't3jquery', 3);
				return FALSE;
			}
		}
		return TRUE;
	}
    /**
     * Check if upload folder / "createDir" directories should be created.
     *
     * @param	string		Extension key
     * @param	array		Extension information array
     * @return	string		HTML content.
     */
    function checkUploadFolder($extKey, $extInfo)
    {
        // Checking for upload folder:
        $uploadFolder = PATH_site . tx_em_Tools::uploadFolder($extKey);
        if ($extInfo['EM_CONF']['uploadfolder'] && !@is_dir($uploadFolder)) {
            if (t3lib_div::_POST('_uploadfolder')) {
                // CREATE dir:
                t3lib_div::mkdir($uploadFolder);
                $indexContent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
	<TITLE></TITLE>
<META http-equiv=Refresh Content="0; Url=../../">
</HEAD>
</HTML>';
                t3lib_div::writeFile($uploadFolder . 'index.html', $indexContent);
            } else {
                // Show checkbox / HTML for creation:
                $content .= '
					<br /><h3>' . $GLOBALS['LANG']->getLL('checkUploadFolder_create_upload_folder') . '</h3>
					<p>' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_upload_folder_needed'), tx_em_Tools::uploadFolder($extKey)) . '<br />
						<label for="check_uploadfolder">' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_create_dir'), tx_em_Tools::uploadFolder($extKey)) . '</label>
						<input type="checkbox" name="_uploadfolder" id="check_uploadfolder" checked="checked" value="1" /><br />
					</p>
				';
            }
        }
        // Additional directories that should be created:
        if ($extInfo['EM_CONF']['createDirs']) {
            $createDirs = array_unique(t3lib_div::trimExplode(',', $extInfo['EM_CONF']['createDirs'], 1));
            foreach ($createDirs as $crDir) {
                if (!@is_dir(PATH_site . $crDir)) {
                    if (t3lib_div::_POST('_createDir_' . md5($crDir))) {
                        // CREATE dir:
                        // Initialize:
                        $crDirStart = '';
                        $dirs_in_path = explode('/', preg_replace('/\\/$/', '', $crDir));
                        // Traverse each part of the dir path and create it one-by-one:
                        foreach ($dirs_in_path as $dirP) {
                            if (strcmp($dirP, '')) {
                                $crDirStart .= $dirP . '/';
                                if (!@is_dir(PATH_site . $crDirStart)) {
                                    t3lib_div::mkdir(PATH_site . $crDirStart);
                                    $finalDir = PATH_site . $crDirStart;
                                }
                            } else {
                                throw new RuntimeException('TYPO3 Fatal Error: ' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_error'), PATH_site . $crDir), 1270853982);
                            }
                        }
                        if ($finalDir) {
                            $indexContent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
	<TITLE></TITLE>
<META http-equiv=Refresh Content="0; Url=/">
</HEAD>
</HTML>';
                            t3lib_div::writeFile($finalDir . 'index.html', $indexContent);
                        }
                    } else {
                        // Show checkbox / HTML for creation:
                        $md5CrDir = md5($crDir);
                        $content .= '
							<br />
							<h3>' . $GLOBALS['LANG']->getLL('checkUploadFolder_create_folder') . '</h3>
							<p>' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_folder_needed'), $crDir) . '<br />
								<label for="check_createDir_' . $md5CrDir . '">' . sprintf($GLOBALS['LANG']->getLL('checkUploadFolder_create_dir'), $crDir) . '</label>
								<input type="checkbox" name="_createDir_' . $md5CrDir . '" id="check_createDir_' . $md5CrDir . '" checked="checked" value="1" /><br />
							</p>
						';
                    }
                }
            }
        }
        return $content;
    }
 /**
  * Checks if t3lib_div::mkdir() correctly creates a directory with trailing slash
  * This test assumes directory 'PATH_site'/typo3temp exists
  *
  * @test
  * @see t3lib_div::mkdir()
  */
 public function checkMkdirCorrectlyCreatesDirectoryWithTrailingSlash()
 {
     $directory = PATH_site . 'typo3temp/' . uniqid('test_');
     $mkdirResult = t3lib_div::mkdir($directory);
     $directoryCreated = is_dir($directory);
     t3lib_div::rmdir($directory);
     $this->assertTrue($mkdirResult);
     $this->assertTrue($directoryCreated);
 }
 /**
  * Create a user directory if defined
  *
  * @param	int		$uid: Id of the user record
  * @return void
  */
 protected function action_createDir($uid)
 {
     $path = $this->action_getUserMainDir();
     if ($path) {
         t3lib_div::mkdir($path . $uid);
         t3lib_div::mkdir($path . $uid . '/_temp_/');
     }
 }
    /**
     * Main class of Spell Checker plugin for Typo3 CMS
     *
     * @return	string		content produced by the plugin
     */
    function main()
    {
        $this->csConvObj = t3lib_div::makeInstance('t3lib_cs');
        // Setting start time
        $time_start = microtime(true);
        $this->pspell_is_available = in_array('pspell', get_loaded_extensions());
        $this->AspellDirectory = trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['AspellDirectory']) ? trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['AspellDirectory']) : '/usr/bin/aspell';
        $this->forceCommandMode = trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['forceCommandMode']) ? trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['forceCommandMode']) : 0;
        $safe_mode_is_enabled = t3lib_utility_PhpOptions::isSafeModeEnabled();
        if ($safe_mode_is_enabled && !$this->pspell_is_available) {
            echo 'Configuration problem: Spell checking cannot be performed';
        }
        if ($safe_mode_is_enabled && $this->forceCommandMode) {
            echo 'Configuration problem: Spell checking cannot be performed in command mode';
        }
        if (!$safe_mode_is_enabled && (!$this->pspell_is_available || $this->forceCommandMode)) {
            $AspellVersionString = explode('Aspell', shell_exec($this->AspellDirectory . ' -v'));
            $AspellVersion = substr($AspellVersionString[1], 0, 4);
            if (doubleval($AspellVersion) < doubleval('0.5') && (!$this->pspell_is_available || $this->forceCommandMode)) {
                echo 'Configuration problem: Aspell version ' . $AspellVersion . ' too old. Spell checking cannot be performed in command mode';
            }
            $this->defaultAspellEncoding = trim(shell_exec($this->AspellDirectory . ' config encoding'));
        }
        // Setting the list of dictionaries
        if (!$safe_mode_is_enabled && (!$this->pspell_is_available || $this->forceCommandMode)) {
            $dictionaryList = shell_exec($this->AspellDirectory . ' dump dicts');
            $dictionaryList = implode(',', t3lib_div::trimExplode(LF, $dictionaryList, 1));
        }
        if (empty($dictionaryList)) {
            $dictionaryList = t3lib_div::_POST('showDictionaries');
            // Applying EM variable DEPRECATED as of TYPO3 4.3.0
            $dictionaryList = $dictionaryList ? $dictionaryList : trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['dictionaryList']);
        }
        $dictionaryArray = t3lib_div::trimExplode(',', $dictionaryList, 1);
        $restrictToDictionaries = t3lib_div::_POST('restrictToDictionaries');
        if ($restrictToDictionaries) {
            $dictionaryArray = array_intersect($dictionaryArray, t3lib_div::trimExplode(',', $restrictToDictionaries, 1));
        }
        if (!count($dictionaryArray)) {
            $dictionaryArray[] = 'en';
        }
        $this->dictionary = t3lib_div::_POST('dictionary');
        // Applying EM variable DEPRECATED as of TYPO3 4.3.0
        $defaultDictionary = $this->dictionary ? $this->dictionary : trim($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['defaultDictionary']);
        if (!$defaultDictionary || !in_array($defaultDictionary, $dictionaryArray)) {
            $defaultDictionary = 'en';
        }
        uasort($dictionaryArray, 'strcoll');
        $dictionaryList = implode(',', $dictionaryArray);
        // Setting the dictionary
        if (empty($this->dictionary) || !in_array($this->dictionary, $dictionaryArray)) {
            $this->dictionary = 'en';
        }
        // Setting the pspell suggestion mode
        $this->pspellMode = t3lib_div::_POST('pspell_mode') ? t3lib_div::_POST('pspell_mode') : $this->pspellMode;
        // Now sanitize $this->pspellMode
        $this->pspellMode = t3lib_div::inList('ultra,fast,normal,bad-spellers', $this->pspellMode) ? $this->pspellMode : 'normal';
        switch ($this->pspellMode) {
            case 'ultra':
            case 'fast':
                $pspellModeFlag = PSPELL_FAST;
                break;
            case 'bad-spellers':
                $pspellModeFlag = PSPELL_BAD_SPELLERS;
                break;
            case 'normal':
            default:
                $pspellModeFlag = PSPELL_NORMAL;
                break;
        }
        // Setting the charset
        if (t3lib_div::_POST('pspell_charset')) {
            $this->charset = trim(t3lib_div::_POST('pspell_charset'));
        }
        if (strtolower($this->charset) == 'iso-8859-1') {
            $this->parserCharset = strtolower($this->charset);
        }
        // In some configurations, Aspell uses 'iso8859-1' instead of 'iso-8859-1'
        $this->aspellEncoding = $this->parserCharset;
        if ($this->parserCharset == 'iso-8859-1' && strstr($this->defaultAspellEncoding, '8859-1')) {
            $this->aspellEncoding = $this->defaultAspellEncoding;
        }
        // However, we are going to work only in the parser charset
        if ($this->pspell_is_available && !$this->forceCommandMode) {
            $this->pspell_link = pspell_new($this->dictionary, '', '', $this->parserCharset, $pspellModeFlag);
        }
        // Setting the path to user personal dicts, if any
        if (t3lib_div::_POST('enablePersonalDicts') == 'true' && TYPO3_MODE == 'BE' && is_object($GLOBALS['BE_USER'])) {
            $this->userUid = 'BE_' . $GLOBALS['BE_USER']->user['uid'];
            if ($this->userUid) {
                $this->personalDictPath = t3lib_div::getFileAbsFileName($this->uploadFolder . $this->userUid);
                if (!is_dir($this->personalDictPath)) {
                    t3lib_div::mkdir($this->personalDictPath);
                }
                // escape here for later use
                $this->personalDictsArg = ' --home-dir=' . escapeshellarg($this->personalDictPath);
            }
        }
        $cmd = t3lib_div::_POST('cmd');
        if ($cmd == 'learn' && !$safe_mode_is_enabled) {
            // Only availble for BE_USERS, die silently if someone has gotten here by accident
            if (TYPO3_MODE != 'BE' || !is_object($GLOBALS['BE_USER'])) {
                die('');
            }
            // Updating the personal word list
            $to_p_dict = t3lib_div::_POST('to_p_dict');
            $to_p_dict = $to_p_dict ? $to_p_dict : array();
            $to_r_list = t3lib_div::_POST('to_r_list');
            $to_r_list = $to_r_list ? $to_r_list : array();
            header('Content-Type: text/plain; charset=' . strtoupper($this->parserCharset));
            header('Pragma: no-cache');
            if ($to_p_dict || $to_r_list) {
                $tmpFileName = t3lib_div::tempnam($this->filePrefix);
                if ($filehandle = fopen($tmpFileName, 'wb')) {
                    foreach ($to_p_dict as $personal_word) {
                        $cmd = '&' . $personal_word . LF;
                        echo $cmd;
                        fwrite($filehandle, $cmd, strlen($cmd));
                    }
                    foreach ($to_r_list as $replace_pair) {
                        $cmd = '$$ra ' . $replace_pair[0] . ' , ' . $replace_pair[1] . LF;
                        echo $cmd;
                        fwrite($filehandle, $cmd, strlen($cmd));
                    }
                    $cmd = "#\n";
                    echo $cmd;
                    fwrite($filehandle, $cmd, strlen($cmd));
                    fclose($filehandle);
                    // $this->personalDictsArg has already been escapeshellarg()'ed above, it is an optional paramter and might be empty here
                    $AspellCommand = 'cat ' . escapeshellarg($tmpFileName) . ' | ' . $this->AspellDirectory . ' -a --mode=none' . $this->personalDictsArg . ' --lang=' . escapeshellarg($this->dictionary) . ' --encoding=' . escapeshellarg($this->aspellEncoding) . ' 2>&1';
                    print $AspellCommand . LF;
                    print shell_exec($AspellCommand);
                    t3lib_div::unlink_tempfile($tmpFileName);
                    echo 'Personal word list was updated.';
                } else {
                    echo 'SpellChecker tempfile open error.';
                }
            } else {
                echo 'Nothing to add to the personal word list.';
            }
            flush();
            exit;
        } else {
            // Check spelling content
            // Initialize output
            $this->result = '<?xml version="1.0" encoding="' . $this->parserCharset . '"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . substr($this->dictionary, 0, 2) . '" lang="' . substr($this->dictionary, 0, 2) . '">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=' . $this->parserCharset . '" />
<link rel="stylesheet" type="text/css" media="all" href="' . (TYPO3_MODE == 'BE' ? '../' : '') . t3lib_extMgm::siteRelPath($this->extKey) . '/htmlarea/plugins/SpellChecker/spell-check-style.css" />
<script type="text/javascript">
/*<![CDATA[*/
<!--
';
            // Getting the input content
            $content = t3lib_div::_POST('content');
            // Parsing the input HTML
            $parser = xml_parser_create(strtoupper($this->parserCharset));
            xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
            xml_set_object($parser, $this);
            if (!xml_set_element_handler($parser, 'startHandler', 'endHandler')) {
                echo 'Bad xml handler setting';
            }
            if (!xml_set_character_data_handler($parser, 'collectDataHandler')) {
                echo 'Bad xml handler setting';
            }
            if (!xml_set_default_handler($parser, 'defaultHandler')) {
                echo 'Bad xml handler setting';
            }
            if (!xml_parse($parser, '<?xml version="1.0" encoding="' . $this->parserCharset . '"?><spellchecker> ' . preg_replace('/&nbsp;/' . ($this->parserCharset == 'utf-8' ? 'u' : ''), ' ', $content) . ' </spellchecker>')) {
                echo 'Bad parsing';
            }
            if (xml_get_error_code($parser)) {
                die('Line ' . xml_get_current_line_number($parser) . ': ' . xml_error_string(xml_get_error_code($parser)));
            }
            xml_parser_free($parser);
            if ($this->pspell_is_available && !$this->forceCommandMode) {
                pspell_clear_session($this->pspell_link);
            }
            $this->result .= 'var suggestedWords = {' . $this->suggestedWords . '};
var dictionaries = "' . $dictionaryList . '";
var selectedDictionary = "' . $this->dictionary . '";
';
            // Calculating parsing and spell checkting time
            $time = number_format(microtime(true) - $time_start, 2, ',', ' ');
            // Insert spellcheck info
            $this->result .= 'var spellcheckInfo = { "Total words":"' . $this->wordCount . '","Misspelled words":"' . sizeof($this->misspelled) . '","Total suggestions":"' . $this->suggestionCount . '","Total words suggested":"' . $this->suggestedWordCount . '","Spelling checked in":"' . $time . '" };
// -->
/*]]>*/
</script>
</head>
';
            $this->result .= '<body onload="window.parent.RTEarea[\'' . t3lib_div::_POST('editorId') . '\'].editor.getPlugin(\'SpellChecker\').spellCheckComplete();">';
            $this->result .= preg_replace('/' . preg_quote('<?xml') . '.*' . preg_quote('?>') . '[' . preg_quote(LF . CR . chr(32)) . ']*/' . ($this->parserCharset == 'utf-8' ? 'u' : ''), '', $this->text);
            $this->result .= '<div style="display: none;">' . $dictionaries . '</div>';
            // Closing
            $this->result .= '
</body></html>';
            // Outputting
            header('Content-Type: text/html; charset=' . strtoupper($this->parserCharset));
            echo $this->result;
        }
    }
 /**
  * Constructor:
  * initializes locking, check input parameters and set variables accordingly.
  *
  * @param	string		ID to identify this lock in the system
  * @param	string		Define which locking method to use. Defaults to "simple".
  * @param	integer		Number of times a locked resource is tried to be acquired. This is only used by manual locks like the "simple" method.
  * @param	integer		Milliseconds after lock acquire is retried. $loops * $step results in the maximum delay of a lock. Only used by manual locks like the "simple" method.
  * @return	boolean		Returns true unless something went wrong
  */
 public function __construct($id, $method = '', $loops = 0, $step = 0)
 {
     // Input checks
     $id = (string) $id;
     // Force ID to be string
     if (intval($loops)) {
         $this->loops = intval($loops);
     }
     if (intval($step)) {
         $this->step = intval($step);
     }
     // Detect locking method
     if (in_array($method, array('disable', 'simple', 'flock', 'semaphore'))) {
         $this->method = $method;
     } else {
         throw new Exception('No such method "' . $method . '"');
     }
     $success = FALSE;
     switch ($this->method) {
         case 'simple':
         case 'flock':
             $path = PATH_site . 'typo3temp/locks/';
             if (!is_dir($path)) {
                 t3lib_div::mkdir($path);
             }
             $this->id = md5($id);
             $this->resource = $path . $this->id;
             $success = TRUE;
             break;
         case 'semaphore':
             $this->id = abs(crc32($id));
             if (($this->resource = sem_get($this->id, 1)) == TRUE) {
                 $success = TRUE;
             }
             break;
         case 'disable':
             return FALSE;
             break;
     }
     return $success;
 }
Example #26
0
 /**
  * Renders and outputs the code coverage report.
  *
  * @return void
  */
 protected function renderCodeCoverage()
 {
     $this->coverage->stop();
     $codeCoverageDirectory = PATH_site . 'typo3temp/codecoverage/';
     if (!is_readable($codeCoverageDirectory) && !is_dir($codeCoverageDirectory)) {
         t3lib_div::mkdir($codeCoverageDirectory);
     }
     $coverageReport = new PHP_CodeCoverage_Report_HTML();
     $coverageReport->process($this->coverage, $codeCoverageDirectory);
     $this->outputService->output('<p><a target="_blank" href="../typo3temp/codecoverage/index.html">' . 'Click here to access the Code Coverage report</a></p>' . '<p>Memory peak usage: ' . t3lib_div::formatSize(memory_get_peak_usage()) . 'B<p/>');
 }
 /**
  * This creates a new folder. (action=6)
  *
  * @param	array		$cmds['data'] is the foldername. $cmds['target'] is the path where to create it.
  * @return	string		Returns the new foldername upon success
  */
 function func_newfolder($cmds, $id)
 {
     if (!$this->isInit) {
         return FALSE;
     }
     $theFolder = $this->cleanFileName($cmds['data']);
     // main log entry
     $this->log['cmd']['newfolder'][$id] = array('errors' => array(), 'target_path' => $cmds['target'], 'target_folder' => $theFolder);
     if ($theFolder) {
         if ($this->checkFileNameLen($theFolder)) {
             $theTarget = $this->is_directory($cmds['target']);
             // Check the target dir
             if ($theTarget) {
                 if ($this->actionPerms['newFolder']) {
                     $theNewFolder = $theTarget . '/' . $theFolder;
                     if ($this->checkPathAgainstMounts($theNewFolder)) {
                         if (!@file_exists($theNewFolder)) {
                             if (t3lib_div::mkdir($theNewFolder)) {
                                 $this->writelog(6, 0, 1, 'Directory "%s" created in "%s"', array($theFolder, $theTarget . '/'), 'newfolder', $id);
                                 return $theNewFolder;
                             } else {
                                 $this->writelog(6, 1, 100, 'Directory "%s" not created. Write-permission problem in "%s"?', array($theFolder, $theTarget . '/'), 'newfolder', $id);
                             }
                         } else {
                             $this->writelog(6, 1, 101, 'File or directory "%s" existed already!', array($theNewFolder), 'newfolder', $id);
                         }
                     } else {
                         $this->writelog(6, 1, 102, 'Destination path "%s" was not within your mountpoints!', array($theTarget . '/'), 'newfolder', $id);
                     }
                 } else {
                     $this->writelog(6, 1, 103, 'You are not allowed to create directories!', '', 'newfolder', $id);
                 }
             } else {
                 $this->writelog(6, 2, 104, 'Destination "%s" was not a directory', array($cmds['target']), 'newfolder', $id);
             }
         } else {
             $this->writelog(6, 1, 105, 'New name "%s" was too long (max %s characters)', array($theFolder, $this->maxInputNameLen), 'newfolder', $id);
         }
     }
 }
 /**
  * This takes the ZIP file, unzips it, reads all documents, store them in database for next retrieval.
  * The file is libunzipped in PATH_site.'typo3temp/' + a randomly named folder.
  *
  * @param  $file
  * @return mixed
  * @access private
  */
 function extractFile($file)
 {
     if (is_file($file)) {
         $tempDir = PATH_site . 'typo3temp/' . md5(microtime()) . '/';
         t3lib_div::mkdir($tempDir);
         if (is_dir($tempDir)) {
             // This is if I want to check the content:
             #       $cmd = $this->unzipAppPath.' -t '.$this->file;
             #       exec($cmd,$dat);
             #       debug($dat);
             // Unzip the files inside: **MODIFIED RL, 15.08.03
             $cmd = $this->unzipAppCmd;
             $cmd = str_replace('###ARCHIVENAME###', $file, $cmd);
             $cmd = str_replace('###DIRECTORY###', $tempDir, $cmd);
             exec($cmd);
             $out['fileArr'] = $this->getAllFilesAndFoldersInPath(array(), $tempDir);
             $out['tempDir'] = $tempDir;
             return $out;
         } else {
             return 'No dir: ' . $tempDir;
         }
     } else {
         return 'No file: ' . $file;
     }
 }
Example #29
0
 /**
  * Returns the contents of a specific file within the ZIP
  *
  * @return	string	contents
  */
 function getZIPFileContents($ZIPfile, $filename)
 {
     if (file_exists($ZIPfile)) {
         // Unzipping SXW file, getting filelist:
         $tempPath = PATH_site . 'typo3temp/tx_tsconfighelp_ziptemp/';
         t3lib_div::mkdir($tempPath);
         $this->unzip($ZIPfile, $tempPath);
         $output = t3lib_div::getURL($tempPath . $filename);
         $cmd = 'rm -r "' . $tempPath . '"';
         t3lib_utility_Command::exec($cmd);
         return $output;
     }
 }
 protected function generateYamlSettingsFile()
 {
     if (!file_exists($this->configurationDirectory . 'ExtensionBuilder/settings.yaml')) {
         t3lib_div::mkdir($this->configurationDirectory . 'ExtensionBuilder');
         $fileContents = $this->generateYamlSettings();
         $targetFile = $this->configurationDirectory . 'ExtensionBuilder/settings.yaml';
         t3lib_div::writeFile($targetFile, $fileContents);
     }
 }