当前位置: 首页>>代码示例>>PHP>>正文


PHP FileSystem::make_folder方法代码示例

本文整理汇总了PHP中Cx\Lib\FileSystem\FileSystem::make_folder方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::make_folder方法的具体用法?PHP FileSystem::make_folder怎么用?PHP FileSystem::make_folder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cx\Lib\FileSystem\FileSystem的用法示例。


在下文中一共展示了FileSystem::make_folder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _createNewDir

 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']);
     }
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:12,代码来源:MediaLibrary.class.php

示例2: __construct

 /**
  * 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);
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:15,代码来源:DeltaRepository.class.php

示例3: ecardUpdates

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();
    }
}
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:49,代码来源:Ecard.php

示例4: handleRequest

 /**
  * @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();
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:49,代码来源:FormUploader.class.php

示例5: initContrexxCaching

 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));
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:44,代码来源:Cache.class.php

示例6: storeUpdateWebsiteDetailsToYml

 /**
  * 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());
     }
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:26,代码来源:UpdateController.class.php

示例7: newWithin

 /**
  * 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)));
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:53,代码来源:JsonViewManager.class.php

示例8: createDefaultFiles

 /**
  * 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;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:54,代码来源:ViewManager.class.php

示例9: saveComponentData

 /**
  * 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();
     }
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:24,代码来源:ThemeRepository.class.php

示例10: getTempPath

 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;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:11,代码来源:session.class.php

示例11: getTempPath

 /**
  * 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;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:16,代码来源:session.class.php

示例12: getUploaderCode

    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");
        }
    }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:52,代码来源:Calendar.class.php

示例13: uploadFinished

 /**
  * 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]);
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:50,代码来源:FileSharingLib.class.php

示例14: addChunk

 /**
  * 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.');
//.........这里部分代码省略.........
开发者ID:Niggu,项目名称:cloudrexx,代码行数:101,代码来源:Uploader.class.php

示例15: move

 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 . '!');
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:41,代码来源:File.class.php


注:本文中的Cx\Lib\FileSystem\FileSystem::make_folder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。