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


PHP jFile::createDir方法代码示例

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


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

示例1: set

 /**
  * set
  *
  * @param string $key	a key (unique name) to identify the cached info
  * @param mixed  $value	the value to cache
  * @param integer $ttl how many seconds will the info be cached
  *
  * @return boolean whether the action was successful or not
  */
 public function set($key, $value, $ttl)
 {
     $r = false;
     if ($fl = @fopen($this->dir . '/.flock', 'w+')) {
         if (flock($fl, LOCK_EX)) {
             // mutex zone
             $md5 = md5($key);
             $subdir = $md5[0] . $md5[1];
             if (!file_exists($this->dir . '/' . $subdir)) {
                 jFile::createDir($this->dir . '/' . $subdir);
             }
             // write data to cache
             $fn = $this->dir . '/' . $subdir . '/' . $md5;
             if ($f = @gzopen($fn . '.tmp', 'w')) {
                 // write temporary file
                 fputs($f, base64_encode(serialize($value)));
                 fclose($f);
                 // change time of the file to the expiry time
                 @touch("{$fn}.tmp", time() + $ttl);
                 // rename the temporary file
                 $r = @rename("{$fn}.tmp", $fn);
             }
             // end of mutex zone
             flock($fl, LOCK_UN);
         }
     }
     return $r;
 }
开发者ID:medali1990,项目名称:medsite,代码行数:37,代码来源:file2.kvdriver.php

示例2: run

 public function run()
 {
     $this->loadAppConfig();
     $config = jApp::config();
     $model_lang = $this->getParam('model_lang', $config->locale);
     $lang = $this->getParam('lang');
     foreach ($config->_modulesPathList as $module => $dir) {
         $source_dir = $dir . 'locales/' . $model_lang . '/';
         if (!file_exists($source_dir)) {
             continue;
         }
         $target_dir = jApp::varPath('overloads/' . $module . '/locales/' . $lang . '/');
         jFile::createDir($target_dir);
         if ($dir_r = opendir($source_dir)) {
             while (FALSE !== ($fich = readdir($dir_r))) {
                 if ($fich != "." && $fich != ".." && is_file($source_dir . $fich) && strpos($fich, '.' . $config->charset . '.properties') && !file_exists($target_dir . $fich)) {
                     copy($source_dir . $fich, $target_dir . $fich);
                     if ($this->verbose()) {
                         echo "Copy Locales file {$fich} from {$source_dir} to {$target_dir}.\n";
                     }
                 }
             }
             closedir($dir_r);
         }
     }
 }
开发者ID:havefnubb,项目名称:havefnubb,代码行数:26,代码来源:createlangpackage.cmd.php

示例3: _execute

 protected function _execute(InputInterface $input, OutputInterface $output)
 {
     $config = App::config();
     $model_lang = $input->getArgument('model_lang');
     if (!$model_lang) {
         $model_lang = $config->locale;
     }
     $lang = $input->getArgument('lang');
     foreach ($config->_modulesPathList as $module => $dir) {
         $source_dir = $dir . 'locales/' . $model_lang . '/';
         if (!file_exists($source_dir)) {
             continue;
         }
         if ($input->getOption('to-overload')) {
             $target_dir = App::appPath('app/overloads/' . $module . '/locales/' . $lang . '/');
         } else {
             $target_dir = App::appPath('app/locales/' . $lang . '/' . $module . '/locales/');
         }
         \jFile::createDir($target_dir);
         if ($dir_r = opendir($source_dir)) {
             while (FALSE !== ($fich = readdir($dir_r))) {
                 if ($fich != "." && $fich != ".." && is_file($source_dir . $fich) && strpos($fich, '.' . $config->charset . '.properties') && !file_exists($target_dir . $fich)) {
                     copy($source_dir . $fich, $target_dir . $fich);
                     if ($this->verbose()) {
                         $output->writeln("Copy Locales file {$fich} from {$source_dir} to {$target_dir}.");
                     }
                 }
             }
             closedir($dir_r);
         }
     }
 }
开发者ID:mdouchin,项目名称:jelix,代码行数:32,代码来源:CreateLangPackage.php

示例4: _connect

 public function _connect()
 {
     if (isset($this->_profile['storage_dir']) && $this->_profile['storage_dir'] != '') {
         $this->_storage_dir = str_replace(array('var:', 'temp:'), array(jApp::varPath(), jApp::tempPath()), $this->_profile['storage_dir']);
         $this->_storage_dir = rtrim($this->_storage_dir, '\\/') . DIRECTORY_SEPARATOR;
     } else {
         $this->_storage_dir = jApp::varPath('kvfiles/');
     }
     jFile::createDir($this->_storage_dir);
     if (isset($this->_profile['file_locking'])) {
         $this->_file_locking = $this->_profile['file_locking'] ? true : false;
     }
     if (isset($this->_profile['automatic_cleaning_factor'])) {
         $this->automatic_cleaning_factor = $this->_profile['automatic_cleaning_factor'];
     }
     if (isset($this->_profile['directory_level']) && $this->_profile['directory_level'] > 0) {
         $this->_directory_level = $this->_profile['directory_level'];
         if ($this->_directory_level > 16) {
             $this->_directory_level = 16;
         }
     }
     if (isset($this->_profile['directory_umask']) && is_string($this->_profile['directory_umask']) && $this->_profile['directory_umask'] != '') {
         $this->_directory_umask = octdec($this->_profile['directory_umask']);
     }
     if (isset($this->_profile['file_umask']) && is_string($this->_profile['file_umask']) && $this->_profile['file_umask'] != '') {
         $this->file_umask = octdec($this->_profile['file_umask']);
     }
 }
开发者ID:hadrienl,项目名称:jelix,代码行数:28,代码来源:file.kvdriver.php

示例5: loadProfile

 protected function loadProfile()
 {
     try {
         jProfiles::get('jcache', 'jforms', true);
     } catch (Exception $e) {
         // no profile, let's create a default profile
         $cacheDir = jApp::tempPath('jforms');
         jFile::createDir($cacheDir);
         $params = array('enabled' => 1, 'driver' => 'file', 'ttl' => 3600 * 48, 'automatic_cleaning_factor' => 3, 'cache_dir' => $cacheDir, 'directory_level' => 3);
         jProfiles::createVirtualProfile('jcache', 'jforms', $params);
     }
 }
开发者ID:mdouchin,项目名称:jelix,代码行数:12,代码来源:jFormsSession.class.php

示例6: readAndCache

 public static function readAndCache($configFile, $isCli = null, $pseudoScriptName = '')
 {
     if ($isCli === null) {
         $isCli = jServer::isCLI();
     }
     $config = self::read($configFile, false, $isCli, $pseudoScriptName);
     $tempPath = jApp::tempPath();
     jFile::createDir($tempPath);
     if (BYTECODE_CACHE_EXISTS) {
         $filename = $tempPath . str_replace('/', '~', $configFile) . '.conf.php';
         if ($f = @fopen($filename, 'wb')) {
             fwrite($f, '<?php $config = ' . var_export(get_object_vars($config), true) . ";\n?>");
             fclose($f);
         } else {
             throw new Exception('Error while writing configuration cache file -- ' . $filename);
         }
     } else {
         jIniFile::write(get_object_vars($config), $tempPath . str_replace('/', '~', $configFile) . '.resultini.php', ";<?php die('');?>\n");
     }
     return $config;
 }
开发者ID:havefnubb,项目名称:havefnubb,代码行数:21,代码来源:jConfigCompiler.class.php

示例7: set

 public function set($key, $value, $ttl)
 {
     $r = false;
     if ($fl = @fopen($this->dir . '/.flock', 'w+')) {
         if (flock($fl, LOCK_EX)) {
             $md5 = md5($key);
             $subdir = $md5[0] . $md5[1];
             if (!file_exists($this->dir . '/' . $subdir)) {
                 jFile::createDir($this->dir . '/' . $subdir);
             }
             $fn = $this->dir . '/' . $subdir . '/' . $md5;
             if ($f = @gzopen($fn . '.tmp', 'w')) {
                 fputs($f, base64_encode(serialize($value)));
                 fclose($f);
                 @touch("{$fn}.tmp", time() + $ttl);
                 $r = @rename("{$fn}.tmp", $fn);
             }
             flock($fl, LOCK_UN);
         }
     }
     return $r;
 }
开发者ID:havefnubb,项目名称:havefnubb,代码行数:22,代码来源:file2.kvdriver.php

示例8: __construct

 public function __construct($params)
 {
     $this->profil_name = $params['_name'];
     if (isset($params['enabled'])) {
         $this->enabled = $params['enabled'] ? true : false;
     }
     if (isset($params['ttl'])) {
         $this->ttl = $params['ttl'];
     }
     $this->_cache_dir = jApp::tempPath('cache/') . $this->profil_name . '/';
     if (isset($params['cache_dir']) && $params['cache_dir'] != '') {
         if (is_dir($params['cache_dir']) && is_writable($params['cache_dir'])) {
             $this->_cache_dir = rtrim(realpath($params['cache_dir']), '\\/') . DIRECTORY_SEPARATOR;
         } else {
             throw new jException('jelix~cache.directory.not.writable', $this->profil_name);
         }
     } else {
         jFile::createDir($this->_cache_dir);
     }
     if (isset($params['file_locking'])) {
         $this->_file_locking = $params['file_locking'] ? true : false;
     }
     if (isset($params['automatic_cleaning_factor'])) {
         $this->automatic_cleaning_factor = $params['automatic_cleaning_factor'];
     }
     if (isset($params['directory_level']) && $params['directory_level'] > 0) {
         $this->_directory_level = $params['directory_level'];
     }
     if (isset($params['directory_umask']) && is_string($params['directory_umask']) && $params['directory_umask'] != '') {
         $this->_directory_umask = octdec($params['directory_umask']);
     }
     if (isset($params['file_name_prefix'])) {
         $this->_file_name_prefix = $params['file_name_prefix'];
     }
     if (isset($params['cache_file_umask']) && is_string($params['cache_file_umask']) && $params['cache_file_umask'] != '') {
         $this->_cache_file_umask = octdec($params['cache_file_umask']);
     }
 }
开发者ID:havefnubb,项目名称:havefnubb,代码行数:38,代码来源:file.cache.php

示例9: readAndCache

 /**
  * Identical to read(), but also stores the result in a temporary file
  * @return object an object which contains configuration values
  */
 public function readAndCache()
 {
     $config = $this->read(false);
     $tempPath = App::tempPath();
     \jFile::createDir($tempPath, $config->chmodDir);
     $filename = $tempPath . str_replace('/', '~', $this->configFileName);
     if (BYTECODE_CACHE_EXISTS) {
         $filename .= '.conf.php';
         if ($f = @fopen($filename, 'wb')) {
             fwrite($f, '<?php $config = ' . var_export(get_object_vars($config), true) . ";\n?>");
             fclose($f);
             chmod($filename, $config->chmodFile);
         } else {
             throw new Exception('Error while writing configuration cache file -- ' . $filename);
         }
     } else {
         IniFileMgr::write(get_object_vars($config), $filename . '.resultini.php', ";<?php die('');?>\n", '', $config->chmodFile);
     }
     return $config;
 }
开发者ID:jelix,项目名称:jelix,代码行数:24,代码来源:Compiler.php

示例10: createVirtualProfile

 public static function createVirtualProfile($repository, $project, $layers, $crs)
 {
     // Set cache configuration
     $cacheName = 'lizmapCache_' . $repository . '_' . $project . '_' . $layers . '_' . $crs;
     if (array_key_exists($cacheName, self::$_profiles)) {
         return $cacheName;
     }
     // Storage type
     $ser = lizmap::getServices();
     $cacheStorageType = $ser->cacheStorageType;
     // Expiration time : take default one
     $cacheExpiration = (int) $ser->cacheExpiration;
     // Cache root directory
     if ($cacheStorageType != 'redis') {
         $cacheRootDirectory = $ser->cacheRootDirectory;
         if (!is_writable($cacheRootDirectory) or !is_dir($cacheRootDirectory)) {
             $cacheRootDirectory = sys_get_temp_dir();
         }
     }
     if ($cacheStorageType == 'file') {
         // CACHE CONTENT INTO FILE SYSTEM
         // Directory where to store the cached files
         $cacheDirectory = $cacheRootDirectory . '/' . $repository . '/' . $project . '/' . $layers . '/' . $crs . '/';
         // Create directory if needed
         jFile::createDir($cacheDirectory);
         // Virtual cache profile parameter
         $cacheParams = array("driver" => "file", "cache_dir" => $cacheDirectory, "file_locking" => True, "directory_level" => "5", "file_name_prefix" => "lizmap_", "ttl" => $cacheExpiration);
         // Create the virtual cache profile
         jProfiles::createVirtualProfile('jcache', $cacheName, $cacheParams);
     } elseif ($cacheStorageType == 'redis') {
         // CACHE CONTENT INTO REDIS
         self::declareRedisProfile($ser, $cacheName, $repository, $project, $layers, $crs);
     } else {
         // CACHE CONTENT INTO SQLITE DATABASE
         // Directory where to store the sqlite database
         $cacheDirectory = $cacheRootDirectory . '/' . $repository . '/' . $project . '/';
         jFile::createDir($cacheDirectory);
         // Create directory if needed
         $cacheDatabase = $cacheDirectory . $layers . '_' . $crs . '.db';
         $cachePdoDsn = 'sqlite:' . $cacheDatabase;
         // Create database and populate with table if needed
         if (!file_exists($cacheDatabase)) {
             copy(jApp::varPath() . "cacheTemplate.db", $cacheDatabase);
         }
         // Virtual jdb profile corresponding to the layer database
         $jdbParams = array("driver" => "pdo", "dsn" => $cachePdoDsn, "user" => "cache", "password" => "cache");
         // Create the virtual jdb profile
         $cacheJdbName = "jdb_" . $cacheName;
         jProfiles::createVirtualProfile('jdb', $cacheJdbName, $jdbParams);
         // Virtual cache profile parameter
         $cacheParams = array("driver" => "db", "dbprofile" => $cacheJdbName, "ttl" => $cacheExpiration, "base64encoding" => true);
         // Create the virtual cache profile
         jProfiles::createVirtualProfile('jcache', $cacheName, $cacheParams);
     }
     self::$_profiles[$cacheName] = true;
     return $cacheName;
 }
开发者ID:aeag,项目名称:lizmap-web-client,代码行数:57,代码来源:lizmapProxy.class.php

示例11: migrate_1_7_0

 protected function migrate_1_7_0()
 {
     $this->reporter->message('Start migration to 1.7.0', 'notice');
     $newConfigPath = App::appConfigPath();
     if (!file_exists($newConfigPath)) {
         $this->reporter->message('Create app/config/', 'notice');
         \jFile::createDir($newConfigPath);
     }
     // move mainconfig.php to app/config/
     if (!file_exists($newConfigPath . 'mainconfig.ini.php')) {
         if (!file_exists(App::configPath('mainconfig.ini.php'))) {
             if (!file_exists(App::configPath('defaultconfig.ini.php'))) {
                 throw new \Exception("Migration to Jelix 1.7.0 canceled: where is your mainconfig.ini.php?");
             }
             $this->reporter->message('Move var/config/defaultconfig.ini.php to app/config/mainconfig.ini.php', 'notice');
             rename(App::configPath('defaultconfig.ini.php'), $newConfigPath . 'mainconfig.ini.php');
         } else {
             $this->reporter->message('Move var/config/mainconfig.ini.php to app/config/', 'notice');
             rename(App::configPath('mainconfig.ini.php'), $newConfigPath . 'mainconfig.ini.php');
         }
     }
     // move entrypoint configs to app/config
     $projectxml = simplexml_load_file(App::appPath('project.xml'));
     // read all entry points data
     foreach ($projectxml->entrypoints->entry as $entrypoint) {
         $configFile = (string) $entrypoint['config'];
         $dest = App::appConfigPath($configFile);
         if (!file_exists($dest)) {
             if (!file_exists(App::configPath($configFile))) {
                 $this->reporter->message("Config file var/config/{$configFile} indicated in project.xml, does not exist", 'warning');
                 continue;
             }
             $this->reporter->message("Move var/config/{$configFile} to app/config/", 'notice');
             \jFile::createDir(dirname($dest));
             rename(App::configPath($configFile), $dest);
         }
         $config = parse_ini_file(App::appConfigPath($configFile), true);
         if (isset($config['urlengine']['significantFile'])) {
             $urlFile = $config['urlengine']['significantFile'];
             if (!file_exists(App::appConfigPath($urlFile)) && file_exists(App::configPath($urlFile))) {
                 $this->reporter->message("Move var/config/{$urlFile} to app/config/", 'notice');
                 rename(App::configPath($urlFile), App::appConfigPath($urlFile));
             }
         }
     }
     // move urls.xml to app/config
     $mainconfig = parse_ini_file(App::appConfigPath('mainconfig.ini.php'), true);
     if (isset($mainconfig['urlengine']['significantFile'])) {
         $urlFile = $mainconfig['urlengine']['significantFile'];
     } else {
         $urlFile = 'urls.xml';
     }
     if (!file_exists(App::appConfigPath($urlFile)) && file_exists(App::configPath($urlFile))) {
         $this->reporter->message("Move var/config/{$urlFile} to app/config/", 'notice');
         rename(App::configPath($urlFile), App::appConfigPath($urlFile));
     }
     $this->reporter->message('Migration to 1.7.0 is done', 'notice');
     if (!file_exists(App::appPath('app/responses'))) {
         $this->reporter->message("Move responses/ to app/responses/", 'notice');
         rename(App::appPath('responses'), App::appPath('app/responses'));
     }
 }
开发者ID:mdouchin,项目名称:jelix,代码行数:62,代码来源:Migration.php

示例12: saveAllFiles

 /**
  * save all uploaded file in the given directory
  * @param string $path path of the directory where to store the file. If it is not given,
  *                     it will be stored under the var/uploads/_modulename~formname_/ directory
  */
 public function saveAllFiles($path = '')
 {
     if ($path == '') {
         $path = JELIX_APP_VAR_PATH . 'uploads/' . $this->sel . '/';
     } else {
         if (substr($path, -1, 1) != '/') {
             $path .= '/';
         }
     }
     if (count($this->uploads)) {
         jFile::createDir($path);
     }
     foreach ($this->uploads as $ref => $ctrl) {
         if (!isset($_FILES[$ref]) || $_FILES[$ref]['error'] != UPLOAD_ERR_OK) {
             continue;
         }
         if ($ctrl->maxsize && $_FILES[$ref]['size'] > $ctrl->maxsize) {
             continue;
         }
         move_uploaded_file($_FILES[$ref]['tmp_name'], $path . $_FILES[$ref]['name']);
     }
 }
开发者ID:Calmacil,项目名称:ffdvh,代码行数:27,代码来源:jFormsBase.class.php

示例13: copyDirectoryContent

 /**
  * @param string $sourcePath
  * @param string $targetPath
  */
 static function copyDirectoryContent($sourcePath, $targetPath)
 {
     jFile::createDir($targetPath);
     $dir = new DirectoryIterator($sourcePath);
     foreach ($dir as $dirContent) {
         if ($dirContent->isFile()) {
             copy($dirContent->getPathName(), $targetPath . substr($dirContent->getPathName(), strlen($dirContent->getPath())));
         } else {
             if (!$dirContent->isDot() && $dirContent->isDir()) {
                 $newTarget = $targetPath . substr($dirContent->getPathName(), strlen($dirContent->getPath()));
                 $this->copyDirectoryContent($dirContent->getPathName(), $newTarget);
             }
         }
     }
 }
开发者ID:alienpham,项目名称:helenekling,代码行数:19,代码来源:jInstallerBase.class.php

示例14: __construct

 /**
  * initialize the installation
  *
  * it reads configurations files of all entry points, and prepare object for
  * each module, needed to install/upgrade modules.
  * @param ReporterInterface $reporter  object which is responsible to process messages (display, storage or other..)
  * @param string $lang  the language code for messages
  */
 function __construct(ReporterInterface $reporter, $lang = '')
 {
     $this->reporter = $reporter;
     $this->messages = new Checker\Messages($lang);
     $localConfig = App::configPath('localconfig.ini.php');
     if (!file_exists($localConfig)) {
         $localConfigDist = App::configPath('localconfig.ini.php.dist');
         if (file_exists($localConfigDist)) {
             copy($localConfigDist, $localConfig);
         } else {
             file_put_contents($localConfig, ';<' . '?php die(\'\');?' . '>');
         }
     }
     $this->mainConfig = new \Jelix\IniFile\MultiIniModifier(\Jelix\Core\Config::getDefaultConfigFile(), App::mainConfigFile());
     $this->localConfig = new \Jelix\IniFile\MultiIniModifier($this->mainConfig, $localConfig);
     $this->installerIni = $this->getInstallerIni();
     $urlfile = App::appConfigPath($this->localConfig->getValue('significantFile', 'urlengine'));
     $this->xmlMapFile = new \Jelix\Routing\UrlMapping\XmlMapModifier($urlfile, true);
     $appInfos = new \Jelix\Core\Infos\AppInfos();
     $this->readEntryPointsData($appInfos);
     $this->installerIni->save();
     // be sure temp path is ready
     $chmod = $this->mainConfig->getValue('chmodDir');
     \jFile::createDir(App::tempPath(), intval($chmod, 8));
 }
开发者ID:jelix,项目名称:jelix,代码行数:33,代码来源:Installer.php

示例15: copyFile

 /**
  * copy a file from the install/ directory to an other
  * @param string $relativeSourcePath relative path to the install/ directory of the file to copy
  * @param string $targetPath the full path where to copy the file
  */
 protected final function copyFile($relativeSourcePath, $targetPath, $overwrite = false)
 {
     $targetPath = $this->expandPath($targetPath);
     if (!$overwrite && file_exists($targetPath)) {
         return;
     }
     $dir = dirname($targetPath);
     \jFile::createDir($dir);
     copy($this->path . 'install/' . $relativeSourcePath, $targetPath);
 }
开发者ID:mdouchin,项目名称:jelix,代码行数:15,代码来源:AbstractInstaller.php


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