本文整理汇总了PHP中jFile类的典型用法代码示例。如果您正苦于以下问题:PHP jFile类的具体用法?PHP jFile怎么用?PHP jFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了jFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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']);
}
}
示例2: check
function check()
{
if (isset($_FILES[$this->ref])) {
$this->fileInfo = $_FILES[$this->ref];
} else {
$this->fileInfo = array('name' => '', 'type' => '', 'size' => 0, 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE);
}
if ($this->fileInfo['error'] == UPLOAD_ERR_NO_FILE) {
if ($this->required) {
return $this->container->errors[$this->ref] = jForms::ERRDATA_REQUIRED;
}
} else {
if ($this->fileInfo['error'] != UPLOAD_ERR_OK || !is_uploaded_file($this->fileInfo['tmp_name'])) {
return $this->container->errors[$this->ref] = jForms::ERRDATA_INVALID;
}
if ($this->maxsize && $this->fileInfo['size'] > $this->maxsize) {
return $this->container->errors[$this->ref] = jForms::ERRDATA_INVALID;
}
if (count($this->mimetype)) {
$this->fileInfo['type'] = jFile::getMimeType($this->fileInfo['tmp_name']);
if (!in_array($this->fileInfo['type'], $this->mimetype)) {
return $this->container->errors[$this->ref] = jForms::ERRDATA_INVALID;
}
}
}
return null;
}
示例3: 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);
}
}
}
示例4: _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);
}
}
}
示例5: compile
public function compile($selector)
{
$sel = clone $selector;
$this->sourceFile = $selector->getPath();
// load XML file
$doc = new DOMDocument();
if (!$doc->load($this->sourceFile)) {
throw new jException('jelix~formserr.invalid.xml.file', array($this->sourceFile));
}
if ($doc->documentElement->namespaceURI == JELIX_NAMESPACE_BASE . 'forms/1.0') {
require_once JELIX_LIB_PATH . 'forms/jFormsCompiler_jf_1_0.class.php';
$compiler = new jFormsCompiler_jf_1_0($this->sourceFile);
} elseif ($doc->documentElement->namespaceURI == JELIX_NAMESPACE_BASE . 'forms/1.1') {
if ($doc->documentElement->localName != 'form') {
throw new jException('jelix~formserr.bad.root.tag', array($doc->documentElement->localName, $this->sourceFile));
}
require_once JELIX_LIB_PATH . 'forms/jFormsCompiler_jf_1_1.class.php';
$compiler = new jFormsCompiler_jf_1_1($this->sourceFile);
} else {
throw new jException('jelix~formserr.namespace.wrong', array($this->sourceFile));
}
$source = array();
$source[] = "<?php \nif (jApp::config()->compilation['checkCacheFiletime'] &&\n";
$source[] .= "filemtime('" . $this->sourceFile . '\') > ' . filemtime($this->sourceFile) . "){ return false;\n}else{\n";
$source[] = 'class ' . $selector->getClass() . ' extends jFormsBase {';
$source[] = ' public function __construct($sel, &$container, $reset = false){';
$source[] = ' parent::__construct($sel, $container, $reset);';
$compiler->compile($doc, $source);
$source[] = " }\n}\n return true;}";
jFile::write($selector->getCompiledFilePath(), implode("\n", $source));
return true;
}
示例6: compile
/**
* Launch the compilation of a template
*
* Store the result (a php content) into a cache file given by the selector.
* @param jSelectorTpl $selector the template selector
* @return boolean true if ok
*/
public function compile($selector)
{
$this->_sourceFile = $selector->getPath();
$cachefile = $selector->getCompiledFilePath();
$this->outputType = $selector->outputType;
$this->trusted = $selector->trusted;
$this->_modifier = array_merge($this->_modifier, $selector->userModifiers);
$this->_userFunctions = $selector->userFunctions;
jContext::push($selector->module);
if (!file_exists($this->_sourceFile)) {
$this->doError0('errors.tpl.not.found');
}
$result = $this->compileContent(file_get_contents($this->_sourceFile));
$header = "<?php \n";
foreach ($this->_pluginPath as $path => $ok) {
$header .= ' require_once(\'' . $path . "');\n";
}
$header .= 'function template_meta_' . md5($selector->module . '_' . $selector->resource . '_' . $this->outputType . ($this->trusted ? '_t' : '')) . '($t){';
$header .= "\n" . $this->_metaBody . "\n}\n";
$header .= 'function template_' . md5($selector->module . '_' . $selector->resource . '_' . $this->outputType . ($this->trusted ? '_t' : '')) . '($t){' . "\n?>";
$result = $header . $result . "<?php \n}\n?>";
jFile::write($cachefile, $result);
jContext::pop();
return true;
}
示例7: run
public function run()
{
try {
$tempPath = jApp::tempBasePath();
if ($tempPath == DIRECTORY_SEPARATOR || $tempPath == '' || $tempPath == '/') {
echo "Error: bad path in jApp::tempBasePath(), it is equals to '" . $tempPath . "' !!\n";
echo " Jelix cannot clear the content of the temp directory.\n";
echo " Correct the path in your application.init.php or create the corresponding directory\n";
exit(1);
}
if (!jFile::removeDir($tempPath, false, array('.svn', '.dummy'))) {
echo "Some temp files were not removed\n";
} else {
if ($this->verbose()) {
echo "All temp files have been removed\n";
}
}
} catch (Exception $e) {
if ($this->config->helpLang == 'fr') {
echo "Un ou plusieurs répertoires n'ont pas pu être supprimés.\n" . "Message d'erreur : " . $e->getMessage() . "\n";
} else {
echo "One or more directories couldn't be deleted.\n" . "Error: " . $e->getMessage() . "\n";
}
}
}
示例8: compile
public function compile($selector)
{
global $gJCoord;
global $gJConfig;
$sel = clone $selector;
$this->sourceFile = $selector->getPath();
// chargement du fichier XML
$doc = new DOMDocument();
if (!$doc->load($this->sourceFile)) {
throw new jException('jelix~formserr.invalid.xml.file', array($this->sourceFile));
}
if ($doc->documentElement->namespaceURI == JELIX_NAMESPACE_BASE . 'forms/1.0') {
require_once JELIX_LIB_PATH . 'forms/jFormsCompiler_jf_1_0.class.php';
$compiler = new jFormsCompiler_jf_1_0($this->sourceFile);
} elseif ($doc->documentElement->namespaceURI == JELIX_NAMESPACE_BASE . 'forms/1.1') {
if ($doc->documentElement->localName != 'form') {
throw new jException('jelix~formserr.bad.root.tag', array($doc->documentElement->localName, $this->sourceFile));
}
require_once JELIX_LIB_PATH . 'forms/jFormsCompiler_jf_1_1.class.php';
$compiler = new jFormsCompiler_jf_1_1($this->sourceFile);
} else {
throw new jException('jelix~formserr.namespace.wrong', array($this->sourceFile));
}
$source = array();
$source[] = '<?php ';
$source[] = 'class ' . $selector->getClass() . ' extends jFormsBase {';
$source[] = ' public function __construct($sel, &$container, $reset = false){';
$source[] = ' parent::__construct($sel, $container, $reset);';
$compiler->compile($doc, $source);
$source[] = " }\n} ?>";
jFile::write($selector->getCompiledFilePath(), implode("\n", $source));
return true;
}
示例9: atStart
function atStart($config)
{
if ($config->sessions['storage'] == 'files') {
$config->sessions['files_path'] = jFile::parseJelixPath($config->sessions['files_path']);
}
$config->sessions['_class_to_load'] = array();
if ($config->sessions['loadClasses'] != '') {
trigger_error("Configuration: loadClasses is deprecated, use instead autoload configuration in jelix-module.json or module.xml files", E_USER_NOTICE);
$list = preg_split('/ *, */', $config->sessions['loadClasses']);
foreach ($list as $sel) {
if (preg_match("/^([a-zA-Z0-9_\\.]+)~([a-zA-Z0-9_\\.\\/]+)\$/", $sel, $m)) {
if (!isset($config->_modulesPathList[$m[1]])) {
throw new Exception('Error in the configuration file -- in loadClasses parameter, ' . $m[1] . ' is not a valid or activated module');
}
if (($p = strrpos($m[2], '/')) !== false) {
$className = substr($m[2], $p + 1);
$subpath = substr($m[2], 0, $p + 1);
} else {
$className = $m[2];
$subpath = '';
}
$path = $config->_modulesPathList[$m[1]] . 'classes/' . $subpath . $className . '.class.php';
if (!file_exists($path) || strpos($subpath, '..') !== false) {
throw new Exception('Error in the configuration file -- in loadClasses parameter, bad class selector: ' . $sel);
}
$config->sessions['_class_to_load'][] = $path;
} else {
throw new Exception('Error in the configuration file -- in loadClasses parameter, bad class selector: ' . $sel);
}
}
}
}
示例10: compile
/**
* compile the given class id.
*/
public function compile($selector)
{
jDaoCompiler::$daoId = $selector->toString();
jDaoCompiler::$daoPath = $selector->getPath();
jDaoCompiler::$dbType = $selector->driver;
// chargement du fichier XML
$doc = new DOMDocument();
if (!$doc->load(jDaoCompiler::$daoPath)) {
throw new jException('jelix~daoxml.file.unknow', jDaoCompiler::$daoPath);
}
if ($doc->documentElement->namespaceURI != JELIX_NAMESPACE_BASE . 'dao/1.0') {
throw new jException('jelix~daoxml.namespace.wrong', array(jDaoCompiler::$daoPath, $doc->namespaceURI));
}
$parser = new jDaoParser();
$parser->parse(simplexml_import_dom($doc));
global $gJConfig;
if (!isset($gJConfig->_pluginsPathList_db[$selector->driver]) || !file_exists($gJConfig->_pluginsPathList_db[$selector->driver])) {
throw new jException('jelix~db.error.driver.notfound', $selector->driver);
}
require_once $gJConfig->_pluginsPathList_db[$selector->driver] . $selector->driver . '.daobuilder.php';
$class = $selector->driver . 'DaoBuilder';
$generator = new $class($selector->getDaoClass(), $selector->getDaoRecordClass(), $parser);
// génération des classes PHP correspondant à la définition de la DAO
$compiled = '<?php ' . $generator->buildClasses() . "\n?>";
jFile::write($selector->getCompiledFilePath(), $compiled);
return true;
}
示例11: check
function check()
{
if (isset($_FILES[$this->ref])) {
$this->fileInfo = $_FILES[$this->ref];
} else {
$this->fileInfo = array('name' => '', 'type' => '', 'size' => 0, 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE);
}
if ($this->fileInfo['error'] == UPLOAD_ERR_NO_FILE) {
if ($this->required) {
return $this->container->errors[$this->ref] = jForms::ERRDATA_REQUIRED;
}
} else {
if ($this->fileInfo['error'] == UPLOAD_ERR_NO_TMP_DIR || $this->fileInfo['error'] == UPLOAD_ERR_CANT_WRITE) {
return $this->container->errors[$this->ref] = jForms::ERRDATA_FILE_UPLOAD_ERROR;
}
if ($this->fileInfo['error'] == UPLOAD_ERR_INI_SIZE || $this->fileInfo['error'] == UPLOAD_ERR_FORM_SIZE || $this->maxsize && $this->fileInfo['size'] > $this->maxsize) {
return $this->container->errors[$this->ref] = jForms::ERRDATA_INVALID_FILE_SIZE;
}
if ($this->fileInfo['error'] == UPLOAD_ERR_PARTIAL || !is_uploaded_file($this->fileInfo['tmp_name'])) {
return $this->container->errors[$this->ref] = jForms::ERRDATA_INVALID;
}
if (count($this->mimetype)) {
$this->fileInfo['type'] = jFile::getMimeType($this->fileInfo['tmp_name']);
if ($this->fileInfo['type'] == 'application/octet-stream') {
// let's try with the name
$this->fileInfo['type'] = jFile::getMimeTypeFromFilename($this->fileInfo['name']);
}
if (!in_array($this->fileInfo['type'], $this->mimetype)) {
return $this->container->errors[$this->ref] = jForms::ERRDATA_INVALID_FILE_TYPE;
}
}
}
return null;
}
示例12: 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;
}
示例13: 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);
}
}
示例14: clear
function clear()
{
$confirm = $this->param('confirm');
if ($confirm == 'Y') {
jFile::removeDir(jApp::tempPath(), false);
jMessage::add(jLocale::get('jelixcache~jelixcache.cache.clear.done'));
} else {
jMessage::add(jLocale::get('jelixcache~jelixcache.cache.clear.canceled'));
}
$rep = $this->getResponse('redirect');
$rep->action = 'jelixcache~default:index';
return $rep;
}
示例15: useit
/**
* Let use one of the available theme
*/
function useit()
{
$theme = (string) $this->param('theme');
$mainConfig = new jIniFileModifier(jApp::configPath() . 'defaultconfig.ini.php');
$mainConfig->setValue('theme', strtolower($theme));
$mainConfig->setValue('datepicker', strtolower($theme), 'forms');
$mainConfig->save();
jFile::removeDir(jApp::tempPath(), false);
jMessage::add(jLocale::get('theme.selected'), 'information');
$rep = $this->getResponse('redirect');
$rep->action = 'default:index';
return $rep;
}