function _createNewDir($dirName)
 {
     global $_ARRAYLANG, $objTemplate;
     $dirName = \Cx\Lib\FileSystem\FileSystem::replaceCharacters($dirName);
     $status = \Cx\Lib\FileSystem\FileSystem::make_folder($this->path . $dirName);
     if ($status) {
         $this->highlightName[] = $dirName;
         $objTemplate->setVariable('CONTENT_OK_MESSAGE', $_ARRAYLANG['TXT_MEDIA_MSG_NEW_DIR']);
     } else {
         $objTemplate->setVariable('CONTENT_STATUS_MESSAGE', $_ARRAYLANG['TXT_MEDIA_MSG_ERROR_NEW_DIR']);
     }
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $folderPath = $cx->getWebsiteTempPath() . '/Update';
     if (!file_exists($folderPath)) {
         \Cx\Lib\FileSystem\FileSystem::make_folder($folderPath);
     }
     if (!file_exists($folderPath . '/' . self::PENDING_DB_UPDATES_YML)) {
         \Cx\Lib\FileSystem\FileSystem::copy_file($cx->getCodeBaseCoreModulePath() . '/Update/Data/' . self::PENDING_DB_UPDATES_YML, $folderPath . '/' . self::PENDING_DB_UPDATES_YML);
     }
     parent::__construct($folderPath . '/' . self::PENDING_DB_UPDATES_YML);
 }
Exemple #3
0
function ecardUpdates()
{
    //Update database changes
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "modules` SET `name` = 'Ecard' WHERE `id` = 49");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=Ecard' WHERE `area_id` = 130");
        //Insert component entry
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "component` (`id`, `name`, `type`) VALUES ('49', 'Ecard', 'module')");
        //update module name for frontend pages
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "content_page` SET `module` = 'Ecard' WHERE `module` = 'ecard'");
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    //Update script for moving the folders
    $imgModulesfolderPath = ASCMS_DOCUMENT_ROOT . '/images/modules/ecard';
    $mediafolderPath = ASCMS_DOCUMENT_ROOT . '/media/Ecard';
    try {
        if (!file_exists($mediafolderPath)) {
            \Cx\Lib\FileSystem\FileSystem::make_folder($mediafolderPath);
            \Cx\Lib\FileSystem\FileSystem::makeWritable($mediafolderPath);
        }
        //move the folder from '/images/modules/ecard/ecards_optimized' to '/media/Ecard/ecards_optimized'
        if (file_exists($imgModulesfolderPath . '/ecards_optimized') && !file_exists($mediafolderPath . '/ecards_optimized')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($imgModulesfolderPath . '/ecards_optimized');
            if (!\Cx\Lib\FileSystem\FileSystem::move($imgModulesfolderPath . '/ecards_optimized', $mediafolderPath . '/ecards_optimized')) {
                return 'Failed to Move the folders from ' . $imgModulesfolderPath . '/ecards_optimized to ' . $mediafolderPath . '/ecards_optimized.';
            }
        }
        //move the folder from '/images/modules/ecard/send_ecards' to '/media/Ecard/send_ecards'
        if (file_exists($imgModulesfolderPath . '/send_ecards') && !file_exists($mediafolderPath . '/send_ecards')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($imgModulesfolderPath . '/send_ecards');
            if (!\Cx\Lib\FileSystem\FileSystem::move($imgModulesfolderPath . '/send_ecards', $mediafolderPath . '/send_ecards')) {
                return 'Failed to Move the folders from ' . $imgModulesfolderPath . '/send_ecards to ' . $mediafolderPath . '/send_ecards.';
            }
        }
        //move the folder from '/images/modules/ecard/thumbnails' to '/media/Ecard/thumbnails'
        if (file_exists($imgModulesfolderPath . '/thumbnails') && !file_exists($mediafolderPath . '/thumbnails')) {
            \Cx\Lib\FileSystem\FileSystem::makeWritable($imgModulesfolderPath . '/thumbnails');
            if (!\Cx\Lib\FileSystem\FileSystem::move($imgModulesfolderPath . '/thumbnails', $mediafolderPath . '/thumbnails')) {
                return 'Failed to Move the folders from ' . $imgModulesfolderPath . '/thumbnails to ' . $mediafolderPath . '/thumbnails.';
            }
        }
        return 'Successfully updated.';
    } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        return $e->getMessage();
    }
}
 /**
  * @override
  */
 public function handleRequest()
 {
     global $_FILES;
     //get a writable directory
     $targetDir = '/upload_' . $this->uploadId;
     $tempPath = $_SESSION->getTempPath();
     $webTempPath = $_SESSION->getWebTempPath();
     //make sure target directory exists
     if (!file_exists($tempPath . $targetDir)) {
         \Cx\Lib\FileSystem\FileSystem::make_folder($webTempPath . $targetDir);
     }
     //move all uploaded file to this upload's temp directory
     foreach ($_FILES["uploaderFiles"]["error"] as $key => $error) {
         if ($error == UPLOAD_ERR_OK) {
             $tmpName = $_FILES["uploaderFiles"]["tmp_name"][$key];
             $name = $_FILES["uploaderFiles"]["name"][$key];
             if (!\FWValidator::is_file_ending_harmless($name)) {
                 die('Error:' . sprintf('The file %s was refused due to its file extension which is not allowed!', htmlentities($name, ENT_QUOTES, CONTREXX_CHARSET)));
             }
             //TODO: Uploader::addChunk does this also -> centralize in function
             // remember the "raw" file name, we want to store all original
             // file names in the session.
             $originalFileName = $name;
             // Clean the fileName for security reasons
             // we're using a-zA-Z0-9 instead of \w because of the umlauts.
             // linux excludes them from \w, windows includes them. we do not want different
             // behaviours on different operating systems.
             $name = preg_replace('/[^a-zA-Z0-9\\._-]+/', '', $name);
             $originalFileNames = array();
             if (isset($_SESSION['upload']['handlers'][$this->uploadId]['originalFileNames'])) {
                 $originalFileNames = $_SESSION['upload']['handlers'][$this->uploadId]['originalFileNames'];
             }
             $originalFileNames[$name] = $originalFileName;
             $_SESSION['upload']['handlers'][$this->uploadId]['originalFileNames'] = $originalFileNames;
             //end of TODO-region
             //move file somewhere we know both the web- and normal path...
             @move_uploaded_file($tmpName, ASCMS_TEMP_PATH . '/' . $name);
             //...then do a safe-mode-safe (yeah) move operation
             \Cx\Lib\FileSystem\FileSystem::move(ASCMS_TEMP_WEB_PATH . '/' . $name, $webTempPath . $targetDir . '/' . $name, true);
         }
     }
     //and call back.
     $this->notifyCallback();
     //redirect the user where he belongs
     $this->redirect();
 }
Exemple #5
0
 protected function initContrexxCaching()
 {
     global $_CONFIG;
     // in case the request's origin is from a mobile devie
     // and this is the first request (the InitCMS object wasn't yet
     // able to determine of the mobile device wishes to be served
     // with the system's mobile view), we shall deactivate the caching system
     if (\InitCMS::_is_mobile_phone() && !\InitCMS::_is_tablet() && !isset($_REQUEST['smallscreen'])) {
         $this->boolIsEnabled = false;
         return;
     }
     if ($_CONFIG['cacheEnabled'] == 'off') {
         $this->boolIsEnabled = false;
         return;
     }
     if (isset($_REQUEST['caching']) && $_REQUEST['caching'] == '0') {
         $this->boolIsEnabled = false;
         return;
     }
     // TODO: Reimplement - see #1205
     /*if ($this->isException()) {
           $this->boolIsEnabled = false;
           return;
       }*/
     $this->boolIsEnabled = true;
     // check the cache directory
     if (!is_dir(ASCMS_CACHE_PATH)) {
         \Cx\Lib\FileSystem\FileSystem::make_folder(ASCMS_CACHE_PATH);
     }
     if (!is_writable(ASCMS_CACHE_PATH)) {
         \Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_CACHE_PATH);
     }
     $this->strCachePath = ASCMS_CACHE_PATH . '/';
     $this->intCachingTime = intval($_CONFIG['cacheExpiration']);
     // Use data of $_GET and $_POST to uniquely identify a request.
     // Important: You must not use $_REQUEST instead. $_REQUEST also contains
     //            the data of $_COOKIE. Whereas the cookie information might
     //            change in each request, which might break the caching-
     //            system.
     $request = array_merge_recursive($_GET, $_POST);
     ksort($request);
     $this->arrPageContent = array('url' => $_SERVER['REQUEST_URI'], 'request' => $request);
     $this->strCacheFilename = md5(serialize($this->arrPageContent));
 }
 /**
  * Store the website details into the YML file
  * 
  * @param string $folderPath
  * @param string $filePath
  * @param array  $ymlContent
  * 
  * @return null
  */
 public function storeUpdateWebsiteDetailsToYml($folderPath, $filePath, $ymlContent)
 {
     if (empty($folderPath) || empty($filePath)) {
         return;
     }
     try {
         if (!file_exists($folderPath)) {
             \Cx\Lib\FileSystem\FileSystem::make_folder($folderPath);
         }
         $file = new \Cx\Lib\FileSystem\File($filePath);
         $file->touch();
         $yaml = new \Symfony\Component\Yaml\Yaml();
         $file->write($yaml->dump(array('PendingCodeBaseChanges' => $ymlContent)));
     } catch (\Exception $e) {
         \DBG::log($e->getMessage());
     }
 }
 /**
  * create new file or folder
  * 
  * @param array $params supplied arguments from JsonData-request
  * @return string
  */
 public function newWithin($params)
 {
     global $_ARRAYLANG, $objInit;
     $_ARRAYLANG = $objInit->loadLanguageData('ViewManager');
     if (empty($params['post']['theme']) || empty($params['post']['name'])) {
         return array('status' => 'error', 'message' => $_ARRAYLANG['TXT_THEME_OPERATION_FAILED_FOR_EMPTY_NAME']);
     }
     if ($params['post']['isFolder'] && preg_match('/^\\./', trim($params['post']['name']))) {
         // folder name should not start with dot(.)
         return array('status' => 'error', 'reload' => false, 'message' => sprintf($_ARRAYLANG['TXT_THEME_FOLDER_NAME_NOT_ALLOWED'], contrexx_input2xhtml($params['post']['name'])));
     }
     $matches = null;
     preg_match('@{([0-9A-Za-z._-]+)(:([_a-zA-Z][A-Za-z_0-9]*))?}@sm', $params['post']['name'], $matches);
     if (!empty($matches)) {
         return array('status' => 'error', 'reload' => false, 'message' => sprintf($_ARRAYLANG['TXT_THEME_NAME_NOT_ALLOWED'], contrexx_input2xhtml($params['post']['newName'])));
     }
     // Cannot rename the virtual directory
     $virtualDirs = array('/' . \Cx\Core\Core\Model\Entity\SystemComponent::TYPE_CORE_MODULE, '/' . \Cx\Core\Core\Model\Entity\SystemComponent::TYPE_MODULE, '/' . \Cx\Core\Core\Model\Entity\SystemComponent::TYPE_CORE);
     $currentThemeFolderDirPath = \Env::get('cx')->getWebsiteThemesPath() . '/' . $params['post']['theme'] . '/';
     // Create the theme folder, if it does not exist
     if (!\Cx\Lib\FileSystem\FileSystem::exists($currentThemeFolderDirPath)) {
         if (!\Cx\Lib\FileSystem\FileSystem::make_folder($currentThemeFolderDirPath)) {
             return array('status' => 'error', 'reload' => false, 'message' => $_ARRAYLANG['TXT_THEME_NEWFILE_FAILED']);
         }
     }
     $newFileName = \Cx\Lib\FileSystem\FileSystem::replaceCharacters($params['post']['name']);
     if (!\FWValidator::is_file_ending_harmless($newFileName)) {
         return array('status' => 'error', 'reload' => false, 'message' => sprintf($_ARRAYLANG['TXT_THEME_FILE_EXTENSION_NOT_ALLOWED'], contrexx_input2xhtml($newFileName)));
     }
     if (in_array('/' . $newFileName, $virtualDirs)) {
         return array('status' => 'error', 'reload' => false, 'message' => $_ARRAYLANG['TXT_THEME_OPERATION_FAILED_FOR_VIRTUAL_FOLDER']);
     }
     if (!\Cx\Lib\FileSystem\FileSystem::exists($currentThemeFolderDirPath . $newFileName)) {
         if ($params['post']['isFolder']) {
             $status = \Cx\Lib\FileSystem\FileSystem::make_folder($currentThemeFolderDirPath . $newFileName);
             $succesMessage = sprintf($_ARRAYLANG['TXT_THEME_FOLDER_CREATE_SUCCESS'], contrexx_input2xhtml($newFileName));
         } else {
             $status = \Cx\Lib\FileSystem\FileSystem::touch($currentThemeFolderDirPath . $newFileName);
             $succesMessage = sprintf($_ARRAYLANG['TXT_THEME_FILE_CREATE_SUCCESS'], contrexx_input2xhtml($newFileName));
         }
         if (!$status) {
             return array('status' => 'error', 'message' => $_ARRAYLANG['TXT_THEME_NEWFILE_FAILED']);
         }
         return array('status' => 'success', 'reload' => true, 'message' => $succesMessage, 'path' => '/' . $newFileName);
     }
     return array('status' => 'error', 'message' => sprintf($_ARRAYLANG['TXT_THEME_OPERATION_FAILED_FOR_FILE_ALREADY_EXITS'], contrexx_input2xhtml($newFileName)));
 }
 /**
  * Create default theme files
  * 
  * \Cx\Core\View\Model\Entity\Theme $theme
  */
 private function createDefaultFiles(\Cx\Core\View\Model\Entity\Theme $theme)
 {
     global $_ARRAYLANG;
     foreach ($this->directories as $dir) {
         if (!\Cx\Lib\FileSystem\FileSystem::make_folder($this->path . $theme->getFoldername() . '/' . $dir)) {
             \Message::add(sprintf($_ARRAYLANG['TXT_UNABLE_TO_CREATE_FILE'], contrexx_raw2xhtml($theme->getFoldername() . '/' . $dir)), \Message::CLASS_ERROR);
             return false;
         }
     }
     //copy "not available" preview.gif as default preview image
     $previewImage = $this->path . $theme->getFoldername() . \Cx\Core\View\Model\Entity\Theme::THEME_PREVIEW_FILE;
     if (!file_exists($previewImage)) {
         try {
             $objFile = new \Cx\Lib\FileSystem\File(\Env::get('cx')->getCodeBaseDocumentRootPath() . \Cx\Core\View\Model\Entity\Theme::THEME_DEFAULT_PREVIEW_FILE);
             $objFile->copy($previewImage);
         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
             \DBG::msg($e->getMessage());
             \Message::add(sprintf($_ARRAYLANG['TXT_UNABLE_TO_CREATE_FILE'], contrexx_raw2xhtml($theme->getFoldername() . \Cx\Core\View\Model\Entity\Theme::THEME_PREVIEW_FILE)), \Message::CLASS_ERROR);
             return false;
         }
     }
     foreach ($this->filenames as $file) {
         // skip component.yml, will be created later
         if ($file == 'component.yml') {
             continue;
         }
         $filePath = $this->path . $theme->getFoldername() . '/' . $file;
         if (!file_exists($filePath)) {
             try {
                 $objFile = new \Cx\Lib\FileSystem\File($filePath);
                 $objFile->touch();
             } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
                 \DBG::msg($e->getMessage());
                 \Message::add(sprintf($_ARRAYLANG['TXT_UNABLE_TO_CREATE_FILE'], contrexx_raw2xhtml($theme->getFoldername() . '/' . $file)), \Message::CLASS_ERROR);
                 return false;
             }
         }
     }
     // write component.yml file
     // this line will create a default component.yml file
     try {
         $this->themeRepository->loadComponentData($theme);
         $this->themeRepository->convertThemeToComponent($theme);
     } catch (\Exception $e) {
         \DBG::msg($e->getMessage());
         \Message::add($_ARRAYLANG['TXT_UNABLE_TO_CONVERT_THEME_TO_COMPONENT'], \Message::CLASS_ERROR);
     }
     return true;
 }
 /**
  * Writes the component.yml file with the data defined in component data array
  * 
  * @param \Cx\Core\View\Model\Entity\Theme $theme the theme object
  */
 public function saveComponentData(\Cx\Core\View\Model\Entity\Theme $theme)
 {
     global $_ARRAYLANG;
     if (!file_exists(\Env::get('cx')->getWebsiteThemesPath() . '/' . $theme->getFoldername())) {
         if (!\Cx\Lib\FileSystem\FileSystem::make_folder(\Env::get('cx')->getWebsiteThemesPath() . '/' . $theme->getFoldername())) {
             \Message::add($theme->getFoldername() . " : " . $_ARRAYLANG['TXT_THEME_UNABLE_TO_CREATE']);
         }
     }
     $filePath = \Env::get('cx')->getWebsiteThemesPath() . '/' . $theme->getFoldername() . '/component.yml';
     try {
         $file = new \Cx\Lib\FileSystem\File($filePath);
         $file->touch();
         $yaml = new \Symfony\Component\Yaml\Yaml();
         $file->write($yaml->dump(array('DlcInfo' => $theme->getComponentData())));
     } catch (\Exception $e) {
         \DBG::log($e->getMessage());
         throw new $e();
     }
 }
Exemple #10
0
 public function getTempPath()
 {
     $this->cleanTempPaths();
     if (!\Cx\Lib\FileSystem\FileSystem::make_folder($this->sessionPath)) {
         return false;
     }
     if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($this->sessionPath)) {
         return false;
     }
     return ASCMS_PATH . $this->sessionPath;
 }
Exemple #11
0
 /**
  * Returns current session's temp path
  * 
  * @return string
  */
 public function getTempPath()
 {
     $this->cleanTempPaths();
     if (!\Cx\Lib\FileSystem\FileSystem::make_folder($this->sessionPath)) {
         return false;
     }
     if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($this->sessionPath)) {
         return false;
     }
     return \Env::get('cx')->getWebsitePath() . $this->sessionPath;
 }
    protected function getUploaderCode($submissionId, $fieldName, $uploadCallBack = "uploadFinished", $allowImageOnly = true)
    {
        try {
            //init the uploader
            \JS::activate('cx');
            //the uploader needs the framework
            $f = \Cx\Core_Modules\Upload\Controller\UploadFactory::getInstance();
            //retrieve temporary location for uploaded files
            $tup = self::getTemporaryUploadPath($fieldName, $submissionId);
            //create the folder
            if (!\Cx\Lib\FileSystem\FileSystem::make_folder($tup[1] . '/' . $tup[2])) {
                throw new \Exception("Could not create temporary upload directory '" . $tup[0] . '/' . $tup[2] . "'");
            }
            if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($tup[1] . '/' . $tup[2])) {
                //some hosters have problems with ftp and file system sync.
                //this is a workaround that seems to somehow show php that
                //the directory was created. clearstatcache() sadly doesn't
                //work in those cases.
                @closedir(@opendir($tup[0]));
                if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($tup[1] . '/' . $tup[2])) {
                    throw new \Exception("Could not chmod temporary upload directory '" . $tup[0] . '/' . $tup[2] . "'");
                }
            }
            /**
             * Name of the upload instance
             */
            $uploaderInstanceName = "exposed_combo_uploader_{$fieldName}_{$submissionId}";
            //initialize the widget displaying the folder contents
            $folderWidget = $f->newFolderWidget($tup[0] . '/' . $tup[2]);
            $uploader = $f->newUploader('exposedCombo', $submissionId, true);
            $uploader->setJsInstanceName($uploaderInstanceName);
            $uploader->setFinishedCallback(array(ASCMS_MODULE_PATH . '/Calendar/Controller/Calendar.class.php', '\\Cx\\Modules\\Calendar\\Controller\\Calendar', $uploadCallBack));
            $uploader->setData(array('submission_id' => $submissionId, 'field_name' => $fieldName, 'allowImageOnly' => $allowImageOnly));
            $strJs = $uploader->getXHtml();
            $strJs .= $folderWidget->getXHtml("#{$fieldName}_uploadWidget", "uploadWidget" . $submissionId);
            $strJs .= <<<JAVASCRIPT
<script type="text/javascript">
    cx.ready(function() {
            var ef = new ExtendedFileInput({
                    field:  cx.jQuery('#{$fieldName}'),
                    instance: '{$uploaderInstanceName}',
                    widget: 'uploadWidget{$submissionId}'
            });
    });
</script>
JAVASCRIPT;
            return $strJs;
        } catch (Exception $e) {
            \DBG::msg('<!-- failed initializing uploader -->');
            throw new \Exception("failed initializing uploader");
        }
    }
 /**
  * the upload is finished
  * rewrite the names
  * write the uploaded files to the database
  *
  * @static
  * @param string $tempPath the temporary file path
  * @param string $tempWebPath the temporary file path which is accessable by web browser
  * @param array $data the data which are attached by uploader init method
  * @param integer $uploadId the upload id
  * @param $fileInfos
  * @param $response
  * @return array the target paths
  */
 public static function uploadFinished($tempPath, $tempWebPath, $data, $uploadId, $fileInfos, $response)
 {
     global $objDatabase;
     // the directory which will be made from the given cmd
     $directory = $data["directory"];
     if (!$directory) {
         $directory = '';
     }
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     // get target path
     // if the cmd is "downloads" add these files to the digital asset management module directory
     if ($directory == 'Downloads') {
         $targetPath = $cx->getWebsiteImagesDownloadsPath();
         $targetPathWeb = $cx->getWebsiteImagesDownloadsWebPath();
     } else {
         $targetPath = $cx->getWebsiteMediaFileSharingPath() . (!empty($directory) ? '/' . $directory : '');
         $targetPathWeb = $cx->getWebsiteMediaFileSharingWebPath() . (!empty($directory) ? '/' . $directory : '');
     }
     // create target folder if the directory does not exist
     if (!is_dir($targetPath)) {
         \Cx\Lib\FileSystem\FileSystem::make_folder($targetPath);
         \Cx\Lib\FileSystem\FileSystem::makeWritable($targetPath);
     }
     // write the uploaded files into database
     $path = str_replace($cx->getWebsiteOffsetPath(), '', $targetPathWeb);
     foreach ($fileInfos["originalFileNames"] as $rawName => $cleanedName) {
         $file = $cleanedName;
         $source = $path . '/' . $rawName;
         $hash = self::createHash();
         $check = self::createCheck($hash);
         $objDatabase->Execute("INSERT INTO " . DBPREFIX . "module_filesharing (`file`, `source`, `cmd`, `hash`, `check`, `upload_id`)\n                                    VALUES (\n                                        '" . contrexx_raw2db($file) . "',\n                                        '" . contrexx_raw2db($source) . "',\n                                        '" . contrexx_raw2db($directory) . "',\n                                        '" . contrexx_raw2db($hash) . "',\n                                        '" . contrexx_raw2db($check) . "',\n                                        '" . intval($uploadId) . "'\n                                    )");
     }
     $tempPaths = self::getTemporaryFilePaths($uploadId);
     // return web- and filesystem path. files will be moved there.
     return array($tempPaths[0] . '/' . $tempPaths[2], $tempPaths[1] . '/' . $tempPaths[2]);
 }
Exemple #14
0
 /**
  * Add a chunk to a file. Creates the file on first chunk, appends else.
  *
  * @param string $fileName upload name
  * @param int $chunk current chunk's number
  * @param int $chunks total chunks
  * @throws UploaderException thrown if upload becomes unusable
  */
 protected function addChunk($fileName, $chunk, $chunks)
 {
     //get a writable directory
     $tempPath = $_SESSION->getTempPath();
     $webTempPath = $_SESSION->getWebTempPath();
     $dirName = 'upload_' . $this->uploadId;
     $targetDir = $tempPath . '/' . $dirName;
     if (!file_exists($targetDir)) {
         \Cx\Lib\FileSystem\FileSystem::make_folder($webTempPath . '/' . $dirName);
     }
     $cleanupTargetDir = false;
     // Remove old files
     $maxFileAge = 60 * 60;
     // Temp file age in seconds
     // 5 minutes execution time
     @set_time_limit(5 * 60);
     // remember the "raw" file name, we want to store all original
     // file names in the session.
     $originalFileName = $fileName;
     // Clean the fileName for security reasons
     // we're using a-zA-Z0-9 instead of \w because of the umlauts.
     // linux excludes them from \w, windows includes them. we do not want different
     // behaviours on different operating systems.
     $fileName = preg_replace('/[^a-zA-Z0-9\\._-]+/', '', $fileName);
     //try to retrieve session file name for chunked uploads
     if ($chunk > 0) {
         if (isset($_SESSION['upload']['handlers'][$this->uploadId]['fileName'])) {
             $fileName = $_SESSION['upload']['handlers'][$this->uploadId]['fileName'];
         } else {
             throw new UploaderException('Session lost.');
         }
     } else {
         //first chunk, store original file name in session
         $originalFileNames = array();
         if (isset($_SESSION['upload']['handlers'][$this->uploadId]['originalFileNames'])) {
             $originalFileNames = $_SESSION['upload']['handlers'][$this->uploadId]['originalFileNames'];
         }
         $originalFileNames[$fileName] = $originalFileName;
         $_SESSION['upload']['handlers'][$this->uploadId]['originalFileNames'] = $originalFileNames;
     }
     // Make sure the fileName is unique (for chunked uploads only on first chunk, since we're using the same name)
     if (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName) && $chunk == 0) {
         $ext = strrpos($fileName, '.');
         $fileName_a = substr($fileName, 0, $ext);
         $fileName_b = substr($fileName, $ext);
         $count = 1;
         while (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b)) {
             $count++;
         }
         $fileName = $fileName_a . '_' . $count . $fileName_b;
     }
     //$fileName contains now the name we'll use for the whole upload process, so store it.
     $_SESSION['upload']['handlers'][$this->uploadId]['fileName'] = $fileName;
     // Remove old temp files
     if (is_dir($targetDir) && ($dir = opendir($targetDir))) {
         while (($file = readdir($dir)) !== false) {
             $filePath = $targetDir . DIRECTORY_SEPARATOR . $file;
             // Remove temp files if they are older than the max age
             if (preg_match('/\\.tmp$/', $file) && filemtime($filePath) < time() - $maxFileAge) {
                 @unlink($filePath);
             }
         }
         closedir($dir);
     } else {
         throw new UploaderException('Failed to open temp directory.');
     }
     $contentType = '';
     // Look for the content type header
     if (isset($_SERVER["HTTP_CONTENT_TYPE"])) {
         $contentType = $_SERVER["HTTP_CONTENT_TYPE"];
     }
     if (isset($_SERVER["CONTENT_TYPE"])) {
         $contentType = $_SERVER["CONTENT_TYPE"];
     }
     if (strpos($contentType, "multipart") !== false) {
         if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
             // Open temp file
             $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
             if ($out) {
                 // Read binary input stream and append it to temp file
                 $in = fopen($_FILES['file']['tmp_name'], "rb");
                 if ($in) {
                     while ($buff = fread($in, 4096)) {
                         fwrite($out, $buff);
                     }
                 } else {
                     throw new UploaderException('Failed to open input stream.');
                 }
                 fclose($out);
                 unlink($_FILES['file']['tmp_name']);
             } else {
                 throw new UploaderException('Failed to open output stream.');
             }
         } else {
             throw new UploaderException('Failed to move uploaded file.');
         }
     } else {
         // Open temp file
         $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
         if ($out) {
             // Read binary input stream and append it to temp file
             $in = fopen("php://input", "rb");
             if ($in) {
                 while ($buff = fread($in, 4096)) {
                     fwrite($out, $buff);
                 }
             } else {
                 throw new UploaderException('Failed to open input stream.');
             }
             fclose($out);
         } else {
             throw new UploaderException('Failed to open output stream.');
         }
     }
     // Send HTTP header to force the browser to send the next file-chunt
     // through a new connection. File-chunks that are sent through the
     // same connection get dropped by the web-server.
     header('Connection: close');
 }
Exemple #15
0
 public function move($dst, $force = false)
 {
     if (!$force && file_exists($dst)) {
         return true;
     }
     $path = ASCMS_PATH . ASCMS_PATH_OFFSET;
     $relPath = str_replace($path, '', $dst);
     $pathInfo = pathinfo($relPath);
     $arrFolders = explode('/', $pathInfo['dirname']);
     foreach ($arrFolders as $folder) {
         if (empty($folder)) {
             continue;
         }
         $path .= '/' . $folder;
         if (!is_dir($path)) {
             \Cx\Lib\FileSystem\FileSystem::make_folder($path);
         }
     }
     // use PHP
     if ($this->accessMode == self::PHP_ACCESS || $this->accessMode == self::UNKNOWN_ACCESS) {
         try {
             // try regular file access first
             $fsFile = new FileSystemFile($this->file);
             $fsFile->move($dst);
             return true;
         } catch (FileSystemFileException $e) {
             \DBG::msg('FileSystemFile: ' . $e->getMessage());
         }
     }
     // use FTP
     if ($this->accessMode == self::FTP_ACCESS || $this->accessMode == self::UNKNOWN_ACCESS) {
         try {
             $ftpFile = new FTPFile($this->file);
             $ftpFile->move($dst);
             return true;
         } catch (FTPFileException $e) {
             \DBG::msg('FTPFile: ' . $e->getMessage());
         }
     }
     throw new FileSystemException('File: Unable to copy file ' . $this->file . '!');
 }
 protected function cleanup()
 {
     \Cx\Lib\FileSystem\FileSystem::delete_folder($this->cx->getWebsiteTempPath() . '/workbench', true);
     \Cx\Lib\FileSystem\FileSystem::make_folder($this->cx->getWebsiteTempPath() . '/workbench');
 }
Exemple #17
0
function copyCxFilesToRoot($src, $dst)
{
    static $copiedCxFilesIndex = 0;
    $src = str_replace('\\', '/', $src);
    $dst = str_replace('\\', '/', $dst);
    $dir = opendir($src);
    $arrCurrentFolderStructure = array();
    while ($file = readdir($dir)) {
        if (!in_array($file, array('.', '..'))) {
            $arrCurrentFolderStructure[] = $file;
        }
    }
    sort($arrCurrentFolderStructure);
    if (!isset($_SESSION['contrexx_update']['copiedCxFilesTotal'])) {
        $_SESSION['contrexx_update']['copiedCxFilesTotal'] = 0;
    }
    foreach ($arrCurrentFolderStructure as $file) {
        if (!checkMemoryLimit() || !checkTimeoutLimit()) {
            $_SESSION['contrexx_update']['copiedCxFilesIndex'] = $copiedCxFilesIndex;
            return 'timeout';
        }
        $srcPath = $src . '/' . $file;
        $dstPath = $dst . '/' . $file;
        if (is_dir($srcPath)) {
            \Cx\Lib\FileSystem\FileSystem::make_folder($dstPath);
            $status = copyCxFilesToRoot($srcPath, $dstPath);
            if ($status !== true) {
                return $status;
            }
        } else {
            $copiedCxFilesIndex++;
            if (isset($_SESSION['contrexx_update']['copiedCxFilesIndex']) && $copiedCxFilesIndex <= $_SESSION['contrexx_update']['copiedCxFilesIndex']) {
                continue;
            }
            $_SESSION['contrexx_update']['copiedCxFilesTotal'] = $_SESSION['contrexx_update']['copiedCxFilesTotal'] + 1;
            try {
                // rename the file if its exists on customizing
                if (!renameCustomizingFile($dstPath)) {
                    return false;
                }
                if (!verifyMd5SumOfFile($dstPath, $srcPath)) {
                    if (!backupModifiedFile($dstPath)) {
                        return false;
                    }
                }
                $objFile = new \Cx\Lib\FileSystem\File($srcPath);
                $objFile->copy($dstPath, true);
            } catch (\Exception $e) {
                $copiedCxFilesIndex--;
                $_SESSION['contrexx_update']['copiedCxFilesIndex'] = $copiedCxFilesIndex;
                $_SESSION['contrexx_update']['copiedCxFilesTotal'] = $_SESSION['contrexx_update']['copiedCxFilesTotal'] - 1;
                setUpdateMsg('Folgende Datei konnte nicht installiert werden:<br />' . $dstPath);
                setUpdateMsg('Fehler: ' . $e->getMessage());
                setUpdateMsg('<br />Häufigste Ursache dieses Problems ist, dass zur Ausführung dieses Vorgangs die benötigten Schreibrechte nicht vorhanden sind. Prüfen Sie daher, ob die FTP-Konfiguration in der Datei <strong>config/configuration.php</strong> korrekt eingerichtet ist.');
                return false;
            }
        }
    }
    closedir($dir);
    return true;
}
 /**
  * Write db structure and data into a file 
  * 
  * @global type $_DBCONFIG
  */
 private function writeDatabaseStructureAndData()
 {
     $componentTables = $this->getComponentTables();
     $dataFolder = ASCMS_APP_CACHE_FOLDER . '/DLC_FILES' . SystemComponent::getPathForType($this->componentType) . '/' . $this->componentName . '/Data';
     \Cx\Lib\FileSystem\FileSystem::make_folder($dataFolder);
     // check whether its a doctrine component
     if (!file_exists($this->getDirectory(false) . "/Model/Yaml")) {
         $this->writeTableStructureToFile($componentTables, $dataFolder . '/Structure.sql');
     }
     $this->writeTableDataToFile($componentTables, $dataFolder . '/Data.sql');
 }
function contentManagerUpdates()
{
    //Database migration
    try {
        //update module name
        \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "modules` (`id`, `name`, `distributor`, `description_variable`, `status`, `is_required`, `is_core`, `is_active`, `is_licensed`) VALUES ('72', 'ContentManager', 'DEV', 'TXT_CONTENTMANAGER_MODULE_DESCRIPTION', 'n', '0', '1', '1', '1')");
        //update navigation url
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=ContentManager&act=new' WHERE `area_id` = 5");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=ContentManager' WHERE `area_id` = 6");
        \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "backend_areas` SET `uri` = 'index.php?cmd=ContentManager' WHERE `area_id` = 161");
        //Alter the content_page table structure
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'content_page', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'node_id' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'id'), 'nodeIdShadowed' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'node_id'), 'lang' => array('type' => 'INT(11)', 'after' => 'nodeIdShadowed'), 'type' => array('type' => 'VARCHAR(16)', 'after' => 'lang'), 'caching' => array('type' => 'TINYINT(1)', 'after' => 'type'), 'updatedAt' => array('type' => 'timestamp', 'after' => 'caching'), 'updatedBy' => array('type' => 'CHAR(40)', 'after' => 'updatedAt'), 'title' => array('type' => 'VARCHAR(255)', 'after' => 'updatedBy'), 'linkTarget' => array('type' => 'VARCHAR(16)', 'notnull' => false, 'after' => 'title'), 'contentTitle' => array('type' => 'VARCHAR(255)', 'after' => 'linkTarget'), 'slug' => array('type' => 'VARCHAR(255)', 'after' => 'contentTitle'), 'content' => array('type' => 'longtext', 'after' => 'slug'), 'sourceMode' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'content'), 'customContent' => array('type' => 'VARCHAR(64)', 'notnull' => false, 'after' => 'sourceMode'), 'useCustomContentForAllChannels' => array('type' => 'INT(2)', 'notnull' => false, 'after' => 'customContent'), 'applicationTemplate' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'after' => 'useCustomContentForAllChannels'), 'useCustomApplicationTemplateForAllChannels' => array('type' => 'TINYINT(2)', 'after' => 'applicationTemplate'), 'cssName' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'useCustomApplicationTemplateForAllChannels'), 'cssNavName' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'cssName'), 'skin' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'cssNavName'), 'useSkinForAllChannels' => array('type' => 'INT(2)', 'notnull' => false, 'after' => 'skin'), 'metatitle' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'useSkinForAllChannels'), 'metadesc' => array('type' => 'text', 'after' => 'metatitle'), 'metakeys' => array('type' => 'text', 'after' => 'metadesc'), 'metarobots' => array('type' => 'VARCHAR(7)', 'notnull' => false, 'after' => 'metakeys'), 'start' => array('type' => 'timestamp', 'after' => 'metarobots'), 'end' => array('type' => 'timestamp', 'after' => 'start'), 'editingStatus' => array('type' => 'VARCHAR(16)', 'after' => 'end'), 'protection' => array('type' => 'INT(11)', 'after' => 'editingStatus'), 'frontendAccessId' => array('type' => 'INT(11)', 'after' => 'protection'), 'backendAccessId' => array('type' => 'INT(11)', 'after' => 'frontendAccessId'), 'display' => array('type' => 'TINYINT(1)', 'after' => 'backendAccessId'), 'active' => array('type' => 'TINYINT(1)', 'after' => 'display'), 'target' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'active'), 'module' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'target'), 'cmd' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '', 'after' => 'module')), array('node_id' => array('fields' => array('node_id', 'lang'), 'type' => 'UNIQUE'), 'IDX_D8E86F54460D9FD7' => array('fields' => array('node_id'))), 'InnoDB', '', array('node_id' => array('table' => DBPREFIX . 'content_node', 'column' => 'id', 'onDelete' => 'SET NULL', 'onUpdate' => 'NO ACTION')));
    } catch (\Cx\Lib\UpdateException $e) {
        return "Error: {$e->sql}";
    }
    $virtualComponents = array('Agb', 'Ids', 'Imprint', 'Privacy');
    //migrating custom application template
    $pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
    $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository();
    $pages = $pageRepo->findBy(array('type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION));
    foreach ($pages as $page) {
        try {
            //virtual components do not migrating custom application template
            if (in_array(ucfirst($page->getModule()), $virtualComponents)) {
                continue;
            }
            $designTemplateName = $page->getSkin() ? $themeRepo->findById($page->getSkin())->getFoldername() : $themeRepo->getDefaultTheme()->getFoldername();
            $cmd = !$page->getCmd() ? 'Default' : ucfirst($page->getCmd());
            $moduleFolderName = contrexx_isCoreModule($page->getModule()) ? 'core_modules' : 'modules';
            $themesPath = ASCMS_THEMES_PATH . '/' . $designTemplateName;
            //check common module or core_module folder exists
            if (!file_exists($themesPath . '/' . $moduleFolderName)) {
                \Cx\Lib\FileSystem\FileSystem::make_folder($themesPath . '/' . $moduleFolderName);
            }
            //check module's folder exists
            if (!file_exists($themesPath . '/' . $moduleFolderName . '/' . $page->getModule())) {
                \Cx\Lib\FileSystem\FileSystem::make_folder($themesPath . '/' . $moduleFolderName . '/' . $page->getModule());
            }
            //check module's template folder exists
            if (!file_exists($themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template')) {
                \Cx\Lib\FileSystem\FileSystem::make_folder($themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template');
            }
            //check module's Frontend folder exists
            if (!file_exists($themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template/Frontend')) {
                \Cx\Lib\FileSystem\FileSystem::make_folder($themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template/Frontend');
            }
            $targetPath = $themesPath . '/' . $moduleFolderName . '/' . $page->getModule() . '/Template/Frontend';
            $applicationTemplateName = getFilename($targetPath, $cmd . '_custom_' . FWLanguage::getLanguageCodeById($page->getLang()));
            if (file_exists($targetPath)) {
                //create a application template file
                $file = new \Cx\Lib\FileSystem\File($targetPath . '/' . $applicationTemplateName);
                $file->write($page->getContent());
            }
            //update application template
            $page->setContent('{APPLICATION_DATA}');
            $page->setApplicationTemplate($applicationTemplateName);
            $page->setUseCustomApplicationTemplateForAllChannels(1);
            \Env::get('em')->persist($page);
            \Env::get('em')->flush();
        } catch (\Exception $e) {
            throw new \Exception('Error :' . $e);
        }
    }
    return 'Application template migrated successfully.';
}
 /**
  * Makes sure that the cache directory exists and is writable
  * @param \Cx\Core\Core\Controller\Cx $cx The contrexx instance
  */
 protected function checkCacheDir($cx)
 {
     if (!is_dir($cx->getWebsiteCachePath())) {
         \Cx\Lib\FileSystem\FileSystem::make_folder($cx->getWebsiteCachePath());
     }
     if (!is_writable($cx->getWebsiteCachePath())) {
         \Cx\Lib\FileSystem\FileSystem::makeWritable($cx->getWebsiteCachePath());
     }
 }
 public function createDirectory($path, $directory)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('MediaBrowser');
     if (!\Cx\Lib\FileSystem\FileSystem::make_folder($this->rootPath . $path . '/' . $directory)) {
         return sprintf($_ARRAYLANG['TXT_FILEBROWSER_UNABLE_TO_CREATE_FOLDER'], $directory);
     } else {
         return sprintf($_ARRAYLANG['TXT_FILEBROWSER_DIRECTORY_SUCCESSFULLY_CREATED'], $directory);
     }
 }
Exemple #22
0
 /**
  * Handle uploads
  * @see Contact::_uploadFilesLegacy()
  * @param array $arrFields
  * @param boolean move should the files be moved or
  *                do we just want an array of filenames?
  *                defaults to false. no effect in legacy mode.
  * @return array A list of files that have been stored successfully in the system
  */
 protected function _uploadFiles($arrFields, $move = false)
 {
     /* the field unique_id has been introduced with the new uploader.
      * it helps us to tell whether we're handling an form generated
      * before the new uploader using the classic input fields or
      * if we have to treat the files already uploaded by the uploader.
      */
     if ($this->legacyMode) {
         //legacy function for old uploader
         return $this->_uploadFilesLegacy($arrFields);
     } else {
         //new uploader used
         if (!$this->hasFileField) {
             //nothing to do for us, no files
             return array();
         }
         $arrFiles = array();
         //we'll collect name => path of all files here and return this
         $documentRootPath = \Env::get('cx')->getWebsiteDocumentRootPath();
         foreach ($arrFields as $fieldId => $arrField) {
             // skip non-upload fields
             if (!in_array($arrField['type'], array('file', 'multi_file'))) {
                 continue;
             }
             $tup = self::getTemporaryUploadPath($this->submissionId, $fieldId);
             $tmpUploadDir = $tup[1] . '/' . $tup[2] . '/';
             //all the files uploaded are in here
             $depositionTarget = "";
             //target folder
             //on the first call, _uploadFiles is called with move=false.
             //this is done in order to get an array of the moved files' names, but
             //the files are left in place.
             //the second call is done with move=true - here we finally move the
             //files.
             //
             //the target folder is created in the first call, because if we can't
             //create the folder, the target path is left pointing at the path
             //specified by $arrSettings['fileUploadDepositionPath'].
             //
             //to remember the target folder for the second call, it is stored in
             //$this->depositionTarget.
             if (!$move) {
                 //first call - create folder
                 //determine where form uploads are stored
                 $arrSettings = $this->getSettings();
                 $depositionTarget = $arrSettings['fileUploadDepositionPath'] . '/';
                 //find an unique folder name for the uploaded files
                 $folderName = date("Ymd") . '_' . $fieldId;
                 $suffix = "";
                 if (file_exists($documentRootPath . $depositionTarget . $folderName)) {
                     $suffix = 1;
                     while (file_exists($documentRootPath . $depositionTarget . $folderName . '-' . $suffix)) {
                         $suffix++;
                     }
                     $suffix = '-' . $suffix;
                 }
                 $folderName .= $suffix;
                 //try to make the folder and change target accordingly on success
                 if (\Cx\Lib\FileSystem\FileSystem::make_folder($documentRootPath . $depositionTarget . $folderName)) {
                     \Cx\Lib\FileSystem\FileSystem::makeWritable($documentRootPath . $depositionTarget . $folderName);
                     $depositionTarget .= $folderName . '/';
                 }
                 $this->depositionTarget[$fieldId] = $depositionTarget;
             } else {
                 $depositionTarget = $this->depositionTarget[$fieldId];
             }
             //move all files
             if (!\Cx\Lib\FileSystem\FileSystem::exists($tmpUploadDir)) {
                 throw new \Cx\Core_Modules\Contact\Controller\ContactException("could not find temporary upload directory '{$tmpUploadDir}'");
             }
             $h = opendir(\Env::get('cx')->getWebsitePath() . $tmpUploadDir);
             while (false !== ($f = readdir($h))) {
                 if ($f != '..' && $f != '.') {
                     //do not overwrite existing files.
                     $prefix = '';
                     while (file_exists($documentRootPath . $depositionTarget . $prefix . $f)) {
                         if (empty($prefix)) {
                             $prefix = 0;
                         }
                         $prefix++;
                     }
                     if ($move) {
                         // move file
                         try {
                             $objFile = new \Cx\Lib\FileSystem\File($tmpUploadDir . $f);
                             $objFile->move($documentRootPath . $depositionTarget . $prefix . $f, false);
                         } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
                             \DBG::msg($e->getMessage());
                         }
                     }
                     $arrFiles[$fieldId][] = array('name' => $f, 'path' => $depositionTarget . $prefix . $f);
                 }
             }
         }
         //cleanup
         //TODO: this does not work for certain reloads - add cleanup routine
         //@rmdir($tmpUploadDir);
         return $arrFiles;
     }
 }
 public function createDirectory($path, $directory)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('MediaBrowser');
     if (preg_match('#^[0-9a-zA-Z_\\-\\/]+$#', $directory)) {
         if (!\Cx\Lib\FileSystem\FileSystem::make_folder($path . '/' . $directory)) {
             return sprintf($_ARRAYLANG['TXT_FILEBROWSER_UNABLE_TO_CREATE_FOLDER'], $directory);
         } else {
             return sprintf($_ARRAYLANG['TXT_FILEBROWSER_DIRECTORY_SUCCESSFULLY_CREATED'], $directory);
         }
     } else {
         if (!empty($directory)) {
             return $_ARRAYLANG['TXT_FILEBROWSER_INVALID_CHARACTERS'];
         }
     }
     return sprintf($_ARRAYLANG['TXT_FILEBROWSER_UNABLE_TO_CREATE_FOLDER'], $directory);
 }